@dsh-workbench/adapter-probe 1.1.14-beta.1 → 1.1.14
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/dist/bootstrap-run.d.ts +31 -0
- package/dist/bootstrap-run.js +59 -0
- package/dist/browser-wake.d.ts +2 -2
- package/dist/browser-wake.js +11 -15
- package/dist/desktop-runtime.d.ts +14 -0
- package/dist/desktop-runtime.js +59 -0
- package/dist/diy-preset-health.js +3 -2
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/platform.d.ts +3 -1
- package/dist/platform.js +5 -2
- package/dist/preflight-route.d.ts +3 -2
- package/dist/preflight-route.js +20 -14
- package/dist/preflight.d.ts +3 -2
- package/dist/preflight.js +13 -11
- package/dist/probe-cache.js +3 -2
- package/dist/probe-libs.d.ts +2 -3
- package/dist/probe-libs.js +2 -2
- package/dist/probe-units.d.ts +3 -4
- package/dist/probe-units.js +21 -14
- package/dist/release-port.d.ts +3 -3
- package/dist/release-port.js +2 -2
- package/dist/runtime-seed.d.ts +4 -6
- package/dist/runtime-seed.js +31 -61
- package/dist/self-update.d.ts +3 -3
- package/dist/self-update.js +10 -13
- package/dist/supply-port.d.ts +5 -2
- package/dist/supply-port.js +3 -2
- package/dist/toolchain-probe.d.ts +4 -2
- package/dist/toolchain-probe.js +80 -14
- package/dist/toolchain.d.ts +7 -19
- package/dist/toolchain.js +19 -63
- package/package.json +5 -8
package/dist/toolchain.js
CHANGED
|
@@ -1,36 +1,11 @@
|
|
|
1
|
-
import { execaSync } from 'execa';
|
|
2
1
|
import lockfile from 'proper-lockfile';
|
|
3
|
-
import
|
|
4
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
|
|
2
|
+
import { existsSync, mkdirSync, readFileSync, rmSync } from 'node:fs';
|
|
5
3
|
import { join } from 'node:path';
|
|
6
|
-
import { quoteShellArg, quoteShellArgFor } from '@dsh-workbench/shared/host';
|
|
4
|
+
import { quoteShellArg, quoteShellArgFor, writeTextFile } from '@dsh-workbench/shared/host';
|
|
5
|
+
import { bootstrapEnv, runBootstrapCommand } from './bootstrap-run.js';
|
|
7
6
|
import { hostSurface } from './platform.js';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
return undefined;
|
|
11
|
-
const resources = proc.resourcesPath;
|
|
12
|
-
if (resources === undefined || resources === '')
|
|
13
|
-
return undefined;
|
|
14
|
-
const path = join(resources, 'runtime', 'primary-runtime', 'dependencies', 'pnpm', 'bin', 'pnpm.cjs');
|
|
15
|
-
return exists(path) ? path : undefined;
|
|
16
|
-
}
|
|
17
|
-
export function desktopPnpmVersion(proc = process, exists = existsSync) {
|
|
18
|
-
if (hostSurface({ proc }).deployment !== 'desktop')
|
|
19
|
-
return undefined;
|
|
20
|
-
const resources = proc.resourcesPath;
|
|
21
|
-
if (resources === undefined || resources === '')
|
|
22
|
-
return undefined;
|
|
23
|
-
const manifest = join(resources, 'runtime', 'primary-runtime', 'dependencies', 'pnpm', 'package.json');
|
|
24
|
-
if (!exists(manifest))
|
|
25
|
-
return undefined;
|
|
26
|
-
try {
|
|
27
|
-
const parsed = JSON.parse(readFileSync(manifest, 'utf8'));
|
|
28
|
-
return typeof parsed.version === 'string' ? parsed.version : undefined;
|
|
29
|
-
}
|
|
30
|
-
catch {
|
|
31
|
-
return undefined;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
7
|
+
import { desktopPnpmPath } from './desktop-runtime.js';
|
|
8
|
+
export { desktopBundledBins, desktopNodeExecutable, desktopPnpmPath, desktopPnpmVersion, desktopResourcesDir, desktopRuntimeEnv, desktopRuntimeEnvPath } from './desktop-runtime.js';
|
|
34
9
|
export const LOCAL_NPM_VERSION = [10, 9, 4].join('.');
|
|
35
10
|
export const LOCAL_PNPM_VERSION = [10, 32, 1].join('.');
|
|
36
11
|
export function localNpmRoot(root) {
|
|
@@ -91,6 +66,17 @@ export function localPnpmInstallCommand(root, proc = process, exists = existsSyn
|
|
|
91
66
|
return (`node ${quoteShellArgFor(pnpm, platform)} add --dir ${quoteShellArgFor(localPnpmRoot(root), platform)} ` +
|
|
92
67
|
`pnpm@${LOCAL_PNPM_VERSION} --store-dir ${quoteShellArgFor(join(root, 'pnpm-store'), platform)}`);
|
|
93
68
|
}
|
|
69
|
+
const LOCAL_PNPM_PROVISION_TIMEOUT_MS = 180_000;
|
|
70
|
+
function hostProvisionRun(root, seam) {
|
|
71
|
+
return async (command) => {
|
|
72
|
+
const result = await runBootstrapCommand(command, {
|
|
73
|
+
timeoutMs: LOCAL_PNPM_PROVISION_TIMEOUT_MS,
|
|
74
|
+
seam,
|
|
75
|
+
env: bootstrapEnv({ opencliRoot: join(root, 'opencli') }),
|
|
76
|
+
});
|
|
77
|
+
return { ok: result.ok, detail: result.detail };
|
|
78
|
+
};
|
|
79
|
+
}
|
|
94
80
|
export async function provisionLocalPnpm(options) {
|
|
95
81
|
const platform = options.platform ?? process.platform;
|
|
96
82
|
const bootstrap = options.pnpm?.trim();
|
|
@@ -111,8 +97,9 @@ export async function provisionLocalPnpm(options) {
|
|
|
111
97
|
return { ok: false, detail: `建不了 ${localPnpmRoot(options.root)}:${String(error)}` };
|
|
112
98
|
}
|
|
113
99
|
let detail = '';
|
|
100
|
+
const run = options.run ?? hostProvisionRun(options.root, options.seam);
|
|
114
101
|
for (const command of commands) {
|
|
115
|
-
const result = await
|
|
102
|
+
const result = await run(command);
|
|
116
103
|
if (result.ok) {
|
|
117
104
|
const installed = options.installed?.() ?? existsSync(localPnpmCommand(options.root, platform));
|
|
118
105
|
if (installed) {
|
|
@@ -130,36 +117,6 @@ export async function provisionLocalPnpm(options) {
|
|
|
130
117
|
}
|
|
131
118
|
return { ok: false, detail };
|
|
132
119
|
}
|
|
133
|
-
export function provisionLocalPnpmSync(options) {
|
|
134
|
-
const command = localPnpmInstallCommand(options.root, options.proc ?? process, options.exists ?? existsSync);
|
|
135
|
-
if (command === undefined)
|
|
136
|
-
return { ok: false, detail: '找不到 Desktop 自带 pnpm,装不了本地 pnpm 10' };
|
|
137
|
-
try {
|
|
138
|
-
mkdirSync(localPnpmRoot(options.root), { recursive: true });
|
|
139
|
-
}
|
|
140
|
-
catch (error) {
|
|
141
|
-
return { ok: false, detail: `建不了 ${localPnpmRoot(options.root)}:${String(error)}` };
|
|
142
|
-
}
|
|
143
|
-
try {
|
|
144
|
-
const run = options.run ??
|
|
145
|
-
((line) => {
|
|
146
|
-
execaSync(line, { stdio: 'ignore', timeout: 180_000, env: process.env, shell: true });
|
|
147
|
-
});
|
|
148
|
-
run(command);
|
|
149
|
-
}
|
|
150
|
-
catch (error) {
|
|
151
|
-
return { ok: false, detail: String(error) };
|
|
152
|
-
}
|
|
153
|
-
const platform = options.platform ?? process.platform;
|
|
154
|
-
const installed = options.installed?.() ?? existsSync(localPnpmCommand(options.root, platform));
|
|
155
|
-
if (!installed)
|
|
156
|
-
return { ok: false, detail: 'pnpm 跑完但本地 pnpm 10 不在' };
|
|
157
|
-
return {
|
|
158
|
-
ok: true,
|
|
159
|
-
binDir: localPnpmBin(options.root),
|
|
160
|
-
detail: `pnpm@${LOCAL_PNPM_VERSION} 装到 ${localPnpmRoot(options.root)}`,
|
|
161
|
-
};
|
|
162
|
-
}
|
|
163
120
|
function readText(file) {
|
|
164
121
|
try {
|
|
165
122
|
return readFileSync(file, 'utf8');
|
|
@@ -207,8 +164,7 @@ export function ensureToolchain(options) {
|
|
|
207
164
|
release = lockfile.lockSync(pathDir, { realpath: false });
|
|
208
165
|
if (readText(file) !== shim) {
|
|
209
166
|
rmSync(file, { force: true });
|
|
210
|
-
|
|
211
|
-
chmodSync(file, 0o755);
|
|
167
|
+
writeTextFile(file, shim, { mode: 0o755 });
|
|
212
168
|
files.push(file);
|
|
213
169
|
}
|
|
214
170
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dsh-workbench/adapter-probe",
|
|
3
|
-
"version": "1.1.14
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"description": "Workbench adapter-probe adapter.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -13,18 +13,15 @@
|
|
|
13
13
|
"dist"
|
|
14
14
|
],
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"execa": "^10.2.0",
|
|
17
16
|
"proper-lockfile": "^4.1.2",
|
|
18
|
-
"
|
|
19
|
-
"@dsh-workbench/
|
|
20
|
-
"@dsh-workbench/adapter-runtime": "1.1.14
|
|
21
|
-
"@dsh-workbench/
|
|
22
|
-
"@dsh-workbench/adapter-profile": "1.1.14-beta.1"
|
|
17
|
+
"@dsh-workbench/adapter-profile": "1.1.14",
|
|
18
|
+
"@dsh-workbench/shared": "1.1.14",
|
|
19
|
+
"@dsh-workbench/adapter-runtime": "1.1.14",
|
|
20
|
+
"@dsh-workbench/adapter-supply": "1.1.14"
|
|
23
21
|
},
|
|
24
22
|
"devDependencies": {
|
|
25
23
|
"@types/node": "^24.19.0",
|
|
26
24
|
"@types/proper-lockfile": "^4.1.4",
|
|
27
|
-
"@types/write-file-atomic": "^4.0.3",
|
|
28
25
|
"vitest": "^5.0.2",
|
|
29
26
|
"dayjs": "^1.11.23",
|
|
30
27
|
"@vitest/coverage-v8": "^5.0.2"
|