@dsh-workbench/adapter-runtime 1.2.0-beta.0 → 1.2.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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencli-plugin-workbench",
3
- "version": "1.2.0-beta.0",
3
+ "version": "1.2.1",
4
4
  "private": true,
5
5
  "type": "module",
6
6
  "description": "DSH 工作台的公共通道:带浏览器登录态的 Node 侧 fetch,只服务 cookie / cookieValue 两种凭据来源",
@@ -1,9 +1,10 @@
1
+ import type { PluginPlanStep } from '@dsh-workbench/shared/host';
1
2
  export declare const CHANNEL_PLUGIN_NAME = "opencli-plugin-workbench";
2
3
  export declare const CHANNEL_PLUGIN_SITE = "workbench";
3
4
  export interface ChannelPluginPlan {
4
5
  readonly dest: string;
5
6
  readonly version: string;
6
- readonly commands: readonly string[];
7
+ readonly steps: readonly PluginPlanStep[];
7
8
  readonly line: string;
8
9
  }
9
10
  export declare function channelVersionOf(dir: string): string | undefined;
@@ -1,6 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
- import { quoteShellArg } from '@dsh-workbench/shared/host';
3
+ import { planLineOf, quoteShellArg } from '@dsh-workbench/shared/host';
4
4
  import { isolatedHome, toolchainOpencliDir, vendorPeerLink, vendorPluginsDir } from '../foundation/paths.js';
5
5
  export const CHANNEL_PLUGIN_NAME = 'opencli-plugin-workbench';
6
6
  export const CHANNEL_PLUGIN_SITE = 'workbench';
@@ -26,13 +26,19 @@ export function channelPluginPlan(options) {
26
26
  const command = options.command ?? 'opencli';
27
27
  const dest = join(vendorPluginsDir(), CHANNEL_PLUGIN_NAME);
28
28
  const peer = vendorPeerLink();
29
- const commands = [
30
- `rm -rf ${quoteShellArg(dest)} && mkdir -p ${quoteShellArg(dest)} && cp -R ${quoteShellArg(options.channelDir)}/. ${quoteShellArg(dest)}/`,
31
- `rm -rf ${quoteShellArg(peer.dir)} && mkdir -p ${quoteShellArg(peer.parent)} && ln -s ${quoteShellArg(toolchainOpencliDir())} ${quoteShellArg(peer.dir)}`,
32
- `(${quoteShellArg(command)} plugin uninstall ${quoteShellArg(CHANNEL_PLUGIN_SITE)} || true)`,
33
- `${quoteShellArg(command)} plugin install ${quoteShellArg(dest)}`,
29
+ const steps = [
30
+ { kind: 'copy', from: options.channelDir, to: dest },
31
+ { kind: 'remove', path: peer.dir },
32
+ { kind: 'mkdir', path: peer.parent },
33
+ { kind: 'link', target: toolchainOpencliDir(), path: peer.dir },
34
+ {
35
+ kind: 'run',
36
+ line: `${quoteShellArg(command)} plugin uninstall ${quoteShellArg(CHANNEL_PLUGIN_SITE)}`,
37
+ optional: true,
38
+ },
39
+ { kind: 'run', line: `${quoteShellArg(command)} plugin install ${quoteShellArg(dest)}` },
34
40
  ];
35
- return { dest, version, commands, line: commands.join(' && ') };
41
+ return { dest, version, steps, line: planLineOf(steps) };
36
42
  }
37
43
  export function channelInstalledVersion() {
38
44
  return channelVersionOf(join(vendorPluginsDir(), CHANNEL_PLUGIN_NAME));
@@ -1,5 +1,5 @@
1
1
  import { fileURLToPath } from 'node:url';
2
- import { DEFAULT_RECIPE_MAX_BYTES, productWrite, quoteShellArg, } from '@dsh-workbench/shared/host';
2
+ import { DEFAULT_RECIPE_MAX_BYTES, PlanStepError, productWrite, quoteShellArg, runPlan, } from '@dsh-workbench/shared/host';
3
3
  import { channelInstalledVersion, channelPluginPlan, channelSiteInstalled, channelVersionOf, } from './channel-plugin.js';
4
4
  export const CHANNEL_DIR = fileURLToPath(new URL('../../channel/', import.meta.url));
5
5
  function authOf(recipe) {
@@ -113,9 +113,17 @@ export async function ensureChannel(seam, command, state, ready = channelAlready
113
113
  state.value = 'unavailable';
114
114
  return false;
115
115
  }
116
- const result = await seam.run({ command: plan.line, intent: productWrite(), timeoutMs: 120_000 });
117
- state.value = result.exitCode === 0 && !result.timedOut ? 'ready' : 'unavailable';
118
- return state.value === 'ready';
116
+ try {
117
+ await runPlan(plan.steps, { seam, intent: productWrite(), timeoutMs: 120_000 });
118
+ }
119
+ catch (error) {
120
+ if (!(error instanceof PlanStepError))
121
+ throw error;
122
+ state.value = 'unavailable';
123
+ return false;
124
+ }
125
+ state.value = 'ready';
126
+ return true;
119
127
  }
120
128
  export function channelCommandLine(call) {
121
129
  return call.argv.map((one) => quoteShellArg(one)).join(' ');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-workbench/adapter-runtime",
3
- "version": "1.2.0-beta.0",
3
+ "version": "1.2.1",
4
4
  "description": "Opencli, browser and data runtime adapters.",
5
5
  "type": "module",
6
6
  "exports": {
@@ -17,7 +17,7 @@
17
17
  "bin"
18
18
  ],
19
19
  "dependencies": {
20
- "@dsh-workbench/shared": "1.2.0-beta.0"
20
+ "@dsh-workbench/shared": "1.2.1"
21
21
  },
22
22
  "devDependencies": {
23
23
  "@types/node": "^24.19.0",