@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
package/src/lib/util/prompt.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import type { EventEmitter } from 'node:events'
|
|
2
|
-
import type { Key } from 'node:readline'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
autocomplete,
|
|
6
|
-
autocompleteMultiselect,
|
|
7
|
-
confirm,
|
|
8
|
-
isCancel,
|
|
9
|
-
type Option,
|
|
10
|
-
select,
|
|
11
|
-
text,
|
|
12
|
-
} from '@clack/prompts'
|
|
13
|
-
import chalk from 'chalk'
|
|
14
|
-
|
|
15
|
-
import { NonInteractiveError } from './cli-args.js'
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Whether the CLI can ask the user a question.
|
|
19
|
-
*
|
|
20
|
-
* Prompts read raw keypresses and render an interface, so they need a
|
|
21
|
-
* terminal on both ends: when stdin is a pipe or a file it holds request
|
|
22
|
-
* params, not answers, and when stderr is redirected nobody sees the
|
|
23
|
-
* question.
|
|
24
|
-
*/
|
|
25
|
-
export const canPrompt = (): boolean =>
|
|
26
|
-
process.stdin.isTTY === true && process.stderr.isTTY === true
|
|
27
|
-
|
|
28
|
-
/** The user dismissed a prompt with ctrl-c or escape instead of answering. */
|
|
29
|
-
export class PromptCancelledError extends Error {
|
|
30
|
-
constructor() {
|
|
31
|
-
super('Cancelled')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface PromptChoice<Value> {
|
|
36
|
-
label: string
|
|
37
|
-
value: Value
|
|
38
|
-
hint?: string | undefined
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Note on a prompt message that dismissing it returns to the previous step.
|
|
43
|
-
*
|
|
44
|
-
* Only for prompts whose caller catches the dismissal: elsewhere it still
|
|
45
|
-
* stops the CLI, and saying otherwise would mislead. The note goes in the
|
|
46
|
-
* message because clack renders its own keyboard hints from a hardcoded list
|
|
47
|
-
* that a caller cannot add to.
|
|
48
|
-
*/
|
|
49
|
-
export const withBackHint = (message: string): string =>
|
|
50
|
-
`${message} ${chalk.dim('· Esc: go back')}`
|
|
51
|
-
|
|
52
|
-
const ensureInteractive = (): void => {
|
|
53
|
-
if (!canPrompt()) {
|
|
54
|
-
throw new NonInteractiveError(
|
|
55
|
-
'Cannot prompt without a terminal: pass the missing arguments, or pipe them in as JSON',
|
|
56
|
-
)
|
|
57
|
-
}
|
|
58
|
-
installArrowKeyAliases()
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* The arrow keypress an Emacs-style control keypress stands for, or
|
|
63
|
-
* undefined for any other key: ctrl-p is up and ctrl-n is down.
|
|
64
|
-
*/
|
|
65
|
-
export const arrowKeyFor = (key: Key | undefined): Key | undefined => {
|
|
66
|
-
if (key?.ctrl !== true || key.meta === true || key.shift === true) {
|
|
67
|
-
return undefined
|
|
68
|
-
}
|
|
69
|
-
const base = { ctrl: false, meta: false, shift: false }
|
|
70
|
-
if (key.name === 'p') return { ...base, name: 'up', sequence: '\x1B[A' }
|
|
71
|
-
if (key.name === 'n') return { ...base, name: 'down', sequence: '\x1B[B' }
|
|
72
|
-
return undefined
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Re-emit Emacs-style control keypresses as the arrow keys they stand for.
|
|
77
|
-
*
|
|
78
|
-
* Clack navigates on the readline key name, so a synthetic arrow keypress
|
|
79
|
-
* moves the cursor in every prompt kind. Its own alias table cannot express
|
|
80
|
-
* this: aliases match bare key names, unaware of ctrl, and are ignored by
|
|
81
|
-
* prompts that track typed input, such as autocomplete.
|
|
82
|
-
*/
|
|
83
|
-
export const emitArrowKeyAliases = (input: EventEmitter): void => {
|
|
84
|
-
input.on('keypress', (_char, key: Key | undefined) => {
|
|
85
|
-
const arrowKey = arrowKeyFor(key)
|
|
86
|
-
if (arrowKey !== undefined) input.emit('keypress', undefined, arrowKey)
|
|
87
|
-
})
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
let arrowKeyAliasesInstalled = false
|
|
91
|
-
|
|
92
|
-
// Keypress events only flow while a prompt has stdin in raw mode, so the
|
|
93
|
-
// listener is inert the rest of the time and never holds the process open.
|
|
94
|
-
const installArrowKeyAliases = (): void => {
|
|
95
|
-
if (arrowKeyAliasesInstalled) return
|
|
96
|
-
arrowKeyAliasesInstalled = true
|
|
97
|
-
emitArrowKeyAliases(process.stdin)
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const unwrap = <Value>(value: Value | symbol): Value => {
|
|
101
|
-
if (isCancel(value)) throw new PromptCancelledError()
|
|
102
|
-
return value as Value
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Prompts are rendered to stderr: a selection is not a command result,
|
|
106
|
-
// so it must not end up in stdout when the CLI is piped.
|
|
107
|
-
const output = process.stderr
|
|
108
|
-
|
|
109
|
-
const toOptions = <Value>(
|
|
110
|
-
choices: Array<PromptChoice<Value>>,
|
|
111
|
-
): Array<Option<Value>> =>
|
|
112
|
-
choices.map(
|
|
113
|
-
({ label, value, hint }) =>
|
|
114
|
-
(hint === undefined
|
|
115
|
-
? { label, value }
|
|
116
|
-
: { label, value, hint }) as Option<Value>,
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
export const promptText = async (options: {
|
|
120
|
-
message: string
|
|
121
|
-
placeholder?: string
|
|
122
|
-
defaultValue?: string
|
|
123
|
-
validate?: (value: string | undefined) => string | undefined
|
|
124
|
-
}): Promise<string> => {
|
|
125
|
-
ensureInteractive()
|
|
126
|
-
return unwrap(await text({ ...options, output }))
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
export const promptNumber = async (options: {
|
|
130
|
-
message: string
|
|
131
|
-
validate?: (value: number) => string | undefined
|
|
132
|
-
}): Promise<number> => {
|
|
133
|
-
ensureInteractive()
|
|
134
|
-
const value = unwrap(
|
|
135
|
-
await text({
|
|
136
|
-
message: options.message,
|
|
137
|
-
validate: (value) => {
|
|
138
|
-
if (value == null || value.trim() === '') return 'Enter a number'
|
|
139
|
-
const parsed = Number(value)
|
|
140
|
-
if (Number.isNaN(parsed)) return 'Enter a number'
|
|
141
|
-
return options.validate?.(parsed)
|
|
142
|
-
},
|
|
143
|
-
output,
|
|
144
|
-
}),
|
|
145
|
-
)
|
|
146
|
-
return Number(value)
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export const promptConfirm = async (options: {
|
|
150
|
-
message: string
|
|
151
|
-
initialValue?: boolean
|
|
152
|
-
active?: string
|
|
153
|
-
inactive?: string
|
|
154
|
-
}): Promise<boolean> => {
|
|
155
|
-
ensureInteractive()
|
|
156
|
-
return unwrap(await confirm({ ...options, output }))
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export const promptSelect = async <Value>(options: {
|
|
160
|
-
message: string
|
|
161
|
-
choices: Array<PromptChoice<Value>>
|
|
162
|
-
}): Promise<Value> => {
|
|
163
|
-
ensureInteractive()
|
|
164
|
-
return unwrap(
|
|
165
|
-
await select<Value>({
|
|
166
|
-
message: options.message,
|
|
167
|
-
options: toOptions(options.choices),
|
|
168
|
-
output,
|
|
169
|
-
}),
|
|
170
|
-
)
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
export const promptAutocomplete = async <Value>(options: {
|
|
174
|
-
message: string
|
|
175
|
-
choices: Array<PromptChoice<Value>>
|
|
176
|
-
}): Promise<Value> => {
|
|
177
|
-
ensureInteractive()
|
|
178
|
-
return unwrap(
|
|
179
|
-
await autocomplete<Value>({
|
|
180
|
-
message: options.message,
|
|
181
|
-
options: toOptions(options.choices),
|
|
182
|
-
// Search a list by any part of a name or hint, rather than only by
|
|
183
|
-
// the label, which is all clack matches for itself.
|
|
184
|
-
filter: searchChoices,
|
|
185
|
-
output,
|
|
186
|
-
}),
|
|
187
|
-
)
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
export const promptAutocompleteMultiselect = async <Value>(options: {
|
|
191
|
-
message: string
|
|
192
|
-
choices: Array<PromptChoice<Value>>
|
|
193
|
-
}): Promise<Value[]> => {
|
|
194
|
-
ensureInteractive()
|
|
195
|
-
return unwrap(
|
|
196
|
-
await autocompleteMultiselect<Value>({
|
|
197
|
-
message: options.message,
|
|
198
|
-
options: toOptions(options.choices),
|
|
199
|
-
filter: searchChoices,
|
|
200
|
-
output,
|
|
201
|
-
}),
|
|
202
|
-
)
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
export interface SearchableChoice {
|
|
206
|
-
label?: string | undefined
|
|
207
|
-
hint?: string | undefined
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
/**
|
|
211
|
-
* Match a choice by every whitespace separated term of the input, matched
|
|
212
|
-
* case insensitively against the label and the hint.
|
|
213
|
-
*/
|
|
214
|
-
export const searchChoices = (
|
|
215
|
-
input: string,
|
|
216
|
-
choice: SearchableChoice,
|
|
217
|
-
): boolean => {
|
|
218
|
-
const terms = input
|
|
219
|
-
.toLowerCase()
|
|
220
|
-
.split(/\s+/)
|
|
221
|
-
.filter((term) => term.length > 0)
|
|
222
|
-
|
|
223
|
-
if (terms.length === 0) return true
|
|
224
|
-
|
|
225
|
-
const searchable = `${choice.label ?? ''} ${choice.hint ?? ''}`
|
|
226
|
-
.toLowerCase()
|
|
227
|
-
.trim()
|
|
228
|
-
return terms.every((term) => searchable.includes(term))
|
|
229
|
-
}
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
import { getSeam } from 'lib/get-seam.js'
|
|
4
|
-
import { getOutput } from 'lib/output/get-output.js'
|
|
5
|
-
import { selectResponsePayload } from 'lib/output/select-response-payload.js'
|
|
6
|
-
|
|
7
|
-
import { withLoading } from './with-loading.js'
|
|
8
|
-
|
|
9
|
-
export interface RequestSeamApiOptions {
|
|
10
|
-
path: string
|
|
11
|
-
params: Record<string, any>
|
|
12
|
-
/** Response key for the endpoint, used to trim the reported payload. */
|
|
13
|
-
responseKey?: string | null | undefined
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const RequestSeamApi = async ({
|
|
17
|
-
path,
|
|
18
|
-
params,
|
|
19
|
-
responseKey,
|
|
20
|
-
}: RequestSeamApiOptions) => {
|
|
21
|
-
const seam = await getSeam()
|
|
22
|
-
const output = getOutput()
|
|
23
|
-
|
|
24
|
-
output.info(`\n${chalk.green(path)}`)
|
|
25
|
-
output.info(`Request Params:`)
|
|
26
|
-
output.info(formatParams(params))
|
|
27
|
-
|
|
28
|
-
const response = await withLoading('Making request...', () =>
|
|
29
|
-
seam.client.post(path, params, {
|
|
30
|
-
validateStatus: () => true,
|
|
31
|
-
}),
|
|
32
|
-
)
|
|
33
|
-
|
|
34
|
-
if (response.status >= 400) {
|
|
35
|
-
output.warn(chalk.red(`[${response.status}]`))
|
|
36
|
-
process.exitCode = 1
|
|
37
|
-
} else {
|
|
38
|
-
output.info(chalk.green(`[${response.status}]`))
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
output.data(selectResponsePayload(response.data, { responseKey }))
|
|
42
|
-
|
|
43
|
-
return response
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const formatParams = (params: Record<string, any>): string =>
|
|
47
|
-
JSON.stringify(params, null, 2)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/{interact-for-action-attempt-poll.d.ts → interactions/action-attempt-poll.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/lib/{interact-for-use-remote-api-defs.d.ts → interactions/use-remote-api-defs.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|