@seamapi/cli 0.22.0 → 0.24.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 +4 -4
- package/bin/cli.js +5 -5
- package/bin/cli.js.map +1 -1
- package/completions/seam.bash +1 -1
- package/completions/seam.fish +1 -1
- package/completions/seam.zsh +1 -1
- package/lib/args/parse.js +1 -1
- package/lib/args/parse.js.map +1 -1
- package/lib/auth/operations.d.ts +8 -8
- package/lib/auth/operations.js +16 -29
- package/lib/auth/operations.js.map +1 -1
- package/lib/blueprint/index.d.ts +3 -3
- package/lib/blueprint/index.js +4 -4
- package/lib/blueprint/index.js.map +1 -1
- package/lib/blueprint/source-npm.js +5 -5
- package/lib/blueprint/source-npm.js.map +1 -1
- package/lib/commands/api-command.js +1 -1
- package/lib/commands/local/completion.d.ts +3 -3
- package/lib/commands/local/completion.js +3 -3
- package/lib/commands/local/config-use-remote-schema.d.ts +2 -0
- package/lib/commands/local/config-use-remote-schema.js +20 -0
- package/lib/commands/local/config-use-remote-schema.js.map +1 -0
- package/lib/commands/local/wizard.d.ts +7 -0
- package/lib/commands/local/wizard.js +31 -0
- package/lib/commands/local/wizard.js.map +1 -1
- package/lib/commands/registry.js +2 -2
- package/lib/commands/registry.js.map +1 -1
- package/lib/commands/spec.d.ts +1 -1
- package/lib/commands/spec.js +6 -6
- package/lib/commands/spec.js.map +1 -1
- package/lib/config/cli-config.d.ts +19 -0
- package/lib/config/cli-config.js +54 -0
- package/lib/config/cli-config.js.map +1 -0
- package/lib/config/config-store.d.ts +8 -5
- package/lib/config/config-store.js +15 -13
- package/lib/config/config-store.js.map +1 -1
- package/lib/config/index.d.ts +3 -2
- package/lib/config/index.js +3 -2
- package/lib/config/index.js.map +1 -1
- package/lib/config/memory-config-store.d.ts +6 -0
- package/lib/config/memory-config-store.js +6 -0
- package/lib/config/memory-config-store.js.map +1 -1
- package/lib/context.d.ts +3 -3
- package/lib/context.js +6 -16
- package/lib/context.js.map +1 -1
- package/lib/interactions/endpoint-selection.js +2 -2
- package/lib/interactions/endpoint-selection.js.map +1 -1
- package/lib/interactions/index.d.ts +1 -1
- package/lib/interactions/index.js +1 -1
- package/lib/interactions/index.js.map +1 -1
- package/lib/interactions/login.js +2 -2
- package/lib/interactions/login.js.map +1 -1
- package/lib/interactions/use-remote-schema.d.ts +1 -0
- package/lib/interactions/use-remote-schema.js +21 -0
- package/lib/interactions/use-remote-schema.js.map +1 -0
- package/lib/interactions/workspace-id.js +2 -2
- package/lib/interactions/workspace-id.js.map +1 -1
- package/lib/render/completion/index.d.ts +1 -1
- package/lib/render/completion/index.js +2 -2
- package/lib/render/completion/render-bash.js +1 -1
- package/lib/render/completion/render-fish.js +1 -1
- package/lib/render/completion/render-zsh.js +1 -1
- package/lib/version.d.ts +1 -1
- package/lib/version.js +1 -1
- package/package.json +2 -2
- package/src/bin/cli.ts +5 -6
- package/src/lib/args/parse.ts +1 -1
- package/src/lib/auth/operations.ts +18 -32
- package/src/lib/blueprint/index.ts +6 -6
- package/src/lib/blueprint/source-npm.ts +5 -6
- package/src/lib/commands/api-command.ts +1 -1
- package/src/lib/commands/local/completion.ts +3 -3
- package/src/lib/commands/local/{config-use-remote-api-defs.ts → config-use-remote-schema.ts} +6 -6
- package/src/lib/commands/local/wizard.ts +48 -0
- package/src/lib/commands/registry.ts +2 -2
- package/src/lib/commands/spec.ts +6 -6
- package/src/lib/config/cli-config.ts +87 -0
- package/src/lib/config/config-store.ts +16 -13
- package/src/lib/config/index.ts +9 -4
- package/src/lib/config/memory-config-store.ts +9 -0
- package/src/lib/context.ts +7 -24
- package/src/lib/interactions/endpoint-selection.ts +2 -2
- package/src/lib/interactions/index.ts +1 -1
- package/src/lib/interactions/login.ts +2 -2
- package/src/lib/interactions/use-remote-schema.ts +22 -0
- package/src/lib/interactions/workspace-id.ts +2 -2
- package/src/lib/render/completion/index.ts +2 -2
- package/src/lib/render/completion/render-bash.ts +1 -1
- package/src/lib/render/completion/render-fish.ts +1 -1
- package/src/lib/render/completion/render-zsh.ts +1 -1
- package/src/lib/version.ts +1 -1
- package/lib/commands/local/config-use-remote-api-defs.d.ts +0 -2
- package/lib/commands/local/config-use-remote-api-defs.js +0 -20
- package/lib/commands/local/config-use-remote-api-defs.js.map +0 -1
- package/lib/interactions/use-remote-api-defs.d.ts +0 -1
- package/lib/interactions/use-remote-api-defs.js +0 -21
- package/lib/interactions/use-remote-api-defs.js.map +0 -1
- package/src/lib/interactions/use-remote-api-defs.ts +0 -22
package/src/lib/context.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Interactivity } from './args/parse.js'
|
|
2
2
|
import type { ApiBlueprint } from './blueprint/index.js'
|
|
3
|
-
import { type
|
|
3
|
+
import { type CliConfig, getConfig } from './config/index.js'
|
|
4
4
|
import {
|
|
5
5
|
getEndpointFromEnv,
|
|
6
6
|
getTokenFromEnv,
|
|
@@ -32,30 +32,21 @@ export interface AuthContext {
|
|
|
32
32
|
workspaceIdSource: Exclude<ValueSource, 'default'> | null
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
export const resolveAuth = (
|
|
36
|
-
config: ConfigStore = getConfigStore(),
|
|
37
|
-
): AuthContext => {
|
|
35
|
+
export const resolveAuth = (config: CliConfig = getConfig()): AuthContext => {
|
|
38
36
|
const { endpoint: flagEndpoint, workspaceId: flagWorkspaceId } =
|
|
39
37
|
getAuthOverrides()
|
|
40
38
|
|
|
41
39
|
const envEndpoint = getEndpointFromEnv()
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const storedEndpoint = config.get('endpoint') ?? config.get('server')
|
|
45
|
-
const endpoint =
|
|
46
|
-
flagEndpoint ??
|
|
47
|
-
envEndpoint ??
|
|
48
|
-
(typeof storedEndpoint === 'string' ? storedEndpoint : null)
|
|
40
|
+
const storedEndpoint = config.getEndpoint()
|
|
41
|
+
const endpoint = flagEndpoint ?? envEndpoint ?? storedEndpoint
|
|
49
42
|
|
|
50
43
|
const envToken = getTokenFromEnv()
|
|
51
44
|
// The token is stored per endpoint, so an overridden endpoint is read with
|
|
52
45
|
// the token belonging to it rather than the one it replaced.
|
|
53
|
-
const storedToken =
|
|
54
|
-
config.get(`${endpoint ?? defaultEndpoint}.pat`),
|
|
55
|
-
)
|
|
46
|
+
const storedToken = config.getToken(endpoint ?? defaultEndpoint)
|
|
56
47
|
|
|
57
48
|
const envWorkspaceId = getWorkspaceIdFromEnv()
|
|
58
|
-
const storedWorkspaceId =
|
|
49
|
+
const storedWorkspaceId = config.getWorkspace()
|
|
59
50
|
const workspaceId = flagWorkspaceId ?? envWorkspaceId ?? storedWorkspaceId
|
|
60
51
|
|
|
61
52
|
return {
|
|
@@ -88,7 +79,7 @@ export const resolveAuth = (
|
|
|
88
79
|
* shape it acts on, and how it may interact with the user.
|
|
89
80
|
*/
|
|
90
81
|
export interface CliContext {
|
|
91
|
-
config:
|
|
82
|
+
config: CliConfig
|
|
92
83
|
auth: AuthContext
|
|
93
84
|
output: Output
|
|
94
85
|
blueprint: ApiBlueprint
|
|
@@ -96,11 +87,3 @@ export interface CliContext {
|
|
|
96
87
|
/** The Seam API, constructed on first use and shared for the run. */
|
|
97
88
|
api: () => Promise<SeamApi>
|
|
98
89
|
}
|
|
99
|
-
|
|
100
|
-
const readString = (value: unknown): string | null => {
|
|
101
|
-
if (typeof value !== 'string') return null
|
|
102
|
-
|
|
103
|
-
const trimmedValue = value.trim()
|
|
104
|
-
|
|
105
|
-
return trimmedValue === '' ? null : trimmedValue
|
|
106
|
-
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { assertMutable, selectEndpoint } from 'lib/auth/operations.js'
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from 'lib/config/index.js'
|
|
3
3
|
import { resolveAuth } from 'lib/context.js'
|
|
4
4
|
import { getOutput } from 'lib/output/get-output.js'
|
|
5
5
|
import { promptAutocomplete } from 'lib/prompt.js'
|
|
6
6
|
|
|
7
7
|
export async function interactForEndpointSelection() {
|
|
8
|
-
const config =
|
|
8
|
+
const config = getConfig()
|
|
9
9
|
assertMutable(resolveAuth(config), 'endpoint', 'select an endpoint')
|
|
10
10
|
|
|
11
11
|
const endpoints = ['http://localhost:3020', 'https://connect.getseam.com']
|
|
@@ -14,6 +14,6 @@ export * from './endpoint-selection.js'
|
|
|
14
14
|
export * from './login.js'
|
|
15
15
|
export * from './resource.js'
|
|
16
16
|
export * from './timestamp.js'
|
|
17
|
-
export * from './use-remote-
|
|
17
|
+
export * from './use-remote-schema.js'
|
|
18
18
|
export * from './user-identity.js'
|
|
19
19
|
export * from './workspace-id.js'
|
|
@@ -3,7 +3,7 @@ import chalk from 'chalk'
|
|
|
3
3
|
|
|
4
4
|
import { assertMutable, storeToken } from 'lib/auth/operations.js'
|
|
5
5
|
import { validateToken } from 'lib/auth/validate-token.js'
|
|
6
|
-
import {
|
|
6
|
+
import { getConfig } from 'lib/config/index.js'
|
|
7
7
|
import { resolveAuth } from 'lib/context.js'
|
|
8
8
|
import { getOutput } from 'lib/output/get-output.js'
|
|
9
9
|
import { withLoading } from 'lib/output/with-loading.js'
|
|
@@ -12,7 +12,7 @@ import { promptText } from 'lib/prompt.js'
|
|
|
12
12
|
import { interactForWorkspaceId } from './workspace-id.js'
|
|
13
13
|
|
|
14
14
|
export const interactForLogin = async () => {
|
|
15
|
-
const config =
|
|
15
|
+
const config = getConfig()
|
|
16
16
|
const output = getOutput()
|
|
17
17
|
const auth = resolveAuth(config)
|
|
18
18
|
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { setUseRemoteSchema } from 'lib/auth/operations.js'
|
|
2
|
+
import { getOutput } from 'lib/output/get-output.js'
|
|
3
|
+
import { promptSelect } from 'lib/prompt.js'
|
|
4
|
+
|
|
5
|
+
export async function interactForUseRemoteSchema() {
|
|
6
|
+
const useRemoteSchema = await promptSelect({
|
|
7
|
+
message: 'Always use the remote schema?',
|
|
8
|
+
choices: [
|
|
9
|
+
{
|
|
10
|
+
label: 'Yes',
|
|
11
|
+
value: true,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
label: 'No',
|
|
15
|
+
value: false,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
setUseRemoteSchema(useRemoteSchema)
|
|
21
|
+
getOutput().info(`Use remote schema: ${useRemoteSchema}`)
|
|
22
|
+
}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { SeamHttpWithoutWorkspace } from '@seamapi/http/connect'
|
|
2
2
|
|
|
3
3
|
import { assertMutable, selectWorkspace } from 'lib/auth/operations.js'
|
|
4
|
-
import {
|
|
4
|
+
import { getConfig } from 'lib/config/index.js'
|
|
5
5
|
import { resolveAuth } from 'lib/context.js'
|
|
6
6
|
import { getSeamMultiWorkspace } from 'lib/http/client.js'
|
|
7
7
|
import { withLoading } from 'lib/output/with-loading.js'
|
|
8
8
|
import { promptAutocomplete } from 'lib/prompt.js'
|
|
9
9
|
|
|
10
10
|
export const interactForWorkspaceId = async (personalAccessToken?: string) => {
|
|
11
|
-
const config =
|
|
11
|
+
const config = getConfig()
|
|
12
12
|
|
|
13
13
|
// Refuse before prompting: nothing selected here could be stored.
|
|
14
14
|
assertMutable(resolveAuth(config), 'workspaceId', 'select a workspace')
|
|
@@ -34,7 +34,7 @@ export const renderCompletion = (
|
|
|
34
34
|
*
|
|
35
35
|
* The loader runs 'seam completion' the first time the shell completes a seam
|
|
36
36
|
* command, so installed completions always match the CLI's current Seam API
|
|
37
|
-
*
|
|
37
|
+
* schema instead of the schema packaged at release time. Each shell
|
|
38
38
|
* loads its completion file on demand, so the CLI runs once per shell session
|
|
39
39
|
* at first completion, never at shell startup.
|
|
40
40
|
*
|
|
@@ -61,7 +61,7 @@ const stubHeader = (shell: CompletionShell): string =>
|
|
|
61
61
|
`# ${shell} completion loader for the seam command.
|
|
62
62
|
#
|
|
63
63
|
# Generated by @seamapi/cli. Loads completions from the CLI on first use, so
|
|
64
|
-
# they always match the CLI's current Seam API
|
|
64
|
+
# they always match the CLI's current Seam API schema. Requires the seam
|
|
65
65
|
# command on PATH. Print the underlying script with 'seam completion ${shell}'.`
|
|
66
66
|
|
|
67
67
|
const stubs: Record<CompletionShell, string> = {
|
|
@@ -25,7 +25,7 @@ export const renderBashCompletion = (spec: CommandSpec): string => {
|
|
|
25
25
|
|
|
26
26
|
const header = `# bash completion for the seam command.
|
|
27
27
|
#
|
|
28
|
-
# Generated by @seamapi/cli from the Seam API
|
|
28
|
+
# Generated by @seamapi/cli from the Seam API schema.
|
|
29
29
|
# Do not edit: regenerate with 'seam completion bash'.
|
|
30
30
|
#
|
|
31
31
|
# Load it for the current shell with
|
|
@@ -13,7 +13,7 @@ export const renderFishCompletion = (spec: CommandSpec): string =>
|
|
|
13
13
|
|
|
14
14
|
const header = `# fish completion for the seam command.
|
|
15
15
|
#
|
|
16
|
-
# Generated by @seamapi/cli from the Seam API
|
|
16
|
+
# Generated by @seamapi/cli from the Seam API schema.
|
|
17
17
|
# Do not edit: regenerate with 'seam completion fish'.
|
|
18
18
|
#
|
|
19
19
|
# Install it with
|
|
@@ -27,7 +27,7 @@ const header = `#compdef seam
|
|
|
27
27
|
|
|
28
28
|
# zsh completion for the seam command.
|
|
29
29
|
#
|
|
30
|
-
# Generated by @seamapi/cli from the Seam API
|
|
30
|
+
# Generated by @seamapi/cli from the Seam API schema.
|
|
31
31
|
# Do not edit: regenerate with 'seam completion zsh'.
|
|
32
32
|
#
|
|
33
33
|
# Load it for the current shell with
|
package/src/lib/version.ts
CHANGED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { NonInteractiveError } from '../../errors.js';
|
|
2
|
-
import { interactForUseRemoteApiDefs } from '../../interactions/index.js';
|
|
3
|
-
export const configUseRemoteApiDefsCommand = {
|
|
4
|
-
definition: {
|
|
5
|
-
path: ['config', 'use-remote-api-defs'],
|
|
6
|
-
kind: 'cli',
|
|
7
|
-
title: 'Choose whether to use the API definitions served by Seam.',
|
|
8
|
-
description: '',
|
|
9
|
-
flags: [],
|
|
10
|
-
},
|
|
11
|
-
requiresAuth: true,
|
|
12
|
-
execute: async (_invocation, ctx) => {
|
|
13
|
-
if (ctx.interactivity === 'non-interactive') {
|
|
14
|
-
throw new NonInteractiveError('Cannot select whether to use remote API definitions in non-interactive mode');
|
|
15
|
-
}
|
|
16
|
-
await interactForUseRemoteApiDefs();
|
|
17
|
-
return { kind: 'done' };
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=config-use-remote-api-defs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config-use-remote-api-defs.js","sourceRoot":"","sources":["../../../src/lib/commands/local/config-use-remote-api-defs.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,2BAA2B,CAAA;AAEvE,MAAM,CAAC,MAAM,6BAA6B,GAAY;IACpD,UAAU,EAAE;QACV,IAAI,EAAE,CAAC,QAAQ,EAAE,qBAAqB,CAAC;QACvC,IAAI,EAAE,KAAK;QACX,KAAK,EAAE,2DAA2D;QAClE,WAAW,EAAE,EAAE;QACf,KAAK,EAAE,EAAE;KACV;IACD,YAAY,EAAE,IAAI;IAClB,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,EAAE;QAClC,IAAI,GAAG,CAAC,aAAa,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,mBAAmB,CAC3B,6EAA6E,CAC9E,CAAA;QACH,CAAC;QACD,MAAM,2BAA2B,EAAE,CAAA;QACnC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;IACzB,CAAC;CACF,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare function interactForUseRemoteApiDefs(): Promise<void>;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { setUseRemoteApiDefs } from '../auth/operations.js';
|
|
2
|
-
import { getOutput } from '../output/get-output.js';
|
|
3
|
-
import { promptSelect } from '../prompt.js';
|
|
4
|
-
export async function interactForUseRemoteApiDefs() {
|
|
5
|
-
const useRemoteApiDefs = await promptSelect({
|
|
6
|
-
message: 'Always use remote API Definitions?',
|
|
7
|
-
choices: [
|
|
8
|
-
{
|
|
9
|
-
label: 'Yes',
|
|
10
|
-
value: true,
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
label: 'No',
|
|
14
|
-
value: false,
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
});
|
|
18
|
-
setUseRemoteApiDefs(useRemoteApiDefs);
|
|
19
|
-
getOutput().info(`Use remote API Definitions: ${useRemoteApiDefs}`);
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=use-remote-api-defs.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-remote-api-defs.js","sourceRoot":"","sources":["../../src/lib/interactions/use-remote-api-defs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,CAAC,KAAK,UAAU,2BAA2B;IAC/C,MAAM,gBAAgB,GAAG,MAAM,YAAY,CAAC;QAC1C,OAAO,EAAE,oCAAoC;QAC7C,OAAO,EAAE;YACP;gBACE,KAAK,EAAE,KAAK;gBACZ,KAAK,EAAE,IAAI;aACZ;YACD;gBACE,KAAK,EAAE,IAAI;gBACX,KAAK,EAAE,KAAK;aACb;SACF;KACF,CAAC,CAAA;IAEF,mBAAmB,CAAC,gBAAgB,CAAC,CAAA;IACrC,SAAS,EAAE,CAAC,IAAI,CAAC,+BAA+B,gBAAgB,EAAE,CAAC,CAAA;AACrE,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { setUseRemoteApiDefs } from 'lib/auth/operations.js'
|
|
2
|
-
import { getOutput } from 'lib/output/get-output.js'
|
|
3
|
-
import { promptSelect } from 'lib/prompt.js'
|
|
4
|
-
|
|
5
|
-
export async function interactForUseRemoteApiDefs() {
|
|
6
|
-
const useRemoteApiDefs = await promptSelect({
|
|
7
|
-
message: 'Always use remote API Definitions?',
|
|
8
|
-
choices: [
|
|
9
|
-
{
|
|
10
|
-
label: 'Yes',
|
|
11
|
-
value: true,
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
label: 'No',
|
|
15
|
-
value: false,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
})
|
|
19
|
-
|
|
20
|
-
setUseRemoteApiDefs(useRemoteApiDefs)
|
|
21
|
-
getOutput().info(`Use remote API Definitions: ${useRemoteApiDefs}`)
|
|
22
|
-
}
|