Skip to content

Commit

Permalink
fix: legacy suffix warning in the correct place
Browse files Browse the repository at this point in the history
  • Loading branch information
mshanemc committed Apr 30, 2024
1 parent 5a6e5fa commit 9426b45
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/resolve/metadataResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -392,22 +392,29 @@ const resolveTypeFromStrictFolder =

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

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

const legacySuffixMatches = (type: MetadataType, fsPath: string): boolean => {
if (
typeof type.legacySuffix === 'string' &&
(fsPath.endsWith(type.legacySuffix) || fsPath.endsWith(appendMetaXmlSuffix(type.legacySuffix)))
) {
void Lifecycle.getInstance().emitWarning(
`The ${type.name} component at ${fsPath} uses the legacy suffix ${type.legacySuffix}. This suffix is deprecated and will be removed in a future release.`
);
return true;
}
return false;
};
const appendMetaXmlSuffix = (suffix: string): string => `${suffix}${META_XML_SUFFIX}`;

const getSuffixes = (type: MetadataType): string[] => [
...(type.suffix ? [type.suffix] : []),
...(type.legacySuffix ? [type.legacySuffix] : []),
];

const isMixedContentOrBundle = (type: MetadataType): boolean =>
typeof type.strategies?.adapter === 'string' && ['mixedContent', 'bundle'].includes(type.strategies.adapter);

Expand Down

2 comments on commit 9426b45

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 9426b45 Previous: 40b6eef Ratio
eda-componentSetCreate-linux 176 ms 178 ms 0.99
eda-sourceToMdapi-linux 2842 ms 1949 ms 1.46
eda-sourceToZip-linux 1378 ms 1409 ms 0.98
eda-mdapiToSource-linux 2801 ms 2917 ms 0.96
lotsOfClasses-componentSetCreate-linux 389 ms 365 ms 1.07
lotsOfClasses-sourceToMdapi-linux 3827 ms 3706 ms 1.03
lotsOfClasses-sourceToZip-linux 3133 ms 3064 ms 1.02
lotsOfClasses-mdapiToSource-linux 3578 ms 3496 ms 1.02
lotsOfClassesOneDir-componentSetCreate-linux 630 ms 629 ms 1.00
lotsOfClassesOneDir-sourceToMdapi-linux 7518 ms 6549 ms 1.15
lotsOfClassesOneDir-sourceToZip-linux 5827 ms 5825 ms 1.00
lotsOfClassesOneDir-mdapiToSource-linux 6484 ms 6425 ms 1.01

This comment was automatically generated by workflow using github-action-benchmark.

@svc-cli-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 9426b45 Previous: 40b6eef Ratio
eda-componentSetCreate-win32 384 ms 379 ms 1.01
eda-sourceToMdapi-win32 3504 ms 3456 ms 1.01
eda-sourceToZip-win32 2146 ms 2151 ms 1.00
eda-mdapiToSource-win32 5768 ms 5614 ms 1.03
lotsOfClasses-componentSetCreate-win32 842 ms 826 ms 1.02
lotsOfClasses-sourceToMdapi-win32 7773 ms 7460 ms 1.04
lotsOfClasses-sourceToZip-win32 4834 ms 4606 ms 1.05
lotsOfClasses-mdapiToSource-win32 7636 ms 7411 ms 1.03
lotsOfClassesOneDir-componentSetCreate-win32 1517 ms 1482 ms 1.02
lotsOfClassesOneDir-sourceToMdapi-win32 14019 ms 13684 ms 1.02
lotsOfClassesOneDir-sourceToZip-win32 8804 ms 8525 ms 1.03
lotsOfClassesOneDir-mdapiToSource-win32 13873 ms 13554 ms 1.02

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.