dsh-crate 0.5.2 → 0.5.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/logo.svg +11 -33
- package/client/client.js +228 -119
- package/lib/discovery-compatibility.js +52 -5
- package/lib/drain.js +28 -9
- package/lib/hot.js +39 -6
- package/lib/index.js +17 -4
- package/lib/patch.js +7 -1
- package/lib/pnpm-compat.js +155 -1
- package/lib/profile.js +17 -1
- package/lib/release-updates.js +9 -2
- package/lib/routes.js +69 -3
- package/lib/themes.js +18 -1
- package/lib/types/discovery-compatibility.d.ts +8 -2
- package/lib/types/hot.d.ts +4 -2
- package/lib/types/index.d.ts +17 -0
- package/lib/types/profile.d.ts +4 -1
- package/lib/verify.js +19 -0
- package/package.json +1 -1
|
@@ -22,7 +22,9 @@ const FAILURE_COOLDOWN_MS = 5 * 60 * 1000;
|
|
|
22
22
|
const OUTAGE_COOLDOWN_MS = 30 * 1000;
|
|
23
23
|
const FETCH_TIMEOUT_MS = 8_000;
|
|
24
24
|
const DEFAULT_CONCURRENCY = 8;
|
|
25
|
-
|
|
25
|
+
// Larger than the catalog (10k+ and growing). A cap below the catalog size
|
|
26
|
+
// made a full scan evict its own first half, so no scan ever stayed cached (#1170).
|
|
27
|
+
const MAX_CACHE_ENTRIES = 20_000;
|
|
26
28
|
const MAX_RANGE_LENGTH = 256;
|
|
27
29
|
/** Reuse catalog facts only for this repository's exact pinned install asset. */
|
|
28
30
|
export function catalogReleaseManifest(source) {
|
|
@@ -32,7 +34,12 @@ export function catalogReleaseManifest(source) {
|
|
|
32
34
|
if (facts === null || !repository || !release || release[1].toLowerCase() !== repository.toLowerCase()
|
|
33
35
|
|| facts.tarball !== source.tarball || !validFacts(facts))
|
|
34
36
|
return null;
|
|
35
|
-
return {
|
|
37
|
+
return {
|
|
38
|
+
version: facts.version,
|
|
39
|
+
enginesDsh: facts.enginesDsh,
|
|
40
|
+
peerDependencies: facts.peerDependencies,
|
|
41
|
+
dependencies: facts.dependencies ?? {},
|
|
42
|
+
};
|
|
36
43
|
}
|
|
37
44
|
/** Read the linked package at its selected release, never the repository root by accident. */
|
|
38
45
|
async function githubManifest(source, fetcher) {
|
|
@@ -130,20 +137,35 @@ export function manifestFacts(value) {
|
|
|
130
137
|
if (declared !== null)
|
|
131
138
|
peerDependencies[name] = declared;
|
|
132
139
|
}
|
|
140
|
+
const dependencies = record(manifest.dependencies);
|
|
141
|
+
const hostDependencies = {};
|
|
142
|
+
for (const [name, raw] of Object.entries(dependencies ?? {})) {
|
|
143
|
+
if (!name.startsWith('@deepseek-ai/'))
|
|
144
|
+
continue;
|
|
145
|
+
const declared = range(raw);
|
|
146
|
+
if (declared !== null)
|
|
147
|
+
hostDependencies[name] = declared;
|
|
148
|
+
}
|
|
133
149
|
return {
|
|
134
150
|
version: range(manifest.version),
|
|
135
151
|
enginesDsh: range(engines?.dsh) ?? range(dshEngines?.dsh),
|
|
136
152
|
peerDependencies,
|
|
153
|
+
dependencies: hostDependencies,
|
|
137
154
|
};
|
|
138
155
|
}
|
|
139
156
|
function validFacts(value) {
|
|
140
157
|
const facts = record(value);
|
|
141
158
|
const peers = record(facts?.peerDependencies);
|
|
159
|
+
// A missing `dependencies` is a pre-upgrade cache entry or catalog manifest,
|
|
160
|
+
// not a malformed one: the durable cache must survive the upgrade rather than
|
|
161
|
+
// be discarded and refetched a thousand packages at once.
|
|
162
|
+
const dependencies = record(facts?.dependencies);
|
|
142
163
|
return facts !== null
|
|
143
164
|
&& (facts.version === null || range(facts.version) === facts.version)
|
|
144
165
|
&& (facts.enginesDsh === null || range(facts.enginesDsh) === facts.enginesDsh)
|
|
145
166
|
&& peers !== null
|
|
146
|
-
&& Object.entries(peers).every(([name, item]) => name.startsWith('@deepseek-ai/') && range(item) === item)
|
|
167
|
+
&& Object.entries(peers).every(([name, item]) => name.startsWith('@deepseek-ai/') && range(item) === item)
|
|
168
|
+
&& (dependencies === null || Object.entries(dependencies).every(([name, item]) => name.startsWith('@deepseek-ai/') && range(item) === item));
|
|
147
169
|
}
|
|
148
170
|
function displayRequirement(declarations) {
|
|
149
171
|
const unique = [...new Set(declarations.map(item => item.range))];
|
|
@@ -168,7 +190,12 @@ function rangeResult(hostVersion, declared) {
|
|
|
168
190
|
*/
|
|
169
191
|
function declarationResult(declaration, hostVersion) {
|
|
170
192
|
const satisfied = rangeResult(hostVersion, declaration.range);
|
|
171
|
-
|
|
193
|
+
// Only a PEER may be stretched: it is a statement of intent about the host
|
|
194
|
+
// line, and the ecosystem is full of sloppy caret ceilings. An engine is a
|
|
195
|
+
// plain bound, and a DEPENDENCY is an install instruction — pnpm resolves
|
|
196
|
+
// the declared range and hoists the result, so a range that excludes the
|
|
197
|
+
// running version means a second copy shadows the host's.
|
|
198
|
+
if (declaration.kind !== 'peer' || satisfied !== false)
|
|
172
199
|
return satisfied;
|
|
173
200
|
if (crossesImplicitCeiling(hostVersion, declaration.range))
|
|
174
201
|
return false;
|
|
@@ -203,6 +230,22 @@ export function deriveHostCompatibility(facts, hostVersion, hostPackages) {
|
|
|
203
230
|
continue;
|
|
204
231
|
declarations.push({ kind: 'peer', package: name, range: declared });
|
|
205
232
|
}
|
|
233
|
+
for (const [name, declared] of Object.entries(facts.dependencies ?? {})) {
|
|
234
|
+
// The peer filter above restricts itself to DSH's lockstep line because a
|
|
235
|
+
// peer range on cordis or schemastery says nothing about the DSH version.
|
|
236
|
+
// A dependency is different: it names a package the host itself provides,
|
|
237
|
+
// and pnpm will install the declared copy and hoist it over the host's.
|
|
238
|
+
// That is the dsh-qqbot failure — @deepseek-ai/dsh-settings and
|
|
239
|
+
// dsh-credentials as ordinary dependencies at `^0.1.0-rc.5` over a
|
|
240
|
+
// 0.2.2-rc.1 runtime — which the peer-only check could not see.
|
|
241
|
+
// Still only the lockstep line: the range is judged against the DSH
|
|
242
|
+
// version, and cordis (4.x) / schemastery (3.x) are not on it — a plugin
|
|
243
|
+
// that depends on `@deepseek-ai/cordis@^4` would otherwise read as
|
|
244
|
+
// incompatible with every host.
|
|
245
|
+
if (!hostPackages.has(name) || !/^@deepseek-ai\/dsh(?:-|$)/.test(name))
|
|
246
|
+
continue;
|
|
247
|
+
declarations.push({ kind: 'dependency', package: name, range: declared });
|
|
248
|
+
}
|
|
206
249
|
const requirement = displayRequirement(declarations);
|
|
207
250
|
if (declarations.length === 0) {
|
|
208
251
|
return { status: 'unknown', basis: 'undeclared', requirement: null, declarations: [] };
|
|
@@ -258,7 +301,11 @@ export class DiscoveryManifestIndex {
|
|
|
258
301
|
const entry = record(raw);
|
|
259
302
|
if (entry === null || typeof entry.checkedAt !== 'number' || !validFacts(entry.facts))
|
|
260
303
|
continue;
|
|
261
|
-
|
|
304
|
+
// Normalize the pre-upgrade shape so every consumer sees an object.
|
|
305
|
+
const facts = entry.facts.dependencies === undefined
|
|
306
|
+
? { ...entry.facts, dependencies: {} }
|
|
307
|
+
: entry.facts;
|
|
308
|
+
this.entries.set(name, { checkedAt: entry.checkedAt, facts });
|
|
262
309
|
}
|
|
263
310
|
}
|
|
264
311
|
catch { /* first run or a truncated cache — fetch fresh */ }
|
package/lib/drain.js
CHANGED
|
@@ -52,6 +52,15 @@ function record(value) {
|
|
|
52
52
|
function text(value) {
|
|
53
53
|
return typeof value === 'string' && value.trim() !== '' ? value.trim() : null;
|
|
54
54
|
}
|
|
55
|
+
/** True when the executor reported a completed change. */
|
|
56
|
+
function landed(result) {
|
|
57
|
+
const payload = record(result.payload);
|
|
58
|
+
return result.status >= 200 && result.status < 300 && payload?.ok !== false && payload?.cancelled !== true;
|
|
59
|
+
}
|
|
60
|
+
/** Mark a finished result as having outlived its market instance. */
|
|
61
|
+
function markReloaded(result) {
|
|
62
|
+
return { ...result, payload: { ...(record(result.payload) ?? {}), marketReloaded: true } };
|
|
63
|
+
}
|
|
55
64
|
/** User-facing failure text, stripped of control characters and home paths. */
|
|
56
65
|
function safeMessage(value) {
|
|
57
66
|
const raw = text(value);
|
|
@@ -431,7 +440,13 @@ export class DrainCoordinator {
|
|
|
431
440
|
if (this.disposeRequested)
|
|
432
441
|
this.detach();
|
|
433
442
|
}
|
|
434
|
-
if (this.disposeRequested) {
|
|
443
|
+
if (this.disposeRequested && !operation.cancelRequested && !this.barrierBroken && landed(result)) {
|
|
444
|
+
// The executor returned success: the package is on disk. The market being
|
|
445
|
+
// unloaded afterwards does not make that a cancellation (#1151).
|
|
446
|
+
result = markReloaded(result);
|
|
447
|
+
this.finishFromResult(operation, result);
|
|
448
|
+
}
|
|
449
|
+
else if (this.disposeRequested) {
|
|
435
450
|
result = {
|
|
436
451
|
status: 503,
|
|
437
452
|
payload: {
|
|
@@ -455,12 +470,12 @@ export class DrainCoordinator {
|
|
|
455
470
|
payload: {
|
|
456
471
|
ok: false,
|
|
457
472
|
failureCode: 'AGENT_BARRIER_LOST',
|
|
458
|
-
error: '
|
|
473
|
+
error: '有会话在操作进行中恢复了活动,文件可能已经改动。先在「已安装」里看看结果,等会话空闲后再试。 / A session became active while the operation ran, so files may have changed. Check Installed for the result, then retry once sessions are idle.',
|
|
459
474
|
},
|
|
460
475
|
};
|
|
461
476
|
this.finish(operation, 'failed', {
|
|
462
477
|
code: 'AGENT_BARRIER_LOST',
|
|
463
|
-
message: '
|
|
478
|
+
message: '有会话在操作进行中恢复了活动,文件可能已经改动。先在「已安装」里看看结果,等会话空闲后再试。 / A session became active while the operation ran, so files may have changed. Check Installed for the result, then retry once sessions are idle.',
|
|
464
479
|
}, null);
|
|
465
480
|
}
|
|
466
481
|
else {
|
|
@@ -479,7 +494,7 @@ export class DrainCoordinator {
|
|
|
479
494
|
if (this.barrierBroken) {
|
|
480
495
|
this.finish(operation, 'failed', {
|
|
481
496
|
code: 'AGENT_BARRIER_LOST',
|
|
482
|
-
message: '
|
|
497
|
+
message: '有会话恢复了活动,这次没有改任何文件。等会话空闲后再试。 / A session became active; nothing was changed. Retry once sessions are idle.',
|
|
483
498
|
}, null);
|
|
484
499
|
return;
|
|
485
500
|
}
|
|
@@ -491,7 +506,7 @@ export class DrainCoordinator {
|
|
|
491
506
|
else if (this.barrierBroken) {
|
|
492
507
|
this.finish(operation, 'failed', {
|
|
493
508
|
code: 'AGENT_BARRIER_LOST',
|
|
494
|
-
message: '
|
|
509
|
+
message: '有会话恢复了活动,这次没有改任何文件。等会话空闲后再试。 / A session became active; nothing was changed. Retry once sessions are idle.',
|
|
495
510
|
}, null);
|
|
496
511
|
}
|
|
497
512
|
else {
|
|
@@ -544,9 +559,13 @@ export class DrainCoordinator {
|
|
|
544
559
|
operation.startedAt = this.now();
|
|
545
560
|
this.notify(operation);
|
|
546
561
|
const result = await operation.execute(operation.intent, operation.onPhase);
|
|
547
|
-
//
|
|
548
|
-
//
|
|
549
|
-
//
|
|
562
|
+
// A cancel wins over a late success: the user asked to stop. An unload
|
|
563
|
+
// does not: a success result means the package command finished and the
|
|
564
|
+
// files are on disk, so it is recorded as done (#1151).
|
|
565
|
+
if (this.disposeRequested && !operation.cancelRequested && !this.barrierBroken && landed(result)) {
|
|
566
|
+
this.finishFromResult(operation, markReloaded(result));
|
|
567
|
+
return;
|
|
568
|
+
}
|
|
550
569
|
if (this.disposeRequested) {
|
|
551
570
|
this.finish(operation, 'cancelled', {
|
|
552
571
|
code: 'MARKET_UNLOADED',
|
|
@@ -561,7 +580,7 @@ export class DrainCoordinator {
|
|
|
561
580
|
if (this.barrierBroken) {
|
|
562
581
|
this.finish(operation, 'failed', {
|
|
563
582
|
code: 'AGENT_BARRIER_LOST',
|
|
564
|
-
message: '
|
|
583
|
+
message: '有会话在操作进行中恢复了活动,文件可能已经改动。先在「已安装」里看看结果,等会话空闲后再试。 / A session became active while the operation ran, so files may have changed. Check Installed for the result, then retry once sessions are idle.',
|
|
565
584
|
}, null);
|
|
566
585
|
return;
|
|
567
586
|
}
|
package/lib/hot.js
CHANGED
|
@@ -23,12 +23,13 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
23
23
|
}
|
|
24
24
|
return path;
|
|
25
25
|
};
|
|
26
|
-
import { mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
26
|
+
import { existsSync, mkdirSync, readFileSync, readdirSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
27
27
|
import { createRequire } from 'node:module';
|
|
28
28
|
import { join } from 'node:path';
|
|
29
29
|
import { pathToFileURL } from 'node:url';
|
|
30
30
|
import { asChannel } from './channels.js';
|
|
31
31
|
import { asRegion, normalizeGithubProxy } from './regions.js';
|
|
32
|
+
import { findDshInstallDir } from './dsh-install.js';
|
|
32
33
|
import { logEvent } from './log.js';
|
|
33
34
|
import { bundlePatchTargets, declaredBundlePatchFiles, entryArtifactExists } from './profile.js';
|
|
34
35
|
import { stateDir, statePath } from './state.js';
|
|
@@ -799,7 +800,9 @@ export async function hotMount(ctx, profileDir, packageName) {
|
|
|
799
800
|
* in every boot — this is what makes them behave like normal plugins.
|
|
800
801
|
* @returns names that were mounted.
|
|
801
802
|
*/
|
|
802
|
-
export async function mountClientOnlyDeps(ctx, profileDir
|
|
803
|
+
export async function mountClientOnlyDeps(ctx, profileDir,
|
|
804
|
+
/** The host's install directory; `undefined` finds it, `null` means "do not look". */
|
|
805
|
+
hostDirectory) {
|
|
803
806
|
let deps;
|
|
804
807
|
let bundles;
|
|
805
808
|
try {
|
|
@@ -813,7 +816,7 @@ export async function mountClientOnlyDeps(ctx, profileDir) {
|
|
|
813
816
|
}
|
|
814
817
|
const disabled = readDisabled(profileDir);
|
|
815
818
|
const userManaged = readUserPatchControls(profileDir);
|
|
816
|
-
const hostProvided = bundleLayerTargets(profileDir, bundles);
|
|
819
|
+
const hostProvided = bundleLayerTargets(profileDir, bundles, hostDirectory);
|
|
817
820
|
const mounted = [];
|
|
818
821
|
for (const name of deps) {
|
|
819
822
|
if (hotHandles.has(name) || disabled.has(name))
|
|
@@ -856,15 +859,45 @@ export async function mountClientOnlyDeps(ctx, profileDir) {
|
|
|
856
859
|
* today's behaviour (shim, possibly duplicated) rather than silently dropping
|
|
857
860
|
* a client bundle that the bundle layer never mounts.
|
|
858
861
|
*/
|
|
859
|
-
export function bundleLayerTargets(profileDir, bundles) {
|
|
862
|
+
export function bundleLayerTargets(profileDir, bundles, hostDirectory) {
|
|
860
863
|
const targets = new Set();
|
|
864
|
+
// Looked up lazily: a profile with no bundle the host provides never pays.
|
|
865
|
+
let host = hostDirectory;
|
|
861
866
|
for (const bundle of bundles) {
|
|
862
|
-
|
|
863
|
-
|
|
867
|
+
if (host === undefined)
|
|
868
|
+
host = findDshInstallDir();
|
|
869
|
+
for (const name of bundlePatchTargets(bundleDirectory(profileDir, host, bundle)))
|
|
864
870
|
targets.add(name);
|
|
865
871
|
}
|
|
866
872
|
return targets;
|
|
867
873
|
}
|
|
874
|
+
/**
|
|
875
|
+
* Where the boot reads one bundle from (#1137).
|
|
876
|
+
*
|
|
877
|
+
* The official bundles — `@deepseek-ai/dsh-web-app` and its siblings — ship
|
|
878
|
+
* inside the dsh installation, not in the profile: a plain `dsh web` profile's
|
|
879
|
+
* `node_modules/@deepseek-ai/` holds only the few packages linked into it. The
|
|
880
|
+
* boot (dsh-app-boot's resolveBundleDir) probes Node's search paths from the
|
|
881
|
+
* installation first and the profile second, and so does this; looking only
|
|
882
|
+
* in the profile made every in-box bundle read as empty, which is the one kind
|
|
883
|
+
* of bundle whose rows mount other in-box packages.
|
|
884
|
+
*
|
|
885
|
+
* A host that cannot be read from here (null, or an archive plain Node cannot
|
|
886
|
+
* open) leaves the profile path, which is what this always did.
|
|
887
|
+
*/
|
|
888
|
+
function bundleDirectory(profileDir, host, bundle) {
|
|
889
|
+
if (host !== null) {
|
|
890
|
+
try {
|
|
891
|
+
for (const searchPath of createRequire(join(host, 'package.json')).resolve.paths(bundle) ?? []) {
|
|
892
|
+
const candidate = join(searchPath, bundle);
|
|
893
|
+
if (existsSync(join(candidate, 'package.json')))
|
|
894
|
+
return candidate;
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
catch { /* an unreadable anchor says nothing: fall back to the profile */ }
|
|
898
|
+
}
|
|
899
|
+
return join(profileDir, 'node_modules', ...bundle.split('/'));
|
|
900
|
+
}
|
|
868
901
|
/**
|
|
869
902
|
* Row ids and package names the user's own patch layer (cordis.patch.yml)
|
|
870
903
|
* already contains. Line-wise scan on purpose: the file may hold structures
|
package/lib/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* dsh-crate host entry: mounts the market's HTTP routes once the profile
|
|
3
3
|
* composes the webServer and shell services.
|
|
4
4
|
*/
|
|
5
|
+
import z from '@deepseek-ai/schemastery';
|
|
5
6
|
import { dirname, isAbsolute } from 'node:path';
|
|
6
7
|
import { createDesktopPluginRuntime, setHostPackageManager } from './dsh-cli.js';
|
|
7
8
|
import { createOfficialDesktopRuntime } from './official-desktop.js';
|
|
@@ -22,6 +23,18 @@ export const name = 'dsh-crate';
|
|
|
22
23
|
* (#928). Nothing happens when the journal is empty, which is the normal case.
|
|
23
24
|
*/
|
|
24
25
|
const PENDING_UPDATE_REPAIR_DELAY_MS = 8_000;
|
|
26
|
+
/** A field the form may edit; newer hosts hand one back as a live reference (#1144). */
|
|
27
|
+
const editable = (schema) => schema.extra('volatile', true);
|
|
28
|
+
const valueOf = (field) => typeof field?.get === 'function' ? field.get() : field;
|
|
29
|
+
/** dsh 0.1.7+ builds its form from `plugin.Config` and writes `simplify(config)` back, so every field the market reads is named here or the first form save deletes it. Each is loose: an older composition still boots, a mistyped value is dropped, and neither editable field takes a default, so "unconfigured" stays distinguishable (#1144, #229). */
|
|
30
|
+
export const Config = z.object({
|
|
31
|
+
profile: z.string().loose(),
|
|
32
|
+
channel: z.string().loose(),
|
|
33
|
+
region: z.string().loose(),
|
|
34
|
+
allowRestart: editable(z.boolean().loose()),
|
|
35
|
+
maxSnapshots: editable(z.number().loose()),
|
|
36
|
+
buildEnv: z.dict(z.any()).loose().extra('default', undefined),
|
|
37
|
+
}).loose();
|
|
25
38
|
/**
|
|
26
39
|
* Register the market against the host context.
|
|
27
40
|
* @param ctx - Host context that may acquire webServer and shell services.
|
|
@@ -289,7 +302,7 @@ export function apply(ctx, config) {
|
|
|
289
302
|
},
|
|
290
303
|
desktopHost: true,
|
|
291
304
|
allowRestart: false,
|
|
292
|
-
maxSnapshots: config?.maxSnapshots,
|
|
305
|
+
maxSnapshots: valueOf(config?.maxSnapshots),
|
|
293
306
|
// The third construction site, and the one #527's review caught
|
|
294
307
|
// missing: a `buildEnv` configured in cordis.yml was silently
|
|
295
308
|
// dropped on the official desktop host — the very host the feature
|
|
@@ -342,8 +355,8 @@ export function apply(ctx, config) {
|
|
|
342
355
|
// would turn "the operator said nothing" into "the operator said
|
|
343
356
|
// yes", and restartAllowed() could no longer tell them apart — which
|
|
344
357
|
// is exactly the distinction supervisor detection needs (#229).
|
|
345
|
-
allowRestart: config?.allowRestart,
|
|
346
|
-
maxSnapshots: config?.maxSnapshots,
|
|
358
|
+
allowRestart: valueOf(config?.allowRestart),
|
|
359
|
+
maxSnapshots: valueOf(config?.maxSnapshots),
|
|
347
360
|
// Build-time environment (#336); undefined means "inherit", and the
|
|
348
361
|
// settings wiring below is what makes it editable at runtime.
|
|
349
362
|
buildEnv: config?.buildEnv,
|
|
@@ -388,7 +401,7 @@ export function apply(ctx, config) {
|
|
|
388
401
|
// Relaunching a raw Electron process would bypass Desktop's launcher
|
|
389
402
|
// lifecycle. The shell remains responsible for restart in this mode.
|
|
390
403
|
allowRestart: false,
|
|
391
|
-
maxSnapshots: config?.maxSnapshots,
|
|
404
|
+
maxSnapshots: valueOf(config?.maxSnapshots),
|
|
392
405
|
// The operator's pinned build environment applies in Desktop mode
|
|
393
406
|
// too: Desktop's packaged pnpm still runs plugin build scripts.
|
|
394
407
|
buildEnv: config?.buildEnv,
|
package/lib/patch.js
CHANGED
|
@@ -579,7 +579,13 @@ export function packagePatchFlags(host, profileDirectory, names, state) {
|
|
|
579
579
|
// host, so it is not a decision about this package (#1113): the shape a
|
|
580
580
|
// package rename leaves behind.
|
|
581
581
|
const applies = (id) => rowFlagApplies(state, id, composedRowName(host, id));
|
|
582
|
-
|
|
582
|
+
// A package counts as off only when nothing of it is left running: a
|
|
583
|
+
// multi-component plugin with some components switched off is still on
|
|
584
|
+
// (#1150). One disabled row used to flip the whole package, which kept
|
|
585
|
+
// it out of 「全部更新」.
|
|
586
|
+
// Rows that name another module do not count either way (#1113).
|
|
587
|
+
const decidedRows = rows.filter(id => decidedByUser(id) && applies(id));
|
|
588
|
+
if (decidedRows.length > 0 && decidedRows.every(id => state.disables.includes(id)))
|
|
583
589
|
disabled.push(name);
|
|
584
590
|
if (rows.some(id => decidedByUser(id) && applies(id) && state.forced.includes(id)))
|
|
585
591
|
forced.push(name);
|
package/lib/pnpm-compat.js
CHANGED
|
@@ -251,6 +251,127 @@ function storesFromNdjson(output) {
|
|
|
251
251
|
function storeVersionSegment(path) {
|
|
252
252
|
return path === undefined ? undefined : /[/\\](v\d+)[/\\]*$/.exec(path)?.[1];
|
|
253
253
|
}
|
|
254
|
+
function readStorePin(profileDirectory) {
|
|
255
|
+
if (profileDirectory === undefined)
|
|
256
|
+
return null;
|
|
257
|
+
let yaml;
|
|
258
|
+
try {
|
|
259
|
+
yaml = readFileSync(join(profileDirectory, 'pnpm-workspace.yaml'), 'utf8');
|
|
260
|
+
}
|
|
261
|
+
catch {
|
|
262
|
+
return null;
|
|
263
|
+
}
|
|
264
|
+
const camel = /^storeDir:[ \t]*['"]?([^'"\r\n]+?)['"]?[ \t]*$/mu.exec(yaml);
|
|
265
|
+
if (camel !== null)
|
|
266
|
+
return { path: camel[1].trim(), honoured: true };
|
|
267
|
+
const kebab = /^store-dir:[ \t]*['"]?([^'"\r\n]+?)['"]?[ \t]*$/mu.exec(yaml);
|
|
268
|
+
return kebab === null ? null : { path: kebab[1].trim(), honoured: false };
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* The store pnpm takes from the environment, which outranks the profile's
|
|
272
|
+
* own pnpm-workspace.yaml.
|
|
273
|
+
*
|
|
274
|
+
* Measured on pnpm 11.28.5 with a profile pinning one store: setting
|
|
275
|
+
* `PNPM_CONFIG_STORE_DIR` (or the lowercase `pnpm_config_store_dir`) to
|
|
276
|
+
* another path made `pnpm store path` print that other path. `npm_config_
|
|
277
|
+
* store_dir` did NOT — verified twice, with and without a workspace pin — so
|
|
278
|
+
* it is deliberately not read here: naming a variable that changes nothing
|
|
279
|
+
* would send the reader to the wrong place.
|
|
280
|
+
*/
|
|
281
|
+
function storeFromEnvironment() {
|
|
282
|
+
for (const [name, value] of Object.entries(process.env)) {
|
|
283
|
+
if (value !== undefined && value !== '' && /^pnpm_config_store_dir$/iu.test(name))
|
|
284
|
+
return { name, value };
|
|
285
|
+
}
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
/** Two store paths the same, tolerating separator style and Windows case. */
|
|
289
|
+
function sameStorePath(left, right) {
|
|
290
|
+
const normalise = (path) => path.replace(/\\/gu, '/').replace(/\/+$/u, '').toLowerCase();
|
|
291
|
+
return normalise(left) === normalise(right);
|
|
292
|
+
}
|
|
293
|
+
/**
|
|
294
|
+
* The way out of ERR_PNPM_UNEXPECTED_STORE, said in terms of the layer that
|
|
295
|
+
* actually decides the store (#244, #715; the layer order below was measured).
|
|
296
|
+
*
|
|
297
|
+
* The old text told every user the same thing: write the recorded store into
|
|
298
|
+
* the profile's pnpm-workspace.yaml. That is right for exactly one of the
|
|
299
|
+
* shapes this error has, and wrong — silently, repeatedly — for the others:
|
|
300
|
+
*
|
|
301
|
+
* - the file may already carry that line, in which case repeating the advice
|
|
302
|
+
* is a loop (the reporter's profile had it, and the fix that worked was
|
|
303
|
+
* elsewhere);
|
|
304
|
+
* - it may carry the kebab spelling, which pnpm ignores with a warning;
|
|
305
|
+
* - it may carry a DIFFERENT path from the record, so following "write the
|
|
306
|
+
* recorded store" means first seeing the two disagree;
|
|
307
|
+
* - an environment variable outranks the file, so on those machines the
|
|
308
|
+
* advice cannot work at all until the variable is changed;
|
|
309
|
+
* - the recorded store may no longer exist (the drive was moved or removed),
|
|
310
|
+
* and pinning a dead path is worse than the error it replaces.
|
|
311
|
+
*
|
|
312
|
+
* Each of those is readable from files and the environment the market already
|
|
313
|
+
* has, so the message can name the one that applies — and give a command that
|
|
314
|
+
* proves the result, since this is the branch where "I followed the advice and
|
|
315
|
+
* nothing changed" has been the actual experience.
|
|
316
|
+
*/
|
|
317
|
+
function storeRelinkAdvice(linked, wanted, profileDirectory) {
|
|
318
|
+
const pin = readStorePin(profileDirectory);
|
|
319
|
+
const env = storeFromEnvironment();
|
|
320
|
+
const envWins = env !== null && !sameStorePath(env.value, linked);
|
|
321
|
+
const wantedZh = wanted ?? '(上面列出的那个)';
|
|
322
|
+
const wantedEn = wanted ?? 'the one listed above';
|
|
323
|
+
const paste = `storeDir: '${linked}'`;
|
|
324
|
+
const verifyZh = '改完先在 profile 目录里执行 `pnpm store path` 验证:它必须**正好**打印上面第一个路径;打出别的就说明这一行没有生效,先别急着重试。';
|
|
325
|
+
const verifyEn = 'Verify before retrying: run `pnpm store path` in the profile directory — it must print the first path above, exactly. Anything else means that line did not take effect.';
|
|
326
|
+
const envZh = env === null ? '' : `(当前环境里 ${env.name}=${env.value})`;
|
|
327
|
+
const envEn = env === null ? '' : ` (currently ${env.name}=${env.value} in this environment)`;
|
|
328
|
+
const ladderZh = 'pnpm 解析 store 的优先级(高→低):--store-dir 命令行参数 → 环境变量 PNPM_CONFIG_STORE_DIR → profile 的 pnpm-workspace.yaml → 全局 pnpm 配置(`pnpm config get store-dir` 看到的就是它)→ 默认位置。';
|
|
329
|
+
const ladderEn = "The order pnpm resolves a store in (highest first): the --store-dir flag → the environment variable PNPM_CONFIG_STORE_DIR → the profile's pnpm-workspace.yaml → the global pnpm config (what `pnpm config get store-dir` reports) → the default location.";
|
|
330
|
+
// The file already names the recorded store and the error is still here:
|
|
331
|
+
// repeating the advice cannot help. Say which layer outranked it. Checked
|
|
332
|
+
// before the "different path" case, because same-path-plus-still-failing is
|
|
333
|
+
// the loop this branch exists to end.
|
|
334
|
+
if (pin !== null && pin.honoured && sameStorePath(pin.path, linked)) {
|
|
335
|
+
const causeZh = envWins
|
|
336
|
+
? `**上面那个环境变量把它覆盖了**:${env.name}=${env.value} 比 profile 文件优先,所以把 storeDir 改多少遍都没有用。`
|
|
337
|
+
: '覆盖它的是更高优先级的一层,而这个文件本身已经没有可改的地方了。';
|
|
338
|
+
const causeEn = envWins
|
|
339
|
+
? `**The environment variable above overrides it**: ${env.name}=${env.value} outranks the profile file, so editing storeDir there changes nothing.`
|
|
340
|
+
: 'A higher-priority layer overrides it, and there is nothing left to change in this file.';
|
|
341
|
+
return {
|
|
342
|
+
zh: `profile 的 pnpm-workspace.yaml 已经写了 storeDir: '${pin.path}'(就是记录里的那个 store),pnpm 却仍然解析到 ${wantedZh}:这说明这一行被更高优先级的东西压住了,再改这个文件不会有任何效果。${causeZh}${ladderZh}把上面那一层改成这个路径,或者去掉它让文件生效${envWins ? `(在这个环境里,去掉 ${env.name} 往往比改它更省事)` : ''}。${verifyZh}`,
|
|
343
|
+
en: `the profile's pnpm-workspace.yaml already pins storeDir: '${pin.path}' — the recorded store — yet pnpm still resolves ${wantedEn}, so a higher-priority layer overrides the file and editing it cannot help. ${causeEn} ${ladderEn} Change that layer to this path, or remove it so the file applies${envWins ? ` (in this environment, dropping ${env.name} is usually simpler than rewriting it)` : ''}. ${verifyEn}`,
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
// A pin in the file that names something else: the file beats the global
|
|
347
|
+
// config, so the line is the right seat for the fix — but it must be
|
|
348
|
+
// corrected rather than added a second time.
|
|
349
|
+
if (pin !== null && pin.honoured && !envWins) {
|
|
350
|
+
return {
|
|
351
|
+
zh: `profile 的 pnpm-workspace.yaml 里写的是 storeDir: '${pin.path}',但 node_modules 记录的是上面第一个路径——两处不一致,pnpm 会按文件里的走,于是继续对不上。把这一行改成记录里的那个路径:\n\n ${paste}\n\n${verifyZh}`,
|
|
352
|
+
en: `the profile's pnpm-workspace.yaml pins storeDir: '${pin.path}' while node_modules records the first path above, so pnpm follows the file and still disagrees with the record. Change that line to the recorded path:\n\n ${paste}\n\n${verifyEn}`,
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
// The file pins something in a spelling this pnpm does not read.
|
|
356
|
+
if (pin !== null && !pin.honoured) {
|
|
357
|
+
return {
|
|
358
|
+
zh: `profile 的 pnpm-workspace.yaml 里写的是 kebab 写法 store-dir: '${pin.path}'——pnpm **不认这个键**(它只在 stderr 留一行 WARN,然后当作没写,pnpm 11.28 实测),所以现在解析到的还是 ${wantedZh}。改成驼峰写法(单引号,Windows 路径在双引号里会被当成转义):\n\n ${paste}\n\n${envWins ? `另外,${env.name}=${env.value} 的优先级比这个文件更高,它还在的时候这一行同样不起作用。` : ''}${verifyZh}`,
|
|
359
|
+
en: `the profile's pnpm-workspace.yaml spells it the kebab way, store-dir: '${pin.path}' — a key this pnpm does **not** read (it prints one WARN to stderr and behaves as if the line were absent; measured on 11.28.5), so pnpm still resolves ${wantedEn}. Use the camelCase key with single quotes (a Windows path in double quotes is read as escape sequences):\n\n ${paste}\n\n${envWins ? `Also, ${env.name}=${env.value} outranks this file, so the line still would not apply while it is set. ` : ''}${verifyEn}`,
|
|
360
|
+
};
|
|
361
|
+
}
|
|
362
|
+
// Nothing pinned yet: the ordinary case. When the environment is what pnpm
|
|
363
|
+
// obeys, that is the layer to change — the file loses to it unconditionally.
|
|
364
|
+
if (envWins) {
|
|
365
|
+
return {
|
|
366
|
+
zh: `现在生效的是**环境变量**${envZh},它比 profile 的 pnpm-workspace.yaml 优先——文件里的 storeDir 写了也会被它压住,所以改那个文件没有任何作用。要改的是这一层:把 ${env.name} 指向上面第一个路径,或者去掉它(让 pnpm 回到全局配置 / 默认位置),然后再验证。${ladderZh}${verifyZh}`,
|
|
367
|
+
en: `the store in effect comes from **the environment**${envEn}, which outranks the profile's pnpm-workspace.yaml — a storeDir written there is overridden, so editing that file cannot work. Change this layer instead: point ${env.name} at the first path above, or remove it (letting pnpm fall back to the global config / default), then verify. ${ladderEn}${verifyEn}`,
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
return {
|
|
371
|
+
zh: `持久的修法:把**记录里的那个** store 写进 profile 的 pnpm-workspace.yaml,顶层、驼峰、单引号(Windows 路径在双引号里会被当成转义,整份文件会读不了):\n\n ${paste}\n\n加完不用重装任何东西——包本来就在那个 store 里,直接重试即可(dsh 正在运行可能占用文件,必要时先退出 dsh)。${verifyZh}如果那个路径其实已经不存在了(盘换了、目录被删),写它只会把 profile 钉在一个空 store 上,那就只能改用 pnpm 现在解析出的这个(包要重新下载)。`,
|
|
372
|
+
en: `durable fix: write the store from the RECORD into the profile's pnpm-workspace.yaml, top level, camelCase, single quotes (a Windows path in double quotes is read as escape sequences and the whole file fails to parse):\n\n ${paste}\n\nNothing has to be reinstalled — the packages are already in that store, so just retry (stop dsh first if it holds the files open). ${verifyEn}If that path no longer exists (the drive changed, the directory was deleted), pinning it would tie the profile to an empty store — adopt the store pnpm now resolves instead (every package is downloaded again).`,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
254
375
|
export function classifyPnpmFailure(output, exitCode, context) {
|
|
255
376
|
// #817: the host's silence watchdog (@deepseek-ai/dsh-plugin-manager,
|
|
256
377
|
// `idleTimeoutMs`, 10 minutes by default) killed pnpm. Checked first: it is
|
|
@@ -311,6 +432,27 @@ export function classifyPnpmFailure(output, exitCode, context) {
|
|
|
311
432
|
// a repair that goes wrong here leaves a profile in worse shape than the
|
|
312
433
|
// clear error it replaced. The paths are in the message; the choice is
|
|
313
434
|
// the user's.
|
|
435
|
+
//
|
|
436
|
+
// Measured on pnpm 11.28.5 (2026-11), for the #1100 report, the layer order
|
|
437
|
+
// that advice depends on
|
|
438
|
+
// (a scratch workspace and `pnpm store path`, each layer set alone and then
|
|
439
|
+
// against the others, because the previous sentence had not been re-checked
|
|
440
|
+
// since #715 and #244 were filed):
|
|
441
|
+
// --store-dir > PNPM_CONFIG_STORE_DIR > pnpm-workspace.yaml `storeDir`
|
|
442
|
+
// > the global npmrc `store-dir` > the default.
|
|
443
|
+
// Three things follow, and the message now states them instead of assuming
|
|
444
|
+
// the middle layer is always the one that decides:
|
|
445
|
+
// - the camelCase key IS honoured (#715), the kebab `store-dir` is NOT:
|
|
446
|
+
// pnpm prints `…ignored because they are not written in camelCase` on
|
|
447
|
+
// stderr and resolves exactly as if the line were absent;
|
|
448
|
+
// - an environment variable outranks the profile file, so a user who
|
|
449
|
+
// relocated the store that way cannot fix it in the profile at all —
|
|
450
|
+
// the advice has to name the variable (storeRelinkAdvice does);
|
|
451
|
+
// - a project `.npmrc` is ignored, the global one is not, so "the npmrc"
|
|
452
|
+
// is the global file and `pnpm config get store-dir` names its value.
|
|
453
|
+
// Each shape also gets a check the user can run (`pnpm store path`), since
|
|
454
|
+
// this branch's real-world failure was "I wrote exactly what it said and
|
|
455
|
+
// the next run failed the same way".
|
|
314
456
|
if (output.includes('ERR_PNPM_UNEXPECTED_STORE')) {
|
|
315
457
|
const ndjson = storesFromNdjson(output);
|
|
316
458
|
// pnpm 12's default reporter wraps long lines, inside the quotes too.
|
|
@@ -368,10 +510,22 @@ export function classifyPnpmFailure(output, exitCode, context) {
|
|
|
368
510
|
message: `这个 profile 的 node_modules 是用另一个大版本的 pnpm${named} 建的,而正在跑的这个 pnpm 大版本不同:它会在任何 storeDir 下面再拼自己的版本目录(上面第二个路径末尾那一段),所以**写 storeDir 修不好**,自动回滚也会以同样的方式失败。${detail}\n出路(任选):\n 1) 用建这份 node_modules 的那个 pnpm 大版本重新执行——${recorded === null ? '版本号写在 profile 的 node_modules/.modules.yaml 里(packageManager)' : `即 pnpm ${recorded}`},装好后让它排在 PATH 前面;\n 2) 或者留在这个新大版本上,清空 node_modules 重新安装(包会重新下载)。 / this profile's node_modules was built by a different pnpm${named === '' ? '' : ` (${recorded})`} major than the one now running: pnpm appends its own store-version segment under whatever storeDir says (the second path above ends with it), so **writing storeDir cannot fix this**, and the automatic rollback fails the same way.${detail}\nTwo ways out: 1) run the pnpm major that built this node_modules — ${recorded === null ? 'its version is recorded in the profile’s node_modules/.modules.yaml (packageManager)' : `pnpm ${recorded}`} — with it ahead of the current one on PATH; or 2) stay on the new major and reinstall node_modules from scratch (every package is downloaded again).`,
|
|
369
511
|
};
|
|
370
512
|
}
|
|
513
|
+
// The paths pnpm names are the whole diagnosis, so when its wording
|
|
514
|
+
// changes and they cannot be read, say so instead of inventing them — and
|
|
515
|
+
// still leave the reader with the key (`storeDir`) and the check
|
|
516
|
+
// (`pnpm store path`), because an unreadable path is not a missing remedy.
|
|
517
|
+
if (linked === undefined) {
|
|
518
|
+
return {
|
|
519
|
+
code: 'unexpected-store',
|
|
520
|
+
recoverable: false,
|
|
521
|
+
message: `这个 profile 的 node_modules 链接到的 pnpm store,和 pnpm 现在解析出的 store 不是同一个,pnpm 因此拒绝这个 profile 的所有安装与卸载。这次没能从 pnpm 的输出里读出两个路径(它的措辞变了),请按上面的原文核对。修法是在 profile 的 pnpm-workspace.yaml 里用驼峰 \`storeDir\` 指定记录里的那个 store(单引号),改完用 \`pnpm store path\` 验证;注意环境变量 PNPM_CONFIG_STORE_DIR 比这个文件优先,而 kebab 写法 \`store-dir\` 会被 pnpm 忽略。\`pnpm install --store-dir\` 不是修复。 / this profile's node_modules is linked to a different pnpm store than the one pnpm now resolves, so pnpm refuses every install and uninstall for it. This time the two paths could not be read from pnpm's output (its wording changed) — check the text above. The fix is to name the recorded store in the profile's pnpm-workspace.yaml under the camelCase key \`storeDir\` (single-quoted), then verify with \`pnpm store path\`; note that the environment variable PNPM_CONFIG_STORE_DIR outranks that file, and the kebab spelling \`store-dir\` is ignored. \`pnpm install --store-dir\` is not a fix.`,
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
const advice = storeRelinkAdvice(linked, wanted, context?.profileDirectory);
|
|
371
525
|
return {
|
|
372
526
|
code: 'unexpected-store',
|
|
373
527
|
recoverable: false,
|
|
374
|
-
message: `这个 profile 的 node_modules 链接到的 pnpm store,和 pnpm 现在解析出的 store 不是同一个,pnpm 因此拒绝这个 profile 的所有安装与卸载。典型触发是把 $DSH_HOME
|
|
528
|
+
message: `这个 profile 的 node_modules 链接到的 pnpm store,和 pnpm 现在解析出的 store 不是同一个,pnpm 因此拒绝这个 profile 的所有安装与卸载。典型触发是把 $DSH_HOME 或 pnpm 的 store 移到另一个盘:搬迁前建的 node_modules 记着旧盘上的 store,而 pnpm 会按新位置另选一个(#244 的另一种触发,见 #715)。${detail}\n${advice.zh}\n注意 \`pnpm install --store-dir <路径>\` **不是修复**:它只对那一次命令生效,也不会改写 node_modules/.modules.yaml 里的记录,所以下一条命令会报同样的错(pnpm 11.7 与 11.22 实测)。想改用 pnpm 现在解析出的那个 store 也行,但那要求清空并重装整个 node_modules(包全部重新下载),代价由你决定。 / this profile's node_modules is linked to a different pnpm store than the one pnpm now resolves, so pnpm refuses every install and uninstall for it. The usual trigger is moving $DSH_HOME or the pnpm store to another drive: a node_modules built before the move records the old disk's store while pnpm selects one for the new location (the other trigger for #244, see #715).${detail}\n${advice.en}\nNote that \`pnpm install --store-dir <path>\` is NOT a fix: it applies to that one command and does not rewrite the record in node_modules/.modules.yaml, so the next command fails exactly the same way (measured on pnpm 11.7 and 11.22). Switching to the store pnpm now resolves is also possible, but it requires purging and reinstalling the whole node_modules (every package re-downloaded) — your call, not the market's.`,
|
|
375
529
|
};
|
|
376
530
|
}
|
|
377
531
|
// #367: pnpm verifies every tarball resolution in the lockfile before it
|
package/lib/profile.js
CHANGED
|
@@ -1891,11 +1891,14 @@ function readReleaseAgeBlock(file) {
|
|
|
1891
1891
|
* nothing in the file says which main package it belongs to — guessing would
|
|
1892
1892
|
* delete policy that may still be in effect for something installed.
|
|
1893
1893
|
*
|
|
1894
|
+
* With `keepVersion` (the update path) the rows that name that version are
|
|
1895
|
+
* kept and only the older ones go.
|
|
1896
|
+
*
|
|
1894
1897
|
* @returns the entries removed, for the caller to log; empty when there is no
|
|
1895
1898
|
* such block, no such row, or the file cannot be read exactly (in which case
|
|
1896
1899
|
* it is left byte-for-byte as it was).
|
|
1897
1900
|
*/
|
|
1898
|
-
export function dropReleaseAgeExcludes(profile, name, explicitDir) {
|
|
1901
|
+
export function dropReleaseAgeExcludes(profile, name, explicitDir, keepVersion) {
|
|
1899
1902
|
const block = readReleaseAgeBlock(join(profileDir(profile, explicitDir), 'pnpm-workspace.yaml'));
|
|
1900
1903
|
if (block === null)
|
|
1901
1904
|
return [];
|
|
@@ -1906,6 +1909,19 @@ export function dropReleaseAgeExcludes(profile, name, explicitDir) {
|
|
|
1906
1909
|
return [item.line];
|
|
1907
1910
|
if (item.rule.name !== name)
|
|
1908
1911
|
return [item.original];
|
|
1912
|
+
// After an update (#1093) only rows that do not name the installed version
|
|
1913
|
+
// are stale. A row that names it stays whole — it may be the one pnpm just
|
|
1914
|
+
// wrote for this very update, which the next install's age check needs. A
|
|
1915
|
+
// union that also lists older versions stays too: it is kept or dropped as
|
|
1916
|
+
// written, never rewritten, so nothing here can loosen the gate. A bare
|
|
1917
|
+
// name already covers every version; that is a policy someone chose, not a
|
|
1918
|
+
// leftover.
|
|
1919
|
+
if (keepVersion !== undefined) {
|
|
1920
|
+
if (item.rule.selector === null)
|
|
1921
|
+
return [item.original];
|
|
1922
|
+
if (item.rule.selector.split('||').some(version => version.trim() === keepVersion))
|
|
1923
|
+
return [item.original];
|
|
1924
|
+
}
|
|
1909
1925
|
dropped.push(item.rule.selector === null ? item.rule.name : `${item.rule.name}@${item.rule.selector}`);
|
|
1910
1926
|
return [];
|
|
1911
1927
|
});
|
package/lib/release-updates.js
CHANGED
|
@@ -19,9 +19,16 @@ export function catalogReleaseSourceOf(spec, entry) {
|
|
|
19
19
|
if (url.protocol !== 'https:' || url.host !== 'github.com' || url.username !== '' || url.password !== '' || url.search !== '' || url.hash !== '')
|
|
20
20
|
return null;
|
|
21
21
|
}
|
|
22
|
-
const match = /^\/([^/]+\/[^/]+)\/releases\/(?:latest\/download|download\/[^/]+)\/([^/]+)$/.exec(installed.pathname);
|
|
23
|
-
if (match === null || match[1].toLowerCase() !== source.repo.toLowerCase()
|
|
22
|
+
const match = /^\/([^/]+\/[^/]+)\/releases\/(?:latest\/download|download\/([^/]+))\/([^/]+)$/.exec(installed.pathname);
|
|
23
|
+
if (match === null || match[1].toLowerCase() !== source.repo.toLowerCase())
|
|
24
24
|
return null;
|
|
25
|
+
const [, , tag, installedAsset] = match;
|
|
26
|
+
if (installedAsset !== asset) {
|
|
27
|
+
// A legacy filename can only add the version from its own stable release tag.
|
|
28
|
+
const version = /^v?(\d+\.\d+\.\d+)$/.exec(tag ?? '')?.[1];
|
|
29
|
+
if (version === undefined || installedAsset !== asset.replace(/\.(?:tgz|tar\.gz)$/, extension => `-${version}${extension}`))
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
25
32
|
return { repo: source.repo, asset, manifest: source.subpath === null ? 'package.json' : `${source.subpath}/package.json` };
|
|
26
33
|
}
|
|
27
34
|
catch {
|