@dsh-workbench/shared 0.3.11 → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/api/blocker-table.d.ts +3 -3
- package/dist/api/blocker-table.js +47 -23
- package/dist/api/dsh.d.ts +1 -1
- package/dist/api/workbench-client.js +2 -1
- package/dist/components/Activity.css +0 -1
- package/dist/components/ApprovalDetail.css +1 -2
- package/dist/components/ApprovalDetail.d.ts +1 -1
- package/dist/components/ApprovalPlan.css +0 -1
- package/dist/components/Card.css +0 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/CardBoundary.d.ts +1 -1
- package/dist/components/CardHead.css +0 -1
- package/dist/components/CardHead.d.ts +1 -1
- package/dist/components/ChoiceGroup.css +1 -2
- package/dist/components/ConfirmBar.d.ts +1 -1
- package/dist/components/ConfirmBar.js +1 -1
- package/dist/components/Form.css +1 -1
- package/dist/components/FormActions.js +1 -1
- package/dist/components/FormNodes.js +5 -1
- package/dist/components/FormRows.css +1 -0
- package/dist/components/FormRows.d.ts +4 -2
- package/dist/components/FormRows.js +5 -4
- package/dist/components/LongTaskRow.css +1 -2
- package/dist/components/LongTaskRow.d.ts +1 -1
- package/dist/components/LongTaskRow.js +1 -1
- package/dist/components/Note.css +0 -1
- package/dist/components/ResourceStates.css +0 -1
- package/dist/components/SettingsSection.css +0 -1
- package/dist/components/Spinner.css +0 -1
- package/dist/components/Stack.css +0 -1
- package/dist/components/StateBlock.css +0 -1
- package/dist/components/board-module.d.ts +3 -3
- package/dist/components/icons.d.ts +1 -1
- package/dist/components/icons.js +11 -4
- package/dist/config/constants.d.ts +2 -4
- package/dist/config/constants.js +2 -7
- package/dist/contract/adapters.d.ts +10 -0
- package/dist/contract/cli.d.ts +3 -0
- package/dist/contract/command.d.ts +22 -0
- package/dist/contract/data.d.ts +127 -0
- package/dist/contract/extension.d.ts +14 -0
- package/dist/contract/extension.js +1 -0
- package/dist/{api → contract}/facts.d.ts +12 -3
- package/dist/{api → contract}/facts.js +19 -1
- package/dist/contract/git.d.ts +38 -0
- package/dist/contract/git.js +1 -0
- package/dist/contract/lib.d.ts +4 -0
- package/dist/contract/lib.js +1 -0
- package/dist/contract/needs.d.ts +132 -0
- package/dist/contract/needs.js +232 -0
- package/dist/contract/plugin-source.d.ts +1 -0
- package/dist/contract/plugin-source.js +1 -0
- package/dist/contract/protocol/bundle-install.d.ts +136 -0
- package/dist/contract/protocol/bundle-install.js +12 -0
- package/dist/contract/protocol/config-sync.d.ts +55 -0
- package/dist/contract/protocol/config-sync.js +2 -0
- package/dist/contract/protocol/diy.d.ts +4 -0
- package/dist/contract/protocol/diy.js +4 -0
- package/dist/contract/protocol/dsh-plugins.d.ts +11 -0
- package/dist/contract/protocol/dsh-plugins.js +1 -0
- package/dist/contract/protocol/long-tasks.d.ts +13 -0
- package/dist/contract/protocol/long-tasks.js +1 -0
- package/dist/contract/protocol/market-index.d.ts +195 -0
- package/dist/contract/protocol/market-index.js +7 -0
- package/dist/contract/protocol/platform.d.ts +44 -0
- package/dist/contract/protocol/platform.js +1 -0
- package/dist/contract/protocol/preflight-wake.d.ts +7 -0
- package/dist/contract/protocol/preflight-wake.js +1 -0
- package/dist/contract/protocol/profile-create.d.ts +30 -0
- package/dist/contract/protocol/profile-create.js +2 -0
- package/dist/contract/protocol/sidebar-edition.d.ts +14 -0
- package/dist/contract/protocol/sidebar-edition.js +2 -0
- package/dist/contract/protocol/unit-manifests.d.ts +6 -0
- package/dist/contract/protocol/unit-manifests.js +1 -0
- package/dist/contract/unit-board.js +1 -0
- package/dist/contract/unit-capability.d.ts +34 -0
- package/dist/contract/unit-capability.js +1 -0
- package/dist/{host → contract}/unit-declaration.d.ts +7 -5
- package/dist/{api → contract}/unit-declaration.js +19 -13
- package/dist/contract/unit.d.ts +57 -0
- package/dist/contract/unit.js +24 -0
- package/dist/contract/workbench-contract.d.ts +15 -0
- package/dist/contract/workbench-contract.js +1 -0
- package/dist/host/adapter-set.d.ts +26 -0
- package/dist/host/adapter-set.js +244 -0
- package/dist/host/adapter-types.d.ts +79 -0
- package/dist/host/adapter-types.js +23 -0
- package/dist/host/adapters.d.ts +28 -0
- package/dist/host/adapters.js +9 -0
- package/dist/host/browser.d.ts +3 -0
- package/dist/host/browser.js +3 -0
- package/dist/host/changelog.d.ts +21 -0
- package/dist/host/changelog.js +188 -0
- package/dist/host/channel-plugin.d.ts +15 -0
- package/dist/host/channel-plugin.js +42 -0
- package/dist/host/cli.d.ts +4 -0
- package/dist/host/cli.js +7 -0
- package/dist/host/command-name.d.ts +1 -0
- package/dist/host/command-name.js +14 -0
- package/dist/host/data-error.d.ts +13 -0
- package/dist/host/data-error.js +20 -0
- package/dist/host/data-root.js +3 -0
- package/dist/host/diy-debug.js +2 -1
- package/dist/host/diy-record.js +2 -1
- package/dist/host/extension.d.ts +7 -0
- package/dist/host/extension.js +39 -0
- package/dist/host/facts.d.ts +1 -1
- package/dist/host/facts.js +3 -2
- package/dist/host/git.d.ts +2 -33
- package/dist/host/git.js +2 -2
- package/dist/host/http.js +2 -2
- package/dist/host/lib-capabilities.d.ts +22 -0
- package/dist/host/lib-capabilities.js +37 -0
- package/dist/host/lib-install.d.ts +9 -0
- package/dist/host/lib-install.js +10 -0
- package/dist/host/long-task.d.ts +1 -1
- package/dist/host/long-task.js +4 -3
- package/dist/host/market-index.d.ts +22 -0
- package/dist/host/market-index.js +379 -0
- package/dist/host/needs.d.ts +4 -0
- package/dist/host/needs.js +2 -0
- package/dist/host/patch.d.ts +9 -0
- package/dist/host/patch.js +78 -0
- package/dist/host/paths.d.ts +12 -0
- package/dist/host/paths.js +28 -0
- package/dist/host/platform.d.ts +14 -0
- package/dist/host/platform.js +40 -0
- package/dist/host/plugin-source.d.ts +8 -6
- package/dist/host/plugin-source.js +43 -33
- package/dist/host/plugin.d.ts +4 -0
- package/dist/host/plugin.js +39 -0
- package/dist/host/port-types.d.ts +192 -0
- package/dist/host/port-types.js +1 -0
- package/dist/host/preflight.d.ts +28 -0
- package/dist/host/preflight.js +1 -0
- package/dist/host/profile-port.d.ts +4 -0
- package/dist/host/profile-port.js +4 -0
- package/dist/host/provision.d.ts +2 -2
- package/dist/host/provision.js +5 -3
- package/dist/host/recipe-rules.d.ts +5 -0
- package/dist/host/recipe-rules.js +382 -0
- package/dist/host/recipe.d.ts +14 -0
- package/dist/host/recipe.js +283 -0
- package/dist/host/release-packages.generated.d.ts +1 -0
- package/dist/host/release-packages.generated.js +10 -0
- package/dist/host/shell-text.d.ts +9 -2
- package/dist/host/shell-text.js +15 -3
- package/dist/host/shell.d.ts +2 -0
- package/dist/host/shell.js +7 -0
- package/dist/host/spec.d.ts +8 -0
- package/dist/host/spec.js +24 -0
- package/dist/host/supply-index.d.ts +34 -0
- package/dist/host/supply-index.js +202 -0
- package/dist/host/supply-port.d.ts +5 -0
- package/dist/host/supply-port.js +39 -0
- package/dist/host/time.d.ts +12 -0
- package/dist/host/time.js +19 -0
- package/dist/host/tokens.d.ts +26 -0
- package/dist/host/tokens.js +154 -0
- package/dist/host/tool-kit.d.ts +0 -6
- package/dist/host/tool-kit.js +0 -22
- package/dist/host/unit-face.d.ts +12 -4
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +13 -0
- package/dist/host/version.d.ts +4 -0
- package/dist/host/version.js +27 -0
- package/dist/host.d.ts +53 -16
- package/dist/host.js +53 -16
- package/dist/i18n/en.js +225 -71
- package/dist/i18n/index.d.ts +299 -73
- package/dist/i18n/merge.js +1 -1
- package/dist/i18n/need-text.d.ts +26 -0
- package/dist/i18n/need-text.js +26 -0
- package/dist/i18n/settings.d.ts +70 -0
- package/dist/i18n/settings.js +136 -0
- package/dist/i18n/zh.d.ts +298 -72
- package/dist/i18n/zh.js +227 -73
- package/dist/index.d.ts +27 -7
- package/dist/index.js +27 -7
- package/dist/{api → lib}/dsh-client.d.ts +11 -1
- package/dist/lib/dsh-client.js +1 -0
- package/dist/lib/market-index.d.ts +7 -0
- package/dist/lib/market-index.js +25 -0
- package/dist/lib/react.d.ts +0 -40
- package/dist/lib/react.js +0 -36
- package/dist/lib/ui.js +3 -9
- package/dist/lib/version.d.ts +4 -0
- package/dist/lib/version.js +21 -0
- package/dist/testing/data.d.ts +13 -0
- package/dist/testing/data.js +46 -0
- package/dist/testing/declaration.d.ts +1 -1
- package/dist/testing/declaration.js +1 -1
- package/dist/testing/host-fakes.d.ts +0 -13
- package/dist/testing/host-fakes.js +0 -24
- package/dist/testing/needs.d.ts +16 -0
- package/dist/testing/needs.js +46 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/package.json +22 -4
- package/src/api/__tests__/blocker-table.test.ts +135 -86
- package/src/api/blocker-table.ts +52 -26
- package/src/api/dsh.ts +1 -1
- package/src/api/host-write.ts +0 -1
- package/src/api/workbench-client.test.ts +2 -2
- package/src/api/workbench-client.ts +2 -1
- package/src/components/Activity.css +0 -1
- package/src/components/ApprovalDetail.css +1 -2
- package/src/components/ApprovalDetail.tsx +1 -1
- package/src/components/ApprovalPlan.css +0 -1
- package/src/components/Card.css +0 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/CardAnchor.test.tsx +1 -1
- package/src/components/CardBoundary.tsx +1 -1
- package/src/components/CardHead.css +0 -1
- package/src/components/CardHead.tsx +1 -1
- package/src/components/ChoiceGroup.css +1 -2
- package/src/components/ConfirmBar.tsx +1 -1
- package/src/components/Form.css +1 -1
- package/src/components/Form.test.tsx +6 -0
- package/src/components/Form.tsx +1 -1
- package/src/components/FormActions.tsx +1 -1
- package/src/components/FormNodes.tsx +6 -1
- package/src/components/FormRows.css +1 -0
- package/src/components/FormRows.test.tsx +30 -0
- package/src/components/FormRows.tsx +9 -5
- package/src/components/LongTaskRow.css +1 -2
- package/src/components/LongTaskRow.tsx +1 -1
- package/src/components/Note.css +0 -1
- package/src/components/ResourceStates.css +0 -1
- package/src/components/SelectFieldNodes.tsx +0 -1
- package/src/components/SettingsSection.css +0 -1
- package/src/components/Spinner.css +0 -1
- package/src/components/Stack.css +0 -1
- package/src/components/StateBlock.css +0 -1
- package/src/components/__tests__/long-task-row.test.ts +1 -1
- package/src/components/board-module.ts +3 -3
- package/src/components/icons.tsx +16 -8
- package/src/config/constants.ts +2 -8
- package/src/{api → contract}/__tests__/facts.test.ts +73 -25
- package/src/{api → contract}/__tests__/long-task.test.ts +3 -3
- package/src/contract/__tests__/needs.test.ts +74 -0
- package/src/{host → contract}/__tests__/unit-declaration.test.ts +1 -1
- package/src/contract/__tests__/unit.test.ts +43 -0
- package/src/contract/adapters.ts +9 -0
- package/src/contract/cli.ts +3 -0
- package/src/contract/command.ts +25 -0
- package/src/contract/data.ts +146 -0
- package/src/contract/extension.ts +20 -0
- package/src/{api → contract}/facts.ts +34 -4
- package/src/contract/git.ts +20 -0
- package/src/contract/lib.ts +5 -0
- package/src/contract/needs.ts +331 -0
- package/src/contract/plugin-source.ts +1 -0
- package/src/contract/protocol/bundle-install.ts +198 -0
- package/src/contract/protocol/config-sync.ts +65 -0
- package/src/contract/protocol/diy.ts +4 -0
- package/src/contract/protocol/dsh-plugins.ts +13 -0
- package/src/contract/protocol/long-tasks.ts +16 -0
- package/src/contract/protocol/market-index.ts +246 -0
- package/src/contract/protocol/platform.ts +47 -0
- package/src/contract/protocol/preflight-wake.ts +17 -0
- package/src/contract/protocol/profile-create.ts +36 -0
- package/src/contract/protocol/sidebar-edition.ts +19 -0
- package/src/contract/protocol/unit-manifests.ts +8 -0
- package/src/{api → contract}/unit-board.ts +0 -1
- package/src/contract/unit-capability.ts +37 -0
- package/src/{host → contract}/unit-declaration.ts +22 -18
- package/src/contract/unit.ts +76 -0
- package/src/contract/workbench-contract.ts +30 -0
- package/src/host/__tests__/adapter-set.test.ts +228 -0
- package/src/host/__tests__/adapters.test.ts +27 -0
- package/src/host/__tests__/changelog.test.ts +102 -0
- package/src/host/__tests__/command-name.test.ts +16 -0
- package/src/host/__tests__/diy-record.test.ts +3 -3
- package/src/host/__tests__/facts.test.ts +5 -5
- package/src/host/__tests__/long-task.test.ts +1 -1
- package/src/host/__tests__/market-index.test.ts +179 -0
- package/src/host/__tests__/plugin-ledger.test.ts +10 -10
- package/src/host/__tests__/provision.test.ts +7 -6
- package/src/host/__tests__/shell-text.test.ts +16 -1
- package/src/host/__tests__/supply-index.test.ts +137 -0
- package/src/host/__tests__/tokens.test.ts +110 -0
- package/src/host/__tests__/version-range.test.ts +21 -0
- package/src/host/adapter-set.ts +299 -0
- package/src/host/adapter-types.ts +105 -0
- package/src/host/adapters.ts +50 -0
- package/src/host/browser.ts +3 -0
- package/src/host/changelog.ts +212 -0
- package/src/host/channel-plugin.ts +55 -0
- package/src/host/cli.ts +11 -0
- package/src/host/command-name.ts +15 -0
- package/src/host/data-error.ts +21 -0
- package/src/host/data-root.ts +2 -0
- package/src/host/diy-debug.ts +2 -1
- package/src/host/diy-record.ts +2 -1
- package/src/host/extension.test.ts +55 -0
- package/src/host/extension.ts +57 -0
- package/src/host/facts.ts +4 -3
- package/src/host/git.ts +8 -16
- package/src/host/http.ts +2 -2
- package/src/host/lib-capabilities.ts +52 -0
- package/src/host/lib-install.ts +18 -0
- package/src/host/long-task.ts +4 -3
- package/src/host/market-index.ts +383 -0
- package/src/host/needs.ts +6 -0
- package/src/host/patch.ts +93 -0
- package/src/host/paths.ts +37 -0
- package/src/host/platform.ts +48 -0
- package/src/host/plugin-source.ts +48 -56
- package/src/host/plugin.ts +39 -0
- package/src/host/port-types.ts +223 -0
- package/src/host/preflight.ts +31 -0
- package/src/host/profile-port.ts +9 -0
- package/src/host/provision.ts +7 -4
- package/src/host/recipe-rules.ts +330 -0
- package/src/host/recipe.test.ts +334 -0
- package/src/host/recipe.ts +323 -0
- package/src/host/release-packages.generated.ts +10 -0
- package/src/host/shell-text.ts +15 -3
- package/src/host/shell.ts +9 -0
- package/src/host/spec.ts +32 -0
- package/src/host/supply-index.ts +256 -0
- package/src/host/supply-port.ts +45 -0
- package/src/host/time.ts +22 -0
- package/src/host/tokens.ts +186 -0
- package/src/host/tool-kit.ts +0 -35
- package/src/host/unit-face.ts +12 -4
- package/src/host/version-range.ts +13 -0
- package/src/host/version.ts +30 -0
- package/src/host.ts +53 -16
- package/src/i18n/en.ts +225 -71
- package/src/i18n/merge.test.ts +6 -6
- package/src/i18n/merge.ts +1 -1
- package/src/i18n/need-text.ts +27 -0
- package/src/i18n/settings.ts +141 -0
- package/src/i18n/zh.ts +228 -73
- package/src/index.ts +27 -7
- package/src/lib/blocker-action.ts +0 -1
- package/src/{api → lib}/dsh-client.ts +12 -1
- package/src/lib/market-index.ts +36 -0
- package/src/lib/react.ts +0 -40
- package/src/lib/text.test.ts +2 -2
- package/src/lib/ui.test.ts +6 -5
- package/src/lib/ui.ts +3 -9
- package/src/testing/__tests__/declaration.test.ts +1 -1
- package/src/testing/data.ts +66 -0
- package/src/testing/declaration.ts +2 -2
- package/src/testing/host-fakes.ts +0 -38
- package/src/testing/needs.ts +80 -0
- package/src/testing.ts +2 -0
- package/dist/api/unit-declaration.d.ts +0 -65
- package/dist/api/unit.d.ts +0 -85
- package/dist/api/unit.js +0 -8
- package/dist/api/workbench-contract.d.ts +0 -44
- package/dist/components/MockStrip.css +0 -39
- package/dist/components/MockStrip.d.ts +0 -15
- package/dist/components/MockStrip.js +0 -8
- package/dist/components/SaveBar.css +0 -7
- package/dist/host/browser-find.d.ts +0 -38
- package/dist/host/browser-find.js +0 -242
- package/dist/host/browser-read.d.ts +0 -28
- package/dist/host/browser-read.js +0 -243
- package/dist/host/opencli-runtime.d.ts +0 -25
- package/dist/host/opencli-runtime.js +0 -56
- package/dist/host/opencli-window.d.ts +0 -2
- package/dist/host/opencli-window.js +0 -8
- package/dist/host/opencli.d.ts +0 -37
- package/dist/host/opencli.js +0 -155
- package/dist/host/unit-declaration.js +0 -213
- package/dist/host/unit-libs.d.ts +0 -37
- package/dist/lib/diy-debug.d.ts +0 -80
- package/dist/lib/diy-debug.js +0 -88
- package/dist/lib/diy-record.d.ts +0 -135
- package/dist/lib/diy-record.js +0 -162
- package/dist/lib/lint-probe.d.ts +0 -1
- package/dist/lib/lint-probe.js +0 -6
- package/dist/lib/panel-state.d.ts +0 -120
- package/dist/lib/panel-state.js +0 -176
- package/src/api/__tests__/unit.test.ts +0 -38
- package/src/api/unit.ts +0 -93
- package/src/api/workbench-contract.ts +0 -59
- package/src/host/__tests__/browser-find.test.ts +0 -330
- package/src/host/__tests__/browser-read.test.ts +0 -228
- package/src/host/__tests__/opencli-runtime.test.ts +0 -46
- package/src/host/browser-find.ts +0 -311
- package/src/host/browser-read.ts +0 -311
- package/src/host/opencli-runtime.ts +0 -79
- package/src/host/opencli-window.ts +0 -11
- package/src/host/opencli.ts +0 -213
- package/src/host/unit-libs.ts +0 -41
- /package/dist/{api/blocker.js → contract/adapters.js} +0 -0
- /package/dist/{api → contract}/blocker.d.ts +0 -0
- /package/dist/{api/dsh-client.js → contract/blocker.js} +0 -0
- /package/dist/{api/unit-board.js → contract/cli.js} +0 -0
- /package/dist/{api/workbench-contract.js → contract/command.js} +0 -0
- /package/dist/{host/unit-libs.js → contract/data.js} +0 -0
- /package/dist/{api → contract}/long-task.d.ts +0 -0
- /package/dist/{api → contract}/long-task.js +0 -0
- /package/dist/{api → contract}/unit-board.d.ts +0 -0
- /package/src/{api → contract}/blocker.ts +0 -0
- /package/src/{api → contract}/long-task.ts +0 -0
package/src/api/unit.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 一张卡片在清单里的静态声明(文案键加排序位);默认显不显示由运行期面板配置定。
|
|
3
|
-
*/
|
|
4
|
-
export interface UnitCard {
|
|
5
|
-
readonly titleKey: string;
|
|
6
|
-
readonly order: number;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* 一条工具在清单里的样子:全名加会不会写;审批按 writes 认领。
|
|
11
|
-
*/
|
|
12
|
-
export interface UnitTool {
|
|
13
|
-
readonly name: string;
|
|
14
|
-
readonly writes: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* 模块要外壳的哪些服务:inject 缺一个就挂不上,optional 缺了照挂。
|
|
19
|
-
*/
|
|
20
|
-
export interface UnitHostNeeds {
|
|
21
|
-
readonly inject: readonly string[];
|
|
22
|
-
readonly optional?: readonly string[];
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* 一个 opencli 插件的来源三选一(git / 本地 / npm);npm 那支的安装源先看 registryEnv 那个环境变量,没设才用 registryDefault。
|
|
27
|
-
*/
|
|
28
|
-
export type PluginSource =
|
|
29
|
-
| { readonly kind: 'git'; readonly url: string }
|
|
30
|
-
| { readonly kind: 'local'; readonly env: string }
|
|
31
|
-
| {
|
|
32
|
-
readonly kind: 'npm';
|
|
33
|
-
readonly package: string;
|
|
34
|
-
readonly registryEnv: string;
|
|
35
|
-
readonly registryDefault?: string;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* 模块要的一个 opencli 插件:名字、它得提供的命令,以及装它的来源(没写就是不代装)。
|
|
40
|
-
*/
|
|
41
|
-
export interface UnitPluginNeed {
|
|
42
|
-
readonly name: string;
|
|
43
|
-
readonly commands?: readonly string[];
|
|
44
|
-
readonly installSource?: PluginSource;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* 模块要的一个共用库:名字、期望范围与它为什么要这个版本(purpose 会进申报文案)。
|
|
49
|
-
*/
|
|
50
|
-
export interface UnitLibNeed {
|
|
51
|
-
readonly name: string;
|
|
52
|
-
readonly version?: string | undefined;
|
|
53
|
-
readonly registryEnv: string;
|
|
54
|
-
readonly registryDefault: string;
|
|
55
|
-
readonly purpose: string;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* 模块的整份环境需要:一条自检命令,加上插件与共用库两张表。
|
|
60
|
-
*/
|
|
61
|
-
export interface UnitEnvNeeds {
|
|
62
|
-
readonly command?: string;
|
|
63
|
-
readonly plugins?: readonly UnitPluginNeed[];
|
|
64
|
-
readonly libs?: readonly UnitLibNeed[];
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* 已装插件与源上最新版那一对,用来判该不该提示升级;latest 缺省表示还没查到。
|
|
69
|
-
*/
|
|
70
|
-
export interface PluginRelease {
|
|
71
|
-
readonly installed: string;
|
|
72
|
-
readonly latest?: string;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* 装配期用的模块清单:单元 id、卡片、工具与宿主 / 环境需要,比声明少一层协议包装。
|
|
77
|
-
*/
|
|
78
|
-
export interface UnitManifest {
|
|
79
|
-
readonly id: string;
|
|
80
|
-
readonly card: UnitCard | null;
|
|
81
|
-
readonly tools: readonly UnitTool[];
|
|
82
|
-
readonly host: UnitHostNeeds;
|
|
83
|
-
readonly env?: UnitEnvNeeds;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* 判这个模块要不要往外装东西。
|
|
88
|
-
* @param manifest 模块清单。
|
|
89
|
-
* @returns 插件与共用库两张表都空时给 false。
|
|
90
|
-
*/
|
|
91
|
-
export function hasEnvSupply(manifest: UnitManifest): boolean {
|
|
92
|
-
return (manifest.env?.plugins ?? []).length > 0 || (manifest.env?.libs ?? []).length > 0;
|
|
93
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { PluginRelease } from '../api/unit.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* 供给动作的那几档(装 / 升 / 卸,模块、共用依赖与插件各一套);写口按它分派。
|
|
5
|
-
*/
|
|
6
|
-
export type ProvisionAction =
|
|
7
|
-
| 'install'
|
|
8
|
-
| 'update'
|
|
9
|
-
| 'uninstall'
|
|
10
|
-
| 'update-dependency'
|
|
11
|
-
| 'install-bundle'
|
|
12
|
-
| 'update-bundle'
|
|
13
|
-
| 'remove-bundle'
|
|
14
|
-
| 'cancel-install'
|
|
15
|
-
| 'update-plugin'
|
|
16
|
-
| 'uninstall-plugin'
|
|
17
|
-
| 'update-workbench';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 宿主报的一个 opencli 插件此刻的状态:装没装、缺哪些命令、该不该升,以及怎么升。
|
|
21
|
-
*/
|
|
22
|
-
export interface PluginStatePayload {
|
|
23
|
-
readonly name: string;
|
|
24
|
-
readonly status: 'ok' | 'outdated' | 'missing';
|
|
25
|
-
readonly missing: readonly string[];
|
|
26
|
-
readonly install?: 'ready' | 'not-declared' | 'env-missing' | 'malformed';
|
|
27
|
-
readonly command?: string;
|
|
28
|
-
readonly release?: PluginRelease;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* 宿主对「这个单元现在能不能用」的那份读数:状态、缺的命令与插件、修复动作和供给细节。
|
|
33
|
-
*/
|
|
34
|
-
export interface CapabilityPayload {
|
|
35
|
-
readonly unit: string;
|
|
36
|
-
readonly status: 'ok' | 'failed' | 'missing-commands' | 'missing-plugin' | 'unchecked';
|
|
37
|
-
readonly plugin?: string;
|
|
38
|
-
readonly required: readonly string[];
|
|
39
|
-
readonly missing: readonly string[];
|
|
40
|
-
readonly detail: string;
|
|
41
|
-
readonly command?: string;
|
|
42
|
-
readonly fix?: 'install' | 'update';
|
|
43
|
-
readonly plugins?: readonly PluginStatePayload[];
|
|
44
|
-
readonly released?: boolean;
|
|
45
|
-
readonly install?: 'ready' | 'not-declared' | 'env-missing' | 'malformed';
|
|
46
|
-
readonly libs?: readonly LibStatePayload[];
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* 宿主报的一个共用库此刻的状态(装没装、版本对不对)与它为什么要这个版本。
|
|
51
|
-
*/
|
|
52
|
-
export interface LibStatePayload {
|
|
53
|
-
readonly name: string;
|
|
54
|
-
readonly purpose: string;
|
|
55
|
-
readonly status: 'ok' | 'outdated' | 'missing' | 'unsatisfied';
|
|
56
|
-
readonly installed?: string;
|
|
57
|
-
readonly latest?: string;
|
|
58
|
-
readonly command?: string;
|
|
59
|
-
}
|
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { BROWSER_SCREEN_SESSION } from '../browser-read.js';
|
|
3
|
-
import {
|
|
4
|
-
browserFind,
|
|
5
|
-
cellRows,
|
|
6
|
-
cellRowsOf,
|
|
7
|
-
entriesOf,
|
|
8
|
-
reasonOf,
|
|
9
|
-
sameOrigin,
|
|
10
|
-
urlOf,
|
|
11
|
-
} from '../browser-find.js';
|
|
12
|
-
|
|
13
|
-
interface Step {
|
|
14
|
-
readonly stdout?: string;
|
|
15
|
-
readonly stderr?: string;
|
|
16
|
-
readonly exitCode?: number;
|
|
17
|
-
readonly timedOut?: boolean;
|
|
18
|
-
readonly throws?: boolean;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
interface Plan {
|
|
22
|
-
readonly url?: string | readonly string[];
|
|
23
|
-
readonly find?: readonly Step[];
|
|
24
|
-
readonly open?: readonly Step[];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function fakeShell(plan: Plan) {
|
|
28
|
-
const commands: string[] = [];
|
|
29
|
-
const counters = { url: 0, find: 0, open: 0 };
|
|
30
|
-
const pick = <T>(list: readonly T[] | undefined, index: number, fallback: T): T =>
|
|
31
|
-
(list ?? [])[Math.min(index, Math.max(0, (list ?? []).length - 1))] ?? fallback;
|
|
32
|
-
|
|
33
|
-
const shell = {
|
|
34
|
-
resolve(request: { command: string }) {
|
|
35
|
-
commands.push(request.command);
|
|
36
|
-
return request;
|
|
37
|
-
},
|
|
38
|
-
async execute(spec: { command: string }) {
|
|
39
|
-
const command = String(spec.command);
|
|
40
|
-
let step: Step = {};
|
|
41
|
-
let stdout = '';
|
|
42
|
-
if (command.includes("'get'") && command.includes("'url'")) {
|
|
43
|
-
const urls = typeof plan.url === 'string' ? [plan.url] : (plan.url ?? []);
|
|
44
|
-
stdout = pick(urls, counters.url, '') as string;
|
|
45
|
-
counters.url += 1;
|
|
46
|
-
} else if (command.includes("'find'")) {
|
|
47
|
-
step = pick(plan.find, counters.find, {});
|
|
48
|
-
stdout = step.stdout ?? '';
|
|
49
|
-
counters.find += 1;
|
|
50
|
-
} else if (command.includes("'open'")) {
|
|
51
|
-
step = pick(plan.open, counters.open, {});
|
|
52
|
-
stdout = step.stdout ?? JSON.stringify({ page: 'AE4021' });
|
|
53
|
-
counters.open += 1;
|
|
54
|
-
}
|
|
55
|
-
if (step.throws === true) throw new Error('spawn opencli ENOENT');
|
|
56
|
-
return {
|
|
57
|
-
result: async () => ({
|
|
58
|
-
exitCode: step.exitCode ?? 0,
|
|
59
|
-
timedOut: step.timedOut ?? false,
|
|
60
|
-
aborted: false,
|
|
61
|
-
stdout: { text: stdout, truncated: false },
|
|
62
|
-
stderr: { text: step.stderr ?? '', truncated: false },
|
|
63
|
-
}),
|
|
64
|
-
};
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
return { shell: shell as never, commands };
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const FAST = { settleMs: 1, timeoutMs: 50 } as const;
|
|
71
|
-
const SITE = 'https://example.test/rates';
|
|
72
|
-
const OTHER = 'https://example.test/elsewhere';
|
|
73
|
-
const CSS = 'table tr';
|
|
74
|
-
const MATCH = JSON.stringify({ entries: [{ text: '美元\n673.30', tag: 'tr', nth: 1 }] });
|
|
75
|
-
const ZERO_MATCH = JSON.stringify({
|
|
76
|
-
error: {
|
|
77
|
-
code: 'selector_not_found',
|
|
78
|
-
hint: 'try a less specific selector',
|
|
79
|
-
message: 'CSS selector table tr matched 0 elements',
|
|
80
|
-
},
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
describe('browserFind · 停在哪一页', () => {
|
|
84
|
-
it('已经在目标站点上:只问一次 get url,然后一次 find', async () => {
|
|
85
|
-
const { shell, commands } = fakeShell({ url: SITE, find: [{ stdout: MATCH }] });
|
|
86
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
87
|
-
|
|
88
|
-
expect(out.ok).toBe(true);
|
|
89
|
-
expect(out.count).toBe(1);
|
|
90
|
-
expect(out.entries[0]?.text).toBe('美元\n673.30');
|
|
91
|
-
expect(commands.filter((one) => one.includes("'find'"))).toHaveLength(1);
|
|
92
|
-
expect(commands.some((one) => one.includes("'open'"))).toBe(false);
|
|
93
|
-
expect(commands[0]).toContain("'get' 'url'");
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
it('新会话还停在 about:blank:先 open 再读,命令走 find --css', async () => {
|
|
97
|
-
const { shell, commands } = fakeShell({
|
|
98
|
-
url: ['about:blank', SITE],
|
|
99
|
-
find: [{ stdout: MATCH }],
|
|
100
|
-
});
|
|
101
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
102
|
-
|
|
103
|
-
expect(out.ok).toBe(true);
|
|
104
|
-
expect(out.count).toBe(1);
|
|
105
|
-
expect(commands.some((one) => one.includes("'open'"))).toBe(true);
|
|
106
|
-
expect(commands.filter((one) => one.includes("'find'"))).toHaveLength(1);
|
|
107
|
-
expect(commands[1]).toContain("'open'");
|
|
108
|
-
expect(commands[1]).toContain(SITE);
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
it('问不出来在哪一页(get url 空)时不乱开,直接找', async () => {
|
|
112
|
-
const { shell, commands } = fakeShell({ url: '', find: [{ stdout: MATCH }] });
|
|
113
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
114
|
-
|
|
115
|
-
expect(out.ok).toBe(true);
|
|
116
|
-
expect(commands.some((one) => one.includes("'open'"))).toBe(false);
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('open 失败 → cli-exec-failed,带上 helpUrl 与原因', async () => {
|
|
120
|
-
const { shell } = fakeShell({
|
|
121
|
-
url: 'about:blank',
|
|
122
|
-
open: [{ stdout: JSON.stringify({ error: { message: 'browser session is not bound' } }), exitCode: 1 }],
|
|
123
|
-
});
|
|
124
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
125
|
-
|
|
126
|
-
expect(out.ok).toBe(false);
|
|
127
|
-
expect(out.code).toBe('cli-exec-failed');
|
|
128
|
-
expect(out.message).toContain('打不开');
|
|
129
|
-
expect(out.detail).toContain('not bound');
|
|
130
|
-
expect(out.helpUrl).toBe(SITE);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('open 那条命令直接抛(opencli 不在)也要报出来,不许把异常漏出去', async () => {
|
|
134
|
-
const { shell } = fakeShell({ url: 'about:blank', open: [{ throws: true }] });
|
|
135
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
136
|
-
|
|
137
|
-
expect(out.ok).toBe(false);
|
|
138
|
-
expect(out.code).toBe('cli-exec-failed');
|
|
139
|
-
expect(out.detail).toContain('ENOENT');
|
|
140
|
-
});
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
describe('browserFind · 找到与找不到', () => {
|
|
144
|
-
it('页面上就是没有匹配元素 → ok,但 count 是 0(空不撒谎)', async () => {
|
|
145
|
-
const { shell } = fakeShell({ url: SITE, find: [{ stdout: JSON.stringify({ entries: [] }) }] });
|
|
146
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
147
|
-
|
|
148
|
-
expect(out.ok).toBe(true);
|
|
149
|
-
expect(out.count).toBe(0);
|
|
150
|
-
expect(out.message).toContain('没有匹配');
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('在站点上但 find 失败(会话刚重启那类):安全网再 open 一次并重读', async () => {
|
|
154
|
-
const { shell, commands } = fakeShell({
|
|
155
|
-
url: SITE,
|
|
156
|
-
find: [{ stdout: ZERO_MATCH, exitCode: 1 }, { stdout: MATCH }],
|
|
157
|
-
});
|
|
158
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
159
|
-
|
|
160
|
-
expect(out.ok).toBe(true);
|
|
161
|
-
expect(out.count).toBe(1);
|
|
162
|
-
expect(commands.filter((one) => one.includes("'find'"))).toHaveLength(2);
|
|
163
|
-
expect(commands.some((one) => one.includes("'open'"))).toBe(true);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('一直失败:把 opencli 自己在 stdout JSON 里说的原因当 message(不是 stderr)', async () => {
|
|
167
|
-
const { shell } = fakeShell({
|
|
168
|
-
url: SITE,
|
|
169
|
-
find: [{ stdout: ZERO_MATCH, exitCode: 1 }, { stdout: ZERO_MATCH, exitCode: 1 }],
|
|
170
|
-
});
|
|
171
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
172
|
-
|
|
173
|
-
expect(out.ok).toBe(false);
|
|
174
|
-
expect(out.code).toBe('cli-exec-failed');
|
|
175
|
-
expect(out.message).toContain('matched 0 elements');
|
|
176
|
-
expect(out.hint).toBe('try a less specific selector');
|
|
177
|
-
expect(out.helpUrl).toBe(SITE);
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
it('超时归成 cli-timeout,且不再折腾页面', async () => {
|
|
181
|
-
const { shell, commands } = fakeShell({
|
|
182
|
-
url: SITE,
|
|
183
|
-
find: [{ timedOut: true, exitCode: 124 }],
|
|
184
|
-
});
|
|
185
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
186
|
-
|
|
187
|
-
expect(out.ok).toBe(false);
|
|
188
|
-
expect(out.code).toBe('cli-timeout');
|
|
189
|
-
expect(out.detail).toContain('秒内返回');
|
|
190
|
-
expect(commands.some((one) => one.includes("'open'"))).toBe(false);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
it('url 没给:只 find,不问页面也不开', async () => {
|
|
194
|
-
const { shell, commands } = fakeShell({ find: [{ stdout: MATCH }] });
|
|
195
|
-
const out = await browserFind({ shell, css: CSS, ...FAST });
|
|
196
|
-
|
|
197
|
-
expect(out.ok).toBe(true);
|
|
198
|
-
expect(commands).toHaveLength(1);
|
|
199
|
-
expect(commands[0]).toContain("'find'");
|
|
200
|
-
});
|
|
201
|
-
|
|
202
|
-
it('open:false:只 find(不说自己在哪一页,也不开)', async () => {
|
|
203
|
-
const { shell, commands } = fakeShell({
|
|
204
|
-
url: SITE,
|
|
205
|
-
find: [{ stdout: ZERO_MATCH, exitCode: 1 }, { stdout: MATCH }],
|
|
206
|
-
});
|
|
207
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, open: false, ...FAST });
|
|
208
|
-
|
|
209
|
-
expect(out.ok).toBe(false);
|
|
210
|
-
expect(commands).toHaveLength(1);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('opencli 根本没起来(find 那条抛)→ cli-exec-failed,带照做的话', async () => {
|
|
214
|
-
const { shell } = fakeShell({ url: SITE, find: [{ throws: true }] });
|
|
215
|
-
const out = await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
216
|
-
|
|
217
|
-
expect(out.ok).toBe(false);
|
|
218
|
-
expect(out.code).toBe('cli-exec-failed');
|
|
219
|
-
expect(out.detail).toContain('ENOENT');
|
|
220
|
-
expect(out.hint).toContain('后台服务');
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('session / command / limit / textMax 都能覆盖(命令行每个 token 都加引号)', async () => {
|
|
224
|
-
const { shell, commands } = fakeShell({ url: SITE, find: [{ stdout: MATCH }] });
|
|
225
|
-
await browserFind({
|
|
226
|
-
shell,
|
|
227
|
-
css: CSS,
|
|
228
|
-
url: SITE,
|
|
229
|
-
session: 'dsh-fx-rate',
|
|
230
|
-
command: '/usr/local/bin/opencli',
|
|
231
|
-
limit: 60,
|
|
232
|
-
textMax: 400,
|
|
233
|
-
...FAST,
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
const findLine = commands.find((one) => one.includes("'find'")) ?? '';
|
|
237
|
-
expect(commands[0]).toContain("'/usr/local/bin/opencli'");
|
|
238
|
-
expect(commands[0]).toContain("'dsh-fx-rate'");
|
|
239
|
-
expect(findLine).toContain("'--limit' '60'");
|
|
240
|
-
expect(findLine).toContain("'--text-max' '400'");
|
|
241
|
-
});
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
describe('cellRowsOf / reasonOf / sameOrigin', () => {
|
|
245
|
-
it('按换行切格、丢掉空行、按 minCells 过滤', () => {
|
|
246
|
-
const rows = cellRowsOf([
|
|
247
|
-
{ text: '货币名称\n现汇买入价\n\n现钞买入价\n现汇卖出价' },
|
|
248
|
-
{ text: '只有一个' },
|
|
249
|
-
{ text: undefined },
|
|
250
|
-
]);
|
|
251
|
-
|
|
252
|
-
expect(rows).toHaveLength(1);
|
|
253
|
-
expect(rows[0]).toEqual(['货币名称', '现汇买入价', '现钞买入价', '现汇卖出价']);
|
|
254
|
-
expect(cellRowsOf([{ text: '一\n二' }], 3)).toEqual([]);
|
|
255
|
-
expect(cellRows('a\n b \n\n')).toEqual(['a', 'b']);
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('reasonOf 优先取 error.message,没有才退回到最后一行', () => {
|
|
259
|
-
expect(reasonOf(JSON.stringify({ error: { message: 'matched 0 elements' } }), '')).toBe(
|
|
260
|
-
'matched 0 elements',
|
|
261
|
-
);
|
|
262
|
-
expect(reasonOf('', 'opencli: daemon not ready\nboom')).toBe('boom');
|
|
263
|
-
expect(reasonOf('not json', '')).toBe('not json');
|
|
264
|
-
});
|
|
265
|
-
|
|
266
|
-
it('entriesOf 只认有 text 的项,缺 nth 用序号补', () => {
|
|
267
|
-
const entries = entriesOf({
|
|
268
|
-
entries: [{ text: 'a', tag: 'tr' }, { tag: 'tr' }, 'nope', { text: 'b', tag: 'tr', nth: 9 }],
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
expect(entries).toHaveLength(3);
|
|
272
|
-
expect(entries[0]).toEqual({ text: 'a', tag: 'tr', nth: 0 });
|
|
273
|
-
expect(entries[2]).toEqual({ text: 'b', tag: 'tr', nth: 9 });
|
|
274
|
-
expect(entriesOf(undefined)).toEqual([]);
|
|
275
|
-
expect(entriesOf({ entries: 'nope' })).toEqual([]);
|
|
276
|
-
});
|
|
277
|
-
|
|
278
|
-
it('urlOf 认裸 URL、认带引号的、也认 {url} 的 JSON(判错的代价是每次多开一次页面)', () => {
|
|
279
|
-
expect(urlOf('https://a.test/x\n')).toBe('https://a.test/x');
|
|
280
|
-
expect(urlOf('URL: https://a.test/x')).toBe('https://a.test/x');
|
|
281
|
-
expect(urlOf('"https://a.test/x"')).toBe('https://a.test/x');
|
|
282
|
-
expect(urlOf('{"url":"https://a.test/x","title":"t"}')).toBe('https://a.test/x');
|
|
283
|
-
expect(urlOf('')).toBe('');
|
|
284
|
-
});
|
|
285
|
-
|
|
286
|
-
it('sameOrigin 只看同源;空串或不是 URL 一律不算', () => {
|
|
287
|
-
expect(sameOrigin('https://a.test/x', 'https://a.test/y')).toBe(true);
|
|
288
|
-
expect(sameOrigin('https://a.test/x', 'https://b.test/y')).toBe(false);
|
|
289
|
-
expect(sameOrigin('about:blank', SITE)).toBe(false);
|
|
290
|
-
expect(sameOrigin('', SITE)).toBe(false);
|
|
291
|
-
expect(sameOrigin('not a url', SITE)).toBe(false);
|
|
292
|
-
expect(OTHER).toContain('elsewhere');
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
function backgroundless(commands: readonly string[]): readonly string[] {
|
|
297
|
-
return commands
|
|
298
|
-
.filter((one) => one.includes("'browser'"))
|
|
299
|
-
.filter(
|
|
300
|
-
(one) => !one.includes("'--window' 'background'") || !one.includes("'OPENCLI_WINDOW=background'"),
|
|
301
|
-
);
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
describe('browserFind · 后台静默(问页 + 读 + 打开都不许抢焦点)', () => {
|
|
305
|
-
it('已经在目标站点上:get url + find 两条全带', async () => {
|
|
306
|
-
const { shell, commands } = fakeShell({ url: SITE, find: [{ stdout: MATCH }] });
|
|
307
|
-
await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
308
|
-
|
|
309
|
-
expect(commands).toHaveLength(2);
|
|
310
|
-
expect(backgroundless(commands)).toEqual([]);
|
|
311
|
-
});
|
|
312
|
-
|
|
313
|
-
it('不在目标站点上:get url + open + find 三条全带', async () => {
|
|
314
|
-
const { shell, commands } = fakeShell({ url: ['about:blank', SITE], find: [{ stdout: MATCH }] });
|
|
315
|
-
await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
316
|
-
|
|
317
|
-
expect(commands.filter((one) => one.includes("'open'"))).toHaveLength(1);
|
|
318
|
-
expect(backgroundless(commands)).toEqual([]);
|
|
319
|
-
});
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
describe('browserFind · 读有它自己那条会话(不许碰屏那条)', () => {
|
|
323
|
-
it('默认那条命令里一条都不带屏那条会话名', async () => {
|
|
324
|
-
const { shell, commands } = fakeShell({ url: ['about:blank', SITE], find: [{ stdout: MATCH }] });
|
|
325
|
-
await browserFind({ shell, css: CSS, url: SITE, ...FAST });
|
|
326
|
-
|
|
327
|
-
expect(commands.length).toBeGreaterThan(0);
|
|
328
|
-
expect(commands.some((one) => one.includes(`'${BROWSER_SCREEN_SESSION}'`))).toBe(false);
|
|
329
|
-
});
|
|
330
|
-
});
|