Skip to content

Commit 4d44845

Browse files
authored
Merge branch 'main' into main
2 parents c5fe25a + 7144376 commit 4d44845

File tree

159 files changed

+5983
-4123
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

159 files changed

+5983
-4123
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ commands:
3737
- run:
3838
name: 'Run fast tests'
3939
command: |
40-
yarn test:fast
40+
yarn test:fast --reporter=junit --outputFile="./reports/out/test_output.xml"
4141
4242
run-slow-tests:
4343
steps:
@@ -114,7 +114,7 @@ jobs:
114114
type: enum
115115
enum: ['x64', 'arm64']
116116
executor: << parameters.executor >>
117-
parallelism: 2
117+
parallelism: 1 # disabled due to being on CircleCI's free plan
118118
steps:
119119
- install
120120
- when:

.eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ packages/*/*/index.ts
77
packages/**/bad.js
88
tmpl
99
packages/api/core/helper/dynamic-import.js
10+
packages/plugin/webpack/spec/fixtures/**/*

.eslintrc.json

+5-3
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@
4848
},
4949
"rules": {
5050
"no-throw-literal": "off",
51-
"@typescript-eslint/no-throw-literal": "error",
51+
"@typescript-eslint/no-explicit-any": "warn",
52+
"@typescript-eslint/no-unused-expressions": "warn",
5253
"@typescript-eslint/no-unused-vars": [
5354
"error",
5455
{
@@ -57,7 +58,8 @@
5758
"ignoreRestSiblings": true,
5859
"vars": "all"
5960
}
60-
]
61+
],
62+
"@typescript-eslint/only-throw-error": "error"
6163
}
6264
},
6365
{
@@ -93,7 +95,7 @@
9395
{
9496
"files": ["packages/api/core/test/**/*.ts", "packages/maker/*/src/Maker*.ts"],
9597
"rules": {
96-
"@typescript-eslint/no-var-requires": "off"
98+
"@typescript-eslint/no-require-imports": "off"
9799
}
98100
},
99101
{

.prettierignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ packages/*/*/README.md
1010
packages/*/*/tsconfig.json
1111
packages/*/*/typedoc.json
1212
packages/api/core/test/fixture/bad_external_forge_config/bad.js
13-
packages/plugin/webpack/test/**/.webpack
13+
packages/plugin/webpack/spec/**/.webpack
1414
.links

package.json

+13-16
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@
1818
"lint:markdown-js": "electron-lint-markdown-standard --root . --ignore-path .markdownlintignore --semi \"**/*.md\"",
1919
"lint:markdown-links": "electron-lint-markdown-links --root . --ignore-path .markdownlintignore \"**/*.md\"",
2020
"lint": "npm run lint:js && npm run lint:markdown && npm run lint:markdown-js && npm run lint:markdown-links",
21-
"lint:fix": "prettier --write .",
21+
"lint:fix": "prettier --write . && eslint --fix .",
2222
"link:prepare": "lerna exec -- node ../../../tools/silent.js yarn link --silent --no-bin-links --link-folder ../../../.links",
2323
"link:remove": "lerna exec -- node ../../../tools/silent.js yarn unlink --silent --no-bin-links --link-folder ../../../.links",
2424
"test": "npm run test:clear && xvfb-maybe cross-env NODE_ENV=test TS_NODE_PROJECT='./tsconfig.test.json' TS_NODE_FILES=1 mocha",
25-
"test:fast": "npm run test -- --suite=fast",
25+
"test:fast": "xvfb-maybe vitest run",
2626
"test:slow": "npm run test -- --suite=slow",
2727
"test:clear": "ts-node tools/test-clear",
2828
"postinstall": "rimraf node_modules/.bin/*.ps1 && ts-node ./tools/gen-tsconfigs.ts && ts-node ./tools/gen-ts-glue.ts",
@@ -91,7 +91,6 @@
9191
"@types/debug": "^4.1.5",
9292
"@types/express": "^4.17.9",
9393
"@types/express-ws": "^3.0.0",
94-
"@types/fetch-mock": "^7.3.1",
9594
"@types/fs-extra": "^9.0.6",
9695
"@types/interpret": "^1.1.1",
9796
"@types/keyv": "^3.1.4",
@@ -102,26 +101,22 @@
102101
"@types/mocha": "^9.0.0",
103102
"@types/node": "^18.0.3",
104103
"@types/node-fetch": "^2.5.5",
105-
"@types/proxyquire": "^1.3.28",
106104
"@types/rechoir": "^0.6.1",
107105
"@types/semver": "^7.3.4",
108-
"@types/sinon": "^10.0.0",
109-
"@types/sinon-chai": "^3.2.5",
110106
"@types/which": "^2.0.0",
111-
"@typescript-eslint/eslint-plugin": "^5.0.0",
112-
"@typescript-eslint/parser": "^5.0.0",
107+
"@typescript-eslint/eslint-plugin": "^8.0.0",
108+
"@typescript-eslint/parser": "^8.0.0",
113109
"chai": "^4.3.3",
114110
"chai-as-promised": "^7.0.0",
115111
"cross-env": "^7.0.2",
116112
"electron-installer-common": "^0.10.2",
117-
"eslint": "^8.0.1",
118-
"eslint-plugin-import": "^2.26.0",
113+
"eslint": "^8.56.0",
114+
"eslint-plugin-import": "^2.31.0",
119115
"eslint-plugin-mocha": "^9.0.0",
120116
"eslint-plugin-node": "^11.1.0",
121117
"eslint-plugin-prettier": "^4.0.0",
122118
"eslint-plugin-promise": "^6.0.0",
123119
"eslint-plugin-tsdoc": "^0.2.14",
124-
"fetch-mock": "^9.10.7",
125120
"fork-ts-checker-webpack-plugin": "^7.2.13",
126121
"generate-changelog": "^1.8.0",
127122
"husky": "^7.0.1",
@@ -131,15 +126,14 @@
131126
"minimist": "^1.2.6",
132127
"mocha": "^9.0.1",
133128
"mocha-junit-reporter": "^2.2.1",
129+
"msw": "^2.7.0",
134130
"prettier": "^2.4.0",
135-
"proxyquire": "^2.1.3",
136131
"rimraf": "^3.0.1",
137-
"sinon": "^13.0.1",
138-
"sinon-chai": "^3.6.0",
139132
"syncpack": "^11.2.1",
140133
"ts-node": "^10.0.0",
141134
"typedoc": "0.25.13",
142-
"typescript": "^4.6.3",
135+
"typescript": "~5.4.5",
136+
"vitest": "^2.1.6",
143137
"xvfb-maybe": "^0.2.1",
144138
"yaml-hook": "^1.0.0"
145139
},
@@ -168,7 +162,7 @@
168162
"prettier": {
169163
"singleQuote": true
170164
},
171-
"packageManager": "[email protected].19+sha1.4ba7fc5c6e704fce2066ecbfb0b0d8976fe62447",
165+
"packageManager": "[email protected].22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e",
172166
"workspaces": {
173167
"packages": [
174168
"packages/api/*",
@@ -179,5 +173,8 @@
179173
"packages/template/*",
180174
"packages/utils/*"
181175
]
176+
},
177+
"resolutions": {
178+
"@malept/eslint-config/@typescript-eslint/parser": "^8.0.0"
182179
}
183180
}

packages/api/cli/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"@malept/cross-spawn-promise": "^2.0.0",
1515
"chai": "^4.3.3",
1616
"chai-as-promised": "^7.0.0",
17-
"mocha": "^9.0.1"
17+
"mocha": "^9.0.1",
18+
"vitest": "^2.1.6"
1819
},
1920
"dependencies": {
2021
"@electron-forge/core": "7.6.0",
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import { expect } from 'chai';
1+
import { describe, expect, it } from 'vitest';
22

33
import { checkValidPackageManagerVersion } from '../src/util/check-system';
44

55
describe('check-system', () => {
66
describe('validPackageManagerVersion', () => {
77
it('should consider whitelisted versions to be valid', () => {
8-
expect(() => checkValidPackageManagerVersion('NPM', '3.10.1', '^3.0.0')).to.not.throw();
8+
expect(() => checkValidPackageManagerVersion('NPM', '3.10.1', '^3.0.0')).not.toThrow();
99
});
1010

1111
it('should consider Yarn nightly versions to be invalid', () => {
12-
expect(() => checkValidPackageManagerVersion('Yarn', '0.23.0-20170311.0515', '0.23.0')).to.throw();
12+
expect(() => checkValidPackageManagerVersion('Yarn', '0.23.0-20170311.0515', '0.23.0')).toThrow();
1313
});
1414

1515
it('should consider invalid semver versions to be invalid', () => {
16-
expect(() => checkValidPackageManagerVersion('Yarn', '0.22', '0.22.0')).to.throw();
16+
expect(() => checkValidPackageManagerVersion('Yarn', '0.22', '0.22.0')).toThrow();
1717
});
1818
});
1919
});

packages/api/cli/spec/cli.spec.ts

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import path from 'node:path';
2+
3+
import { spawn } from '@malept/cross-spawn-promise';
4+
import { describe, expect, it } from 'vitest';
5+
6+
function runForgeCLI(...extraArgs: string[]): Promise<string> {
7+
const args = ['ts-node', path.resolve(__dirname, '../src/electron-forge.ts'), ...extraArgs];
8+
return spawn('npx', args);
9+
}
10+
11+
describe('cli', { timeout: 30_000 }, () => {
12+
it('should not fail on known subcommands', async () => {
13+
await expect(runForgeCLI('help')).resolves.toMatch(/Usage:/);
14+
});
15+
16+
it('should fail on unknown subcommands', async () => {
17+
await expect(runForgeCLI('nonexistent')).rejects.toThrow(Error);
18+
});
19+
});

packages/api/cli/src/electron-forge-make.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22

3-
import { api, MakeOptions } from '@electron-forge/core';
43
import { initializeProxy } from '@electron/get';
4+
import { api, MakeOptions } from '@electron-forge/core';
55
import program from 'commander';
66
import fs from 'fs-extra';
77

packages/api/cli/src/electron-forge-package.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22

3-
import { api, PackageOptions } from '@electron-forge/core';
43
import { initializeProxy } from '@electron/get';
4+
import { api, PackageOptions } from '@electron-forge/core';
55
import program from 'commander';
66
import fs from 'fs-extra';
77

packages/api/cli/src/electron-forge-publish.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'node:path';
22

3-
import { api, PublishOptions } from '@electron-forge/core';
43
import { initializeProxy } from '@electron/get';
4+
import { api, PublishOptions } from '@electron-forge/core';
55
import program from 'commander';
66
import fs from 'fs-extra';
77

packages/api/cli/src/electron-forge.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import './util/terminate';
99

1010
import { checkSystem } from './util/check-system';
1111

12-
// eslint-disable-next-line @typescript-eslint/no-var-requires
12+
// eslint-disable-next-line @typescript-eslint/no-require-imports
1313
const metadata = require('../package.json');
1414

1515
const originalSC = program.executeSubCommand.bind(program);

packages/api/cli/test/cli_spec.ts

-30
This file was deleted.

packages/api/core/package.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,8 @@
3232
"chai-as-promised": "^7.0.0",
3333
"cross-env": "^7.0.2",
3434
"electron-installer-common": "^0.10.2",
35-
"fetch-mock": "^9.10.7",
3635
"mocha": "^9.0.1",
37-
"proxyquire": "^2.1.3",
38-
"sinon": "^13.0.1",
39-
"sinon-chai": "^3.6.0",
36+
"vitest": "^2.1.6",
4037
"yaml-hook": "^1.0.0"
4138
},
4239
"dependencies": {
+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/* eslint-disable node/no-unsupported-features/es-syntax */
2+
import * as path from 'node:path';
3+
4+
import { describe, expect, it, vi } from 'vitest';
5+
6+
import make from '../../src/api/make';
7+
8+
vi.mock(import('@electron-forge/core-utils'), async (importOriginal) => {
9+
const mod = await importOriginal();
10+
return {
11+
...mod,
12+
getElectronVersion: vi.fn().mockResolvedValue('1.0.0'),
13+
};
14+
});
15+
16+
describe('make', () => {
17+
const fixtureDir = path.resolve(__dirname, '../../test/fixture');
18+
19+
it.todo('should call "package"');
20+
21+
it('works with @scoped package names', { timeout: 10_000 }, async () => {
22+
const result = await make({
23+
arch: 'x64',
24+
dir: path.join(fixtureDir, 'app-with-scoped-name'),
25+
platform: 'linux',
26+
skipPackage: true,
27+
});
28+
expect(result).toHaveLength(1);
29+
expect(result[0].artifacts).toEqual([expect.stringContaining('@scope-package-linux-x64-1.0.0.zip')]);
30+
});
31+
32+
it('can override targets', async () => {
33+
const results = await make({
34+
arch: 'x64',
35+
dir: path.join(fixtureDir, 'app-with-custom-maker-config'),
36+
overrideTargets: ['../custom-maker'],
37+
platform: 'linux',
38+
skipPackage: true,
39+
});
40+
41+
expect(results[0].artifacts).toEqual(['from config']);
42+
});
43+
44+
it('throws an error if the name is not a string', async () => {
45+
await expect(
46+
make({
47+
arch: 'x64',
48+
dir: path.join(fixtureDir, 'maker-name-wrong-type'),
49+
platform: 'linux',
50+
skipPackage: true,
51+
})
52+
).rejects.toThrowError(/^The following maker config has a maker name that is not a string:/);
53+
});
54+
55+
it('throws an error if the name is missing', async () => {
56+
await expect(
57+
make({
58+
arch: 'x64',
59+
dir: path.join(fixtureDir, 'maker-sans-name'),
60+
platform: 'linux',
61+
skipPackage: true,
62+
})
63+
).rejects.toThrowError(/^The following maker config is missing a maker name:/);
64+
});
65+
66+
it('can skip makers via config', async () => {
67+
await expect(
68+
make({
69+
arch: 'x64',
70+
dir: path.join(fixtureDir, 'app-with-maker-disable'),
71+
platform: 'linux',
72+
skipPackage: true,
73+
})
74+
).rejects.toThrowError(/Could not find any make targets configured for the "linux" platform./);
75+
});
76+
77+
it('throws if maker cannot be resolved', async () => {
78+
const opts = {
79+
arch: 'x64',
80+
dir: path.join(fixtureDir, 'app-with-custom-maker-config'),
81+
platform: 'linux',
82+
skipPackage: true,
83+
};
84+
85+
await expect(make(opts)).rejects.toThrowError("Could not find module with name '@electron-forge/non-existent-forge-maker'");
86+
});
87+
});

0 commit comments

Comments
 (0)