dshmarket 1.73.21 → 1.73.22
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/README.md +15 -0
- package/README.zh.md +15 -0
- package/client/client.js +312 -64
- package/lib/gist.js +1 -1
- package/lib/install.js +33 -0
- package/lib/official-desktop.js +28 -1
- package/lib/release-blockers.js +177 -0
- package/lib/routes.js +31 -2
- package/lib/types/dsh-cli.d.ts +6 -0
- package/lib/types/gist.d.ts +1 -1
- package/lib/types/official-desktop.d.ts +4 -0
- package/lib/types/release-blockers.d.ts +34 -0
- package/lib/types/update-notifications.d.ts +6 -0
- package/lib/types/updates.d.ts +19 -0
- package/lib/update-notifications.js +6 -4
- package/lib/updates.js +16 -0
- package/locale/en.json +3 -1
- package/locale/ja.json +5 -0
- package/package.json +1 -1
package/lib/gist.js
CHANGED
|
@@ -308,7 +308,7 @@ async function sendGistRequest(token, method, path, body, action, signal) {
|
|
|
308
308
|
throw parseGistError(response.status, response.body, action);
|
|
309
309
|
return response;
|
|
310
310
|
}
|
|
311
|
-
/** Create a
|
|
311
|
+
/** Create a secret Gist carrying one backup file. */
|
|
312
312
|
export async function createGist(token, content, signal) {
|
|
313
313
|
const body = JSON.stringify({
|
|
314
314
|
description: 'dshmarket profile backup',
|
package/lib/install.js
CHANGED
|
@@ -11,6 +11,7 @@ import { findDshInstallDir } from './dsh-install.js';
|
|
|
11
11
|
import { classifyPnpmFailure, HOST_NAMESPACE_RE } from './pnpm-compat.js';
|
|
12
12
|
import { conflictingEntryIds, dropFromManifest, hasDshManifest, hasLoadableEntry, mergeDuplicateReleaseAgeExcludes, pluginSubdirs, profileDir, readGitResolutionCommit, readInstalled, readInstalledVersion, readLockCommits, readManifestDeps, readProfileBundles, dropUnparseableBuildKeys } from './profile.js';
|
|
13
13
|
import { logEvent } from './log.js';
|
|
14
|
+
import { clearReleaseBlockers, parseReleaseAgeBlockers, recordReleaseBlockers } from './release-blockers.js';
|
|
14
15
|
import { registryNameOf } from './official-desktop.js';
|
|
15
16
|
import { hostedRepoKey, NPM_NAME_RE } from './sources.js';
|
|
16
17
|
import { cleanOrphanedIgnored, cleanOrphanedStore } from './store.js';
|
|
@@ -120,6 +121,8 @@ export function isUnpublishedHostPeer(pkg, profile, explicitDir) {
|
|
|
120
121
|
*/
|
|
121
122
|
export async function withHoistRecovery(run, profile, pluginArgs, profileDirectory, options = {}) {
|
|
122
123
|
const marketFlags = options.marketFlags !== false;
|
|
124
|
+
/** The release-age bypass ran, so a success proves nothing about the lockfile (#1252). */
|
|
125
|
+
let bypassed = pluginArgs.includes(RELEASE_AGE_OVERRIDE);
|
|
123
126
|
// An already verified mature update must not rewrite the user's workspace
|
|
124
127
|
// policy as a side effect of market-level recovery (#991).
|
|
125
128
|
const repairProfilePolicy = options.preserveProfilePolicy !== true;
|
|
@@ -213,6 +216,7 @@ export async function withHoistRecovery(run, profile, pluginArgs, profileDirecto
|
|
|
213
216
|
}
|
|
214
217
|
else {
|
|
215
218
|
logEvent('warn', 'install', `a too-young release blocks pnpm's lockfile verification (#39) — retrying once with ${RELEASE_AGE_OVERRIDE}`);
|
|
219
|
+
bypassed = true;
|
|
216
220
|
result = await run(profile, [pluginArgs[0], RELEASE_AGE_OVERRIDE, ...pluginArgs.slice(1)]);
|
|
217
221
|
}
|
|
218
222
|
}
|
|
@@ -420,6 +424,7 @@ export async function withHoistRecovery(run, profile, pluginArgs, profileDirecto
|
|
|
420
424
|
logEvent('warn', 'install', `could not merge minimumReleaseAgeExclude after success (#883, #878): ${String(error)}`);
|
|
421
425
|
}
|
|
422
426
|
}
|
|
427
|
+
learnReleaseBlockers(profile, profileDirectory, pluginArgs, result, bypassed);
|
|
423
428
|
// After every mutation — success, failure, and cancel. Garbage lands in
|
|
424
429
|
// `.ignored` on the NEXT pnpm run, so a success-only hook would miss the
|
|
425
430
|
// run that just moved it there (#974). Must not fail the user's command.
|
|
@@ -432,6 +437,34 @@ export async function withHoistRecovery(run, profile, pluginArgs, profileDirecto
|
|
|
432
437
|
catch { /* cleanup must never fail the install */ }
|
|
433
438
|
return result;
|
|
434
439
|
}
|
|
440
|
+
/**
|
|
441
|
+
* Keep what the last run taught about the profile's young lockfile entries
|
|
442
|
+
* (#1252): a refusal names them, a success without the bypass proves there
|
|
443
|
+
* are none. Must never fail the user's command.
|
|
444
|
+
*/
|
|
445
|
+
function learnReleaseBlockers(profile, profileDirectory, pluginArgs, result, bypassed) {
|
|
446
|
+
try {
|
|
447
|
+
const verb = pluginArgs.find(argument => !argument.startsWith('-'));
|
|
448
|
+
const mutates = verb === 'add' || verb === 'remove' || verb === 'install' || verb === 'update';
|
|
449
|
+
if (!mutates || result.cancelled)
|
|
450
|
+
return;
|
|
451
|
+
const dir = profileDir(profile, profileDirectory);
|
|
452
|
+
if (result.exitCode === 0 && !result.timedOut) {
|
|
453
|
+
if (!bypassed)
|
|
454
|
+
clearReleaseBlockers(dir);
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
const output = `${result.stderr}\n${result.stdout}`;
|
|
458
|
+
if (classifyPnpmFailure(output, result.exitCode, { profileDirectory })?.code !== 'release-age-violation')
|
|
459
|
+
return;
|
|
460
|
+
const blockers = parseReleaseAgeBlockers(output, readMinimumReleaseAgeMs(profile, profileDirectory));
|
|
461
|
+
if (blockers.length === 0)
|
|
462
|
+
return;
|
|
463
|
+
recordReleaseBlockers(dir, blockers);
|
|
464
|
+
logEvent('warn', 'install', `the profile's lockfile holds ${blockers.length} release(s) still inside the safety wait (${blockers.slice(0, 3).map(blocker => `${blocker.name}@${blocker.version}${blocker.readyAt === null ? ' (end unknown)' : ` until ${blocker.readyAt}`}`).join(', ')}) — updates are held until then (#1252)`);
|
|
465
|
+
}
|
|
466
|
+
catch { /* bookkeeping must never fail the install */ }
|
|
467
|
+
}
|
|
435
468
|
/**
|
|
436
469
|
* The tail of the diagnostics file the dsh CLI pointed at, when it pointed at
|
|
437
470
|
* one (#672).
|
package/lib/official-desktop.js
CHANGED
|
@@ -393,6 +393,12 @@ async function installOrReinstall(manager, spec, options, context) {
|
|
|
393
393
|
// Nothing was unloaded, so there is nothing for a later start to repair.
|
|
394
394
|
if (record !== undefined)
|
|
395
395
|
context?.journal.finish(record.id);
|
|
396
|
+
// An update already landed behind a restart in this process, and the
|
|
397
|
+
// host now says `bundle-in-use` for a plugin it put back itself (#1253).
|
|
398
|
+
// It is the same wait for a restart, not a plugin that is really in use.
|
|
399
|
+
if (removed.application === 'failed' && managementCode(removed.error) === 'bundle-in-use' && restartPending()) {
|
|
400
|
+
return { ...removed, needsRestart: true };
|
|
401
|
+
}
|
|
396
402
|
return removed;
|
|
397
403
|
}
|
|
398
404
|
if (record !== undefined)
|
|
@@ -407,6 +413,8 @@ async function installOrReinstall(manager, spec, options, context) {
|
|
|
407
413
|
}
|
|
408
414
|
if (record !== undefined)
|
|
409
415
|
context?.journal.finish(record.id);
|
|
416
|
+
if (installed.application === 'restart-required')
|
|
417
|
+
markRestartPending();
|
|
410
418
|
return installed;
|
|
411
419
|
}
|
|
412
420
|
catch (error) {
|
|
@@ -427,6 +435,24 @@ async function installOrReinstall(manager, spec, options, context) {
|
|
|
427
435
|
* The slot lives on `globalThis` because a reload may evaluate this module
|
|
428
436
|
* again, which a module-level variable would not survive.
|
|
429
437
|
*/
|
|
438
|
+
const RESTART_SLOT = Symbol.for('dshmarket.officialDesktop.restartPending');
|
|
439
|
+
/**
|
|
440
|
+
* Whether an update in THIS host process already settled behind a restart.
|
|
441
|
+
* On the global like the slots below: a market reload keeps the process, and
|
|
442
|
+
* the process is what has to restart.
|
|
443
|
+
*/
|
|
444
|
+
function restartPending() {
|
|
445
|
+
return globalThis[RESTART_SLOT] === true;
|
|
446
|
+
}
|
|
447
|
+
function markRestartPending() {
|
|
448
|
+
globalThis[RESTART_SLOT] = true;
|
|
449
|
+
}
|
|
450
|
+
/** Test seam: a new host process starts with nothing pending. */
|
|
451
|
+
export function forgetRestartPending() {
|
|
452
|
+
delete globalThis[RESTART_SLOT];
|
|
453
|
+
}
|
|
454
|
+
/** What the user reads when the host asks for a restart before the next update (#1253). */
|
|
455
|
+
const RESTART_FIRST_MESSAGE = '这一轮只能更新到这里。重启后再点「全部更新」继续。 / This run can only go this far. Restart, then click Update all to continue.';
|
|
430
456
|
const OPERATION_SLOT = Symbol.for('dshmarket.officialDesktop.operation');
|
|
431
457
|
const WRITE_SLOT = Symbol.for('dshmarket.officialDesktop.packageWrites');
|
|
432
458
|
/** Keep the native promises across a market reload, including after a route deadline. */
|
|
@@ -592,7 +618,7 @@ packageManager) {
|
|
|
592
618
|
result.packageResult?.output ?? '',
|
|
593
619
|
result.application === 'overridden' ? 'the plugin manager kept this change, but another layer overrides whether it is enabled' : '',
|
|
594
620
|
].filter(Boolean).join('\n');
|
|
595
|
-
const message = ok ? '' : detail(result.error);
|
|
621
|
+
const message = ok ? '' : result.needsRestart === true ? RESTART_FIRST_MESSAGE : detail(result.error);
|
|
596
622
|
if (!ok)
|
|
597
623
|
progress.error = message;
|
|
598
624
|
// The manager never settled: the profile may be half-updated, so this
|
|
@@ -617,6 +643,7 @@ packageManager) {
|
|
|
617
643
|
// The manager's own code, kept machine-readable (#909): a client can
|
|
618
644
|
// tell a self-update refusal from an ordinary failure.
|
|
619
645
|
...(ok ? {} : { refusalCode: managementCode(result.error) }),
|
|
646
|
+
...(result.needsRestart === true ? { needsRestart: true } : {}),
|
|
620
647
|
};
|
|
621
648
|
}, (error) => {
|
|
622
649
|
const message = detail(error);
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Profile-level fresh-release blockers (#1252).
|
|
3
|
+
*
|
|
4
|
+
* pnpm checks the WHOLE lockfile against `minimumReleaseAge` before it lets
|
|
5
|
+
* any change through. One young entry (say `dsh-mobile-plugin@0.5.71`) makes
|
|
6
|
+
* every update, install and removal of that profile fail, whichever plugin
|
|
7
|
+
* the user clicked. The update check only judges each plugin's own target
|
|
8
|
+
* (#945), so every row still looked updatable.
|
|
9
|
+
*
|
|
10
|
+
* The market does not ask the registry for the publish time of every lockfile
|
|
11
|
+
* entry. It learns from the first refusal instead: pnpm prints each offending
|
|
12
|
+
* `name@version` with its publish time, and that is kept here until the wait
|
|
13
|
+
* ends. No extra registry traffic, and nothing is guessed: a time that cannot
|
|
14
|
+
* be read is recorded as unknown and held for a short, fixed time (#961).
|
|
15
|
+
*/
|
|
16
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
17
|
+
import { dirname, join } from 'node:path';
|
|
18
|
+
/** How long a blocker with an unknown end time is believed (same as #961). */
|
|
19
|
+
export const UNKNOWN_BLOCKER_TTL_MS = 30 * 60 * 1000;
|
|
20
|
+
const MAX_BLOCKERS = 50;
|
|
21
|
+
const FILE = join('.dsh-market', 'release-blockers.json');
|
|
22
|
+
const ISO_TIME = /\d{4}-\d{2}-\d{2}T[\d:.]+(?:Z|[+-]\d{2}:?\d{2})/;
|
|
23
|
+
const LINE = /^\s*((?:@[^/\s@]+\/)?[^\s@]+)@(\d[^\s]*?)\s+was published at\b(.*)$/;
|
|
24
|
+
/** `a-{x,y}` becomes `a-x`, `a-y`; any other name is returned as is. */
|
|
25
|
+
function expandBraces(name) {
|
|
26
|
+
const match = /^(.*)\{([^{}]+)\}(.*)$/.exec(name);
|
|
27
|
+
if (match === null)
|
|
28
|
+
return [name];
|
|
29
|
+
return match[2].split(',').map(part => `${match[1]}${part.trim()}${match[3]}`);
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Read the entries pnpm refused out of its violation output.
|
|
33
|
+
* @param output - pnpm's combined stdout and stderr.
|
|
34
|
+
* @param windowMs - the profile's effective wait, or null when it is unknown.
|
|
35
|
+
* @param now - epoch ms, injectable for tests.
|
|
36
|
+
* @returns one blocker per `name@version`; empty when the output names none.
|
|
37
|
+
*/
|
|
38
|
+
export function parseReleaseAgeBlockers(output, windowMs, now = Date.now()) {
|
|
39
|
+
// Only the lockfile verification lists entries that are already in the
|
|
40
|
+
// profile. Any other release-age failure is about a target and says nothing
|
|
41
|
+
// about what else would be refused.
|
|
42
|
+
if (!output.includes('ERR_PNPM_MINIMUM_RELEASE_AGE_VIOLATION') || !/lockfile entr(?:y|ies) failed verification/.test(output))
|
|
43
|
+
return [];
|
|
44
|
+
const seen = new Set();
|
|
45
|
+
const blockers = [];
|
|
46
|
+
for (const line of output.split(/\r?\n/)) {
|
|
47
|
+
const match = LINE.exec(line);
|
|
48
|
+
if (match === null)
|
|
49
|
+
continue;
|
|
50
|
+
const time = ISO_TIME.exec(match[3] ?? '')?.[0];
|
|
51
|
+
const published = time === undefined ? Number.NaN : Date.parse(time);
|
|
52
|
+
const publishedAt = Number.isFinite(published) ? new Date(published).toISOString() : null;
|
|
53
|
+
// A window that would already have ended contradicts pnpm's refusal: the
|
|
54
|
+
// market is reading a different wait than pnpm used. Say "unknown" rather
|
|
55
|
+
// than record a wait that is over and would never be believed.
|
|
56
|
+
const ready = publishedAt === null || windowMs === null ? null : published + windowMs;
|
|
57
|
+
const readyAt = ready === null || ready <= now ? null : new Date(ready).toISOString();
|
|
58
|
+
for (const name of expandBraces(match[1])) {
|
|
59
|
+
const key = `${name}@${match[2]}`;
|
|
60
|
+
if (seen.has(key))
|
|
61
|
+
continue;
|
|
62
|
+
seen.add(key);
|
|
63
|
+
blockers.push({ name, version: match[2], publishedAt, readyAt });
|
|
64
|
+
if (blockers.length >= MAX_BLOCKERS)
|
|
65
|
+
return blockers;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return blockers;
|
|
69
|
+
}
|
|
70
|
+
const memory = new Map();
|
|
71
|
+
function load(dir) {
|
|
72
|
+
const cached = memory.get(dir);
|
|
73
|
+
if (cached !== undefined)
|
|
74
|
+
return cached;
|
|
75
|
+
let loaded = [];
|
|
76
|
+
try {
|
|
77
|
+
const raw = JSON.parse(readFileSync(join(dir, FILE), 'utf8'));
|
|
78
|
+
if (Array.isArray(raw.blockers)) {
|
|
79
|
+
loaded = raw.blockers.flatMap((item) => {
|
|
80
|
+
const entry = item;
|
|
81
|
+
if (entry === null || typeof entry !== 'object')
|
|
82
|
+
return [];
|
|
83
|
+
if (typeof entry.name !== 'string' || typeof entry.version !== 'string' || typeof entry.learnedAt !== 'number')
|
|
84
|
+
return [];
|
|
85
|
+
return [{
|
|
86
|
+
name: entry.name, version: entry.version, learnedAt: entry.learnedAt,
|
|
87
|
+
publishedAt: typeof entry.publishedAt === 'string' ? entry.publishedAt : null,
|
|
88
|
+
readyAt: typeof entry.readyAt === 'string' ? entry.readyAt : null,
|
|
89
|
+
}];
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch { /* no file, or unreadable: start empty */ }
|
|
94
|
+
memory.set(dir, loaded);
|
|
95
|
+
return loaded;
|
|
96
|
+
}
|
|
97
|
+
function save(dir, blockers) {
|
|
98
|
+
memory.set(dir, blockers);
|
|
99
|
+
try {
|
|
100
|
+
const file = join(dir, FILE);
|
|
101
|
+
mkdirSync(dirname(file), { recursive: true, mode: 0o700 });
|
|
102
|
+
writeFileSync(file, JSON.stringify({ blockers }));
|
|
103
|
+
}
|
|
104
|
+
catch { /* memory still holds it; a restart just relearns on the next refusal */ }
|
|
105
|
+
}
|
|
106
|
+
/** Remember what pnpm just refused, replacing whatever was known for this profile. */
|
|
107
|
+
export function recordReleaseBlockers(dir, blockers, now = Date.now()) {
|
|
108
|
+
if (blockers.length === 0)
|
|
109
|
+
return;
|
|
110
|
+
save(dir, blockers.map(blocker => ({ ...blocker, learnedAt: now })));
|
|
111
|
+
}
|
|
112
|
+
/** Forget every blocker of this profile (a mutation went through without a bypass). */
|
|
113
|
+
export function clearReleaseBlockers(dir) {
|
|
114
|
+
if (load(dir).length === 0)
|
|
115
|
+
return;
|
|
116
|
+
save(dir, []);
|
|
117
|
+
}
|
|
118
|
+
/** Test seam: drop the in-memory copy so the next read comes from disk (a restart). */
|
|
119
|
+
export function forgetReleaseBlockerMemory() {
|
|
120
|
+
memory.clear();
|
|
121
|
+
}
|
|
122
|
+
/** Whether the lockfile still pins `name@version`; true when it cannot be read. */
|
|
123
|
+
function lockfileStillHas(dir, blocker) {
|
|
124
|
+
let text;
|
|
125
|
+
try {
|
|
126
|
+
text = readFileSync(join(dir, 'pnpm-lock.yaml'), 'utf8');
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
return true;
|
|
130
|
+
}
|
|
131
|
+
const escaped = `${blocker.name}@${blocker.version}`.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
132
|
+
return new RegExp(`(?:^|[\\s'"/(])${escaped}(?![\\w.+-])`, 'm').test(text);
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* The blockers that still hold, with the ended and the departed dropped.
|
|
136
|
+
* A blocker ends at its time, or after {@link UNKNOWN_BLOCKER_TTL_MS} when
|
|
137
|
+
* the time is unknown, or as soon as the lockfile no longer pins it.
|
|
138
|
+
*/
|
|
139
|
+
export function activeReleaseBlockers(dir, now = Date.now()) {
|
|
140
|
+
const all = load(dir);
|
|
141
|
+
if (all.length === 0)
|
|
142
|
+
return [];
|
|
143
|
+
const live = all.filter(blocker => (blocker.readyAt === null
|
|
144
|
+
? blocker.learnedAt + UNKNOWN_BLOCKER_TTL_MS > now
|
|
145
|
+
: Date.parse(blocker.readyAt) > now) && lockfileStillHas(dir, blocker));
|
|
146
|
+
if (live.length !== all.length)
|
|
147
|
+
save(dir, live);
|
|
148
|
+
return live.map(({ learnedAt: _learnedAt, ...blocker }) => blocker);
|
|
149
|
+
}
|
|
150
|
+
/** The one blocker to name: an unknown time first (nothing is certain), else the last to end. */
|
|
151
|
+
export function headlineBlocker(blockers) {
|
|
152
|
+
let best = null;
|
|
153
|
+
for (const blocker of blockers) {
|
|
154
|
+
if (blocker.readyAt === null)
|
|
155
|
+
return blocker;
|
|
156
|
+
if (best === null || Date.parse(blocker.readyAt) > Date.parse(best.readyAt))
|
|
157
|
+
best = blocker;
|
|
158
|
+
}
|
|
159
|
+
return best;
|
|
160
|
+
}
|
|
161
|
+
function pad(value) {
|
|
162
|
+
return String(value).padStart(2, '0');
|
|
163
|
+
}
|
|
164
|
+
/** `11-19 12:56` in the server's local time. */
|
|
165
|
+
function clock(at) {
|
|
166
|
+
const date = new Date(at);
|
|
167
|
+
return `${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
168
|
+
}
|
|
169
|
+
/** What the update route says when it declines to start (bilingual, `zh / en`). */
|
|
170
|
+
export function releaseBlockedMessage(blocker) {
|
|
171
|
+
const what = `${blocker.name} ${blocker.version}`;
|
|
172
|
+
if (blocker.readyAt === null) {
|
|
173
|
+
return `要等 ${what} 满安全等待期后才能更新(时间未知)。在那之前,任何插件都更新不了,所以没有开始。 / Updates wait until ${what} has passed the safety wait (time unknown). Until then no plugin can be updated, so nothing was started.`;
|
|
174
|
+
}
|
|
175
|
+
const when = clock(blocker.readyAt);
|
|
176
|
+
return `要等 ${what} 满安全等待期(约 ${when})后才能更新。在那之前,任何插件都更新不了,所以没有开始。 / Updates wait until ${what} has passed the safety wait (about ${when}). Until then no plugin can be updated, so nothing was started.`;
|
|
177
|
+
}
|
package/lib/routes.js
CHANGED
|
@@ -50,7 +50,8 @@ import { acceleratedTarget, resolveHeadCommit } from './accelerate.js';
|
|
|
50
50
|
import { mismatchedWorkspaceRoot } from './github-install-target.js';
|
|
51
51
|
import { sourceWebUrl, updateNotesFor } from './changelog.js';
|
|
52
52
|
import { isCommitId } from './release-history.js';
|
|
53
|
-
import {
|
|
53
|
+
import { activeReleaseBlockers, headlineBlocker, releaseBlockedMessage } from './release-blockers.js';
|
|
54
|
+
import { applyProfileBlockers, checkUpdates, isUpdatablePlugin, compareVersions, fetchNpmLatest, invalidateUpdates, readVersionMaturity, resolveDesktopMatureUpdate, resolveGitRemoteHead, isUpgrade, latestPublishedRecently, setUpdateRegistry, versionOnChannel } from './updates.js';
|
|
54
55
|
import { isExactReleaseVersion, isStableReleaseVersion } from './release-candidates.js';
|
|
55
56
|
import { createUpdateNotificationMonitor } from './update-notifications.js';
|
|
56
57
|
import { DEFAULT_UPDATE_CHECK_INTERVAL_HOURS, isUpdateCheckIntervalHours } from './update-notification-settings.js';
|
|
@@ -2979,6 +2980,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
2979
2980
|
profileKey: createHash('sha256').update(activeProfileDir).digest('hex'),
|
|
2980
2981
|
enabled: marketState.backgroundUpdateChecks === true,
|
|
2981
2982
|
intervalHours: marketState.backgroundUpdateIntervalHours,
|
|
2983
|
+
overlay: updates => applyProfileBlockers(updates, activeProfileDir),
|
|
2982
2984
|
inventory: () => {
|
|
2983
2985
|
const installed = readInstalled(config.profile, activeProfileDir);
|
|
2984
2986
|
const commits = readLockCommits(config.profile, activeProfileDir);
|
|
@@ -4766,6 +4768,8 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
4766
4768
|
}
|
|
4767
4769
|
if (favorites.length >= MAX_FAVORITES) {
|
|
4768
4770
|
sendJson(response, 400, {
|
|
4771
|
+
code: 'FAVORITES_LIMIT_REACHED',
|
|
4772
|
+
limit: MAX_FAVORITES,
|
|
4769
4773
|
error: `favorites limit reached (${String(MAX_FAVORITES)}) / 收藏已达上限(${String(MAX_FAVORITES)})`,
|
|
4770
4774
|
});
|
|
4771
4775
|
return;
|
|
@@ -6338,6 +6342,25 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
6338
6342
|
detail: `更新前的来源 ${spec} 不是受支持的精确回滚目标(${previousVersionZh}),因此自动回滚不可用;需要时请从可信来源手工重新安装先前版本。 / The previous source ${spec} is not a supported exact rollback target (${previousVersionEn}), so automatic rollback is unavailable. Reinstall the prior version manually from a trusted source if needed.`,
|
|
6339
6343
|
lockfileBefore: lockfileCapture.snapshot,
|
|
6340
6344
|
};
|
|
6345
|
+
// Another release already in this profile is still inside the safety
|
|
6346
|
+
// wait (#1252). pnpm checks the whole lockfile before any change, so
|
|
6347
|
+
// this update would fail exactly as the last one did — and write
|
|
6348
|
+
// and restore the profile on the way. Where a one-shot bypass is
|
|
6349
|
+
// available the run can still succeed, so only the hosts without
|
|
6350
|
+
// one (the official Desktop, mature-only updates) stop here.
|
|
6351
|
+
if (!marketFlags || enforceMatureReleaseAge) {
|
|
6352
|
+
const blocker = headlineBlocker(activeReleaseBlockers(activeProfileDir));
|
|
6353
|
+
if (blocker !== null) {
|
|
6354
|
+
logEvent('info', 'update-held', `${name}: not started — ${blocker.name}@${blocker.version} in this profile is still inside the safety wait${blocker.readyAt === null ? ' (end unknown)' : ` until ${blocker.readyAt}`} (#1252)`);
|
|
6355
|
+
sendJson(response, 409, {
|
|
6356
|
+
ok: false,
|
|
6357
|
+
failureCode: 'PROFILE_RELEASE_BLOCKED',
|
|
6358
|
+
profileBlocked: { name: blocker.name, version: blocker.version, readyAt: blocker.readyAt },
|
|
6359
|
+
error: releaseBlockedMessage(blocker),
|
|
6360
|
+
});
|
|
6361
|
+
return;
|
|
6362
|
+
}
|
|
6363
|
+
}
|
|
6341
6364
|
// The desktop host names the package a run installed by diffing the
|
|
6342
6365
|
// profile manifest before and after pnpm. A floating re-resolve is
|
|
6343
6366
|
// sent as the bare remote URL, which pnpm writes back byte-for-byte
|
|
@@ -7084,6 +7107,11 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7084
7107
|
if (ok)
|
|
7085
7108
|
recordUpdated(activeProfileDir, [name]);
|
|
7086
7109
|
logEvent(ok || cancelled ? 'info' : 'error', 'update', `${name} -> ${target} exit=${String(result.exitCode)}${result.timedOut ? ' TIMEOUT' : ''}${cancelled ? ' CANCELLED' : ''}${stale ? ` STALE(${staleReason ?? 'unknown'})` : ''}${ok || cancelled ? '' : ` err=${failureDetail(result)}`}`);
|
|
7110
|
+
// The run this update just made is what taught the market which
|
|
7111
|
+
// release is in the way (#1252): say it by name, with the time.
|
|
7112
|
+
const learnedBlocker = !ok && !cancelled && pnpmRefusedYoungRelease(result)
|
|
7113
|
+
? headlineBlocker(activeReleaseBlockers(activeProfileDir))
|
|
7114
|
+
: null;
|
|
7087
7115
|
// A user-cancelled run is a quiet outcome, not an error.
|
|
7088
7116
|
sendJson(response, ok || cancelled ? 200 : result.busy === true ? 409 : 502, {
|
|
7089
7117
|
ok,
|
|
@@ -7103,7 +7131,8 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
7103
7131
|
// The host's own refusal code when it stopped before pnpm
|
|
7104
7132
|
// (#909): `market-self-update` tells a client that the button
|
|
7105
7133
|
// cannot work on this host, not that the update was broken.
|
|
7106
|
-
failureCode: versionFailureCode ?? result.refusalCode ?? undefined,
|
|
7134
|
+
failureCode: versionFailureCode ?? (result.needsRestart === true ? 'RESTART_REQUIRED' : undefined) ?? result.refusalCode ?? (learnedBlocker === null ? undefined : 'PROFILE_RELEASE_BLOCKED'),
|
|
7135
|
+
...(learnedBlocker === null ? {} : { profileBlocked: { name: learnedBlocker.name, version: learnedBlocker.version, readyAt: learnedBlocker.readyAt } }),
|
|
7107
7136
|
renamedTo: renamedTo ?? undefined,
|
|
7108
7137
|
removedDeclaration: removedDeclaration ?? undefined,
|
|
7109
7138
|
// #1047: no version could be pinned, so this is the one pnpm
|
package/lib/types/dsh-cli.d.ts
CHANGED
|
@@ -194,6 +194,12 @@ export interface InstallResult {
|
|
|
194
194
|
* an ordinary failure without parsing a sentence.
|
|
195
195
|
*/
|
|
196
196
|
refusalCode?: string;
|
|
197
|
+
/**
|
|
198
|
+
* The desktop host refused with `bundle-in-use` after an update already
|
|
199
|
+
* settled behind a restart in this process (#1253): the answer is "restart",
|
|
200
|
+
* not "that plugin is in use".
|
|
201
|
+
*/
|
|
202
|
+
needsRestart?: boolean;
|
|
197
203
|
/** Package names pnpm reported as having ignored build scripts (ndjson). */
|
|
198
204
|
ignoredBuilds?: string[];
|
|
199
205
|
/**
|
package/lib/types/gist.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare function ghAuthSpawnOptions(platform?: NodeJS.Platform): {
|
|
|
67
67
|
detached: boolean;
|
|
68
68
|
windowsHide: boolean;
|
|
69
69
|
};
|
|
70
|
-
/** Create a
|
|
70
|
+
/** Create a secret Gist carrying one backup file. */
|
|
71
71
|
export declare function createGist(token: string, content: string, signal?: AbortSignal): Promise<GistRef>;
|
|
72
72
|
/** Overwrite the backup file inside an existing Gist (other files kept). */
|
|
73
73
|
export declare function updateGist(token: string, gistId: string, content: string, signal?: AbortSignal): Promise<GistRef>;
|
|
@@ -13,6 +13,8 @@ interface ManagedResult {
|
|
|
13
13
|
* must not try to "restore" it through the same stuck manager.
|
|
14
14
|
*/
|
|
15
15
|
repairOnRestart?: boolean;
|
|
16
|
+
/** The refusal is the host's restart-first state, not a plugin in use (#1253). */
|
|
17
|
+
needsRestart?: boolean;
|
|
16
18
|
}
|
|
17
19
|
export interface OfficialPluginManagerLike {
|
|
18
20
|
installBundle(spec: string, options?: {
|
|
@@ -30,6 +32,8 @@ export interface OfficialPluginManagerLike {
|
|
|
30
32
|
export declare const OFFICIAL_PAGE_HINT = "\u5B98\u65B9\u684C\u9762\u5BA2\u6237\u7AEF\u7684\u8FD9\u4E2A\u63D2\u4EF6\u64CD\u4F5C\u9700\u8981\u5728\u300C\u8BBE\u7F6E \u2192 \u63D2\u4EF6\u300D\u91CC\u5B8C\u6210\uFF1B\u5E02\u573A\u65E0\u6CD5\u901A\u8FC7\u547D\u4EE4\u884C\u4FEE\u6539\u684C\u9762\u7AEF\u7684 profile\u3002 / On the official desktop app, do this from Settings \u2192 Plugins; the market cannot change the desktop profile through the command line.";
|
|
31
33
|
/** `dshmarket@1.66.32` → `dshmarket`; anything that is not a registry name stays unparsed. */
|
|
32
34
|
export declare function registryNameOf(spec: string): string | undefined;
|
|
35
|
+
/** Test seam: a new host process starts with nothing pending. */
|
|
36
|
+
export declare function forgetRestartPending(): void;
|
|
33
37
|
/** The official runtime's own surface, plus the repair a later start owes the profile. */
|
|
34
38
|
export interface OfficialDesktopRuntime extends DesktopPluginRuntime {
|
|
35
39
|
/**
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export interface ReleaseBlocker {
|
|
2
|
+
name: string;
|
|
3
|
+
version: string;
|
|
4
|
+
/** ISO time pnpm printed, or null when it printed none we can read. */
|
|
5
|
+
publishedAt: string | null;
|
|
6
|
+
/** ISO time the safety wait ends, or null when it cannot be worked out. */
|
|
7
|
+
readyAt: string | null;
|
|
8
|
+
}
|
|
9
|
+
/** How long a blocker with an unknown end time is believed (same as #961). */
|
|
10
|
+
export declare const UNKNOWN_BLOCKER_TTL_MS: number;
|
|
11
|
+
/**
|
|
12
|
+
* Read the entries pnpm refused out of its violation output.
|
|
13
|
+
* @param output - pnpm's combined stdout and stderr.
|
|
14
|
+
* @param windowMs - the profile's effective wait, or null when it is unknown.
|
|
15
|
+
* @param now - epoch ms, injectable for tests.
|
|
16
|
+
* @returns one blocker per `name@version`; empty when the output names none.
|
|
17
|
+
*/
|
|
18
|
+
export declare function parseReleaseAgeBlockers(output: string, windowMs: number | null, now?: number): ReleaseBlocker[];
|
|
19
|
+
/** Remember what pnpm just refused, replacing whatever was known for this profile. */
|
|
20
|
+
export declare function recordReleaseBlockers(dir: string, blockers: readonly ReleaseBlocker[], now?: number): void;
|
|
21
|
+
/** Forget every blocker of this profile (a mutation went through without a bypass). */
|
|
22
|
+
export declare function clearReleaseBlockers(dir: string): void;
|
|
23
|
+
/** Test seam: drop the in-memory copy so the next read comes from disk (a restart). */
|
|
24
|
+
export declare function forgetReleaseBlockerMemory(): void;
|
|
25
|
+
/**
|
|
26
|
+
* The blockers that still hold, with the ended and the departed dropped.
|
|
27
|
+
* A blocker ends at its time, or after {@link UNKNOWN_BLOCKER_TTL_MS} when
|
|
28
|
+
* the time is unknown, or as soon as the lockfile no longer pins it.
|
|
29
|
+
*/
|
|
30
|
+
export declare function activeReleaseBlockers(dir: string, now?: number): ReleaseBlocker[];
|
|
31
|
+
/** The one blocker to name: an unknown time first (nothing is certain), else the last to end. */
|
|
32
|
+
export declare function headlineBlocker(blockers: readonly ReleaseBlocker[]): ReleaseBlocker | null;
|
|
33
|
+
/** What the update route says when it declines to start (bilingual, `zh / en`). */
|
|
34
|
+
export declare function releaseBlockedMessage(blocker: ReleaseBlocker): string;
|
|
@@ -38,6 +38,12 @@ interface MonitorDependencies {
|
|
|
38
38
|
updates: Record<string, UpdateStatus>;
|
|
39
39
|
error?: string;
|
|
40
40
|
}>;
|
|
41
|
+
/**
|
|
42
|
+
* Applied to every answer on the way out, never stored: facts that change
|
|
43
|
+
* between checks (a profile-level wait learned from a failed click, #1252)
|
|
44
|
+
* must show on the next read, not the next poll.
|
|
45
|
+
*/
|
|
46
|
+
overlay?(updates: Record<string, UpdateStatus>): Record<string, UpdateStatus>;
|
|
41
47
|
}
|
|
42
48
|
export interface UpdateNotificationMonitor {
|
|
43
49
|
snapshot(): UpdateNotificationSnapshot;
|
package/lib/types/updates.d.ts
CHANGED
|
@@ -84,6 +84,18 @@ export interface UpdateStatus {
|
|
|
84
84
|
until: string;
|
|
85
85
|
estimated?: true;
|
|
86
86
|
};
|
|
87
|
+
/**
|
|
88
|
+
* An update exists, but ANOTHER release already in this profile's lockfile
|
|
89
|
+
* is still inside the safety wait, and pnpm refuses every change until it is
|
|
90
|
+
* past (#1252). Separate from {@link heldUpdate}, which is about this
|
|
91
|
+
* plugin's own target. `readyAt` is null when the end time is unknown.
|
|
92
|
+
* `updateAvailable` is false while this is set.
|
|
93
|
+
*/
|
|
94
|
+
profileBlocked?: {
|
|
95
|
+
name: string;
|
|
96
|
+
version: string;
|
|
97
|
+
readyAt: string | null;
|
|
98
|
+
};
|
|
87
99
|
/**
|
|
88
100
|
* The version this package's channel points at, when it differs from what
|
|
89
101
|
* is installed and is NOT newer.
|
|
@@ -241,6 +253,13 @@ export declare function fetchNpmLatest(name: string): Promise<string | null>;
|
|
|
241
253
|
* without the market volunteering anyone's prerelease as an update.
|
|
242
254
|
*/
|
|
243
255
|
export declare function newerPrereleaseFor(name: string, installed: string | null): Promise<string | null>;
|
|
256
|
+
/**
|
|
257
|
+
* Mark the updates a known profile-level blocker would turn into a failed
|
|
258
|
+
* click (#1252). Applied to what is served, not to the cached registry
|
|
259
|
+
* answer, so a blocker learned a second ago and one that just ended both show
|
|
260
|
+
* on the very next read without another round of registry traffic.
|
|
261
|
+
*/
|
|
262
|
+
export declare function applyProfileBlockers(statuses: Record<string, UpdateStatus>, activeProfileDir: string, now?: number): Record<string, UpdateStatus>;
|
|
244
263
|
/** Check each plugin independently so a failed lookup leaves the other results usable. */
|
|
245
264
|
export declare function checkUpdates(profile: string, force?: boolean, explicitDir?: string,
|
|
246
265
|
/**
|
|
@@ -55,13 +55,15 @@ export function createUpdateNotificationMonitor(deps) {
|
|
|
55
55
|
if (disposed || !enabled)
|
|
56
56
|
return;
|
|
57
57
|
nextCheckAt = Date.now() + delay;
|
|
58
|
-
timer = setTimeout(() => { void
|
|
58
|
+
timer = setTimeout(() => { void runCheck(stale); }, delay);
|
|
59
59
|
timer.unref?.();
|
|
60
60
|
};
|
|
61
61
|
const nextDelay = () => failures > 0
|
|
62
62
|
? Math.min(RETRY_MAX_MS, RETRY_BASE_MS * 2 ** Math.min(failures - 1, 5))
|
|
63
63
|
: intervalHours * 60 * 60_000;
|
|
64
|
-
const
|
|
64
|
+
const view = (value) => deps.overlay === undefined ? value : deps.overlay(value);
|
|
65
|
+
const check = (force = false) => deps.overlay === undefined ? runCheck(force) : runCheck(force).then(view);
|
|
66
|
+
const runCheck = (force = false) => {
|
|
65
67
|
if (disposed)
|
|
66
68
|
return Promise.resolve({ ...updates });
|
|
67
69
|
if (pending !== null) {
|
|
@@ -69,7 +71,7 @@ export function createUpdateNotificationMonitor(deps) {
|
|
|
69
71
|
return pending;
|
|
70
72
|
// A manual refresh arriving during a cache-eligible read must still
|
|
71
73
|
// bypass that cache, once. Several such callers share the follow-up.
|
|
72
|
-
queuedForce ??= pending.then(() =>
|
|
74
|
+
queuedForce ??= pending.then(() => runCheck(true)).finally(() => { queuedForce = null; });
|
|
73
75
|
return queuedForce;
|
|
74
76
|
}
|
|
75
77
|
stopTimer();
|
|
@@ -136,7 +138,7 @@ export function createUpdateNotificationMonitor(deps) {
|
|
|
136
138
|
reconcile();
|
|
137
139
|
return {
|
|
138
140
|
enabled, intervalHours, checking: pending !== null, checkedAt, lastSuccessAt, nextCheckAt,
|
|
139
|
-
stale, error, updates: { ...updates }, boot: deps.boot, ...deps.preferences(),
|
|
141
|
+
stale, error, updates: view({ ...updates }), boot: deps.boot, ...deps.preferences(),
|
|
140
142
|
...(deps.profileKey === undefined ? {} : { profileKey: deps.profileKey }),
|
|
141
143
|
};
|
|
142
144
|
},
|
package/lib/updates.js
CHANGED
|
@@ -17,6 +17,7 @@ import { isNumericReleaseAgeWindow, readMinimumReleaseAgeMs } from './install.js
|
|
|
17
17
|
import { isStableReleaseVersion, selectMatureUpdate, versionMaturity } from './release-candidates.js';
|
|
18
18
|
import { hasDshManifest, profileDir, readGitResolutionCommit, readInstalled, readInstalledVersion, readLockCommits, readProfileBundles } from './profile.js';
|
|
19
19
|
import { userPatchPackageReferences } from './patch.js';
|
|
20
|
+
import { activeReleaseBlockers, headlineBlocker } from './release-blockers.js';
|
|
20
21
|
import { catalogRepoKey, gitCommitOfTarget, gitRefOfTarget, gitUploadPackUrl, hasSemverSelector, hostedRepoKey, githubCommitOfTarget, githubRefOfTarget, isGenerationLink, isGitHostedSpec, lookupRepoFromUrl, parseGitHubRemote, repoOfTarget } from './sources.js';
|
|
21
22
|
/**
|
|
22
23
|
* Whether a direct dependency is a plugin the update channel can apply (#793).
|
|
@@ -718,6 +719,21 @@ async function releaseAgeHold(name, latest, profile, activeProfileDir) {
|
|
|
718
719
|
const until = age.at + windowMs;
|
|
719
720
|
return until > Date.now() ? { until: new Date(until).toISOString(), estimated: false } : 'past';
|
|
720
721
|
}
|
|
722
|
+
/**
|
|
723
|
+
* Mark the updates a known profile-level blocker would turn into a failed
|
|
724
|
+
* click (#1252). Applied to what is served, not to the cached registry
|
|
725
|
+
* answer, so a blocker learned a second ago and one that just ended both show
|
|
726
|
+
* on the very next read without another round of registry traffic.
|
|
727
|
+
*/
|
|
728
|
+
export function applyProfileBlockers(statuses, activeProfileDir, now = Date.now()) {
|
|
729
|
+
if (!Object.values(statuses).some(status => status.updateAvailable === true))
|
|
730
|
+
return statuses;
|
|
731
|
+
const blocker = headlineBlocker(activeReleaseBlockers(activeProfileDir, now));
|
|
732
|
+
if (blocker === null)
|
|
733
|
+
return statuses;
|
|
734
|
+
const profileBlocked = { name: blocker.name, version: blocker.version, readyAt: blocker.readyAt };
|
|
735
|
+
return Object.fromEntries(Object.entries(statuses).map(([name, status]) => [name, status.updateAvailable === true ? { ...status, updateAvailable: false, profileBlocked } : status]));
|
|
736
|
+
}
|
|
721
737
|
/** A hold expiration invalidates evidence; it cannot itself authorize an install. */
|
|
722
738
|
function nextHoldRecheck(data) {
|
|
723
739
|
return Math.min(...Object.values(data).flatMap(status => status.heldUpdate === undefined ? [] : [Date.parse(status.heldUpdate.until)]));
|
package/locale/en.json
CHANGED
package/locale/ja.json
ADDED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dshmarket",
|
|
3
3
|
"description": "Visual plugin market inside DeepSeek Harness — browse, search, and one-click install community plugins. · DSH 可视化插件市场:逛一逛,点一下,装好。",
|
|
4
|
-
"version": "1.73.
|
|
4
|
+
"version": "1.73.22",
|
|
5
5
|
"icon": "assets/logo.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|