Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
"test:slow": "xvfb-maybe vitest run --project slow",
"test:verdaccio": "tsx tools/verdaccio/spawn-verdaccio.ts xvfb-maybe vitest run --project slow-verdaccio",
"test:clear": "tsx tools/test-clear",
"update:lockfile-fixtures": "tsx tools/regenerate-lockfile-fixtures.ts",
"postinstall": "husky install && node -e \"try { fs.rmSync('node_modules/.bin/*.ps1', { recursive: true, force: true }) } catch (e) {}\" && tsx ./tools/gen-tsconfigs.ts && tsx ./tools/gen-ts-glue.ts"
},
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import { afterAll, beforeAll, describe, expect, it } from 'vitest';

// eslint-disable-next-line n/no-missing-import
import { api } from '../../../api/core/dist/api';
import { initLink } from '../../../api/core/src/api/init-scripts/init-link';

describe('ViteTypeScriptTemplate', () => {
let dir: string;
Expand Down Expand Up @@ -85,59 +84,6 @@ describe('ViteTypeScriptTemplate', () => {
// Vite resolves plugins via cwd
cwd = process.cwd();
process.chdir(dir);
/**
* LOCKFILE FIXTURE USAGE:
* We use a pre-generated lockfile to avoid needing to disable Yarn's security features.
*
* When to regenerate the fixture:
* - When vite version is updated in Forge's package.json
* - When template dependencies change significantly
* - When Yarn lockfile format changes
* - When this test starts failing due to dependency resolution issues
*
* How to regenerate:
* Run: yarn update:lockfile-fixtures
*
* This will create a new lockfile with the correct vite resolution and dependencies.
*/
// Copy pre-generated lockfile and update the project name
const fixtureLockfile = path.join(
__dirname,
'fixtures',
'test-yarn.lock',
);
const targetLockfile = path.join(dir, 'yarn.lock');
let lockfileContent = await fs.promises.readFile(
fixtureLockfile,
'utf-8',
);

// Get the current project name from package.json
const currentPackageJson = JSON.parse(
await fs.promises.readFile(path.join(dir, 'package.json'), 'utf-8'),
);
const projectName = currentPackageJson.name;

// Replace the fixture project name with the actual project name
lockfileContent = lockfileContent.replace(
/electron-forge-test-\d+/g,
projectName,
);
await fs.promises.writeFile(targetLockfile, lockfileContent);

// Install with immutable lockfile (no modifications needed)
await spawnPackageManager(
PACKAGE_MANAGERS['yarn'],
['install', '--immutable'],
{
cwd: dir,
},
);

// Installing deps removes symlinks that were added at the start of this
// spec via `api.init`. So we should re-link local forge dependencies
// again.
await initLink(PACKAGE_MANAGERS['yarn'], dir);
});

afterAll(() => {
Expand Down
Loading
Loading