Updated create-app to use Yarn 4
Signed-off-by: Andre Wanlin <awanlin@spotify.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user