@sanity/runtime-cli 13.4.1 → 14.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 +40 -34
- package/dist/actions/blueprints/stacks.d.ts +1 -0
- package/dist/actions/blueprints/stacks.js +11 -0
- package/dist/baseCommands.d.ts +2 -0
- package/dist/baseCommands.js +6 -1
- package/dist/commands/blueprints/config.d.ts +1 -1
- package/dist/commands/blueprints/config.js +5 -5
- package/dist/commands/blueprints/deploy.d.ts +1 -0
- package/dist/commands/blueprints/deploy.js +2 -1
- package/dist/commands/blueprints/destroy.d.ts +1 -1
- package/dist/commands/blueprints/destroy.js +6 -6
- package/dist/commands/blueprints/info.d.ts +1 -1
- package/dist/commands/blueprints/info.js +4 -4
- package/dist/commands/blueprints/init.js +1 -1
- package/dist/commands/blueprints/logs.d.ts +1 -0
- package/dist/commands/blueprints/logs.js +2 -1
- package/dist/commands/blueprints/plan.d.ts +3 -0
- package/dist/commands/blueprints/plan.js +4 -1
- package/dist/commands/functions/logs.d.ts +1 -0
- package/dist/commands/functions/logs.js +2 -1
- package/dist/cores/blueprints/config.d.ts +1 -1
- package/dist/cores/blueprints/config.js +17 -5
- package/dist/cores/blueprints/destroy.d.ts +1 -1
- package/dist/cores/blueprints/destroy.js +15 -10
- package/dist/cores/blueprints/info.d.ts +1 -3
- package/dist/cores/blueprints/info.js +5 -20
- package/dist/cores/blueprints/init.js +1 -1
- package/dist/cores/blueprints/plan.d.ts +1 -0
- package/dist/cores/blueprints/plan.js +20 -15
- package/dist/cores/index.d.ts +1 -0
- package/dist/cores/index.js +12 -7
- package/oclif.manifest.json +78 -20
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/
|
|
23
|
+
@sanity/runtime-cli/14.0.0 linux-x64 node-v24.13.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -98,7 +98,7 @@ EXAMPLES
|
|
|
98
98
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
99
99
|
```
|
|
100
100
|
|
|
101
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
101
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/add.ts)_
|
|
102
102
|
|
|
103
103
|
## `sanity-run blueprints config`
|
|
104
104
|
|
|
@@ -106,12 +106,12 @@ View or edit the local Blueprint configuration
|
|
|
106
106
|
|
|
107
107
|
```
|
|
108
108
|
USAGE
|
|
109
|
-
$ sanity-run blueprints config [--project-id <value> -e] [--stack
|
|
109
|
+
$ sanity-run blueprints config [--project-id <value> -e] [--stack <value> ]
|
|
110
110
|
|
|
111
111
|
FLAGS
|
|
112
112
|
-e, --edit Modify the configuration interactively, or directly when combined with ID flags.
|
|
113
113
|
--project-id=<value> Directly set the project ID in the configuration. Requires --edit flag
|
|
114
|
-
--stack
|
|
114
|
+
--stack=<value> Stack name or ID to set in the configuration. Requires --edit flag
|
|
115
115
|
|
|
116
116
|
DESCRIPTION
|
|
117
117
|
View or edit the local Blueprint configuration
|
|
@@ -121,7 +121,7 @@ DESCRIPTION
|
|
|
121
121
|
Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with
|
|
122
122
|
ID flags to update values directly (useful for scripting and automation).
|
|
123
123
|
|
|
124
|
-
If you need to switch your Blueprint to a different Stack, use --edit --stack
|
|
124
|
+
If you need to switch your Blueprint to a different Stack, use --edit --stack.
|
|
125
125
|
|
|
126
126
|
EXAMPLES
|
|
127
127
|
$ sanity-run blueprints config
|
|
@@ -130,10 +130,10 @@ EXAMPLES
|
|
|
130
130
|
|
|
131
131
|
$ sanity-run blueprints config --edit --project-id <projectId>
|
|
132
132
|
|
|
133
|
-
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id
|
|
133
|
+
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
136
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/config.ts)_
|
|
137
137
|
|
|
138
138
|
## `sanity-run blueprints deploy`
|
|
139
139
|
|
|
@@ -141,10 +141,11 @@ Deploy the local Blueprint to the remote Stack
|
|
|
141
141
|
|
|
142
142
|
```
|
|
143
143
|
USAGE
|
|
144
|
-
$ sanity-run blueprints deploy [--no-wait]
|
|
144
|
+
$ sanity-run blueprints deploy [--stack <value>] [--no-wait]
|
|
145
145
|
|
|
146
146
|
FLAGS
|
|
147
|
-
--no-wait
|
|
147
|
+
--no-wait Do not wait for Stack deployment to complete
|
|
148
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
148
149
|
|
|
149
150
|
DESCRIPTION
|
|
150
151
|
Deploy the local Blueprint to the remote Stack
|
|
@@ -163,7 +164,7 @@ EXAMPLES
|
|
|
163
164
|
$ sanity-run blueprints deploy --no-wait
|
|
164
165
|
```
|
|
165
166
|
|
|
166
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
167
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/deploy.ts)_
|
|
167
168
|
|
|
168
169
|
## `sanity-run blueprints destroy`
|
|
169
170
|
|
|
@@ -171,13 +172,13 @@ Destroy the remote Stack deployment and its resources (will not delete local fil
|
|
|
171
172
|
|
|
172
173
|
```
|
|
173
174
|
USAGE
|
|
174
|
-
$ sanity-run blueprints destroy [--project-id <value> --stack
|
|
175
|
+
$ sanity-run blueprints destroy [--project-id <value> --stack <value> --force] [--no-wait]
|
|
175
176
|
|
|
176
177
|
FLAGS
|
|
177
178
|
--force Force Stack destruction (skip confirmation)
|
|
178
179
|
--no-wait Do not wait for Stack destruction to complete
|
|
179
180
|
--project-id=<value> Project associated with the Stack
|
|
180
|
-
--stack
|
|
181
|
+
--stack=<value> Stack name or ID to destroy (defaults to the locally configured Stack)
|
|
181
182
|
|
|
182
183
|
DESCRIPTION
|
|
183
184
|
Destroy the remote Stack deployment and its resources (will not delete local files)
|
|
@@ -192,10 +193,10 @@ DESCRIPTION
|
|
|
192
193
|
EXAMPLES
|
|
193
194
|
$ sanity-run blueprints destroy
|
|
194
195
|
|
|
195
|
-
$ sanity-run blueprints destroy --stack-id
|
|
196
|
+
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
196
197
|
```
|
|
197
198
|
|
|
198
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
199
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/destroy.ts)_
|
|
199
200
|
|
|
200
201
|
## `sanity-run blueprints doctor`
|
|
201
202
|
|
|
@@ -221,7 +222,7 @@ DESCRIPTION
|
|
|
221
222
|
issues.
|
|
222
223
|
```
|
|
223
224
|
|
|
224
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
225
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/doctor.ts)_
|
|
225
226
|
|
|
226
227
|
## `sanity-run blueprints info`
|
|
227
228
|
|
|
@@ -229,10 +230,10 @@ Show information about the local Blueprint's remote Stack deployment
|
|
|
229
230
|
|
|
230
231
|
```
|
|
231
232
|
USAGE
|
|
232
|
-
$ sanity-run blueprints info [--
|
|
233
|
+
$ sanity-run blueprints info [--stack <value>]
|
|
233
234
|
|
|
234
235
|
FLAGS
|
|
235
|
-
--
|
|
236
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
236
237
|
|
|
237
238
|
DESCRIPTION
|
|
238
239
|
Show information about the local Blueprint's remote Stack deployment
|
|
@@ -248,10 +249,10 @@ DESCRIPTION
|
|
|
248
249
|
EXAMPLES
|
|
249
250
|
$ sanity-run blueprints info
|
|
250
251
|
|
|
251
|
-
$ sanity-run blueprints info --
|
|
252
|
+
$ sanity-run blueprints info --stack <name-or-id>
|
|
252
253
|
```
|
|
253
254
|
|
|
254
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
255
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/info.ts)_
|
|
255
256
|
|
|
256
257
|
## `sanity-run blueprints init [DIR]`
|
|
257
258
|
|
|
@@ -301,7 +302,7 @@ EXAMPLES
|
|
|
301
302
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
302
303
|
```
|
|
303
304
|
|
|
304
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
305
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/init.ts)_
|
|
305
306
|
|
|
306
307
|
## `sanity-run blueprints logs`
|
|
307
308
|
|
|
@@ -309,10 +310,11 @@ Display logs for the current Blueprint's Stack deployment
|
|
|
309
310
|
|
|
310
311
|
```
|
|
311
312
|
USAGE
|
|
312
|
-
$ sanity-run blueprints logs [-w]
|
|
313
|
+
$ sanity-run blueprints logs [--stack <value>] [-w]
|
|
313
314
|
|
|
314
315
|
FLAGS
|
|
315
|
-
-w, --watch
|
|
316
|
+
-w, --watch Watch for new Stack logs (streaming mode)
|
|
317
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
316
318
|
|
|
317
319
|
DESCRIPTION
|
|
318
320
|
Display logs for the current Blueprint's Stack deployment
|
|
@@ -329,7 +331,7 @@ EXAMPLES
|
|
|
329
331
|
$ sanity-run blueprints logs --watch
|
|
330
332
|
```
|
|
331
333
|
|
|
332
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
334
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/logs.ts)_
|
|
333
335
|
|
|
334
336
|
## `sanity-run blueprints plan`
|
|
335
337
|
|
|
@@ -337,7 +339,10 @@ Enumerate resources to be deployed to the remote Stack - will not modify any res
|
|
|
337
339
|
|
|
338
340
|
```
|
|
339
341
|
USAGE
|
|
340
|
-
$ sanity-run blueprints plan
|
|
342
|
+
$ sanity-run blueprints plan [--stack <value>]
|
|
343
|
+
|
|
344
|
+
FLAGS
|
|
345
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
341
346
|
|
|
342
347
|
DESCRIPTION
|
|
343
348
|
Enumerate resources to be deployed to the remote Stack - will not modify any resources
|
|
@@ -352,7 +357,7 @@ EXAMPLES
|
|
|
352
357
|
$ sanity-run blueprints plan
|
|
353
358
|
```
|
|
354
359
|
|
|
355
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
360
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/plan.ts)_
|
|
356
361
|
|
|
357
362
|
## `sanity-run blueprints stacks`
|
|
358
363
|
|
|
@@ -381,7 +386,7 @@ EXAMPLES
|
|
|
381
386
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
382
387
|
```
|
|
383
388
|
|
|
384
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
389
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/blueprints/stacks.ts)_
|
|
385
390
|
|
|
386
391
|
## `sanity-run functions add`
|
|
387
392
|
|
|
@@ -430,7 +435,7 @@ EXAMPLES
|
|
|
430
435
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
431
436
|
```
|
|
432
437
|
|
|
433
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
438
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/add.ts)_
|
|
434
439
|
|
|
435
440
|
## `sanity-run functions dev`
|
|
436
441
|
|
|
@@ -464,7 +469,7 @@ EXAMPLES
|
|
|
464
469
|
$ sanity-run functions dev --timeout 60
|
|
465
470
|
```
|
|
466
471
|
|
|
467
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
472
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/dev.ts)_
|
|
468
473
|
|
|
469
474
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
470
475
|
|
|
@@ -491,7 +496,7 @@ EXAMPLES
|
|
|
491
496
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
492
497
|
```
|
|
493
498
|
|
|
494
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
499
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/env/add.ts)_
|
|
495
500
|
|
|
496
501
|
## `sanity-run functions env list NAME`
|
|
497
502
|
|
|
@@ -515,7 +520,7 @@ EXAMPLES
|
|
|
515
520
|
$ sanity-run functions env list MyFunction
|
|
516
521
|
```
|
|
517
522
|
|
|
518
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
523
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/env/list.ts)_
|
|
519
524
|
|
|
520
525
|
## `sanity-run functions env remove NAME KEY`
|
|
521
526
|
|
|
@@ -541,7 +546,7 @@ EXAMPLES
|
|
|
541
546
|
$ sanity-run functions env remove MyFunction API_URL
|
|
542
547
|
```
|
|
543
548
|
|
|
544
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
549
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/env/remove.ts)_
|
|
545
550
|
|
|
546
551
|
## `sanity-run functions logs [NAME]`
|
|
547
552
|
|
|
@@ -549,7 +554,7 @@ Retrieve or delete logs for a Sanity Function
|
|
|
549
554
|
|
|
550
555
|
```
|
|
551
556
|
USAGE
|
|
552
|
-
$ sanity-run functions logs [NAME] [-u] [-f [-d | -l <value> | -j]] [-w]
|
|
557
|
+
$ sanity-run functions logs [NAME] [--stack <value>] [-u] [-f [-d | -l <value> | -j]] [-w]
|
|
553
558
|
|
|
554
559
|
ARGUMENTS
|
|
555
560
|
[NAME] The name of the Sanity Function
|
|
@@ -561,6 +566,7 @@ FLAGS
|
|
|
561
566
|
-l, --limit=<value> [default: 50] Total number of log entries to retrieve
|
|
562
567
|
-u, --utc Show dates in UTC time zone
|
|
563
568
|
-w, --watch Watch for new logs (streaming mode)
|
|
569
|
+
--stack=<value> Stack name or ID to use instead of the locally configured Stack
|
|
564
570
|
|
|
565
571
|
DESCRIPTION
|
|
566
572
|
Retrieve or delete logs for a Sanity Function
|
|
@@ -580,7 +586,7 @@ EXAMPLES
|
|
|
580
586
|
$ sanity-run functions logs <name> --delete
|
|
581
587
|
```
|
|
582
588
|
|
|
583
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
589
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/logs.ts)_
|
|
584
590
|
|
|
585
591
|
## `sanity-run functions test [NAME]`
|
|
586
592
|
|
|
@@ -634,7 +640,7 @@ EXAMPLES
|
|
|
634
640
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
635
641
|
```
|
|
636
642
|
|
|
637
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/
|
|
643
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v14.0.0/src/commands/functions/test.ts)_
|
|
638
644
|
|
|
639
645
|
## `sanity-run help [COMMAND]`
|
|
640
646
|
|
|
@@ -55,6 +55,7 @@ interface DestroyStackResponse {
|
|
|
55
55
|
error: string | null;
|
|
56
56
|
stack: Stack;
|
|
57
57
|
}
|
|
58
|
+
export declare function resolveStackIdByNameOrId(value: string, auth: AuthParams, logger: ReturnType<typeof Logger>): Promise<string>;
|
|
58
59
|
export declare function destroyStack({ stackId, auth, logger, }: {
|
|
59
60
|
stackId: string;
|
|
60
61
|
auth: AuthParams;
|
|
@@ -75,6 +75,17 @@ export async function updateStack({ stackId, stackMutation, auth, logger, }) {
|
|
|
75
75
|
stack: data,
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
|
+
export async function resolveStackIdByNameOrId(value, auth, logger) {
|
|
79
|
+
if (value.startsWith('ST-') && value.length === 13)
|
|
80
|
+
return value;
|
|
81
|
+
const result = await listStacks(auth, logger);
|
|
82
|
+
if (!result.ok)
|
|
83
|
+
throw new Error(result.error || 'Failed to list stacks');
|
|
84
|
+
const match = result.stacks.find((s) => s.name === value);
|
|
85
|
+
if (!match)
|
|
86
|
+
throw new Error(`No stack found with name "${value}"`);
|
|
87
|
+
return match.id;
|
|
88
|
+
}
|
|
78
89
|
export async function destroyStack({ stackId, auth, logger, }) {
|
|
79
90
|
const fetchFn = createTracedFetch(logger);
|
|
80
91
|
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
package/dist/baseCommands.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const baseFlags: {
|
|
|
11
11
|
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
12
12
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
13
13
|
};
|
|
14
|
+
export declare const stackFlag: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
14
15
|
/**
|
|
15
16
|
* @description Unhides a flag by setting its hidden property to false
|
|
16
17
|
* Also makes oclif's types happy when destructuring the flag
|
|
@@ -75,6 +76,7 @@ export declare abstract class DeployedStackCommand<T extends typeof Command> ext
|
|
|
75
76
|
protected scopeId: string;
|
|
76
77
|
protected stackId: string;
|
|
77
78
|
static baseFlags: {
|
|
79
|
+
stack: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
78
80
|
json: Interfaces.BooleanFlag<boolean>;
|
|
79
81
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
80
82
|
trace: Interfaces.BooleanFlag<boolean>;
|
package/dist/baseCommands.js
CHANGED
|
@@ -33,6 +33,10 @@ export const baseFlags = {
|
|
|
33
33
|
hidden,
|
|
34
34
|
}),
|
|
35
35
|
};
|
|
36
|
+
export const stackFlag = OclifFlags.string({
|
|
37
|
+
description: 'Stack name or ID to use instead of the locally configured Stack',
|
|
38
|
+
hidden: true,
|
|
39
|
+
});
|
|
36
40
|
/**
|
|
37
41
|
* @description Unhides a flag by setting its hidden property to false
|
|
38
42
|
* Also makes oclif's types happy when destructuring the flag
|
|
@@ -150,7 +154,7 @@ export class DeployedStackCommand extends LocalBlueprintCommand {
|
|
|
150
154
|
scopeType;
|
|
151
155
|
scopeId;
|
|
152
156
|
stackId;
|
|
153
|
-
static baseFlags = baseFlags;
|
|
157
|
+
static baseFlags = { ...baseFlags, stack: stackFlag };
|
|
154
158
|
async init() {
|
|
155
159
|
await super.init();
|
|
156
160
|
const result = await initDeployedBlueprintConfig({
|
|
@@ -160,6 +164,7 @@ export class DeployedStackCommand extends LocalBlueprintCommand {
|
|
|
160
164
|
token: this.sanityToken,
|
|
161
165
|
validateToken: false,
|
|
162
166
|
validateResources: this.flags['validate-resources'],
|
|
167
|
+
stackOverride: this.flags.stack,
|
|
163
168
|
});
|
|
164
169
|
if (!result.ok) {
|
|
165
170
|
this.error(result.error);
|
|
@@ -7,7 +7,7 @@ export default class ConfigCommand extends LocalBlueprintCommand<typeof ConfigCo
|
|
|
7
7
|
edit: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
|
|
10
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
};
|
|
12
12
|
run(): Promise<void>;
|
|
13
13
|
}
|
|
@@ -8,12 +8,12 @@ export default class ConfigCommand extends LocalBlueprintCommand {
|
|
|
8
8
|
|
|
9
9
|
Without flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with ID flags to update values directly (useful for scripting and automation).
|
|
10
10
|
|
|
11
|
-
If you need to switch your Blueprint to a different Stack, use --edit --stack
|
|
11
|
+
If you need to switch your Blueprint to a different Stack, use --edit --stack.`;
|
|
12
12
|
static examples = [
|
|
13
13
|
'<%= config.bin %> <%= command.id %>',
|
|
14
14
|
'<%= config.bin %> <%= command.id %> --edit',
|
|
15
15
|
'<%= config.bin %> <%= command.id %> --edit --project-id <projectId>',
|
|
16
|
-
'<%= config.bin %> <%= command.id %> --edit --project-id <projectId> --stack-id
|
|
16
|
+
'<%= config.bin %> <%= command.id %> --edit --project-id <projectId> --stack <name-or-id>',
|
|
17
17
|
];
|
|
18
18
|
static flags = {
|
|
19
19
|
edit: Flags.boolean({
|
|
@@ -32,9 +32,9 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack-id
|
|
|
32
32
|
dependsOn: ['edit'],
|
|
33
33
|
hidden: true,
|
|
34
34
|
}),
|
|
35
|
-
|
|
36
|
-
description: '
|
|
37
|
-
aliases: ['stack', 'stackId'],
|
|
35
|
+
stack: Flags.string({
|
|
36
|
+
description: 'Stack name or ID to set in the configuration. Requires --edit flag',
|
|
37
|
+
aliases: ['stack-id', 'stackId'],
|
|
38
38
|
dependsOn: ['edit'],
|
|
39
39
|
}),
|
|
40
40
|
};
|
|
@@ -4,6 +4,7 @@ export default class DeployCommand extends DeployedStackCommand<typeof DeployCom
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
'new-stack-name': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
10
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
import { DeployedStackCommand, stackFlag, unhide } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintDeployCore } from '../../cores/blueprints/deploy.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class DeployCommand extends DeployedStackCommand {
|
|
@@ -14,6 +14,7 @@ Use --no-wait to queue the deployment and return immediately without waiting for
|
|
|
14
14
|
'<%= config.bin %> <%= command.id %> --no-wait',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
+
stack: unhide(stackFlag),
|
|
17
18
|
'no-wait': Flags.boolean({
|
|
18
19
|
description: 'Do not wait for Stack deployment to complete',
|
|
19
20
|
default: false,
|
|
@@ -7,7 +7,7 @@ export default class DestroyCommand extends LocalBlueprintCommand<typeof Destroy
|
|
|
7
7
|
force: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
'project-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
'organization-id': import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
-
|
|
10
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
11
|
'no-wait': import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
12
|
};
|
|
13
13
|
run(): Promise<void>;
|
|
@@ -11,7 +11,7 @@ This is a destructive operation. You will be prompted to confirm unless --force
|
|
|
11
11
|
Use this to clean up test environments or decommission a Stack you no longer need.`;
|
|
12
12
|
static examples = [
|
|
13
13
|
'<%= config.bin %> <%= command.id %>',
|
|
14
|
-
'<%= config.bin %> <%= command.id %> --stack-id
|
|
14
|
+
'<%= config.bin %> <%= command.id %> --stack <name-or-id> --project-id <projectId> --force --no-wait',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
17
|
force: Flags.boolean({
|
|
@@ -22,19 +22,19 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
22
22
|
'project-id': Flags.string({
|
|
23
23
|
description: 'Project associated with the Stack',
|
|
24
24
|
aliases: ['projectId', 'project'],
|
|
25
|
-
dependsOn: ['stack
|
|
25
|
+
dependsOn: ['stack', 'force'],
|
|
26
26
|
exclusive: ['organization-id'],
|
|
27
27
|
}),
|
|
28
28
|
'organization-id': Flags.string({
|
|
29
29
|
description: 'Organization associated with the Stack',
|
|
30
30
|
aliases: ['organizationId', 'organization', 'org'],
|
|
31
|
-
dependsOn: ['stack
|
|
31
|
+
dependsOn: ['stack', 'force'],
|
|
32
32
|
exclusive: ['project-id'],
|
|
33
33
|
hidden: true,
|
|
34
34
|
}),
|
|
35
|
-
|
|
36
|
-
description: 'Stack ID to destroy (defaults to
|
|
37
|
-
aliases: ['
|
|
35
|
+
stack: Flags.string({
|
|
36
|
+
description: 'Stack name or ID to destroy (defaults to the locally configured Stack)',
|
|
37
|
+
aliases: ['stack-id', 'stackId'],
|
|
38
38
|
}),
|
|
39
39
|
'no-wait': Flags.boolean({
|
|
40
40
|
description: 'Do not wait for Stack destruction to complete',
|
|
@@ -4,7 +4,7 @@ export default class InfoCommand extends DeployedStackCommand<typeof InfoCommand
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
-
|
|
7
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
};
|
|
9
9
|
run(): Promise<void>;
|
|
10
10
|
}
|
|
@@ -11,18 +11,18 @@ Use this command to verify a deployment succeeded, check what resources are live
|
|
|
11
11
|
Run 'blueprints stacks' to see all available Stacks in your project or organization.`;
|
|
12
12
|
static examples = [
|
|
13
13
|
'<%= config.bin %> <%= command.id %>',
|
|
14
|
-
'<%= config.bin %> <%= command.id %> --
|
|
14
|
+
'<%= config.bin %> <%= command.id %> --stack <name-or-id>',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
-
|
|
18
|
-
description: 'Stack ID to
|
|
17
|
+
stack: Flags.string({
|
|
18
|
+
description: 'Stack name or ID to use instead of the locally configured Stack',
|
|
19
|
+
aliases: ['id'],
|
|
19
20
|
}),
|
|
20
21
|
};
|
|
21
22
|
async run() {
|
|
22
23
|
const { success, error } = await blueprintInfoCore({
|
|
23
24
|
bin: this.config.bin,
|
|
24
25
|
log: Logger(this.log.bind(this), this.flags),
|
|
25
|
-
auth: this.auth,
|
|
26
26
|
stackId: this.stackId,
|
|
27
27
|
deployedStack: this.deployedStack,
|
|
28
28
|
validateResources: this.flags['validate-resources'],
|
|
@@ -49,7 +49,7 @@ After initialization, use 'blueprints plan' to preview changes, then 'blueprints
|
|
|
49
49
|
}),
|
|
50
50
|
'stack-id': Flags.string({
|
|
51
51
|
description: 'Existing Stack ID used to scope local Blueprint',
|
|
52
|
-
aliases: ['
|
|
52
|
+
aliases: ['stackId'],
|
|
53
53
|
dependsOn: ['project-id'],
|
|
54
54
|
exclusive: ['stack-name'],
|
|
55
55
|
}),
|
|
@@ -4,6 +4,7 @@ export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand
|
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
6
|
static flags: {
|
|
7
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
8
|
watch: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
9
|
};
|
|
9
10
|
run(): Promise<void>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Flags } from '@oclif/core';
|
|
2
|
-
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
import { DeployedStackCommand, stackFlag, unhide } from '../../baseCommands.js';
|
|
3
3
|
import { blueprintLogsCore } from '../../cores/blueprints/logs.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class LogsCommand extends DeployedStackCommand {
|
|
@@ -14,6 +14,7 @@ If you're not seeing expected logs, verify your Stack is deployed with 'blueprin
|
|
|
14
14
|
'<%= config.bin %> <%= command.id %> --watch',
|
|
15
15
|
];
|
|
16
16
|
static flags = {
|
|
17
|
+
stack: unhide(stackFlag),
|
|
17
18
|
watch: Flags.boolean({
|
|
18
19
|
char: 'w',
|
|
19
20
|
description: 'Watch for new Stack logs (streaming mode)',
|
|
@@ -3,5 +3,8 @@ export default class PlanCommand extends LocalBlueprintCommand<typeof PlanComman
|
|
|
3
3
|
static summary: string;
|
|
4
4
|
static description: string;
|
|
5
5
|
static examples: string[];
|
|
6
|
+
static flags: {
|
|
7
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
};
|
|
6
9
|
run(): Promise<void>;
|
|
7
10
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { LocalBlueprintCommand } from '../../baseCommands.js';
|
|
1
|
+
import { LocalBlueprintCommand, stackFlag, unhide } from '../../baseCommands.js';
|
|
2
2
|
import { blueprintPlanCore } from '../../cores/blueprints/plan.js';
|
|
3
3
|
import { Logger } from '../../utils/logger.js';
|
|
4
4
|
export default class PlanCommand extends LocalBlueprintCommand {
|
|
@@ -7,6 +7,9 @@ export default class PlanCommand extends LocalBlueprintCommand {
|
|
|
7
7
|
|
|
8
8
|
Run 'blueprints plan' after making local changes to your Blueprint manifest to verify the expected diff. When ready, run 'blueprints deploy' to apply changes.`;
|
|
9
9
|
static examples = ['<%= config.bin %> <%= command.id %>'];
|
|
10
|
+
static flags = {
|
|
11
|
+
stack: unhide(stackFlag),
|
|
12
|
+
};
|
|
10
13
|
async run() {
|
|
11
14
|
const { success, error } = await blueprintPlanCore({
|
|
12
15
|
bin: this.config.bin,
|
|
@@ -7,6 +7,7 @@ export default class LogsCommand extends DeployedStackCommand<typeof LogsCommand
|
|
|
7
7
|
};
|
|
8
8
|
static examples: string[];
|
|
9
9
|
static flags: {
|
|
10
|
+
stack: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
11
|
limit: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
11
12
|
json: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
12
13
|
utc: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Args, Flags } from '@oclif/core';
|
|
2
|
-
import { DeployedStackCommand } from '../../baseCommands.js';
|
|
2
|
+
import { DeployedStackCommand, stackFlag, unhide } from '../../baseCommands.js';
|
|
3
3
|
import { functionLogsCore } from '../../cores/functions/logs.js';
|
|
4
4
|
import { Logger } from '../../utils/logger.js';
|
|
5
5
|
export default class LogsCommand extends DeployedStackCommand {
|
|
@@ -17,6 +17,7 @@ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for
|
|
|
17
17
|
'<%= config.bin %> <%= command.id %> <name> --delete',
|
|
18
18
|
];
|
|
19
19
|
static flags = {
|
|
20
|
+
stack: unhide(stackFlag),
|
|
20
21
|
limit: Flags.integer({
|
|
21
22
|
char: 'l',
|
|
22
23
|
description: 'Total number of log entries to retrieve',
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { patchConfigFile, writeConfigFile, } from '../../actions/blueprints/config.js';
|
|
2
|
+
import { resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
2
3
|
import { filePathRelativeToCwd, labeledId, warn } from '../../utils/display/presenters.js';
|
|
3
4
|
import { promptForProject, promptForStack } from '../../utils/display/prompt.js';
|
|
4
5
|
import { styleText } from '../../utils/style-text.js';
|
|
5
6
|
export async function blueprintConfigCore(options) {
|
|
6
7
|
const { bin = 'sanity', blueprint, log, token, flags } = options;
|
|
7
|
-
const { edit: editConfig = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId,
|
|
8
|
-
const providedConfigFlag = [flagProjectId,
|
|
8
|
+
const { edit: editConfig = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, stack: flagStack, verbose: _v = false, } = flags;
|
|
9
|
+
const providedConfigFlag = [flagProjectId, flagStack, flagOrganizationId].some(Boolean);
|
|
9
10
|
const { stackId: configStackId, scopeType: configScopeType, scopeId: configScopeId, blueprintConfig, fileInfo, } = blueprint;
|
|
10
11
|
const blueprintFilePath = fileInfo.blueprintFilePath;
|
|
11
12
|
if (!configStackId && !configScopeType && !configScopeId) {
|
|
@@ -34,8 +35,16 @@ export async function blueprintConfigCore(options) {
|
|
|
34
35
|
const configUpdate = {};
|
|
35
36
|
if (flagProjectId)
|
|
36
37
|
configUpdate.projectId = flagProjectId;
|
|
37
|
-
if (
|
|
38
|
-
|
|
38
|
+
if (flagStack) {
|
|
39
|
+
const scopeType = flagProjectId ? 'project' : configScopeType;
|
|
40
|
+
const scopeId = flagProjectId || configScopeId;
|
|
41
|
+
if (scopeType && scopeId) {
|
|
42
|
+
configUpdate.stackId = await resolveStackIdByNameOrId(flagStack, { token, scopeType, scopeId }, log);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
configUpdate.stackId = flagStack;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
39
48
|
if (flagOrganizationId)
|
|
40
49
|
configUpdate.organizationId = flagOrganizationId;
|
|
41
50
|
try {
|
|
@@ -60,7 +69,10 @@ export async function blueprintConfigCore(options) {
|
|
|
60
69
|
}
|
|
61
70
|
if (!updatedProjectId)
|
|
62
71
|
return { success: false, error: 'Project ID is required.' };
|
|
63
|
-
let updatedStackId
|
|
72
|
+
let updatedStackId;
|
|
73
|
+
if (flagStack) {
|
|
74
|
+
updatedStackId = await resolveStackIdByNameOrId(flagStack, { token, scopeType: 'project', scopeId: updatedProjectId }, log);
|
|
75
|
+
}
|
|
64
76
|
if (!updatedStackId) {
|
|
65
77
|
const pickedStack = await promptForStack({ projectId: updatedProjectId, token, logger: log });
|
|
66
78
|
updatedStackId = pickedStack.stackId;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { setTimeout } from 'node:timers/promises';
|
|
2
2
|
import { confirm } from '@inquirer/prompts';
|
|
3
3
|
import { setupLogStreaming } from '../../actions/blueprints/logs-streaming.js';
|
|
4
|
-
import { destroyStack, getStack } from '../../actions/blueprints/stacks.js';
|
|
4
|
+
import { destroyStack, getStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
5
5
|
import { niceId } from '../../utils/display/presenters.js';
|
|
6
6
|
import { styleText } from '../../utils/style-text.js';
|
|
7
7
|
export async function blueprintDestroyCore(options) {
|
|
8
8
|
const { log, token, blueprint, flags } = options;
|
|
9
|
-
const { force = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId,
|
|
9
|
+
const { force = false, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, stack: flagStack, 'no-wait': noWait = false, verbose: _verbose = false, } = flags;
|
|
10
10
|
// 3-flag combo: just destroy it
|
|
11
|
-
if ((flagProjectId || flagOrganizationId) &&
|
|
11
|
+
if ((flagProjectId || flagOrganizationId) && flagStack && force) {
|
|
12
12
|
let scopeType;
|
|
13
13
|
let scopeId;
|
|
14
14
|
if (flagOrganizationId) {
|
|
@@ -22,9 +22,11 @@ export async function blueprintDestroyCore(options) {
|
|
|
22
22
|
else {
|
|
23
23
|
return { success: false, error: 'Unable to determine scope for Blueprint Destroy' };
|
|
24
24
|
}
|
|
25
|
+
const auth = { token, scopeType, scopeId };
|
|
26
|
+
const resolvedId = await resolveStackIdByNameOrId(flagStack, auth, log);
|
|
25
27
|
const { ok, error, stack } = await destroyStack({
|
|
26
|
-
stackId:
|
|
27
|
-
auth
|
|
28
|
+
stackId: resolvedId,
|
|
29
|
+
auth,
|
|
28
30
|
logger: log,
|
|
29
31
|
});
|
|
30
32
|
if (!ok)
|
|
@@ -36,13 +38,16 @@ export async function blueprintDestroyCore(options) {
|
|
|
36
38
|
if (!scopeType || !scopeId)
|
|
37
39
|
return { success: false, error: 'Scope is required' };
|
|
38
40
|
const auth = { token, scopeType, scopeId };
|
|
41
|
+
const resolvedStackId = flagStack
|
|
42
|
+
? await resolveStackIdByNameOrId(flagStack, auth, log)
|
|
43
|
+
: undefined;
|
|
39
44
|
let stack;
|
|
40
45
|
try {
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
if (!
|
|
44
|
-
return { success: false, error:
|
|
45
|
-
stack =
|
|
46
|
+
if (resolvedStackId) {
|
|
47
|
+
const overrideStack = await getStack({ stackId: resolvedStackId, auth, logger: log });
|
|
48
|
+
if (!overrideStack.ok)
|
|
49
|
+
return { success: false, error: overrideStack.error || 'Failed to get Stack' };
|
|
50
|
+
stack = overrideStack.stack;
|
|
46
51
|
}
|
|
47
52
|
else if (stackId) {
|
|
48
53
|
const blueprintStack = await getStack({ stackId, auth, logger: log });
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Stack } from '../../utils/types.js';
|
|
2
2
|
import type { CoreConfig, CoreResult } from '../index.js';
|
|
3
3
|
export interface BlueprintInfoOptions extends CoreConfig {
|
|
4
|
-
auth: AuthParams;
|
|
5
4
|
stackId: string;
|
|
6
5
|
deployedStack: Stack;
|
|
7
6
|
flags: {
|
|
8
|
-
id?: string;
|
|
9
7
|
verbose?: boolean;
|
|
10
8
|
};
|
|
11
9
|
}
|
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
2
1
|
import { formatDeployedResourceTree, formatStackInfo, } from '../../utils/display/blueprints-formatting.js';
|
|
3
|
-
import { niceId } from '../../utils/display/presenters.js';
|
|
4
2
|
export async function blueprintInfoCore(options) {
|
|
5
|
-
const { log,
|
|
6
|
-
const {
|
|
3
|
+
const { log, deployedStack, flags } = options;
|
|
4
|
+
const { verbose = false } = flags;
|
|
7
5
|
try {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
const existingStackResponse = await getStack({ stackId: targetStackId, auth, logger: log });
|
|
12
|
-
if (!existingStackResponse.ok) {
|
|
13
|
-
log.error(`Could not retrieve Stack deployment info for ${niceId(targetStackId)}`);
|
|
14
|
-
return {
|
|
15
|
-
success: false,
|
|
16
|
-
error: existingStackResponse.error || 'Failed to retrieve Stack deployment',
|
|
17
|
-
};
|
|
18
|
-
}
|
|
19
|
-
stack = existingStackResponse.stack;
|
|
20
|
-
}
|
|
21
|
-
log(formatStackInfo(stack, true));
|
|
22
|
-
if (stack.resources)
|
|
23
|
-
log(formatDeployedResourceTree(stack.resources, verbose));
|
|
6
|
+
log(formatStackInfo(deployedStack, true));
|
|
7
|
+
if (deployedStack.resources)
|
|
8
|
+
log(formatDeployedResourceTree(deployedStack.resources, verbose));
|
|
24
9
|
return { success: true };
|
|
25
10
|
}
|
|
26
11
|
catch (error) {
|
|
@@ -1,25 +1,30 @@
|
|
|
1
|
-
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
1
|
+
import { getStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
2
2
|
import { formatResourceTree, stackDeployDiff } from '../../utils/display/blueprints-formatting.js';
|
|
3
3
|
import { styleText } from '../../utils/style-text.js';
|
|
4
4
|
export async function blueprintPlanCore(options) {
|
|
5
5
|
const { bin = 'sanity', log, blueprint, token, flags } = options;
|
|
6
6
|
const { verbose: _verbose = false } = flags;
|
|
7
|
-
const { scopeType, scopeId, stackId, parsedBlueprint, fileInfo } = blueprint;
|
|
7
|
+
const { scopeType, scopeId, stackId: blueprintStackId, parsedBlueprint, fileInfo } = blueprint;
|
|
8
8
|
log(`${styleText(['bold', 'blueBright'], 'Blueprint Stack deployment plan')} ${styleText('dim', `(${fileInfo.fileName})`)}`);
|
|
9
9
|
log(formatResourceTree(parsedBlueprint.resources));
|
|
10
|
-
if (token && scopeType && scopeId
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
if (token && scopeType && scopeId) {
|
|
11
|
+
const stackId = flags.stack
|
|
12
|
+
? await resolveStackIdByNameOrId(flags.stack, { token, scopeType, scopeId }, log)
|
|
13
|
+
: blueprintStackId;
|
|
14
|
+
if (stackId) {
|
|
15
|
+
const stackResponse = await getStack({
|
|
16
|
+
auth: { token, scopeType, scopeId },
|
|
17
|
+
stackId,
|
|
18
|
+
logger: log,
|
|
19
|
+
});
|
|
20
|
+
if (!stackResponse.ok) {
|
|
21
|
+
log(styleText('dim', 'Unable to retrieve live Stack deployment for comparison'));
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
const diff = stackDeployDiff(parsedBlueprint, stackResponse.stack);
|
|
25
|
+
if (diff)
|
|
26
|
+
log(diff);
|
|
27
|
+
}
|
|
23
28
|
}
|
|
24
29
|
}
|
|
25
30
|
log(`\n Run "${styleText(['bold', 'magenta'], `${bin} blueprints deploy`)}" to deploy these Stack changes`);
|
package/dist/cores/index.d.ts
CHANGED
|
@@ -50,4 +50,5 @@ type InitBlueprintConfigParams = CoreConfig & ({
|
|
|
50
50
|
export declare function initBlueprintConfig({ bin, log, token, validateResources, validateToken, blueprintPath, }: InitBlueprintConfigParams): Promise<Result<BlueprintConfig>>;
|
|
51
51
|
export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'token' | 'validateResources'> & {
|
|
52
52
|
validateToken?: boolean;
|
|
53
|
+
stackOverride?: string;
|
|
53
54
|
}): Promise<Result<DeployedBlueprintConfig>>;
|
package/dist/cores/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { readLocalBlueprint } from '../actions/blueprints/blueprint.js';
|
|
2
|
-
import { getStack } from '../actions/blueprints/stacks.js';
|
|
2
|
+
import { getStack, resolveStackIdByNameOrId } from '../actions/blueprints/stacks.js';
|
|
3
3
|
import { presentBlueprintParserErrors } from '../utils/display/errors.js';
|
|
4
4
|
import { niceId } from '../utils/display/presenters.js';
|
|
5
5
|
import { validTokenOrErrorMessage } from '../utils/validated-token.js';
|
|
@@ -41,15 +41,20 @@ export async function initDeployedBlueprintConfig(config) {
|
|
|
41
41
|
config.blueprint = blueprintResult.value.blueprint;
|
|
42
42
|
config.token = blueprintResult.value.token;
|
|
43
43
|
}
|
|
44
|
-
const { scopeType, scopeId, stackId } = config.blueprint;
|
|
45
|
-
if (!
|
|
44
|
+
const { scopeType, scopeId, stackId: blueprintStackId } = config.blueprint;
|
|
45
|
+
if (!scopeType || !scopeId) {
|
|
46
46
|
config.log(`Incomplete configuration. Run \`${config.bin} blueprints doctor\` for diagnostics.`);
|
|
47
|
-
|
|
48
|
-
return { ok: false, error: 'Missing scope configuration for Blueprint' };
|
|
49
|
-
if (!stackId)
|
|
50
|
-
return { ok: false, error: 'Missing Stack deployment configuration for Blueprint' };
|
|
47
|
+
return { ok: false, error: 'Missing scope configuration for Blueprint' };
|
|
51
48
|
}
|
|
52
49
|
const auth = { token: config.token, scopeType, scopeId };
|
|
50
|
+
let stackId = blueprintStackId;
|
|
51
|
+
if (config.stackOverride) {
|
|
52
|
+
stackId = await resolveStackIdByNameOrId(config.stackOverride, auth, config.log);
|
|
53
|
+
}
|
|
54
|
+
if (!stackId) {
|
|
55
|
+
config.log(`Incomplete configuration. Run \`${config.bin} blueprints doctor\` for diagnostics.`);
|
|
56
|
+
return { ok: false, error: 'Missing Stack deployment configuration for Blueprint' };
|
|
57
|
+
}
|
|
53
58
|
const stackResponse = await getStack({ stackId, auth, logger: config.log });
|
|
54
59
|
if (!stackResponse.ok) {
|
|
55
60
|
config.log(`Could not retrieve Stack deployment info for ${niceId(stackId)}.`);
|
package/oclif.manifest.json
CHANGED
|
@@ -197,12 +197,12 @@
|
|
|
197
197
|
"blueprints:config": {
|
|
198
198
|
"aliases": [],
|
|
199
199
|
"args": {},
|
|
200
|
-
"description": "Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.\n\nWithout flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with ID flags to update values directly (useful for scripting and automation).\n\nIf you need to switch your Blueprint to a different Stack, use --edit --stack
|
|
200
|
+
"description": "Manages the local Blueprint configuration, which links your Blueprint to a Sanity project and Stack.\n\nWithout flags, displays the current configuration. Use --edit to interactively modify settings, or combine --edit with ID flags to update values directly (useful for scripting and automation).\n\nIf you need to switch your Blueprint to a different Stack, use --edit --stack.",
|
|
201
201
|
"examples": [
|
|
202
202
|
"<%= config.bin %> <%= command.id %>",
|
|
203
203
|
"<%= config.bin %> <%= command.id %> --edit",
|
|
204
204
|
"<%= config.bin %> <%= command.id %> --edit --project-id <projectId>",
|
|
205
|
-
"<%= config.bin %> <%= command.id %> --edit --project-id <projectId> --stack-id
|
|
205
|
+
"<%= config.bin %> <%= command.id %> --edit --project-id <projectId> --stack <name-or-id>"
|
|
206
206
|
],
|
|
207
207
|
"flags": {
|
|
208
208
|
"json": {
|
|
@@ -283,16 +283,16 @@
|
|
|
283
283
|
"multiple": false,
|
|
284
284
|
"type": "option"
|
|
285
285
|
},
|
|
286
|
-
"stack
|
|
286
|
+
"stack": {
|
|
287
287
|
"aliases": [
|
|
288
|
-
"stack",
|
|
288
|
+
"stack-id",
|
|
289
289
|
"stackId"
|
|
290
290
|
],
|
|
291
291
|
"dependsOn": [
|
|
292
292
|
"edit"
|
|
293
293
|
],
|
|
294
|
-
"description": "
|
|
295
|
-
"name": "stack
|
|
294
|
+
"description": "Stack name or ID to set in the configuration. Requires --edit flag",
|
|
295
|
+
"name": "stack",
|
|
296
296
|
"hasDynamicHelp": false,
|
|
297
297
|
"multiple": false,
|
|
298
298
|
"type": "option"
|
|
@@ -365,6 +365,14 @@
|
|
|
365
365
|
"allowNo": false,
|
|
366
366
|
"type": "boolean"
|
|
367
367
|
},
|
|
368
|
+
"stack": {
|
|
369
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
370
|
+
"hidden": false,
|
|
371
|
+
"name": "stack",
|
|
372
|
+
"hasDynamicHelp": false,
|
|
373
|
+
"multiple": false,
|
|
374
|
+
"type": "option"
|
|
375
|
+
},
|
|
368
376
|
"no-wait": {
|
|
369
377
|
"description": "Do not wait for Stack deployment to complete",
|
|
370
378
|
"name": "no-wait",
|
|
@@ -403,7 +411,7 @@
|
|
|
403
411
|
"description": "Permanently removes the remote Stack and all its provisioned resources. Your local Blueprint files remain untouched, allowing you to redeploy later with 'blueprints init' + 'blueprints deploy'.\n\nThis is a destructive operation. You will be prompted to confirm unless --force is specified.\n\nUse this to clean up test environments or decommission a Stack you no longer need.",
|
|
404
412
|
"examples": [
|
|
405
413
|
"<%= config.bin %> <%= command.id %>",
|
|
406
|
-
"<%= config.bin %> <%= command.id %> --stack-id
|
|
414
|
+
"<%= config.bin %> <%= command.id %> --stack <name-or-id> --project-id <projectId> --force --no-wait"
|
|
407
415
|
],
|
|
408
416
|
"flags": {
|
|
409
417
|
"json": {
|
|
@@ -462,7 +470,7 @@
|
|
|
462
470
|
"project"
|
|
463
471
|
],
|
|
464
472
|
"dependsOn": [
|
|
465
|
-
"stack
|
|
473
|
+
"stack",
|
|
466
474
|
"force"
|
|
467
475
|
],
|
|
468
476
|
"description": "Project associated with the Stack",
|
|
@@ -481,7 +489,7 @@
|
|
|
481
489
|
"org"
|
|
482
490
|
],
|
|
483
491
|
"dependsOn": [
|
|
484
|
-
"stack
|
|
492
|
+
"stack",
|
|
485
493
|
"force"
|
|
486
494
|
],
|
|
487
495
|
"description": "Organization associated with the Stack",
|
|
@@ -494,13 +502,13 @@
|
|
|
494
502
|
"multiple": false,
|
|
495
503
|
"type": "option"
|
|
496
504
|
},
|
|
497
|
-
"stack
|
|
505
|
+
"stack": {
|
|
498
506
|
"aliases": [
|
|
499
|
-
"
|
|
500
|
-
"
|
|
507
|
+
"stack-id",
|
|
508
|
+
"stackId"
|
|
501
509
|
],
|
|
502
|
-
"description": "Stack ID to destroy (defaults to
|
|
503
|
-
"name": "stack
|
|
510
|
+
"description": "Stack name or ID to destroy (defaults to the locally configured Stack)",
|
|
511
|
+
"name": "stack",
|
|
504
512
|
"hasDynamicHelp": false,
|
|
505
513
|
"multiple": false,
|
|
506
514
|
"type": "option"
|
|
@@ -606,7 +614,7 @@
|
|
|
606
614
|
"description": "Displays the current state and metadata of your remote Stack deployment, including deployed resources, status, and configuration.\n\nUse this command to verify a deployment succeeded, check what resources are live, or confirm which Stack your local Blueprint is connected to.\n\nRun 'blueprints stacks' to see all available Stacks in your project or organization.",
|
|
607
615
|
"examples": [
|
|
608
616
|
"<%= config.bin %> <%= command.id %>",
|
|
609
|
-
"<%= config.bin %> <%= command.id %> --
|
|
617
|
+
"<%= config.bin %> <%= command.id %> --stack <name-or-id>"
|
|
610
618
|
],
|
|
611
619
|
"flags": {
|
|
612
620
|
"json": {
|
|
@@ -650,9 +658,12 @@
|
|
|
650
658
|
"allowNo": false,
|
|
651
659
|
"type": "boolean"
|
|
652
660
|
},
|
|
653
|
-
"
|
|
654
|
-
"
|
|
655
|
-
|
|
661
|
+
"stack": {
|
|
662
|
+
"aliases": [
|
|
663
|
+
"id"
|
|
664
|
+
],
|
|
665
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
666
|
+
"name": "stack",
|
|
656
667
|
"hasDynamicHelp": false,
|
|
657
668
|
"multiple": false,
|
|
658
669
|
"type": "option"
|
|
@@ -796,7 +807,6 @@
|
|
|
796
807
|
},
|
|
797
808
|
"stack-id": {
|
|
798
809
|
"aliases": [
|
|
799
|
-
"stack",
|
|
800
810
|
"stackId"
|
|
801
811
|
],
|
|
802
812
|
"dependsOn": [
|
|
@@ -892,6 +902,14 @@
|
|
|
892
902
|
"allowNo": false,
|
|
893
903
|
"type": "boolean"
|
|
894
904
|
},
|
|
905
|
+
"stack": {
|
|
906
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
907
|
+
"hidden": false,
|
|
908
|
+
"name": "stack",
|
|
909
|
+
"hasDynamicHelp": false,
|
|
910
|
+
"multiple": false,
|
|
911
|
+
"type": "option"
|
|
912
|
+
},
|
|
895
913
|
"watch": {
|
|
896
914
|
"aliases": [
|
|
897
915
|
"follow"
|
|
@@ -968,6 +986,14 @@
|
|
|
968
986
|
"name": "verbose",
|
|
969
987
|
"allowNo": false,
|
|
970
988
|
"type": "boolean"
|
|
989
|
+
},
|
|
990
|
+
"stack": {
|
|
991
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
992
|
+
"hidden": false,
|
|
993
|
+
"name": "stack",
|
|
994
|
+
"hasDynamicHelp": false,
|
|
995
|
+
"multiple": false,
|
|
996
|
+
"type": "option"
|
|
971
997
|
}
|
|
972
998
|
},
|
|
973
999
|
"hasDynamicHelp": false,
|
|
@@ -1412,6 +1438,14 @@
|
|
|
1412
1438
|
"allowNo": false,
|
|
1413
1439
|
"type": "boolean"
|
|
1414
1440
|
},
|
|
1441
|
+
"stack": {
|
|
1442
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1443
|
+
"hidden": false,
|
|
1444
|
+
"name": "stack",
|
|
1445
|
+
"hasDynamicHelp": false,
|
|
1446
|
+
"multiple": false,
|
|
1447
|
+
"type": "option"
|
|
1448
|
+
},
|
|
1415
1449
|
"limit": {
|
|
1416
1450
|
"char": "l",
|
|
1417
1451
|
"description": "Total number of log entries to retrieve",
|
|
@@ -1852,6 +1886,14 @@
|
|
|
1852
1886
|
"name": "verbose",
|
|
1853
1887
|
"allowNo": false,
|
|
1854
1888
|
"type": "boolean"
|
|
1889
|
+
},
|
|
1890
|
+
"stack": {
|
|
1891
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1892
|
+
"hidden": true,
|
|
1893
|
+
"name": "stack",
|
|
1894
|
+
"hasDynamicHelp": false,
|
|
1895
|
+
"multiple": false,
|
|
1896
|
+
"type": "option"
|
|
1855
1897
|
}
|
|
1856
1898
|
},
|
|
1857
1899
|
"hasDynamicHelp": false,
|
|
@@ -1926,6 +1968,14 @@
|
|
|
1926
1968
|
"name": "verbose",
|
|
1927
1969
|
"allowNo": false,
|
|
1928
1970
|
"type": "boolean"
|
|
1971
|
+
},
|
|
1972
|
+
"stack": {
|
|
1973
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1974
|
+
"hidden": true,
|
|
1975
|
+
"name": "stack",
|
|
1976
|
+
"hasDynamicHelp": false,
|
|
1977
|
+
"multiple": false,
|
|
1978
|
+
"type": "option"
|
|
1929
1979
|
}
|
|
1930
1980
|
},
|
|
1931
1981
|
"hasDynamicHelp": false,
|
|
@@ -2005,6 +2055,14 @@
|
|
|
2005
2055
|
"name": "verbose",
|
|
2006
2056
|
"allowNo": false,
|
|
2007
2057
|
"type": "boolean"
|
|
2058
|
+
},
|
|
2059
|
+
"stack": {
|
|
2060
|
+
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
2061
|
+
"hidden": true,
|
|
2062
|
+
"name": "stack",
|
|
2063
|
+
"hasDynamicHelp": false,
|
|
2064
|
+
"multiple": false,
|
|
2065
|
+
"type": "option"
|
|
2008
2066
|
}
|
|
2009
2067
|
},
|
|
2010
2068
|
"hasDynamicHelp": false,
|
|
@@ -2026,5 +2084,5 @@
|
|
|
2026
2084
|
]
|
|
2027
2085
|
}
|
|
2028
2086
|
},
|
|
2029
|
-
"version": "
|
|
2087
|
+
"version": "14.0.0"
|
|
2030
2088
|
}
|