2024-06-03 13:14:57 +02:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2024-08-10 20:44:33 +02:00
|
|
|
import { dirname, resolve } from 'node:path';
|
|
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
|
|
|
|
2024-08-09 19:46:49 +02:00
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
|
|
|
import { execa, execaCommand } from 'execa';
|
2024-06-03 13:14:57 +02:00
|
|
|
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
2024-08-10 20:44:33 +02:00
|
|
|
const dirname = dirname(filename);
|
2024-06-03 13:14:57 +02:00
|
|
|
|
2024-08-10 20:44:33 +02:00
|
|
|
const rootPackageJsonPath = resolve(dirname, '../../package.json');
|
|
|
|
const sandboxPackageJsonPath = resolve(dirname, '../../sandbox/react-vite-default-ts/package.json');
|
2024-06-03 13:14:57 +02:00
|
|
|
|
2024-08-10 20:44:33 +02:00
|
|
|
const rootPackageJson = JSON.parse(await readFile(rootPackageJsonPath, 'utf-8'));
|
|
|
|
const sandboxPackageJson = JSON.parse(await readFile(sandboxPackageJsonPath, 'utf-8'));
|
2024-06-03 13:14:57 +02:00
|
|
|
|
|
|
|
sandboxPackageJson.resolutions = {
|
|
|
|
...(sandboxPackageJson.resolutions ?? {}),
|
|
|
|
...rootPackageJson.resolutions,
|
|
|
|
};
|
|
|
|
|
2024-08-10 20:44:33 +02:00
|
|
|
await writeFile(sandboxPackageJsonPath, JSON.stringify(sandboxPackageJson, null, 2));
|
|
|
|
const sandboxFolder = dirname(sandboxPackageJsonPath);
|
2024-08-08 10:19:44 +02:00
|
|
|
await execa('yarn add playwright', { cwd: sandboxFolder, shell: true });
|
|
|
|
await execaCommand('yarn playwright install', { cwd: sandboxFolder, shell: true });
|