@dsh-workbench/shared 1.5.2-alpha.0 → 1.5.2-alpha.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/dist/contract/protocol/bundle-install.d.ts +7 -1
- package/dist/contract/protocol/bundle-install.js +1 -0
- package/dist/host/runtime/dsh-compat.js +20 -6
- package/dist/i18n/en.js +2 -0
- package/dist/i18n/index.d.ts +3 -1
- package/dist/i18n/zh.d.ts +2 -0
- package/dist/i18n/zh.js +2 -0
- package/dist/lib/dsh-client.d.ts +1 -1
- package/package.json +47 -51
- package/src/contract/protocol/bundle-install.ts +9 -1
- package/src/host/runtime/__tests__/dsh-compat.test.ts +23 -0
- package/src/host/runtime/dsh-compat.ts +18 -5
- package/src/i18n/en.ts +2 -0
- package/src/i18n/zh.ts +2 -0
- package/src/lib/dsh-client.ts +1 -2
- package/dist/components/Activity.css +0 -69
- package/dist/components/Activity.d.ts +0 -56
- package/dist/components/Activity.js +0 -47
- package/dist/components/ApprovalDetail.css +0 -3
- package/dist/components/ApprovalDetail.d.ts +0 -42
- package/dist/components/ApprovalDetail.js +0 -53
- package/dist/components/ApprovalPlan.css +0 -39
- package/dist/components/ApprovalPlan.d.ts +0 -27
- package/dist/components/ApprovalPlan.js +0 -19
- package/dist/components/Card.css +0 -19
- package/dist/components/Card.d.ts +0 -26
- package/dist/components/Card.js +0 -18
- package/dist/components/CardAnchor.d.ts +0 -21
- package/dist/components/CardAnchor.js +0 -19
- package/dist/components/CardAnchor.module.css +0 -3
- package/dist/components/CardBoundary.d.ts +0 -42
- package/dist/components/CardBoundary.js +0 -58
- package/dist/components/CardBoundary.module.css +0 -5
- package/dist/components/CardHead.css +0 -87
- package/dist/components/CardHead.d.ts +0 -30
- package/dist/components/CardHead.js +0 -27
- package/dist/components/ChoiceGroup.css +0 -182
- package/dist/components/ChoiceGroup.d.ts +0 -54
- package/dist/components/ChoiceGroup.js +0 -63
- package/dist/components/ConfirmBar.css +0 -26
- package/dist/components/ConfirmBar.d.ts +0 -36
- package/dist/components/ConfirmBar.js +0 -26
- package/dist/components/EmptyIllustration.d.ts +0 -12
- package/dist/components/EmptyIllustration.js +0 -32
- package/dist/components/Field.css +0 -20
- package/dist/components/Field.d.ts +0 -18
- package/dist/components/Field.js +0 -15
- package/dist/components/Form.css +0 -6
- package/dist/components/Form.d.ts +0 -22
- package/dist/components/Form.js +0 -60
- package/dist/components/FormActions.css +0 -13
- package/dist/components/FormActions.d.ts +0 -29
- package/dist/components/FormActions.js +0 -43
- package/dist/components/FormNodes.d.ts +0 -107
- package/dist/components/FormNodes.js +0 -165
- package/dist/components/FormRows.css +0 -107
- package/dist/components/FormRows.d.ts +0 -36
- package/dist/components/FormRows.js +0 -26
- package/dist/components/FormTypes.d.ts +0 -84
- package/dist/components/FormTypes.js +0 -1
- package/dist/components/Link.css +0 -22
- package/dist/components/Link.d.ts +0 -22
- package/dist/components/Link.js +0 -17
- package/dist/components/LongTaskRow.css +0 -171
- package/dist/components/LongTaskRow.d.ts +0 -94
- package/dist/components/LongTaskRow.js +0 -103
- package/dist/components/Note.css +0 -13
- package/dist/components/Note.d.ts +0 -20
- package/dist/components/Note.js +0 -14
- package/dist/components/ResourceStates.css +0 -114
- package/dist/components/ResourceStates.d.ts +0 -44
- package/dist/components/ResourceStates.js +0 -41
- package/dist/components/Rows.css +0 -42
- package/dist/components/Rows.d.ts +0 -28
- package/dist/components/Rows.js +0 -21
- package/dist/components/SaveBar.d.ts +0 -24
- package/dist/components/SaveBar.js +0 -25
- package/dist/components/SelectField.css +0 -182
- package/dist/components/SelectField.d.ts +0 -89
- package/dist/components/SelectField.js +0 -260
- package/dist/components/SelectFieldNodes.d.ts +0 -49
- package/dist/components/SelectFieldNodes.js +0 -43
- package/dist/components/SettingsSection.css +0 -25
- package/dist/components/SettingsSection.d.ts +0 -20
- package/dist/components/SettingsSection.js +0 -17
- package/dist/components/SetupShell.d.ts +0 -93
- package/dist/components/SetupShell.js +0 -64
- package/dist/components/SetupShell.module.css +0 -81
- package/dist/components/Spinner.css +0 -5
- package/dist/components/Spinner.d.ts +0 -15
- package/dist/components/Spinner.js +0 -13
- package/dist/components/Stack.css +0 -6
- package/dist/components/Stack.d.ts +0 -14
- package/dist/components/Stack.js +0 -10
- package/dist/components/StateBlock.css +0 -38
- package/dist/components/StateBlock.d.ts +0 -24
- package/dist/components/StateBlock.js +0 -22
- package/dist/components/TextField.css +0 -32
- package/dist/components/TextField.d.ts +0 -14
- package/dist/components/TextField.js +0 -10
- package/dist/components/board-module.d.ts +0 -307
- package/dist/components/board-module.js +0 -1
- package/dist/components/card-view-validate.d.ts +0 -5
- package/dist/components/card-view-validate.js +0 -256
- package/dist/components/icons.d.ts +0 -63
- package/dist/components/icons.js +0 -107
- package/dist/components/layout/icon-command.d.ts +0 -8
- package/dist/components/layout/icon-command.js +0 -21
- package/dist/contract/capture.d.ts +0 -16
- package/dist/contract/capture.js +0 -1
- package/dist/contract/diagnostics.d.ts +0 -34
- package/dist/contract/diagnostics.js +0 -124
- package/dist/contract/protocol/unit-manager.d.ts +0 -50
- package/dist/contract/protocol/unit-manager.js +0 -2
- package/dist/host/adapter-contract.d.ts +0 -3
- package/dist/host/adapter-contract.js +0 -95
- package/dist/host/adapter-set.d.ts +0 -27
- package/dist/host/adapter-set.js +0 -258
- package/dist/host/adapter-types.d.ts +0 -87
- package/dist/host/adapter-types.js +0 -23
- package/dist/host/adapters/platform.d.ts +0 -14
- package/dist/host/adapters/platform.js +0 -40
- package/dist/host/adapters.d.ts +0 -28
- package/dist/host/adapters.js +0 -9
- package/dist/host/auth-loss.d.ts +0 -33
- package/dist/host/auth-loss.js +0 -107
- package/dist/host/board-fact.d.ts +0 -8
- package/dist/host/board-fact.js +0 -16
- package/dist/host/boot-record.d.ts +0 -11
- package/dist/host/boot-record.js +0 -31
- package/dist/host/browser.d.ts +0 -3
- package/dist/host/browser.js +0 -3
- package/dist/host/bundle-manager.d.ts +0 -4
- package/dist/host/bundle-manager.js +0 -338
- package/dist/host/changelog.d.ts +0 -28
- package/dist/host/changelog.js +0 -201
- package/dist/host/cli-error.d.ts +0 -8
- package/dist/host/cli-error.js +0 -70
- package/dist/host/cli.d.ts +0 -4
- package/dist/host/cli.js +0 -9
- package/dist/host/config-sync.d.ts +0 -40
- package/dist/host/config-sync.js +0 -267
- package/dist/host/context-ref.d.ts +0 -13
- package/dist/host/context-ref.js +0 -41
- package/dist/host/data-error.d.ts +0 -15
- package/dist/host/data-error.js +0 -23
- package/dist/host/data-plan-check.d.ts +0 -10
- package/dist/host/data-plan-check.js +0 -315
- package/dist/host/data-plan.d.ts +0 -15
- package/dist/host/data-plan.js +0 -283
- package/dist/host/data-root.d.ts +0 -5
- package/dist/host/data-root.js +0 -23
- package/dist/host/diy-debug.d.ts +0 -80
- package/dist/host/diy-debug.js +0 -89
- package/dist/host/diy-preset.d.ts +0 -26
- package/dist/host/diy-preset.js +0 -115
- package/dist/host/diy-record.d.ts +0 -135
- package/dist/host/diy-record.js +0 -163
- package/dist/host/dsh-compat.d.ts +0 -27
- package/dist/host/dsh-compat.js +0 -75
- package/dist/host/dsh-plugins.d.ts +0 -5
- package/dist/host/dsh-plugins.js +0 -51
- package/dist/host/env-policy.d.ts +0 -82
- package/dist/host/env-policy.js +0 -181
- package/dist/host/extension.d.ts +0 -7
- package/dist/host/extension.js +0 -40
- package/dist/host/facts.d.ts +0 -31
- package/dist/host/facts.js +0 -58
- package/dist/host/fs-write.d.ts +0 -96
- package/dist/host/fs-write.js +0 -183
- package/dist/host/git.d.ts +0 -5
- package/dist/host/git.js +0 -1
- package/dist/host/host-actions.d.ts +0 -2
- package/dist/host/host-actions.js +0 -5
- package/dist/host/host-kit.d.ts +0 -37
- package/dist/host/host-kit.js +0 -27
- package/dist/host/http.d.ts +0 -47
- package/dist/host/http.js +0 -289
- package/dist/host/install-failure.d.ts +0 -50
- package/dist/host/install-failure.js +0 -184
- package/dist/host/installed-module.d.ts +0 -25
- package/dist/host/installed-module.js +0 -289
- package/dist/host/installed-sources.d.ts +0 -10
- package/dist/host/installed-sources.js +0 -63
- package/dist/host/lease.d.ts +0 -70
- package/dist/host/lease.js +0 -264
- package/dist/host/lib-capabilities.d.ts +0 -22
- package/dist/host/lib-capabilities.js +0 -37
- package/dist/host/lib-install.d.ts +0 -19
- package/dist/host/lib-install.js +0 -40
- package/dist/host/lib-runners.d.ts +0 -18
- package/dist/host/lib-runners.js +0 -46
- package/dist/host/local-declaration.d.ts +0 -7
- package/dist/host/local-declaration.js +0 -33
- package/dist/host/long-task.d.ts +0 -97
- package/dist/host/long-task.js +0 -297
- package/dist/host/market-index-claim.d.ts +0 -19
- package/dist/host/market-index-claim.js +0 -87
- package/dist/host/market-index-doc.d.ts +0 -12
- package/dist/host/market-index-doc.js +0 -1
- package/dist/host/market-index-parse.d.ts +0 -28
- package/dist/host/market-index-parse.js +0 -413
- package/dist/host/market-index.d.ts +0 -13
- package/dist/host/market-index.js +0 -105
- package/dist/host/module-root.d.ts +0 -1
- package/dist/host/module-root.js +0 -5
- package/dist/host/needs.d.ts +0 -4
- package/dist/host/needs.js +0 -2
- package/dist/host/npm-registry.d.ts +0 -10
- package/dist/host/npm-registry.js +0 -16
- package/dist/host/package-content.d.ts +0 -8
- package/dist/host/package-content.js +0 -90
- package/dist/host/package-kind.d.ts +0 -13
- package/dist/host/package-kind.js +0 -51
- package/dist/host/package-route.d.ts +0 -33
- package/dist/host/package-route.js +0 -68
- package/dist/host/panel-state.d.ts +0 -120
- package/dist/host/panel-state.js +0 -177
- package/dist/host/patch-blocks.d.ts +0 -13
- package/dist/host/patch-blocks.js +0 -52
- package/dist/host/patch.d.ts +0 -4
- package/dist/host/patch.js +0 -7
- package/dist/host/paths.d.ts +0 -12
- package/dist/host/paths.js +0 -20
- package/dist/host/payload.d.ts +0 -12
- package/dist/host/payload.js +0 -16
- package/dist/host/plan-results.d.ts +0 -5
- package/dist/host/plan-results.js +0 -71
- package/dist/host/plan-run.d.ts +0 -41
- package/dist/host/plan-run.js +0 -87
- package/dist/host/platform.d.ts +0 -14
- package/dist/host/platform.js +0 -40
- package/dist/host/plugin-ledger.d.ts +0 -32
- package/dist/host/plugin-ledger.js +0 -106
- package/dist/host/plugin.d.ts +0 -3
- package/dist/host/plugin.js +0 -38
- package/dist/host/port-types.d.ts +0 -233
- package/dist/host/port-types.js +0 -1
- package/dist/host/preflight.d.ts +0 -32
- package/dist/host/preflight.js +0 -1
- package/dist/host/process-alive.d.ts +0 -6
- package/dist/host/process-alive.js +0 -16
- package/dist/host/profile-bundles.d.ts +0 -20
- package/dist/host/profile-bundles.js +0 -48
- package/dist/host/profile-create.d.ts +0 -19
- package/dist/host/profile-create.js +0 -124
- package/dist/host/profile-port.d.ts +0 -4
- package/dist/host/profile-port.js +0 -4
- package/dist/host/profile-registries.d.ts +0 -10
- package/dist/host/profile-registries.js +0 -149
- package/dist/host/provision.d.ts +0 -32
- package/dist/host/provision.js +0 -105
- package/dist/host/read-json.d.ts +0 -1
- package/dist/host/read-json.js +0 -11
- package/dist/host/recipe-rules.d.ts +0 -5
- package/dist/host/recipe-rules.js +0 -412
- package/dist/host/recipe.d.ts +0 -14
- package/dist/host/recipe.js +0 -332
- package/dist/host/registry-declaration.d.ts +0 -21
- package/dist/host/registry-declaration.js +0 -42
- package/dist/host/reinstall-record.d.ts +0 -16
- package/dist/host/reinstall-record.js +0 -54
- package/dist/host/release-age.d.ts +0 -24
- package/dist/host/release-age.js +0 -92
- package/dist/host/release-packages.generated.d.ts +0 -1
- package/dist/host/release-packages.generated.js +0 -10
- package/dist/host/release-probe.d.ts +0 -37
- package/dist/host/release-probe.js +0 -156
- package/dist/host/runtime/browser-argv.d.ts +0 -1
- package/dist/host/runtime/browser-argv.js +0 -9
- package/dist/host/runtime/front-app.d.ts +0 -6
- package/dist/host/runtime/front-app.js +0 -70
- package/dist/host/shell-render.d.ts +0 -52
- package/dist/host/shell-render.js +0 -117
- package/dist/host/shell-text.d.ts +0 -30
- package/dist/host/shell-text.js +0 -40
- package/dist/host/shell.d.ts +0 -25
- package/dist/host/shell.js +0 -55
- package/dist/host/site.d.ts +0 -45
- package/dist/host/site.js +0 -182
- package/dist/host/spec.d.ts +0 -8
- package/dist/host/spec.js +0 -24
- package/dist/host/submit-confirm.d.ts +0 -19
- package/dist/host/submit-confirm.js +0 -45
- package/dist/host/supply-index.d.ts +0 -38
- package/dist/host/supply-index.js +0 -209
- package/dist/host/supply-port.d.ts +0 -5
- package/dist/host/supply-port.js +0 -50
- package/dist/host/time.d.ts +0 -22
- package/dist/host/time.js +0 -33
- package/dist/host/tokens.d.ts +0 -26
- package/dist/host/tokens.js +0 -154
- package/dist/host/tool-approval.d.ts +0 -86
- package/dist/host/tool-approval.js +0 -118
- package/dist/host/tool-kit.d.ts +0 -8
- package/dist/host/tool-kit.js +0 -22
- package/dist/host/toolbox-port.d.ts +0 -16
- package/dist/host/toolbox-port.js +0 -1
- package/dist/host/unit-config.d.ts +0 -34
- package/dist/host/unit-config.js +0 -28
- package/dist/host/unit-data.d.ts +0 -3
- package/dist/host/unit-data.js +0 -127
- package/dist/host/unit-face.d.ts +0 -95
- package/dist/host/unit-face.js +0 -1
- package/dist/host/unit-plugin.d.ts +0 -24
- package/dist/host/unit-plugin.js +0 -25
- package/dist/host/update-journal-manifest.d.ts +0 -19
- package/dist/host/update-journal-manifest.js +0 -134
- package/dist/host/update-journal-types.d.ts +0 -33
- package/dist/host/update-journal-types.js +0 -2
- package/dist/host/update-journal.d.ts +0 -43
- package/dist/host/update-journal.js +0 -409
- package/dist/host/value-handoff.d.ts +0 -16
- package/dist/host/value-handoff.js +0 -22
- package/dist/host/version-range.d.ts +0 -2
- package/dist/host/version-range.js +0 -13
- package/dist/host/version.d.ts +0 -4
- package/dist/host/version.js +0 -32
- package/dist/host/workspace-store.d.ts +0 -19
- package/dist/host/workspace-store.js +0 -133
- package/dist/host/write-result.d.ts +0 -1
- package/dist/host/write-result.js +0 -18
package/dist/host/preflight.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
export type PreflightStepId = 'toolchain' | 'cli' | 'bridge' | 'runtime' | 'diy' | 'warm';
|
|
2
|
-
export type PreflightStepStatus = 'pending' | 'running' | 'ok' | 'warn' | 'failed';
|
|
3
|
-
export type PreflightFailure = 'permission' | 'network' | 'missing' | 'host' | 'unknown';
|
|
4
|
-
export type PreflightGuidance = 'install' | 'path' | 'shell' | 'host';
|
|
5
|
-
export type PreflightBridgeIssue = string;
|
|
6
|
-
export interface PreflightStep {
|
|
7
|
-
readonly id: PreflightStepId;
|
|
8
|
-
readonly label?: string;
|
|
9
|
-
readonly status: PreflightStepStatus;
|
|
10
|
-
readonly detail?: string;
|
|
11
|
-
readonly action?: string;
|
|
12
|
-
readonly command?: string;
|
|
13
|
-
readonly log?: readonly string[];
|
|
14
|
-
}
|
|
15
|
-
export interface PreflightDiyGap {
|
|
16
|
-
readonly rows: readonly string[];
|
|
17
|
-
readonly detail: string;
|
|
18
|
-
readonly command: string;
|
|
19
|
-
}
|
|
20
|
-
export interface PreflightSnapshot {
|
|
21
|
-
readonly phase: 'idle' | 'checking' | 'installing' | 'ready' | 'failed';
|
|
22
|
-
readonly steps: readonly PreflightStep[];
|
|
23
|
-
readonly at: number;
|
|
24
|
-
readonly error?: string;
|
|
25
|
-
readonly failure?: PreflightFailure;
|
|
26
|
-
readonly guidance?: PreflightGuidance;
|
|
27
|
-
readonly bridgeIssues?: readonly PreflightBridgeIssue[];
|
|
28
|
-
readonly diyGap?: PreflightDiyGap;
|
|
29
|
-
readonly canWakeBrowser?: boolean;
|
|
30
|
-
readonly extensionDir?: string;
|
|
31
|
-
readonly log?: readonly string[];
|
|
32
|
-
}
|
package/dist/host/preflight.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 进程号是否还活着。
|
|
3
|
-
* @param pid 进程号;非正整数一律视为不在。
|
|
4
|
-
* @returns 存活为 `true`。权限不足(EPERM)说明进程存在,算活着。
|
|
5
|
-
*/
|
|
6
|
-
export function pidAlive(pid) {
|
|
7
|
-
if (typeof pid !== 'number' || !Number.isInteger(pid) || pid <= 0)
|
|
8
|
-
return false;
|
|
9
|
-
try {
|
|
10
|
-
process.kill(pid, 0);
|
|
11
|
-
return true;
|
|
12
|
-
}
|
|
13
|
-
catch (error) {
|
|
14
|
-
return error.code === 'EPERM';
|
|
15
|
-
}
|
|
16
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export declare const WORKBENCH_BUNDLE = "@dsh-workbench/core";
|
|
2
|
-
export type ProfileBundleRefusal = 'no-manifest' | 'broken-manifest' | 'dependency-missing';
|
|
3
|
-
export interface ProfileBundleCheck {
|
|
4
|
-
readonly path: string;
|
|
5
|
-
readonly bundle: string;
|
|
6
|
-
readonly bundles: readonly string[];
|
|
7
|
-
readonly selected: boolean;
|
|
8
|
-
readonly repaired: boolean;
|
|
9
|
-
readonly refusal?: ProfileBundleRefusal | undefined;
|
|
10
|
-
}
|
|
11
|
-
export declare function profileBundlesOf(profileDir: string): readonly string[];
|
|
12
|
-
/**
|
|
13
|
-
* 核对 `dsh.profile.bundles` 里有没有这一项;缺了按 `seed-profile.sh ensure-selected` 的老规矩补回去
|
|
14
|
-
* (追加到末尾,且**依赖必须先在清单里** —— 没装的包塞进 bundles 只会让 profile 组不起来)。
|
|
15
|
-
* 读不了清单、或依赖不在时一个字节都不写,把原因交给调用点说人话。
|
|
16
|
-
* @param profileDir - profile 目录(清单在它下面的 `package.json`)。
|
|
17
|
-
* @param bundle - 要确保选中的组合包名,默认工作台自己。
|
|
18
|
-
* @returns 核对结果:改没改、现在有哪些、以及拒绝的原因。
|
|
19
|
-
*/
|
|
20
|
-
export declare function ensureProfileBundle(profileDir: string, bundle?: string): ProfileBundleCheck;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { existsSync } from 'node:fs';
|
|
2
|
-
import { join } from 'node:path';
|
|
3
|
-
import { writeJsonFile } from './fs-write.js';
|
|
4
|
-
import { profileManifestOf } from './installed-module.js';
|
|
5
|
-
export const WORKBENCH_BUNDLE = '@dsh-workbench/core';
|
|
6
|
-
function recordOf(value) {
|
|
7
|
-
return typeof value === 'object' && value !== null ? value : {};
|
|
8
|
-
}
|
|
9
|
-
function stringsOf(value) {
|
|
10
|
-
return Array.isArray(value) ? value.filter((item) => typeof item === 'string') : [];
|
|
11
|
-
}
|
|
12
|
-
export function profileBundlesOf(profileDir) {
|
|
13
|
-
const manifest = profileManifestOf(profileDir);
|
|
14
|
-
return stringsOf(recordOf(recordOf(manifest?.dsh).profile).bundles);
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* 核对 `dsh.profile.bundles` 里有没有这一项;缺了按 `seed-profile.sh ensure-selected` 的老规矩补回去
|
|
18
|
-
* (追加到末尾,且**依赖必须先在清单里** —— 没装的包塞进 bundles 只会让 profile 组不起来)。
|
|
19
|
-
* 读不了清单、或依赖不在时一个字节都不写,把原因交给调用点说人话。
|
|
20
|
-
* @param profileDir - profile 目录(清单在它下面的 `package.json`)。
|
|
21
|
-
* @param bundle - 要确保选中的组合包名,默认工作台自己。
|
|
22
|
-
* @returns 核对结果:改没改、现在有哪些、以及拒绝的原因。
|
|
23
|
-
*/
|
|
24
|
-
export function ensureProfileBundle(profileDir, bundle = WORKBENCH_BUNDLE) {
|
|
25
|
-
const path = join(profileDir, 'package.json');
|
|
26
|
-
const manifest = profileManifestOf(profileDir);
|
|
27
|
-
if (manifest === undefined || Array.isArray(manifest)) {
|
|
28
|
-
return {
|
|
29
|
-
path,
|
|
30
|
-
bundle,
|
|
31
|
-
bundles: [],
|
|
32
|
-
selected: false,
|
|
33
|
-
repaired: false,
|
|
34
|
-
refusal: existsSync(path) ? 'broken-manifest' : 'no-manifest',
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
const dsh = recordOf(manifest.dsh);
|
|
38
|
-
const profile = recordOf(dsh.profile);
|
|
39
|
-
const bundles = stringsOf(profile.bundles);
|
|
40
|
-
if (bundles.includes(bundle))
|
|
41
|
-
return { path, bundle, bundles, selected: true, repaired: false };
|
|
42
|
-
if (typeof recordOf(manifest.dependencies)[bundle] !== 'string') {
|
|
43
|
-
return { path, bundle, bundles, selected: false, repaired: false, refusal: 'dependency-missing' };
|
|
44
|
-
}
|
|
45
|
-
const after = [...bundles, bundle];
|
|
46
|
-
writeJsonFile(path, { ...manifest, dsh: { ...dsh, profile: { ...profile, bundles: after } } });
|
|
47
|
-
return { path, bundle, bundles: after, selected: true, repaired: true };
|
|
48
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { PostResource, RouteHandler } from './http.js';
|
|
2
|
-
import type { ProfileCreateApplied, ProfileCreateSnapshot } from '../contract/protocol/profile-create.js';
|
|
3
|
-
export interface ProfileCreateDeps {
|
|
4
|
-
readonly home: string;
|
|
5
|
-
readonly self: string;
|
|
6
|
-
readonly packageRoot: string;
|
|
7
|
-
readonly platform?: NodeJS.Platform | undefined;
|
|
8
|
-
readonly runSetup?: ((env: Readonly<Record<string, string>>) => Promise<{
|
|
9
|
-
ok: boolean;
|
|
10
|
-
log: string;
|
|
11
|
-
}>) | undefined;
|
|
12
|
-
}
|
|
13
|
-
export declare function profileCreateSnapshot(deps: ProfileCreateDeps): ProfileCreateSnapshot;
|
|
14
|
-
export declare function profileCreateHandler(deps: ProfileCreateDeps): RouteHandler;
|
|
15
|
-
export declare function profileCreateApply(deps: ProfileCreateDeps, payload: unknown): Promise<ProfileCreateApplied | {
|
|
16
|
-
ok: false;
|
|
17
|
-
text: string;
|
|
18
|
-
}>;
|
|
19
|
-
export declare function profileCreateAction(deps: ProfileCreateDeps): PostResource;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync, readdirSync, rmSync } from 'node:fs';
|
|
2
|
-
import { join, resolve, sep } from 'node:path';
|
|
3
|
-
import { quoteShellArgFor, shellKindOf } from './shell-text.js';
|
|
4
|
-
import { PROFILE_CREATE_RESOURCE } from '../contract/protocol/profile-create.js';
|
|
5
|
-
const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
|
|
6
|
-
const BUNDLE = '@dsh-workbench/core';
|
|
7
|
-
function textOf(value) {
|
|
8
|
-
return typeof value === 'string' ? value : '';
|
|
9
|
-
}
|
|
10
|
-
function profileNames(profilesDir) {
|
|
11
|
-
try {
|
|
12
|
-
return readdirSync(profilesDir, { withFileTypes: true })
|
|
13
|
-
.filter((entry) => entry.isDirectory() || entry.isSymbolicLink())
|
|
14
|
-
.map((entry) => entry.name)
|
|
15
|
-
.filter((name) => existsSync(join(profilesDir, name, 'package.json')))
|
|
16
|
-
.sort((a, b) => a.localeCompare(b));
|
|
17
|
-
}
|
|
18
|
-
catch {
|
|
19
|
-
return [];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
export function profileCreateSnapshot(deps) {
|
|
23
|
-
const profiles = profileNames(join(deps.home, 'profiles')).map((name) => ({
|
|
24
|
-
name,
|
|
25
|
-
current: name === deps.self,
|
|
26
|
-
readable: true,
|
|
27
|
-
}));
|
|
28
|
-
return { current: deps.self, profiles };
|
|
29
|
-
}
|
|
30
|
-
export function profileCreateHandler(deps) {
|
|
31
|
-
return () => ({ ok: true, ...profileCreateSnapshot(deps) });
|
|
32
|
-
}
|
|
33
|
-
function inside(base, path) {
|
|
34
|
-
const root = resolve(base);
|
|
35
|
-
const target = resolve(path);
|
|
36
|
-
return target === root ? false : target.startsWith(`${root}${sep}`);
|
|
37
|
-
}
|
|
38
|
-
function startCommandOf(deps, profile) {
|
|
39
|
-
if (shellKindOf(deps.platform) === 'pwsh')
|
|
40
|
-
return undefined;
|
|
41
|
-
const bin = join(deps.packageRoot, 'bin', 'dsh-workbench');
|
|
42
|
-
return `${quoteShellArgFor(bin, deps.platform)} --profile ${quoteShellArgFor(profile, deps.platform)}`;
|
|
43
|
-
}
|
|
44
|
-
export async function profileCreateApply(deps, payload) {
|
|
45
|
-
const body = typeof payload === 'object' && payload !== null ? payload : {};
|
|
46
|
-
const profile = textOf(body['profile']).trim();
|
|
47
|
-
const source = textOf(body['source']).trim();
|
|
48
|
-
const copy = typeof body['copy'] === 'object' && body['copy'] !== null ? body['copy'] : {};
|
|
49
|
-
const flags = {
|
|
50
|
-
settings: copy['settings'] === true,
|
|
51
|
-
};
|
|
52
|
-
if (!PROFILE_NAME.test(profile))
|
|
53
|
-
return { ok: false, text: '新工作台的名字不合法:只用字母、数字、点、下划线或短横线' };
|
|
54
|
-
if (source === '')
|
|
55
|
-
return { ok: false, text: '先选一个来源 profile' };
|
|
56
|
-
if (source === profile)
|
|
57
|
-
return { ok: false, text: '来源不能是新工作台自己' };
|
|
58
|
-
const profilesDir = join(deps.home, 'profiles');
|
|
59
|
-
if (!profileNames(profilesDir).includes(source))
|
|
60
|
-
return { ok: false, text: `没有这个 profile:${source}` };
|
|
61
|
-
if (existsSync(join(profilesDir, profile)))
|
|
62
|
-
return { ok: false, text: `已经有一个叫 ${profile} 的 profile` };
|
|
63
|
-
const targetHome = join(deps.home, profile);
|
|
64
|
-
if (existsSync(targetHome))
|
|
65
|
-
return { ok: false, text: `运行时目录已经存在:${targetHome}` };
|
|
66
|
-
const env = {
|
|
67
|
-
DSH_HOME: deps.home,
|
|
68
|
-
DSH_WORKBENCH_HOME: targetHome,
|
|
69
|
-
WORKBENCH_PROFILE: profile,
|
|
70
|
-
WORKBENCH_SOURCE_PROFILE: source,
|
|
71
|
-
WB_CLONE: '1',
|
|
72
|
-
WB_COPY_SETTINGS: flags.settings ? '1' : '0',
|
|
73
|
-
};
|
|
74
|
-
const setup = deps.runSetup;
|
|
75
|
-
if (setup === undefined) {
|
|
76
|
-
return { ok: false, text: '这台机器上没有装工作台的脚本入口,建不了新的工作台。' };
|
|
77
|
-
}
|
|
78
|
-
const cleanup = () => {
|
|
79
|
-
try {
|
|
80
|
-
if (inside(profilesDir, join(profilesDir, profile)))
|
|
81
|
-
rmSync(join(profilesDir, profile), { recursive: true, force: true });
|
|
82
|
-
if (inside(deps.home, targetHome))
|
|
83
|
-
rmSync(targetHome, { recursive: true, force: true });
|
|
84
|
-
}
|
|
85
|
-
catch {
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
const result = await setup(env);
|
|
90
|
-
if (!result.ok) {
|
|
91
|
-
cleanup();
|
|
92
|
-
return { ok: false, text: `创建失败:${result.log.trim().slice(-1200) || 'setup 没给出原因'}` };
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const manifest = JSON.parse(readFileSync(join(profilesDir, profile, 'package.json'), 'utf8'));
|
|
96
|
-
const bundles = manifest.dsh?.profile?.bundles;
|
|
97
|
-
if (!Array.isArray(bundles) || !bundles.includes(BUNDLE)) {
|
|
98
|
-
cleanup();
|
|
99
|
-
return { ok: false, text: 'profile 建好了,但工作台 bundle 没被选中;先跑一次 setup 修好它' };
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
catch (error) {
|
|
103
|
-
cleanup();
|
|
104
|
-
return { ok: false, text: `profile 建好了,但读不了清单:${error instanceof Error ? error.message : String(error)}` };
|
|
105
|
-
}
|
|
106
|
-
const copied = Object.entries(flags)
|
|
107
|
-
.filter(([, on]) => on)
|
|
108
|
-
.map(([name]) => name);
|
|
109
|
-
const command = startCommandOf(deps, profile);
|
|
110
|
-
return {
|
|
111
|
-
ok: true,
|
|
112
|
-
profile,
|
|
113
|
-
source,
|
|
114
|
-
home: targetHome,
|
|
115
|
-
...(command === undefined ? {} : { command }),
|
|
116
|
-
copied,
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
export function profileCreateAction(deps) {
|
|
120
|
-
return {
|
|
121
|
-
resource: PROFILE_CREATE_RESOURCE,
|
|
122
|
-
handle: (payload) => profileCreateApply(deps, payload),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { RegistryEntry, RegistryNotebook } from './adapter-types.js';
|
|
2
|
-
export declare const REGISTRY_MARKER = "# dsh-workbench \u5199\u7684\uFF1A\u8FD9\u4E00\u884C\u7684\u5305\u53EA\u5728\u8FD9\u4E2A\u6E90\u4E0A\uFF08dsh \u5378\u8F7D\u6CA1\u6709\u6E90\u53C2\u6570\uFF0Cpnpm \u5F97\u95EE\u5F97\u5230\uFF09";
|
|
3
|
-
export declare function sourcesFromLockfile(text: string): readonly RegistryEntry[];
|
|
4
|
-
export interface RegistryConfigMerge {
|
|
5
|
-
readonly text: string;
|
|
6
|
-
readonly added: readonly string[];
|
|
7
|
-
}
|
|
8
|
-
export declare function mergeRegistryConfig(text: string, entries: readonly RegistryEntry[]): RegistryConfigMerge;
|
|
9
|
-
export declare function replaceScopeRegistry(text: string, scope: string, registry: string): string;
|
|
10
|
-
export declare function createRegistryNotebook(dir: string | null): RegistryNotebook;
|
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { normalizeRegistry, sameRegistry, scopeOf } from './adapter-types.js';
|
|
2
|
-
import fs from 'node:fs';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
import { writeTextFile } from './fs-write.js';
|
|
5
|
-
export const REGISTRY_MARKER = '# dsh-workbench 写的:这一行的包只在这个源上(dsh 卸载没有源参数,pnpm 得问得到)';
|
|
6
|
-
function registryRootOf(name, tarball) {
|
|
7
|
-
const at = tarball.indexOf(`/${name}/-/`);
|
|
8
|
-
if (at > 0)
|
|
9
|
-
return normalizeRegistry(tarball.slice(0, at));
|
|
10
|
-
try {
|
|
11
|
-
return normalizeRegistry(new URL(tarball).origin);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
const PACKAGE_KEY = /^ {2}'?(\S+)'?:\s*$/;
|
|
18
|
-
const PACKAGE_NAME = /^(?:@[^/\s]+\/)?[^/\s@]+$/;
|
|
19
|
-
const TARBALL = /tarball:\s*(\S+?)\}?\s*$/;
|
|
20
|
-
export function sourcesFromLockfile(text) {
|
|
21
|
-
const found = new Map();
|
|
22
|
-
let name = null;
|
|
23
|
-
for (const line of text.split('\n')) {
|
|
24
|
-
const key = PACKAGE_KEY.exec(line);
|
|
25
|
-
if (key !== null) {
|
|
26
|
-
const raw = key[1] ?? '';
|
|
27
|
-
const at = raw.lastIndexOf('@');
|
|
28
|
-
const candidate = at > 0 ? raw.slice(0, at) : '';
|
|
29
|
-
name = PACKAGE_NAME.test(candidate) ? candidate : null;
|
|
30
|
-
continue;
|
|
31
|
-
}
|
|
32
|
-
if (name === null)
|
|
33
|
-
continue;
|
|
34
|
-
const tarball = TARBALL.exec(line);
|
|
35
|
-
if (tarball === null)
|
|
36
|
-
continue;
|
|
37
|
-
const scope = scopeOf(name);
|
|
38
|
-
const root = registryRootOf(name, tarball[1] ?? '');
|
|
39
|
-
name = null;
|
|
40
|
-
if (scope === null || root === null)
|
|
41
|
-
continue;
|
|
42
|
-
const seen = found.get(scope);
|
|
43
|
-
if (seen === undefined)
|
|
44
|
-
found.set(scope, root);
|
|
45
|
-
else if (!sameRegistry(seen, root))
|
|
46
|
-
found.set(scope, null);
|
|
47
|
-
}
|
|
48
|
-
return [...found.entries()]
|
|
49
|
-
.filter((entry) => entry[1] !== null)
|
|
50
|
-
.map(([scope, registry]) => ({ scope, registry }));
|
|
51
|
-
}
|
|
52
|
-
export function mergeRegistryConfig(text, entries) {
|
|
53
|
-
const lines = text.split('\n');
|
|
54
|
-
const present = (key) => lines.some((line) => line.trim().startsWith(`${key}=`));
|
|
55
|
-
const appended = [];
|
|
56
|
-
const added = [];
|
|
57
|
-
for (const entry of entries) {
|
|
58
|
-
const key = `${entry.scope}:registry`;
|
|
59
|
-
if (entry.registry.trim() === '' || present(key))
|
|
60
|
-
continue;
|
|
61
|
-
lines.push(`${key}=${normalizeRegistry(entry.registry)}`);
|
|
62
|
-
appended.push(`${key}=${normalizeRegistry(entry.registry)}`);
|
|
63
|
-
added.push(key);
|
|
64
|
-
}
|
|
65
|
-
if (appended.length === 0)
|
|
66
|
-
return { text, added: [] };
|
|
67
|
-
const base = text === '' ? '' : text.endsWith('\n') ? text : `${text}\n`;
|
|
68
|
-
const marker = base.includes(REGISTRY_MARKER) ? '' : `${REGISTRY_MARKER}\n`;
|
|
69
|
-
return { text: `${base}${marker}${appended.join('\n')}\n`, added };
|
|
70
|
-
}
|
|
71
|
-
export function replaceScopeRegistry(text, scope, registry) {
|
|
72
|
-
const key = `${scope}:registry`;
|
|
73
|
-
const value = normalizeRegistry(registry);
|
|
74
|
-
let found = false;
|
|
75
|
-
const lines = text.split('\n').map((line) => {
|
|
76
|
-
if (!line.trim().startsWith(`${key}=`))
|
|
77
|
-
return line;
|
|
78
|
-
found = true;
|
|
79
|
-
return `${key}=${value}`;
|
|
80
|
-
});
|
|
81
|
-
if (found)
|
|
82
|
-
return lines.join('\n');
|
|
83
|
-
const base = text === '' ? '' : text.endsWith('\n') ? text : `${text}\n`;
|
|
84
|
-
return `${base}${key}=${value}\n`;
|
|
85
|
-
}
|
|
86
|
-
function readNpmrc(file) {
|
|
87
|
-
try {
|
|
88
|
-
return fs.readFileSync(file, 'utf8');
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
return '';
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
function writeNpmrc(file, text) {
|
|
95
|
-
writeTextFile(file, text, { mode: 0o600 });
|
|
96
|
-
}
|
|
97
|
-
export function createRegistryNotebook(dir) {
|
|
98
|
-
return {
|
|
99
|
-
sources() {
|
|
100
|
-
if (dir === null)
|
|
101
|
-
return [];
|
|
102
|
-
try {
|
|
103
|
-
return sourcesFromLockfile(fs.readFileSync(path.join(dir, 'pnpm-lock.yaml'), 'utf8'));
|
|
104
|
-
}
|
|
105
|
-
catch {
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
remember(entries) {
|
|
110
|
-
if (dir === null || entries.length === 0)
|
|
111
|
-
return [];
|
|
112
|
-
const file = path.join(dir, '.npmrc');
|
|
113
|
-
const merged = mergeRegistryConfig(readNpmrc(file), entries);
|
|
114
|
-
if (merged.added.length === 0)
|
|
115
|
-
return [];
|
|
116
|
-
writeNpmrc(file, merged.text);
|
|
117
|
-
return merged.added;
|
|
118
|
-
},
|
|
119
|
-
swapScope(scope, registry) {
|
|
120
|
-
if (dir === null || scope.trim() === '' || registry.trim() === '')
|
|
121
|
-
return () => { };
|
|
122
|
-
const file = path.join(dir, '.npmrc');
|
|
123
|
-
const key = `${scope.trim()}:registry`;
|
|
124
|
-
const value = normalizeRegistry(registry);
|
|
125
|
-
const before = readNpmrc(file);
|
|
126
|
-
const previous = before.split('\n').find((line) => line.trim().startsWith(`${key}=`));
|
|
127
|
-
const after = replaceScopeRegistry(before, scope.trim(), registry);
|
|
128
|
-
if (after === before)
|
|
129
|
-
return () => { };
|
|
130
|
-
writeNpmrc(file, after);
|
|
131
|
-
return () => {
|
|
132
|
-
const now = readNpmrc(file);
|
|
133
|
-
if (now === after) {
|
|
134
|
-
if (before === '')
|
|
135
|
-
fs.rmSync(file, { force: true });
|
|
136
|
-
else
|
|
137
|
-
writeNpmrc(file, before);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
if (!now.includes(`${key}=${value}`))
|
|
141
|
-
return;
|
|
142
|
-
const restored = previous === undefined
|
|
143
|
-
? now.split('\n').filter((line) => !line.trim().startsWith(`${key}=`)).join('\n')
|
|
144
|
-
: now.replace(`${key}=${value}`, previous);
|
|
145
|
-
writeNpmrc(file, restored);
|
|
146
|
-
};
|
|
147
|
-
},
|
|
148
|
-
};
|
|
149
|
-
}
|
package/dist/host/provision.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import type { ProvisionAction } from '../contract/workbench-contract.js';
|
|
2
|
-
export type { ProvisionAction };
|
|
3
|
-
export declare const PROVISION_ACTIONS: readonly ["install", "update", "uninstall", "install-bundle", "install-version", "update-bundle", "remove-bundle", "cancel-install", "update-dependency", "update-plugin", "uninstall-plugin", "update-workbench", "migrate-workbench", "dismiss-followup"];
|
|
4
|
-
export declare const DEPENDENCY_ACTIONS: readonly ["update-dependency"];
|
|
5
|
-
export declare function isDependencyAction(action: ProvisionAction): action is (typeof DEPENDENCY_ACTIONS)[number];
|
|
6
|
-
export type ProvisionTarget = 'unit' | 'id' | 'spec' | 'name' | 'requestId';
|
|
7
|
-
export declare function provisionTargetOf(action: ProvisionAction): ProvisionTarget;
|
|
8
|
-
export interface ProvisionRequest {
|
|
9
|
-
readonly action: ProvisionAction;
|
|
10
|
-
readonly unit?: string;
|
|
11
|
-
readonly id?: string;
|
|
12
|
-
readonly spec?: string;
|
|
13
|
-
readonly name?: string;
|
|
14
|
-
readonly requestId?: string;
|
|
15
|
-
readonly version?: string;
|
|
16
|
-
readonly registry?: string;
|
|
17
|
-
readonly approvedBuilds?: readonly string[];
|
|
18
|
-
}
|
|
19
|
-
export interface ProvisionHandler {
|
|
20
|
-
handle(request: ProvisionRequest): Promise<unknown> | unknown;
|
|
21
|
-
affectedUnits?(request: ProvisionRequest): readonly string[];
|
|
22
|
-
}
|
|
23
|
-
export interface ProvisionRejected {
|
|
24
|
-
readonly ok: false;
|
|
25
|
-
readonly code: string;
|
|
26
|
-
readonly message: string;
|
|
27
|
-
}
|
|
28
|
-
export type ProvisionParsed = {
|
|
29
|
-
readonly ok: true;
|
|
30
|
-
readonly request: ProvisionRequest;
|
|
31
|
-
} | ProvisionRejected;
|
|
32
|
-
export declare function parseProvisionBody(body: unknown): ProvisionParsed;
|
package/dist/host/provision.js
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
export const PROVISION_ACTIONS = [
|
|
2
|
-
'install',
|
|
3
|
-
'update',
|
|
4
|
-
'uninstall',
|
|
5
|
-
'install-bundle',
|
|
6
|
-
'install-version',
|
|
7
|
-
'update-bundle',
|
|
8
|
-
'remove-bundle',
|
|
9
|
-
'cancel-install',
|
|
10
|
-
'update-dependency',
|
|
11
|
-
'update-plugin',
|
|
12
|
-
'uninstall-plugin',
|
|
13
|
-
'update-workbench',
|
|
14
|
-
'migrate-workbench',
|
|
15
|
-
'dismiss-followup',
|
|
16
|
-
];
|
|
17
|
-
export const DEPENDENCY_ACTIONS = ['update-dependency'];
|
|
18
|
-
export function isDependencyAction(action) {
|
|
19
|
-
return DEPENDENCY_ACTIONS.includes(action);
|
|
20
|
-
}
|
|
21
|
-
const ALL_ACTIONS_COVERED = true;
|
|
22
|
-
void ALL_ACTIONS_COVERED;
|
|
23
|
-
export function provisionTargetOf(action) {
|
|
24
|
-
if (action === 'update-dependency')
|
|
25
|
-
return 'id';
|
|
26
|
-
if (action === 'install-bundle' || action === 'install-version')
|
|
27
|
-
return 'spec';
|
|
28
|
-
if (action === 'remove-bundle')
|
|
29
|
-
return 'name';
|
|
30
|
-
if (action === 'update-plugin' || action === 'uninstall-plugin')
|
|
31
|
-
return 'name';
|
|
32
|
-
if (action === 'update-workbench' || action === 'migrate-workbench')
|
|
33
|
-
return 'name';
|
|
34
|
-
if (action === 'dismiss-followup')
|
|
35
|
-
return 'id';
|
|
36
|
-
if (action === 'cancel-install')
|
|
37
|
-
return 'requestId';
|
|
38
|
-
return 'unit';
|
|
39
|
-
}
|
|
40
|
-
const TARGET_CODE = {
|
|
41
|
-
unit: 'workbench/no-unit',
|
|
42
|
-
id: 'workbench/no-id',
|
|
43
|
-
spec: 'workbench/no-spec',
|
|
44
|
-
name: 'workbench/no-name',
|
|
45
|
-
requestId: 'workbench/no-request-id',
|
|
46
|
-
};
|
|
47
|
-
function asRecord(value) {
|
|
48
|
-
return typeof value === 'object' && value !== null ? value : {};
|
|
49
|
-
}
|
|
50
|
-
function stringsOf(value) {
|
|
51
|
-
if (!Array.isArray(value))
|
|
52
|
-
return undefined;
|
|
53
|
-
const items = value.filter((item) => typeof item === 'string' && item.trim() !== '');
|
|
54
|
-
return items.length === 0 ? undefined : items;
|
|
55
|
-
}
|
|
56
|
-
function requestOf(action, value) {
|
|
57
|
-
if (action === 'update-dependency')
|
|
58
|
-
return { action, id: value };
|
|
59
|
-
if (action === 'install-bundle' || action === 'install-version')
|
|
60
|
-
return { action, spec: value };
|
|
61
|
-
if (action === 'remove-bundle')
|
|
62
|
-
return { action, name: value };
|
|
63
|
-
if (action === 'update-plugin' || action === 'uninstall-plugin')
|
|
64
|
-
return { action, name: value };
|
|
65
|
-
if (action === 'update-workbench' || action === 'migrate-workbench') {
|
|
66
|
-
return { action, name: value };
|
|
67
|
-
}
|
|
68
|
-
if (action === 'dismiss-followup')
|
|
69
|
-
return { action, id: value };
|
|
70
|
-
if (action === 'cancel-install')
|
|
71
|
-
return { action, requestId: value };
|
|
72
|
-
return { action, unit: value };
|
|
73
|
-
}
|
|
74
|
-
export function parseProvisionBody(body) {
|
|
75
|
-
const raw = asRecord(body);
|
|
76
|
-
const action = raw.action;
|
|
77
|
-
if (typeof action !== 'string' || !PROVISION_ACTIONS.includes(action)) {
|
|
78
|
-
return {
|
|
79
|
-
ok: false,
|
|
80
|
-
code: 'workbench/bad-action',
|
|
81
|
-
message: `不认识的 action:${String(action)}(可用:${PROVISION_ACTIONS.join(' / ')})`,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
const wanted = action;
|
|
85
|
-
const target = provisionTargetOf(wanted);
|
|
86
|
-
const value = raw[target];
|
|
87
|
-
if (typeof value !== 'string' || value.trim() === '') {
|
|
88
|
-
return { ok: false, code: TARGET_CODE[target], message: `缺少 ${target}` };
|
|
89
|
-
}
|
|
90
|
-
if (wanted !== 'install-bundle' && wanted !== 'install-version') {
|
|
91
|
-
return { ok: true, request: requestOf(wanted, value.trim()) };
|
|
92
|
-
}
|
|
93
|
-
const registry = typeof raw.registry === 'string' && raw.registry.trim() !== '' ? raw.registry.trim() : undefined;
|
|
94
|
-
const approvedBuilds = stringsOf(raw.approvedBuilds);
|
|
95
|
-
const requestId = typeof raw.requestId === 'string' && raw.requestId.trim() !== '' ? raw.requestId.trim() : undefined;
|
|
96
|
-
return {
|
|
97
|
-
ok: true,
|
|
98
|
-
request: {
|
|
99
|
-
...requestOf(wanted, value.trim()),
|
|
100
|
-
...(registry === undefined ? {} : { registry }),
|
|
101
|
-
...(approvedBuilds === undefined ? {} : { approvedBuilds }),
|
|
102
|
-
...(requestId === undefined ? {} : { requestId }),
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
package/dist/host/read-json.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function readJsonObject(file: string): Readonly<Record<string, unknown>> | undefined;
|
package/dist/host/read-json.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from 'node:fs';
|
|
2
|
-
export function readJsonObject(file) {
|
|
3
|
-
let raw;
|
|
4
|
-
try {
|
|
5
|
-
raw = JSON.parse(readFileSync(file, 'utf8'));
|
|
6
|
-
}
|
|
7
|
-
catch {
|
|
8
|
-
return undefined;
|
|
9
|
-
}
|
|
10
|
-
return typeof raw === 'object' && raw !== null ? raw : undefined;
|
|
11
|
-
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { CallOverrides } from '../contract/data.js';
|
|
2
|
-
export declare const DEFAULT_RECIPE_MAX_BYTES: number;
|
|
3
|
-
export declare const MAX_RECIPE_CALLS = 8;
|
|
4
|
-
export declare function recipeProblemOf(recipe: unknown, overrides?: CallOverrides): string | undefined;
|
|
5
|
-
export declare function callsProblemOf(recipe: unknown, calls: unknown): string | undefined;
|