@sanity/runtime-cli 3.2.0 → 4.1.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 +29 -21
- package/dist/actions/blueprints/blueprint.d.ts +32 -16
- package/dist/actions/blueprints/blueprint.js +157 -106
- package/dist/actions/blueprints/stacks.js +1 -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/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/commands/functions/test.js +5 -3
- package/dist/server/static/components/payload-panel.js +5 -3
- package/dist/utils/child-process-wrapper.js +1 -26
- package/dist/utils/display/blueprints-formatting.js +9 -6
- package/dist/utils/display/colors.d.ts +1 -0
- package/dist/utils/display/colors.js +3 -0
- package/dist/utils/invoke-local.d.ts +1 -0
- package/dist/utils/invoke-local.js +9 -3
- package/dist/utils/types.d.ts +37 -3
- package/oclif.manifest.json +23 -6
- package/package.json +1 -1
|
@@ -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,2 +1,3 @@
|
|
|
1
1
|
import type { InvocationResponse, InvokeContextOptions } from './types.js';
|
|
2
|
+
export declare function sanitizeLogs(logs: string): string;
|
|
2
3
|
export default function invoke(srcPath: string, data: null | object, context: InvokeContextOptions, timeout?: number): Promise<InvocationResponse>;
|
|
@@ -5,6 +5,9 @@ import config from '../config.js';
|
|
|
5
5
|
function getChildProcessWrapperPath() {
|
|
6
6
|
return new URL('./child-process-wrapper.js', import.meta.url).pathname;
|
|
7
7
|
}
|
|
8
|
+
export function sanitizeLogs(logs) {
|
|
9
|
+
return logs.replace(/[a-zA-Z0-9]{75}/g, '*'.repeat(10));
|
|
10
|
+
}
|
|
8
11
|
export default async function invoke(srcPath, data, context, timeout = 5) {
|
|
9
12
|
return new Promise((resolve, reject) => {
|
|
10
13
|
let child;
|
|
@@ -18,7 +21,7 @@ export default async function invoke(srcPath, data, context, timeout = 5) {
|
|
|
18
21
|
child.on('message', (data) => {
|
|
19
22
|
const { json, logs } = JSON.parse(data.toString());
|
|
20
23
|
shutdown();
|
|
21
|
-
resolve({ json, logs, error: '' });
|
|
24
|
+
resolve({ json, logs: sanitizeLogs(logs), error: '' });
|
|
22
25
|
});
|
|
23
26
|
child.on('error', (error) => {
|
|
24
27
|
reject(new Error(`encountered error ${error.message}`));
|
|
@@ -40,9 +43,12 @@ export default async function invoke(srcPath, data, context, timeout = 5) {
|
|
|
40
43
|
const payload = {
|
|
41
44
|
...data,
|
|
42
45
|
context: {
|
|
43
|
-
apiHost: config.apiUrl,
|
|
44
|
-
token: config.token,
|
|
45
46
|
...context,
|
|
47
|
+
clientOptions: {
|
|
48
|
+
...context.clientOptions,
|
|
49
|
+
apiHost: config.apiUrl,
|
|
50
|
+
token: config.token,
|
|
51
|
+
},
|
|
46
52
|
},
|
|
47
53
|
};
|
|
48
54
|
child.send(JSON.stringify({ srcPath, payload }, null, 2));
|
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 {
|
|
@@ -73,9 +104,11 @@ export interface InvokePayloadOptions {
|
|
|
73
104
|
}
|
|
74
105
|
/** @internal */
|
|
75
106
|
export interface InvokeContextOptions {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
107
|
+
clientOptions: {
|
|
108
|
+
apiVersion?: string;
|
|
109
|
+
dataset?: string;
|
|
110
|
+
projectId?: string;
|
|
111
|
+
};
|
|
79
112
|
}
|
|
80
113
|
/** @internal */
|
|
81
114
|
export interface InvocationResponse {
|
|
@@ -89,6 +122,7 @@ export interface BlueprintLog {
|
|
|
89
122
|
message: string;
|
|
90
123
|
stackId: string;
|
|
91
124
|
level: string;
|
|
125
|
+
metadata?: Record<string, unknown>;
|
|
92
126
|
}
|
|
93
127
|
/** @internal */
|
|
94
128
|
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",
|
|
@@ -132,10 +139,10 @@
|
|
|
132
139
|
"blueprints:info": {
|
|
133
140
|
"aliases": [],
|
|
134
141
|
"args": {},
|
|
135
|
-
"description": "Show information about a Blueprint",
|
|
142
|
+
"description": "Show information about a deployed Blueprint Stack",
|
|
136
143
|
"examples": [
|
|
137
144
|
"<%= config.bin %> <%= command.id %>",
|
|
138
|
-
"<%= config.bin %> <%= command.id %> --id
|
|
145
|
+
"<%= config.bin %> <%= command.id %> --id ST-a1b2c3"
|
|
139
146
|
],
|
|
140
147
|
"flags": {
|
|
141
148
|
"id": {
|
|
@@ -250,9 +257,19 @@
|
|
|
250
257
|
"args": {},
|
|
251
258
|
"description": "List all Blueprint stacks",
|
|
252
259
|
"examples": [
|
|
253
|
-
"<%= config.bin %> <%= command.id %>"
|
|
260
|
+
"<%= config.bin %> <%= command.id %>",
|
|
261
|
+
"<%= config.bin %> <%= command.id %> --projectId a1b2c3"
|
|
254
262
|
],
|
|
255
|
-
"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
|
+
},
|
|
256
273
|
"hasDynamicHelp": false,
|
|
257
274
|
"hiddenAliases": [],
|
|
258
275
|
"id": "blueprints:stacks",
|
|
@@ -591,5 +608,5 @@
|
|
|
591
608
|
]
|
|
592
609
|
}
|
|
593
610
|
},
|
|
594
|
-
"version": "
|
|
611
|
+
"version": "4.1.0"
|
|
595
612
|
}
|