Updated create-app to use Yarn 4

Signed-off-by: Andre Wanlin <awanlin@spotify.com>
This commit is contained in:
Andre Wanlin
2024-09-10 19:06:50 -05:00
parent f094dfd54a
commit 4975e634f4
9 changed files with 946 additions and 45 deletions
-21
View File
@@ -227,27 +227,6 @@ describe('tasks', () => {
);
});
it('should error out on incorrect yarn version', async () => {
// requires callback implementation to support `promisify` wrapper
// https://stackoverflow.com/a/60579617/10044859
mockExec.mockImplementation((_command, callback) => {
callback(null, { stdout: '3.2.1', stderr: 'standard error' });
});
const appDir = 'projects/dir';
await expect(buildAppTask(appDir)).rejects.toThrow(
/^@backstage\/create-app requires Yarn v1, found '3\.2\.1'/,
);
expect(mockChdir).toHaveBeenCalledTimes(1);
expect(mockChdir).toHaveBeenNthCalledWith(1, appDir);
expect(mockExec).toHaveBeenCalledTimes(1);
expect(mockExec).toHaveBeenNthCalledWith(
1,
'yarn --version',
expect.any(Function),
);
});
it('should fail if project directory does not exist', async () => {
const appDir = 'projects/missingProject';
await expect(buildAppTask(appDir)).rejects.toThrow(
-11
View File
@@ -187,17 +187,6 @@ export async function checkPathExistsTask(path: string) {
export async function buildAppTask(appDir: string) {
process.chdir(appDir);
await Task.forItem('determining', 'yarn version', async () => {
const result = await exec('yarn --version');
const yarnVersion = result.stdout?.trim();
if (yarnVersion && !yarnVersion.startsWith('1.')) {
throw new Error(
`@backstage/create-app requires Yarn v1, found '${yarnVersion}'. You can migrate the project to Yarn 3 after creation using https://backstage.io/docs/tutorials/yarn-migration`,
);
}
});
const runCmd = async (cmd: string) => {
await Task.forItem('executing', cmd, async () => {
await exec(cmd).catch(error => {