@forgecart/cli 2.202610122040.0 → 2.202610122318.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/dist/src/admin-api/admin-api-interruption.error.d.ts +11 -0
- package/dist/src/admin-api/admin-api-interruption.error.js +17 -0
- package/dist/src/admin-api/admin-api-interruption.error.js.map +1 -0
- package/dist/src/{sync/sync-api.error.d.ts → admin-api/admin-api-refusal.error.d.ts} +2 -2
- package/dist/src/{sync/sync-api.error.js → admin-api/admin-api-refusal.error.js} +5 -5
- package/dist/src/admin-api/admin-api-refusal.error.js.map +1 -0
- package/dist/src/admin-api/admin-api.client.d.ts +51 -0
- package/dist/src/admin-api/admin-api.client.js +157 -0
- package/dist/src/admin-api/admin-api.client.js.map +1 -0
- package/dist/src/admin-api/admin-api.result.d.ts +24 -0
- package/dist/src/admin-api/admin-api.result.js +75 -0
- package/dist/src/admin-api/admin-api.result.js.map +1 -0
- package/dist/src/admin-api/type/admin-api.types.d.ts +10 -0
- package/dist/src/admin-api/type/admin-api.types.js +2 -0
- package/dist/src/admin-api/type/admin-api.types.js.map +1 -0
- package/dist/src/authorization/cli-credential-check.d.ts +9 -1
- package/dist/src/authorization/cli-credential-check.js +19 -1
- package/dist/src/authorization/cli-credential-check.js.map +1 -1
- package/dist/src/cli.js +2 -1
- package/dist/src/cli.js.map +1 -1
- package/dist/src/commands/deploy.d.ts +8 -0
- package/dist/src/commands/deploy.js +23 -0
- package/dist/src/commands/deploy.js.map +1 -0
- package/dist/src/commands/placeholders.d.ts +0 -2
- package/dist/src/commands/placeholders.js +0 -9
- package/dist/src/commands/placeholders.js.map +1 -1
- package/dist/src/commands/sync.js +2 -8
- package/dist/src/commands/sync.js.map +1 -1
- package/dist/src/deploy/deploy-follow-bound.d.ts +37 -0
- package/dist/src/deploy/deploy-follow-bound.js +83 -0
- package/dist/src/deploy/deploy-follow-bound.js.map +1 -0
- package/dist/src/deploy/deploy-publish-refusal.d.ts +17 -0
- package/dist/src/deploy/deploy-publish-refusal.js +30 -0
- package/dist/src/deploy/deploy-publish-refusal.js.map +1 -0
- package/dist/src/deploy/deploy.runner.d.ts +23 -0
- package/dist/src/deploy/deploy.runner.js +58 -0
- package/dist/src/deploy/deploy.runner.js.map +1 -0
- package/dist/src/deploy/deployment-follow.d.ts +22 -0
- package/dist/src/deploy/deployment-follow.js +56 -0
- package/dist/src/deploy/deployment-follow.js.map +1 -0
- package/dist/src/deploy/deployment.client.d.ts +26 -0
- package/dist/src/deploy/deployment.client.js +70 -0
- package/dist/src/deploy/deployment.client.js.map +1 -0
- package/dist/src/deploy/type/deploy.types.d.ts +35 -0
- package/dist/src/deploy/type/deploy.types.js +15 -0
- package/dist/src/deploy/type/deploy.types.js.map +1 -0
- package/dist/src/sync/sync-repository.js +1 -0
- package/dist/src/sync/sync-repository.js.map +1 -1
- package/dist/src/sync/sync-round.js +3 -3
- package/dist/src/sync/sync-round.js.map +1 -1
- package/dist/src/sync/sync.runner.d.ts +0 -6
- package/dist/src/sync/sync.runner.js +3 -18
- package/dist/src/sync/sync.runner.js.map +1 -1
- package/dist/src/sync/workspace-sync.client.d.ts +7 -50
- package/dist/src/sync/workspace-sync.client.js +24 -214
- package/dist/src/sync/workspace-sync.client.js.map +1 -1
- package/dist/src/util/timeout-seconds.util.d.ts +2 -0
- package/dist/src/util/timeout-seconds.util.js +9 -0
- package/dist/src/util/timeout-seconds.util.js.map +1 -0
- package/package.json +1 -1
- package/dist/src/sync/sync-api.error.js.map +0 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An exchange the interrupt it was given ended before the admin API answered
|
|
3
|
+
* (#2781, #411) — Ctrl-C, or a bound the caller set on the run. What the
|
|
4
|
+
* interrupt means is the caller's to say: `forgecart sync` reports it as is,
|
|
5
|
+
* `forgecart deploy` as the end of its follow.
|
|
6
|
+
*/
|
|
7
|
+
export declare class AdminApiInterruption extends Error {
|
|
8
|
+
readonly endpoint: string;
|
|
9
|
+
readonly field: string;
|
|
10
|
+
constructor(endpoint: string, field: string, options: ErrorOptions);
|
|
11
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An exchange the interrupt it was given ended before the admin API answered
|
|
3
|
+
* (#2781, #411) — Ctrl-C, or a bound the caller set on the run. What the
|
|
4
|
+
* interrupt means is the caller's to say: `forgecart sync` reports it as is,
|
|
5
|
+
* `forgecart deploy` as the end of its follow.
|
|
6
|
+
*/
|
|
7
|
+
export class AdminApiInterruption extends Error {
|
|
8
|
+
endpoint;
|
|
9
|
+
field;
|
|
10
|
+
constructor(endpoint, field, options) {
|
|
11
|
+
super(`Interrupted while the admin API at ${endpoint} answered ${field}.`, options);
|
|
12
|
+
this.endpoint = endpoint;
|
|
13
|
+
this.field = field;
|
|
14
|
+
this.name = 'AdminApiInterruption';
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=admin-api-interruption.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-api-interruption.error.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api-interruption.error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,oBAAqB,SAAQ,KAAK;IAElC;IACA;IAFX,YACW,QAAgB,EAChB,KAAa,EACtB,OAAqB;QAErB,KAAK,CAAC,sCAAsC,QAAQ,aAAa,KAAK,GAAG,EAAE,OAAO,CAAC,CAAC;QAJ3E,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAQ;QAItB,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A typed refusal the admin API answered
|
|
2
|
+
* A typed refusal the admin API answered an operation with (#2781, #411): the
|
|
3
3
|
* `ErrorCode` its GraphQL error carries and the variables beside it — what a
|
|
4
4
|
* caller routes on. Credentials the API refuses are no such error: they end the
|
|
5
5
|
* run as `CliUnauthorizedRefusal`.
|
|
6
6
|
*/
|
|
7
|
-
export declare class
|
|
7
|
+
export declare class AdminApiRefusal extends Error {
|
|
8
8
|
readonly endpoint: string;
|
|
9
9
|
readonly field: string;
|
|
10
10
|
readonly code: string;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A typed refusal the admin API answered
|
|
2
|
+
* A typed refusal the admin API answered an operation with (#2781, #411): the
|
|
3
3
|
* `ErrorCode` its GraphQL error carries and the variables beside it — what a
|
|
4
4
|
* caller routes on. Credentials the API refuses are no such error: they end the
|
|
5
5
|
* run as `CliUnauthorizedRefusal`.
|
|
6
6
|
*/
|
|
7
|
-
export class
|
|
7
|
+
export class AdminApiRefusal extends Error {
|
|
8
8
|
endpoint;
|
|
9
9
|
field;
|
|
10
10
|
code;
|
|
11
11
|
variables;
|
|
12
12
|
constructor(endpoint, field, code, variables) {
|
|
13
|
-
super(`The admin API at ${endpoint} refused ${field}: ${code}${
|
|
13
|
+
super(`The admin API at ${endpoint} refused ${field}: ${code}${AdminApiRefusal.describe(variables)}.`);
|
|
14
14
|
this.endpoint = endpoint;
|
|
15
15
|
this.field = field;
|
|
16
16
|
this.code = code;
|
|
17
17
|
this.variables = variables;
|
|
18
|
-
this.name = '
|
|
18
|
+
this.name = 'AdminApiRefusal';
|
|
19
19
|
}
|
|
20
20
|
/** The variables as ` (key=value, …)` — nothing when there are none. */
|
|
21
21
|
static describe(variables) {
|
|
@@ -23,4 +23,4 @@ export class SyncApiError extends Error {
|
|
|
23
23
|
return pairs.length === 0 ? '' : ` (${pairs.join(', ')})`;
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
//# sourceMappingURL=
|
|
26
|
+
//# sourceMappingURL=admin-api-refusal.error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-api-refusal.error.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api-refusal.error.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAE7B;IACA;IACA;IACA;IAJX,YACW,QAAgB,EAChB,KAAa,EACb,IAAY,EACZ,SAA2C;QAEpD,KAAK,CACH,oBAAoB,QAAQ,YAAY,KAAK,KAAK,IAAI,GAAG,eAAe,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,CAChG,CAAC;QAPO,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAQ;QACb,SAAI,GAAJ,IAAI,CAAQ;QACZ,cAAS,GAAT,SAAS,CAAkC;QAKpD,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;IAED,wEAAwE;IAChE,MAAM,CAAC,QAAQ,CAAC,SAA2C;QACjE,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,GAAG,GAAG,IAAI,KAAK,EAAE,CAAC,CAAC;QACjF,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;IAC5D,CAAC;CACF"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { CliCredentials } from '../authorization/type/cli-authorization.types.js';
|
|
2
|
+
import { AdminApiResult } from './admin-api.result.js';
|
|
3
|
+
import type { AdminApiRequest } from './type/admin-api.types.js';
|
|
4
|
+
/**
|
|
5
|
+
* The admin API over GraphQL on HTTP (#2781, #411), with the channel token and
|
|
6
|
+
* the admin secret as the `forgecart-token` and `forgecart-secret` headers —
|
|
7
|
+
* the one surface `forgecart sync` and `forgecart deploy` reach the shop
|
|
8
|
+
* through. Every request goes to FORGECART_ADMIN_API_URL as given; every
|
|
9
|
+
* exchange is bounded by `--timeout` and ends when the interrupt it is given
|
|
10
|
+
* fires. Credentials the API refuses end the run on exit 3; any other refusal
|
|
11
|
+
* is an {@link AdminApiRefusal} carrying its code.
|
|
12
|
+
*/
|
|
13
|
+
export declare class AdminApiClient {
|
|
14
|
+
private readonly credentials;
|
|
15
|
+
private readonly timeoutSeconds;
|
|
16
|
+
/**
|
|
17
|
+
* @param credentials the four credentials the run settled.
|
|
18
|
+
* @param timeoutSeconds the bound on one exchange — `--timeout`.
|
|
19
|
+
*/
|
|
20
|
+
constructor(credentials: CliCredentials, timeoutSeconds: number);
|
|
21
|
+
/** A GraphQL request as JSON. */
|
|
22
|
+
jsonRequest(document: string, variables: Record<string, unknown>): AdminApiRequest;
|
|
23
|
+
/** The headers every request authenticates with — an upload's body sets its own content type. */
|
|
24
|
+
authHeaders(): Record<string, string>;
|
|
25
|
+
/**
|
|
26
|
+
* POST one operation and answer its root field. The exchange — the response
|
|
27
|
+
* and its whole body — is bounded by `--timeout` and ends with `interrupt`;
|
|
28
|
+
* an exchange given none runs to its answer or its bound.
|
|
29
|
+
*/
|
|
30
|
+
exchange(request: AdminApiRequest, field: string, interrupt?: AbortSignal): Promise<AdminApiResult>;
|
|
31
|
+
private get endpoint();
|
|
32
|
+
private post;
|
|
33
|
+
/** Why an exchange ended without an answer: the interrupt, `--timeout`, or the network. */
|
|
34
|
+
private exchangeFailure;
|
|
35
|
+
/** The response's GraphQL body — an answer that is not one names its HTTP status. */
|
|
36
|
+
private parseBody;
|
|
37
|
+
/** The root field, once the body carries no error. */
|
|
38
|
+
private rootField;
|
|
39
|
+
/**
|
|
40
|
+
* A GraphQL error ends the call: credentials refused as UNAUTHORIZED or
|
|
41
|
+
* FORBIDDEN on exit 3, any other code as the typed {@link AdminApiRefusal}.
|
|
42
|
+
*/
|
|
43
|
+
private assertNoErrors;
|
|
44
|
+
private extensionsOf;
|
|
45
|
+
private messageOf;
|
|
46
|
+
/** The variables a typed error carries, as text — none when it carries none. */
|
|
47
|
+
private errorVariables;
|
|
48
|
+
private notGraphQlMessage;
|
|
49
|
+
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
50
|
+
private failureDetail;
|
|
51
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { CliUnauthorizedReason, CliUnauthorizedRefusal, } from '../authorization/cli-unauthorized-refusal.js';
|
|
2
|
+
import { isJsonObject } from '../json.js';
|
|
3
|
+
import { AdminApiInterruption } from './admin-api-interruption.error.js';
|
|
4
|
+
import { AdminApiRefusal } from './admin-api-refusal.error.js';
|
|
5
|
+
import { AdminApiResult } from './admin-api.result.js';
|
|
6
|
+
/** The codes the admin API refuses an admin operation's credentials with. */
|
|
7
|
+
const CREDENTIAL_REFUSALS = new Set(['UNAUTHORIZED', 'FORBIDDEN']);
|
|
8
|
+
/** Milliseconds in a second — `--timeout` is given in seconds. */
|
|
9
|
+
const MS_PER_SECOND = 1000;
|
|
10
|
+
/**
|
|
11
|
+
* The admin API over GraphQL on HTTP (#2781, #411), with the channel token and
|
|
12
|
+
* the admin secret as the `forgecart-token` and `forgecart-secret` headers —
|
|
13
|
+
* the one surface `forgecart sync` and `forgecart deploy` reach the shop
|
|
14
|
+
* through. Every request goes to FORGECART_ADMIN_API_URL as given; every
|
|
15
|
+
* exchange is bounded by `--timeout` and ends when the interrupt it is given
|
|
16
|
+
* fires. Credentials the API refuses end the run on exit 3; any other refusal
|
|
17
|
+
* is an {@link AdminApiRefusal} carrying its code.
|
|
18
|
+
*/
|
|
19
|
+
export class AdminApiClient {
|
|
20
|
+
credentials;
|
|
21
|
+
timeoutSeconds;
|
|
22
|
+
/**
|
|
23
|
+
* @param credentials the four credentials the run settled.
|
|
24
|
+
* @param timeoutSeconds the bound on one exchange — `--timeout`.
|
|
25
|
+
*/
|
|
26
|
+
constructor(credentials, timeoutSeconds) {
|
|
27
|
+
this.credentials = credentials;
|
|
28
|
+
this.timeoutSeconds = timeoutSeconds;
|
|
29
|
+
}
|
|
30
|
+
/** A GraphQL request as JSON. */
|
|
31
|
+
jsonRequest(document, variables) {
|
|
32
|
+
return {
|
|
33
|
+
body: JSON.stringify({ query: document, variables }),
|
|
34
|
+
headers: { ...this.authHeaders(), 'content-type': 'application/json' },
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
/** The headers every request authenticates with — an upload's body sets its own content type. */
|
|
38
|
+
authHeaders() {
|
|
39
|
+
return {
|
|
40
|
+
accept: 'application/json',
|
|
41
|
+
'forgecart-token': this.credentials.channelToken,
|
|
42
|
+
'forgecart-secret': this.credentials.adminSecret,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* POST one operation and answer its root field. The exchange — the response
|
|
47
|
+
* and its whole body — is bounded by `--timeout` and ends with `interrupt`;
|
|
48
|
+
* an exchange given none runs to its answer or its bound.
|
|
49
|
+
*/
|
|
50
|
+
async exchange(request, field, interrupt) {
|
|
51
|
+
const bound = new AbortController();
|
|
52
|
+
const timer = setTimeout(() => {
|
|
53
|
+
bound.abort();
|
|
54
|
+
}, this.timeoutSeconds * MS_PER_SECOND);
|
|
55
|
+
const relay = () => {
|
|
56
|
+
bound.abort();
|
|
57
|
+
};
|
|
58
|
+
interrupt?.addEventListener('abort', relay, { once: true });
|
|
59
|
+
if (interrupt?.aborted === true)
|
|
60
|
+
bound.abort();
|
|
61
|
+
try {
|
|
62
|
+
const { status, text } = await this.post(request, bound.signal, field, interrupt);
|
|
63
|
+
return this.rootField(this.parseBody(text, status), field);
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
interrupt?.removeEventListener('abort', relay);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
get endpoint() {
|
|
71
|
+
return this.credentials.adminApiUrl;
|
|
72
|
+
}
|
|
73
|
+
async post(request, signal, field, interrupt) {
|
|
74
|
+
try {
|
|
75
|
+
const response = await fetch(this.endpoint, {
|
|
76
|
+
method: 'POST',
|
|
77
|
+
headers: request.headers,
|
|
78
|
+
body: request.body,
|
|
79
|
+
signal,
|
|
80
|
+
});
|
|
81
|
+
return { status: response.status, text: await response.text() };
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
throw this.exchangeFailure(error, signal, field, interrupt);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** Why an exchange ended without an answer: the interrupt, `--timeout`, or the network. */
|
|
88
|
+
exchangeFailure(error, signal, field, interrupt) {
|
|
89
|
+
if (interrupt?.aborted === true) {
|
|
90
|
+
return new AdminApiInterruption(this.endpoint, field, { cause: error });
|
|
91
|
+
}
|
|
92
|
+
if (signal.aborted) {
|
|
93
|
+
return new Error(`The admin API at ${this.endpoint} did not answer ${field} within --timeout ${String(this.timeoutSeconds)} s.`, { cause: error });
|
|
94
|
+
}
|
|
95
|
+
return new Error(`Could not reach the admin API at ${this.endpoint}: ${this.failureDetail(error)}.`, { cause: error });
|
|
96
|
+
}
|
|
97
|
+
/** The response's GraphQL body — an answer that is not one names its HTTP status. */
|
|
98
|
+
parseBody(text, status) {
|
|
99
|
+
let parsed;
|
|
100
|
+
try {
|
|
101
|
+
parsed = JSON.parse(text);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
throw new Error(this.notGraphQlMessage(status), { cause: error });
|
|
105
|
+
}
|
|
106
|
+
if (!isJsonObject(parsed))
|
|
107
|
+
throw new Error(this.notGraphQlMessage(status));
|
|
108
|
+
return parsed;
|
|
109
|
+
}
|
|
110
|
+
/** The root field, once the body carries no error. */
|
|
111
|
+
rootField(body, field) {
|
|
112
|
+
this.assertNoErrors(body.errors, field);
|
|
113
|
+
const data = body.data;
|
|
114
|
+
return AdminApiResult.of(this.endpoint, field, isJsonObject(data) ? data[field] : undefined);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* A GraphQL error ends the call: credentials refused as UNAUTHORIZED or
|
|
118
|
+
* FORBIDDEN on exit 3, any other code as the typed {@link AdminApiRefusal}.
|
|
119
|
+
*/
|
|
120
|
+
assertNoErrors(errors, field) {
|
|
121
|
+
if (!Array.isArray(errors) || errors.length === 0)
|
|
122
|
+
return;
|
|
123
|
+
const first = errors[0];
|
|
124
|
+
const extensions = this.extensionsOf(first);
|
|
125
|
+
const code = typeof extensions.code === 'string' ? extensions.code : undefined;
|
|
126
|
+
if (code !== undefined && CREDENTIAL_REFUSALS.has(code)) {
|
|
127
|
+
throw new CliUnauthorizedRefusal(CliUnauthorizedReason.REFUSED);
|
|
128
|
+
}
|
|
129
|
+
throw new AdminApiRefusal(this.endpoint, field, code ?? this.messageOf(first), this.errorVariables(extensions.variables));
|
|
130
|
+
}
|
|
131
|
+
extensionsOf(error) {
|
|
132
|
+
return isJsonObject(error) && isJsonObject(error.extensions) ? error.extensions : {};
|
|
133
|
+
}
|
|
134
|
+
messageOf(error) {
|
|
135
|
+
return isJsonObject(error) && typeof error.message === 'string' ? error.message : '';
|
|
136
|
+
}
|
|
137
|
+
/** The variables a typed error carries, as text — none when it carries none. */
|
|
138
|
+
errorVariables(variables) {
|
|
139
|
+
if (!isJsonObject(variables))
|
|
140
|
+
return {};
|
|
141
|
+
return Object.fromEntries(Object.entries(variables).map(([key, value]) => [
|
|
142
|
+
key,
|
|
143
|
+
typeof value === 'string' ? value : JSON.stringify(value),
|
|
144
|
+
]));
|
|
145
|
+
}
|
|
146
|
+
notGraphQlMessage(status) {
|
|
147
|
+
return `The admin API at ${this.endpoint} answered HTTP ${String(status)} without a GraphQL response.`;
|
|
148
|
+
}
|
|
149
|
+
/** What failed to connect: fetch's own message names nothing, its cause names the socket error. */
|
|
150
|
+
failureDetail(error) {
|
|
151
|
+
const cause = error instanceof Error ? error.cause : undefined;
|
|
152
|
+
if (cause instanceof Error)
|
|
153
|
+
return cause.message;
|
|
154
|
+
return error instanceof Error ? error.message : String(error);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
//# sourceMappingURL=admin-api.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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C,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC;CACF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One operation's root field as the admin API answered it (#2781, #411), read
|
|
3
|
+
* field by field: a value the CLI cannot read is an error naming the endpoint
|
|
4
|
+
* and the operation — never a guess.
|
|
5
|
+
*/
|
|
6
|
+
export declare class AdminApiResult {
|
|
7
|
+
private readonly endpoint;
|
|
8
|
+
private readonly field;
|
|
9
|
+
private readonly record;
|
|
10
|
+
private constructor();
|
|
11
|
+
/** The root field `field` answered — it must be an object. */
|
|
12
|
+
static of(endpoint: string, field: string, value: unknown): AdminApiResult;
|
|
13
|
+
/** The error an answer the CLI cannot read ends the run with. */
|
|
14
|
+
private static unreadable;
|
|
15
|
+
/** A string field that must carry text. */
|
|
16
|
+
readString(key: string): string;
|
|
17
|
+
/** A string field that may be empty. */
|
|
18
|
+
readText(key: string): string;
|
|
19
|
+
readNullableString(key: string): string | null;
|
|
20
|
+
readStringList(key: string): string[];
|
|
21
|
+
readCount(key: string): number;
|
|
22
|
+
readBoolean(key: string): boolean;
|
|
23
|
+
private unreadable;
|
|
24
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { isJsonObject } from '../json.js';
|
|
2
|
+
/**
|
|
3
|
+
* One operation's root field as the admin API answered it (#2781, #411), read
|
|
4
|
+
* field by field: a value the CLI cannot read is an error naming the endpoint
|
|
5
|
+
* and the operation — never a guess.
|
|
6
|
+
*/
|
|
7
|
+
export class AdminApiResult {
|
|
8
|
+
endpoint;
|
|
9
|
+
field;
|
|
10
|
+
record;
|
|
11
|
+
constructor(endpoint, field, record) {
|
|
12
|
+
this.endpoint = endpoint;
|
|
13
|
+
this.field = field;
|
|
14
|
+
this.record = record;
|
|
15
|
+
}
|
|
16
|
+
/** The root field `field` answered — it must be an object. */
|
|
17
|
+
static of(endpoint, field, value) {
|
|
18
|
+
if (!isJsonObject(value))
|
|
19
|
+
throw AdminApiResult.unreadable(endpoint, field);
|
|
20
|
+
return new AdminApiResult(endpoint, field, value);
|
|
21
|
+
}
|
|
22
|
+
/** The error an answer the CLI cannot read ends the run with. */
|
|
23
|
+
static unreadable(endpoint, field) {
|
|
24
|
+
return new Error(`The admin API at ${endpoint} answered a ${field} result the CLI cannot read.`);
|
|
25
|
+
}
|
|
26
|
+
/** A string field that must carry text. */
|
|
27
|
+
readString(key) {
|
|
28
|
+
const value = this.record[key];
|
|
29
|
+
if (typeof value !== 'string' || value === '')
|
|
30
|
+
throw this.unreadable();
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
/** A string field that may be empty. */
|
|
34
|
+
readText(key) {
|
|
35
|
+
const value = this.record[key];
|
|
36
|
+
if (typeof value !== 'string')
|
|
37
|
+
throw this.unreadable();
|
|
38
|
+
return value;
|
|
39
|
+
}
|
|
40
|
+
readNullableString(key) {
|
|
41
|
+
const value = this.record[key];
|
|
42
|
+
if (value === null)
|
|
43
|
+
return null;
|
|
44
|
+
if (typeof value !== 'string')
|
|
45
|
+
throw this.unreadable();
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
readStringList(key) {
|
|
49
|
+
const value = this.record[key];
|
|
50
|
+
if (!Array.isArray(value))
|
|
51
|
+
throw this.unreadable();
|
|
52
|
+
const items = value;
|
|
53
|
+
if (!items.every((item) => typeof item === 'string')) {
|
|
54
|
+
throw this.unreadable();
|
|
55
|
+
}
|
|
56
|
+
return items;
|
|
57
|
+
}
|
|
58
|
+
readCount(key) {
|
|
59
|
+
const value = this.record[key];
|
|
60
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
|
|
61
|
+
throw this.unreadable();
|
|
62
|
+
}
|
|
63
|
+
return value;
|
|
64
|
+
}
|
|
65
|
+
readBoolean(key) {
|
|
66
|
+
const value = this.record[key];
|
|
67
|
+
if (typeof value !== 'boolean')
|
|
68
|
+
throw this.unreadable();
|
|
69
|
+
return value;
|
|
70
|
+
}
|
|
71
|
+
unreadable() {
|
|
72
|
+
return AdminApiResult.unreadable(this.endpoint, this.field);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=admin-api.result.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-api.result.js","sourceRoot":"","sources":["../../../src/admin-api/admin-api.result.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C;;;;GAIG;AACH,MAAM,OAAO,cAAc;IAEN;IACA;IACA;IAHnB,YACmB,QAAgB,EAChB,KAAa,EACb,MAA+B;QAF/B,aAAQ,GAAR,QAAQ,CAAQ;QAChB,UAAK,GAAL,KAAK,CAAQ;QACb,WAAM,GAAN,MAAM,CAAyB;IAC/C,CAAC;IAEJ,8DAA8D;IAC9D,MAAM,CAAC,EAAE,CAAC,QAAgB,EAAE,KAAa,EAAE,KAAc;QACvD,IAAI,CAAC,YAAY,CAAC,KAAK,CAAC;YAAE,MAAM,cAAc,CAAC,UAAU,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;QAC3E,OAAO,IAAI,cAAc,CAAC,QAAQ,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED,iEAAiE;IACzD,MAAM,CAAC,UAAU,CAAC,QAAgB,EAAE,KAAa;QACvD,OAAO,IAAI,KAAK,CACd,oBAAoB,QAAQ,eAAe,KAAK,8BAA8B,CAC/E,CAAC;IACJ,CAAC;IAED,2CAA2C;IAC3C,UAAU,CAAC,GAAW;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,EAAE;YAAE,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACvE,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wCAAwC;IACxC,QAAQ,CAAC,GAAW;QAClB,MAAM,KAAK,GAA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AAC,CAAC;QAC/B,IAAI,OAAO,KAAK,KAAK,SAAS;YAAE,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QACxD,OAAO,KAAK,CAAC;IACf,CAAC;IAEO,UAAU;QAChB,OAAO,cAAc,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** One HTTP exchange with the admin API: its body and the headers it travels with. */
|
|
2
|
+
export interface AdminApiRequest {
|
|
3
|
+
body: string | FormData;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
}
|
|
6
|
+
/** An HTTP answer: its status and its whole body. */
|
|
7
|
+
export interface AdminApiResponse {
|
|
8
|
+
status: number;
|
|
9
|
+
text: string;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-api.types.js","sourceRoot":"","sources":["../../../../src/admin-api/type/admin-api.types.ts"],"names":[],"mappings":""}
|
|
@@ -4,7 +4,8 @@ import { CliCredentialKey, type CliCredentials } from './type/cli-authorization.
|
|
|
4
4
|
* environment, then the target's `.env`, then its `.forgecart/config.json`
|
|
5
5
|
* (`channelToken`, `apiUrl`) — the first non-empty value wins. With all four
|
|
6
6
|
* found, init asks nothing; with any absent, it authorizes in the browser, and
|
|
7
|
-
* the check's {@link report} is the first thing that run prints.
|
|
7
|
+
* the check's {@link report} is the first thing that run prints. The commands
|
|
8
|
+
* that never authorize read the same four keys through {@link settle}.
|
|
8
9
|
*/
|
|
9
10
|
export declare class CliCredentialCheck {
|
|
10
11
|
private readonly environment;
|
|
@@ -13,6 +14,13 @@ export declare class CliCredentialCheck {
|
|
|
13
14
|
private constructor();
|
|
14
15
|
/** Look for the four keys for the storefront at `targetDir`. */
|
|
15
16
|
static read(targetDir: string, env?: NodeJS.ProcessEnv): Promise<CliCredentialCheck>;
|
|
17
|
+
/**
|
|
18
|
+
* The four credentials for the storefront at `targetDir`, for a command that
|
|
19
|
+
* never authorizes (`forgecart sync`, `forgecart deploy`): with one in no
|
|
20
|
+
* source, the check's {@link report} is printed — key names, never values —
|
|
21
|
+
* and the run exits 3 before any request.
|
|
22
|
+
*/
|
|
23
|
+
static settle(targetDir: string): Promise<CliCredentials>;
|
|
16
24
|
/** The value the check found for `key`: the environment's, then `.env`'s, then `config.json`'s. */
|
|
17
25
|
value(key: CliCredentialKey): string | undefined;
|
|
18
26
|
/** All four credentials — undefined while any one is absent. */
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
import { isJsonObject } from '../json.js';
|
|
4
|
+
import { print } from '../output.js';
|
|
5
|
+
import { CliUnauthorizedReason, CliUnauthorizedRefusal } from './cli-unauthorized-refusal.js';
|
|
4
6
|
import { CliCredentialKey } from './type/cli-authorization.types.js';
|
|
5
7
|
/** The report's source column: `.forgecart/config.json`, and the gutter after it. */
|
|
6
8
|
const SOURCE_COLUMN_WIDTH = 26;
|
|
@@ -18,7 +20,8 @@ const CONFIG_FIELDS = [
|
|
|
18
20
|
* environment, then the target's `.env`, then its `.forgecart/config.json`
|
|
19
21
|
* (`channelToken`, `apiUrl`) — the first non-empty value wins. With all four
|
|
20
22
|
* found, init asks nothing; with any absent, it authorizes in the browser, and
|
|
21
|
-
* the check's {@link report} is the first thing that run prints.
|
|
23
|
+
* the check's {@link report} is the first thing that run prints. The commands
|
|
24
|
+
* that never authorize read the same four keys through {@link settle}.
|
|
22
25
|
*/
|
|
23
26
|
export class CliCredentialCheck {
|
|
24
27
|
environment;
|
|
@@ -39,6 +42,21 @@ export class CliCredentialCheck {
|
|
|
39
42
|
}
|
|
40
43
|
return new CliCredentialCheck(environment, await CliCredentialCheck.readDotenv(join(targetDir, '.env')), await CliCredentialCheck.readConfig(join(targetDir, '.forgecart', 'config.json')));
|
|
41
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* The four credentials for the storefront at `targetDir`, for a command that
|
|
47
|
+
* never authorizes (`forgecart sync`, `forgecart deploy`): with one in no
|
|
48
|
+
* source, the check's {@link report} is printed — key names, never values —
|
|
49
|
+
* and the run exits 3 before any request.
|
|
50
|
+
*/
|
|
51
|
+
static async settle(targetDir) {
|
|
52
|
+
const check = await CliCredentialCheck.read(targetDir);
|
|
53
|
+
const credentials = check.credentials();
|
|
54
|
+
if (credentials !== undefined)
|
|
55
|
+
return credentials;
|
|
56
|
+
for (const line of check.report())
|
|
57
|
+
print(line);
|
|
58
|
+
throw new CliUnauthorizedRefusal(CliUnauthorizedReason.MISSING);
|
|
59
|
+
}
|
|
42
60
|
/** The value the check found for `key`: the environment's, then `.env`'s, then `config.json`'s. */
|
|
43
61
|
value(key) {
|
|
44
62
|
return this.environment.get(key) ?? this.dotenv?.get(key) ?? this.config?.get(key);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-credential-check.js","sourceRoot":"","sources":["../../../src/authorization/cli-credential-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"cli-credential-check.js","sourceRoot":"","sources":["../../../src/authorization/cli-credential-check.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAuB,MAAM,mCAAmC,CAAC;AAE1F,qF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,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAEO,MAAM,CAAC,OAAO,CAAC,KAAa;QAClC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxC,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7C,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,GAAW;QACxC,OAAO,MAAM,CAAC,MAAM,CAAS,gBAAgB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC/D,CAAC;CACF"}
|
package/dist/src/cli.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
|
+
import { createDeployCommand } from './commands/deploy.js';
|
|
2
3
|
import { createDesignSystemCommand } from './commands/design-system.js';
|
|
3
4
|
import { createInitCommand } from './commands/init.js';
|
|
4
|
-
import { createDeleteCommand,
|
|
5
|
+
import { createDeleteCommand, createEnvCommand, createInitApplicationCommand, createListCommand, createLogsCommand, createScaleCommand, createStatusCommand, createWhoamiCommand, } from './commands/placeholders.js';
|
|
5
6
|
import { createRefreshCommand } from './commands/refresh.js';
|
|
6
7
|
import { createSyncCommand, createSyncEnvCommand } from './commands/sync.js';
|
|
7
8
|
import { CliExitLadder, CliRefusal } from './exit-ladder.js';
|
package/dist/src/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,6BAA6B,CAAC;AACxE,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EACL,mBAAmB,EACnB,
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../src/cli.ts"],"names":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Y,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC;QAClC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,KAAK;YAAE,UAAU,CAAC,GAAG,IAAI,KAAK,IAAI,EAAE,CAAC,CAAC;QAC/D,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;QAClC,OAAO;IACT,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACvE,UAAU,CAAC,UAAU,OAAO,EAAE,CAAC,CAAC;IAChC,OAAO,CAAC,QAAQ,GAAG,aAAa,CAAC,KAAK,CAAC;AACzC,CAAC;AAED,0EAA0E;AAC1E,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,OAAO,GAAmB,OAAO,EAAE,OAAO,KAAK,IAAI,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;QACvF,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
/**
|
|
3
|
+
* Build the `deploy [name]` command (#411). No flag carries a token, a secret
|
|
4
|
+
* or a URL — the run settles the four `FORGECART_*` keys from the environment,
|
|
5
|
+
* `.env` and `.forgecart/config.json` — and none builds: the server builds and
|
|
6
|
+
* ships what the board serves.
|
|
7
|
+
*/
|
|
8
|
+
export declare function createDeployCommand(): Command;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Command, Option } from 'commander';
|
|
2
|
+
import { DeployRunner } from '../deploy/deploy.runner.js';
|
|
3
|
+
import { parseTimeoutSeconds } from '../util/timeout-seconds.util.js';
|
|
4
|
+
/** `--timeout`'s default: twenty minutes — the pod's build and the provider's rollout of one publish. */
|
|
5
|
+
const DEFAULT_TIMEOUT_SECONDS = 1200;
|
|
6
|
+
/**
|
|
7
|
+
* Build the `deploy [name]` command (#411). No flag carries a token, a secret
|
|
8
|
+
* or a URL — the run settles the four `FORGECART_*` keys from the environment,
|
|
9
|
+
* `.env` and `.forgecart/config.json` — and none builds: the server builds and
|
|
10
|
+
* ships what the board serves.
|
|
11
|
+
*/
|
|
12
|
+
export function createDeployCommand() {
|
|
13
|
+
return new Command('deploy')
|
|
14
|
+
.description('Ship what the board serves: one publish, which the server builds and ships, followed until the deployment is RUNNING (its URL printed) or FAILED. Laptop changes reach the board through `forgecart sync` — run it first.')
|
|
15
|
+
.argument('[name]', 'Storefront directory whose credentials name the channel (defaults to the current directory)')
|
|
16
|
+
.addOption(new Option('--timeout <seconds>', 'Seconds deploy follows the deployment before it exits 1 — the publish continues on the server')
|
|
17
|
+
.argParser(parseTimeoutSeconds)
|
|
18
|
+
.default(DEFAULT_TIMEOUT_SECONDS))
|
|
19
|
+
.action(async (name, options) => {
|
|
20
|
+
await new DeployRunner(name, options).run();
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=deploy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deploy.js","sourceRoot":"","sources":["../../../src/commands/deploy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAEtE,yGAAyG;AACzG,MAAM,uBAAuB,GAAG,IAAI,CAAC;AAErC;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB;IACjC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC;SACzB,WAAW,CACV,2NAA2N,CAC5N;SACA,QAAQ,CACP,QAAQ,EACR,6FAA6F,CAC9F;SACA,SAAS,CACR,IAAI,MAAM,CACR,qBAAqB,EACrB,+FAA+F,CAChG;SACE,SAAS,CAAC,mBAAmB,CAAC;SAC9B,OAAO,CAAC,uBAAuB,CAAC,CACpC;SACA,MAAM,CAAC,KAAK,EAAE,IAAwB,EAAE,OAAsB,EAAE,EAAE;QACjE,MAAM,IAAI,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,GAAG,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
/** `init:application` — add a NestJS application to an existing project. */
|
|
3
3
|
export declare function createInitApplicationCommand(): Command;
|
|
4
|
-
/** `deploy` — deploy the current project. */
|
|
5
|
-
export declare function createDeployCommand(): Command;
|
|
6
4
|
/** `list` — list deployments for the channel. */
|
|
7
5
|
export declare function createListCommand(): Command;
|
|
8
6
|
/** `status [type]` — show deployment status. */
|
|
@@ -17,15 +17,6 @@ export function createInitApplicationCommand() {
|
|
|
17
17
|
notImplemented('init:application');
|
|
18
18
|
});
|
|
19
19
|
}
|
|
20
|
-
/** `deploy` — deploy the current project. */
|
|
21
|
-
export function createDeployCommand() {
|
|
22
|
-
return new Command('deploy')
|
|
23
|
-
.description('Deploy the current ForgeCart project')
|
|
24
|
-
.option('--skip-build', 'Skip the build step')
|
|
25
|
-
.action(() => {
|
|
26
|
-
notImplemented('deploy');
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
20
|
/** `list` — list deployments for the channel. */
|
|
30
21
|
export function createListCommand() {
|
|
31
22
|
return new Command('list')
|