@sanity/runtime-cli 15.1.0 → 15.1.2
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 +32 -24
- package/dist/actions/blueprints/config.d.ts +2 -2
- package/dist/actions/blueprints/config.js +1 -1
- package/dist/baseCommands.d.ts +5 -0
- package/dist/baseCommands.js +17 -0
- package/dist/commands/blueprints/destroy.js +1 -1
- package/dist/commands/blueprints/doctor.js +2 -0
- package/dist/commands/blueprints/init.js +6 -2
- package/dist/cores/blueprints/destroy.js +16 -0
- package/dist/cores/blueprints/doctor.js +42 -2
- package/dist/cores/index.d.ts +5 -0
- package/dist/utils/blueprints/warnings.d.ts +19 -0
- package/dist/utils/blueprints/warnings.js +36 -0
- package/dist/utils/display/presenters.d.ts +1 -0
- package/dist/utils/display/presenters.js +3 -0
- package/oclif.manifest.json +8 -4
- 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/15.1.
|
|
23
|
+
@sanity/runtime-cli/15.1.2 linux-x64 node-v24.15.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -103,7 +103,7 @@ EXAMPLES
|
|
|
103
103
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
106
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/add.ts)_
|
|
107
107
|
|
|
108
108
|
## `sanity-run blueprints config`
|
|
109
109
|
|
|
@@ -140,7 +140,7 @@ EXAMPLES
|
|
|
140
140
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
141
141
|
```
|
|
142
142
|
|
|
143
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
143
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/config.ts)_
|
|
144
144
|
|
|
145
145
|
## `sanity-run blueprints deploy`
|
|
146
146
|
|
|
@@ -191,7 +191,7 @@ EXAMPLES
|
|
|
191
191
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
194
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/deploy.ts)_
|
|
195
195
|
|
|
196
196
|
## `sanity-run blueprints destroy`
|
|
197
197
|
|
|
@@ -213,8 +213,8 @@ FLAGS
|
|
|
213
213
|
DESCRIPTION
|
|
214
214
|
Destroy a remote Stack deployment and its resources
|
|
215
215
|
|
|
216
|
-
Permanently removes the remote Stack and all its provisioned resources. Your
|
|
217
|
-
|
|
216
|
+
Permanently removes the remote Stack and all its provisioned resources. Your Blueprint manifest and resource files
|
|
217
|
+
remain intact; "stackId" is unset in your local config.
|
|
218
218
|
|
|
219
219
|
This is a destructive operation. You will be prompted to confirm unless --force is specified.
|
|
220
220
|
|
|
@@ -226,7 +226,7 @@ EXAMPLES
|
|
|
226
226
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
229
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/destroy.ts)_
|
|
230
230
|
|
|
231
231
|
## `sanity-run blueprints doctor`
|
|
232
232
|
|
|
@@ -257,7 +257,7 @@ EXAMPLES
|
|
|
257
257
|
$ sanity-run blueprints doctor --fix
|
|
258
258
|
```
|
|
259
259
|
|
|
260
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
260
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/doctor.ts)_
|
|
261
261
|
|
|
262
262
|
## `sanity-run blueprints info`
|
|
263
263
|
|
|
@@ -294,7 +294,7 @@ EXAMPLES
|
|
|
294
294
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
295
295
|
```
|
|
296
296
|
|
|
297
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
297
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/info.ts)_
|
|
298
298
|
|
|
299
299
|
## `sanity-run blueprints init [DIR]`
|
|
300
300
|
|
|
@@ -340,12 +340,20 @@ EXAMPLES
|
|
|
340
340
|
|
|
341
341
|
$ sanity-run blueprints init --blueprint-type <json|js|ts>
|
|
342
342
|
|
|
343
|
-
$ sanity-run blueprints init --
|
|
343
|
+
$ sanity-run blueprints init --organization-id <organizationId>
|
|
344
344
|
|
|
345
|
-
$ sanity-run blueprints init --
|
|
345
|
+
$ sanity-run blueprints init --project-id <projectId>
|
|
346
|
+
|
|
347
|
+
$ sanity-run blueprints init --stack-name <newStackName>
|
|
348
|
+
|
|
349
|
+
$ sanity-run blueprints init --stack-id <existingStackId>
|
|
350
|
+
|
|
351
|
+
$ sanity-run blueprints init new-stack --type <json|js|ts> --org <organizationId> --name <newStackName>
|
|
352
|
+
|
|
353
|
+
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
346
354
|
```
|
|
347
355
|
|
|
348
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
356
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/init.ts)_
|
|
349
357
|
|
|
350
358
|
## `sanity-run blueprints logs`
|
|
351
359
|
|
|
@@ -391,7 +399,7 @@ EXAMPLES
|
|
|
391
399
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
392
400
|
```
|
|
393
401
|
|
|
394
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
402
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/logs.ts)_
|
|
395
403
|
|
|
396
404
|
## `sanity-run blueprints mint-deploy-token`
|
|
397
405
|
|
|
@@ -436,7 +444,7 @@ EXAMPLES
|
|
|
436
444
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
437
445
|
```
|
|
438
446
|
|
|
439
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
447
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/mint-deploy-token.ts)_
|
|
440
448
|
|
|
441
449
|
## `sanity-run blueprints plan`
|
|
442
450
|
|
|
@@ -469,7 +477,7 @@ EXAMPLES
|
|
|
469
477
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
470
478
|
```
|
|
471
479
|
|
|
472
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
480
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/plan.ts)_
|
|
473
481
|
|
|
474
482
|
## `sanity-run blueprints promote`
|
|
475
483
|
|
|
@@ -505,7 +513,7 @@ EXAMPLES
|
|
|
505
513
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
506
514
|
```
|
|
507
515
|
|
|
508
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
516
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/promote.ts)_
|
|
509
517
|
|
|
510
518
|
## `sanity-run blueprints stacks`
|
|
511
519
|
|
|
@@ -541,7 +549,7 @@ EXAMPLES
|
|
|
541
549
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
542
550
|
```
|
|
543
551
|
|
|
544
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
552
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/stacks.ts)_
|
|
545
553
|
|
|
546
554
|
## `sanity-run functions add`
|
|
547
555
|
|
|
@@ -593,7 +601,7 @@ EXAMPLES
|
|
|
593
601
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
594
602
|
```
|
|
595
603
|
|
|
596
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
604
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/add.ts)_
|
|
597
605
|
|
|
598
606
|
## `sanity-run functions dev`
|
|
599
607
|
|
|
@@ -628,7 +636,7 @@ EXAMPLES
|
|
|
628
636
|
$ sanity-run functions dev --timeout 60
|
|
629
637
|
```
|
|
630
638
|
|
|
631
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
639
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/dev.ts)_
|
|
632
640
|
|
|
633
641
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
634
642
|
|
|
@@ -658,7 +666,7 @@ EXAMPLES
|
|
|
658
666
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
659
667
|
```
|
|
660
668
|
|
|
661
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
669
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/add.ts)_
|
|
662
670
|
|
|
663
671
|
## `sanity-run functions env list NAME`
|
|
664
672
|
|
|
@@ -685,7 +693,7 @@ EXAMPLES
|
|
|
685
693
|
$ sanity-run functions env list MyFunction
|
|
686
694
|
```
|
|
687
695
|
|
|
688
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
696
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/list.ts)_
|
|
689
697
|
|
|
690
698
|
## `sanity-run functions env remove NAME KEY`
|
|
691
699
|
|
|
@@ -714,7 +722,7 @@ EXAMPLES
|
|
|
714
722
|
$ sanity-run functions env remove MyFunction API_URL
|
|
715
723
|
```
|
|
716
724
|
|
|
717
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
725
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/remove.ts)_
|
|
718
726
|
|
|
719
727
|
## `sanity-run functions logs [NAME]`
|
|
720
728
|
|
|
@@ -754,7 +762,7 @@ EXAMPLES
|
|
|
754
762
|
$ sanity-run functions logs <name> --delete
|
|
755
763
|
```
|
|
756
764
|
|
|
757
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
765
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/logs.ts)_
|
|
758
766
|
|
|
759
767
|
## `sanity-run functions test [NAME]`
|
|
760
768
|
|
|
@@ -811,7 +819,7 @@ EXAMPLES
|
|
|
811
819
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
812
820
|
```
|
|
813
821
|
|
|
814
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.
|
|
822
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/test.ts)_
|
|
815
823
|
|
|
816
824
|
## `sanity-run help [COMMAND]`
|
|
817
825
|
|
|
@@ -32,7 +32,7 @@ export declare function writeConfigFile(blueprintFilePath: string, options: {
|
|
|
32
32
|
export interface ConfigPatch {
|
|
33
33
|
organizationId?: string | null;
|
|
34
34
|
projectId?: string | null;
|
|
35
|
-
stackId?: string;
|
|
35
|
+
stackId?: string | null;
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* Update the config file with the given properties.
|
|
@@ -42,7 +42,7 @@ export interface ConfigPatch {
|
|
|
42
42
|
* @param updateableProperties - the properties to update
|
|
43
43
|
* @param updateableProperties.organizationId - the organization ID (null to remove)
|
|
44
44
|
* @param updateableProperties.projectId - the project ID (null to remove)
|
|
45
|
-
* @param updateableProperties.stackId - the stack ID
|
|
45
|
+
* @param updateableProperties.stackId - the stack ID (null to remove)
|
|
46
46
|
*/
|
|
47
47
|
export declare function patchConfigFile(blueprintFilePath: string, updateableProperties: ConfigPatch): BlueprintsConfig;
|
|
48
48
|
/**
|
|
@@ -59,7 +59,7 @@ export function writeConfigFile(blueprintFilePath, options) {
|
|
|
59
59
|
* @param updateableProperties - the properties to update
|
|
60
60
|
* @param updateableProperties.organizationId - the organization ID (null to remove)
|
|
61
61
|
* @param updateableProperties.projectId - the project ID (null to remove)
|
|
62
|
-
* @param updateableProperties.stackId - the stack ID
|
|
62
|
+
* @param updateableProperties.stackId - the stack ID (null to remove)
|
|
63
63
|
*/
|
|
64
64
|
export function patchConfigFile(blueprintFilePath, updateableProperties) {
|
|
65
65
|
const existingConfig = readConfigFile(blueprintFilePath);
|
package/dist/baseCommands.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { Interfaces } from '@oclif/core';
|
|
|
2
2
|
import { Command } from '@oclif/core';
|
|
3
3
|
import { type ReadBlueprintResult } from './actions/blueprints/blueprint.js';
|
|
4
4
|
import type { CoreResult } from './cores/index.js';
|
|
5
|
+
import type { Warning } from './utils/blueprints/warnings.js';
|
|
5
6
|
import type { AuthParams, ScopeType, Stack } from './utils/types.js';
|
|
6
7
|
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof RuntimeCommand)['baseFlags'] & T['flags']>;
|
|
7
8
|
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
@@ -63,6 +64,10 @@ export declare abstract class RuntimeCommand<T extends typeof Command> extends C
|
|
|
63
64
|
protected coreError(result: CoreResult & {
|
|
64
65
|
success: false;
|
|
65
66
|
}): never;
|
|
67
|
+
/**
|
|
68
|
+
* Renders any actionable items the user can take that don't warrant throwing an error.
|
|
69
|
+
*/
|
|
70
|
+
protected renderWarnings(warnings: Warning[]): void;
|
|
66
71
|
/**
|
|
67
72
|
* If an error doesn't have suggestions, match against known patterns to
|
|
68
73
|
* attach relevant suggestions before oclif renders the error.
|
package/dist/baseCommands.js
CHANGED
|
@@ -6,6 +6,7 @@ import { resolveIds } from './actions/blueprints/resolve.js';
|
|
|
6
6
|
import { getStack, resolveStackIdByNameOrId } from './actions/blueprints/stacks.js';
|
|
7
7
|
import { presentBlueprintParserErrors } from './utils/display/errors.js';
|
|
8
8
|
import { Logger } from './utils/logger.js';
|
|
9
|
+
import { styleText } from './utils/style-text.js';
|
|
9
10
|
import { validTokenOrErrorMessage } from './utils/validated-token.js';
|
|
10
11
|
/**
|
|
11
12
|
* Fallback error-to-hint patterns for RuntimeCommand.catch().
|
|
@@ -137,6 +138,22 @@ export class RuntimeCommand extends Command {
|
|
|
137
138
|
code: result.code,
|
|
138
139
|
});
|
|
139
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Renders any actionable items the user can take that don't warrant throwing an error.
|
|
143
|
+
*/
|
|
144
|
+
renderWarnings(warnings) {
|
|
145
|
+
if (!warnings.length)
|
|
146
|
+
return;
|
|
147
|
+
this.log('');
|
|
148
|
+
this.log(styleText(['bold', 'yellow'], 'Suggestions'));
|
|
149
|
+
this.log('');
|
|
150
|
+
for (const entry of warnings) {
|
|
151
|
+
entry.suggestions.forEach((sug) => {
|
|
152
|
+
this.log(` ${styleText('dim', sug)}`);
|
|
153
|
+
});
|
|
154
|
+
this.log('');
|
|
155
|
+
}
|
|
156
|
+
}
|
|
140
157
|
/**
|
|
141
158
|
* If an error doesn't have suggestions, match against known patterns to
|
|
142
159
|
* attach relevant suggestions before oclif renders the error.
|
|
@@ -5,7 +5,7 @@ import { Logger } from '../../utils/logger.js';
|
|
|
5
5
|
export default class DestroyCommand extends ResolvedCommand {
|
|
6
6
|
static needs = ['token', 'blueprint'];
|
|
7
7
|
static summary = 'Destroy a remote Stack deployment and its resources';
|
|
8
|
-
static description = `Permanently removes the remote Stack and all its provisioned resources. Your
|
|
8
|
+
static description = `Permanently removes the remote Stack and all its provisioned resources. Your Blueprint manifest and resource files remain intact; "stackId" is unset in your local config.
|
|
9
9
|
|
|
10
10
|
This is a destructive operation. You will be prompted to confirm unless --force is specified.
|
|
11
11
|
|
|
@@ -16,8 +16,12 @@ After initialization, use 'blueprints plan' to preview changes, then 'blueprints
|
|
|
16
16
|
'<%= config.bin %> <%= command.id %>',
|
|
17
17
|
'<%= config.bin %> <%= command.id %> [directory]',
|
|
18
18
|
'<%= config.bin %> <%= command.id %> --blueprint-type <json|js|ts>',
|
|
19
|
-
'<%= config.bin %> <%= command.id %> --
|
|
20
|
-
'<%= config.bin %> <%= command.id %> --
|
|
19
|
+
'<%= config.bin %> <%= command.id %> --organization-id <organizationId>',
|
|
20
|
+
'<%= config.bin %> <%= command.id %> --project-id <projectId>',
|
|
21
|
+
'<%= config.bin %> <%= command.id %> --stack-name <newStackName>',
|
|
22
|
+
'<%= config.bin %> <%= command.id %> --stack-id <existingStackId>',
|
|
23
|
+
'<%= config.bin %> <%= command.id %> new-stack --type <json|js|ts> --org <organizationId> --name <newStackName>',
|
|
24
|
+
'<%= config.bin %> <%= command.id %> old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>',
|
|
21
25
|
];
|
|
22
26
|
static args = {
|
|
23
27
|
dir: Args.string({
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { setTimeout as sleep } from 'node:timers/promises';
|
|
2
2
|
import { confirm } from '@inquirer/prompts';
|
|
3
|
+
import { patchConfigFile } from '../../actions/blueprints/config.js';
|
|
3
4
|
import { setupLogPolling } from '../../actions/blueprints/logs-polling.js';
|
|
4
5
|
import { destroyStack, getStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
5
6
|
import { createHintCollector } from '../../utils/blueprints/hints.js';
|
|
@@ -32,6 +33,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
32
33
|
});
|
|
33
34
|
if (!ok)
|
|
34
35
|
return { success: false, error: error || 'Failed to destroy Stack deployment' };
|
|
36
|
+
clearLocalStackIdFromConfig(blueprint, stack.id, log);
|
|
35
37
|
if (noWait) {
|
|
36
38
|
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
37
39
|
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
@@ -112,6 +114,7 @@ export async function blueprintDestroyCore(options) {
|
|
|
112
114
|
return { success: false, error: error || 'Failed to destroy Stack deployment' };
|
|
113
115
|
}
|
|
114
116
|
destroySpinner.stop().clear();
|
|
117
|
+
clearLocalStackIdFromConfig(blueprint, stack.id, log);
|
|
115
118
|
if (noWait) {
|
|
116
119
|
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
117
120
|
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
@@ -130,6 +133,19 @@ export async function blueprintDestroyCore(options) {
|
|
|
130
133
|
return { success: false, error: errorMessage };
|
|
131
134
|
}
|
|
132
135
|
}
|
|
136
|
+
function clearLocalStackIdFromConfig(blueprint, destroyedStackId, log) {
|
|
137
|
+
if (!blueprint.blueprintConfig)
|
|
138
|
+
return;
|
|
139
|
+
if (blueprint.blueprintConfig.stackId !== destroyedStackId)
|
|
140
|
+
return;
|
|
141
|
+
try {
|
|
142
|
+
patchConfigFile(blueprint.fileInfo.blueprintFilePath, { stackId: null });
|
|
143
|
+
log(styleText('dim', 'Removed stackId from .sanity/blueprint.config.json'));
|
|
144
|
+
}
|
|
145
|
+
catch {
|
|
146
|
+
log(styleText('yellow', 'Could not update .sanity/blueprint.config.json. Remove stackId manually.'));
|
|
147
|
+
}
|
|
148
|
+
}
|
|
133
149
|
async function waitForDestruction(options) {
|
|
134
150
|
const { stackId, stackName, operationId, auth, log, bin } = options;
|
|
135
151
|
log(styleText('dim', 'Stack destruction progress:'));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { dirname } from 'node:path';
|
|
2
3
|
import { arch, cwd, env, version as nodeVersion, platform } from 'node:process';
|
|
3
4
|
import * as resolve from 'empathic/resolve';
|
|
4
5
|
import ora from 'ora';
|
|
@@ -7,8 +8,9 @@ import { readConfigFile } from '../../actions/blueprints/config.js';
|
|
|
7
8
|
import { resolveIds } from '../../actions/blueprints/resolve.js';
|
|
8
9
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
9
10
|
import config, { RUNTIME_CLI_VERSION } from '../../config.js';
|
|
11
|
+
import { getWarnings } from '../../utils/blueprints/warnings.js';
|
|
10
12
|
import { formatDateTime } from '../../utils/display/dates.js';
|
|
11
|
-
import { check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
|
|
13
|
+
import { advise, check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
|
|
12
14
|
import { styleText } from '../../utils/style-text.js';
|
|
13
15
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
14
16
|
import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
|
|
@@ -20,6 +22,9 @@ const diagLookup = {
|
|
|
20
22
|
stackReady: 'Stack ready',
|
|
21
23
|
userHasAccess: 'User has access',
|
|
22
24
|
};
|
|
25
|
+
const warnLookup = {
|
|
26
|
+
projectLayout: 'Project layout',
|
|
27
|
+
};
|
|
23
28
|
function sourceLabel(source) {
|
|
24
29
|
switch (source) {
|
|
25
30
|
case 'env':
|
|
@@ -42,6 +47,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
42
47
|
for (const key in diagLookup) {
|
|
43
48
|
diagnostics[key] = { status: null };
|
|
44
49
|
}
|
|
50
|
+
const warningDiagnostics = {};
|
|
45
51
|
const envRows = [['Directory', p ? filePathRelativeToCwd(path) : path]];
|
|
46
52
|
if (bin && bin !== 'sanity')
|
|
47
53
|
envRows.push(['CLI', bin]);
|
|
@@ -234,6 +240,21 @@ export async function blueprintDoctorCore(options) {
|
|
|
234
240
|
diagnostics.userHasAccess = { status: null, detail };
|
|
235
241
|
}
|
|
236
242
|
}
|
|
243
|
+
for (const key in warnLookup) {
|
|
244
|
+
warningDiagnostics[key] = { status: null };
|
|
245
|
+
}
|
|
246
|
+
// LAYOUT ISSUES; IE Functions in Studio
|
|
247
|
+
let layoutWarnings = [];
|
|
248
|
+
if (localBlueprint) {
|
|
249
|
+
const blueprintDir = dirname(localBlueprint.fileInfo.blueprintFilePath || '.');
|
|
250
|
+
layoutWarnings = getWarnings({ dir: blueprintDir });
|
|
251
|
+
if (layoutWarnings.length) {
|
|
252
|
+
warningDiagnostics.projectLayout = {
|
|
253
|
+
status: true,
|
|
254
|
+
detail: 'Blueprint config in the Studio dir',
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
}
|
|
237
258
|
// --- RENDER REPORT ---
|
|
238
259
|
spinner.stop();
|
|
239
260
|
// Environment (verbose)
|
|
@@ -270,6 +291,20 @@ export async function blueprintDoctorCore(options) {
|
|
|
270
291
|
break;
|
|
271
292
|
}
|
|
272
293
|
}
|
|
294
|
+
let hasWarnings = false;
|
|
295
|
+
if (Object.values(warningDiagnostics).some((entry) => entry.status === true)) {
|
|
296
|
+
hasWarnings = true;
|
|
297
|
+
const maxLabel = Math.max(...Object.values(warnLookup).map((l) => l.length));
|
|
298
|
+
log(styleText('bold', 'Warnings'));
|
|
299
|
+
for (const [key, entry] of Object.entries(warningDiagnostics)) {
|
|
300
|
+
if (entry.status) {
|
|
301
|
+
const label = warnLookup[key].padEnd(maxLabel);
|
|
302
|
+
const detail = entry.detail ? ` ${styleText('dim', entry.detail)}` : '';
|
|
303
|
+
log(` ${advise(label)}${detail}`);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
log('');
|
|
307
|
+
}
|
|
273
308
|
// Result
|
|
274
309
|
const flatDiagnostics = {};
|
|
275
310
|
for (const [key, entry] of Object.entries(diagnostics)) {
|
|
@@ -285,6 +320,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
285
320
|
success: true,
|
|
286
321
|
json: { diagnostics: flatDiagnostics },
|
|
287
322
|
data: { diagnostics: flatDiagnostics },
|
|
323
|
+
warnings: hasWarnings ? layoutWarnings : undefined,
|
|
288
324
|
};
|
|
289
325
|
}
|
|
290
326
|
if (fix) {
|
|
@@ -319,7 +355,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
319
355
|
data: { diagnostics: flatDiagnostics },
|
|
320
356
|
};
|
|
321
357
|
}
|
|
322
|
-
|
|
358
|
+
const fixResult = await blueprintConfigCore({
|
|
323
359
|
bin,
|
|
324
360
|
log,
|
|
325
361
|
token: tokenOrError.value,
|
|
@@ -327,6 +363,10 @@ export async function blueprintDoctorCore(options) {
|
|
|
327
363
|
validateResources,
|
|
328
364
|
flags: { edit: true, verbose: v },
|
|
329
365
|
});
|
|
366
|
+
if (fixResult.success) {
|
|
367
|
+
return { ...fixResult, warnings: hasWarnings ? layoutWarnings : undefined };
|
|
368
|
+
}
|
|
369
|
+
return fixResult;
|
|
330
370
|
}
|
|
331
371
|
return {
|
|
332
372
|
success: false,
|
package/dist/cores/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ReadBlueprintResult } from '../actions/blueprints/blueprint.js';
|
|
2
|
+
import type { Warning } from '../utils/blueprints/warnings.js';
|
|
2
3
|
import type { Logger } from '../utils/logger.js';
|
|
3
4
|
import type { AuthParams, Result, ScopeType, Stack } from '../utils/types.js';
|
|
4
5
|
export interface CoreConfig {
|
|
@@ -52,6 +53,10 @@ export type CoreResult = {
|
|
|
52
53
|
* Commands should return this value from `run()` for oclif to serialize.
|
|
53
54
|
*/
|
|
54
55
|
json?: Record<string, unknown>;
|
|
56
|
+
/**
|
|
57
|
+
* Actionable items displayed to the user that we don't error out on.
|
|
58
|
+
*/
|
|
59
|
+
warnings?: Warning[];
|
|
55
60
|
});
|
|
56
61
|
type InitBlueprintConfigParams = CoreConfig & ({
|
|
57
62
|
validateToken: true;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type Warning = {
|
|
2
|
+
label: string;
|
|
3
|
+
suggestions: string[];
|
|
4
|
+
};
|
|
5
|
+
export type WarningContext = {
|
|
6
|
+
dir: string;
|
|
7
|
+
};
|
|
8
|
+
export type WarningEntryCheck = {
|
|
9
|
+
label: string;
|
|
10
|
+
suggestions: string[];
|
|
11
|
+
check: (ctx: WarningContext) => boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Checks if the given directory contains files Sanity Studio specific files.
|
|
15
|
+
* Directory is either the cwd where `init` is run or during the `doctor` command
|
|
16
|
+
*/
|
|
17
|
+
export declare const isStudioDir: (filePath: string) => boolean;
|
|
18
|
+
export declare const warningCheck: WarningEntryCheck[];
|
|
19
|
+
export declare const getWarnings: (ctx: WarningContext) => Warning[];
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { readdirSync } from 'node:fs';
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* Checks if the given directory contains files Sanity Studio specific files.
|
|
5
|
+
* Directory is either the cwd where `init` is run or during the `doctor` command
|
|
6
|
+
*/
|
|
7
|
+
export const isStudioDir = (filePath) => {
|
|
8
|
+
try {
|
|
9
|
+
const dir = resolve(filePath);
|
|
10
|
+
return readdirSync(dir, { withFileTypes: true }).some((entry) => {
|
|
11
|
+
if (entry.isFile()) {
|
|
12
|
+
return entry.name.startsWith('sanity.config') || entry.name.startsWith('sanity.cli');
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
catch (_err) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
export const warningCheck = [
|
|
22
|
+
{
|
|
23
|
+
label: 'Project layout',
|
|
24
|
+
suggestions: [
|
|
25
|
+
'A Blueprints file is co-located with a Sanity Studio. Please see the docs for better layout options',
|
|
26
|
+
// @todo: this will need to updated once the layout is published.
|
|
27
|
+
'https://www.sanity.io/docs/blueprints/blueprints-introduction#aaeea93bdd42',
|
|
28
|
+
],
|
|
29
|
+
check: ({ dir }) => isStudioDir(dir),
|
|
30
|
+
},
|
|
31
|
+
];
|
|
32
|
+
export const getWarnings = (ctx) => {
|
|
33
|
+
return warningCheck
|
|
34
|
+
.filter(({ check }) => check(ctx))
|
|
35
|
+
.map(({ label, suggestions }) => ({ label, suggestions }));
|
|
36
|
+
};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare function check(str: string): string;
|
|
2
2
|
export declare function info(str: string): string;
|
|
3
3
|
export declare function warn(str: string): string;
|
|
4
|
+
export declare function advise(str: string): string;
|
|
4
5
|
export declare function unsure(str: string): string;
|
|
5
6
|
export declare function severe(str: string): string;
|
|
6
7
|
export declare function niceId(id: string | undefined): string;
|
|
@@ -9,6 +9,9 @@ export function info(str) {
|
|
|
9
9
|
export function warn(str) {
|
|
10
10
|
return `${styleText(['bold', 'yellow'], '▶︎')} ${str}`;
|
|
11
11
|
}
|
|
12
|
+
export function advise(str) {
|
|
13
|
+
return `${styleText(['bold', 'yellow'], '!')} ${str}`;
|
|
14
|
+
}
|
|
12
15
|
export function unsure(str) {
|
|
13
16
|
return `${styleText(['bold', 'cyan'], '?')} ${str}`;
|
|
14
17
|
}
|
package/oclif.manifest.json
CHANGED
|
@@ -523,7 +523,7 @@
|
|
|
523
523
|
"blueprints:destroy": {
|
|
524
524
|
"aliases": [],
|
|
525
525
|
"args": {},
|
|
526
|
-
"description": "Permanently removes the remote Stack and all its provisioned resources. Your
|
|
526
|
+
"description": "Permanently removes the remote Stack and all its provisioned resources. Your Blueprint manifest and resource files remain intact; \"stackId\" is unset in your local config.\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.",
|
|
527
527
|
"examples": [
|
|
528
528
|
"<%= config.bin %> <%= command.id %>",
|
|
529
529
|
"<%= config.bin %> <%= command.id %> --stack <name-or-id> --project-id <projectId> --force --no-wait"
|
|
@@ -849,8 +849,12 @@
|
|
|
849
849
|
"<%= config.bin %> <%= command.id %>",
|
|
850
850
|
"<%= config.bin %> <%= command.id %> [directory]",
|
|
851
851
|
"<%= config.bin %> <%= command.id %> --blueprint-type <json|js|ts>",
|
|
852
|
-
"<%= config.bin %> <%= command.id %> --
|
|
853
|
-
"<%= config.bin %> <%= command.id %> --
|
|
852
|
+
"<%= config.bin %> <%= command.id %> --organization-id <organizationId>",
|
|
853
|
+
"<%= config.bin %> <%= command.id %> --project-id <projectId>",
|
|
854
|
+
"<%= config.bin %> <%= command.id %> --stack-name <newStackName>",
|
|
855
|
+
"<%= config.bin %> <%= command.id %> --stack-id <existingStackId>",
|
|
856
|
+
"<%= config.bin %> <%= command.id %> new-stack --type <json|js|ts> --org <organizationId> --name <newStackName>",
|
|
857
|
+
"<%= config.bin %> <%= command.id %> old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>"
|
|
854
858
|
],
|
|
855
859
|
"flags": {
|
|
856
860
|
"json": {
|
|
@@ -2994,5 +2998,5 @@
|
|
|
2994
2998
|
]
|
|
2995
2999
|
}
|
|
2996
3000
|
},
|
|
2997
|
-
"version": "15.1.
|
|
3001
|
+
"version": "15.1.2"
|
|
2998
3002
|
}
|