@sanity/runtime-cli 17.13.1 → 17.14.0-next.g792820f
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 +19 -19
- package/dist/actions/blueprints/pre-deploy.d.ts +1 -0
- package/dist/actions/blueprints/pre-deploy.js +21 -4
- package/dist/actions/blueprints/stacks.d.ts +6 -5
- package/dist/actions/blueprints/stacks.js +25 -12
- package/dist/baseCommands.js +7 -2
- package/dist/constants.d.ts +2 -0
- package/dist/constants.js +2 -0
- package/dist/cores/blueprints/deploy.js +10 -5
- package/dist/cores/blueprints/destroy.js +28 -17
- package/dist/cores/blueprints/plan.js +6 -2
- package/dist/cores/index.d.ts +2 -0
- package/dist/utils/bundles/prepare-asset.d.ts +38 -0
- package/dist/utils/bundles/prepare-asset.js +271 -0
- package/dist/utils/bundles/stamp-config-version.d.ts +5 -0
- package/dist/utils/bundles/stamp-config-version.js +45 -0
- package/dist/utils/display/blueprints-formatting.d.ts +5 -1
- package/dist/utils/display/blueprints-formatting.js +15 -2
- package/dist/utils/{blueprints → functions}/extract-durable-config.d.ts +2 -2
- package/dist/utils/functions/extract-durable-config.js +58 -0
- package/dist/utils/request-id.d.ts +4 -0
- package/dist/utils/request-id.js +19 -0
- package/dist/utils/types.d.ts +15 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
- package/dist/utils/blueprints/extract-durable-config.js +0 -60
- package/dist/utils/studios/prepare-asset.d.ts +0 -6
- package/dist/utils/studios/prepare-asset.js +0 -166
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ EXAMPLES
|
|
|
90
90
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
93
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/add.ts)_
|
|
94
94
|
|
|
95
95
|
## `sanity-run blueprints config`
|
|
96
96
|
|
|
@@ -127,7 +127,7 @@ EXAMPLES
|
|
|
127
127
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
130
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/config.ts)_
|
|
131
131
|
|
|
132
132
|
## `sanity-run blueprints deploy`
|
|
133
133
|
|
|
@@ -183,7 +183,7 @@ EXAMPLES
|
|
|
183
183
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
186
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/deploy.ts)_
|
|
187
187
|
|
|
188
188
|
## `sanity-run blueprints destroy`
|
|
189
189
|
|
|
@@ -221,7 +221,7 @@ EXAMPLES
|
|
|
221
221
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
224
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/destroy.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints doctor`
|
|
227
227
|
|
|
@@ -253,7 +253,7 @@ EXAMPLES
|
|
|
253
253
|
$ sanity-run blueprints doctor --fix
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
256
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/doctor.ts)_
|
|
257
257
|
|
|
258
258
|
## `sanity-run blueprints info`
|
|
259
259
|
|
|
@@ -291,7 +291,7 @@ EXAMPLES
|
|
|
291
291
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
294
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/info.ts)_
|
|
295
295
|
|
|
296
296
|
## `sanity-run blueprints init [DIR]`
|
|
297
297
|
|
|
@@ -355,7 +355,7 @@ EXAMPLES
|
|
|
355
355
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
358
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/init.ts)_
|
|
359
359
|
|
|
360
360
|
## `sanity-run blueprints logs`
|
|
361
361
|
|
|
@@ -401,7 +401,7 @@ EXAMPLES
|
|
|
401
401
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
404
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/logs.ts)_
|
|
405
405
|
|
|
406
406
|
## `sanity-run blueprints mint-deploy-token`
|
|
407
407
|
|
|
@@ -446,7 +446,7 @@ EXAMPLES
|
|
|
446
446
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
449
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/mint-deploy-token.ts)_
|
|
450
450
|
|
|
451
451
|
## `sanity-run blueprints plan`
|
|
452
452
|
|
|
@@ -479,7 +479,7 @@ EXAMPLES
|
|
|
479
479
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
482
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/plan.ts)_
|
|
483
483
|
|
|
484
484
|
## `sanity-run blueprints promote`
|
|
485
485
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
518
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/promote.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run blueprints stacks`
|
|
521
521
|
|
|
@@ -556,7 +556,7 @@ EXAMPLES
|
|
|
556
556
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
557
557
|
```
|
|
558
558
|
|
|
559
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
559
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/blueprints/stacks.ts)_
|
|
560
560
|
|
|
561
561
|
## `sanity-run functions add`
|
|
562
562
|
|
|
@@ -608,7 +608,7 @@ EXAMPLES
|
|
|
608
608
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
609
609
|
```
|
|
610
610
|
|
|
611
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
611
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/add.ts)_
|
|
612
612
|
|
|
613
613
|
## `sanity-run functions dev`
|
|
614
614
|
|
|
@@ -643,7 +643,7 @@ EXAMPLES
|
|
|
643
643
|
$ sanity-run functions dev --timeout 60
|
|
644
644
|
```
|
|
645
645
|
|
|
646
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
646
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/dev.ts)_
|
|
647
647
|
|
|
648
648
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
649
649
|
|
|
@@ -676,7 +676,7 @@ EXAMPLES
|
|
|
676
676
|
$ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
|
|
677
677
|
```
|
|
678
678
|
|
|
679
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
679
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/env/add.ts)_
|
|
680
680
|
|
|
681
681
|
## `sanity-run functions env list NAME`
|
|
682
682
|
|
|
@@ -706,7 +706,7 @@ EXAMPLES
|
|
|
706
706
|
$ sanity-run functions env list --stack <name-or-id> MyFunction
|
|
707
707
|
```
|
|
708
708
|
|
|
709
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
709
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/env/list.ts)_
|
|
710
710
|
|
|
711
711
|
## `sanity-run functions env remove NAME KEY`
|
|
712
712
|
|
|
@@ -738,7 +738,7 @@ EXAMPLES
|
|
|
738
738
|
$ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
|
|
739
739
|
```
|
|
740
740
|
|
|
741
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
741
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/env/remove.ts)_
|
|
742
742
|
|
|
743
743
|
## `sanity-run functions logs [NAME]`
|
|
744
744
|
|
|
@@ -778,7 +778,7 @@ EXAMPLES
|
|
|
778
778
|
$ sanity-run functions logs <name> --delete
|
|
779
779
|
```
|
|
780
780
|
|
|
781
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
781
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/logs.ts)_
|
|
782
782
|
|
|
783
783
|
## `sanity-run functions test [NAME]`
|
|
784
784
|
|
|
@@ -836,7 +836,7 @@ EXAMPLES
|
|
|
836
836
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
837
837
|
```
|
|
838
838
|
|
|
839
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.
|
|
839
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.14.0-next.g792820f/src/commands/functions/test.ts)_
|
|
840
840
|
|
|
841
841
|
## `sanity-run help [COMMAND]`
|
|
842
842
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { SANITY_FUNCTION_PREFIX } from '../../constants.js';
|
|
2
2
|
import { resolveDeployedResources } from '../../utils/blueprints/resolve-deployed-resources.js';
|
|
3
|
+
import { BUNDLE_SPECS, prepareBundleAsset, } from '../../utils/bundles/prepare-asset.js';
|
|
4
|
+
import { stampConfigVersion } from '../../utils/bundles/stamp-config-version.js';
|
|
3
5
|
import { CODE_OPERATION_UNCONFIRMED, EXIT_OPERATION_UNCONFIRMED } from '../../utils/exit-codes.js';
|
|
6
|
+
import { extractDurableConfig } from '../../utils/functions/extract-durable-config.js';
|
|
4
7
|
import { prepareAsset as prepareFunctionAsset } from '../../utils/functions/prepare-asset.js';
|
|
5
8
|
import { runCommand } from '../../utils/package-manager.js';
|
|
6
|
-
import { prepareStudioAsset } from '../../utils/studios/prepare-asset.js';
|
|
7
9
|
import { setupLogPolling } from './logs-polling.js';
|
|
8
10
|
import { getOperationStateInfo } from './operations-state.js';
|
|
9
11
|
import { processAssets } from './process-assets.js';
|
|
@@ -13,13 +15,16 @@ import { updateStack } from './stacks.js';
|
|
|
13
15
|
*/
|
|
14
16
|
const preDeployConfigs = [
|
|
15
17
|
{
|
|
16
|
-
resourceType:
|
|
18
|
+
resourceType: (type) => type in BUNDLE_SPECS,
|
|
17
19
|
async prepareAsset(options) {
|
|
18
|
-
return
|
|
20
|
+
return prepareBundleAsset({
|
|
19
21
|
resource: options.resource,
|
|
20
22
|
blueprintFileDir: options.blueprintFileDir,
|
|
21
23
|
});
|
|
22
24
|
},
|
|
25
|
+
async prepareResource(options) {
|
|
26
|
+
await stampConfigVersion(options.resource, options.blueprintFileDir);
|
|
27
|
+
},
|
|
23
28
|
},
|
|
24
29
|
{
|
|
25
30
|
resourceType: (type) => type.startsWith(SANITY_FUNCTION_PREFIX),
|
|
@@ -30,6 +35,9 @@ const preDeployConfigs = [
|
|
|
30
35
|
installer: options.installer,
|
|
31
36
|
});
|
|
32
37
|
},
|
|
38
|
+
async prepareResource(options) {
|
|
39
|
+
await extractDurableConfig(options.resource, options.blueprintFileDir);
|
|
40
|
+
},
|
|
33
41
|
},
|
|
34
42
|
];
|
|
35
43
|
function hasPreDeployResources(resources) {
|
|
@@ -47,6 +55,12 @@ export async function preDeploy(options) {
|
|
|
47
55
|
const { resources, stackId, auth, blueprintFileDir, installer, fetchFn } = options;
|
|
48
56
|
const resourceMetadata = [];
|
|
49
57
|
if (hasPreDeployResources(resources)) {
|
|
58
|
+
for (const r of resources) {
|
|
59
|
+
const config = getPredeployConfig(r);
|
|
60
|
+
if (typeof config !== 'undefined' && typeof config.prepareResource === 'function') {
|
|
61
|
+
await config.prepareResource({ resource: r, blueprintFileDir });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
50
64
|
const preDeployStackResult = await preDeployStack(options);
|
|
51
65
|
if (!preDeployStackResult.success) {
|
|
52
66
|
return preDeployStackResult;
|
|
@@ -114,12 +128,13 @@ async function preDeployStack(options) {
|
|
|
114
128
|
preDeploy: true,
|
|
115
129
|
document: { resources },
|
|
116
130
|
};
|
|
117
|
-
const { ok: deployOk, stack, error: deployError, } = await updateStack({ stackId, stackMutation, auth, fetchFn });
|
|
131
|
+
const { ok: deployOk, stack, error: deployError, requestId, } = await updateStack({ stackId, stackMutation, auth, fetchFn });
|
|
118
132
|
if (!deployOk) {
|
|
119
133
|
options.onPreDeployStackFail?.();
|
|
120
134
|
return {
|
|
121
135
|
success: false,
|
|
122
136
|
error: deployError || 'Failed to complete Stack pre-deployment',
|
|
137
|
+
requestId,
|
|
123
138
|
suggestions: [
|
|
124
139
|
`Run \`${runCommand(bin)} blueprints plan\` to preview changes before deploying.`,
|
|
125
140
|
`Run \`${runCommand(bin)} blueprints doctor\` to check your configuration.`,
|
|
@@ -162,6 +177,7 @@ async function preDeployStack(options) {
|
|
|
162
177
|
return {
|
|
163
178
|
success: false,
|
|
164
179
|
error: `Stack pre-deployment was accepted but completion could not be confirmed${outcome.error ? ` (${outcome.error})` : ''}.`,
|
|
180
|
+
requestId,
|
|
165
181
|
code: CODE_OPERATION_UNCONFIRMED,
|
|
166
182
|
exitCode: EXIT_OPERATION_UNCONFIRMED,
|
|
167
183
|
suggestions: [
|
|
@@ -175,6 +191,7 @@ async function preDeployStack(options) {
|
|
|
175
191
|
return {
|
|
176
192
|
success: false,
|
|
177
193
|
error: 'Stack pre-deployment failed',
|
|
194
|
+
requestId,
|
|
178
195
|
suggestions: [
|
|
179
196
|
...outcome.logHints,
|
|
180
197
|
'Review the pre-deployment output above for error details.',
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Blueprint } from '@sanity/blueprints-parser';
|
|
2
2
|
import type { Logger } from '../../utils/logger.js';
|
|
3
|
-
import type { AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
|
|
3
|
+
import type { AuthParams, ScopeType, Stack, StackMutation, StackSummary, UpdatedStack } from '../../utils/types.js';
|
|
4
4
|
export declare const stacksUrl: string;
|
|
5
5
|
type ListStacksResponse = {
|
|
6
6
|
ok: true;
|
|
@@ -46,14 +46,15 @@ export declare function createEmptyStack({ token, scopeType, scopeId, name, logg
|
|
|
46
46
|
type UpdateStackResponse = {
|
|
47
47
|
ok: true;
|
|
48
48
|
error: null;
|
|
49
|
-
stack:
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
};
|
|
49
|
+
stack: UpdatedStack;
|
|
50
|
+
requestId?: string;
|
|
51
|
+
response?: Response;
|
|
53
52
|
} | {
|
|
54
53
|
ok: false;
|
|
55
54
|
error: string;
|
|
56
55
|
stack?: unknown;
|
|
56
|
+
requestId?: string;
|
|
57
|
+
response?: Response;
|
|
57
58
|
};
|
|
58
59
|
export declare function updateStack({ stackId, stackMutation, auth, fetchFn, }: {
|
|
59
60
|
stackId: string;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { blueprintsUrl } from '../../config.js';
|
|
2
2
|
import getHeaders from '../../utils/get-headers.js';
|
|
3
|
+
import { getRequestId } from '../../utils/request-id.js';
|
|
3
4
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
4
5
|
export const stacksUrl = blueprintsUrl('stacks');
|
|
5
6
|
export async function listStacks(auth, logger) {
|
|
@@ -91,6 +92,28 @@ export async function createEmptyStack({ token, scopeType, scopeId, name, logger
|
|
|
91
92
|
}
|
|
92
93
|
return response.stack;
|
|
93
94
|
}
|
|
95
|
+
async function parseOperationResponse(response) {
|
|
96
|
+
let data;
|
|
97
|
+
try {
|
|
98
|
+
data = await response.json();
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
return {
|
|
102
|
+
ok: false,
|
|
103
|
+
error: `HTTP ${response.status} ${response.statusText}`.trim(),
|
|
104
|
+
requestId: getRequestId(response),
|
|
105
|
+
response,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
const body = data;
|
|
109
|
+
return {
|
|
110
|
+
ok: response.ok,
|
|
111
|
+
error: response.ok ? null : String(body?.message ?? `HTTP ${response.status}`),
|
|
112
|
+
stack: data,
|
|
113
|
+
requestId: getRequestId(response, data),
|
|
114
|
+
response,
|
|
115
|
+
};
|
|
116
|
+
}
|
|
94
117
|
export async function updateStack({ stackId, stackMutation, auth, fetchFn, }) {
|
|
95
118
|
try {
|
|
96
119
|
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
@@ -98,12 +121,7 @@ export async function updateStack({ stackId, stackMutation, auth, fetchFn, }) {
|
|
|
98
121
|
headers: getHeaders(auth),
|
|
99
122
|
body: JSON.stringify(stackMutation),
|
|
100
123
|
});
|
|
101
|
-
|
|
102
|
-
return {
|
|
103
|
-
ok: response.ok,
|
|
104
|
-
error: response.ok ? null : data.message,
|
|
105
|
-
stack: data,
|
|
106
|
-
};
|
|
124
|
+
return await parseOperationResponse(response);
|
|
107
125
|
}
|
|
108
126
|
catch (error) {
|
|
109
127
|
return {
|
|
@@ -183,12 +201,7 @@ export async function destroyStack({ stackId, auth, logger, }) {
|
|
|
183
201
|
method: 'DELETE',
|
|
184
202
|
headers: getHeaders(auth),
|
|
185
203
|
});
|
|
186
|
-
|
|
187
|
-
return {
|
|
188
|
-
ok: response.ok,
|
|
189
|
-
error: response.ok ? null : data.message,
|
|
190
|
-
stack: data,
|
|
191
|
-
};
|
|
204
|
+
return await parseOperationResponse(response);
|
|
192
205
|
}
|
|
193
206
|
catch (error) {
|
|
194
207
|
return {
|
package/dist/baseCommands.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// * https://oclif.io/docs/base_class
|
|
2
|
-
import { Command, CommandHelp, Flags as OclifFlags } from '@oclif/core';
|
|
2
|
+
import { Command, CommandHelp, Errors, Flags as OclifFlags } from '@oclif/core';
|
|
3
3
|
import { findBlueprintFile, loadBlueprintFile, parseBlueprintContent, } from './actions/blueprints/blueprint.js';
|
|
4
4
|
import { backfillProjectBasedStackId, readConfigFile, } from './actions/blueprints/config.js';
|
|
5
5
|
import { resolveIds } from './actions/blueprints/resolve.js';
|
|
@@ -8,6 +8,7 @@ import config from './config.js';
|
|
|
8
8
|
import { CI_SETUP_DOCS_URL } from './constants.js';
|
|
9
9
|
import { presentBlueprintParserErrors } from './utils/display/errors.js';
|
|
10
10
|
import { Logger } from './utils/logger.js';
|
|
11
|
+
import { withRequestId } from './utils/request-id.js';
|
|
11
12
|
import { styleText } from './utils/style-text.js';
|
|
12
13
|
import { createTracedFetch } from './utils/traced-fetch.js';
|
|
13
14
|
import { validTokenOrErrorMessage } from './utils/validated-token.js';
|
|
@@ -135,12 +136,16 @@ export class RuntimeCommand extends Command {
|
|
|
135
136
|
* forwarding suggestions, ref, or code to oclif's PrettyPrintableError rendering.
|
|
136
137
|
*/
|
|
137
138
|
coreError(result) {
|
|
138
|
-
|
|
139
|
+
const error = new Errors.CLIError(withRequestId(result.error, result.requestId), {
|
|
139
140
|
suggestions: result.suggestions,
|
|
140
141
|
ref: result.ref,
|
|
141
142
|
code: result.code,
|
|
142
143
|
exit: result.exitCode,
|
|
143
144
|
});
|
|
145
|
+
// oclif's toErrorJson spreads own enumerable properties into the --json error
|
|
146
|
+
if (result.requestId)
|
|
147
|
+
Object.assign(error, { requestId: result.requestId });
|
|
148
|
+
throw error;
|
|
144
149
|
}
|
|
145
150
|
/**
|
|
146
151
|
* Renders any actionable items the user can take that don't warrant throwing an error.
|
package/dist/constants.d.ts
CHANGED
|
@@ -13,6 +13,8 @@ export declare const SANITY_PROJECT_CORS = "sanity.project.cors";
|
|
|
13
13
|
export declare const SANITY_PROJECT_DATASET = "sanity.project.dataset";
|
|
14
14
|
export declare const SANITY_PROJECT_WEBHOOK = "sanity.project.webhook";
|
|
15
15
|
export declare const SANITY_STUDIO = "sanity.studio";
|
|
16
|
+
export declare const SANITY_APPLICATION = "sanity.application";
|
|
17
|
+
export declare const SANITY_INSTALLATION_CONFIG = "sanity.installation.config";
|
|
16
18
|
export declare const EVENT_DOCUMENT_PUBLISH = "document-publish";
|
|
17
19
|
export declare const EVENT_DOCUMENT_CREATE = "document-create";
|
|
18
20
|
export declare const EVENT_DOCUMENT_UPDATE = "document-update";
|
package/dist/constants.js
CHANGED
|
@@ -12,6 +12,8 @@ export const SANITY_PROJECT_CORS = 'sanity.project.cors';
|
|
|
12
12
|
export const SANITY_PROJECT_DATASET = 'sanity.project.dataset';
|
|
13
13
|
export const SANITY_PROJECT_WEBHOOK = 'sanity.project.webhook';
|
|
14
14
|
export const SANITY_STUDIO = 'sanity.studio';
|
|
15
|
+
export const SANITY_APPLICATION = 'sanity.application';
|
|
16
|
+
export const SANITY_INSTALLATION_CONFIG = 'sanity.installation.config';
|
|
15
17
|
export const EVENT_DOCUMENT_PUBLISH = 'document-publish';
|
|
16
18
|
export const EVENT_DOCUMENT_CREATE = 'document-create';
|
|
17
19
|
export const EVENT_DOCUMENT_UPDATE = 'document-update';
|
|
@@ -4,7 +4,6 @@ import { getStack, updateStack } from '../../actions/blueprints/stacks.js';
|
|
|
4
4
|
import { waitForOperation } from '../../actions/blueprints/wait-for-operation.js';
|
|
5
5
|
import { checkUserPermission } from '../../actions/sanity/access.js';
|
|
6
6
|
import { getClientMetadata } from '../../utils/blueprints/deploy-metadata.js';
|
|
7
|
-
import { extractDurableConfig } from '../../utils/blueprints/extract-durable-config.js';
|
|
8
7
|
import { createHintCollector } from '../../utils/blueprints/hints.js';
|
|
9
8
|
import { createWaitFor } from '../../utils/blueprints/wait-for.js';
|
|
10
9
|
import { formatStudioUrls } from '../../utils/display/blueprints-formatting.js';
|
|
@@ -41,7 +40,6 @@ export async function blueprintDeployCore(options) {
|
|
|
41
40
|
};
|
|
42
41
|
}
|
|
43
42
|
const resources = [...blueprint.resources];
|
|
44
|
-
await extractDurableConfig(resources, blueprintFileDir);
|
|
45
43
|
let spinner;
|
|
46
44
|
const preDeployResult = await preDeploy({
|
|
47
45
|
scopeType,
|
|
@@ -80,7 +78,7 @@ export async function blueprintDeployCore(options) {
|
|
|
80
78
|
resources: preDeployResult.resourceMetadata,
|
|
81
79
|
};
|
|
82
80
|
const deploySpinner = logger.ora('Deploying...').start();
|
|
83
|
-
const { ok: deployOk, stack, error: deployError, } = await updateStack({
|
|
81
|
+
const { ok: deployOk, stack, error: deployError, requestId, } = await updateStack({
|
|
84
82
|
stackId,
|
|
85
83
|
stackMutation: {
|
|
86
84
|
scopeType,
|
|
@@ -102,6 +100,7 @@ export async function blueprintDeployCore(options) {
|
|
|
102
100
|
return {
|
|
103
101
|
success: false,
|
|
104
102
|
error: deployError || 'Failed to update Stack deployment',
|
|
103
|
+
requestId,
|
|
105
104
|
suggestions: [
|
|
106
105
|
...hints.getSuggestions(),
|
|
107
106
|
`Run \`${runCommand(bin)} blueprints plan\` to preview changes before deploying.`,
|
|
@@ -110,6 +109,8 @@ export async function blueprintDeployCore(options) {
|
|
|
110
109
|
};
|
|
111
110
|
}
|
|
112
111
|
deploySpinner.stop().clear();
|
|
112
|
+
if (requestId)
|
|
113
|
+
logger.verbose(styleText('dim', `Request ID: ${requestId}`));
|
|
113
114
|
const legacyPermissionsNoticePromise = CHECK_LEGACY_DEPLOY_PERMISSION
|
|
114
115
|
? checkLegacyDeployPermission({
|
|
115
116
|
auth,
|
|
@@ -121,11 +122,13 @@ export async function blueprintDeployCore(options) {
|
|
|
121
122
|
if (noWait) {
|
|
122
123
|
logger(styleText(['bold', 'green'], 'Stack deployment started!'));
|
|
123
124
|
logger(`Use \`${runCommand(bin)} blueprints info\` to check status`);
|
|
125
|
+
if (requestId && !verbose)
|
|
126
|
+
logger(styleText('dim', `Request ID: ${requestId}`));
|
|
124
127
|
const legacyWarning = await legacyPermissionsNoticePromise;
|
|
125
128
|
const warnings = [...(legacyWarning ? [legacyWarning] : []), ...workspaceWarnings];
|
|
126
129
|
return {
|
|
127
130
|
success: true,
|
|
128
|
-
json: { stackId, resources },
|
|
131
|
+
json: { stackId, resources, requestId },
|
|
129
132
|
data: { resources },
|
|
130
133
|
warnings: warnings.length ? warnings : undefined,
|
|
131
134
|
};
|
|
@@ -149,7 +152,7 @@ export async function blueprintDeployCore(options) {
|
|
|
149
152
|
const warnings = [...(legacyWarning ? [legacyWarning] : []), ...workspaceWarnings];
|
|
150
153
|
return {
|
|
151
154
|
success: true,
|
|
152
|
-
json: { stackId, resources },
|
|
155
|
+
json: { stackId, resources, requestId },
|
|
153
156
|
data: { resources },
|
|
154
157
|
warnings: warnings.length ? warnings : undefined,
|
|
155
158
|
};
|
|
@@ -158,6 +161,7 @@ export async function blueprintDeployCore(options) {
|
|
|
158
161
|
return {
|
|
159
162
|
success: false,
|
|
160
163
|
error: `Stack deployment was accepted but completion could not be confirmed${outcome.error ? ` (${outcome.error})` : ''}.`,
|
|
164
|
+
requestId,
|
|
161
165
|
code: CODE_OPERATION_UNCONFIRMED,
|
|
162
166
|
exitCode: EXIT_OPERATION_UNCONFIRMED,
|
|
163
167
|
suggestions: [
|
|
@@ -170,6 +174,7 @@ export async function blueprintDeployCore(options) {
|
|
|
170
174
|
return {
|
|
171
175
|
success: false,
|
|
172
176
|
error: 'Stack deployment failed',
|
|
177
|
+
requestId,
|
|
173
178
|
suggestions: [
|
|
174
179
|
...outcome.logHints,
|
|
175
180
|
'Review the deployment output above for error details.',
|
|
@@ -19,22 +19,21 @@ export async function blueprintDestroyCore(options) {
|
|
|
19
19
|
}
|
|
20
20
|
const auth = { token, scopeType, scopeId };
|
|
21
21
|
const resolvedId = await resolveStackIdByNameOrId(flagStack, auth, log);
|
|
22
|
-
const { ok, error, stack } = await destroyStack({
|
|
22
|
+
const { ok, error, stack, requestId } = await destroyStack({
|
|
23
23
|
stackId: resolvedId,
|
|
24
24
|
auth,
|
|
25
25
|
logger: log,
|
|
26
26
|
});
|
|
27
|
-
if (!ok)
|
|
28
|
-
return { success: false, error: error || 'Failed to destroy Stack deployment' };
|
|
29
|
-
clearLocalStackIdFromConfig(blueprintConfig, stack.id, log);
|
|
30
|
-
if (noWait) {
|
|
31
|
-
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
32
|
-
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
27
|
+
if (!ok) {
|
|
28
|
+
return { success: false, error: error || 'Failed to destroy Stack deployment', requestId };
|
|
33
29
|
}
|
|
34
|
-
|
|
30
|
+
clearLocalStackIdFromConfig(blueprintConfig, stack.id, log);
|
|
31
|
+
return afterDestroyAccepted({
|
|
35
32
|
stackId: stack.id,
|
|
36
33
|
stackName: stack.name,
|
|
37
34
|
operationId: stack.operationId,
|
|
35
|
+
requestId,
|
|
36
|
+
noWait,
|
|
38
37
|
auth,
|
|
39
38
|
log,
|
|
40
39
|
bin,
|
|
@@ -98,25 +97,23 @@ export async function blueprintDestroyCore(options) {
|
|
|
98
97
|
else {
|
|
99
98
|
destroySpinner.start();
|
|
100
99
|
}
|
|
101
|
-
const { ok, error, stack: destroyedStack, } = await destroyStack({
|
|
100
|
+
const { ok, error, stack: destroyedStack, requestId, } = await destroyStack({
|
|
102
101
|
stackId: stack.id,
|
|
103
102
|
auth,
|
|
104
103
|
logger: log,
|
|
105
104
|
});
|
|
106
105
|
if (!ok) {
|
|
107
106
|
destroySpinner.fail('Failed to destroy Stack deployment');
|
|
108
|
-
return { success: false, error: error || 'Failed to destroy Stack deployment' };
|
|
107
|
+
return { success: false, error: error || 'Failed to destroy Stack deployment', requestId };
|
|
109
108
|
}
|
|
110
109
|
destroySpinner.stop().clear();
|
|
111
110
|
clearLocalStackIdFromConfig(blueprintConfig, stack.id, log);
|
|
112
|
-
|
|
113
|
-
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
114
|
-
return { success: true, json: { stackId: stack.id, stackName: stack.name } };
|
|
115
|
-
}
|
|
116
|
-
return waitForDestruction({
|
|
111
|
+
return afterDestroyAccepted({
|
|
117
112
|
stackId: stack.id,
|
|
118
113
|
stackName: stack.name,
|
|
119
114
|
operationId: destroyedStack.operationId,
|
|
115
|
+
requestId,
|
|
116
|
+
noWait,
|
|
120
117
|
auth,
|
|
121
118
|
log,
|
|
122
119
|
bin,
|
|
@@ -141,8 +138,20 @@ function clearLocalStackIdFromConfig(blueprintConfig, destroyedStackId, log) {
|
|
|
141
138
|
log(styleText('yellow', 'Could not update .sanity/blueprint.config.json. Remove stackId manually.'));
|
|
142
139
|
}
|
|
143
140
|
}
|
|
141
|
+
function afterDestroyAccepted(options) {
|
|
142
|
+
const { stackId, stackName, requestId, noWait, log, verbose = false } = options;
|
|
143
|
+
if (requestId)
|
|
144
|
+
log.verbose(styleText('dim', `Request ID: ${requestId}`));
|
|
145
|
+
if (noWait) {
|
|
146
|
+
log(styleText(['bold', 'magenta'], 'Stack destruction started!'));
|
|
147
|
+
if (requestId && !verbose)
|
|
148
|
+
log(styleText('dim', `Request ID: ${requestId}`));
|
|
149
|
+
return { success: true, json: { stackId, stackName, requestId } };
|
|
150
|
+
}
|
|
151
|
+
return waitForDestruction(options);
|
|
152
|
+
}
|
|
144
153
|
async function waitForDestruction(options) {
|
|
145
|
-
const { stackId, stackName, operationId, auth, log, bin, verbose = false } = options;
|
|
154
|
+
const { stackId, stackName, operationId, requestId, auth, log, bin, verbose = false } = options;
|
|
146
155
|
log(styleText('dim', 'Stack destruction progress:'));
|
|
147
156
|
log('');
|
|
148
157
|
const outcome = await waitForOperation({
|
|
@@ -157,12 +166,13 @@ async function waitForDestruction(options) {
|
|
|
157
166
|
});
|
|
158
167
|
if (outcome.type === 'completed') {
|
|
159
168
|
log(styleText(['bold', 'magenta'], 'Stack destruction completed!'));
|
|
160
|
-
return { success: true, json: { stackId, stackName } };
|
|
169
|
+
return { success: true, json: { stackId, stackName, requestId } };
|
|
161
170
|
}
|
|
162
171
|
if (outcome.type === 'unconfirmed') {
|
|
163
172
|
return {
|
|
164
173
|
success: false,
|
|
165
174
|
error: `Stack destruction was accepted but completion could not be confirmed${outcome.error ? ` (${outcome.error})` : ''}.`,
|
|
175
|
+
requestId,
|
|
166
176
|
code: CODE_OPERATION_UNCONFIRMED,
|
|
167
177
|
exitCode: EXIT_OPERATION_UNCONFIRMED,
|
|
168
178
|
suggestions: [
|
|
@@ -175,6 +185,7 @@ async function waitForDestruction(options) {
|
|
|
175
185
|
return {
|
|
176
186
|
success: false,
|
|
177
187
|
error: 'Stack destruction failed',
|
|
188
|
+
requestId,
|
|
178
189
|
suggestions: [
|
|
179
190
|
...outcome.logHints,
|
|
180
191
|
'Review the destruction output above for error details.',
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { dirname } from 'node:path';
|
|
2
2
|
import { planStack, resolveStackIdByNameOrId } from '../../actions/blueprints/stacks.js';
|
|
3
|
-
import { extractDurableConfig } from '../../utils/blueprints/extract-durable-config.js';
|
|
4
3
|
import { createHintCollector } from '../../utils/blueprints/hints.js';
|
|
4
|
+
import { stampConfigVersion } from '../../utils/bundles/stamp-config-version.js';
|
|
5
5
|
import { formatDeploymentPlan, formatResourceTree, hasActionableChanges, } from '../../utils/display/blueprints-formatting.js';
|
|
6
|
+
import { extractDurableConfig } from '../../utils/functions/extract-durable-config.js';
|
|
6
7
|
import { runCommand } from '../../utils/package-manager.js';
|
|
7
8
|
import { styleText } from '../../utils/style-text.js';
|
|
8
9
|
import { getWarnings } from '../../utils/warnings.js';
|
|
@@ -11,7 +12,10 @@ export async function blueprintPlanCore(options) {
|
|
|
11
12
|
const { verbose: _verbose = false } = flags;
|
|
12
13
|
const { scopeType, scopeId, stackId: blueprintStackId, parsedBlueprint, resources, fileInfo, } = blueprint;
|
|
13
14
|
log(`${styleText(['bold', 'blueBright'], 'Local Blueprint')} ${styleText('dim', `(${fileInfo.fileName})`)}`);
|
|
14
|
-
|
|
15
|
+
for (const resource of resources) {
|
|
16
|
+
await extractDurableConfig(resource, dirname(fileInfo.blueprintFilePath));
|
|
17
|
+
await stampConfigVersion(resource, dirname(fileInfo.blueprintFilePath));
|
|
18
|
+
}
|
|
15
19
|
log(formatResourceTree(resources));
|
|
16
20
|
if (!token || !scopeType || !scopeId) {
|
|
17
21
|
log(styleText('dim', 'Unable to retrieve live Stack deployment for comparison'));
|
package/dist/cores/index.d.ts
CHANGED
|
@@ -39,6 +39,8 @@ export type CoreResult = {
|
|
|
39
39
|
ref?: string;
|
|
40
40
|
/** A machine-readable error code. */
|
|
41
41
|
code?: string;
|
|
42
|
+
/** Request ID of the API call that failed, for support. */
|
|
43
|
+
requestId?: string;
|
|
42
44
|
/**
|
|
43
45
|
* The user cancelled a prompt. A calling core reads it to keep its own message.
|
|
44
46
|
* Not printed: `code` would surface as `Code:` in the command output.
|