@seamapi/cli 0.18.1 → 0.19.0
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/README.md +55 -1
- package/bin/cli.js +73 -249
- package/bin/cli.js.map +1 -1
- package/lib/args/coerce.d.ts +28 -0
- package/lib/args/coerce.js +131 -0
- package/lib/args/coerce.js.map +1 -0
- package/lib/{util/cli-args.d.ts → args/parse.d.ts} +12 -15
- package/lib/{util/cli-args.js → args/parse.js} +21 -24
- package/lib/args/parse.js.map +1 -0
- package/lib/args/validate.d.ts +23 -0
- package/lib/args/validate.js +42 -0
- package/lib/args/validate.js.map +1 -0
- package/lib/auth/operations.d.ts +54 -0
- package/lib/auth/operations.js +115 -0
- package/lib/auth/operations.js.map +1 -0
- package/lib/{validate-token.js → auth/validate-token.js} +2 -2
- package/lib/auth/validate-token.js.map +1 -0
- package/lib/blueprint/cache.d.ts +16 -0
- package/lib/blueprint/cache.js +73 -0
- package/lib/blueprint/cache.js.map +1 -0
- package/lib/blueprint/endpoint.d.ts +14 -0
- package/lib/{get-response-key.js → blueprint/endpoint.js} +11 -2
- package/lib/blueprint/endpoint.js.map +1 -0
- package/lib/blueprint/index.d.ts +12 -0
- package/lib/blueprint/index.js +10 -0
- package/lib/blueprint/index.js.map +1 -0
- package/lib/blueprint/source-npm.d.ts +10 -0
- package/lib/{blueprint.js → blueprint/source-npm.js} +20 -74
- package/lib/blueprint/source-npm.js.map +1 -0
- package/lib/blueprint/source-remote.d.ts +6 -0
- package/lib/blueprint/source-remote.js +14 -0
- package/lib/blueprint/source-remote.js.map +1 -0
- package/lib/commands/api-command.d.ts +8 -0
- package/lib/commands/api-command.js +71 -0
- package/lib/commands/api-command.js.map +1 -0
- package/lib/commands/local/completion.d.ts +18 -0
- package/lib/commands/local/completion.js +35 -0
- package/lib/commands/local/completion.js.map +1 -0
- package/lib/commands/local/config-reveal-location.d.ts +2 -0
- package/lib/commands/local/config-reveal-location.js +15 -0
- package/lib/commands/local/config-reveal-location.js.map +1 -0
- package/lib/commands/local/config-set-fake-server.d.ts +3 -0
- package/lib/commands/local/config-set-fake-server.js +20 -0
- package/lib/commands/local/config-set-fake-server.js.map +1 -0
- package/lib/commands/local/config-use-remote-api-defs.d.ts +2 -0
- package/lib/commands/local/config-use-remote-api-defs.js +20 -0
- package/lib/commands/local/config-use-remote-api-defs.js.map +1 -0
- package/lib/commands/local/health.d.ts +2 -0
- package/lib/commands/local/health.js +18 -0
- package/lib/commands/local/health.js.map +1 -0
- package/lib/commands/local/login.d.ts +2 -0
- package/lib/commands/local/login.js +35 -0
- package/lib/commands/local/login.js.map +1 -0
- package/lib/commands/local/logout.d.ts +2 -0
- package/lib/commands/local/logout.js +17 -0
- package/lib/commands/local/logout.js.map +1 -0
- package/lib/commands/local/select-server.d.ts +2 -0
- package/lib/commands/local/select-server.js +27 -0
- package/lib/commands/local/select-server.js.map +1 -0
- package/lib/commands/local/select-workspace.d.ts +2 -0
- package/lib/commands/local/select-workspace.js +22 -0
- package/lib/commands/local/select-workspace.js.map +1 -0
- package/lib/commands/local/wizard.d.ts +9 -0
- package/lib/commands/local/wizard.js +28 -0
- package/lib/commands/local/wizard.js.map +1 -0
- package/lib/commands/registry.d.ts +54 -0
- package/lib/commands/registry.js +64 -0
- package/lib/commands/registry.js.map +1 -0
- package/lib/{command-spec.d.ts → commands/spec.d.ts} +8 -12
- package/lib/{command-spec.js → commands/spec.js} +27 -120
- package/lib/commands/spec.js.map +1 -0
- package/lib/config/config-store.d.ts +23 -8
- package/lib/config/config-store.js +16 -42
- package/lib/config/config-store.js.map +1 -1
- package/lib/config/index.d.ts +2 -1
- package/lib/config/index.js +2 -1
- package/lib/config/index.js.map +1 -1
- package/lib/config/memory-config-store.d.ts +21 -0
- package/lib/config/memory-config-store.js +48 -0
- package/lib/config/memory-config-store.js.map +1 -0
- package/lib/config/migrate.js +1 -1
- package/lib/config/migrate.js.map +1 -1
- package/lib/config/values.d.ts +12 -0
- package/lib/config/values.js +50 -0
- package/lib/config/values.js.map +1 -0
- package/lib/context.d.ts +37 -0
- package/lib/context.js +31 -0
- package/lib/context.js.map +1 -0
- package/lib/env.d.ts +5 -0
- package/lib/env.js +5 -0
- package/lib/env.js.map +1 -1
- package/lib/errors.d.ts +31 -0
- package/lib/errors.js +58 -0
- package/lib/errors.js.map +1 -0
- package/lib/http/api.d.ts +37 -0
- package/lib/http/api.js +20 -0
- package/lib/http/api.js.map +1 -0
- package/lib/http/client.d.ts +4 -0
- package/lib/{get-seam.js → http/client.js} +16 -17
- package/lib/http/client.js.map +1 -0
- package/lib/http/follow-ups.d.ts +6 -0
- package/lib/http/follow-ups.js +30 -0
- package/lib/http/follow-ups.js.map +1 -0
- package/lib/http/memory-seam-api.d.ts +22 -0
- package/lib/http/memory-seam-api.js +41 -0
- package/lib/http/memory-seam-api.js.map +1 -0
- package/lib/http/request.d.ts +19 -0
- package/lib/http/request.js +39 -0
- package/lib/http/request.js.map +1 -0
- package/lib/{interact-for-access-code.js → interactions/access-code.js} +4 -4
- package/lib/interactions/access-code.js.map +1 -0
- package/lib/{interact-for-acs-entrance.js → interactions/acs-entrance.js} +3 -3
- package/lib/interactions/acs-entrance.js.map +1 -0
- package/lib/{interact-for-acs-system.js → interactions/acs-system.js} +3 -3
- package/lib/interactions/acs-system.js.map +1 -0
- package/lib/{interact-for-acs-user.js → interactions/acs-user.js} +4 -4
- package/lib/interactions/acs-user.js.map +1 -0
- package/lib/{interact-for-action-attempt-poll.js → interactions/action-attempt-poll.js} +5 -5
- package/lib/interactions/action-attempt-poll.js.map +1 -0
- package/lib/{interact-for-array.js → interactions/array.js} +4 -3
- package/lib/interactions/array.js.map +1 -0
- package/lib/{interact-for-blueprint-object.d.ts → interactions/blueprint-object.d.ts} +3 -2
- package/lib/{interact-for-blueprint-object.js → interactions/blueprint-object.js} +49 -20
- package/lib/interactions/blueprint-object.js.map +1 -0
- package/lib/{interact-for-command-params.d.ts → interactions/command-params.d.ts} +2 -2
- package/lib/{interact-for-command-params.js → interactions/command-params.js} +4 -3
- package/lib/interactions/command-params.js.map +1 -0
- package/lib/interactions/command-selection.d.ts +10 -0
- package/lib/{interact-for-command-selection.js → interactions/command-selection.js} +9 -15
- package/lib/interactions/command-selection.js.map +1 -0
- package/lib/{interact-for-connected-account.js → interactions/connected-account.js} +3 -3
- package/lib/interactions/connected-account.js.map +1 -0
- package/lib/{interact-for-custom-metadata.js → interactions/custom-metadata.js} +4 -3
- package/lib/interactions/custom-metadata.js.map +1 -0
- package/lib/{interact-for-device.js → interactions/device.js} +3 -3
- package/lib/interactions/device.js.map +1 -0
- package/lib/interactions/index.d.ts +19 -0
- package/lib/interactions/index.js +20 -0
- package/lib/interactions/index.js.map +1 -0
- package/lib/{interact-for-login.js → interactions/login.js} +16 -14
- package/lib/interactions/login.js.map +1 -0
- package/lib/{interact-for-resource.js → interactions/resource.js} +3 -3
- package/lib/interactions/resource.js.map +1 -0
- package/lib/{interact-for-server-selection.js → interactions/server-selection.js} +10 -13
- package/lib/interactions/server-selection.js.map +1 -0
- package/lib/{interact-for-timestamp.js → interactions/timestamp.js} +2 -2
- package/lib/interactions/timestamp.js.map +1 -0
- package/lib/{interact-for-use-remote-api-defs.js → interactions/use-remote-api-defs.js} +5 -6
- package/lib/interactions/use-remote-api-defs.js.map +1 -0
- package/lib/{interact-for-user-identity.js → interactions/user-identity.js} +3 -3
- package/lib/interactions/user-identity.js.map +1 -0
- package/lib/{interact-for-workspace-id.js → interactions/workspace-id.js} +11 -10
- package/lib/interactions/workspace-id.js.map +1 -0
- package/lib/memory-prompt.d.ts +32 -0
- package/lib/memory-prompt.js +41 -0
- package/lib/memory-prompt.js.map +1 -0
- package/lib/output/get-output.d.ts +1 -1
- package/lib/output/get-output.js +1 -1
- package/lib/output/get-output.js.map +1 -1
- package/lib/output/{create-memory-output.d.ts → memory-output.d.ts} +1 -1
- package/lib/output/{create-memory-output.js → memory-output.js} +2 -2
- package/lib/output/memory-output.js.map +1 -0
- package/lib/output/{create-output.d.ts → output.d.ts} +18 -1
- package/lib/output/output.js +46 -0
- package/lib/output/output.js.map +1 -0
- package/lib/output/read-stdin-json.js.map +1 -0
- package/lib/output/resolve-output-format.d.ts +1 -1
- package/lib/{util → output}/with-loading.js +1 -1
- package/lib/output/with-loading.js.map +1 -0
- package/lib/prompt.d.ts +101 -0
- package/lib/{util/prompt.js → prompt.js} +83 -56
- package/lib/prompt.js.map +1 -0
- package/lib/{completion → render/completion}/describe.js +1 -2
- package/lib/render/completion/describe.js.map +1 -0
- package/lib/{completion → render/completion}/index.d.ts +2 -2
- package/lib/{completion → render/completion}/index.js +1 -2
- package/lib/render/completion/index.js.map +1 -0
- package/lib/{completion → render/completion}/render-bash.d.ts +1 -1
- package/lib/{completion → render/completion}/render-bash.js +1 -1
- package/lib/render/completion/render-bash.js.map +1 -0
- package/lib/{completion → render/completion}/render-fish.d.ts +1 -1
- package/lib/render/completion/render-fish.js.map +1 -0
- package/lib/{completion → render/completion}/render-zsh.d.ts +1 -1
- package/lib/{completion → render/completion}/render-zsh.js +1 -1
- package/lib/render/completion/render-zsh.js.map +1 -0
- package/lib/{render-help.d.ts → render/help.d.ts} +1 -1
- package/lib/{render-help.js → render/help.js} +2 -2
- package/lib/render/help.js.map +1 -0
- package/lib/render/text.d.ts +4 -0
- package/lib/render/text.js +16 -0
- package/lib/render/text.js.map +1 -0
- package/lib/version.d.ts +2 -2
- package/lib/version.js +2 -2
- package/package.json +4 -3
- package/src/bin/cli.ts +91 -332
- package/src/lib/args/coerce.ts +164 -0
- package/src/lib/{util/cli-args.ts → args/parse.ts} +30 -25
- package/src/lib/args/validate.ts +73 -0
- package/src/lib/auth/operations.ts +169 -0
- package/src/lib/{validate-token.ts → auth/validate-token.ts} +2 -2
- package/src/lib/blueprint/cache.ts +97 -0
- package/src/lib/{get-response-key.ts → blueprint/endpoint.ts} +17 -3
- package/src/lib/blueprint/index.ts +27 -0
- package/src/lib/{blueprint.ts → blueprint/source-npm.ts} +27 -99
- package/src/lib/blueprint/source-remote.ts +17 -0
- package/src/lib/commands/api-command.ts +109 -0
- package/src/lib/commands/local/completion.ts +51 -0
- package/src/lib/commands/local/config-reveal-location.ts +16 -0
- package/src/lib/commands/local/config-set-fake-server.ts +21 -0
- package/src/lib/commands/local/config-use-remote-api-defs.ts +23 -0
- package/src/lib/commands/local/health.ts +22 -0
- package/src/lib/commands/local/login.ts +42 -0
- package/src/lib/commands/local/logout.ts +18 -0
- package/src/lib/commands/local/select-server.ts +30 -0
- package/src/lib/commands/local/select-workspace.ts +25 -0
- package/src/lib/commands/local/wizard.ts +31 -0
- package/src/lib/commands/registry.ts +127 -0
- package/src/lib/{command-spec.ts → commands/spec.ts} +30 -131
- package/src/lib/config/config-store.ts +39 -64
- package/src/lib/config/index.ts +8 -1
- package/src/lib/config/memory-config-store.ts +62 -0
- package/src/lib/config/migrate.ts +1 -1
- package/src/lib/config/values.ts +72 -0
- package/src/lib/context.ts +84 -0
- package/src/lib/env.ts +9 -2
- package/src/lib/errors.ts +67 -0
- package/src/lib/http/api.ts +61 -0
- package/src/lib/{get-seam.ts → http/client.ts} +19 -18
- package/src/lib/http/follow-ups.ts +42 -0
- package/src/lib/http/memory-seam-api.ts +57 -0
- package/src/lib/http/request.ts +69 -0
- package/src/lib/{interact-for-access-code.ts → interactions/access-code.ts} +4 -3
- package/src/lib/{interact-for-acs-entrance.ts → interactions/acs-entrance.ts} +3 -2
- package/src/lib/{interact-for-acs-system.ts → interactions/acs-system.ts} +3 -2
- package/src/lib/{interact-for-acs-user.ts → interactions/acs-user.ts} +4 -3
- package/src/lib/{interact-for-action-attempt-poll.ts → interactions/action-attempt-poll.ts} +4 -4
- package/src/lib/{interact-for-array.ts → interactions/array.ts} +3 -3
- package/src/lib/{interact-for-blueprint-object.ts → interactions/blueprint-object.ts} +57 -24
- package/src/lib/{interact-for-command-params.ts → interactions/command-params.ts} +6 -4
- package/src/lib/{interact-for-command-selection.ts → interactions/command-selection.ts} +11 -23
- package/src/lib/{interact-for-connected-account.ts → interactions/connected-account.ts} +3 -2
- package/src/lib/{interact-for-custom-metadata.ts → interactions/custom-metadata.ts} +3 -7
- package/src/lib/{interact-for-device.ts → interactions/device.ts} +3 -2
- package/src/lib/interactions/index.ts +19 -0
- package/src/lib/{interact-for-login.ts → interactions/login.ts} +16 -13
- package/src/lib/{interact-for-resource.ts → interactions/resource.ts} +2 -2
- package/src/lib/{interact-for-server-selection.ts → interactions/server-selection.ts} +12 -17
- package/src/lib/{interact-for-timestamp.ts → interactions/timestamp.ts} +1 -1
- package/src/lib/{interact-for-use-remote-api-defs.ts → interactions/use-remote-api-defs.ts} +4 -5
- package/src/lib/{interact-for-user-identity.ts → interactions/user-identity.ts} +3 -2
- package/src/lib/{interact-for-workspace-id.ts → interactions/workspace-id.ts} +10 -17
- package/src/lib/memory-prompt.ts +89 -0
- package/src/lib/output/get-output.ts +1 -1
- package/src/lib/output/{create-memory-output.ts → memory-output.ts} +1 -1
- package/src/lib/output/{create-output.ts → output.ts} +47 -32
- package/src/lib/output/resolve-output-format.ts +1 -1
- package/src/lib/{util → output}/with-loading.ts +1 -1
- package/src/lib/prompt.ts +306 -0
- package/src/lib/{completion → render/completion}/describe.ts +1 -2
- package/src/lib/{completion → render/completion}/index.ts +3 -4
- package/src/lib/{completion → render/completion}/render-bash.ts +1 -1
- package/src/lib/{completion → render/completion}/render-fish.ts +2 -1
- package/src/lib/{completion → render/completion}/render-zsh.ts +2 -1
- package/src/lib/{render-help.ts → render/help.ts} +1 -1
- package/src/lib/render/text.ts +17 -0
- package/src/lib/version.ts +2 -2
- package/lib/blueprint.d.ts +0 -7
- package/lib/blueprint.js.map +0 -1
- package/lib/command-spec.js.map +0 -1
- package/lib/completion/describe.js.map +0 -1
- package/lib/completion/index.js.map +0 -1
- package/lib/completion/render-bash.js.map +0 -1
- package/lib/completion/render-fish.js.map +0 -1
- package/lib/completion/render-zsh.js.map +0 -1
- package/lib/get-api-blueprint.d.ts +0 -6
- package/lib/get-api-blueprint.js +0 -18
- package/lib/get-api-blueprint.js.map +0 -1
- package/lib/get-command-blueprint-def.d.ts +0 -2
- package/lib/get-command-blueprint-def.js +0 -11
- package/lib/get-command-blueprint-def.js.map +0 -1
- package/lib/get-credentials.d.ts +0 -15
- package/lib/get-credentials.js +0 -35
- package/lib/get-credentials.js.map +0 -1
- package/lib/get-current-workspace-id.d.ts +0 -1
- package/lib/get-current-workspace-id.js +0 -9
- package/lib/get-current-workspace-id.js.map +0 -1
- package/lib/get-response-key.d.ts +0 -9
- package/lib/get-response-key.js.map +0 -1
- package/lib/get-seam.d.ts +0 -3
- package/lib/get-seam.js.map +0 -1
- package/lib/get-server.d.ts +0 -6
- package/lib/get-server.js +0 -17
- package/lib/get-server.js.map +0 -1
- package/lib/interact-for-access-code.js.map +0 -1
- package/lib/interact-for-acs-entrance.js.map +0 -1
- package/lib/interact-for-acs-system.js.map +0 -1
- package/lib/interact-for-acs-user.js.map +0 -1
- package/lib/interact-for-action-attempt-poll.js.map +0 -1
- package/lib/interact-for-array.js.map +0 -1
- package/lib/interact-for-blueprint-object.js.map +0 -1
- package/lib/interact-for-command-params.js.map +0 -1
- package/lib/interact-for-command-selection.d.ts +0 -2
- package/lib/interact-for-command-selection.js.map +0 -1
- package/lib/interact-for-connected-account.js.map +0 -1
- package/lib/interact-for-custom-metadata.js.map +0 -1
- package/lib/interact-for-device.js.map +0 -1
- package/lib/interact-for-login.js.map +0 -1
- package/lib/interact-for-resource.js.map +0 -1
- package/lib/interact-for-server-selection.js.map +0 -1
- package/lib/interact-for-timestamp.js.map +0 -1
- package/lib/interact-for-use-remote-api-defs.js.map +0 -1
- package/lib/interact-for-user-identity.js.map +0 -1
- package/lib/interact-for-workspace-id.js.map +0 -1
- package/lib/output/create-memory-output.js.map +0 -1
- package/lib/output/create-output.js +0 -34
- package/lib/output/create-output.js.map +0 -1
- package/lib/render-help.js.map +0 -1
- package/lib/types.d.ts +0 -6
- package/lib/types.js +0 -2
- package/lib/types.js.map +0 -1
- package/lib/util/cli-args.js.map +0 -1
- package/lib/util/ellipsis.d.ts +0 -1
- package/lib/util/ellipsis.js +0 -6
- package/lib/util/ellipsis.js.map +0 -1
- package/lib/util/prompt.d.ts +0 -80
- package/lib/util/prompt.js.map +0 -1
- package/lib/util/read-stdin-json.js.map +0 -1
- package/lib/util/request-seam-api.d.ts +0 -7
- package/lib/util/request-seam-api.js +0 -26
- package/lib/util/request-seam-api.js.map +0 -1
- package/lib/util/with-loading.js.map +0 -1
- package/lib/validate-token.js.map +0 -1
- package/src/lib/get-api-blueprint.ts +0 -31
- package/src/lib/get-command-blueprint-def.ts +0 -15
- package/src/lib/get-credentials.ts +0 -38
- package/src/lib/get-current-workspace-id.ts +0 -9
- package/src/lib/get-server.ts +0 -20
- package/src/lib/types.ts +0 -7
- package/src/lib/util/ellipsis.ts +0 -4
- package/src/lib/util/prompt.ts +0 -229
- package/src/lib/util/request-seam-api.ts +0 -47
- /package/lib/{validate-token.d.ts → auth/validate-token.d.ts} +0 -0
- /package/lib/{interact-for-access-code.d.ts → interactions/access-code.d.ts} +0 -0
- /package/lib/{interact-for-acs-entrance.d.ts → interactions/acs-entrance.d.ts} +0 -0
- /package/lib/{interact-for-acs-system.d.ts → interactions/acs-system.d.ts} +0 -0
- /package/lib/{interact-for-acs-user.d.ts → interactions/acs-user.d.ts} +0 -0
- /package/lib/{interact-for-action-attempt-poll.d.ts → interactions/action-attempt-poll.d.ts} +0 -0
- /package/lib/{interact-for-array.d.ts → interactions/array.d.ts} +0 -0
- /package/lib/{interact-for-connected-account.d.ts → interactions/connected-account.d.ts} +0 -0
- /package/lib/{interact-for-custom-metadata.d.ts → interactions/custom-metadata.d.ts} +0 -0
- /package/lib/{interact-for-device.d.ts → interactions/device.d.ts} +0 -0
- /package/lib/{interact-for-login.d.ts → interactions/login.d.ts} +0 -0
- /package/lib/{interact-for-resource.d.ts → interactions/resource.d.ts} +0 -0
- /package/lib/{interact-for-server-selection.d.ts → interactions/server-selection.d.ts} +0 -0
- /package/lib/{interact-for-timestamp.d.ts → interactions/timestamp.d.ts} +0 -0
- /package/lib/{interact-for-use-remote-api-defs.d.ts → interactions/use-remote-api-defs.d.ts} +0 -0
- /package/lib/{interact-for-user-identity.d.ts → interactions/user-identity.d.ts} +0 -0
- /package/lib/{interact-for-workspace-id.d.ts → interactions/workspace-id.d.ts} +0 -0
- /package/lib/{util → output}/read-stdin-json.d.ts +0 -0
- /package/lib/{util → output}/read-stdin-json.js +0 -0
- /package/lib/{util → output}/with-loading.d.ts +0 -0
- /package/lib/{completion → render/completion}/describe.d.ts +0 -0
- /package/lib/{completion → render/completion}/render-fish.js +0 -0
- /package/src/lib/{util → output}/read-stdin-json.ts +0 -0
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import type { ParsedArgs } from 'minimist';
|
|
2
|
+
import type { ApiBlueprint } from '../blueprint/index.js';
|
|
3
|
+
import type { CliContext } from '../context.js';
|
|
4
|
+
import { type CommandDefinition, type CommandSpec } from './spec.js';
|
|
5
|
+
/**
|
|
6
|
+
* One invocable command: what it looks like to help, completion, and the
|
|
7
|
+
* interactive picker, whether it needs a login, and how to run it. Declaring
|
|
8
|
+
* the metadata and the executor together is what keeps them from drifting.
|
|
9
|
+
*/
|
|
10
|
+
export interface Command {
|
|
11
|
+
definition: CommandDefinition;
|
|
12
|
+
/** Whether the command needs a token before it can do anything. */
|
|
13
|
+
requiresAuth: boolean;
|
|
14
|
+
/** Kept out of the spec, so out of help, completion, and the picker. */
|
|
15
|
+
hidden?: boolean;
|
|
16
|
+
execute: (invocation: Invocation, ctx: CliContext) => Promise<CommandResult>;
|
|
17
|
+
}
|
|
18
|
+
/** Everything a single run of a command was given. */
|
|
19
|
+
export interface Invocation {
|
|
20
|
+
path: string[];
|
|
21
|
+
/** Params given as arguments, held to what the command accepts. */
|
|
22
|
+
argParams: Record<string, unknown>;
|
|
23
|
+
/** Params piped in as JSON, passed through as given. */
|
|
24
|
+
stdinParams: Record<string, unknown>;
|
|
25
|
+
/** The full parsed arguments, for commands that read their own flags. */
|
|
26
|
+
args: ParsedArgs;
|
|
27
|
+
/** The raw argv, for commands that re-read arguments with their own types. */
|
|
28
|
+
argv: string[];
|
|
29
|
+
}
|
|
30
|
+
export type CommandResult = {
|
|
31
|
+
kind: 'done';
|
|
32
|
+
}
|
|
33
|
+
/** Navigate back to selecting a command under `toPath`. */
|
|
34
|
+
| {
|
|
35
|
+
kind: 'back';
|
|
36
|
+
toPath: string[];
|
|
37
|
+
};
|
|
38
|
+
export interface CommandRegistry {
|
|
39
|
+
/** The spec help, completion, and the interactive picker render. */
|
|
40
|
+
spec: CommandSpec;
|
|
41
|
+
find: (path: string[]) => Command | undefined;
|
|
42
|
+
}
|
|
43
|
+
export declare const localCommands: Command[];
|
|
44
|
+
/** Definitions shown in help, completion, and the picker. */
|
|
45
|
+
export declare const localCommandDefinitions: CommandDefinition[];
|
|
46
|
+
/**
|
|
47
|
+
* The local command going by a path, or `undefined` when the path is an
|
|
48
|
+
* endpoint or no command at all. Needs no blueprint, so the entry may check
|
|
49
|
+
* commands before any definitions are loaded.
|
|
50
|
+
*/
|
|
51
|
+
export declare const findLocalCommand: (path: string[]) => Command | undefined;
|
|
52
|
+
/** Parameter names a command accepts as arguments. */
|
|
53
|
+
export declare const acceptedParamsOf: (definition: CommandDefinition) => Set<string>;
|
|
54
|
+
export declare const buildRegistry: (blueprint: ApiBlueprint) => CommandRegistry;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { toParameterName } from '../args/parse.js';
|
|
2
|
+
import { executeApiCommand } from './api-command.js';
|
|
3
|
+
import { createCompletionCommands } from './local/completion.js';
|
|
4
|
+
import { configRevealLocationCommand } from './local/config-reveal-location.js';
|
|
5
|
+
import { configSetFakeServerCommand } from './local/config-set-fake-server.js';
|
|
6
|
+
import { configUseRemoteApiDefsCommand } from './local/config-use-remote-api-defs.js';
|
|
7
|
+
import { healthCommand } from './local/health.js';
|
|
8
|
+
import { loginCommand } from './local/login.js';
|
|
9
|
+
import { logoutCommand } from './local/logout.js';
|
|
10
|
+
import { selectServerCommand } from './local/select-server.js';
|
|
11
|
+
import { selectWorkspaceCommand } from './local/select-workspace.js';
|
|
12
|
+
import { wizardCommand } from './local/wizard.js';
|
|
13
|
+
import { getCommandSpec, isSamePath, } from './spec.js';
|
|
14
|
+
/**
|
|
15
|
+
* Commands handled by the CLI itself, which have no endpoint in the
|
|
16
|
+
* blueprint. The single source of truth: the spec, the picker, and the
|
|
17
|
+
* dispatcher all consume this list.
|
|
18
|
+
*/
|
|
19
|
+
const completionCommands = createCompletionCommands((blueprint) => buildRegistry(blueprint).spec);
|
|
20
|
+
export const localCommands = [
|
|
21
|
+
...completionCommands,
|
|
22
|
+
configRevealLocationCommand,
|
|
23
|
+
configSetFakeServerCommand,
|
|
24
|
+
configUseRemoteApiDefsCommand,
|
|
25
|
+
healthCommand,
|
|
26
|
+
loginCommand,
|
|
27
|
+
logoutCommand,
|
|
28
|
+
selectServerCommand,
|
|
29
|
+
selectWorkspaceCommand,
|
|
30
|
+
wizardCommand,
|
|
31
|
+
];
|
|
32
|
+
/** Definitions shown in help, completion, and the picker. */
|
|
33
|
+
export const localCommandDefinitions = localCommands
|
|
34
|
+
.filter((command) => command.hidden !== true)
|
|
35
|
+
.map((command) => command.definition);
|
|
36
|
+
/**
|
|
37
|
+
* The local command going by a path, or `undefined` when the path is an
|
|
38
|
+
* endpoint or no command at all. Needs no blueprint, so the entry may check
|
|
39
|
+
* commands before any definitions are loaded.
|
|
40
|
+
*/
|
|
41
|
+
export const findLocalCommand = (path) => localCommands.find((command) => isSamePath(command.definition.path, path));
|
|
42
|
+
/** Parameter names a command accepts as arguments. */
|
|
43
|
+
export const acceptedParamsOf = (definition) => new Set(definition.flags.flatMap(({ long }) => long == null ? [] : [toParameterName(long)]));
|
|
44
|
+
export const buildRegistry = (blueprint) => {
|
|
45
|
+
const spec = getCommandSpec(blueprint, localCommandDefinitions);
|
|
46
|
+
const commands = new Map();
|
|
47
|
+
for (const definition of spec.commands) {
|
|
48
|
+
commands.set(definition.path.join(' '), {
|
|
49
|
+
definition,
|
|
50
|
+
requiresAuth: true,
|
|
51
|
+
execute: executeApiCommand,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
// Local commands win over a same-named endpoint, as the spec's dedupe does,
|
|
55
|
+
// and hidden ones are findable without being in the spec.
|
|
56
|
+
for (const command of localCommands) {
|
|
57
|
+
commands.set(command.definition.path.join(' '), command);
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
spec,
|
|
61
|
+
find: (path) => commands.get(path.join(' ')),
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=registry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/lib/commands/registry.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAInD,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAA;AACpD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAChE,OAAO,EAAE,2BAA2B,EAAE,MAAM,mCAAmC,CAAA;AAC/E,OAAO,EAAE,0BAA0B,EAAE,MAAM,mCAAmC,CAAA;AAC9E,OAAO,EAAE,6BAA6B,EAAE,MAAM,uCAAuC,CAAA;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAC/C,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAA;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAA;AACjD,OAAO,EAGL,cAAc,EACd,UAAU,GACX,MAAM,WAAW,CAAA;AAwClB;;;;GAIG;AACH,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AM,UAAU,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;QACvC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;YACtC,UAAU;YACV,YAAY,EAAE,IAAI;YAClB,OAAO,EAAE,iBAAiB;SAC3B,CAAC,CAAA;IACJ,CAAC;IACD,4EAA4E;IAC5E,0DAA0D;IAC1D,KAAK,MAAM,OAAO,IAAI,aAAa,EAAE,CAAC;QACpC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC,CAAA;IAC1D,CAAC;IAED,OAAO;QACL,IAAI;QACJ,IAAI,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KAC7C,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -45,17 +45,13 @@ export interface CommandSpec {
|
|
|
45
45
|
}
|
|
46
46
|
export declare const globalFlags: CommandFlag[];
|
|
47
47
|
export declare const flagTokens: (flag: CommandFlag) => string[];
|
|
48
|
-
export declare const getCommandSpec: (blueprint: Blueprint) => CommandSpec;
|
|
49
|
-
export declare const findCommand: (spec: CommandSpec, path: string[]) => CommandDefinition | undefined;
|
|
50
|
-
export declare const findGroup: (spec: CommandSpec, path: string[]) => CommandGroup | undefined;
|
|
51
48
|
/**
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
* Unlike {@link findCommand} this needs no blueprint, since these commands are
|
|
56
|
-
* declared by the CLI rather than derived from the API definitions.
|
|
49
|
+
* Derive the command spec from the API definitions, merged with the commands
|
|
50
|
+
* the CLI declares itself (see `commands/registry.ts`, the single source of
|
|
51
|
+
* those declarations).
|
|
57
52
|
*/
|
|
58
|
-
export declare const
|
|
59
|
-
|
|
60
|
-
export declare const
|
|
61
|
-
export declare const
|
|
53
|
+
export declare const getCommandSpec: (blueprint: Blueprint, localCommands?: CommandDefinition[]) => CommandSpec;
|
|
54
|
+
export declare const findCommand: (spec: CommandSpec, path: string[]) => CommandDefinition | undefined;
|
|
55
|
+
export declare const findGroup: (spec: CommandSpec, path: string[]) => CommandGroup | undefined;
|
|
56
|
+
export declare const isSamePath: (a: string[], b: string[]) => boolean;
|
|
57
|
+
export declare const stringFlag: (long: string, description: string) => CommandFlag;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { firstSentence, toPlainText } from '../render/text.js';
|
|
1
2
|
export const globalFlags = [
|
|
2
3
|
{
|
|
3
4
|
long: 'help',
|
|
@@ -64,7 +65,12 @@ export const flagTokens = (flag) => {
|
|
|
64
65
|
tokens.push(`-${flag.short}`);
|
|
65
66
|
return tokens;
|
|
66
67
|
};
|
|
67
|
-
|
|
68
|
+
/**
|
|
69
|
+
* Derive the command spec from the API definitions, merged with the commands
|
|
70
|
+
* the CLI declares itself (see `commands/registry.ts`, the single source of
|
|
71
|
+
* those declarations).
|
|
72
|
+
*/
|
|
73
|
+
export const getCommandSpec = (blueprint, localCommands = []) => {
|
|
68
74
|
const commands = sortByPath(dedupeByPath([
|
|
69
75
|
...blueprint.routes
|
|
70
76
|
.flatMap((route) => route.endpoints)
|
|
@@ -79,16 +85,8 @@ export const getCommandSpec = (blueprint) => {
|
|
|
79
85
|
};
|
|
80
86
|
export const findCommand = (spec, path) => spec.commands.find((command) => isSamePath(command.path, path));
|
|
81
87
|
export const findGroup = (spec, path) => spec.groups.find((group) => isSamePath(group.path, path));
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
* path is an endpoint or no command at all.
|
|
85
|
-
*
|
|
86
|
-
* Unlike {@link findCommand} this needs no blueprint, since these commands are
|
|
87
|
-
* declared by the CLI rather than derived from the API definitions.
|
|
88
|
-
*/
|
|
89
|
-
export const findLocalCommand = (path) => localCommands.find((command) => isSamePath(command.path, path));
|
|
90
|
-
const isSamePath = (a, b) => a.length === b.length && a.every((word, index) => word === b[index]);
|
|
91
|
-
const stringFlag = (long, description) => ({
|
|
88
|
+
export const isSamePath = (a, b) => a.length === b.length && a.every((word, index) => word === b[index]);
|
|
89
|
+
export const stringFlag = (long, description) => ({
|
|
92
90
|
long,
|
|
93
91
|
short: null,
|
|
94
92
|
description,
|
|
@@ -96,95 +94,6 @@ const stringFlag = (long, description) => ({
|
|
|
96
94
|
takesValue: true,
|
|
97
95
|
isRequired: false,
|
|
98
96
|
});
|
|
99
|
-
/**
|
|
100
|
-
* Commands handled by the CLI itself, which have no endpoint in the blueprint.
|
|
101
|
-
*
|
|
102
|
-
* Keep in sync with the command handling in `src/bin/cli.ts` and the extra
|
|
103
|
-
* commands offered by `interactForCommandSelection`.
|
|
104
|
-
*/
|
|
105
|
-
const localCommands = [
|
|
106
|
-
{
|
|
107
|
-
path: ['completion', 'bash'],
|
|
108
|
-
kind: 'cli',
|
|
109
|
-
title: 'Print the bash completion script.',
|
|
110
|
-
description: '',
|
|
111
|
-
flags: [],
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
path: ['completion', 'fish'],
|
|
115
|
-
kind: 'cli',
|
|
116
|
-
title: 'Print the fish completion script.',
|
|
117
|
-
description: '',
|
|
118
|
-
flags: [],
|
|
119
|
-
},
|
|
120
|
-
{
|
|
121
|
-
path: ['completion', 'zsh'],
|
|
122
|
-
kind: 'cli',
|
|
123
|
-
title: 'Print the zsh completion script.',
|
|
124
|
-
description: '',
|
|
125
|
-
flags: [],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
path: ['config', 'reveal-location'],
|
|
129
|
-
kind: 'cli',
|
|
130
|
-
title: 'Print the path to the CLI configuration file.',
|
|
131
|
-
description: '',
|
|
132
|
-
flags: [],
|
|
133
|
-
},
|
|
134
|
-
{
|
|
135
|
-
path: ['config', 'use-remote-api-defs'],
|
|
136
|
-
kind: 'cli',
|
|
137
|
-
title: 'Choose whether to use the API definitions served by Seam.',
|
|
138
|
-
description: '',
|
|
139
|
-
flags: [],
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
path: ['health', 'get-health'],
|
|
143
|
-
kind: 'api',
|
|
144
|
-
title: 'Report the health of the Seam API.',
|
|
145
|
-
description: '',
|
|
146
|
-
flags: [],
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
path: ['login'],
|
|
150
|
-
kind: 'cli',
|
|
151
|
-
title: 'Log in to Seam.',
|
|
152
|
-
description: 'Prompts for a personal access token unless one is passed with --token.',
|
|
153
|
-
flags: [
|
|
154
|
-
stringFlag('server', 'Seam API server to log in to.'),
|
|
155
|
-
stringFlag('token', 'Personal access token to log in with.'),
|
|
156
|
-
stringFlag('workspace-id', 'Workspace to select after logging in.'),
|
|
157
|
-
],
|
|
158
|
-
},
|
|
159
|
-
{
|
|
160
|
-
path: ['logout'],
|
|
161
|
-
kind: 'cli',
|
|
162
|
-
title: 'Log out of Seam.',
|
|
163
|
-
description: '',
|
|
164
|
-
flags: [],
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
path: ['select', 'server'],
|
|
168
|
-
kind: 'cli',
|
|
169
|
-
title: 'Select the Seam API server.',
|
|
170
|
-
description: '',
|
|
171
|
-
flags: [stringFlag('server', 'Seam API server to select.')],
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
path: ['select', 'workspace'],
|
|
175
|
-
kind: 'cli',
|
|
176
|
-
title: 'Select the current workspace.',
|
|
177
|
-
description: '',
|
|
178
|
-
flags: [],
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
path: ['wizard'],
|
|
182
|
-
kind: 'cli',
|
|
183
|
-
title: 'Set up Seam in the current project.',
|
|
184
|
-
description: 'Takes a project from zero to a working Seam integration. Run seam wizard --help for its own options.',
|
|
185
|
-
flags: [],
|
|
186
|
-
},
|
|
187
|
-
];
|
|
188
97
|
const toCommandDefinition = (endpoint) => {
|
|
189
98
|
const description = toPlainText(endpoint.description);
|
|
190
99
|
return {
|
|
@@ -209,17 +118,21 @@ const toCommandFlag = (parameter) => ({
|
|
|
209
118
|
isRequired: parameter.isRequired,
|
|
210
119
|
});
|
|
211
120
|
const toFlagValues = (parameter) => {
|
|
121
|
+
let values = [];
|
|
212
122
|
if (parameter.format === 'enum') {
|
|
213
|
-
|
|
123
|
+
values = parameter.values.map(({ name }) => name).filter(isSafeToken);
|
|
214
124
|
}
|
|
215
|
-
if (parameter.format === 'list' && parameter.itemFormat === 'enum') {
|
|
216
|
-
|
|
125
|
+
else if (parameter.format === 'list' && parameter.itemFormat === 'enum') {
|
|
126
|
+
values = parameter.itemEnumValues
|
|
127
|
+
.map(({ name }) => name)
|
|
128
|
+
.filter(isSafeToken);
|
|
217
129
|
}
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
130
|
+
else if (parameter.format === 'boolean') {
|
|
131
|
+
// Nothing marks parameters as boolean-only flags, so minimist reads the
|
|
132
|
+
// next argument as the value.
|
|
133
|
+
values = ['true', 'false'];
|
|
134
|
+
}
|
|
135
|
+
return parameter.isNullable ? [...values, 'null'] : values;
|
|
223
136
|
};
|
|
224
137
|
/**
|
|
225
138
|
* Whether a word is safe to write into a shell script. Command, flag, and
|
|
@@ -241,7 +154,11 @@ const toCommandGroups = (commands) => {
|
|
|
241
154
|
// `seam devices` alongside `seam devices list`. Prefer the command
|
|
242
155
|
// title, since it describes what running the name does.
|
|
243
156
|
if (depth === command.path.length - 1) {
|
|
244
|
-
entries.set(name, {
|
|
157
|
+
entries.set(name, {
|
|
158
|
+
isCommand: true,
|
|
159
|
+
kind,
|
|
160
|
+
description: command.title,
|
|
161
|
+
});
|
|
245
162
|
continue;
|
|
246
163
|
}
|
|
247
164
|
const entry = entries.get(name);
|
|
@@ -285,14 +202,4 @@ const sortByPath = (commands) => [...commands].sort((a, b) => compare(a.path.joi
|
|
|
285
202
|
const compare = (a, b) => (a ?? '') < (b ?? '') ? -1 : (a ?? '') > (b ?? '') ? 1 : 0;
|
|
286
203
|
const toCommandPath = (path) => path.replace(/^\//, '').split('/').map(toFlagName);
|
|
287
204
|
const toFlagName = (name) => name.replace(/_/g, '-');
|
|
288
|
-
|
|
289
|
-
export const toPlainText = (markdown) => markdown
|
|
290
|
-
.replace(/\[([^\]]*)\]\([^)]*\)/g, '$1')
|
|
291
|
-
.replace(/[`*]/g, '')
|
|
292
|
-
.replace(/\s+/g, ' ')
|
|
293
|
-
.trim();
|
|
294
|
-
export const firstSentence = (text) => {
|
|
295
|
-
const [sentence] = text.split(/(?<=\.)\s/);
|
|
296
|
-
return sentence ?? text;
|
|
297
|
-
};
|
|
298
|
-
//# sourceMappingURL=command-spec.js.map
|
|
205
|
+
//# sourceMappingURL=spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"spec.js","sourceRoot":"","sources":["../../src/lib/commands/spec.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAA;AAuD/D,MAAM,CAAC,MAAM,WAAW,GAAkB;IACxC;QACE,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,GAAG;QACV,WAAW,EAAE,0BAA0B;QACvC,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,KAAK;KAClB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,GAAG;QACV,WAAW,EACT,kFAAkF;QACpF,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,KAAK;KAClB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,IAAI;QACX,WAAW,EACT,oHAAoH;QACtH,MAAM,EAAE,EAAE;QACV,UAAU,EAAE,KAAK;QACjB,UAAU,EAAE,KAAK;KAClB;IACD;QACE,IAAI,EAAE,iBAAiB;QACvB,KAAK,EAAE,GAAG;QACV,WAAW,EACT,sFAAsF;QACxF,MAAM,EAAE,EAAE;QACV,UAA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,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAA;AAE3E,MAAM,OAAO,GAAG,CAAC,CAAgB,EAAE,CAAgB,EAAU,EAAE,CAC7D,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;AAE5D,MAAM,aAAa,GAAG,CAAC,IAAY,EAAY,EAAE,CAC/C,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,CAAC,UAAU,CAAC,CAAA;AAEpD,MAAM,UAAU,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA"}
|
|
@@ -1,11 +1,27 @@
|
|
|
1
1
|
import Configstore from 'configstore';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
/**
|
|
3
|
+
* What a config store can do, regardless of where it keeps the values.
|
|
4
|
+
*
|
|
5
|
+
* The CLI reads and writes through this interface so a test may hand code an
|
|
6
|
+
* in-memory store (see `memory-config-store.ts`) instead of the real
|
|
7
|
+
* file-backed one.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConfigStore {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
all: Record<string, unknown>;
|
|
12
|
+
readonly size: number;
|
|
13
|
+
get: (key: string) => unknown;
|
|
14
|
+
set: (key: string | Record<string, unknown>, value?: unknown) => void;
|
|
15
|
+
has: (key: string) => boolean;
|
|
16
|
+
delete: (key: string) => void;
|
|
17
|
+
clear: () => void;
|
|
18
|
+
}
|
|
19
|
+
export declare const getConfigStore: () => ConfigStore;
|
|
20
|
+
/** Replace the store, e.g., with an in-memory one for a test. */
|
|
21
|
+
export declare const setConfigStore: (store: ConfigStore) => void;
|
|
22
|
+
/** Drop the current store so the next read builds the real one. */
|
|
23
|
+
export declare const resetConfigStore: () => void;
|
|
24
|
+
export declare class PersistentConfigStore implements ConfigStore {
|
|
9
25
|
private readonly settingsStore;
|
|
10
26
|
private readonly stateStore;
|
|
11
27
|
readonly path: string;
|
|
@@ -20,4 +36,3 @@ declare class SeamConfigStore {
|
|
|
20
36
|
clear(): void;
|
|
21
37
|
private getStore;
|
|
22
38
|
}
|
|
23
|
-
export {};
|
|
@@ -2,12 +2,24 @@ import { join } from 'node:path';
|
|
|
2
2
|
import Configstore from 'configstore';
|
|
3
3
|
import envPaths from 'env-paths';
|
|
4
4
|
import { migrateConfigStore } from './migrate.js';
|
|
5
|
+
import { isStateKey, mergeConfig, splitConfig } from './values.js';
|
|
5
6
|
const configFileName = 'cli.json';
|
|
6
7
|
const legacyConfigStoreId = 'seam-cli';
|
|
7
|
-
const currentWorkspaceIdKey = 'current_workspace_id';
|
|
8
|
-
const patKey = 'pat';
|
|
9
8
|
const paths = envPaths('seam', { suffix: '' });
|
|
9
|
+
let configStore = null;
|
|
10
10
|
export const getConfigStore = () => {
|
|
11
|
+
configStore ??= createConfigStore();
|
|
12
|
+
return configStore;
|
|
13
|
+
};
|
|
14
|
+
/** Replace the store, e.g., with an in-memory one for a test. */
|
|
15
|
+
export const setConfigStore = (store) => {
|
|
16
|
+
configStore = store;
|
|
17
|
+
};
|
|
18
|
+
/** Drop the current store so the next read builds the real one. */
|
|
19
|
+
export const resetConfigStore = () => {
|
|
20
|
+
configStore = null;
|
|
21
|
+
};
|
|
22
|
+
const createConfigStore = () => {
|
|
11
23
|
const settingsStore = new Configstore(legacyConfigStoreId, undefined, {
|
|
12
24
|
configPath: getConfigPath(),
|
|
13
25
|
});
|
|
@@ -15,42 +27,9 @@ export const getConfigStore = () => {
|
|
|
15
27
|
configPath: getStateConfigPath(),
|
|
16
28
|
});
|
|
17
29
|
migrateConfigStore(settingsStore, stateStore, new Configstore(legacyConfigStoreId));
|
|
18
|
-
return new
|
|
19
|
-
};
|
|
20
|
-
export const mergeConfig = (baseConfig, overrideConfig) => {
|
|
21
|
-
const mergedConfig = { ...baseConfig };
|
|
22
|
-
for (const [key, value] of Object.entries(overrideConfig)) {
|
|
23
|
-
const baseValue = mergedConfig[key];
|
|
24
|
-
mergedConfig[key] =
|
|
25
|
-
isRecord(baseValue) && isRecord(value)
|
|
26
|
-
? mergeConfig(baseValue, value)
|
|
27
|
-
: value;
|
|
28
|
-
}
|
|
29
|
-
return mergedConfig;
|
|
30
|
-
};
|
|
31
|
-
export const splitConfig = (config) => {
|
|
32
|
-
const settings = {};
|
|
33
|
-
const state = {};
|
|
34
|
-
for (const [key, value] of Object.entries(config)) {
|
|
35
|
-
if (isStateKey(key)) {
|
|
36
|
-
state[key] = value;
|
|
37
|
-
continue;
|
|
38
|
-
}
|
|
39
|
-
if (isRecord(value)) {
|
|
40
|
-
const splitValue = splitConfig(value);
|
|
41
|
-
if (Object.keys(splitValue.settings).length > 0) {
|
|
42
|
-
settings[key] = splitValue.settings;
|
|
43
|
-
}
|
|
44
|
-
if (Object.keys(splitValue.state).length > 0) {
|
|
45
|
-
state[key] = splitValue.state;
|
|
46
|
-
}
|
|
47
|
-
continue;
|
|
48
|
-
}
|
|
49
|
-
settings[key] = value;
|
|
50
|
-
}
|
|
51
|
-
return { settings, state };
|
|
30
|
+
return new PersistentConfigStore(settingsStore, stateStore);
|
|
52
31
|
};
|
|
53
|
-
class
|
|
32
|
+
export class PersistentConfigStore {
|
|
54
33
|
settingsStore;
|
|
55
34
|
stateStore;
|
|
56
35
|
path;
|
|
@@ -102,11 +81,6 @@ const getConfigPath = () => {
|
|
|
102
81
|
const getStateConfigPath = () => {
|
|
103
82
|
return join(paths.log, configFileName);
|
|
104
83
|
};
|
|
105
|
-
const isStateKey = (key) => {
|
|
106
|
-
return (key === currentWorkspaceIdKey ||
|
|
107
|
-
key === patKey ||
|
|
108
|
-
key.endsWith(`.${patKey}`));
|
|
109
|
-
};
|
|
110
84
|
const isRecord = (value) => {
|
|
111
85
|
return value != null && typeof value === 'object' && !Array.isArray(value);
|
|
112
86
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/lib/config/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"config-store.js","sourceRoot":"","sources":["../../src/lib/config/config-store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,WAAW,MAAM,aAAa,CAAA;AACrC,OAAO,QAAQ,MAAM,WAAW,CAAA;AAEhC,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAElE,MAAM,cAAc,GAAG,UAAU,CAAA;AACjC,MAAM,mBAAmB,GAAG,UAAU,CAAA;AACtC,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAA;AAoB9C,IAAI,WAAW,GAAuB,IAAI,CAAA;AAE1C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAgB,EAAE;IAC9C,WAAW,KAAK,iBAAiB,EAAE,CAAA;IACnC,OA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AI,CAAC,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;AAC3C,CAAC,CAAA;AAED,MAAM,kBAAkB,GAAG,GAAW,EAAE;IACtC,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,cAAc,CAAC,CAAA;AACxC,CAAC,CAAA;AAED,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE;IACpE,OAAO,KAAK,IAAI,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC5E,CAAC,CAAA"}
|
package/lib/config/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { getConfigStore } from './config-store.js';
|
|
1
|
+
export { type ConfigStore, getConfigStore, type PersistentConfigStore, resetConfigStore, setConfigStore, } from './config-store.js';
|
|
2
|
+
export { createMemoryConfigStore } from './memory-config-store.js';
|
package/lib/config/index.js
CHANGED
package/lib/config/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/lib/config/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,cAAc,EAEd,gBAAgB,EAChB,cAAc,GACf,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ConfigStore } from './config-store.js';
|
|
2
|
+
/**
|
|
3
|
+
* A real {@link ConfigStore} held in memory, for tests.
|
|
4
|
+
*
|
|
5
|
+
* Keys are flat: the file-backed store nests dotted keys, but nothing reads
|
|
6
|
+
* a value back by a different spelling than it was written with.
|
|
7
|
+
*/
|
|
8
|
+
export declare class MemoryConfigStore implements ConfigStore {
|
|
9
|
+
readonly path = "/memory/cli.json";
|
|
10
|
+
private readonly values;
|
|
11
|
+
constructor(initialValues?: Record<string, unknown>);
|
|
12
|
+
get all(): Record<string, unknown>;
|
|
13
|
+
set all(newValues: Record<string, unknown>);
|
|
14
|
+
get size(): number;
|
|
15
|
+
get(key: string): unknown;
|
|
16
|
+
set(key: string | Record<string, unknown>, value?: unknown): void;
|
|
17
|
+
has(key: string): boolean;
|
|
18
|
+
delete(key: string): void;
|
|
19
|
+
clear(): void;
|
|
20
|
+
}
|
|
21
|
+
export declare const createMemoryConfigStore: (initialValues?: Record<string, unknown>) => ConfigStore;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A real {@link ConfigStore} held in memory, for tests.
|
|
3
|
+
*
|
|
4
|
+
* Keys are flat: the file-backed store nests dotted keys, but nothing reads
|
|
5
|
+
* a value back by a different spelling than it was written with.
|
|
6
|
+
*/
|
|
7
|
+
export class MemoryConfigStore {
|
|
8
|
+
path = '/memory/cli.json';
|
|
9
|
+
values;
|
|
10
|
+
constructor(initialValues = {}) {
|
|
11
|
+
this.values = new Map(Object.entries(initialValues));
|
|
12
|
+
}
|
|
13
|
+
get all() {
|
|
14
|
+
return Object.fromEntries(this.values);
|
|
15
|
+
}
|
|
16
|
+
set all(newValues) {
|
|
17
|
+
this.values.clear();
|
|
18
|
+
for (const [key, value] of Object.entries(newValues)) {
|
|
19
|
+
this.values.set(key, value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
get size() {
|
|
23
|
+
return this.values.size;
|
|
24
|
+
}
|
|
25
|
+
get(key) {
|
|
26
|
+
return this.values.get(key);
|
|
27
|
+
}
|
|
28
|
+
set(key, value) {
|
|
29
|
+
if (typeof key === 'string') {
|
|
30
|
+
this.values.set(key, value);
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
for (const [configKey, configValue] of Object.entries(key)) {
|
|
34
|
+
this.values.set(configKey, configValue);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
has(key) {
|
|
38
|
+
return this.values.has(key);
|
|
39
|
+
}
|
|
40
|
+
delete(key) {
|
|
41
|
+
this.values.delete(key);
|
|
42
|
+
}
|
|
43
|
+
clear() {
|
|
44
|
+
this.values.clear();
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export const createMemoryConfigStore = (initialValues = {}) => new MemoryConfigStore(initialValues);
|
|
48
|
+
//# sourceMappingURL=memory-config-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-config-store.js","sourceRoot":"","sources":["../../src/lib/config/memory-config-store.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,OAAO,iBAAiB;IACnB,IAAI,GAAG,kBAAkB,CAAA;IAEjB,MAAM,CAAsB;IAE7C,YAAY,gBAAyC,EAAE;QACrD,IAAI,CAAC,MAAM,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAA;IACtD,CAAC;IAED,IAAI,GAAG;QACL,OAAO,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;IACxC,CAAC;IAED,IAAI,GAAG,CAAC,SAAkC;QACxC,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;QACnB,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC;YACrD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QAC7B,CAAC;IACH,CAAC;IAED,IAAI,IAAI;QACN,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA;IACzB,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,GAAG,CAAC,GAAqC,EAAE,KAAe;QACxD,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YAC5B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;YAC3B,OAAM;QACR,CAAC;QACD,KAAK,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAC3D,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,WAAW,CAAC,CAAA;QACzC,CAAC;IACH,CAAC;IAED,GAAG,CAAC,GAAW;QACb,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,MAAM,CAAC,GAAW;QAChB,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;IACzB,CAAC;IAED,KAAK;QACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAA;IACrB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,gBAAyC,EAAE,EAC9B,EAAE,CAAC,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAA"}
|
package/lib/config/migrate.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { existsSync, rmSync } from 'node:fs';
|
|
2
|
-
import { mergeConfig, splitConfig } from './
|
|
2
|
+
import { mergeConfig, splitConfig } from './values.js';
|
|
3
3
|
export const migrateConfigStore = (settingsStore, stateStore, legacyStore) => {
|
|
4
4
|
if (!existsSync(legacyStore.path))
|
|
5
5
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/lib/config/migrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,SAAS,CAAA;AAI5C,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"migrate.js","sourceRoot":"","sources":["../../src/lib/config/migrate.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ole trees: merging two trees into one view, and
|
|
3
|
+
* splitting one tree into the settings file and the state file by key.
|
|
4
|
+
* Pure transforms shared by the persistent store and the legacy migration.
|
|
5
|
+
*/
|
|
6
|
+
/** Whether a key holds auth state rather than a setting. */
|
|
7
|
+
export declare const isStateKey: (key: string) => boolean;
|
|
8
|
+
export declare const mergeConfig: (baseConfig: Record<string, unknown>, overrideConfig: Record<string, unknown>) => Record<string, unknown>;
|
|
9
|
+
export declare const splitConfig: (config: Record<string, unknown>) => {
|
|
10
|
+
settings: Record<string, unknown>;
|
|
11
|
+
state: Record<string, unknown>;
|
|
12
|
+
};
|