Skip to content

Commit a335b89

Browse files
build: drop redundant npx prefixes (#334)
* build: drop redundant npx prefixes - package.json scripts: eslint, tsc, prettier are all devDependencies, npm/yarn already resolve them from node_modules/.bin - mocha-cli.ts: spawn yarn tsx instead of npx tsx (tsx is a devDep) * test: use npx --no instead of yarn for tsx spawn CI uses npm and installs different electron versions per matrix entry, which modifies package.json and leaves yarn.lock stale. yarn tsx then fails its workspace consistency check. npx --no achieves the same thing (no registry fallback, tsx is a devDep) without yarn's lockfile check. * ci: use --no-save for matrix electron install npm install defaults to --save, which rewrites package.json with the matrix electron version. That leaves yarn.lock stale, and yarn 4 checks lockfile consistency on every invocation — including yarn tsx in the spec runner. --no-save installs to node_modules without touching package.json. Reverts the previous npx --no workaround. * ci: pin matrix electron versions via npm: aliases Replaces the CI-time npm install electron@X with lockfile-pinned aliases (electron36 through electron40 as npm:electron@^XX). The spec runner selects which one to use via ELECTRON_PKG env var, defaulting to the base electron devDep for local runs. This reverts the --no-save workaround from the previous commit — the real fix is not fetching electron from the registry at CI time at all. Each alias has a dependenciesMeta.built: true entry so the postinstall binary download runs despite enableScripts: false. The npmPreapprovedPackages entry for 'electron' already covers the aliases (yarn checks the resolved name, not the alias). Also switches setup-node cache from 'npm' to 'yarn'.
1 parent 1997cf1 commit a335b89

File tree

5 files changed

+126
-9
lines changed

5 files changed

+126
-9
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ jobs:
5050
uses: actions/setup-node@6044e13b5dc448c55e2357c09f80417699197238 # v6.2.0
5151
with:
5252
node-version: "${{ matrix.node-version }}"
53-
cache: 'npm'
53+
cache: 'yarn'
5454
- name: Install dependencies
5555
run: yarn install --immutable
56-
- name: Install Electron
57-
run: npm install "electron@${{ matrix.electron-version }}"
5856
- name: Lint
5957
run: npm run lint
6058
- name: Build
6159
run: npm run build
6260
- name: Test
6361
run: npm run test
62+
env:
63+
ELECTRON_PKG: electron${{ matrix.electron-version }}

package.json

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@
2828
"build:node": "cross-env NODE_OPTIONS='--import=tsx' webpack --config webpack.node.config.ts",
2929
"build": "npm run clean && npm run build:node && npm run build:types && npm run build:browser",
3030
"dev": "cross-env NODE_OPTIONS='--import=tsx' webpack serve --config webpack.dev.config.ts",
31-
"lint:eslint": "npx eslint -c eslint.config.mjs",
32-
"lint": "npx tsc --noEmit && prettier . --check --experimental-cli",
33-
"lint:fix": "npx prettier . --write --experimental-cli && npm run lint:eslint --fix",
31+
"lint:eslint": "eslint -c eslint.config.mjs",
32+
"lint": "tsc --noEmit && prettier . --check --experimental-cli",
33+
"lint:fix": "prettier . --write --experimental-cli && npm run lint:eslint --fix",
3434
"prepublishOnly": "npm run build",
3535
"test": "mocha spec-electron-setup/scripts/mocha-cli.ts"
3636
},
@@ -70,6 +70,11 @@
7070
"cross-env": "^7.0.3",
7171
"css-loader": "^7.1.2",
7272
"electron": "^36.5.0",
73+
"electron36": "npm:electron@^36",
74+
"electron37": "npm:electron@^37",
75+
"electron38": "npm:electron@^38",
76+
"electron39": "npm:electron@^39",
77+
"electron40": "npm:electron@^40",
7378
"eslint": "^9.28.0",
7479
"eslint-plugin-chai-friendly": "^1.1.0",
7580
"eslint-plugin-react": "^7.37.5",
@@ -116,6 +121,21 @@
116121
"dependenciesMeta": {
117122
"electron": {
118123
"built": true
124+
},
125+
"electron36": {
126+
"built": true
127+
},
128+
"electron37": {
129+
"built": true
130+
},
131+
"electron38": {
132+
"built": true
133+
},
134+
"electron39": {
135+
"built": true
136+
},
137+
"electron40": {
138+
"built": true
119139
}
120140
}
121141
}

spec-electron-setup/scripts/mocha-cli.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ describe('Electron Spec Runner', function () {
1616

1717
it('should complete Electron tests successfully', (done) => {
1818
const runnerPath = path.resolve(__dirname, './spec-runner.ts');
19-
const child = spawn('npx', ['tsx', `"${runnerPath}"`], { stdio: 'inherit', shell: true });
19+
const child = spawn('yarn', ['tsx', `"${runnerPath}"`], { stdio: 'inherit', shell: true });
2020

2121
child.on('close', (code) => {
2222
expect(code).to.equal(0, 'Electron exited with non-zero status');

spec-electron-setup/scripts/spec-runner.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { spawnSync } from 'node:child_process';
22
import path from 'node:path';
3-
import electronPath from 'electron';
3+
// eslint-disable-next-line @typescript-eslint/no-require-imports
4+
const electronPath: string = require(process.env.ELECTRON_PKG || 'electron');
45
import 'colors';
56

67
async function main(): Promise<void> {
78
const runnerArgs = ['spec-electron-setup/electron/main.js'];
89
const cwd = path.resolve(__dirname, '..', '..');
910

10-
const { status, signal } = spawnSync(electronPath as unknown as string, runnerArgs, {
11+
const { status, signal } = spawnSync(electronPath, runnerArgs, {
1112
cwd,
1213
stdio: 'inherit',
1314
});

yarn.lock

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ __metadata:
628628
css-loader: "npm:^7.1.2"
629629
denque: "npm:^2.1.0"
630630
electron: "npm:^36.5.0"
631+
electron36: "npm:electron@^36"
632+
electron37: "npm:electron@^37"
633+
electron38: "npm:electron@^38"
634+
electron39: "npm:electron@^39"
635+
electron40: "npm:electron@^40"
631636
eslint: "npm:^9.28.0"
632637
eslint-plugin-chai-friendly: "npm:^1.1.0"
633638
eslint-plugin-react: "npm:^7.37.5"
@@ -657,6 +662,16 @@ __metadata:
657662
dependenciesMeta:
658663
electron:
659664
built: true
665+
electron36:
666+
built: true
667+
electron37:
668+
built: true
669+
electron38:
670+
built: true
671+
electron39:
672+
built: true
673+
electron40:
674+
built: true
660675
languageName: unknown
661676
linkType: soft
662677

@@ -1560,6 +1575,15 @@ __metadata:
15601575
languageName: node
15611576
linkType: hard
15621577

1578+
"@types/node@npm:^24.9.0":
1579+
version: 24.12.0
1580+
resolution: "@types/node@npm:24.12.0"
1581+
dependencies:
1582+
undici-types: "npm:~7.16.0"
1583+
checksum: 10c0/8b31c0af5b5474f13048a4e77c57f22cd4f8fe6e58c4b6fde9456b0c13f46a5bfaf5744ff88fd089581de9f0d6e99c584e022681de7acb26a58d258c654c4843
1584+
languageName: node
1585+
linkType: hard
1586+
15631587
"@types/node@npm:~22.10.7":
15641588
version: 22.10.10
15651589
resolution: "@types/node@npm:22.10.10"
@@ -3480,6 +3504,71 @@ __metadata:
34803504
languageName: node
34813505
linkType: hard
34823506

3507+
"electron36@npm:electron@^36":
3508+
version: 36.9.5
3509+
resolution: "electron@npm:36.9.5"
3510+
dependencies:
3511+
"@electron/get": "npm:^2.0.0"
3512+
"@types/node": "npm:^22.7.7"
3513+
extract-zip: "npm:^2.0.1"
3514+
bin:
3515+
electron: cli.js
3516+
checksum: 10c0/85f7239e6912dba8dcab133b51c12e730e3da083877226d8f783d938779023f76b6a1012e8587a21944cd84491b69b376c3ab9d334ee81e4b7e87301ccfa0c44
3517+
languageName: node
3518+
linkType: hard
3519+
3520+
"electron37@npm:electron@^37":
3521+
version: 37.10.3
3522+
resolution: "electron@npm:37.10.3"
3523+
dependencies:
3524+
"@electron/get": "npm:^2.0.0"
3525+
"@types/node": "npm:^22.7.7"
3526+
extract-zip: "npm:^2.0.1"
3527+
bin:
3528+
electron: cli.js
3529+
checksum: 10c0/a09c10d76be021a94f6c8b251ef990553fe530a6a1271c22026f06a502e977fac116a88b78e73abf50177386a76d69b1c9a52f62d6de60006cc50ed4cb969f0f
3530+
languageName: node
3531+
linkType: hard
3532+
3533+
"electron38@npm:electron@^38":
3534+
version: 38.8.6
3535+
resolution: "electron@npm:38.8.6"
3536+
dependencies:
3537+
"@electron/get": "npm:^2.0.0"
3538+
"@types/node": "npm:^22.7.7"
3539+
extract-zip: "npm:^2.0.1"
3540+
bin:
3541+
electron: cli.js
3542+
checksum: 10c0/4e3c02a01b99a77d715a28ec1b1053382860c3100a735adae5784387e38f7cb800313aeb2c9d292297f37237b57b8660bafcf913360a6b68865a45642a495264
3543+
languageName: node
3544+
linkType: hard
3545+
3546+
"electron39@npm:electron@^39":
3547+
version: 39.8.5
3548+
resolution: "electron@npm:39.8.5"
3549+
dependencies:
3550+
"@electron/get": "npm:^2.0.0"
3551+
"@types/node": "npm:^22.7.7"
3552+
extract-zip: "npm:^2.0.1"
3553+
bin:
3554+
electron: cli.js
3555+
checksum: 10c0/21448e3d69a5e96912ce84533d39e7258be17879502cfed30bcdd6581b61516a1d1f3b492aad20344367967229bce27018625047f7ee6801257df93bf6b96d97
3556+
languageName: node
3557+
linkType: hard
3558+
3559+
"electron40@npm:electron@^40":
3560+
version: 40.8.5
3561+
resolution: "electron@npm:40.8.5"
3562+
dependencies:
3563+
"@electron/get": "npm:^2.0.0"
3564+
"@types/node": "npm:^24.9.0"
3565+
extract-zip: "npm:^2.0.1"
3566+
bin:
3567+
electron: cli.js
3568+
checksum: 10c0/3874115299b101bada7f243afd1e0479c88a11fa534171a3d60d7933f4f0c382ef8e58aeaf91c963a2bb4d087ef3cd68065796b611a1dbaeb4b1205e680a23bd
3569+
languageName: node
3570+
linkType: hard
3571+
34833572
"electron@npm:^36.5.0":
34843573
version: 36.9.4
34853574
resolution: "electron@npm:36.9.4"
@@ -8729,6 +8818,13 @@ __metadata:
87298818
languageName: node
87308819
linkType: hard
87318820

8821+
"undici-types@npm:~7.16.0":
8822+
version: 7.16.0
8823+
resolution: "undici-types@npm:7.16.0"
8824+
checksum: 10c0/3033e2f2b5c9f1504bdc5934646cb54e37ecaca0f9249c983f7b1fc2e87c6d18399ebb05dc7fd5419e02b2e915f734d872a65da2e3eeed1813951c427d33cc9a
8825+
languageName: node
8826+
linkType: hard
8827+
87328828
"unique-filename@npm:^4.0.0":
87338829
version: 4.0.0
87348830
resolution: "unique-filename@npm:4.0.0"

0 commit comments

Comments
 (0)