dsh-crate 0.5.8 → 0.5.10
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/client/client.js +498 -231
- package/lib/install.js +1 -1
- package/lib/routes.js +49 -8
- package/lib/types/updates.d.ts +2 -1
- package/lib/updates.js +4 -3
- package/package.json +1 -1
package/lib/install.js
CHANGED
|
@@ -349,7 +349,7 @@ export async function withHoistRecovery(run, profile, pluginArgs, profileDirecto
|
|
|
349
349
|
// to a shut door (#982).
|
|
350
350
|
const lockedTarget = pluginArgs.find(argument => !argument.startsWith('-') && argument !== verb) ?? '';
|
|
351
351
|
const lockedName = registryNameOf(lockedTarget) ?? lockedTarget;
|
|
352
|
-
if (lockedName !== 'dsh-crate'
|
|
352
|
+
if (lockedName !== 'dsh-crate') {
|
|
353
353
|
result = {
|
|
354
354
|
...result,
|
|
355
355
|
stderr: `${result.stderr}\n\n这是官方桌面端:上面「在命令行执行」这一条在这里用不了,请改在应用自己的「设置 → 插件」里操作(退出重启后,或先停用加载该包的插件再重启)。 / This is the official desktop app: the "run it from the command line" option above is not available here — use the app's own Settings → Plugins instead (after restarting, or after disabling the plugin that loads this package and restarting).`,
|
package/lib/routes.js
CHANGED
|
@@ -199,6 +199,33 @@ function githubUpdateTarget(spec) {
|
|
|
199
199
|
const selectors = [...(ref === null ? [] : [ref]), ...(subpath === null ? [] : [`path:/${subpath}`])];
|
|
200
200
|
return selectors.length === 0 ? repo : `${repo}#${selectors.join('&')}`;
|
|
201
201
|
}
|
|
202
|
+
/**
|
|
203
|
+
* What an update of `spec` re-resolves, before any region acceleration:
|
|
204
|
+
* `gitSpec` for a GitHub source in either spelling (the `github:` shortcut or
|
|
205
|
+
* a legacy proxied codeload URL), `genericGitTarget` for any other git remote
|
|
206
|
+
* (#525). Both are null for a source that is not git.
|
|
207
|
+
*/
|
|
208
|
+
function gitUpdateTargets(spec) {
|
|
209
|
+
const codeloadRepo = spec.startsWith('github:') ? null : repoOfTarget(spec);
|
|
210
|
+
const gitSpec = spec.startsWith('github:')
|
|
211
|
+
? githubUpdateTarget(spec)
|
|
212
|
+
: codeloadRepo === null ? null : `github:${codeloadRepo}`;
|
|
213
|
+
return { gitSpec, genericGitTarget: gitSpec === null ? gitUpdateTarget(spec) : null };
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Whether the update route may send this install's update as
|
|
217
|
+
* `pnpm update <name>` on a host that takes the market's options: a floating
|
|
218
|
+
* git source, whose update target is the specifier itself (#562). The
|
|
219
|
+
* one-shot release-age retry (#39) covers only `add` and `remove`, so that
|
|
220
|
+
* update fails on a young lockfile entry. "May": in an accelerated region (a
|
|
221
|
+
* bare `github:owner/repo`) and for a deferred run (any `github:` source) the
|
|
222
|
+
* route first pins the source to its head commit when it can resolve one, and
|
|
223
|
+
* the pinned target goes out as an `add`.
|
|
224
|
+
*/
|
|
225
|
+
function mayUpdateGitInPlace(spec) {
|
|
226
|
+
const { gitSpec, genericGitTarget } = gitUpdateTargets(spec);
|
|
227
|
+
return (genericGitTarget ?? gitSpec) === spec;
|
|
228
|
+
}
|
|
202
229
|
/**
|
|
203
230
|
* Whether an installed package declares a client part (`dsh.client`). Its UI
|
|
204
231
|
* is injected into the page, so toggling it needs a browser refresh to show
|
|
@@ -2983,7 +3010,24 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
2983
3010
|
profileKey: createHash('sha256').update(activeProfileDir).digest('hex'),
|
|
2984
3011
|
enabled: marketState.backgroundUpdateChecks === true,
|
|
2985
3012
|
intervalHours: marketState.backgroundUpdateIntervalHours,
|
|
2986
|
-
|
|
3013
|
+
// A learned blocker (#1252) holds the offered updates that would stop or
|
|
3014
|
+
// fail on it. On the official Desktop bridge (no market options) and on
|
|
3015
|
+
// Desktop hosts that is every one, as before; checkUpdates holds young
|
|
3016
|
+
// releases on those hosts too (#945). Elsewhere the update route never
|
|
3017
|
+
// stops on a blocker, and it sends most updates as an `add`, which it
|
|
3018
|
+
// retries once with the release-age bypass (#39) when pnpm refuses it for
|
|
3019
|
+
// a young lockfile entry, so those rows stay offered. A floating git
|
|
3020
|
+
// source may go out as `pnpm update <name>` instead; that verb gets no
|
|
3021
|
+
// retry and fails on the blocker, so its row stays held.
|
|
3022
|
+
overlay: updates => {
|
|
3023
|
+
if (!marketFlags || config.desktopHost === true)
|
|
3024
|
+
return applyProfileBlockers(updates, activeProfileDir);
|
|
3025
|
+
const installed = readInstalled(config.profile, activeProfileDir);
|
|
3026
|
+
return applyProfileBlockers(updates, activeProfileDir, Date.now(), name => {
|
|
3027
|
+
const spec = installed[name];
|
|
3028
|
+
return spec === undefined || mayUpdateGitInPlace(spec);
|
|
3029
|
+
});
|
|
3030
|
+
},
|
|
2987
3031
|
inventory: () => {
|
|
2988
3032
|
const installed = readInstalled(config.profile, activeProfileDir);
|
|
2989
3033
|
const commits = readLockCommits(config.profile, activeProfileDir);
|
|
@@ -4667,7 +4711,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
4667
4711
|
const body = (await readJsonBody(request));
|
|
4668
4712
|
const name = typeof body.name === 'string' ? body.name : '';
|
|
4669
4713
|
const enabled = body.enabled === true;
|
|
4670
|
-
if (name === 'dsh-crate'
|
|
4714
|
+
if (name === 'dsh-crate') {
|
|
4671
4715
|
sendJson(response, 400, { error: 'the market cannot be disabled from its own page; use the dsh CLI' });
|
|
4672
4716
|
return;
|
|
4673
4717
|
}
|
|
@@ -5881,14 +5925,11 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
5881
5925
|
// from it. Without this branch these fell through to the npm path
|
|
5882
5926
|
// below, where `name@latest` either fails or — far worse —
|
|
5883
5927
|
// installs an unrelated package that shares the plugin's name.
|
|
5884
|
-
|
|
5885
|
-
const gitSpec = spec.startsWith('github:')
|
|
5886
|
-
? githubUpdateTarget(spec)
|
|
5887
|
-
: codeloadRepo === null ? null : `github:${codeloadRepo}`;
|
|
5928
|
+
//
|
|
5888
5929
|
// Non-GitHub git remotes (Gitea / git+https): keep the remote URL
|
|
5889
5930
|
// as the add target. Falling through to name@latest is what #525
|
|
5890
5931
|
// reported — a colliding npm package replaced the private install.
|
|
5891
|
-
const
|
|
5932
|
+
const { gitSpec, genericGitTarget } = gitUpdateTargets(spec);
|
|
5892
5933
|
const isGit = gitSpec !== null || genericGitTarget !== null;
|
|
5893
5934
|
const isReleaseTarball = !restore && isGitHubReleaseTarballSpec(spec);
|
|
5894
5935
|
let releaseUpdate = null;
|
|
@@ -8029,7 +8070,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
8029
8070
|
// has a concrete thing to go fix, so an override would only help
|
|
8030
8071
|
// them break their next boot.
|
|
8031
8072
|
const force = body.force === true;
|
|
8032
|
-
if (name === 'dsh-crate'
|
|
8073
|
+
if (name === 'dsh-crate') {
|
|
8033
8074
|
sendJson(response, 400, { error: 'the market cannot uninstall itself; use the dsh CLI' });
|
|
8034
8075
|
return;
|
|
8035
8076
|
}
|
package/lib/types/updates.d.ts
CHANGED
|
@@ -258,8 +258,9 @@ export declare function newerPrereleaseFor(name: string, installed: string | nul
|
|
|
258
258
|
* click (#1252). Applied to what is served, not to the cached registry
|
|
259
259
|
* answer, so a blocker learned a second ago and one that just ended both show
|
|
260
260
|
* on the very next read without another round of registry traffic.
|
|
261
|
+
* @param holds - which offered updates the blocker stops; every one by default.
|
|
261
262
|
*/
|
|
262
|
-
export declare function applyProfileBlockers(statuses: Record<string, UpdateStatus>, activeProfileDir: string, now?: number): Record<string, UpdateStatus>;
|
|
263
|
+
export declare function applyProfileBlockers(statuses: Record<string, UpdateStatus>, activeProfileDir: string, now?: number, holds?: (name: string) => boolean): Record<string, UpdateStatus>;
|
|
263
264
|
/** Check each plugin independently so a failed lookup leaves the other results usable. */
|
|
264
265
|
export declare function checkUpdates(profile: string, force?: boolean, explicitDir?: string,
|
|
265
266
|
/**
|
package/lib/updates.js
CHANGED
|
@@ -724,15 +724,16 @@ async function releaseAgeHold(name, latest, profile, activeProfileDir) {
|
|
|
724
724
|
* click (#1252). Applied to what is served, not to the cached registry
|
|
725
725
|
* answer, so a blocker learned a second ago and one that just ended both show
|
|
726
726
|
* on the very next read without another round of registry traffic.
|
|
727
|
+
* @param holds - which offered updates the blocker stops; every one by default.
|
|
727
728
|
*/
|
|
728
|
-
export function applyProfileBlockers(statuses, activeProfileDir, now = Date.now()) {
|
|
729
|
-
if (!Object.
|
|
729
|
+
export function applyProfileBlockers(statuses, activeProfileDir, now = Date.now(), holds = () => true) {
|
|
730
|
+
if (!Object.entries(statuses).some(([name, status]) => status.updateAvailable === true && holds(name)))
|
|
730
731
|
return statuses;
|
|
731
732
|
const blocker = headlineBlocker(activeReleaseBlockers(activeProfileDir, now));
|
|
732
733
|
if (blocker === null)
|
|
733
734
|
return statuses;
|
|
734
735
|
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
|
+
return Object.fromEntries(Object.entries(statuses).map(([name, status]) => [name, status.updateAvailable === true && holds(name) ? { ...status, updateAvailable: false, profileBlocked } : status]));
|
|
736
737
|
}
|
|
737
738
|
/** A hold expiration invalidates evidence; it cannot itself authorize an install. */
|
|
738
739
|
function nextHoldRecheck(data) {
|