dsh-crate 0.5.0 → 0.5.2
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 +142 -40
- package/lib/check.js +1 -1
- package/lib/compatibility.js +54 -32
- package/lib/discovery-compatibility.js +37 -2
- package/lib/dsh-cli.js +5 -1
- package/lib/hot.js +55 -8
- package/lib/index.js +30 -7
- package/lib/install.js +40 -4
- package/lib/official-desktop.js +65 -7
- package/lib/profile.js +13 -2
- package/lib/routes.js +48 -5
- package/lib/types/check.d.ts +28 -0
- package/lib/types/discovery-compatibility.d.ts +5 -1
- package/lib/types/hot.d.ts +29 -0
- package/lib/types/index.d.ts +7 -6
- package/lib/types/install.d.ts +24 -0
- package/lib/verify.js +35 -9
- package/package.json +1 -1
package/client/client.js
CHANGED
|
@@ -360,7 +360,9 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
360
360
|
installedEmpty: "尚未安装社区插件,可前往「发现」页浏览",
|
|
361
361
|
marketGoneTitle: "插件箱子已停止运行",
|
|
362
362
|
marketGoneBody: "DSH 重新加载插件时把市场一起卸载了。重启 DSH 即可恢复;刚才的操作可能已经完成。",
|
|
363
|
-
marketGoneRecord: "
|
|
363
|
+
marketGoneRecord: "市场被 DSH 卸载了,这次操作没有等到结果。市场恢复后,到「已安装」里确认。",
|
|
364
|
+
marketGoneReconnecting: "正在重新连接…",
|
|
365
|
+
marketGoneReconnect: "重新连接",
|
|
364
366
|
loadFail: "插件目录加载失败,请稍后重试",
|
|
365
367
|
loadRetry: "重试",
|
|
366
368
|
installFail: "安装失败",
|
|
@@ -1152,7 +1154,9 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
1152
1154
|
installedEmpty: "No community plugins yet — browse the Discover tab",
|
|
1153
1155
|
marketGoneTitle: "The plugin market stopped running",
|
|
1154
1156
|
marketGoneBody: "DSH unloaded the market while reloading plugins. Restart DSH to bring it back. The last operation may already have finished.",
|
|
1155
|
-
marketGoneRecord: "
|
|
1157
|
+
marketGoneRecord: "DSH unloaded the market, so this operation got no result. Once the market is back, check Installed.",
|
|
1158
|
+
marketGoneReconnecting: "Reconnecting…",
|
|
1159
|
+
marketGoneReconnect: "Reconnect",
|
|
1156
1160
|
loadFail: "The plugin catalog failed to load. Try again later.",
|
|
1157
1161
|
loadRetry: "Retry",
|
|
1158
1162
|
installFail: "Install failed",
|
|
@@ -1944,7 +1948,9 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
1944
1948
|
installedEmpty: "コミュニティプラグインはまだインストールされていません。「見つける」ページで探せます",
|
|
1945
1949
|
marketGoneTitle: "プラグインボックスが停止しました",
|
|
1946
1950
|
marketGoneBody: "DSH がプラグインを再読み込みした際に、マーケットも一緒にアンロードされました。DSH を再起動すれば復旧します。直前の操作は完了している可能性があります。",
|
|
1947
|
-
marketGoneRecord: "マーケットが DSH
|
|
1951
|
+
marketGoneRecord: "マーケットが DSH からアンロードされたため、この操作の結果は届きませんでした。マーケットが戻ったら、「インストール済み」で確認してください。",
|
|
1952
|
+
marketGoneReconnecting: "再接続しています…",
|
|
1953
|
+
marketGoneReconnect: "再接続",
|
|
1948
1954
|
loadFail: "プラグインカタログの読み込みに失敗しました。しばらくしてから再試行してください",
|
|
1949
1955
|
loadRetry: "再試行",
|
|
1950
1956
|
installFail: "インストールに失敗しました",
|
|
@@ -7808,6 +7814,9 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
7808
7814
|
const HOST_DEPENDENCY_PREVIEW_LIMIT = 5;
|
|
7809
7815
|
/** After this long without a structured phase, the install line adds a note that waiting is normal (#1011). */
|
|
7810
7816
|
const SLOW_INSTALL_SECONDS = 90;
|
|
7817
|
+
/** How long the page keeps asking for a market DSH unloaded, and how long one ask may take (#1151). */
|
|
7818
|
+
const RECONNECT_BUDGET_MS = 9e4;
|
|
7819
|
+
const RECONNECT_REQUEST_MS = 4e3;
|
|
7811
7820
|
const IGNORED_UPDATES_SESSION_KEY = "dshm-updates-ignored";
|
|
7812
7821
|
const UNAVAILABLE_HOST_COMPATIBILITY = {
|
|
7813
7822
|
status: "unknown",
|
|
@@ -10070,6 +10079,8 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
10070
10079
|
* exactly why it owes the user this sentence instead of a spinner.
|
|
10071
10080
|
*/
|
|
10072
10081
|
const [marketGone, setMarketGone] = (0, react.useState)(false);
|
|
10082
|
+
const [reconnecting, setReconnecting] = (0, react.useState)(true);
|
|
10083
|
+
const [reconnectRound, setReconnectRound] = (0, react.useState)(0);
|
|
10073
10084
|
const [installed, setInstalledState] = (0, react.useState)(cachedInstalled ?? {});
|
|
10074
10085
|
const setInstalled = (0, react.useCallback)((value) => {
|
|
10075
10086
|
cachedInstalled = value;
|
|
@@ -11150,6 +11161,66 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
11150
11161
|
setLoadError(error instanceof Error ? error.message : String(error));
|
|
11151
11162
|
});
|
|
11152
11163
|
}, [noteMarketGone, t]);
|
|
11164
|
+
/**
|
|
11165
|
+
* Come back when the routes do (#1151).
|
|
11166
|
+
*
|
|
11167
|
+
* A 404 is how the page learns DSH unloaded the market, but DSH usually
|
|
11168
|
+
* mounts it again within seconds: it reloads plugins around an install or
|
|
11169
|
+
* an update, and the market is one of them. The page used to stay on "stopped"
|
|
11170
|
+
* for good, so the user restarted DSH — which also killed whatever the host
|
|
11171
|
+
* was still doing. Read-only on purpose: only `status` is asked, never a
|
|
11172
|
+
* request that changes anything, and nothing that was in flight is replayed.
|
|
11173
|
+
*/
|
|
11174
|
+
(0, react.useEffect)(() => {
|
|
11175
|
+
if (!marketGone) return;
|
|
11176
|
+
setReconnecting(true);
|
|
11177
|
+
const startedAt = Date.now();
|
|
11178
|
+
let wait = 1e3;
|
|
11179
|
+
let timer;
|
|
11180
|
+
let inFlight;
|
|
11181
|
+
let stopped = false;
|
|
11182
|
+
const attempt = async () => {
|
|
11183
|
+
inFlight = new AbortController();
|
|
11184
|
+
const cutoff = setTimeout(() => inFlight?.abort(), RECONNECT_REQUEST_MS);
|
|
11185
|
+
try {
|
|
11186
|
+
const res = await fetch(api("/dsh-crate/status"), {
|
|
11187
|
+
cache: "no-store",
|
|
11188
|
+
signal: inFlight.signal
|
|
11189
|
+
});
|
|
11190
|
+
const status = res.ok ? await res.json() : null;
|
|
11191
|
+
if (!stopped && status !== null && typeof status === "object" && typeof status.boot === "string") {
|
|
11192
|
+
setMarketGone(false);
|
|
11193
|
+
loadCatalog();
|
|
11194
|
+
refreshInstalled();
|
|
11195
|
+
return;
|
|
11196
|
+
}
|
|
11197
|
+
} catch {} finally {
|
|
11198
|
+
clearTimeout(cutoff);
|
|
11199
|
+
}
|
|
11200
|
+
if (stopped) return;
|
|
11201
|
+
if (Date.now() - startedAt >= RECONNECT_BUDGET_MS) {
|
|
11202
|
+
setReconnecting(false);
|
|
11203
|
+
return;
|
|
11204
|
+
}
|
|
11205
|
+
timer = setTimeout(() => {
|
|
11206
|
+
attempt();
|
|
11207
|
+
}, wait);
|
|
11208
|
+
wait = Math.min(wait * 2, 5e3);
|
|
11209
|
+
};
|
|
11210
|
+
timer = setTimeout(() => {
|
|
11211
|
+
attempt();
|
|
11212
|
+
}, wait);
|
|
11213
|
+
return () => {
|
|
11214
|
+
stopped = true;
|
|
11215
|
+
clearTimeout(timer);
|
|
11216
|
+
inFlight?.abort();
|
|
11217
|
+
};
|
|
11218
|
+
}, [
|
|
11219
|
+
marketGone,
|
|
11220
|
+
reconnectRound,
|
|
11221
|
+
loadCatalog,
|
|
11222
|
+
refreshInstalled
|
|
11223
|
+
]);
|
|
11153
11224
|
const loadHostCompatibility = (0, react.useCallback)(async (names) => {
|
|
11154
11225
|
const unique = [...new Set(names)].filter((name) => {
|
|
11155
11226
|
if (name === "" || hostCompatibilitySettled(name) || hostCompatibilityInFlight.has(name)) return false;
|
|
@@ -11616,36 +11687,20 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
11616
11687
|
root.style.removeProperty("--dshm-head-h");
|
|
11617
11688
|
};
|
|
11618
11689
|
}, [surface, themesFullscreen]);
|
|
11619
|
-
const
|
|
11620
|
-
if (data === null) return
|
|
11621
|
-
plugins: [],
|
|
11622
|
-
hostHiddenCount: 0
|
|
11623
|
-
};
|
|
11690
|
+
const pluginsAll = (0, react.useMemo)(() => {
|
|
11691
|
+
if (data === null) return [];
|
|
11624
11692
|
const query = {
|
|
11625
11693
|
category: cat,
|
|
11626
11694
|
query: q,
|
|
11627
11695
|
lang,
|
|
11628
11696
|
categories: data.categories,
|
|
11629
11697
|
sort: `${sortField}-${sortDir}`,
|
|
11630
|
-
sinceDays: timeRange === "all" ? void 0 : TIME_RANGE_DAYS[timeRange]
|
|
11631
|
-
hostCompatibility
|
|
11698
|
+
sinceDays: timeRange === "all" ? void 0 : TIME_RANGE_DAYS[timeRange]
|
|
11632
11699
|
};
|
|
11633
|
-
|
|
11700
|
+
return visiblePlugins(data.plugins, {
|
|
11634
11701
|
...query,
|
|
11635
11702
|
compatibleWithHost: false
|
|
11636
11703
|
});
|
|
11637
|
-
if (!compatibleWithHost) return {
|
|
11638
|
-
plugins: unfiltered,
|
|
11639
|
-
hostHiddenCount: 0
|
|
11640
|
-
};
|
|
11641
|
-
const filtered = visiblePlugins(data.plugins, {
|
|
11642
|
-
...query,
|
|
11643
|
-
compatibleWithHost: true
|
|
11644
|
-
});
|
|
11645
|
-
return {
|
|
11646
|
-
plugins: filtered,
|
|
11647
|
-
hostHiddenCount: unfiltered.length - filtered.length
|
|
11648
|
-
};
|
|
11649
11704
|
}, [
|
|
11650
11705
|
data,
|
|
11651
11706
|
q,
|
|
@@ -11653,21 +11708,35 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
11653
11708
|
lang,
|
|
11654
11709
|
sortField,
|
|
11655
11710
|
sortDir,
|
|
11656
|
-
timeRange
|
|
11657
|
-
hostCompatibility,
|
|
11658
|
-
compatibleWithHost
|
|
11711
|
+
timeRange
|
|
11659
11712
|
]);
|
|
11660
11713
|
const pluginBlocked = (plugin) => blockAliases(plugin, matchInstalledName(plugin, installed, repoIdentities, data?.plugins, repoHints)).some((name) => blockedNameSet.has(name));
|
|
11661
|
-
const installedBlocked = (
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11665
|
-
|
|
11666
|
-
|
|
11667
|
-
|
|
11668
|
-
|
|
11714
|
+
const installedBlocked = (0, react.useMemo)(() => {
|
|
11715
|
+
const compute = (name) => {
|
|
11716
|
+
if (blockedNameSet.has(name)) return true;
|
|
11717
|
+
if (data === null) return false;
|
|
11718
|
+
const spec = installed[name];
|
|
11719
|
+
if (spec === void 0) return false;
|
|
11720
|
+
const entry = catalogEntryForInstalled(data.plugins, name, String(spec), repoIdentities[name], repoHints[name]);
|
|
11721
|
+
return entry !== void 0 && blockAliases(entry, name).some((alias) => blockedNameSet.has(alias));
|
|
11722
|
+
};
|
|
11723
|
+
const cache = /* @__PURE__ */ new Map();
|
|
11724
|
+
return (name) => {
|
|
11725
|
+
const hit = cache.get(name);
|
|
11726
|
+
if (hit !== void 0) return hit;
|
|
11727
|
+
const value = compute(name);
|
|
11728
|
+
cache.set(name, value);
|
|
11729
|
+
return value;
|
|
11730
|
+
};
|
|
11731
|
+
}, [
|
|
11732
|
+
data,
|
|
11733
|
+
blockedNameSet,
|
|
11734
|
+
installed,
|
|
11735
|
+
repoIdentities,
|
|
11736
|
+
repoHints
|
|
11737
|
+
]);
|
|
11669
11738
|
const blockToggleName = (aliases) => aliases.find((name) => blockedNameSet.has(name)) ?? aliases[0];
|
|
11670
|
-
const
|
|
11739
|
+
const pluginsUnblocked = (0, react.useMemo)(() => pluginsAll.filter((plugin) => !pluginBlocked(plugin)), [
|
|
11671
11740
|
pluginsAll,
|
|
11672
11741
|
blockedNameSet,
|
|
11673
11742
|
installed,
|
|
@@ -11675,6 +11744,27 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
11675
11744
|
data,
|
|
11676
11745
|
repoHints
|
|
11677
11746
|
]);
|
|
11747
|
+
const { plugins, hostHiddenCount } = (0, react.useMemo)(() => {
|
|
11748
|
+
if (!compatibleWithHost) return {
|
|
11749
|
+
plugins: pluginsUnblocked,
|
|
11750
|
+
hostHiddenCount: 0
|
|
11751
|
+
};
|
|
11752
|
+
const compatible = (plugin) => {
|
|
11753
|
+
const key = hostCompatibilityKey(plugin);
|
|
11754
|
+
return key === null || hostCompatibility[key]?.status !== "incompatible";
|
|
11755
|
+
};
|
|
11756
|
+
let hidden = 0;
|
|
11757
|
+
for (const plugin of pluginsAll) if (!compatible(plugin)) hidden += 1;
|
|
11758
|
+
return {
|
|
11759
|
+
plugins: pluginsUnblocked.filter(compatible),
|
|
11760
|
+
hostHiddenCount: hidden
|
|
11761
|
+
};
|
|
11762
|
+
}, [
|
|
11763
|
+
pluginsAll,
|
|
11764
|
+
pluginsUnblocked,
|
|
11765
|
+
compatibleWithHost,
|
|
11766
|
+
hostCompatibility
|
|
11767
|
+
]);
|
|
11678
11768
|
const recentlyAdded = (0, react.useMemo)(() => data === null || tab !== "discover" || q.trim() !== "" || cat !== "all" || timeRange !== "all" || sortField !== "downloads" || sortDir !== "desc" ? [] : visiblePlugins(data.plugins, {
|
|
11679
11769
|
category: "all",
|
|
11680
11770
|
query: "",
|
|
@@ -15291,10 +15381,22 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
15291
15381
|
children: marketGone ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15292
15382
|
className: Market_module_css_default.empty,
|
|
15293
15383
|
role: "alert",
|
|
15294
|
-
children: [
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
15384
|
+
children: [
|
|
15385
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("b", { children: t("marketGoneTitle") }) }),
|
|
15386
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15387
|
+
className: Market_module_css_default.spec,
|
|
15388
|
+
children: t("marketGoneBody")
|
|
15389
|
+
}),
|
|
15390
|
+
reconnecting ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
15391
|
+
className: Market_module_css_default.spec,
|
|
15392
|
+
children: t("marketGoneReconnecting")
|
|
15393
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_deepseek_ai_dsh_client_ui_primitives.Button, {
|
|
15394
|
+
variant: "outline",
|
|
15395
|
+
size: "sm",
|
|
15396
|
+
onClick: () => setReconnectRound((round) => round + 1),
|
|
15397
|
+
children: t("marketGoneReconnect")
|
|
15398
|
+
}) })
|
|
15399
|
+
]
|
|
15298
15400
|
}) : tab === "backup" ? /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
15299
15401
|
className: Market_module_css_default.backupGrid,
|
|
15300
15402
|
children: [
|
|
@@ -15661,7 +15763,7 @@ window.__ModuleLoader__.load({ id: "dsh-crate", factory: (require) => {
|
|
|
15661
15763
|
})]
|
|
15662
15764
|
})),
|
|
15663
15765
|
plugins.length === 0 ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(EmptyResults, {
|
|
15664
|
-
blocked: pluginsAll.length >
|
|
15766
|
+
blocked: pluginsAll.length > hostHiddenCount,
|
|
15665
15767
|
t,
|
|
15666
15768
|
onClear: data.plugins.length > 0 && (q !== "" || cat !== "all" || timeRange !== "all" || compatibleWithHost) ? () => {
|
|
15667
15769
|
setQ("");
|
package/lib/check.js
CHANGED
|
@@ -340,7 +340,7 @@ function parseSemver(value) {
|
|
|
340
340
|
* (`>=1.2.0 <1.3.0`), so it stays as is and parses as unknown below rather
|
|
341
341
|
* than being mistaken for the exact version `1.2.0`.
|
|
342
342
|
*/
|
|
343
|
-
function expandPartialComparator(part, includePrerelease) {
|
|
343
|
+
export function expandPartialComparator(part, includePrerelease) {
|
|
344
344
|
const m = /^(\^|~|>=|<=|>|<)(\d+)(?:\.(\d+))?$/u.exec(part.trim());
|
|
345
345
|
if (m === null)
|
|
346
346
|
return [part];
|
package/lib/compatibility.js
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
* Everything else stays informational: `*`, prerelease-vs-`*` artifacts,
|
|
17
17
|
* unparseable ranges, and optional peers never produce a risk here.
|
|
18
18
|
*/
|
|
19
|
-
import { analyzeProfile, compareSemver } from './check.js';
|
|
19
|
+
import { analyzeProfile, compareSemver, expandPartialComparator } from './check.js';
|
|
20
20
|
import { profileDir, readInstalledManifest } from './profile.js';
|
|
21
21
|
const SEMVER = /^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
22
22
|
function parseComparator(part) {
|
|
@@ -30,6 +30,26 @@ function parseComparator(part) {
|
|
|
30
30
|
const raw = m[1] ?? '';
|
|
31
31
|
return { op: raw === '' || raw === '=' ? 'exact' : raw, target };
|
|
32
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* One written comparator as full-version comparators. A partial target
|
|
35
|
+
* (`<0.3`, `^0.1`, `~1`) goes through the same node-semver expansion the gate
|
|
36
|
+
* uses in `satisfiesRange`, so both sides agree on where the line ends.
|
|
37
|
+
* A bare partial (`1.2`) stays unparseable, as it does there.
|
|
38
|
+
*/
|
|
39
|
+
function parseWritten(part) {
|
|
40
|
+
const full = parseComparator(part);
|
|
41
|
+
if (full !== null)
|
|
42
|
+
return [full];
|
|
43
|
+
const expanded = expandPartialComparator(part, false);
|
|
44
|
+
if (expanded.length === 1 && expanded[0] === part)
|
|
45
|
+
return null;
|
|
46
|
+
const parsed = expanded.map(parseComparator);
|
|
47
|
+
return parsed.every(p => p !== null) ? parsed : null;
|
|
48
|
+
}
|
|
49
|
+
/** A `^` / `~` comparator, whose ceiling the author implied rather than wrote. */
|
|
50
|
+
function isImplicitCeiling(part) {
|
|
51
|
+
return /^[\^~]/.test(part.trim());
|
|
52
|
+
}
|
|
33
53
|
/** Next breaking bump for `^` / `~`, using `-0` so prereleases compare consistently. */
|
|
34
54
|
function nextBound(target, kind) {
|
|
35
55
|
const m = /^(\d+)\.(\d+)\.(\d+)(?:-[0-9A-Za-z.-]+)?$/.exec(target);
|
|
@@ -51,39 +71,41 @@ function boundsFor(range) {
|
|
|
51
71
|
const alternatives = [];
|
|
52
72
|
for (const rawAlternative of range.split('||')) {
|
|
53
73
|
const parts = rawAlternative.trim().split(/\s+/).filter(Boolean);
|
|
54
|
-
const
|
|
55
|
-
if (
|
|
74
|
+
const written = parts.map(part => ({ implicit: isImplicitCeiling(part), parsed: parseWritten(part) }));
|
|
75
|
+
if (written.some(part => part.parsed === null))
|
|
56
76
|
return null;
|
|
57
77
|
let lower = null;
|
|
58
78
|
let upper = null;
|
|
59
79
|
let explicitUpper = false;
|
|
60
80
|
let exact = null;
|
|
61
|
-
for (const
|
|
62
|
-
const p
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
81
|
+
for (const { implicit, parsed } of written)
|
|
82
|
+
for (const p of parsed) {
|
|
83
|
+
if (p.op === 'exact') {
|
|
84
|
+
exact = p.target;
|
|
85
|
+
continue;
|
|
86
|
+
}
|
|
87
|
+
if (p.op === '^' || p.op === '~') {
|
|
88
|
+
const bound = nextBound(p.target, p.op);
|
|
89
|
+
if (bound === null)
|
|
90
|
+
return null;
|
|
91
|
+
if (lower === null || compareSemver(p.target, lower.target) > 0)
|
|
92
|
+
lower = p;
|
|
93
|
+
if (upper === null || compareSemver(bound, upper.target) < 0)
|
|
94
|
+
upper = { op: '<=', target: bound };
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (p.op === '>=' || p.op === '>') {
|
|
98
|
+
if (lower === null || compareSemver(p.target, lower.target) > 0)
|
|
99
|
+
lower = p;
|
|
100
|
+
}
|
|
101
|
+
else {
|
|
102
|
+
if (upper === null || compareSemver(p.target, upper.target) < 0)
|
|
103
|
+
upper = p;
|
|
104
|
+
// A partial `^0.1` arrives here as `<0.2.0-0`; its ceiling is still implied.
|
|
105
|
+
if (!implicit)
|
|
106
|
+
explicitUpper = true;
|
|
107
|
+
}
|
|
66
108
|
}
|
|
67
|
-
if (p.op === '^' || p.op === '~') {
|
|
68
|
-
const bound = nextBound(p.target, p.op);
|
|
69
|
-
if (bound === null)
|
|
70
|
-
return null;
|
|
71
|
-
if (lower === null || compareSemver(p.target, lower.target) > 0)
|
|
72
|
-
lower = p;
|
|
73
|
-
if (upper === null || compareSemver(bound, upper.target) < 0)
|
|
74
|
-
upper = { op: '<=', target: bound };
|
|
75
|
-
continue;
|
|
76
|
-
}
|
|
77
|
-
if (p.op === '>=' || p.op === '>') {
|
|
78
|
-
if (lower === null || compareSemver(p.target, lower.target) > 0)
|
|
79
|
-
lower = p;
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
if (upper === null || compareSemver(p.target, upper.target) < 0)
|
|
83
|
-
upper = p;
|
|
84
|
-
explicitUpper = true;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
109
|
alternatives.push({ lower, upper, explicitUpper, exact });
|
|
88
110
|
}
|
|
89
111
|
return alternatives;
|
|
@@ -116,12 +138,12 @@ function declaredLines(range) {
|
|
|
116
138
|
const lines = [];
|
|
117
139
|
for (const rawAlternative of range.split('||')) {
|
|
118
140
|
for (const raw of rawAlternative.trim().split(/\s+/).filter(Boolean)) {
|
|
119
|
-
|
|
120
|
-
if (parsed === null)
|
|
141
|
+
if (parseWritten(raw) === null)
|
|
121
142
|
return null;
|
|
122
|
-
if (
|
|
143
|
+
if (!isImplicitCeiling(raw))
|
|
123
144
|
continue;
|
|
124
|
-
|
|
145
|
+
// `^0.1` names the 0.1 line like `^0.1.0`; `^1` names no minor line.
|
|
146
|
+
const m = /^[\^~](\d+)\.(\d+)(?:\.|$)/.exec(raw.trim());
|
|
125
147
|
if (m !== null)
|
|
126
148
|
lines.push(`${m[1]}.${m[2]}`);
|
|
127
149
|
}
|
|
@@ -13,6 +13,8 @@ import { dirname } from 'node:path';
|
|
|
13
13
|
import { compareSemver, isSemver, satisfiesRange } from './check.js';
|
|
14
14
|
import { classifyPeer, crossesImplicitCeiling } from './compatibility.js';
|
|
15
15
|
import { marketFetch } from './net.js';
|
|
16
|
+
import { isStableReleaseVersion } from './release-candidates.js';
|
|
17
|
+
import { activeRegion, githubRoutesFor, rememberGithubRoute, throughProxy } from './regions.js';
|
|
16
18
|
import { parseSourceUrl } from './sources.js';
|
|
17
19
|
const CACHE_SCHEMA = 'dsh-crate/discovery-compatibility-cache/v1';
|
|
18
20
|
const DEFAULT_TTL_MS = 24 * 60 * 60 * 1000;
|
|
@@ -65,10 +67,38 @@ async function githubManifest(source, fetcher) {
|
|
|
65
67
|
throw new Error('invalid GitHub reference');
|
|
66
68
|
}
|
|
67
69
|
const file = parsed.subpath === null ? 'package.json' : `${parsed.subpath}/package.json`;
|
|
68
|
-
const manifest = await
|
|
70
|
+
const manifest = await rawJson(`https://raw.githubusercontent.com/${parsed.repo}/${encodeURIComponent(ref)}/${file}`);
|
|
69
71
|
if (record(manifest) === null)
|
|
70
72
|
throw new Error('package manifest unavailable');
|
|
71
73
|
return manifest;
|
|
74
|
+
/**
|
|
75
|
+
* Read a raw file through the region's configured routes, in order.
|
|
76
|
+
*
|
|
77
|
+
* `raw.githubusercontent.com` is blockable on its own — the report (#1148)
|
|
78
|
+
* measured an `ECONNRESET` with no proxy and a 200 through one — while the
|
|
79
|
+
* catalog and the registry answered fine, so "the market page loads" said
|
|
80
|
+
* nothing about this read. This path used to compose the host directly and
|
|
81
|
+
* give up on the first error, and the card then said the host's requirement
|
|
82
|
+
* was unknown even though the release declares one. The routes are the same
|
|
83
|
+
* list the update path walks; one retry per route covers the transient
|
|
84
|
+
* resets that made a single miss look permanent.
|
|
85
|
+
*/
|
|
86
|
+
async function rawJson(url) {
|
|
87
|
+
let last;
|
|
88
|
+
for (const route of githubRoutesFor('raw', activeRegion())) {
|
|
89
|
+
for (let attempt = 0; attempt < 2; attempt += 1) {
|
|
90
|
+
try {
|
|
91
|
+
const value = await json(throughProxy(route, url));
|
|
92
|
+
rememberGithubRoute('raw', route);
|
|
93
|
+
return value;
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
last = error;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
throw last instanceof Error ? last : new Error('GitHub raw content unavailable');
|
|
101
|
+
}
|
|
72
102
|
}
|
|
73
103
|
function range(value) {
|
|
74
104
|
if (typeof value !== 'string')
|
|
@@ -417,10 +447,14 @@ export class DiscoveryManifestIndex {
|
|
|
417
447
|
* installed one, which is what an update needs: suggesting a downgrade is not
|
|
418
448
|
* an update.
|
|
419
449
|
*
|
|
450
|
+
* `stableOnly` drops prereleases. The official Desktop refuses to move a
|
|
451
|
+
* stable install onto a prerelease by itself (#991), so offering one there is
|
|
452
|
+
* an enabled button that can only answer 409 (#1161).
|
|
453
|
+
*
|
|
420
454
|
* @returns the version, or null when the packument cannot be read or nothing
|
|
421
455
|
* in the history declares itself compatible.
|
|
422
456
|
*/
|
|
423
|
-
export async function findCompatibleVersion(npmName, hostVersion, hostPackages, registry, fetcher = marketFetch, minimumVersionExclusive = null) {
|
|
457
|
+
export async function findCompatibleVersion(npmName, hostVersion, hostPackages, registry, fetcher = marketFetch, minimumVersionExclusive = null, stableOnly = false) {
|
|
424
458
|
let doc;
|
|
425
459
|
try {
|
|
426
460
|
const res = await fetcher(`${registry}/${encodeURIComponent(npmName)}`, { signal: AbortSignal.timeout(15_000), headers: { accept: 'application/json', 'user-agent': 'dsh-crate' } });
|
|
@@ -436,6 +470,7 @@ export async function findCompatibleVersion(npmName, hostVersion, hostPackages,
|
|
|
436
470
|
return null;
|
|
437
471
|
const candidates = Object.keys(versions)
|
|
438
472
|
.filter(version => isSemver(version)
|
|
473
|
+
&& (!stableOnly || isStableReleaseVersion(version))
|
|
439
474
|
&& (minimumVersionExclusive === null || compareSemver(version, minimumVersionExclusive) > 0))
|
|
440
475
|
.sort((left, right) => compareSemver(right, left));
|
|
441
476
|
for (const version of candidates) {
|
package/lib/dsh-cli.js
CHANGED
|
@@ -479,7 +479,11 @@ export function dshArgv() {
|
|
|
479
479
|
// The official bundled CLI inherits the launcher's cwd. Its entry can
|
|
480
480
|
// live inside app.asar: Electron can read it, but the OS cannot chdir there.
|
|
481
481
|
// Do not probe that directory through Electron's virtual filesystem.
|
|
482
|
-
|
|
482
|
+
// An entry inside an .asar archive carries the same hazard as the desktop
|
|
483
|
+
// CLI above: Electron's fs shim resolves the directory, the OS cannot chdir
|
|
484
|
+
// there, and CreateProcess fails with ENOENT naming an unrelated executable.
|
|
485
|
+
const entryInAsar = /[\\/][^\\/]+\.asar[\\/]/i.test(abs);
|
|
486
|
+
return { file: nodeExecutable(), args: [...process.execArgv, abs], cwd: desktopCli || entryInAsar ? undefined : dirname(abs), viaShell: false };
|
|
483
487
|
}
|
|
484
488
|
// Bare `dsh` is a .cmd shim on Windows that only a shell can start (#13).
|
|
485
489
|
return { file: 'dsh', args: [], cwd: undefined, viaShell: winCmdShim };
|
package/lib/hot.js
CHANGED
|
@@ -148,8 +148,17 @@ function readPkgDsh(profileDir, packageName) {
|
|
|
148
148
|
* expressions) — those compositions fall back to restart activation.
|
|
149
149
|
*/
|
|
150
150
|
export function parseSimplePatch(patchText) {
|
|
151
|
+
const scan = scanPatch(patchText);
|
|
152
|
+
return scan.blocker === null ? scan.rows : null;
|
|
153
|
+
}
|
|
154
|
+
export function scanPatch(patchText) {
|
|
151
155
|
const rows = [];
|
|
152
156
|
let pending = null;
|
|
157
|
+
// A patch row at column 0 targets an EXISTING entry (the long-standing way
|
|
158
|
+
// to disable one); only rows indented inside `- insert:` bring a plugin in.
|
|
159
|
+
// Tracked so the walk can say which of the two it met instead of calling
|
|
160
|
+
// every top-level row "a config block" (#1102, dsh-mnemon's shipped patch).
|
|
161
|
+
let topLevelRow = false;
|
|
153
162
|
// Split on CRLF too. `#.*$` cannot strip a comment that ends in \r —
|
|
154
163
|
// JS treats \r as a line terminator, so `.` will not cross it and `$`
|
|
155
164
|
// only anchors at the very end — leaving the comment text in place,
|
|
@@ -162,10 +171,15 @@ export function parseSimplePatch(patchText) {
|
|
|
162
171
|
continue;
|
|
163
172
|
if (/^-\s+insert:\s*$/.test(line))
|
|
164
173
|
continue;
|
|
174
|
+
if (/^-\s+id:\s*\S+\s*$/.test(line)) {
|
|
175
|
+
topLevelRow = true;
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
165
178
|
const id = /^\s+-\s+id:\s*(\S+)\s*$/.exec(line);
|
|
166
179
|
if (id !== null) {
|
|
180
|
+
// A second id before the first got its name: the row was cut short.
|
|
167
181
|
if (pending !== null)
|
|
168
|
-
return
|
|
182
|
+
return { rows, blocker: 'incomplete' };
|
|
169
183
|
pending = id[1];
|
|
170
184
|
continue;
|
|
171
185
|
}
|
|
@@ -175,11 +189,43 @@ export function parseSimplePatch(patchText) {
|
|
|
175
189
|
pending = null;
|
|
176
190
|
continue;
|
|
177
191
|
}
|
|
178
|
-
|
|
192
|
+
const leaf = /^\s*(?:-\s+)?([A-Za-z_][\w-]*)\s*:/.exec(line);
|
|
193
|
+
const key = leaf?.[1];
|
|
194
|
+
if (key === 'config')
|
|
195
|
+
return { rows, blocker: 'config', key };
|
|
196
|
+
if (key === 'disabled' || key === 'enabled')
|
|
197
|
+
return { rows, blocker: 'disabled', key };
|
|
198
|
+
return { rows, blocker: 'other', key };
|
|
199
|
+
}
|
|
200
|
+
if (pending !== null)
|
|
201
|
+
return { rows, blocker: 'incomplete' };
|
|
202
|
+
// A top-level row whose body never arrived: still not an insert list, and
|
|
203
|
+
// saying so keeps `parseSimplePatch` from mounting the inserts around it
|
|
204
|
+
// while silently dropping the entry it patched.
|
|
205
|
+
if (topLevelRow)
|
|
206
|
+
return { rows, blocker: 'other', key: 'id' };
|
|
207
|
+
if (rows.length === 0)
|
|
208
|
+
return { rows, blocker: 'empty' };
|
|
209
|
+
return { rows, blocker: null };
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* One sentence for a refusal that is only about the patch's shape, naming the
|
|
213
|
+
* cause and what happens next. Shared by the hot mount and the activation
|
|
214
|
+
* verdict so the two cannot drift apart on the same fact again.
|
|
215
|
+
*/
|
|
216
|
+
export function patchBlockerReason(blocker, key) {
|
|
217
|
+
switch (blocker) {
|
|
218
|
+
case 'config':
|
|
219
|
+
return 'bundle patch 里有 config 块,热挂载只重放纯 insert 行;重启后由 bundle 层按原样加载 / the bundle patch has a config block; hot-mount replays plain insert rows only — a restart loads the bundle as written';
|
|
220
|
+
case 'disabled':
|
|
221
|
+
return '这个包有一行被关掉了(disabled),热挂载不重放开关行;重启后按原样加载,那一行仍然是关的 / one of its rows is switched off (disabled); hot-mount does not replay switch rows — a restart loads the bundle as written and that row stays off';
|
|
222
|
+
case 'incomplete':
|
|
223
|
+
return 'bundle patch 里有一行 id 没有配 name,市场读不懂这一行;重启后由 bundle 层按原样加载,仍不生效就修这个包的 patch / a row has an id but no name, so the market cannot read it — a restart loads the bundle as written; fix the package patch if it still does not work';
|
|
224
|
+
case 'empty':
|
|
225
|
+
return 'bundle patch 里没有 insert 行,热挂载没有可重放的内容;重启后由 bundle 层生效 / the bundle patch has no insert rows, so there is nothing to replay — it activates on restart';
|
|
226
|
+
default:
|
|
227
|
+
return `bundle patch 里有 insert 之外的行(${key ?? '未识别的键'}),热挂载只重放纯 insert;重启后由 bundle 层按原样加载 / the bundle patch has a row beyond plain inserts (${key ?? 'an unrecognised key'}); hot-mount replays plain inserts only — a restart loads the bundle as written`;
|
|
179
228
|
}
|
|
180
|
-
if (pending !== null || rows.length === 0)
|
|
181
|
-
return null;
|
|
182
|
-
return rows;
|
|
183
229
|
}
|
|
184
230
|
/**
|
|
185
231
|
* Wipe leftover hot-mount inputs; call once when the market host starts.
|
|
@@ -659,14 +705,15 @@ export async function hotMount(ctx, profileDir, packageName) {
|
|
|
659
705
|
}
|
|
660
706
|
let rows;
|
|
661
707
|
if (texts !== null && texts.length > 0) {
|
|
662
|
-
|
|
663
|
-
if (
|
|
708
|
+
const scan = scanPatch(texts.join('\n'));
|
|
709
|
+
if (scan.blocker !== null) {
|
|
664
710
|
return {
|
|
665
711
|
ok: false,
|
|
666
712
|
deferred: true,
|
|
667
|
-
reason:
|
|
713
|
+
reason: patchBlockerReason(scan.blocker, scan.key),
|
|
668
714
|
};
|
|
669
715
|
}
|
|
716
|
+
rows = scan.rows;
|
|
670
717
|
}
|
|
671
718
|
else if (declared.length > 0) {
|
|
672
719
|
// The declaration is VOID — one of its files cannot be read. The host
|
package/lib/index.js
CHANGED
|
@@ -118,15 +118,18 @@ function hostPackageManagerOf(context) {
|
|
|
118
118
|
function agentsLookupOf(ctx) {
|
|
119
119
|
return () => ctx.get('agents');
|
|
120
120
|
}
|
|
121
|
+
/** What an all-interfaces listener reports as its bind host; it names no machine. */
|
|
122
|
+
const WILDCARD_BIND_HOSTS = new Set(['0.0.0.0', '::', '[::]']);
|
|
121
123
|
/**
|
|
122
124
|
* The deployment's declared authorities, read from the host (#729).
|
|
123
125
|
*
|
|
124
|
-
* DSH's own /api fence accepts loopback
|
|
125
|
-
* (`dsh web --trusted-host <name
|
|
126
|
-
*
|
|
127
|
-
*
|
|
128
|
-
*
|
|
129
|
-
*
|
|
126
|
+
* DSH's own /api fence accepts loopback, the listener's bind IP literal, or an
|
|
127
|
+
* authority the operator declared (`dsh web --trusted-host <name>`). The
|
|
128
|
+
* market's routes are `exact` registrations on the bare webServer, and exact
|
|
129
|
+
* matches win over that fence's prefix, so they never pass through it — and a
|
|
130
|
+
* loopback-only rule of its own made every mutating route 403 on any deployment
|
|
131
|
+
* reached by a name. The source below therefore mirrors the host's fence: the
|
|
132
|
+
* declared `trustedHosts` plus the listener's own bind host from `webServer`.
|
|
130
133
|
*
|
|
131
134
|
* The `connection` service is optional: a host without it leaves the fence
|
|
132
135
|
* exactly as it was, which is the behaviour every release so far has had.
|
|
@@ -153,9 +156,29 @@ export function useTrustedHosts(ctx) {
|
|
|
153
156
|
warned = true;
|
|
154
157
|
console.warn('dsh-crate: the host connection service is not available; the origin fence accepts loopback only');
|
|
155
158
|
}
|
|
156
|
-
|
|
159
|
+
const hosts = Array.isArray(connection?.trustedHosts)
|
|
157
160
|
? connection.trustedHosts.filter((entry) => typeof entry === 'string')
|
|
158
161
|
: [];
|
|
162
|
+
// The host's own fence accepts the listener's bind IP independently of the
|
|
163
|
+
// declared trustedHosts list, so a deployment reached through its own bind
|
|
164
|
+
// address passed /api yet still 403s here. Mirror that acceptance as a
|
|
165
|
+
// port-less entry, with the same normalization the host applies (the zone
|
|
166
|
+
// id is an interface selector, not address text; a bare IPv6 literal needs
|
|
167
|
+
// brackets to survive the canonical-form parse). The webserver config
|
|
168
|
+
// already rejects anything that is not a concrete, non-wildcard IP literal
|
|
169
|
+
// at load, so the value is safe to trust.
|
|
170
|
+
const bindHost = ctx.get('webServer')?.host;
|
|
171
|
+
// Older hosts bind the all-interfaces literal itself, which no browser
|
|
172
|
+
// sends as a Host and which names no machine in particular: not an
|
|
173
|
+
// authority to trust. Newer ones refuse to load with it.
|
|
174
|
+
if (typeof bindHost === 'string' && bindHost !== '' && !WILDCARD_BIND_HOSTS.has(bindHost)) {
|
|
175
|
+
const zoneAt = bindHost.indexOf('%');
|
|
176
|
+
const address = zoneAt === -1 ? bindHost : bindHost.slice(0, zoneAt);
|
|
177
|
+
const entry = address.includes(':') && !address.startsWith('[') ? `[${address}]` : address;
|
|
178
|
+
if (!hosts.includes(entry))
|
|
179
|
+
hosts.push(entry);
|
|
180
|
+
}
|
|
181
|
+
return hosts;
|
|
159
182
|
});
|
|
160
183
|
// The same service carries the host's request gate (#603): its fence plus
|
|
161
184
|
// its browser login, the check its own API runs. Read per request for the
|
package/lib/install.js
CHANGED
|
@@ -1048,7 +1048,7 @@ export function parsePrepareNotAllowed(stdout, stderr) {
|
|
|
1048
1048
|
// … git-hosted package \"pkg@1.0.0\" needs to execute build scripts …
|
|
1049
1049
|
// Unescape before matching, or the ndjson path — the ONLY path in
|
|
1050
1050
|
// production — silently returns null and the approve banner never shows.
|
|
1051
|
-
const text = `${stdout}\n${stderr}`.replace(/\\"/g, '"');
|
|
1051
|
+
const text = unwrapPnpmErrors(`${stdout}\n${stderr}`.replace(/\\"/g, '"'));
|
|
1052
1052
|
const m = /git-hosted package "([^"]+)" needs to execute build scripts/.exec(text);
|
|
1053
1053
|
if (m === null)
|
|
1054
1054
|
return null;
|
|
@@ -1057,6 +1057,42 @@ export function parsePrepareNotAllowed(stdout, stderr) {
|
|
|
1057
1057
|
const at = raw.lastIndexOf('@');
|
|
1058
1058
|
return at > 0 ? raw.slice(0, at) : raw;
|
|
1059
1059
|
}
|
|
1060
|
+
/**
|
|
1061
|
+
* Undo the line wrapping of pnpm 12's boxed error text (#1156).
|
|
1062
|
+
*
|
|
1063
|
+
* pnpm 12 prints a failure as
|
|
1064
|
+
*
|
|
1065
|
+
* Error: ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED
|
|
1066
|
+
*
|
|
1067
|
+
* × adding a new package
|
|
1068
|
+
* ╰─▶ The git-hosted package "x@1.0.0" needs to execute build
|
|
1069
|
+
* scripts but is not in the "allowBuilds" allowlist.
|
|
1070
|
+
* help: …
|
|
1071
|
+
*
|
|
1072
|
+
* and wraps it at about 80 columns — through the middle of a sentence, and
|
|
1073
|
+
* through the middle of a package key at a `/` or `-`. Every sentence this
|
|
1074
|
+
* file matches then has a line break where its single space was, so the
|
|
1075
|
+
* refusal was classified correctly and still yielded no package name, no
|
|
1076
|
+
* key, and therefore no approve-and-retry button. Continuation lines are
|
|
1077
|
+
* indented deeper than the line they continue; join them back, without a
|
|
1078
|
+
* space when the break fell inside a token.
|
|
1079
|
+
*
|
|
1080
|
+
* Output that never wraps this way (pnpm 10/11, ndjson) has no such lines
|
|
1081
|
+
* and comes back unchanged.
|
|
1082
|
+
*/
|
|
1083
|
+
export function unwrapPnpmErrors(text) {
|
|
1084
|
+
const out = [];
|
|
1085
|
+
for (const line of text.replace(/\r\n/g, '\n').split('\n')) {
|
|
1086
|
+
const previous = out[out.length - 1];
|
|
1087
|
+
if (previous !== undefined && /^ {2,}\S/.test(previous) && /^ {4,}\S/.test(line)) {
|
|
1088
|
+
out[out.length - 1] = previous + (/[^\s][/-]$/.test(previous) ? '' : ' ') + line.trim();
|
|
1089
|
+
}
|
|
1090
|
+
else {
|
|
1091
|
+
out.push(line);
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
return out.join('\n');
|
|
1095
|
+
}
|
|
1060
1096
|
/**
|
|
1061
1097
|
* The allowBuilds key pnpm itself printed for a prepare refusal, when it
|
|
1062
1098
|
* printed one (#698).
|
|
@@ -1077,8 +1113,8 @@ export function parsePrepareNotAllowed(stdout, stderr) {
|
|
|
1077
1113
|
*/
|
|
1078
1114
|
export function parsePrepareKey(stdout, stderr) {
|
|
1079
1115
|
// ndjson carries this inside a JSON string: quotes and newlines escaped.
|
|
1080
|
-
const text = `${stdout}\n${stderr}`.replace(/\\"/g, '"').replace(/\\n/g, '\n');
|
|
1081
|
-
const m = /For example:\s
|
|
1116
|
+
const text = unwrapPnpmErrors(`${stdout}\n${stderr}`.replace(/\\"/g, '"').replace(/\\n/g, '\n'));
|
|
1117
|
+
const m = /For example:\s*allowBuilds:\s*("?)([^\s"]+)\1:\s*true/.exec(text);
|
|
1082
1118
|
return m === null ? null : m[2];
|
|
1083
1119
|
}
|
|
1084
1120
|
/**
|
|
@@ -1118,7 +1154,7 @@ export function allowBuildKeyFromIgnoredBuild(depPath) {
|
|
|
1118
1154
|
* path can contain, so the surrounding JSON is not swallowed.
|
|
1119
1155
|
*/
|
|
1120
1156
|
export function parseIgnoredBuildEntries(stdout, stderr) {
|
|
1121
|
-
const m = /Ignored build scripts:?\s*([^\n]+)/i.exec(`${stdout}\n${stderr}`);
|
|
1157
|
+
const m = /Ignored build scripts:?\s*([^\n]+)/i.exec(unwrapPnpmErrors(`${stdout}\n${stderr}`));
|
|
1122
1158
|
if (m === null)
|
|
1123
1159
|
return [];
|
|
1124
1160
|
const found = [];
|
package/lib/official-desktop.js
CHANGED
|
@@ -241,7 +241,8 @@ async function updateMarketInPlace(spec, name, options, context) {
|
|
|
241
241
|
const args = ['add', spec];
|
|
242
242
|
if (typeof options.registry === 'string' && options.registry !== '')
|
|
243
243
|
args.push(`--registry=${options.registry}`);
|
|
244
|
-
|
|
244
|
+
context.onOwnChild?.(true);
|
|
245
|
+
const run = await runHostPnpm(invocation, directory, args).finally(() => context.onOwnChild?.(false));
|
|
245
246
|
const output = `${run.stdout}\n${run.stderr}`.trim();
|
|
246
247
|
if (run.cancelled) {
|
|
247
248
|
return { application: 'cancelled', packageResult: { exitCode: run.exitCode, output } };
|
|
@@ -384,6 +385,29 @@ async function installOrReinstall(manager, spec, options, context) {
|
|
|
384
385
|
throw error;
|
|
385
386
|
}
|
|
386
387
|
}
|
|
388
|
+
/**
|
|
389
|
+
* The operation the desktop manager is running, visible to every instance of
|
|
390
|
+
* this runtime in the process (#1151).
|
|
391
|
+
*
|
|
392
|
+
* The host reloads the market while an operation the market started is still
|
|
393
|
+
* inside the manager, so the instance that began it is disposed and a new one
|
|
394
|
+
* is built around it. The new one has no `active` of its own and would call
|
|
395
|
+
* the manager idle: it would start a second operation into the first, and its
|
|
396
|
+
* start-up repair would take the removal in progress for an interrupted one.
|
|
397
|
+
* The slot lives on `globalThis` because a reload may evaluate this module
|
|
398
|
+
* again, which a module-level variable would not survive.
|
|
399
|
+
*/
|
|
400
|
+
const OPERATION_SLOT = Symbol.for('dsh-crate.officialDesktop.operation');
|
|
401
|
+
function runningOperation() {
|
|
402
|
+
return globalThis[OPERATION_SLOT];
|
|
403
|
+
}
|
|
404
|
+
function setRunningOperation(operation) {
|
|
405
|
+
const slot = globalThis;
|
|
406
|
+
if (operation === undefined)
|
|
407
|
+
delete slot[OPERATION_SLOT];
|
|
408
|
+
else
|
|
409
|
+
slot[OPERATION_SLOT] = operation;
|
|
410
|
+
}
|
|
387
411
|
/** Resolve the profile directory without making an invalid name a construction failure. */
|
|
388
412
|
function safeProfileDirectory(profile, explicit) {
|
|
389
413
|
if (explicit !== undefined)
|
|
@@ -415,13 +439,22 @@ _profileDirectory,
|
|
|
415
439
|
packageManager) {
|
|
416
440
|
let disposed = false;
|
|
417
441
|
let repairing = false;
|
|
442
|
+
// True only while the self-update overlay runs its own pnpm child: the one
|
|
443
|
+
// operation this instance, and nobody else, has to stop and wait for.
|
|
444
|
+
let ownsChild = false;
|
|
418
445
|
let active;
|
|
419
446
|
const directory = safeProfileDirectory(profileName, _profileDirectory);
|
|
420
447
|
const journal = directory === undefined ? undefined : PendingUpdateJournal.forProfile(directory);
|
|
421
448
|
const updateContext = directory === undefined || journal === undefined
|
|
422
449
|
? undefined
|
|
423
|
-
: {
|
|
424
|
-
|
|
450
|
+
: {
|
|
451
|
+
profile: profileName,
|
|
452
|
+
profileDirectory: directory,
|
|
453
|
+
journal,
|
|
454
|
+
packageManager,
|
|
455
|
+
onOwnChild: running => { ownsChild = running; },
|
|
456
|
+
};
|
|
457
|
+
const busy = () => active !== undefined || repairing || runningOperation() !== undefined;
|
|
425
458
|
const runPlugin = (profile, argv) => {
|
|
426
459
|
if (disposed)
|
|
427
460
|
return Promise.resolve(failure('official desktop plugin runtime is disposed', 127));
|
|
@@ -429,7 +462,7 @@ packageManager) {
|
|
|
429
462
|
return Promise.resolve(failure('refusing to change a different profile', 127));
|
|
430
463
|
// A repair uses the same manager; overlapping the two would race the
|
|
431
464
|
// profile's write lock and the route's single-operation rule.
|
|
432
|
-
if (
|
|
465
|
+
if (busy())
|
|
433
466
|
return Promise.resolve({ ...failure('another plugin operation is running', 127), busy: true });
|
|
434
467
|
const manager = managerLookup();
|
|
435
468
|
if (manager === undefined
|
|
@@ -509,6 +542,8 @@ packageManager) {
|
|
|
509
542
|
}
|
|
510
543
|
const current = { requestId, cancelled: false, done: Promise.resolve(failure('not started')) };
|
|
511
544
|
active = current;
|
|
545
|
+
const flight = { done: current.done };
|
|
546
|
+
setRunningOperation(flight);
|
|
512
547
|
current.done = operation.then((result) => {
|
|
513
548
|
// `overridden` is a change the manager KEPT (`changed: true`) whose live
|
|
514
549
|
// state differs because another layer — a user patch — overrides it.
|
|
@@ -560,11 +595,21 @@ packageManager) {
|
|
|
560
595
|
progress.cancelling = false;
|
|
561
596
|
if (active === current)
|
|
562
597
|
active = undefined;
|
|
598
|
+
if (runningOperation() === flight)
|
|
599
|
+
setRunningOperation(undefined);
|
|
563
600
|
});
|
|
601
|
+
flight.done = current.done;
|
|
564
602
|
return current.done;
|
|
565
603
|
};
|
|
566
604
|
const repairPendingUpdates = async () => {
|
|
567
605
|
const empty = { reinstalled: [], finished: [], failed: [], abandoned: [] };
|
|
606
|
+
// An operation a previous instance started is still inside the manager:
|
|
607
|
+
// its journal record is in progress, not interrupted. Let it settle first
|
|
608
|
+
// — it finishes its own record on success, and a failure leaves the
|
|
609
|
+
// record for exactly this repair. The operation is bounded by its own
|
|
610
|
+
// deadline, so this wait is too.
|
|
611
|
+
if (active === undefined)
|
|
612
|
+
await runningOperation()?.done.catch(() => { });
|
|
568
613
|
if (disposed || repairing || active !== undefined)
|
|
569
614
|
return empty;
|
|
570
615
|
const manager = managerLookup();
|
|
@@ -607,13 +652,26 @@ packageManager) {
|
|
|
607
652
|
acceptsMarketPnpmFlags: false,
|
|
608
653
|
dispose: async () => {
|
|
609
654
|
disposed = true;
|
|
610
|
-
|
|
655
|
+
const running = active;
|
|
656
|
+
// An operation inside the host's manager is the host's to finish (#1151).
|
|
657
|
+
// The host reloads the market in the middle of the operation the market
|
|
658
|
+
// started — and its reconciliation waits for this very disposer — so
|
|
659
|
+
// waiting here for the operation, which waits for the reconciliation,
|
|
660
|
+
// is a cycle: the market was already unmounted, the request never
|
|
661
|
+
// answered, the profile lock stayed held. Cancelling would also abort
|
|
662
|
+
// the update the user asked for halfway. Let it run; the next instance
|
|
663
|
+
// sees it through `runningOperation`.
|
|
664
|
+
if (running !== undefined && !ownsChild) {
|
|
665
|
+
void running.done.catch(() => { });
|
|
666
|
+
return;
|
|
667
|
+
}
|
|
668
|
+
if (running?.requestId !== undefined) {
|
|
611
669
|
const manager = managerLookup();
|
|
612
670
|
if (manager !== undefined)
|
|
613
|
-
void manager.cancelInstall(
|
|
671
|
+
void manager.cancelInstall(running.requestId).catch(() => { });
|
|
614
672
|
}
|
|
615
673
|
cancelHostChild();
|
|
616
|
-
await
|
|
674
|
+
await running?.done;
|
|
617
675
|
},
|
|
618
676
|
};
|
|
619
677
|
}
|
package/lib/profile.js
CHANGED
|
@@ -10,7 +10,7 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
10
10
|
import { JSON_SCHEMA, load } from 'js-yaml';
|
|
11
11
|
import { findDshInstallDir } from './dsh-install.js';
|
|
12
12
|
import { resolveDshHome } from './home-paths.js';
|
|
13
|
-
import { githubRemoteIdentities, githubRepoIdentities, hostedRepoKey, isGenerationLink, isGitHostedSpec, repoOfTarget } from './sources.js';
|
|
13
|
+
import { catalogRepoKey, githubRemoteIdentities, githubRepoIdentities, hostedRepoKey, isGenerationLink, isGitHostedSpec, lookupRepoFromUrl, repoOfTarget } from './sources.js';
|
|
14
14
|
/**
|
|
15
15
|
* Whether a profile name follows DSH's own directory-name contract.
|
|
16
16
|
*
|
|
@@ -669,9 +669,20 @@ export function readInstalledRepoEvidence(profile, name, spec, explicitDir) {
|
|
|
669
669
|
// The URL still must not be resolved through the package's OWN manifest:
|
|
670
670
|
// a fork installed as `github:myfork/plugin` carries upstream's repository
|
|
671
671
|
// field, and trusting it made upstream's card read as installed (#580).
|
|
672
|
+
//
|
|
673
|
+
// A Release asset URL names its source just as plainly, but it is not an
|
|
674
|
+
// install TARGET this build will fetch from later, so it stays out of
|
|
675
|
+
// repoOfTarget (that one answers "where will this come from"). Reading it
|
|
676
|
+
// here keeps the display-only promise lookupRepoFromUrl makes: the identity
|
|
677
|
+
// links an installed package to its catalog entry, and nothing in install,
|
|
678
|
+
// rollback, duplicate detection, or build-script approval reads it.
|
|
672
679
|
if (!local && (isGitHostedSpec(spec) || /^https?:/i.test(spec.trim()))) {
|
|
673
680
|
const repo = repoOfTarget(spec);
|
|
674
|
-
|
|
681
|
+
if (repo !== null)
|
|
682
|
+
return { identities: [repo], hints: [] };
|
|
683
|
+
const release = lookupRepoFromUrl(spec.trim());
|
|
684
|
+
const key = release === null ? null : catalogRepoKey(release);
|
|
685
|
+
return key === null ? { identities: [], hints: [] } : { identities: [key], hints: [] };
|
|
675
686
|
}
|
|
676
687
|
const root = profileDir(profile, explicitDir);
|
|
677
688
|
const sourceDir = local ? localSpecDirectory(root, spec) : null;
|
package/lib/routes.js
CHANGED
|
@@ -722,6 +722,38 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
722
722
|
return;
|
|
723
723
|
logEvent('warn', 'toggle', `${name}: kept off by this market's own record, while ${homePatchPath} enables it — that layer is not the one the market writes, so the market will not follow it. Move the row into this profile's cordis.patch.yml to make it stick (#519)`);
|
|
724
724
|
}
|
|
725
|
+
/**
|
|
726
|
+
* Replay one switched-off package at boot, carrier-safe.
|
|
727
|
+
*
|
|
728
|
+
* The disable list only names a package, while a CARRIER bundle's patch
|
|
729
|
+
* also rewires foreign rows: it disables stock rows or gives them an
|
|
730
|
+
* `inject:` for a service the bundle's own gate entry provides. Disabling
|
|
731
|
+
* every matching entry would stop that gate too (the gate entry's name is
|
|
732
|
+
* `<pkg>/<row>`, so it matches the package), and the foreign rows would
|
|
733
|
+
* wait forever for a service that no longer exists — every preset pending.
|
|
734
|
+
*
|
|
735
|
+
* While such a bundle still sits in dsh.profile.bundles (an interrupted or
|
|
736
|
+
* older toggle can leave the list and the stack out of sync), reconcile it
|
|
737
|
+
* the same way the live toggle route does: remove the whole bundle so its
|
|
738
|
+
* entire patch stops applying on the next composition. Ordinary packages
|
|
739
|
+
* keep the best-effort entry disable they always had.
|
|
740
|
+
*
|
|
741
|
+
* The bundle removal edits the manifest for the NEXT composition; the
|
|
742
|
+
* current process already loaded the bundle, which is the same restart
|
|
743
|
+
* contract a live carrier toggle already has.
|
|
744
|
+
*/
|
|
745
|
+
async function replayDisabledPackage(name) {
|
|
746
|
+
const carrierRows = carrierRowIds(activeProfileDir, name);
|
|
747
|
+
if (carrierRows.length > 0
|
|
748
|
+
&& declaresBundle(activeProfileDir, name)
|
|
749
|
+
&& readProfileBundles(activeProfileDir).includes(name)) {
|
|
750
|
+
removeProfileBundle(activeProfileDir, name);
|
|
751
|
+
logEvent('info', 'boot', `${name}: carrier removed from dsh.profile.bundles during boot replay (carrier rows: ${carrierRows.join(', ')}) — restart to finish; its gate is not disabled`);
|
|
752
|
+
return;
|
|
753
|
+
}
|
|
754
|
+
if (await themes.setEntryDisabled(name, true))
|
|
755
|
+
logEvent('info', 'boot', `plugin kept off: ${name}`);
|
|
756
|
+
}
|
|
725
757
|
// Client-only packages (dsh.client without dsh.bundle) are invisible to the
|
|
726
758
|
// bundle layer in every boot; the market shim-mounts them so their client
|
|
727
759
|
// bundles are actually served.
|
|
@@ -736,8 +768,7 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
736
768
|
if (followOutsideEnable(name))
|
|
737
769
|
continue;
|
|
738
770
|
noteHomeLayerConflict(name);
|
|
739
|
-
|
|
740
|
-
logEvent('info', 'boot', `plugin kept off: ${name}`);
|
|
771
|
+
await replayDisabledPackage(name);
|
|
741
772
|
}
|
|
742
773
|
});
|
|
743
774
|
// Self-healing guard: dsh's own patch overlay can re-update entries during
|
|
@@ -746,8 +777,15 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
746
777
|
host.on?.('internal/plugin', (payload) => {
|
|
747
778
|
const fiber = payload;
|
|
748
779
|
const name = fiber.entry?.options?.name;
|
|
749
|
-
if (name
|
|
750
|
-
|
|
780
|
+
if (name === undefined || !disabled.has(name) || followOutsideEnable(name))
|
|
781
|
+
return;
|
|
782
|
+
// A carrier is reconciled by removing its bundle for the next
|
|
783
|
+
// composition, not by disabling its entries. Pushing a matching entry
|
|
784
|
+
// back down here would stop the gate foreign rows inject and re-strand
|
|
785
|
+
// them in the running process; let the restart finish the switch.
|
|
786
|
+
if (carrierRowIds(activeProfileDir, name).length > 0 && declaresBundle(activeProfileDir, name))
|
|
787
|
+
return;
|
|
788
|
+
void themes.setEntryDisabled(name, true);
|
|
751
789
|
});
|
|
752
790
|
let installing = false;
|
|
753
791
|
let restarting = false;
|
|
@@ -3165,7 +3203,12 @@ export function mountMarketRoutes(host, config, commandRuntime, agentsLookup, ho
|
|
|
3165
3203
|
sendJson(response, 200, { compatibleVersion: null, reason: 'installed-version-unknown' });
|
|
3166
3204
|
return;
|
|
3167
3205
|
}
|
|
3168
|
-
|
|
3206
|
+
// The update route's own rule (#991): the Desktop moves a stable npm
|
|
3207
|
+
// install only to a stable release, so a prerelease found here would
|
|
3208
|
+
// be an enabled button that answers 409 (#1161).
|
|
3209
|
+
const stableOnly = upgradeOnly && config.desktopHost === true && !SELF_NAMES.has(npmName)
|
|
3210
|
+
&& isStableReleaseVersion(currentVersion);
|
|
3211
|
+
const compatibleVersion = await findCompatibleVersion(npmName, host.version, corePackageNames(host.directory ?? null), routesFor(region).npmRegistry, undefined, currentVersion, stableOnly);
|
|
3169
3212
|
// A compatible version is only advice until the release-age gate
|
|
3170
3213
|
// agrees: the dialog says "update to X", and clicking that used to
|
|
3171
3214
|
// dead-end on a 409 the log never mentioned. Answer both questions
|
package/lib/types/check.d.ts
CHANGED
|
@@ -235,6 +235,34 @@ export declare function parsePatchText(text: string): unknown[] | null;
|
|
|
235
235
|
export declare function parsePatchFile(path: string): unknown[] | null;
|
|
236
236
|
/** DSH host core packages: what the dsh installation ships under @deepseek-ai. */
|
|
237
237
|
export declare function corePackageNames(dshInstallDir: string | null): Set<string>;
|
|
238
|
+
/**
|
|
239
|
+
* Rewrite a comparator whose target is a PARTIAL version into the full
|
|
240
|
+
* comparators node-semver desugars it to. Anything else comes back as is.
|
|
241
|
+
*
|
|
242
|
+
* The `@deepseek-ai/dsh-*` peers of a whole family of connector plugins are
|
|
243
|
+
* written this way (`>=0.1.5 <0.3`, `>=0.1.7-rc <2`, `>=0.2.0-rc.0 <0.3`).
|
|
244
|
+
* Read as unknown, they left the activation gate standing aside: measured
|
|
245
|
+
* against the host's own evaluator over 699 live catalog manifests, those
|
|
246
|
+
* were the last 7 of 2796 (package, runtime) pairs where the host refuses a
|
|
247
|
+
* plugin and the market still promised a restart would apply it.
|
|
248
|
+
*
|
|
249
|
+
* Zero-filling the target is right for `>=` and wrong for the rest. A partial
|
|
250
|
+
* names a whole release line, so node-semver (`replaceXRange`, `replaceTilde`,
|
|
251
|
+
* `replaceCaret`) moves the bound to the edge of that line:
|
|
252
|
+
*
|
|
253
|
+
* `<0.3` → `<0.3.0-0` `<=0.3` → `<0.4.0-0`
|
|
254
|
+
* `>0.3` → `>=0.4.0` `>1` → `>=2.0.0`
|
|
255
|
+
* `~1` → `>=1.0.0 <2.0.0-0` `^0` → `>=0.0.0 <1.0.0-0`
|
|
256
|
+
* `^0.0` → `>=0.0.0 <0.1.0-0`
|
|
257
|
+
*
|
|
258
|
+
* Comparing against the raw partial string instead ordered `9.1.0` above
|
|
259
|
+
* `10` and `0.10.0` below `0.3`, character by character.
|
|
260
|
+
*
|
|
261
|
+
* A BARE partial (`1.2`) has no operator and is an x-range in semver
|
|
262
|
+
* (`>=1.2.0 <1.3.0`), so it stays as is and parses as unknown below rather
|
|
263
|
+
* than being mistaken for the exact version `1.2.0`.
|
|
264
|
+
*/
|
|
265
|
+
export declare function expandPartialComparator(part: string, includePrerelease: boolean): string[];
|
|
238
266
|
/** Compare two semver strings: negative | zero | positive (prerelease < release of same base). */
|
|
239
267
|
/** Whether a string is a well-formed semver `compareSemver` can order. */
|
|
240
268
|
export declare function isSemver(value: string): boolean;
|
|
@@ -138,8 +138,12 @@ export declare class DiscoveryManifestIndex {
|
|
|
138
138
|
* installed one, which is what an update needs: suggesting a downgrade is not
|
|
139
139
|
* an update.
|
|
140
140
|
*
|
|
141
|
+
* `stableOnly` drops prereleases. The official Desktop refuses to move a
|
|
142
|
+
* stable install onto a prerelease by itself (#991), so offering one there is
|
|
143
|
+
* an enabled button that can only answer 409 (#1161).
|
|
144
|
+
*
|
|
141
145
|
* @returns the version, or null when the packument cannot be read or nothing
|
|
142
146
|
* in the history declares itself compatible.
|
|
143
147
|
*/
|
|
144
|
-
export declare function findCompatibleVersion(npmName: string, hostVersion: string, hostPackages: ReadonlySet<string>, registry: string, fetcher?: FetchLike, minimumVersionExclusive?: string | null): Promise<string | null>;
|
|
148
|
+
export declare function findCompatibleVersion(npmName: string, hostVersion: string, hostPackages: ReadonlySet<string>, registry: string, fetcher?: FetchLike, minimumVersionExclusive?: string | null, stableOnly?: boolean): Promise<string | null>;
|
|
145
149
|
export {};
|
package/lib/types/hot.d.ts
CHANGED
|
@@ -69,6 +69,35 @@ export declare function resolveProfileEntry(profileDir: string, name: string): s
|
|
|
69
69
|
* expressions) — those compositions fall back to restart activation.
|
|
70
70
|
*/
|
|
71
71
|
export declare function parseSimplePatch(patchText: string): HotRow[] | null;
|
|
72
|
+
/**
|
|
73
|
+
* Which shape stopped `parseSimplePatch` — the CAUSE, not just "not plain".
|
|
74
|
+
*
|
|
75
|
+
* `parseSimplePatch` collapses five different inputs into one `null`: a
|
|
76
|
+
* `config` block, a `disabled`/`enabled` switch row, any other key (`inject`,
|
|
77
|
+
* a nested mapping), a row whose `name` never arrives, and a patch with no
|
|
78
|
+
* insert rows at all. Every caller that had to explain the refusal threw all
|
|
79
|
+
* five into one sentence written for the first, and told users their patch
|
|
80
|
+
* "contains config/expression rows" when it merely switched a row off
|
|
81
|
+
* (#1102). Naming the shape is the difference between a sentence the reader
|
|
82
|
+
* can act on and one they cannot (#813, AGENTS.md: 说不出来就别用一句话把
|
|
83
|
+
* 空缺填上).
|
|
84
|
+
*/
|
|
85
|
+
export type PatchBlocker = 'config' | 'disabled' | 'incomplete' | 'empty' | 'other';
|
|
86
|
+
export interface PatchScan {
|
|
87
|
+
/** Insert rows read before the scan stopped; empty when it did not. */
|
|
88
|
+
rows: HotRow[];
|
|
89
|
+
/** null when the patch IS a plain insert list (`rows` is then non-empty). */
|
|
90
|
+
blocker: PatchBlocker | null;
|
|
91
|
+
/** The key that stopped the scan, when there is one to name. */
|
|
92
|
+
key?: string;
|
|
93
|
+
}
|
|
94
|
+
export declare function scanPatch(patchText: string): PatchScan;
|
|
95
|
+
/**
|
|
96
|
+
* One sentence for a refusal that is only about the patch's shape, naming the
|
|
97
|
+
* cause and what happens next. Shared by the hot mount and the activation
|
|
98
|
+
* verdict so the two cannot drift apart on the same fact again.
|
|
99
|
+
*/
|
|
100
|
+
export declare function patchBlockerReason(blocker: PatchBlocker, key?: string): string;
|
|
72
101
|
/**
|
|
73
102
|
* Wipe leftover hot-mount inputs; call once when the market host starts.
|
|
74
103
|
* `state.json` (disable choices + groups) deliberately survives.
|
package/lib/types/index.d.ts
CHANGED
|
@@ -18,12 +18,13 @@ export declare function describeProfileContext(value: unknown): string;
|
|
|
18
18
|
/**
|
|
19
19
|
* The deployment's declared authorities, read from the host (#729).
|
|
20
20
|
*
|
|
21
|
-
* DSH's own /api fence accepts loopback
|
|
22
|
-
* (`dsh web --trusted-host <name
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
21
|
+
* DSH's own /api fence accepts loopback, the listener's bind IP literal, or an
|
|
22
|
+
* authority the operator declared (`dsh web --trusted-host <name>`). The
|
|
23
|
+
* market's routes are `exact` registrations on the bare webServer, and exact
|
|
24
|
+
* matches win over that fence's prefix, so they never pass through it — and a
|
|
25
|
+
* loopback-only rule of its own made every mutating route 403 on any deployment
|
|
26
|
+
* reached by a name. The source below therefore mirrors the host's fence: the
|
|
27
|
+
* declared `trustedHosts` plus the listener's own bind host from `webServer`.
|
|
27
28
|
*
|
|
28
29
|
* The `connection` service is optional: a host without it leaves the fence
|
|
29
30
|
* exactly as it was, which is the behaviour every release so far has had.
|
package/lib/types/install.d.ts
CHANGED
|
@@ -402,6 +402,30 @@ export declare function isStaleUpdate(check: {
|
|
|
402
402
|
* node_modules yet (the fetcher rejects before materialization, #68).
|
|
403
403
|
*/
|
|
404
404
|
export declare function parsePrepareNotAllowed(stdout: string, stderr: string): string | null;
|
|
405
|
+
/**
|
|
406
|
+
* Undo the line wrapping of pnpm 12's boxed error text (#1156).
|
|
407
|
+
*
|
|
408
|
+
* pnpm 12 prints a failure as
|
|
409
|
+
*
|
|
410
|
+
* Error: ERR_PNPM_GIT_DEP_PREPARE_NOT_ALLOWED
|
|
411
|
+
*
|
|
412
|
+
* × adding a new package
|
|
413
|
+
* ╰─▶ The git-hosted package "x@1.0.0" needs to execute build
|
|
414
|
+
* scripts but is not in the "allowBuilds" allowlist.
|
|
415
|
+
* help: …
|
|
416
|
+
*
|
|
417
|
+
* and wraps it at about 80 columns — through the middle of a sentence, and
|
|
418
|
+
* through the middle of a package key at a `/` or `-`. Every sentence this
|
|
419
|
+
* file matches then has a line break where its single space was, so the
|
|
420
|
+
* refusal was classified correctly and still yielded no package name, no
|
|
421
|
+
* key, and therefore no approve-and-retry button. Continuation lines are
|
|
422
|
+
* indented deeper than the line they continue; join them back, without a
|
|
423
|
+
* space when the break fell inside a token.
|
|
424
|
+
*
|
|
425
|
+
* Output that never wraps this way (pnpm 10/11, ndjson) has no such lines
|
|
426
|
+
* and comes back unchanged.
|
|
427
|
+
*/
|
|
428
|
+
export declare function unwrapPnpmErrors(text: string): string;
|
|
405
429
|
/**
|
|
406
430
|
* The allowBuilds key pnpm itself printed for a prepare refusal, when it
|
|
407
431
|
* printed one (#698).
|
package/lib/verify.js
CHANGED
|
@@ -30,7 +30,7 @@ import { readFileSync, realpathSync, statSync } from 'node:fs';
|
|
|
30
30
|
import { createRequire, isBuiltin } from 'node:module';
|
|
31
31
|
import { Script } from 'node:vm';
|
|
32
32
|
import { join } from 'node:path';
|
|
33
|
-
import { listHotMounts,
|
|
33
|
+
import { listHotMounts, patchBlockerReason, scanPatch } from './hot.js';
|
|
34
34
|
import { userPatchPackageReferences } from './patch.js';
|
|
35
35
|
import { nameMatchesPackage } from './entry-identity.js';
|
|
36
36
|
import { bundlePatchInsertedIds, declaredBundlePatchFiles, hasDshManifest, hasLoadableEntry, pluginSubdirs, profileDir, readInstalled } from './profile.js';
|
|
@@ -135,13 +135,34 @@ function readPkgDsh(profile, name, explicitDir) {
|
|
|
135
135
|
return null;
|
|
136
136
|
}
|
|
137
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* The patch text the HOST reads for this package, or null when it reads none.
|
|
140
|
+
*
|
|
141
|
+
* #1102: this used to read the package root's `cordis.patch.yml`
|
|
142
|
+
* unconditionally, while hot mount (#646, #792) and `bundlePatchIsEmpty`
|
|
143
|
+
* resolve `dsh.bundle.patch` through `declaredBundlePatchFiles`. Two
|
|
144
|
+
* consumers of one fact disagreed: a patch declared in a subdirectory, or as
|
|
145
|
+
* a list, was judged from a file the host never reads (or from no file at
|
|
146
|
+
* all), and a leftover root file could decide the verdict by itself.
|
|
147
|
+
*
|
|
148
|
+
* Same rule as hot mount, deliberately: the declared files, the root file as
|
|
149
|
+
* the fallback for packages that declare nothing, and all-or-nothing — the
|
|
150
|
+
* host throws on one unreadable overlay file and skips the whole bundle.
|
|
151
|
+
*/
|
|
138
152
|
function patchTextOf(profile, name, explicitDir) {
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
153
|
+
const dir = join(profileDir(profile, explicitDir), 'node_modules', name);
|
|
154
|
+
const declared = declaredBundlePatchFiles(dir);
|
|
155
|
+
const sources = declared.length > 0 ? declared : [join(dir, 'cordis.patch.yml')];
|
|
156
|
+
const texts = [];
|
|
157
|
+
for (const file of sources) {
|
|
158
|
+
try {
|
|
159
|
+
texts.push(readFileSync(file, 'utf8'));
|
|
160
|
+
}
|
|
161
|
+
catch {
|
|
162
|
+
return null;
|
|
163
|
+
}
|
|
144
164
|
}
|
|
165
|
+
return texts.join('\n');
|
|
145
166
|
}
|
|
146
167
|
/**
|
|
147
168
|
* Verify the activation state of one installed package.
|
|
@@ -570,12 +591,17 @@ loaderNeverStarted = false) {
|
|
|
570
591
|
};
|
|
571
592
|
}
|
|
572
593
|
const patch = patchTextOf(profile, name, activeProfileDir);
|
|
573
|
-
const
|
|
594
|
+
const scan = patch === null ? null : scanPatch(patch);
|
|
595
|
+
// #1102: a patch the market cannot replay has five shapes, and saying
|
|
596
|
+
// "config/expression" for all of them told users something about their
|
|
597
|
+
// package that was not true — a switched-off row is not a config block.
|
|
598
|
+
// Name the shape when it is known; keep the honest "not hot-mounted this
|
|
599
|
+
// session" when the declaration could not be read at all.
|
|
574
600
|
return {
|
|
575
601
|
state: 'restart',
|
|
576
602
|
reasons: [
|
|
577
|
-
|
|
578
|
-
?
|
|
603
|
+
scan !== null && scan.blocker !== null
|
|
604
|
+
? patchBlockerReason(scan.blocker, scan.key)
|
|
579
605
|
: '已进入 profile bundle 层但本次未能热挂载;重启后生效 / in the bundle layer but not hot-mounted this session — it activates on restart',
|
|
580
606
|
],
|
|
581
607
|
bundle: true,
|