Skip to content

Commit e1b9786

Browse files
committed
fix(release): verify legacy installers against legacy resources
1 parent f14e621 commit e1b9786

3 files changed

Lines changed: 35 additions & 3 deletions

File tree

‎scripts/verify-packaged-app.mjs‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,10 @@ export async function assertPackagedResources(
738738
// reads it at runtime, so current builds must carry it — but a
739739
// previously released baseline predates it.
740740
requireCanonicalIcon = true,
741+
// The pinned Windows upgrade baseline predates bundled npm. Current
742+
// artifacts must carry it, while that historical baseline is verified
743+
// against the release contract that applied when it shipped.
744+
requireBundledNpm = true,
741745
} = {},
742746
) {
743747
if (bundledGitContract !== 'forbidden' && bundledGitContract !== 'legacy-required') {
@@ -747,9 +751,13 @@ export async function assertPackagedResources(
747751
const required = [
748752
'app.asar',
749753
'bundled-tools.json',
750-
'bundled-npm.json',
751-
join('npm', 'bin', 'npm-cli.js'),
752-
join('licenses', 'npm-cli', 'LICENSE'),
754+
...(requireBundledNpm
755+
? [
756+
'bundled-npm.json',
757+
join('npm', 'bin', 'npm-cli.js'),
758+
join('licenses', 'npm-cli', 'LICENSE'),
759+
]
760+
: []),
753761
...(requiresLegacyBundledGit
754762
? [
755763
'bundled-git.json',

‎scripts/verify-packaged-app.test.mjs‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,29 @@ test('packaged resources forbid the retired bundled Git distribution', async ()
4949
}
5050
});
5151

52+
test('requires bundled npm only for the current release contract', async () => {
53+
const currentPaths = [];
54+
await assertPackagedResources('resources', {
55+
requirePath: async (path) => currentPaths.push(path),
56+
forbidPath: async () => {},
57+
requireWindowsSandbox: false,
58+
});
59+
assert.ok(currentPaths.includes(join('resources', 'bundled-npm.json')));
60+
assert.ok(currentPaths.includes(join('resources', 'npm', 'bin', 'npm-cli.js')));
61+
assert.ok(currentPaths.includes(join('resources', 'licenses', 'npm-cli', 'LICENSE')));
62+
63+
const legacyPaths = [];
64+
await assertPackagedResources('resources', {
65+
requirePath: async (path) => legacyPaths.push(path),
66+
forbidPath: async () => {},
67+
requireWindowsSandbox: false,
68+
requireBundledNpm: false,
69+
});
70+
assert.equal(legacyPaths.includes(join('resources', 'bundled-npm.json')), false);
71+
assert.equal(legacyPaths.includes(join('resources', 'npm', 'bin', 'npm-cli.js')), false);
72+
assert.equal(legacyPaths.includes(join('resources', 'licenses', 'npm-cli', 'LICENSE')), false);
73+
});
74+
5275
test('legacy packaged resources require the historical bundled Git contract', async () => {
5376
const required = [];
5477
const forbidden = [];

‎scripts/verify-windows-x64.mjs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ export async function verifyPackagedWindowsApp(
130130
requireDisclaimer: requiresCurrentContract,
131131
bundledGitContract: requiresCurrentContract ? 'forbidden' : 'legacy-required',
132132
requireCanonicalIcon: requiresCurrentContract,
133+
requireBundledNpm: requiresCurrentContract,
133134
});
134135
if (requiresCurrentContract) await assertPackagedDependencyClosure(resources);
135136
else await requirePath(join(resources, 'git', 'cmd', 'git.exe'));

0 commit comments

Comments
 (0)