@seamapi/cli 0.21.0 → 0.23.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 +39 -4
- package/bin/cli.js +29 -9
- package/bin/cli.js.map +1 -1
- package/lib/args/parse.d.ts +9 -0
- package/lib/args/parse.js +42 -2
- package/lib/args/parse.js.map +1 -1
- package/lib/args/validate.d.ts +10 -0
- package/lib/args/validate.js +23 -0
- package/lib/args/validate.js.map +1 -1
- package/lib/auth/operations.d.ts +13 -15
- package/lib/auth/operations.js +25 -48
- package/lib/auth/operations.js.map +1 -1
- package/lib/blueprint/source-npm.js +2 -2
- package/lib/blueprint/source-npm.js.map +1 -1
- package/lib/commands/local/login.js +4 -12
- package/lib/commands/local/login.js.map +1 -1
- package/lib/commands/local/select-endpoint.js +10 -7
- package/lib/commands/local/select-endpoint.js.map +1 -1
- package/lib/commands/local/select-workspace.js +12 -4
- package/lib/commands/local/select-workspace.js.map +1 -1
- 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.d.ts +11 -0
- package/lib/commands/registry.js +11 -0
- package/lib/commands/registry.js.map +1 -1
- package/lib/commands/spec.d.ts +12 -0
- package/lib/commands/spec.js +16 -0
- package/lib/commands/spec.js.map +1 -1
- package/lib/config/cli-config.d.ts +19 -0
- package/lib/config/cli-config.js +51 -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 +8 -7
- package/lib/context.js +26 -21
- 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/login.js +2 -2
- package/lib/interactions/login.js.map +1 -1
- package/lib/interactions/workspace-id.js +2 -2
- package/lib/interactions/workspace-id.js.map +1 -1
- package/lib/overrides.d.ts +20 -0
- package/lib/overrides.js +23 -0
- package/lib/overrides.js.map +1 -0
- package/lib/render/help.js +20 -1
- package/lib/render/help.js.map +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 +34 -9
- package/src/lib/args/parse.ts +47 -2
- package/src/lib/args/validate.ts +37 -0
- package/src/lib/auth/operations.ts +26 -56
- package/src/lib/blueprint/source-npm.ts +2 -3
- package/src/lib/commands/local/login.ts +4 -15
- package/src/lib/commands/local/select-endpoint.ts +11 -7
- package/src/lib/commands/local/select-workspace.ts +13 -4
- package/src/lib/commands/local/wizard.ts +48 -0
- package/src/lib/commands/registry.ts +20 -0
- package/src/lib/commands/spec.ts +31 -0
- package/src/lib/config/cli-config.ts +83 -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 +34 -33
- package/src/lib/interactions/endpoint-selection.ts +2 -2
- package/src/lib/interactions/login.ts +2 -2
- package/src/lib/interactions/workspace-id.ts +2 -2
- package/src/lib/overrides.ts +32 -0
- package/src/lib/render/help.ts +21 -1
- package/src/lib/version.ts +1 -1
package/lib/context.js
CHANGED
|
@@ -1,33 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { getConfig } from './config/index.js';
|
|
2
2
|
import { getEndpointFromEnv, getTokenFromEnv, getWorkspaceIdFromEnv, } from './env.js';
|
|
3
|
+
import { getAuthOverrides } from './overrides.js';
|
|
3
4
|
export const defaultEndpoint = 'https://connect.getseam.com';
|
|
4
|
-
export const resolveAuth = (config =
|
|
5
|
+
export const resolveAuth = (config = getConfig()) => {
|
|
6
|
+
const { endpoint: flagEndpoint, workspaceId: flagWorkspaceId } = getAuthOverrides();
|
|
5
7
|
const envEndpoint = getEndpointFromEnv();
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const storedEndpoint = config.get('endpoint') ?? config.get('server');
|
|
9
|
-
const endpoint = envEndpoint ?? (typeof storedEndpoint === 'string' ? storedEndpoint : null);
|
|
8
|
+
const storedEndpoint = config.getEndpoint();
|
|
9
|
+
const endpoint = flagEndpoint ?? envEndpoint ?? storedEndpoint;
|
|
10
10
|
const envToken = getTokenFromEnv();
|
|
11
|
-
|
|
11
|
+
// The token is stored per endpoint, so an overridden endpoint is read with
|
|
12
|
+
// the token belonging to it rather than the one it replaced.
|
|
13
|
+
const storedToken = config.getToken(endpoint ?? defaultEndpoint);
|
|
12
14
|
const envWorkspaceId = getWorkspaceIdFromEnv();
|
|
13
|
-
const storedWorkspaceId =
|
|
15
|
+
const storedWorkspaceId = config.getWorkspace();
|
|
16
|
+
const workspaceId = flagWorkspaceId ?? envWorkspaceId ?? storedWorkspaceId;
|
|
14
17
|
return {
|
|
15
18
|
endpoint: endpoint ?? defaultEndpoint,
|
|
16
|
-
endpointSource:
|
|
19
|
+
endpointSource: flagEndpoint != null
|
|
20
|
+
? 'flag'
|
|
21
|
+
: envEndpoint != null
|
|
22
|
+
? 'env'
|
|
23
|
+
: endpoint != null
|
|
24
|
+
? 'config'
|
|
25
|
+
: 'default',
|
|
17
26
|
token: envToken ?? storedToken,
|
|
18
27
|
tokenSource: envToken != null ? 'env' : storedToken != null ? 'config' : null,
|
|
19
|
-
workspaceId
|
|
20
|
-
workspaceIdSource:
|
|
21
|
-
? '
|
|
22
|
-
:
|
|
23
|
-
? '
|
|
24
|
-
: null
|
|
28
|
+
workspaceId,
|
|
29
|
+
workspaceIdSource: flagWorkspaceId != null
|
|
30
|
+
? 'flag'
|
|
31
|
+
: envWorkspaceId != null
|
|
32
|
+
? 'env'
|
|
33
|
+
: storedWorkspaceId != null
|
|
34
|
+
? 'config'
|
|
35
|
+
: null,
|
|
25
36
|
};
|
|
26
37
|
};
|
|
27
|
-
const readString = (value) => {
|
|
28
|
-
if (typeof value !== 'string')
|
|
29
|
-
return null;
|
|
30
|
-
const trimmedValue = value.trim();
|
|
31
|
-
return trimmedValue === '' ? null : trimmedValue;
|
|
32
|
-
};
|
|
33
38
|
//# sourceMappingURL=context.js.map
|
package/lib/context.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/lib/context.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/lib/context.ts"],"names":[],"mappings":"AAEA,OAAO,EAAkB,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7D,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,qBAAqB,GACtB,MAAM,UAAU,CAAA;AAGjB,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAEjD,MAAM,CAAC,MAAM,eAAe,GAAG,6BAA6B,CAAA;AAsB5D,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAoB,SAAS,EAAE,EAAe,EAAE;IAC1E,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,GAC5D,gBAAgB,EAAE,CAAA;IAEpB,MAAM,WAAW,GAAG,kBAAkB,EAAE,CAAA;IACxC,MAAM,cAAc,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;IAC3C,MAAM,QAAQ,GAAG,YAAY,IAAI,WAAW,IAAI,cAAc,CAAA;IAE9D,MAAM,QAAQ,GAAG,eAAe,EAAE,CAAA;IAClC,2EAA2E;IAC3E,6DAA6D;IAC7D,MAAM,WAAW,GAAG,MAAM,CAAC,QAAQ,CAAC,QAAQ,IAAI,eAAe,CAAC,CAAA;IAEhE,MAAM,cAAc,GAAG,qBAAqB,EAAE,CAAA;IAC9C,MAAM,iBAAiB,GAAG,MAAM,CAAC,YAAY,EAAE,CAAA;IAC/C,MAAM,WAAW,GAAG,eAAe,IAAI,cAAc,IAAI,iBAAiB,CAAA;IAE1E,OAAO;QACL,QAAQ,EAAE,QAAQ,IAAI,eAAe;QACrC,cAAc,EACZ,YAAY,IAAI,IAAI;YAClB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,WAAW,IAAI,IAAI;gBACnB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,QAAQ,IAAI,IAAI;oBAChB,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,SAAS;QACnB,KAAK,EAAE,QAAQ,IAAI,WAAW;QAC9B,WAAW,EACT,QAAQ,IAAI,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI;QAClE,WAAW;QACX,iBAAiB,EACf,eAAe,IAAI,IAAI;YACrB,CAAC,CAAC,MAAM;YACR,CAAC,CAAC,cAAc,IAAI,IAAI;gBACtB,CAAC,CAAC,KAAK;gBACP,CAAC,CAAC,iBAAiB,IAAI,IAAI;oBACzB,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,IAAI;KACf,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { assertMutable, selectEndpoint } from '../auth/operations.js';
|
|
2
|
-
import {
|
|
2
|
+
import { getConfig } from '../config/index.js';
|
|
3
3
|
import { resolveAuth } from '../context.js';
|
|
4
4
|
import { getOutput } from '../output/get-output.js';
|
|
5
5
|
import { promptAutocomplete } from '../prompt.js';
|
|
6
6
|
export async function interactForEndpointSelection() {
|
|
7
|
-
const config =
|
|
7
|
+
const config = getConfig();
|
|
8
8
|
assertMutable(resolveAuth(config), 'endpoint', 'select an endpoint');
|
|
9
9
|
const endpoints = ['http://localhost:3020', 'https://connect.getseam.com'];
|
|
10
10
|
// Searchable, as selecting a device or a command is.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoint-selection.js","sourceRoot":"","sources":["../../src/lib/interactions/endpoint-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"endpoint-selection.js","sourceRoot":"","sources":["../../src/lib/interactions/endpoint-selection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAA;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAElD,MAAM,CAAC,KAAK,UAAU,4BAA4B;IAChD,MAAM,MAAM,GAAG,SAAS,EAAE,CAAA;IAC1B,aAAa,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,oBAAoB,CAAC,CAAA;IAEpE,MAAM,SAAS,GAAG,CAAC,uBAAuB,EAAE,6BAA6B,CAAC,CAAA;IAE1E,qDAAqD;IACrD,MAAM,QAAQ,GAAG,MAAM,kBAAkB,CAAC;QACxC,OAAO,EAAE,qBAAqB;QAC9B,OAAO,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;YACpC,KAAK,EAAE,QAAQ;YACf,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;KACJ,CAAC,CAAA;IAEF,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;IAChC,SAAS,EAAE,CAAC,IAAI,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAA;AACjD,CAAC"}
|
|
@@ -2,14 +2,14 @@ import { isApiKey, isPersonalAccessToken } from '@seamapi/http/connect';
|
|
|
2
2
|
import chalk from 'chalk';
|
|
3
3
|
import { assertMutable, storeToken } from '../auth/operations.js';
|
|
4
4
|
import { validateToken } from '../auth/validate-token.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getConfig } from '../config/index.js';
|
|
6
6
|
import { resolveAuth } from '../context.js';
|
|
7
7
|
import { getOutput } from '../output/get-output.js';
|
|
8
8
|
import { withLoading } from '../output/with-loading.js';
|
|
9
9
|
import { promptText } from '../prompt.js';
|
|
10
10
|
import { interactForWorkspaceId } from './workspace-id.js';
|
|
11
11
|
export const interactForLogin = async () => {
|
|
12
|
-
const config =
|
|
12
|
+
const config = getConfig();
|
|
13
13
|
const output = getOutput();
|
|
14
14
|
const auth = resolveAuth(config);
|
|
15
15
|
// Refuse before prompting: nothing typed here could be stored.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/interactions/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"login.js","sourceRoot":"","sources":["../../src/lib/interactions/login.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AACvE,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAA;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,SAAS,EA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,CAAC,CAAC,CAAA;IACxE,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CACb,4DAA4D,CAC7D,CAAA;IACH,CAAC;IAED,UAAU,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACzB,MAAM,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAA;AAC1D,CAAC,CAAA"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { SeamHttpWithoutWorkspace } from '@seamapi/http/connect';
|
|
2
2
|
import { assertMutable, selectWorkspace } from '../auth/operations.js';
|
|
3
|
-
import {
|
|
3
|
+
import { getConfig } from '../config/index.js';
|
|
4
4
|
import { resolveAuth } from '../context.js';
|
|
5
5
|
import { getSeamMultiWorkspace } from '../http/client.js';
|
|
6
6
|
import { withLoading } from '../output/with-loading.js';
|
|
7
7
|
import { promptAutocomplete } from '../prompt.js';
|
|
8
8
|
export const interactForWorkspaceId = async (personalAccessToken) => {
|
|
9
|
-
const config =
|
|
9
|
+
const config = getConfig();
|
|
10
10
|
// Refuse before prompting: nothing selected here could be stored.
|
|
11
11
|
assertMutable(resolveAuth(config), 'workspaceId', 'select a workspace');
|
|
12
12
|
const seam = personalAccessToken
|
|
@@ -1 +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,
|
|
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,SAAS,EAAE,MAAM,qBAAq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
* The endpoint and workspace may be overridden for a single command.
|
|
3
|
+
*
|
|
4
|
+
* `--endpoint` and `--workspace-id` change what one invocation resolves to
|
|
5
|
+
* and are never stored: only `seam select endpoint` and `seam select
|
|
6
|
+
* workspace` write those settings. They are held here rather than threaded
|
|
7
|
+
* through every call because auth resolves ambiently, exactly as the
|
|
8
|
+
* environment variables they shadow do (see `env.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Set once from the parsed arguments before anything resolves auth, and
|
|
11
|
+
* reset between tests.
|
|
12
|
+
*/
|
|
13
|
+
export interface AuthOverrides {
|
|
14
|
+
endpoint: string | null;
|
|
15
|
+
workspaceId: string | null;
|
|
16
|
+
}
|
|
17
|
+
export declare const getAuthOverrides: () => AuthOverrides;
|
|
18
|
+
export declare const setAuthOverrides: (next: AuthOverrides) => void;
|
|
19
|
+
/** Drop the overrides, e.g., between tests sharing a process. */
|
|
20
|
+
export declare const resetAuthOverrides: () => void;
|
package/lib/overrides.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The endpoint and workspace may be overridden for a single command.
|
|
3
|
+
*
|
|
4
|
+
* `--endpoint` and `--workspace-id` change what one invocation resolves to
|
|
5
|
+
* and are never stored: only `seam select endpoint` and `seam select
|
|
6
|
+
* workspace` write those settings. They are held here rather than threaded
|
|
7
|
+
* through every call because auth resolves ambiently, exactly as the
|
|
8
|
+
* environment variables they shadow do (see `env.ts`).
|
|
9
|
+
*
|
|
10
|
+
* Set once from the parsed arguments before anything resolves auth, and
|
|
11
|
+
* reset between tests.
|
|
12
|
+
*/
|
|
13
|
+
const noOverrides = { endpoint: null, workspaceId: null };
|
|
14
|
+
let overrides = noOverrides;
|
|
15
|
+
export const getAuthOverrides = () => overrides;
|
|
16
|
+
export const setAuthOverrides = (next) => {
|
|
17
|
+
overrides = next;
|
|
18
|
+
};
|
|
19
|
+
/** Drop the overrides, e.g., between tests sharing a process. */
|
|
20
|
+
export const resetAuthOverrides = () => {
|
|
21
|
+
overrides = noOverrides;
|
|
22
|
+
};
|
|
23
|
+
//# sourceMappingURL=overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"overrides.js","sourceRoot":"","sources":["../src/lib/overrides.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAOH,MAAM,WAAW,GAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,CAAA;AAExE,IAAI,SAAS,GAAkB,WAAW,CAAA;AAE1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAkB,EAAE,CAAC,SAAS,CAAA;AAE9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAmB,EAAQ,EAAE;IAC5D,SAAS,GAAG,IAAI,CAAA;AAClB,CAAC,CAAA;AAED,iEAAiE;AACjE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAS,EAAE;IAC3C,SAAS,GAAG,WAAW,CAAA;AACzB,CAAC,CAAA"}
|
package/lib/render/help.js
CHANGED
|
@@ -101,12 +101,31 @@ const commandSectionsForGroup = (group, isRoot) => {
|
|
|
101
101
|
const commandSections = (command, spec) => {
|
|
102
102
|
const name = ['seam', ...command.path].join(' ');
|
|
103
103
|
const hasFlags = command.flags.length > 0;
|
|
104
|
+
const { positional } = command;
|
|
104
105
|
return [
|
|
105
106
|
{
|
|
106
107
|
header: name,
|
|
107
108
|
content: [command.title, command.description].filter((line) => line !== ''),
|
|
108
109
|
},
|
|
109
|
-
{
|
|
110
|
+
{
|
|
111
|
+
header: 'Usage',
|
|
112
|
+
content: positional == null
|
|
113
|
+
? `${name} [options]`
|
|
114
|
+
: `${name} <${positional.name}> [options]`,
|
|
115
|
+
},
|
|
116
|
+
...(positional == null
|
|
117
|
+
? []
|
|
118
|
+
: [
|
|
119
|
+
{
|
|
120
|
+
header: 'Arguments',
|
|
121
|
+
content: [
|
|
122
|
+
{
|
|
123
|
+
name: `{underline <${positional.name}>}`,
|
|
124
|
+
summary: positional.description,
|
|
125
|
+
},
|
|
126
|
+
],
|
|
127
|
+
},
|
|
128
|
+
]),
|
|
110
129
|
// The command's own parameters are what the request is made of, so keep
|
|
111
130
|
// them apart from the options every seam command takes.
|
|
112
131
|
...(hasFlags ? [optionSection(command.flags, 'Parameters')] : []),
|
package/lib/render/help.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"help.js","sourceRoot":"","sources":["../../src/lib/render/help.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,EAAE,EAAgB,MAAM,oBAAoB,CAAA;AAEnE,OAAO,EAKL,WAAW,EACX,SAAS,GACV,MAAM,sBAAsB,CAAA;AAE7B;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,IAAc,EACd,IAAiB,EACF,EAAE;IACjB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACnC,IAAI,KAAK,IAAI,IAAI;QAAE,OAAO,gBAAgB,CAAC,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAA;IAEtE,MAAM,OAAO,GAAG,WAAW,CAAC,IAAI,EAAE,IAAI,CAAC,CAAA;IACvC,IAAI,OAAO,IAAI,IAAI;QAAE,OAAO,gBAAgB,CAAC,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAA;IAE5E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,MAAM,QAAQ,GACZ,qNAAqN,CAAA;AAEvN,MAAM,aAAa,GAAG;IACpB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE;QACP,gIAAgI;QAChI,6DAA6D;QAC7D,2HAA2H;KAC5H;CACF,CAAA;AAED,MAAM,QAAQ,GAAG;IACf,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,2CAA2C,EAAE;IACtE,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE;IACjD,EAAE,IAAI,EA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AAC,CAAC,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC9D,WAAW;KACZ,CAAA;AACH,CAAC,CAAA;AAED,MAAM,cAAc,GAAG,CAAC,IAAiB,EAAU,EAAE;IACnD,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,CAAA;IAEvC,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;IAClE,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,mBAAmB,CAAA;IAErD,OAAO,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,KAAK,SAAS,IAAI,QAAQ,CAAC,CAAC,CAAC,WAAW,KAAK,GAAG,CAAA;AAC/E,CAAC,CAAA"}
|
package/lib/version.d.ts
CHANGED
package/lib/version.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@seamapi/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.23.0",
|
|
4
4
|
"description": "A command-line interface (CLI) for interacting with the Seam API.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "index.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@clack/prompts": "^1.7.0",
|
|
96
96
|
"@seamapi/blueprint": "1.5.0",
|
|
97
97
|
"@seamapi/http": "2.2.0",
|
|
98
|
-
"@seamapi/wizard": "0.
|
|
98
|
+
"@seamapi/wizard": "0.7.0",
|
|
99
99
|
"chalk": "^6.0.0",
|
|
100
100
|
"command-line-usage": "^7.0.4",
|
|
101
101
|
"configstore": "^8.0.0",
|
package/src/bin/cli.ts
CHANGED
|
@@ -8,9 +8,10 @@ import {
|
|
|
8
8
|
cliFlags,
|
|
9
9
|
getInteractivity,
|
|
10
10
|
parseCliArgs,
|
|
11
|
+
toAuthOverrides,
|
|
11
12
|
toParameterName,
|
|
12
13
|
} from 'lib/args/parse.js'
|
|
13
|
-
import { assertKnownArgs } from 'lib/args/validate.js'
|
|
14
|
+
import { assertKnownArgs, assertNoAuthOverrides } from 'lib/args/validate.js'
|
|
14
15
|
import { getApiBlueprint } from 'lib/blueprint/index.js'
|
|
15
16
|
import { printCompletion } from 'lib/commands/local/completion.js'
|
|
16
17
|
import { runWizard } from 'lib/commands/local/wizard.js'
|
|
@@ -18,8 +19,9 @@ import {
|
|
|
18
19
|
acceptedParamsOf,
|
|
19
20
|
buildRegistry,
|
|
20
21
|
findLocalCommand,
|
|
22
|
+
findLocalCommandTakingPositional,
|
|
21
23
|
} from 'lib/commands/registry.js'
|
|
22
|
-
import {
|
|
24
|
+
import { getConfig } from 'lib/config/index.js'
|
|
23
25
|
import { type CliContext, resolveAuth } from 'lib/context.js'
|
|
24
26
|
import { tokenEnvVar } from 'lib/env.js'
|
|
25
27
|
import { reportErrorAndExit } from 'lib/errors.js'
|
|
@@ -29,6 +31,7 @@ import { getOutput, setOutput } from 'lib/output/get-output.js'
|
|
|
29
31
|
import { createOutput } from 'lib/output/output.js'
|
|
30
32
|
import { readStdinJson } from 'lib/output/read-stdin-json.js'
|
|
31
33
|
import { resolveOutputFormat } from 'lib/output/resolve-output-format.js'
|
|
34
|
+
import { setAuthOverrides } from 'lib/overrides.js'
|
|
32
35
|
import { canPrompt } from 'lib/prompt.js'
|
|
33
36
|
import {
|
|
34
37
|
completionShells,
|
|
@@ -38,9 +41,24 @@ import { renderHelp } from 'lib/render/help.js'
|
|
|
38
41
|
import seamapiCliVersion from 'lib/version.js'
|
|
39
42
|
|
|
40
43
|
async function cli(args: ParsedArgs, argv: string[]) {
|
|
41
|
-
const config =
|
|
44
|
+
const config = getConfig()
|
|
42
45
|
const output = getOutput()
|
|
43
46
|
|
|
47
|
+
// Scoped to this one command, and read wherever auth resolves, so they are
|
|
48
|
+
// in place before anything asks what the endpoint or the workspace is.
|
|
49
|
+
const authOverrides = toAuthOverrides(args)
|
|
50
|
+
setAuthOverrides(authOverrides)
|
|
51
|
+
|
|
52
|
+
// A command may take one value after its path, e.g., the URL in 'seam
|
|
53
|
+
// select endpoint <url>'. Split it off before the path is normalized, or
|
|
54
|
+
// lowercasing the path would rewrite the value along with it.
|
|
55
|
+
const commandWords = args._.map(toCommandWord)
|
|
56
|
+
const commandTakingPositional = findLocalCommandTakingPositional(commandWords)
|
|
57
|
+
const positional =
|
|
58
|
+
commandTakingPositional == null ? undefined : String(args._.at(-1))
|
|
59
|
+
args._ =
|
|
60
|
+
commandTakingPositional == null ? commandWords : commandWords.slice(0, -1)
|
|
61
|
+
|
|
44
62
|
const update = args['update'] === true
|
|
45
63
|
|
|
46
64
|
const helpFlag = args['help'] ?? args['h']
|
|
@@ -75,8 +93,6 @@ async function cli(args: ParsedArgs, argv: string[]) {
|
|
|
75
93
|
return
|
|
76
94
|
}
|
|
77
95
|
|
|
78
|
-
args._ = args._.map(toCommandWord)
|
|
79
|
-
|
|
80
96
|
// Argument keys name parameters however they are written, so normalize each
|
|
81
97
|
// one to the name the API gives it. Replace the key rather than adding the
|
|
82
98
|
// normalized form alongside it, or an argument would be sent twice: once as
|
|
@@ -121,6 +137,12 @@ async function cli(args: ParsedArgs, argv: string[]) {
|
|
|
121
137
|
|
|
122
138
|
const localCommand = findLocalCommand(args._)
|
|
123
139
|
|
|
140
|
+
// Before the login gate, so a command that selects reports the flag it
|
|
141
|
+
// cannot take rather than whatever the flag pointed it at.
|
|
142
|
+
if (localCommand != null) {
|
|
143
|
+
assertNoAuthOverrides(localCommand.definition, authOverrides)
|
|
144
|
+
}
|
|
145
|
+
|
|
124
146
|
// Commands declared not to need a token bypass the login gate. A partial
|
|
125
147
|
// path keeps the historical rule: only login and select endpoint may be
|
|
126
148
|
// reached logged out.
|
|
@@ -136,7 +158,7 @@ async function cli(args: ParsedArgs, argv: string[]) {
|
|
|
136
158
|
}
|
|
137
159
|
|
|
138
160
|
const useRemoteApiDefs =
|
|
139
|
-
args['remote_api_defs'] ?? config.
|
|
161
|
+
args['remote_api_defs'] ?? config.getUseRemoteApiDefs()
|
|
140
162
|
|
|
141
163
|
const blueprint = await getApiBlueprint({
|
|
142
164
|
useRemoteDefinitions: useRemoteApiDefs ?? false,
|
|
@@ -185,13 +207,14 @@ async function cli(args: ParsedArgs, argv: string[]) {
|
|
|
185
207
|
|
|
186
208
|
// Check the arguments before the command acts on any of them, so a
|
|
187
209
|
// mistake is reported rather than half applied.
|
|
210
|
+
assertNoAuthOverrides(command.definition, authOverrides)
|
|
188
211
|
assertKnownArgs(argParams, selectedCommand, {
|
|
189
212
|
accepted: acceptedParamsOf(command.definition),
|
|
190
213
|
isLocal: findLocalCommand(selectedCommand) != null,
|
|
191
214
|
})
|
|
192
215
|
|
|
193
216
|
const result = await command.execute(
|
|
194
|
-
{ path: selectedCommand, argParams, stdinParams, args, argv },
|
|
217
|
+
{ path: selectedCommand, positional, argParams, stdinParams, args, argv },
|
|
195
218
|
ctx,
|
|
196
219
|
)
|
|
197
220
|
|
|
@@ -204,8 +227,10 @@ async function cli(args: ParsedArgs, argv: string[]) {
|
|
|
204
227
|
}
|
|
205
228
|
}
|
|
206
229
|
|
|
207
|
-
|
|
208
|
-
|
|
230
|
+
// minimist reads a numeric word as a number, so a command path is only a
|
|
231
|
+
// path once every word is one.
|
|
232
|
+
const toCommandWord = (arg: string | number): string =>
|
|
233
|
+
String(arg).toLowerCase().replace(/_/g, '-')
|
|
209
234
|
|
|
210
235
|
const run = async (argv: string[]) => {
|
|
211
236
|
if (argv[0] === 'wizard') {
|
package/src/lib/args/parse.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import parseArgs, { type ParsedArgs } from 'minimist'
|
|
2
2
|
|
|
3
|
+
import type { AuthOverrides } from 'lib/overrides.js'
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* How the CLI should behave when properties are not given as arguments.
|
|
5
7
|
*
|
|
@@ -29,12 +31,14 @@ export const interactivityFlags: string[] = [
|
|
|
29
31
|
*/
|
|
30
32
|
export const cliFlags: string[] = [
|
|
31
33
|
...interactivityFlags,
|
|
34
|
+
'endpoint',
|
|
32
35
|
'h',
|
|
33
36
|
'help',
|
|
34
37
|
'json',
|
|
35
38
|
'remote_api_defs',
|
|
36
39
|
'update',
|
|
37
40
|
'version',
|
|
41
|
+
'workspace_id',
|
|
38
42
|
]
|
|
39
43
|
|
|
40
44
|
export interface ParseCliArgsOptions {
|
|
@@ -53,8 +57,18 @@ export const parseCliArgs = (
|
|
|
53
57
|
): ParsedArgs =>
|
|
54
58
|
parseArgs(argv, {
|
|
55
59
|
// A page cursor and a code are opaque even before the endpoint's own
|
|
56
|
-
// parameter types are known, so always keep them exactly as given.
|
|
57
|
-
|
|
60
|
+
// parameter types are known, so always keep them exactly as given. The
|
|
61
|
+
// overrides are read as given for the same reason: a URL or an id is
|
|
62
|
+
// never a number, however it happens to be spelled.
|
|
63
|
+
string: [
|
|
64
|
+
'code',
|
|
65
|
+
'endpoint',
|
|
66
|
+
'page-cursor',
|
|
67
|
+
'page_cursor',
|
|
68
|
+
'workspace-id',
|
|
69
|
+
'workspace_id',
|
|
70
|
+
...stringKeys,
|
|
71
|
+
],
|
|
58
72
|
boolean: ['non-interactive', 'interactive', 'json'],
|
|
59
73
|
// Deliberately not aliased to -n, which is reserved for a future
|
|
60
74
|
// --dry-run flag.
|
|
@@ -76,6 +90,37 @@ export const toArgParams = (args: ParsedArgs): Record<string, unknown> => {
|
|
|
76
90
|
return argParams
|
|
77
91
|
}
|
|
78
92
|
|
|
93
|
+
/**
|
|
94
|
+
* The auth overrides among the parsed arguments.
|
|
95
|
+
*
|
|
96
|
+
* Both scope a single command: they change what it resolves to and are never
|
|
97
|
+
* stored, so they read like the environment variables they take precedence
|
|
98
|
+
* over, down to treating a blank value as though it were not given.
|
|
99
|
+
*/
|
|
100
|
+
export const toAuthOverrides = (args: ParsedArgs): AuthOverrides => {
|
|
101
|
+
// Read by the name each key names, as every other argument is, so the
|
|
102
|
+
// overrides may be written `--workspace-id`, `--workspace_id`, or in caps,
|
|
103
|
+
// and so they resolve whenever they are read.
|
|
104
|
+
const byName: Record<string, unknown> = {}
|
|
105
|
+
for (const [key, value] of Object.entries(args)) {
|
|
106
|
+
if (key === '_') continue
|
|
107
|
+
byName[toParameterName(key)] = value
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return {
|
|
111
|
+
endpoint: readOverride(byName['endpoint']),
|
|
112
|
+
workspaceId: readOverride(byName['workspace_id']),
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const readOverride = (value: unknown): string | null => {
|
|
117
|
+
if (typeof value !== 'string') return null
|
|
118
|
+
|
|
119
|
+
const trimmedValue = value.trim()
|
|
120
|
+
|
|
121
|
+
return trimmedValue === '' ? null : trimmedValue
|
|
122
|
+
}
|
|
123
|
+
|
|
79
124
|
export interface GetInteractivityOptions {
|
|
80
125
|
/**
|
|
81
126
|
* Whether there is a terminal to prompt on.
|
package/src/lib/args/validate.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Parameter } from '@seamapi/blueprint'
|
|
2
2
|
|
|
3
|
+
import type { CommandDefinition } from 'lib/commands/spec.js'
|
|
3
4
|
import { NonInteractiveError, UsageError } from 'lib/errors.js'
|
|
5
|
+
import type { AuthOverrides } from 'lib/overrides.js'
|
|
4
6
|
|
|
5
7
|
import { toArgName, toGivenArgName } from './parse.js'
|
|
6
8
|
|
|
@@ -40,6 +42,41 @@ export const assertRequiredParams = (
|
|
|
40
42
|
* Only arguments are checked. Params read from stdin are passed through as
|
|
41
43
|
* given, so a caller may send whatever the API itself accepts.
|
|
42
44
|
*/
|
|
45
|
+
/**
|
|
46
|
+
* Refuse the auth overrides on a command that selects what they override.
|
|
47
|
+
*
|
|
48
|
+
* `--endpoint` and `--workspace-id` scope one command and are never stored,
|
|
49
|
+
* so on `seam select ...` they would read as the value to store and quietly
|
|
50
|
+
* do nothing of the kind. The positional is what stores.
|
|
51
|
+
*/
|
|
52
|
+
export const assertNoAuthOverrides = (
|
|
53
|
+
{ path, positional }: CommandDefinition,
|
|
54
|
+
overrides: AuthOverrides,
|
|
55
|
+
): void => {
|
|
56
|
+
if (path[0] !== 'select') return
|
|
57
|
+
|
|
58
|
+
const given = [
|
|
59
|
+
overrides.endpoint == null ? null : '--endpoint',
|
|
60
|
+
overrides.workspaceId == null ? null : '--workspace-id',
|
|
61
|
+
].filter((flag) => flag != null)
|
|
62
|
+
|
|
63
|
+
if (given.length === 0) return
|
|
64
|
+
|
|
65
|
+
const command = `seam ${path.join(' ')}`
|
|
66
|
+
|
|
67
|
+
throw new UsageError(
|
|
68
|
+
`${given.join(' and ')} cannot be used with ${command}: ${
|
|
69
|
+
given.length === 1 ? 'it overrides' : 'they override'
|
|
70
|
+
} a single command rather than changing what is selected.`,
|
|
71
|
+
{
|
|
72
|
+
hint:
|
|
73
|
+
positional == null
|
|
74
|
+
? `Run '${command}' to change what is selected.`
|
|
75
|
+
: `Run '${command} <${positional.name}>' to change what is selected.`,
|
|
76
|
+
},
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
|
|
43
80
|
export const assertKnownArgs = (
|
|
44
81
|
argParams: Record<string, unknown>,
|
|
45
82
|
command: string[],
|