@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/toolchain.js CHANGED
@@ -1,36 +1,11 @@
1
- import { execaSync } from 'execa';
2
1
  import lockfile from 'proper-lockfile';
3
- import writeFileAtomic from 'write-file-atomic';
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
- export function desktopPnpmPath(proc = process, exists = existsSync) {
9
- if (hostSurface({ proc }).deployment !== 'desktop')
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 options.run(command);
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
- writeFileAtomic.sync(file, shim, 'utf8');
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-beta.1",
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
- "write-file-atomic": "^8.0.0",
19
- "@dsh-workbench/adapter-supply": "1.1.14-beta.1",
20
- "@dsh-workbench/adapter-runtime": "1.1.14-beta.1",
21
- "@dsh-workbench/shared": "1.1.14-beta.1",
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"