Skip to content

Commit baeb68f

Browse files
authored
fix: yarn classic Command "tsc" not found (#1033)
* fix yarn classic and test * add changeset * move env to execaCommand option * fix unit test
1 parent 7eedb02 commit baeb68f

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

.changeset/giant-feet-sing.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/cli-core': patch
3+
---
4+
5+
fix yarn classic error Command "tsc" not found.

packages/cli-core/src/package-manager-controller/yarn_classic_package_manager_controller.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ void describe('YarnClassicPackageManagerController', () => {
138138
existsSyncMock
139139
);
140140
await yarnClassicPackageManagerController.initializeTsConfig('./amplify');
141-
assert.equal(executeWithDebugLoggerMock.mock.callCount(), 1);
141+
assert.equal(executeWithDebugLoggerMock.mock.callCount(), 2);
142142
});
143143
});
144144
});

packages/cli-core/src/package-manager-controller/yarn_classic_package_manager_controller.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,18 @@ export class YarnClassicPackageManagerController extends PackageManagerControlle
3333
existsSync
3434
);
3535
}
36+
37+
initializeTsConfig = async (targetDir: string) => {
38+
await this.addTypescript(targetDir);
39+
await super.initializeTsConfig(targetDir);
40+
};
41+
42+
private addTypescript = async (targetDir: string) => {
43+
await this.executeWithDebugLogger(
44+
targetDir,
45+
'yarn',
46+
['add', 'typescript@^5'],
47+
this.execa
48+
);
49+
};
3650
}

packages/integration-tests/src/package_manager_sanity_checks.test.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,6 @@ void describe('getting started happy path', async () => {
4343
});
4444

4545
after(async () => {
46-
// TODO: remove the condition once GA https://github.com/aws-amplify/amplify-backend/issues/1013
47-
// create-amplify has been installed globally, we need to remove it before running `setup:local`
48-
if (packageManager === 'yarn-classic') {
49-
await execa('yarn', ['global', 'remove', 'create-amplify']);
50-
}
5146
// stop the npm proxy
5247
await execa('npm', ['install'], { stdio: 'inherit' }); // add tsx back since we removed all the binaries
5348
await execa('npm', ['run', 'stop:npm-proxy'], { stdio: 'inherit' });
@@ -81,13 +76,11 @@ void describe('getting started happy path', async () => {
8176
void it('creates new project and deploy them without an error', async () => {
8277
// TODO: remove the condition once GA https://github.com/aws-amplify/amplify-backend/issues/1013
8378
if (packageManager === 'yarn-classic') {
84-
await execa('yarn', ['global', 'add', 'create-amplify@beta']);
85-
process.env.npm_config_user_agent = 'yarn/1.22.21';
86-
await runPackageManager(
87-
packageManager,
88-
['create', 'amplify', '--yes'],
89-
tempDir
90-
).run();
79+
await execa('yarn', ['add', 'create-amplify@beta'], { cwd: tempDir });
80+
await execaCommand('./node_modules/.bin/create-amplify --yes --debug', {
81+
cwd: tempDir,
82+
env: { npm_config_user_agent: 'yarn/1.22.21' },
83+
});
9184
} else {
9285
await runPackageManager(
9386
packageManager,

0 commit comments

Comments
 (0)