@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
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
2
|
+
import { assertMutable, selectWorkspace } from '../auth/operations.js';
|
|
3
|
+
import { getConfigStore } from '../config/index.js';
|
|
4
|
+
import { resolveAuth } from '../context.js';
|
|
5
|
+
import { getSeamMultiWorkspace } from '../http/client.js';
|
|
6
|
+
import { withLoading } from '../output/with-loading.js';
|
|
7
|
+
import { promptAutocomplete } from '../prompt.js';
|
|
8
8
|
export const interactForWorkspaceId = async (personalAccessToken) => {
|
|
9
9
|
const config = getConfigStore();
|
|
10
|
-
|
|
10
|
+
// Refuse before prompting: nothing selected here could be stored.
|
|
11
|
+
assertMutable(resolveAuth(config), 'workspaceId', 'select a workspace');
|
|
11
12
|
const seam = personalAccessToken
|
|
12
13
|
? SeamHttpWithoutWorkspace.fromPersonalAccessToken(personalAccessToken, {
|
|
13
|
-
endpoint:
|
|
14
|
+
endpoint: resolveAuth(config).server,
|
|
14
15
|
})
|
|
15
16
|
: await getSeamMultiWorkspace();
|
|
16
17
|
const workspaces = await withLoading('Fetching workspaces...', () => seam.workspaces.list());
|
|
@@ -24,7 +25,7 @@ export const interactForWorkspaceId = async (personalAccessToken) => {
|
|
|
24
25
|
hint: workspace.workspace_id,
|
|
25
26
|
})),
|
|
26
27
|
});
|
|
27
|
-
|
|
28
|
+
selectWorkspace(workspaceId, config);
|
|
28
29
|
return workspaceId;
|
|
29
30
|
};
|
|
30
|
-
//# sourceMappingURL=
|
|
31
|
+
//# sourceMappingURL=workspace-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workspace-id.js","sourceRoot":"","sources":["../../src/lib/interactions/workspace-id.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAA;AAEhE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,mBAA4B,EAAE,EAAE;IAC3E,MAAM,MAAM,GAAG,cAAc,EAAE,CAAA;IAE/B,kEAAkE;IAClE,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAA;IAEvE,MAAM,IAAI,GAAG,mBAAmB;QAC9B,CAAC,CAAC,wBAAwB,CAAC,uBAAuB,CAAC,mBAAmB,EAAE;YACpE,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC,MAAM;SACrC,CAAC;QACJ,CAAC,CAAC,MAAM,qBAAqB,EAAE,CAAA;IAEjC,MAAM,UAAU,GAAG,MAAM,WAAW,CAAC,wBAAwB,EAAE,GAAG,EAAE,CAClE,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CACvB,CAAA;IACD,yEAAyE;IACzE,wCAAwC;IACxC,MAAM,WAAW,GAAG,MAAM,kBAAkB,CAAS;QACnD,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,UAAU,CAAC,GAAG,CAAC,CAAC,SAAc,EAAE,EAAE,CAAC,CAAC;YAC3C,KAAK,EAAE,SAAS,CAAC,IAAI;YACrB,KAAK,EAAE,SAAS,CAAC,YAAY;YAC7B,IAAI,EAAE,SAAS,CAAC,YAAY;SAC7B,CAAC,CAAC;KACJ,CAAC,CAAA;IAEF,eAAe,CAAC,WAAW,EAAE,MAAM,CAAC,CAAA;IACpC,OAAO,WAAW,CAAA;AACpB,CAAC,CAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { PromptChoice, PromptClient, PromptConfirmOptions, PromptNumberOptions, PromptSelectOptions, PromptTextOptions } from './prompt.js';
|
|
2
|
+
/** A question a {@link PromptClient} was asked, as a test sees it. */
|
|
3
|
+
export interface PromptQuestion {
|
|
4
|
+
kind: 'text' | 'number' | 'confirm' | 'select' | 'autocomplete' | 'autocompleteMultiselect';
|
|
5
|
+
message: string;
|
|
6
|
+
choices?: Array<PromptChoice<unknown>>;
|
|
7
|
+
}
|
|
8
|
+
/** Scripted in place of an answer to dismiss that prompt. */
|
|
9
|
+
export declare const cancelPrompt: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* A real {@link PromptClient} that answers from a script instead of a
|
|
12
|
+
* terminal, and records every question it was asked.
|
|
13
|
+
*
|
|
14
|
+
* Each ask consumes the next scripted answer in turn. Scripting
|
|
15
|
+
* {@link cancelPrompt} dismisses that prompt, and an exhausted script
|
|
16
|
+
* dismisses every prompt after it, exactly as a user cancelling would.
|
|
17
|
+
*/
|
|
18
|
+
export declare class MemoryPromptClient implements PromptClient {
|
|
19
|
+
/** Every question asked, in order — assert on what the user was offered. */
|
|
20
|
+
readonly questions: PromptQuestion[];
|
|
21
|
+
private readonly answers;
|
|
22
|
+
constructor(script?: unknown[]);
|
|
23
|
+
canPrompt: () => boolean;
|
|
24
|
+
text: ({ message }: PromptTextOptions) => Promise<string>;
|
|
25
|
+
number: ({ message }: PromptNumberOptions) => Promise<number>;
|
|
26
|
+
confirm: ({ message }: PromptConfirmOptions) => Promise<boolean>;
|
|
27
|
+
select: <Value>({ message, choices, }: PromptSelectOptions<Value>) => Promise<Value>;
|
|
28
|
+
autocomplete: <Value>({ message, choices, }: PromptSelectOptions<Value>) => Promise<Value>;
|
|
29
|
+
autocompleteMultiselect: <Value>({ message, choices, }: PromptSelectOptions<Value>) => Promise<Value[]>;
|
|
30
|
+
private answer;
|
|
31
|
+
}
|
|
32
|
+
export declare const createMemoryPrompt: (script?: unknown[]) => MemoryPromptClient;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { PromptCancelledError } from './errors.js';
|
|
2
|
+
/** Scripted in place of an answer to dismiss that prompt. */
|
|
3
|
+
export const cancelPrompt = Symbol('cancel-prompt');
|
|
4
|
+
/**
|
|
5
|
+
* A real {@link PromptClient} that answers from a script instead of a
|
|
6
|
+
* terminal, and records every question it was asked.
|
|
7
|
+
*
|
|
8
|
+
* Each ask consumes the next scripted answer in turn. Scripting
|
|
9
|
+
* {@link cancelPrompt} dismisses that prompt, and an exhausted script
|
|
10
|
+
* dismisses every prompt after it, exactly as a user cancelling would.
|
|
11
|
+
*/
|
|
12
|
+
export class MemoryPromptClient {
|
|
13
|
+
/** Every question asked, in order — assert on what the user was offered. */
|
|
14
|
+
questions = [];
|
|
15
|
+
answers;
|
|
16
|
+
constructor(script = []) {
|
|
17
|
+
this.answers = [...script];
|
|
18
|
+
}
|
|
19
|
+
canPrompt = () => true;
|
|
20
|
+
text = async ({ message }) => this.answer({ kind: 'text', message });
|
|
21
|
+
number = async ({ message }) => this.answer({ kind: 'number', message });
|
|
22
|
+
confirm = async ({ message }) => this.answer({ kind: 'confirm', message });
|
|
23
|
+
select = async ({ message, choices, }) => this.answer({ kind: 'select', message, choices });
|
|
24
|
+
autocomplete = async ({ message, choices, }) => this.answer({ kind: 'autocomplete', message, choices });
|
|
25
|
+
autocompleteMultiselect = async ({ message, choices, }) => this.answer({
|
|
26
|
+
kind: 'autocompleteMultiselect',
|
|
27
|
+
message,
|
|
28
|
+
choices,
|
|
29
|
+
});
|
|
30
|
+
answer(question) {
|
|
31
|
+
this.questions.push(question);
|
|
32
|
+
if (this.answers.length === 0)
|
|
33
|
+
throw new PromptCancelledError();
|
|
34
|
+
const value = this.answers.shift();
|
|
35
|
+
if (value === cancelPrompt)
|
|
36
|
+
throw new PromptCancelledError();
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export const createMemoryPrompt = (script = []) => new MemoryPromptClient(script);
|
|
41
|
+
//# sourceMappingURL=memory-prompt.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-prompt.js","sourceRoot":"","sources":["../src/lib/memory-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAuBpD,6DAA6D;AAC7D,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,eAAe,CAAC,CAAA;AAEnD;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAkB;IAC7B,4EAA4E;IACnE,SAAS,GAAqB,EAAE,CAAA;IAExB,OAAO,CAAW;IAEnC,YAAY,SAAoB,EAAE;QAChC,IAAI,CAAC,OAAO,GAAG,CAAC,GAAG,MAAM,CAAC,CAAA;IAC5B,CAAC;IAED,SAAS,GAAG,GAAY,EAAE,CAAC,IAAI,CAAA;IAE/B,IAAI,GAAG,KAAK,EAAE,EAAE,OAAO,EAAqB,EAAmB,EAAE,CAC/D,IAAI,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,CAAW,CAAA;IAElD,MAAM,GAAG,KAAK,EAAE,EAAE,OAAO,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CAAA"}
|
package/lib/output/get-output.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-output.js","sourceRoot":"","sources":["../../src/lib/output/get-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,
|
|
1
|
+
{"version":3,"file":"get-output.js","sourceRoot":"","sources":["../../src/lib/output/get-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAe,MAAM,aAAa,CAAA;AAEvD,IAAI,MAAM,GAAkB,IAAI,CAAA;AAEhC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,GAAW,EAAE;IACpC,MAAM,KAAK,YAAY,EAAE,CAAA;IACzB,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,uEAAuE;AACvE,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,UAAkB,EAAQ,EAAE;IACpD,MAAM,GAAG,UAAU,CAAA;AACrB,CAAC,CAAA;AAED,sDAAsD;AACtD,MAAM,CAAC,MAAM,WAAW,GAAG,GAAS,EAAE;IACpC,MAAM,GAAG,IAAI,CAAA;AACf,CAAC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createOutput, } from './
|
|
1
|
+
import { createOutput, } from './output.js';
|
|
2
2
|
const createMemoryStream = () => {
|
|
3
3
|
const chunks = [];
|
|
4
4
|
return {
|
|
@@ -19,4 +19,4 @@ export const createMemoryOutput = (options = {}) => {
|
|
|
19
19
|
stderr: stderr.read,
|
|
20
20
|
};
|
|
21
21
|
};
|
|
22
|
-
//# sourceMappingURL=
|
|
22
|
+
//# sourceMappingURL=memory-output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-output.js","sourceRoot":"","sources":["../../src/lib/output/memory-output.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAIb,MAAM,aAAa,CAAA;AAUpB,MAAM,kBAAkB,GAAG,GAA0C,EAAE;IACrE,MAAM,MAAM,GAAa,EAAE,CAAA;IAC3B,OAAO;QACL,KAAK,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;QAC5C,IAAI,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC;KAC5B,CAAA;AACH,CAAC,CAAA;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,UAA0D,EAAE,EAC9C,EAAE;IAChB,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAA;IACnC,MAAM,MAAM,GAAG,kBAAkB,EAAE,CAAA;IAEnC,OAAO;QACL,MAAM,EAAE,YAAY,CAAC,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;QACpD,MAAM,EAAE,MAAM,CAAC,IAAI;QACnB,MAAM,EAAE,MAAM,CAAC,IAAI;KACpB,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -47,4 +47,21 @@ export interface CreateOutputOptions {
|
|
|
47
47
|
/** Colorize pretty printed data. Never applied to the json format. */
|
|
48
48
|
colors?: boolean;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
/**
|
|
51
|
+
* The one {@link Output} implementation: writes to a pair of streams. The
|
|
52
|
+
* process streams make it the real output; in-memory streams make it the
|
|
53
|
+
* test capture (see `create-memory-output.ts`).
|
|
54
|
+
*/
|
|
55
|
+
export declare class StreamOutput implements Output {
|
|
56
|
+
readonly format: OutputFormat;
|
|
57
|
+
private readonly stdout;
|
|
58
|
+
private readonly stderr;
|
|
59
|
+
private readonly colors;
|
|
60
|
+
constructor({ format, stdout, stderr, colors, }?: CreateOutputOptions);
|
|
61
|
+
data: (value: unknown) => void;
|
|
62
|
+
text: (value: string) => void;
|
|
63
|
+
info: (message?: string) => void;
|
|
64
|
+
warn: (message: string) => void;
|
|
65
|
+
error: (message: string) => void;
|
|
66
|
+
}
|
|
67
|
+
export declare const createOutput: (options?: CreateOutputOptions) => Output;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { inspect } from 'node:util';
|
|
2
|
+
/**
|
|
3
|
+
* The one {@link Output} implementation: writes to a pair of streams. The
|
|
4
|
+
* process streams make it the real output; in-memory streams make it the
|
|
5
|
+
* test capture (see `create-memory-output.ts`).
|
|
6
|
+
*/
|
|
7
|
+
export class StreamOutput {
|
|
8
|
+
format;
|
|
9
|
+
stdout;
|
|
10
|
+
stderr;
|
|
11
|
+
colors;
|
|
12
|
+
constructor({ format = 'text', stdout = process.stdout, stderr = process.stderr, colors = false, } = {}) {
|
|
13
|
+
this.format = format;
|
|
14
|
+
this.stdout = stdout;
|
|
15
|
+
this.stderr = stderr;
|
|
16
|
+
this.colors = colors;
|
|
17
|
+
}
|
|
18
|
+
data = (value) => {
|
|
19
|
+
if (value === undefined)
|
|
20
|
+
return;
|
|
21
|
+
this.stdout.write(`${formatData(value, this.format, this.colors)}\n`);
|
|
22
|
+
};
|
|
23
|
+
text = (value) => {
|
|
24
|
+
this.stdout.write(`${value}\n`);
|
|
25
|
+
};
|
|
26
|
+
info = (message = '') => {
|
|
27
|
+
if (this.format === 'json')
|
|
28
|
+
return;
|
|
29
|
+
this.stderr.write(`${message}\n`);
|
|
30
|
+
};
|
|
31
|
+
warn = (message) => {
|
|
32
|
+
this.stderr.write(`${message}\n`);
|
|
33
|
+
};
|
|
34
|
+
error = (message) => {
|
|
35
|
+
this.stderr.write(`${message}\n`);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export const createOutput = (options = {}) => new StreamOutput(options);
|
|
39
|
+
const formatData = (value, format, colors) => {
|
|
40
|
+
if (format === 'json')
|
|
41
|
+
return JSON.stringify(value, null, 2);
|
|
42
|
+
if (typeof value === 'string')
|
|
43
|
+
return value;
|
|
44
|
+
return inspect(value, { depth: null, colors });
|
|
45
|
+
};
|
|
46
|
+
//# sourceMappingURL=output.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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;IAC1E,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,EAAE,EAAE,CAAA;QACzB,OAAO,CAAC,OAAO,EAAE,CAAA;QACjB,OAAO,MAAM,CAAA;IACf,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,EAAE,CAAA;QACf,MAAM,KAAK,CAAA;IACb,CAAC;AACH,CAAC,CAAA;AAED,MAAM,UAAU,GAAG,GAAY,EAAE,CAC/B,SAAS,EAAE,CAAC,MAAM,KAAK,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,KAAK,KAAK,IAAI,CAAA"}
|
package/lib/prompt.d.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { EventEmitter } from 'node:events';
|
|
2
|
+
import type { Key } from 'node:readline';
|
|
3
|
+
export interface PromptChoice<Value> {
|
|
4
|
+
label: string;
|
|
5
|
+
value: Value;
|
|
6
|
+
hint?: string | undefined;
|
|
7
|
+
}
|
|
8
|
+
export interface PromptTextOptions {
|
|
9
|
+
message: string;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
defaultValue?: string;
|
|
12
|
+
validate?: (value: string | undefined) => string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface PromptNumberOptions {
|
|
15
|
+
message: string;
|
|
16
|
+
validate?: (value: number) => string | undefined;
|
|
17
|
+
}
|
|
18
|
+
export interface PromptConfirmOptions {
|
|
19
|
+
message: string;
|
|
20
|
+
initialValue?: boolean;
|
|
21
|
+
active?: string;
|
|
22
|
+
inactive?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface PromptSelectOptions<Value> {
|
|
25
|
+
message: string;
|
|
26
|
+
choices: Array<PromptChoice<Value>>;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The terminal edge behind the prompt functions: whether questions can be
|
|
30
|
+
* asked, and how to ask each kind.
|
|
31
|
+
*
|
|
32
|
+
* A test replaces this with an in-memory client (see
|
|
33
|
+
* `memory-prompt.ts`) via {@link setPromptClient} — the code under
|
|
34
|
+
* test keeps calling `promptText` and friends as usual.
|
|
35
|
+
*/
|
|
36
|
+
export interface PromptClient {
|
|
37
|
+
canPrompt: () => boolean;
|
|
38
|
+
text: (options: PromptTextOptions) => Promise<string>;
|
|
39
|
+
number: (options: PromptNumberOptions) => Promise<number>;
|
|
40
|
+
confirm: (options: PromptConfirmOptions) => Promise<boolean>;
|
|
41
|
+
select: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
42
|
+
autocomplete: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
43
|
+
autocompleteMultiselect: <Value>(options: PromptSelectOptions<Value>) => Promise<Value[]>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Note on a prompt message that dismissing it returns to the previous step.
|
|
47
|
+
*
|
|
48
|
+
* Only for prompts whose caller catches the dismissal: elsewhere it still
|
|
49
|
+
* stops the CLI, and saying otherwise would mislead. The note goes in the
|
|
50
|
+
* message because clack renders its own keyboard hints from a hardcoded list
|
|
51
|
+
* that a caller cannot add to.
|
|
52
|
+
*/
|
|
53
|
+
export declare const withBackHint: (message: string) => string;
|
|
54
|
+
/**
|
|
55
|
+
* The arrow keypress an Emacs-style control keypress stands for, or
|
|
56
|
+
* undefined for any other key: ctrl-p is up and ctrl-n is down.
|
|
57
|
+
*/
|
|
58
|
+
export declare const arrowKeyFor: (key: Key | undefined) => Key | undefined;
|
|
59
|
+
/**
|
|
60
|
+
* Re-emit Emacs-style control keypresses as the arrow keys they stand for.
|
|
61
|
+
*
|
|
62
|
+
* Clack navigates on the readline key name, so a synthetic arrow keypress
|
|
63
|
+
* moves the cursor in every prompt kind. Its own alias table cannot express
|
|
64
|
+
* this: aliases match bare key names, unaware of ctrl, and are ignored by
|
|
65
|
+
* prompts that track typed input, such as autocomplete.
|
|
66
|
+
*/
|
|
67
|
+
export declare const emitArrowKeyAliases: (input: EventEmitter) => void;
|
|
68
|
+
export declare class TerminalPromptClient implements PromptClient {
|
|
69
|
+
/**
|
|
70
|
+
* Prompts read raw keypresses and render an interface, so they need a
|
|
71
|
+
* terminal on both ends: when stdin is a pipe or a file it holds request
|
|
72
|
+
* params, not answers, and when stderr is redirected nobody sees the
|
|
73
|
+
* question.
|
|
74
|
+
*/
|
|
75
|
+
canPrompt: () => boolean;
|
|
76
|
+
text: (options: PromptTextOptions) => Promise<string>;
|
|
77
|
+
number: (options: PromptNumberOptions) => Promise<number>;
|
|
78
|
+
confirm: (options: PromptConfirmOptions) => Promise<boolean>;
|
|
79
|
+
select: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
80
|
+
autocomplete: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
81
|
+
autocompleteMultiselect: <Value>(options: PromptSelectOptions<Value>) => Promise<Value[]>;
|
|
82
|
+
}
|
|
83
|
+
export declare const setPromptClient: (promptClient: PromptClient) => void;
|
|
84
|
+
export declare const resetPromptClient: () => void;
|
|
85
|
+
/** Whether the CLI can ask the user a question. */
|
|
86
|
+
export declare const canPrompt: () => boolean;
|
|
87
|
+
export declare const promptText: (options: PromptTextOptions) => Promise<string>;
|
|
88
|
+
export declare const promptNumber: (options: PromptNumberOptions) => Promise<number>;
|
|
89
|
+
export declare const promptConfirm: (options: PromptConfirmOptions) => Promise<boolean>;
|
|
90
|
+
export declare const promptSelect: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
91
|
+
export declare const promptAutocomplete: <Value>(options: PromptSelectOptions<Value>) => Promise<Value>;
|
|
92
|
+
export declare const promptAutocompleteMultiselect: <Value>(options: PromptSelectOptions<Value>) => Promise<Value[]>;
|
|
93
|
+
export interface SearchableChoice {
|
|
94
|
+
label?: string | undefined;
|
|
95
|
+
hint?: string | undefined;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Match a choice by every whitespace separated term of the input, matched
|
|
99
|
+
* case insensitively against the label and the hint.
|
|
100
|
+
*/
|
|
101
|
+
export declare const searchChoices: (input: string, choice: SearchableChoice) => boolean;
|
|
@@ -1,21 +1,6 @@
|
|
|
1
1
|
import { autocomplete, autocompleteMultiselect, confirm, isCancel, select, text, } from '@clack/prompts';
|
|
2
2
|
import chalk from 'chalk';
|
|
3
|
-
import { NonInteractiveError } from './
|
|
4
|
-
/**
|
|
5
|
-
* Whether the CLI can ask the user a question.
|
|
6
|
-
*
|
|
7
|
-
* Prompts read raw keypresses and render an interface, so they need a
|
|
8
|
-
* terminal on both ends: when stdin is a pipe or a file it holds request
|
|
9
|
-
* params, not answers, and when stderr is redirected nobody sees the
|
|
10
|
-
* question.
|
|
11
|
-
*/
|
|
12
|
-
export const canPrompt = () => process.stdin.isTTY === true && process.stderr.isTTY === true;
|
|
13
|
-
/** The user dismissed a prompt with ctrl-c or escape instead of answering. */
|
|
14
|
-
export class PromptCancelledError extends Error {
|
|
15
|
-
constructor() {
|
|
16
|
-
super('Cancelled');
|
|
17
|
-
}
|
|
18
|
-
}
|
|
3
|
+
import { NonInteractiveError, PromptCancelledError } from './errors.js';
|
|
19
4
|
/**
|
|
20
5
|
* Note on a prompt message that dismissing it returns to the previous step.
|
|
21
6
|
*
|
|
@@ -25,12 +10,6 @@ export class PromptCancelledError extends Error {
|
|
|
25
10
|
* that a caller cannot add to.
|
|
26
11
|
*/
|
|
27
12
|
export const withBackHint = (message) => `${message} ${chalk.dim('· Esc: go back')}`;
|
|
28
|
-
const ensureInteractive = () => {
|
|
29
|
-
if (!canPrompt()) {
|
|
30
|
-
throw new NonInteractiveError('Cannot prompt without a terminal: pass the missing arguments, or pipe them in as JSON');
|
|
31
|
-
}
|
|
32
|
-
installArrowKeyAliases();
|
|
33
|
-
};
|
|
34
13
|
/**
|
|
35
14
|
* The arrow keypress an Emacs-style control keypress stands for, or
|
|
36
15
|
* undefined for any other key: ctrl-p is up and ctrl-n is down.
|
|
@@ -81,57 +60,105 @@ const output = process.stderr;
|
|
|
81
60
|
const toOptions = (choices) => choices.map(({ label, value, hint }) => (hint === undefined
|
|
82
61
|
? { label, value }
|
|
83
62
|
: { label, value, hint }));
|
|
63
|
+
export class TerminalPromptClient {
|
|
64
|
+
/**
|
|
65
|
+
* Prompts read raw keypresses and render an interface, so they need a
|
|
66
|
+
* terminal on both ends: when stdin is a pipe or a file it holds request
|
|
67
|
+
* params, not answers, and when stderr is redirected nobody sees the
|
|
68
|
+
* question.
|
|
69
|
+
*/
|
|
70
|
+
canPrompt = () => process.stdin.isTTY === true && process.stderr.isTTY === true;
|
|
71
|
+
text = async (options) => {
|
|
72
|
+
installArrowKeyAliases();
|
|
73
|
+
return unwrap(await text({ ...options, output }));
|
|
74
|
+
};
|
|
75
|
+
number = async (options) => {
|
|
76
|
+
installArrowKeyAliases();
|
|
77
|
+
const value = unwrap(await text({
|
|
78
|
+
message: options.message,
|
|
79
|
+
validate: (value) => {
|
|
80
|
+
if (value == null || value.trim() === '')
|
|
81
|
+
return 'Enter a number';
|
|
82
|
+
const parsed = Number(value);
|
|
83
|
+
if (Number.isNaN(parsed))
|
|
84
|
+
return 'Enter a number';
|
|
85
|
+
return options.validate?.(parsed);
|
|
86
|
+
},
|
|
87
|
+
output,
|
|
88
|
+
}));
|
|
89
|
+
return Number(value);
|
|
90
|
+
};
|
|
91
|
+
confirm = async (options) => {
|
|
92
|
+
installArrowKeyAliases();
|
|
93
|
+
return unwrap(await confirm({ ...options, output }));
|
|
94
|
+
};
|
|
95
|
+
select = async (options) => {
|
|
96
|
+
installArrowKeyAliases();
|
|
97
|
+
return unwrap(await select({
|
|
98
|
+
message: options.message,
|
|
99
|
+
options: toOptions(options.choices),
|
|
100
|
+
output,
|
|
101
|
+
}));
|
|
102
|
+
};
|
|
103
|
+
autocomplete = async (options) => {
|
|
104
|
+
installArrowKeyAliases();
|
|
105
|
+
return unwrap(await autocomplete({
|
|
106
|
+
message: options.message,
|
|
107
|
+
options: toOptions(options.choices),
|
|
108
|
+
// Search a list by any part of a name or hint, rather than only by
|
|
109
|
+
// the label, which is all clack matches for itself.
|
|
110
|
+
filter: searchChoices,
|
|
111
|
+
output,
|
|
112
|
+
}));
|
|
113
|
+
};
|
|
114
|
+
autocompleteMultiselect = async (options) => {
|
|
115
|
+
installArrowKeyAliases();
|
|
116
|
+
return unwrap(await autocompleteMultiselect({
|
|
117
|
+
message: options.message,
|
|
118
|
+
options: toOptions(options.choices),
|
|
119
|
+
filter: searchChoices,
|
|
120
|
+
output,
|
|
121
|
+
}));
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const terminalPromptClient = new TerminalPromptClient();
|
|
125
|
+
let client = terminalPromptClient;
|
|
126
|
+
export const setPromptClient = (promptClient) => {
|
|
127
|
+
client = promptClient;
|
|
128
|
+
};
|
|
129
|
+
export const resetPromptClient = () => {
|
|
130
|
+
client = terminalPromptClient;
|
|
131
|
+
};
|
|
132
|
+
/** Whether the CLI can ask the user a question. */
|
|
133
|
+
export const canPrompt = () => client.canPrompt();
|
|
134
|
+
const ensureInteractive = () => {
|
|
135
|
+
if (!client.canPrompt()) {
|
|
136
|
+
throw new NonInteractiveError('Cannot prompt without a terminal: pass the missing arguments, or pipe them in as JSON');
|
|
137
|
+
}
|
|
138
|
+
};
|
|
84
139
|
export const promptText = async (options) => {
|
|
85
140
|
ensureInteractive();
|
|
86
|
-
return
|
|
141
|
+
return await client.text(options);
|
|
87
142
|
};
|
|
88
143
|
export const promptNumber = async (options) => {
|
|
89
144
|
ensureInteractive();
|
|
90
|
-
|
|
91
|
-
message: options.message,
|
|
92
|
-
validate: (value) => {
|
|
93
|
-
if (value == null || value.trim() === '')
|
|
94
|
-
return 'Enter a number';
|
|
95
|
-
const parsed = Number(value);
|
|
96
|
-
if (Number.isNaN(parsed))
|
|
97
|
-
return 'Enter a number';
|
|
98
|
-
return options.validate?.(parsed);
|
|
99
|
-
},
|
|
100
|
-
output,
|
|
101
|
-
}));
|
|
102
|
-
return Number(value);
|
|
145
|
+
return await client.number(options);
|
|
103
146
|
};
|
|
104
147
|
export const promptConfirm = async (options) => {
|
|
105
148
|
ensureInteractive();
|
|
106
|
-
return
|
|
149
|
+
return await client.confirm(options);
|
|
107
150
|
};
|
|
108
151
|
export const promptSelect = async (options) => {
|
|
109
152
|
ensureInteractive();
|
|
110
|
-
return
|
|
111
|
-
message: options.message,
|
|
112
|
-
options: toOptions(options.choices),
|
|
113
|
-
output,
|
|
114
|
-
}));
|
|
153
|
+
return await client.select(options);
|
|
115
154
|
};
|
|
116
155
|
export const promptAutocomplete = async (options) => {
|
|
117
156
|
ensureInteractive();
|
|
118
|
-
return
|
|
119
|
-
message: options.message,
|
|
120
|
-
options: toOptions(options.choices),
|
|
121
|
-
// Search a list by any part of a name or hint, rather than only by
|
|
122
|
-
// the label, which is all clack matches for itself.
|
|
123
|
-
filter: searchChoices,
|
|
124
|
-
output,
|
|
125
|
-
}));
|
|
157
|
+
return await client.autocomplete(options);
|
|
126
158
|
};
|
|
127
159
|
export const promptAutocompleteMultiselect = async (options) => {
|
|
128
160
|
ensureInteractive();
|
|
129
|
-
return
|
|
130
|
-
message: options.message,
|
|
131
|
-
options: toOptions(options.choices),
|
|
132
|
-
filter: searchChoices,
|
|
133
|
-
output,
|
|
134
|
-
}));
|
|
161
|
+
return await client.autocompleteMultiselect(options);
|
|
135
162
|
};
|
|
136
163
|
/**
|
|
137
164
|
* Match a choice by every whitespace separated term of the input, matched
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prompt.js","sourceRoot":"","sources":["../src/lib/prompt.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,OAAO,EACP,QAAQ,EAER,MAAM,EACN,IAAI,GACL,MAAM,gBAAgB,CAAA;AACvB,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAoDzE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,OAAe,EAAU,EAAE,CACtD,GAAG,OAAO,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
2
|
-
import { ellipsis } from '../util/ellipsis.js';
|
|
1
|
+
import { ellipsis, firstSentence } from '../../render/text.js';
|
|
3
2
|
const maxDescriptionLength = 72;
|
|
4
3
|
/**
|
|
5
4
|
* Reduce a description to one short line that is safe to embed in a
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"describe.js","sourceRoot":"","sources":["../../../src/lib/render/completion/describe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAE5D,MAAM,oBAAoB,GAAG,EAAE,CAAA;AAE/B;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,WAAmB,EAAU,EAAE,CAC9D,QAAQ,CACN,aAAa,CAAC,WAAW,CAAC;KACvB,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC;KACzB,IAAI,EAAE,EACT,oBAAoB,CACrB,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { CommandSpec } from '../../commands/spec.js';
|
|
2
2
|
export declare const completionShells: readonly ["bash", "fish", "zsh"];
|
|
3
3
|
export type CompletionShell = (typeof completionShells)[number];
|
|
4
4
|
export declare const isCompletionShell: (shell: unknown) => shell is CompletionShell;
|
|
5
5
|
/** File name to install the completion script for each shell as. */
|
|
6
6
|
export declare const completionFileNames: Record<CompletionShell, string>;
|
|
7
|
-
export declare const renderCompletion: (shell: CompletionShell,
|
|
7
|
+
export declare const renderCompletion: (shell: CompletionShell, spec: CommandSpec) => string;
|
|
8
8
|
/**
|
|
9
9
|
* Render the completion loader installed by system packages.
|
|
10
10
|
*
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { getCommandSpec } from '../command-spec.js';
|
|
2
1
|
import { renderBashCompletion } from './render-bash.js';
|
|
3
2
|
import { renderFishCompletion } from './render-fish.js';
|
|
4
3
|
import { renderZshCompletion } from './render-zsh.js';
|
|
@@ -15,7 +14,7 @@ const renderers = {
|
|
|
15
14
|
fish: renderFishCompletion,
|
|
16
15
|
zsh: renderZshCompletion,
|
|
17
16
|
};
|
|
18
|
-
export const renderCompletion = (shell,
|
|
17
|
+
export const renderCompletion = (shell, spec) => renderers[shell](spec);
|
|
19
18
|
/**
|
|
20
19
|
* Render the completion loader installed by system packages.
|
|
21
20
|
*
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/lib/render/completion/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAA;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,CAAU,CAAA;AAIhE,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,KAAc,EAA4B,EAAE,CAC5E,gBAAgB,CAAC,QAAQ,CAAC,KAAwB,CAAC,CAAA;AAErD,oEAAoE;AACpE,MAAM,CAAC,MAAM,mBAAmB,GAAoC;IAClE,IAAI,EAAE,WAAW;IACjB,IAAI,EAAE,WAAW;IACjB,GAAG,EAAE,UAAU;CAChB,CAAA;AAED,MAAM,SAAS,GAA2D;IACxE,IAAI,EAAE,oBAAoB;IAC1B,IAAI,EAAE,oBAAoB;IAC1B,GAAG,EAAE,mBAAmB;CACzB,CAAA;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAsB,EACtB,IAAiB,EACT,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAA;AAEnC;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAsB,EAAU,EAAE,CACrE,KAAK,CAAC,KAAK,CAAC,CAAA;AAEd;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAoC;IACxE,IAAI,EAAE,yCAAyC;IAC/C,IAAI,EAAE,yCAAyC;IAC/C,GAAG,EAAE,eAAe;CACrB,CAAA;AAED,MAAM,UAAU,GAAG,CAAC,KAAsB,EAAU,EAAE,CACpD,KAAK,KAAK;;;;uEAI2D,KAAK,IAAI,CAAA;AAEhF,MAAM,KAAK,GAAoC;IAC7C,IAAI,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;;;;;;;;OAQtB,yBAAyB,CAAC,IAAI;;;;CAIpC;IACC,IAAI,EAAE,GAAG,UAAU,CAAC,MAAM,CAAC;;;;;;;+BAOE,yBAAyB,CAAC,IAAI;;;;CAI5D;IACC,GAAG,EAAE;EACL,UAAU,CAAC,KAAK,CAAC;;;;;;;;;;;wCAWqB,yBAAyB,CAAC,GAAG;;;CAGpE;CACA,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { type CommandSpec } from '
|
|
1
|
+
import { type CommandSpec } from '../../commands/spec.js';
|
|
2
2
|
export declare const renderBashCompletion: (spec: CommandSpec) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"render-bash.js","sourceRoot":"","sources":["../../../src/lib/render/completion/render-bash.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,UAAU,GACX,MAAM,sBAAsB,CAAA;AAE7B,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,IAAiB,EAAU,EAAE;IAChE,MAAM,YAAY,GAAG,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,IAAI,EAAE,CAAA;IAChE,MAAM,eAAe,GAAG,IAAI,CAAC,WAAW;SACrC,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC,CAAC,UAAU,CAAC;SACvC,OAAO,CAAC,UAAU,CAAC;SACnB,IAAI,EAAE,CAAA;IAET,OAAO,GAAG;QACR,MAAM;QACN,uBAAuB,YAAY,CAAC,IAA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AAM,iBAAiB,GAAG,CAAC,IAAiB,EAAY,EAAE,CACxD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAChC,OAAO,CAAC,KAAK,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAC/C,UAAU,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAC/B,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,KAAK,EAAE;IAC7C,KAAK,EAAE,IAAI,CAAC,MAAM;CACnB,CAAC,CAAC,CACJ,CACF,CAAA;AAEH,MAAM,SAAS,GAAG,CAAC,IAAiB,EAAW,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAA;AAExE,MAAM,UAAU,GAAG,CAAC,IAAY,EAAE,QAAkB,EAAU,EAAE,CAC9D;IACE,GAAG,IAAI,MAAM;IACb,gBAAgB;IAChB,GAAG,QAAQ,CAAC,GAAG,CACb,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,QAAQ,OAAO,YAAY,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CACzE;IACD,QAAQ;IACR,GAAG;CACJ,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type { CommandSpec } from '
|
|
1
|
+
import type { CommandSpec } from '../../commands/spec.js';
|
|
2
2
|
export declare const renderFishCompletion: (spec: CommandSpec) => string;
|