2024-06-03 13:14:57 +02:00
|
|
|
/**
|
2024-08-15 10:26:24 +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-06-03 13:14:57 +02:00
|
|
|
*/
|
2024-08-10 20:44:33 +02:00
|
|
|
import { readFile, writeFile } from 'node:fs/promises';
|
2024-08-12 15:47:48 +02:00
|
|
|
import { dirname, resolve } from 'node:path';
|
2024-08-09 19:46:49 +02:00
|
|
|
import { fileURLToPath } from 'node:url';
|
|
|
|
|
2024-10-02 17:07:43 +02:00
|
|
|
// eslint-disable-next-line depend/ban-dependencies
|
|
|
|
import { execaCommand } from 'execa';
|
2024-06-03 13:14:57 +02:00
|
|
|
|
|
|
|
const filename = fileURLToPath(import.meta.url);
|
2024-08-12 15:47:48 +02:00
|
|
|
// eslint-disable-next-line no-underscore-dangle, @typescript-eslint/naming-convention
|
|
|
|
const __dirname = dirname(filename);
|
2024-06-03 13:14:57 +02:00
|
|
|
|
2024-08-12 15:47:48 +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-12 15:47:48 +02:00
|
|
|
|
|
|
|
await execaCommand('yarn add playwright', { cwd: sandboxFolder, shell: true });
|
2024-08-08 10:19:44 +02:00
|
|
|
await execaCommand('yarn playwright install', { cwd: sandboxFolder, shell: true });
|