mirror of
https://github.com/storybookjs/storybook.git
synced 2025-03-16 05:03:11 +08:00
32 lines
1.3 KiB
JavaScript
32 lines
1.3 KiB
JavaScript
/**
|
|
* This script is used to copy the resolutions from the root package.json to the sandbox package.json.
|
|
* This is necessary because the sandbox package.json is used to run the tests and the resolutions are needed to run the tests.
|
|
* The vite-ecosystem-ci, though, sets the resolutions in the root package.json.
|
|
*/
|
|
import fs from 'fs';
|
|
import path from 'path';
|
|
import { fileURLToPath } from 'url';
|
|
import { execaCommand, execa } from 'execa';
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
|
const dirname = path.dirname(filename);
|
|
|
|
const rootPackageJsonPath = path.resolve(dirname, '../../package.json');
|
|
const sandboxPackageJsonPath = path.resolve(
|
|
dirname,
|
|
'../../sandbox/react-vite-default-ts/package.json'
|
|
);
|
|
|
|
const rootPackageJson = JSON.parse(await fs.promises.readFile(rootPackageJsonPath, 'utf-8'));
|
|
const sandboxPackageJson = JSON.parse(await fs.promises.readFile(sandboxPackageJsonPath, 'utf-8'));
|
|
|
|
sandboxPackageJson.resolutions = {
|
|
...(sandboxPackageJson.resolutions ?? {}),
|
|
...rootPackageJson.resolutions,
|
|
};
|
|
|
|
await fs.promises.writeFile(sandboxPackageJsonPath, JSON.stringify(sandboxPackageJson, null, 2));
|
|
const sandboxFolder = path.dirname(sandboxPackageJsonPath);
|
|
await execa('yarn add playwright', { cwd: sandboxFolder, shell: true });
|
|
await execaCommand('yarn playwright install', { cwd: sandboxFolder, shell: true });
|