dshmarket 1.76.0 → 1.76.1
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/lib/dsh-cli.js +50 -3
- package/lib/types/dsh-cli.d.ts +20 -0
- package/package.json +1 -1
package/lib/dsh-cli.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
*/
|
|
9
9
|
import { spawn, spawnSync } from 'node:child_process';
|
|
10
10
|
import { existsSync, readFileSync, rmSync } from 'node:fs';
|
|
11
|
-
import { homedir } from 'node:os';
|
|
11
|
+
import { homedir, tmpdir } from 'node:os';
|
|
12
12
|
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
13
13
|
import { logEvent } from './log.js';
|
|
14
14
|
import { createProgressTracker } from './ndjson.js';
|
|
@@ -749,6 +749,34 @@ export function probePnpm() {
|
|
|
749
749
|
return probePnpmOnPath();
|
|
750
750
|
return probeHostPackageManager().then(ready => ready ? true : probePnpmOnPath());
|
|
751
751
|
}
|
|
752
|
+
/**
|
|
753
|
+
* The cwd to hand a provisioning child.
|
|
754
|
+
*
|
|
755
|
+
* `corepack enable`, `npm i -g` and `npm prefix -g` read no project files, so
|
|
756
|
+
* they gain nothing from inheriting this process's directory — and a host
|
|
757
|
+
* whose boot directory was deleted loses everything to it: the child dies
|
|
758
|
+
* inside `getcwd()` before running a line of its own logic, which is how a
|
|
759
|
+
* one-click setup ended up reporting `npm -g: exit=7` with `syscall:
|
|
760
|
+
* 'uv_cwd'` (#1270).
|
|
761
|
+
*
|
|
762
|
+
* A readable directory is still inherited unchanged, so a healthy machine
|
|
763
|
+
* behaves exactly as before, including the per-project `.npmrc` npm would
|
|
764
|
+
* read from it. Only an unreadable one is replaced, and then with a directory
|
|
765
|
+
* that exists by definition.
|
|
766
|
+
*
|
|
767
|
+
* `process.cwd()` throws instead of returning a stale path, so the call
|
|
768
|
+
* itself is the test.
|
|
769
|
+
* @returns `undefined` to inherit, or a directory that is known to exist.
|
|
770
|
+
*/
|
|
771
|
+
export function provisionCwd() {
|
|
772
|
+
try {
|
|
773
|
+
process.cwd();
|
|
774
|
+
return undefined;
|
|
775
|
+
}
|
|
776
|
+
catch {
|
|
777
|
+
return tmpdir();
|
|
778
|
+
}
|
|
779
|
+
}
|
|
752
780
|
/** Probe `pnpm --version` on PATH. */
|
|
753
781
|
function probePnpmOnPath() {
|
|
754
782
|
if (pnpmReady)
|
|
@@ -779,6 +807,7 @@ function runQuiet(file, args, timeoutMs) {
|
|
|
779
807
|
env: spawnEnv(),
|
|
780
808
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
781
809
|
viaShell: winCmdShim,
|
|
810
|
+
cwd: provisionCwd(),
|
|
782
811
|
});
|
|
783
812
|
const output = createOutputBuffer(8 * 1024);
|
|
784
813
|
const timer = setTimeout(() => killChild(child), timeoutMs);
|
|
@@ -894,11 +923,29 @@ function hostPackageManagerHint() {
|
|
|
894
923
|
* @returns a bilingual, actionable hint, or undefined when unrecognized.
|
|
895
924
|
*/
|
|
896
925
|
export function provisionHint(corepackOutput, npmOutput, npmFound = true, probeFailure = null) {
|
|
926
|
+
// npm started and then could not read the directory it was started in: the
|
|
927
|
+
// host's own cwd had been deleted, so `getcwd()` failed before npm reached
|
|
928
|
+
// any of its logic (#1270). Nothing is missing and nothing is
|
|
929
|
+
// misconfigured, which makes every PATH-shaped hint below — install pnpm,
|
|
930
|
+
// start from a terminal, set PNPM_HOME — advice for a problem this user
|
|
931
|
+
// does not have. `provisionCwd` now keeps a dead directory from being
|
|
932
|
+
// inherited in the first place, so reaching this means the cwd went away
|
|
933
|
+
// after the spawn; naming it is still the only accurate thing to say.
|
|
934
|
+
if (/syscall:\s*['"]uv_cwd['"]/.test(`${corepackOutput}\n${npmOutput}`)) {
|
|
935
|
+
return '这台机器上 dsh 进程启动时的工作目录已经被删掉了,所以 npm 还没跑到自己的逻辑就退了(`syscall: \'uv_cwd\'` 是取当前目录失败,不是找不到文件)。这不是 pnpm 的问题,也不是 PATH 的问题,装什么都修不好。请从一个存在的目录重启 dsh:launchd / systemd 托管的部署把工作目录指到一个确定存在的目录(例如 /tmp),或者先在终端 cd 到任意存在的目录再启动 / The directory this dsh process was started in no longer exists, so npm exited inside `getcwd()` before reaching any of its own logic (`syscall: \'uv_cwd\'` — reading the current directory failed, nothing is missing on disk). This is not a pnpm problem and not a PATH problem, and no install can fix it. Restart dsh from a directory that exists: for launchd/systemd deployments point the working directory at one that does (e.g. /tmp), or `cd` somewhere real before starting it';
|
|
936
|
+
}
|
|
897
937
|
// Node itself unreachable: pointing the user back at this same button
|
|
898
938
|
// would be a dead end (#32). `npmFound` answers this from disk, so it
|
|
899
939
|
// holds on a Windows console that reports the same thing in a codepage we
|
|
900
|
-
// cannot read (#167)
|
|
901
|
-
|
|
940
|
+
// cannot read (#167).
|
|
941
|
+
//
|
|
942
|
+
// The ENOENT pair stays as a fallback for callers that do not pass
|
|
943
|
+
// `npmFound`, but it now has to be a spawn-level miss — `spawn npm ENOENT`,
|
|
944
|
+
// the shape a command that was never found produces. Matching the bare
|
|
945
|
+
// word is how a genuine `spawn corepack ENOENT` got ANDed with npm's
|
|
946
|
+
// `uv_cwd` ENOENT: two unrelated meanings on one token (#1270).
|
|
947
|
+
const spawnMissed = (output, tool) => output.includes(`spawn ${tool} ENOENT`);
|
|
948
|
+
if (!npmFound || (spawnMissed(corepackOutput, 'corepack') && spawnMissed(npmOutput, 'npm'))) {
|
|
902
949
|
// The searched list is spelled out because the previous wording named
|
|
903
950
|
// only the Node directory, which was both incomplete and unhelpful: a
|
|
904
951
|
// user who HAD installed pnpm could not tell whether we looked in the
|
package/lib/types/dsh-cli.d.ts
CHANGED
|
@@ -394,6 +394,26 @@ export declare function lastPnpmProbeFailure(): {
|
|
|
394
394
|
* publishes a broken invocation cannot make things worse than they were.
|
|
395
395
|
*/
|
|
396
396
|
export declare function probePnpm(): Promise<boolean>;
|
|
397
|
+
/**
|
|
398
|
+
* The cwd to hand a provisioning child.
|
|
399
|
+
*
|
|
400
|
+
* `corepack enable`, `npm i -g` and `npm prefix -g` read no project files, so
|
|
401
|
+
* they gain nothing from inheriting this process's directory — and a host
|
|
402
|
+
* whose boot directory was deleted loses everything to it: the child dies
|
|
403
|
+
* inside `getcwd()` before running a line of its own logic, which is how a
|
|
404
|
+
* one-click setup ended up reporting `npm -g: exit=7` with `syscall:
|
|
405
|
+
* 'uv_cwd'` (#1270).
|
|
406
|
+
*
|
|
407
|
+
* A readable directory is still inherited unchanged, so a healthy machine
|
|
408
|
+
* behaves exactly as before, including the per-project `.npmrc` npm would
|
|
409
|
+
* read from it. Only an unreadable one is replaced, and then with a directory
|
|
410
|
+
* that exists by definition.
|
|
411
|
+
*
|
|
412
|
+
* `process.cwd()` throws instead of returning a stale path, so the call
|
|
413
|
+
* itself is the test.
|
|
414
|
+
* @returns `undefined` to inherit, or a directory that is known to exist.
|
|
415
|
+
*/
|
|
416
|
+
export declare function provisionCwd(): string | undefined;
|
|
397
417
|
/**
|
|
398
418
|
* Provision pnpm without user involvement: corepack (ships with Node) first,
|
|
399
419
|
* a global npm install as fallback.
|
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.76.
|
|
4
|
+
"version": "1.76.1",
|
|
5
5
|
"icon": "assets/logo.svg",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|