Skip to content

Commit 9426b45

Browse files
committed
fix: legacy suffix warning in the correct place
1 parent 5a6e5fa commit 9426b45

File tree

1 file changed

+17
-10
lines changed

1 file changed

+17
-10
lines changed

src/resolve/metadataResolver.ts

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -392,22 +392,29 @@ const resolveTypeFromStrictFolder =
392392

393393
/** the type has children and the file suffix (in source format) matches a child type suffix of the type we think it is */
394394
const childSuffixMatches = (type: MetadataType, fsPath: string): boolean =>
395-
Object.values(type.children?.types ?? {})
396-
.flatMap(getSuffixes)
397-
.map(appendMetaXmlSuffix)
398-
.some((s) => fsPath.endsWith(s));
395+
Object.values(type.children?.types ?? {}).some(
396+
(childType) => suffixMatches(childType, fsPath) || legacySuffixMatches(childType, fsPath)
397+
);
399398

400399
/** the file suffix (in source or mdapi format) matches the type suffix we think it is */
401400
const suffixMatches = (type: MetadataType, fsPath: string): boolean =>
402-
[...getSuffixes(type), ...getSuffixes(type).map(appendMetaXmlSuffix)].some((s) => fsPath.endsWith(s));
401+
typeof type.suffix === 'string' &&
402+
(fsPath.endsWith(type.suffix) || fsPath.endsWith(appendMetaXmlSuffix(type.suffix)));
403403

404+
const legacySuffixMatches = (type: MetadataType, fsPath: string): boolean => {
405+
if (
406+
typeof type.legacySuffix === 'string' &&
407+
(fsPath.endsWith(type.legacySuffix) || fsPath.endsWith(appendMetaXmlSuffix(type.legacySuffix)))
408+
) {
409+
void Lifecycle.getInstance().emitWarning(
410+
`The ${type.name} component at ${fsPath} uses the legacy suffix ${type.legacySuffix}. This suffix is deprecated and will be removed in a future release.`
411+
);
412+
return true;
413+
}
414+
return false;
415+
};
404416
const appendMetaXmlSuffix = (suffix: string): string => `${suffix}${META_XML_SUFFIX}`;
405417

406-
const getSuffixes = (type: MetadataType): string[] => [
407-
...(type.suffix ? [type.suffix] : []),
408-
...(type.legacySuffix ? [type.legacySuffix] : []),
409-
];
410-
411418
const isMixedContentOrBundle = (type: MetadataType): boolean =>
412419
typeof type.strategies?.adapter === 'string' && ['mixedContent', 'bundle'].includes(type.strategies.adapter);
413420

0 commit comments

Comments
 (0)