@sanity/runtime-cli 3.1.0 → 4.0.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 +52 -20
- package/dist/actions/blueprints/blueprint.d.ts +32 -16
- package/dist/actions/blueprints/blueprint.js +157 -106
- package/dist/actions/blueprints/stacks.d.ts +9 -0
- package/dist/actions/blueprints/stacks.js +13 -1
- package/dist/actions/functions/env/index.d.ts +2 -2
- package/dist/actions/functions/env/index.js +2 -2
- package/dist/commands/blueprints/add.js +3 -4
- package/dist/commands/blueprints/config.js +29 -17
- package/dist/commands/blueprints/deploy.d.ts +3 -0
- package/dist/commands/blueprints/deploy.js +49 -46
- package/dist/commands/blueprints/destroy.d.ts +10 -0
- package/dist/commands/blueprints/destroy.js +85 -0
- package/dist/commands/blueprints/info.js +12 -6
- package/dist/commands/blueprints/init.js +54 -11
- package/dist/commands/blueprints/logs.js +6 -6
- package/dist/commands/blueprints/stacks.d.ts +3 -0
- package/dist/commands/blueprints/stacks.js +34 -10
- package/dist/utils/display/blueprints-formatting.js +9 -6
- package/dist/utils/display/colors.d.ts +2 -0
- package/dist/utils/display/colors.js +8 -0
- package/dist/utils/types.d.ts +32 -0
- package/oclif.manifest.json +63 -6
- package/package.json +3 -3
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { treeify } from 'array-treeify';
|
|
2
|
-
import { blue, bold, boldnblue, green, red, yellow } from './colors.js';
|
|
2
|
+
import { blue, bold, boldnblue, green, niceId, red, yellow } from './colors.js';
|
|
3
3
|
import { formatDate, formatDuration } from './dates.js';
|
|
4
4
|
export function formatTitle(title, name) {
|
|
5
5
|
return `${boldnblue(title)} ${bold(`"${name}"`)}`;
|
|
6
6
|
}
|
|
7
7
|
export function formatResourceTree(resources) {
|
|
8
8
|
if (!resources || resources.length === 0) {
|
|
9
|
-
return '
|
|
9
|
+
return ' Zero resources in this stack';
|
|
10
10
|
}
|
|
11
11
|
const output = [];
|
|
12
12
|
output.push(`${blue('Stack Resources')} [${resources.length}]`);
|
|
@@ -18,7 +18,7 @@ export function formatResourceTree(resources) {
|
|
|
18
18
|
functionsOutput.push(`${bold('Functions')} [${functionResources.length}]`);
|
|
19
19
|
const functionResourcesOutput = functionResources.map((fn) => {
|
|
20
20
|
const name = green(fn.displayName || fn.name);
|
|
21
|
-
const externalId = fn.externalId ? `Fn
|
|
21
|
+
const externalId = fn.externalId ? `Fn${niceId(fn.externalId)}` : '';
|
|
22
22
|
return `"${name}" ${externalId}`;
|
|
23
23
|
});
|
|
24
24
|
functionsOutput.push(functionResourcesOutput);
|
|
@@ -38,17 +38,20 @@ export function formatResourceTree(resources) {
|
|
|
38
38
|
export function formatStackInfo(stack, isCurrentStack = false) {
|
|
39
39
|
const output = [];
|
|
40
40
|
const isStack = 'id' in stack;
|
|
41
|
+
const infoOutput = [];
|
|
41
42
|
if (isStack) {
|
|
42
43
|
const stackName = isCurrentStack ? boldnblue(stack.name) : bold(stack.name);
|
|
43
|
-
output.push(`"${stackName}"
|
|
44
|
+
output.push(`"${stackName}" ${niceId(stack.id)}${isCurrentStack ? ' (current)' : ''}`);
|
|
44
45
|
}
|
|
45
46
|
else {
|
|
46
47
|
output.push('Local Blueprint');
|
|
47
48
|
}
|
|
48
|
-
const infoOutput = [];
|
|
49
49
|
if (stack.resources) {
|
|
50
50
|
infoOutput.push(`${stack.resources.length} resource${stack.resources.length === 1 ? '' : 's'}`);
|
|
51
51
|
}
|
|
52
|
+
else {
|
|
53
|
+
infoOutput.push('No resources');
|
|
54
|
+
}
|
|
52
55
|
if (isStack) {
|
|
53
56
|
if (stack.createdAt)
|
|
54
57
|
infoOutput.push(`Created: ${formatDate(stack.createdAt)}`);
|
|
@@ -58,7 +61,7 @@ export function formatStackInfo(stack, isCurrentStack = false) {
|
|
|
58
61
|
const operation = stack.recentOperation;
|
|
59
62
|
const operationOutput = [];
|
|
60
63
|
if (operation.id)
|
|
61
|
-
operationOutput.push(`Recent Operation
|
|
64
|
+
operationOutput.push(`Recent Operation ${niceId(operation.id)}:`);
|
|
62
65
|
if (operation.status) {
|
|
63
66
|
const operationColor = operation.status === 'COMPLETED' ? green : red;
|
|
64
67
|
const status = operation.status || 'UNKNOWN';
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
export declare function bold(str: string): string;
|
|
2
|
+
export declare function underline(str: string): string;
|
|
2
3
|
export declare function dim(str: string): string;
|
|
3
4
|
export declare function blue(str: string): string;
|
|
4
5
|
export declare function green(str: string): string;
|
|
5
6
|
export declare function red(str: string): string;
|
|
6
7
|
export declare function yellow(str: string): string;
|
|
7
8
|
export declare function boldnblue(str: string): string;
|
|
9
|
+
export declare function niceId(id: string | undefined): string;
|
|
@@ -2,6 +2,9 @@ import chalk from 'chalk';
|
|
|
2
2
|
export function bold(str) {
|
|
3
3
|
return chalk.bold(str);
|
|
4
4
|
}
|
|
5
|
+
export function underline(str) {
|
|
6
|
+
return chalk.underline(str);
|
|
7
|
+
}
|
|
5
8
|
export function dim(str) {
|
|
6
9
|
return chalk.dim(str);
|
|
7
10
|
}
|
|
@@ -20,3 +23,8 @@ export function yellow(str) {
|
|
|
20
23
|
export function boldnblue(str) {
|
|
21
24
|
return chalk.bold.blue(str);
|
|
22
25
|
}
|
|
26
|
+
export function niceId(id) {
|
|
27
|
+
if (!id)
|
|
28
|
+
return '';
|
|
29
|
+
return `<${yellow(id)}>`;
|
|
30
|
+
}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -5,10 +5,41 @@ export interface AuthParams {
|
|
|
5
5
|
}
|
|
6
6
|
/** @internal */
|
|
7
7
|
export interface LocalBlueprint {
|
|
8
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#versioning */
|
|
8
9
|
blueprintVersion?: string;
|
|
10
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#values */
|
|
9
11
|
values?: Record<string, unknown>;
|
|
12
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#outputs */
|
|
10
13
|
outputs?: Array<Record<string, unknown>>;
|
|
14
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#resources */
|
|
11
15
|
resources?: Array<LocalResource>;
|
|
16
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#parameters */
|
|
17
|
+
parameters?: Array<{
|
|
18
|
+
name: string;
|
|
19
|
+
type: 'arg' | 'argument' | 'env-var' | 'envVar' | 'config' | 'stdin';
|
|
20
|
+
} & ({
|
|
21
|
+
type: 'arg' | 'argument';
|
|
22
|
+
argument: string;
|
|
23
|
+
'env-var'?: never;
|
|
24
|
+
setting?: never;
|
|
25
|
+
} | {
|
|
26
|
+
type: 'env-var' | 'envVar';
|
|
27
|
+
'env-var': string;
|
|
28
|
+
argument?: never;
|
|
29
|
+
setting?: never;
|
|
30
|
+
} | {
|
|
31
|
+
type: 'config';
|
|
32
|
+
setting: string;
|
|
33
|
+
'env-var'?: never;
|
|
34
|
+
argument?: never;
|
|
35
|
+
} | {
|
|
36
|
+
type: 'stdin';
|
|
37
|
+
'env-var'?: never;
|
|
38
|
+
argument?: never;
|
|
39
|
+
setting?: never;
|
|
40
|
+
})>;
|
|
41
|
+
/** @link https://github.com/sanity-io/blueprints-rfc/blob/main/readme.md#arbitrary-userland-data */
|
|
42
|
+
metadata?: Record<string, unknown>;
|
|
12
43
|
}
|
|
13
44
|
/** @internal */
|
|
14
45
|
export interface LocalResource {
|
|
@@ -89,6 +120,7 @@ export interface BlueprintLog {
|
|
|
89
120
|
message: string;
|
|
90
121
|
stackId: string;
|
|
91
122
|
level: string;
|
|
123
|
+
metadata?: Record<string, unknown>;
|
|
92
124
|
}
|
|
93
125
|
/** @internal */
|
|
94
126
|
export interface FunctionLog {
|
package/oclif.manifest.json
CHANGED
|
@@ -72,7 +72,14 @@
|
|
|
72
72
|
"examples": [
|
|
73
73
|
"<%= config.bin %> <%= command.id %>"
|
|
74
74
|
],
|
|
75
|
-
"flags": {
|
|
75
|
+
"flags": {
|
|
76
|
+
"no-wait": {
|
|
77
|
+
"description": "Do not wait for deployment to complete",
|
|
78
|
+
"name": "no-wait",
|
|
79
|
+
"allowNo": false,
|
|
80
|
+
"type": "boolean"
|
|
81
|
+
}
|
|
82
|
+
},
|
|
76
83
|
"hasDynamicHelp": false,
|
|
77
84
|
"hiddenAliases": [],
|
|
78
85
|
"id": "blueprints:deploy",
|
|
@@ -89,13 +96,53 @@
|
|
|
89
96
|
"deploy.js"
|
|
90
97
|
]
|
|
91
98
|
},
|
|
99
|
+
"blueprints:destroy": {
|
|
100
|
+
"aliases": [],
|
|
101
|
+
"args": {},
|
|
102
|
+
"description": "Destroy a deployed Blueprint Stack",
|
|
103
|
+
"examples": [
|
|
104
|
+
"<%= config.bin %> <%= command.id %>",
|
|
105
|
+
"<%= config.bin %> <%= command.id %> --id ST-a1b2c3"
|
|
106
|
+
],
|
|
107
|
+
"flags": {
|
|
108
|
+
"id": {
|
|
109
|
+
"description": "Stack ID to destroy (defaults to current Stack)",
|
|
110
|
+
"name": "id",
|
|
111
|
+
"required": false,
|
|
112
|
+
"hasDynamicHelp": false,
|
|
113
|
+
"multiple": false,
|
|
114
|
+
"type": "option"
|
|
115
|
+
},
|
|
116
|
+
"force": {
|
|
117
|
+
"description": "Force destroy (skip confirmation)",
|
|
118
|
+
"name": "force",
|
|
119
|
+
"allowNo": false,
|
|
120
|
+
"type": "boolean"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
"hasDynamicHelp": false,
|
|
124
|
+
"hiddenAliases": [],
|
|
125
|
+
"id": "blueprints:destroy",
|
|
126
|
+
"pluginAlias": "@sanity/runtime-cli",
|
|
127
|
+
"pluginName": "@sanity/runtime-cli",
|
|
128
|
+
"pluginType": "core",
|
|
129
|
+
"strict": true,
|
|
130
|
+
"enableJsonFlag": false,
|
|
131
|
+
"isESM": true,
|
|
132
|
+
"relativePath": [
|
|
133
|
+
"dist",
|
|
134
|
+
"commands",
|
|
135
|
+
"blueprints",
|
|
136
|
+
"destroy.js"
|
|
137
|
+
]
|
|
138
|
+
},
|
|
92
139
|
"blueprints:info": {
|
|
93
140
|
"aliases": [],
|
|
94
141
|
"args": {},
|
|
95
|
-
"description": "Show information about a Blueprint",
|
|
142
|
+
"description": "Show information about a deployed Blueprint Stack",
|
|
96
143
|
"examples": [
|
|
97
144
|
"<%= config.bin %> <%= command.id %>",
|
|
98
|
-
"<%= config.bin %> <%= command.id %> --id
|
|
145
|
+
"<%= config.bin %> <%= command.id %> --id ST-a1b2c3"
|
|
99
146
|
],
|
|
100
147
|
"flags": {
|
|
101
148
|
"id": {
|
|
@@ -210,9 +257,19 @@
|
|
|
210
257
|
"args": {},
|
|
211
258
|
"description": "List all Blueprint stacks",
|
|
212
259
|
"examples": [
|
|
213
|
-
"<%= config.bin %> <%= command.id %>"
|
|
260
|
+
"<%= config.bin %> <%= command.id %>",
|
|
261
|
+
"<%= config.bin %> <%= command.id %> --projectId a1b2c3"
|
|
214
262
|
],
|
|
215
|
-
"flags": {
|
|
263
|
+
"flags": {
|
|
264
|
+
"projectId": {
|
|
265
|
+
"description": "Project ID to show stacks for",
|
|
266
|
+
"name": "projectId",
|
|
267
|
+
"required": false,
|
|
268
|
+
"hasDynamicHelp": false,
|
|
269
|
+
"multiple": false,
|
|
270
|
+
"type": "option"
|
|
271
|
+
}
|
|
272
|
+
},
|
|
216
273
|
"hasDynamicHelp": false,
|
|
217
274
|
"hiddenAliases": [],
|
|
218
275
|
"id": "blueprints:stacks",
|
|
@@ -551,5 +608,5 @@
|
|
|
551
608
|
]
|
|
552
609
|
}
|
|
553
610
|
},
|
|
554
|
-
"version": "
|
|
611
|
+
"version": "4.0.0"
|
|
555
612
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/runtime-cli",
|
|
3
3
|
"description": "Sanity's Runtime CLI for Blueprints and Functions",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "4.0.0",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -84,10 +84,10 @@
|
|
|
84
84
|
"@types/node": "18",
|
|
85
85
|
"codemirror": "^6.0.1",
|
|
86
86
|
"mentoss": "^0.9.2",
|
|
87
|
-
"oclif": "^4.17.
|
|
87
|
+
"oclif": "^4.17.44",
|
|
88
88
|
"pretty-bytes": "^6.1.1",
|
|
89
89
|
"pretty-ms": "^9.2.0",
|
|
90
|
-
"rollup": "^4.
|
|
90
|
+
"rollup": "^4.40.0",
|
|
91
91
|
"shx": "^0.4.0",
|
|
92
92
|
"ts-node": "^10.9.2",
|
|
93
93
|
"tsx": "^4.19.3",
|