Skip to content

build: drop redundant npx prefixes#334

Merged
MarshallOfSound merged 4 commits intomainfrom
sam/drop-redundant-npx
Mar 31, 2026
Merged

build: drop redundant npx prefixes#334
MarshallOfSound merged 4 commits intomainfrom
sam/drop-redundant-npx

Conversation

@MarshallOfSound
Copy link
Copy Markdown
Member

@MarshallOfSound MarshallOfSound commented Mar 31, 2026

Drops redundant npx prefixes from package.json scripts (eslint/tsc/prettier are all devDeps) and the spec runner spawn.

The spec runner change exposed a latent CI bug: npm install "electron@${{ matrix.electron-version }}" defaults to --save, rewriting package.json on every matrix entry. The old npx tsx never cared about yarn.lock consistency; yarn tsx does, and died on the stale lockfile.

Fix: lockfile-pin the matrix electron versions via npm: aliases.

"electron36": "npm:electron@^36",
"electron37": "npm:electron@^37",
// ...
"electron40": "npm:electron@^40"

spec-runner.ts now picks the alias via process.env.ELECTRON_PKG (defaults to the base electron devDep for local yarn test). CI sets ELECTRON_PKG: electron${{ matrix.electron-version }} and drops the npm install step entirely.

Each alias gets a dependenciesMeta.*.built: true entry so the postinstall binary download runs despite enableScripts: false. The existing npmPreapprovedPackages: [electron] already covers the aliases — yarn checks the resolved name, not the alias.

Lockfile delta: +96 lines (the 5 electron versions share their entire dep tree). Also switched setup-node cache: npmcache: yarn.

- 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)
@MarshallOfSound MarshallOfSound requested a review from a team as a code owner March 31, 2026 05:25
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.
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.
@erickzhao
Copy link
Copy Markdown
Member

> tsc --noEmit && prettier . --check --experimental-cli

Checking formatting...
[warn] spec-electron-setup/scripts/mocha-cli.ts
[warn] Code style issues found in 1 file. Run Prettier with --write to fix.

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'.
@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedelectron@​36.9.59410010098100
Addedelectron@​37.10.39410010098100
Addedelectron@​40.8.59410010098100
Addedelectron@​38.8.610010010098100
Addedelectron@​39.8.510010010098100

View full report

@MarshallOfSound MarshallOfSound merged commit a335b89 into main Mar 31, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants