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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ packages/**/.swc
.webpack
packages/api/core/spec/fixture/app-with-scoped-name/out/make
packages/plugin/webpack/spec/fixtures/apps/native-modules/package-lock.json
packages/plugin/fuses/spec/fixture/app
packages/plugin/fuses/spec/fixture/out
.links
reports
packages/**/typedoc.json
Expand Down
40 changes: 12 additions & 28 deletions packages/plugin/fuses/spec/FusesPlugin.slow.spec.ts
Original file line number Diff line number Diff line change
@@ -1,59 +1,43 @@
import fs from 'node:fs';
import path from 'node:path';

import { PACKAGE_MANAGERS } from '@electron-forge/core-utils';
import { CrossSpawnOptions, spawn } from '@malept/cross-spawn-promise';
import { afterAll, beforeAll, describe, expect, it } from 'vitest';
import { spawn } from '@malept/cross-spawn-promise';
import { afterAll, describe, expect, it } from 'vitest';

import { initLink } from '../../../api/core/src/api/init-scripts/init-link';
import packageAPI from '../../../api/core/src/api/package';
import { getElectronExecutablePath } from '../src/util/getElectronExecutablePath';

describe('FusesPlugin', () => {
const appPath = path.join(__dirname, 'fixture', 'app');

const spawnOptions: CrossSpawnOptions = {
cwd: appPath,
shell: true,
};
const appPath = path.join(__dirname, 'fixture');

const packageJSON = JSON.parse(
fs.readFileSync(path.join(appPath, 'package.json.tmpl'), {
fs.readFileSync(path.join(appPath, 'package.json'), {
encoding: 'utf-8',
}),
);

const { name: appName } = packageJSON;

const outDir = path.join(appPath, 'out', 'fuses-test-app');

beforeAll(async () => {
delete process.env.TS_NODE_PROJECT;
await fs.promises.copyFile(
path.join(appPath, 'package.json.tmpl'),
path.join(appPath, 'package.json'),
);

// Use initLink to set up dependencies with local forge packages
// This will copy .yarnrc.yml, link local packages, and run install
process.env.LINK_FORGE_DEPENDENCIES_ON_INIT = '1';
await initLink(PACKAGE_MANAGERS['yarn'], appPath);
delete process.env.LINK_FORGE_DEPENDENCIES_ON_INIT;
});
const outDir = path.join(appPath, 'out');

afterAll(async () => {
await fs.promises.rm(path.resolve(outDir, '../'), {
await fs.promises.rm(outDir, {
recursive: true,
force: true,
});
});

it('should flip Fuses', async () => {
await spawn('yarn', ['package'], spawnOptions);
await packageAPI({
dir: appPath,
interactive: false,
});

const electronExecutablePath = getElectronExecutablePath({
appName,
basePath: path.join(
outDir,
'fuses-test-app',
...(process.platform === 'darwin'
? [`${appName}.app`, 'Contents']
: []),
Expand Down
9 changes: 9 additions & 0 deletions packages/plugin/fuses/spec/fixture/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
nodeLinker: node-modules

npmMinimalAgeGate: 10080

npmPreapprovedPackages:
- '@electron/*'
- '@electron-forge/*'
- electron
- node-abi
18 changes: 0 additions & 18 deletions packages/plugin/fuses/spec/fixture/app/package.json

This file was deleted.

18 changes: 0 additions & 18 deletions packages/plugin/fuses/spec/fixture/app/package.json.tmpl

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
import path from 'path';

import { FuseV1Options, FuseVersion } from '@electron/fuses';
import { FusesPlugin } from '@electron-forge/plugin-fuses';
import { ForgeConfig } from '@electron-forge/shared-types';
import fsExtra from 'fs-extra';

import { ForgeConfig } from '../../../../utils/types/src/index';
import { FusesPlugin } from '../../src/FusesPlugin';

const forgeConfig: ForgeConfig = {
packagerConfig: {
afterComplete: [
// makes tests a bit simpler by having a single output directory in every platform/arch
async (packagedAppLocation, _electronVersion, _targetPlatform, _targetArch, done) => {
async (
packagedAppLocation,
_electronVersion,
_targetPlatform,
_targetArch,
done,
) => {
const parentDir = path.resolve(packagedAppLocation, '..');
await fsExtra.move(packagedAppLocation, path.join(parentDir, 'fuses-test-app'), {
overwrite: true,
});
await fsExtra.move(
packagedAppLocation,
path.join(parentDir, 'fuses-test-app'),
{
overwrite: true,
},
);

done();
},
Expand Down
13 changes: 13 additions & 0 deletions packages/plugin/fuses/spec/fixture/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "fuses-test-app",
"version": "1.0.0",
"main": "./src/main.js",
"dependencies": {
"@electron/fuses": "^1.6.1",
"fs-extra": "^10.0.0"
},
"devDependencies": {
"electron": "39.2.3",
"@electron-forge/core": "portal:../../../../api/core"
}
}
Loading