Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Do not use modern TS assets in legacy TS projects #20458

Merged
merged 9 commits into from
Feb 13, 2023
14 changes: 8 additions & 6 deletions code/lib/cli/src/helpers.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,14 @@ describe('Helpers', () => {
});

it.each`
language | exists | expected
${'javascript'} | ${['js', 'ts']} | ${'/js'}
${'typescript'} | ${['js', 'ts']} | ${'/ts'}
${'typescript'} | ${['js']} | ${'/js'}
${'javascript'} | ${[]} | ${''}
${'typescript'} | ${[]} | ${''}
language | exists | expected
${'javascript'} | ${['js', 'ts']} | ${'/js'}
${'typescript'} | ${['js', 'ts']} | ${'/ts'}
${'typescript-legacy'} | ${['js', 'ts', 'ts-legacy']} | ${'/ts-legacy'}
${'typescript-legacy'} | ${['js', 'ts']} | ${'/js'}
${'typescript'} | ${['js']} | ${'/js'}
${'javascript'} | ${[]} | ${''}
${'typescript'} | ${[]} | ${''}
`(
`should copy $expected when folder $exists exists for language $language`,
async ({ language, exists, expected }) => {
Expand Down
5 changes: 1 addition & 4 deletions code/lib/cli/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,17 +205,14 @@ export async function copyComponents(
assetsDir,
languageFolderMapping[SupportedLanguage.TYPESCRIPT_LEGACY]
);
const assetsTS = join(assetsDir, languageFolderMapping[SupportedLanguage.TYPESCRIPT]);

if (await fse.pathExists(assetsLanguage)) {
return assetsLanguage;
}
// Use fallback legacy typescript assets if new ones aren't available
if (language === SupportedLanguage.TYPESCRIPT && (await fse.pathExists(assetsTSLegacy))) {
return assetsTSLegacy;
}
if (language === SupportedLanguage.TYPESCRIPT_LEGACY && (await fse.pathExists(assetsTS))) {
return assetsTS;
}
if (await fse.pathExists(assetsJS)) {
return assetsJS;
}
Expand Down