@sanity/runtime-cli 13.2.2 → 13.2.3
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 +18 -18
- package/dist/actions/blueprints/blueprint.d.ts +17 -1
- package/dist/actions/blueprints/blueprint.js +43 -11
- package/dist/cores/blueprints/doctor.js +51 -53
- package/dist/server/static/api.js +22 -2
- package/dist/server/static/components/run-panel.js +3 -5
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
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/13.2.
|
|
23
|
+
@sanity/runtime-cli/13.2.3 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/v13.2.
|
|
101
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/add.ts)_
|
|
102
102
|
|
|
103
103
|
## `sanity-run blueprints config`
|
|
104
104
|
|
|
@@ -133,7 +133,7 @@ EXAMPLES
|
|
|
133
133
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
136
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/config.ts)_
|
|
137
137
|
|
|
138
138
|
## `sanity-run blueprints deploy`
|
|
139
139
|
|
|
@@ -163,7 +163,7 @@ EXAMPLES
|
|
|
163
163
|
$ sanity-run blueprints deploy --no-wait
|
|
164
164
|
```
|
|
165
165
|
|
|
166
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
166
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/deploy.ts)_
|
|
167
167
|
|
|
168
168
|
## `sanity-run blueprints destroy`
|
|
169
169
|
|
|
@@ -195,7 +195,7 @@ EXAMPLES
|
|
|
195
195
|
$ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
|
|
196
196
|
```
|
|
197
197
|
|
|
198
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
198
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/destroy.ts)_
|
|
199
199
|
|
|
200
200
|
## `sanity-run blueprints doctor`
|
|
201
201
|
|
|
@@ -221,7 +221,7 @@ DESCRIPTION
|
|
|
221
221
|
issues.
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
224
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/doctor.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints info`
|
|
227
227
|
|
|
@@ -251,7 +251,7 @@ EXAMPLES
|
|
|
251
251
|
$ sanity-run blueprints info --id <stackId>
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
254
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/info.ts)_
|
|
255
255
|
|
|
256
256
|
## `sanity-run blueprints init [DIR]`
|
|
257
257
|
|
|
@@ -301,7 +301,7 @@ EXAMPLES
|
|
|
301
301
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
|
|
302
302
|
```
|
|
303
303
|
|
|
304
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
304
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/init.ts)_
|
|
305
305
|
|
|
306
306
|
## `sanity-run blueprints logs`
|
|
307
307
|
|
|
@@ -329,7 +329,7 @@ EXAMPLES
|
|
|
329
329
|
$ sanity-run blueprints logs --watch
|
|
330
330
|
```
|
|
331
331
|
|
|
332
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
332
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/logs.ts)_
|
|
333
333
|
|
|
334
334
|
## `sanity-run blueprints plan`
|
|
335
335
|
|
|
@@ -352,7 +352,7 @@ EXAMPLES
|
|
|
352
352
|
$ sanity-run blueprints plan
|
|
353
353
|
```
|
|
354
354
|
|
|
355
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
355
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/plan.ts)_
|
|
356
356
|
|
|
357
357
|
## `sanity-run blueprints stacks`
|
|
358
358
|
|
|
@@ -381,7 +381,7 @@ EXAMPLES
|
|
|
381
381
|
$ sanity-run blueprints stacks --organization-id <organizationId>
|
|
382
382
|
```
|
|
383
383
|
|
|
384
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
384
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/blueprints/stacks.ts)_
|
|
385
385
|
|
|
386
386
|
## `sanity-run functions add`
|
|
387
387
|
|
|
@@ -430,7 +430,7 @@ EXAMPLES
|
|
|
430
430
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
431
431
|
```
|
|
432
432
|
|
|
433
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
433
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/add.ts)_
|
|
434
434
|
|
|
435
435
|
## `sanity-run functions dev`
|
|
436
436
|
|
|
@@ -464,7 +464,7 @@ EXAMPLES
|
|
|
464
464
|
$ sanity-run functions dev --timeout 60
|
|
465
465
|
```
|
|
466
466
|
|
|
467
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
467
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/dev.ts)_
|
|
468
468
|
|
|
469
469
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
470
470
|
|
|
@@ -491,7 +491,7 @@ EXAMPLES
|
|
|
491
491
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
492
492
|
```
|
|
493
493
|
|
|
494
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
494
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/env/add.ts)_
|
|
495
495
|
|
|
496
496
|
## `sanity-run functions env list NAME`
|
|
497
497
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run functions env list MyFunction
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
518
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/env/list.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run functions env remove NAME KEY`
|
|
521
521
|
|
|
@@ -541,7 +541,7 @@ EXAMPLES
|
|
|
541
541
|
$ sanity-run functions env remove MyFunction API_URL
|
|
542
542
|
```
|
|
543
543
|
|
|
544
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
544
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/env/remove.ts)_
|
|
545
545
|
|
|
546
546
|
## `sanity-run functions logs [NAME]`
|
|
547
547
|
|
|
@@ -580,7 +580,7 @@ EXAMPLES
|
|
|
580
580
|
$ sanity-run functions logs <name> --delete
|
|
581
581
|
```
|
|
582
582
|
|
|
583
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
583
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/logs.ts)_
|
|
584
584
|
|
|
585
585
|
## `sanity-run functions test [NAME]`
|
|
586
586
|
|
|
@@ -634,7 +634,7 @@ EXAMPLES
|
|
|
634
634
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
635
635
|
```
|
|
636
636
|
|
|
637
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.
|
|
637
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.3/src/commands/functions/test.ts)_
|
|
638
638
|
|
|
639
639
|
## `sanity-run help [COMMAND]`
|
|
640
640
|
|
|
@@ -27,6 +27,14 @@ type FileInfo = {
|
|
|
27
27
|
* @returns The path, file name, and extension of the blueprint file
|
|
28
28
|
*/
|
|
29
29
|
export declare function findBlueprintFile(blueprintPath?: string): FileInfo | null;
|
|
30
|
+
/**
|
|
31
|
+
* Source of the config value.
|
|
32
|
+
* - config: from the config file - .sanity.blueprint.config.json most common
|
|
33
|
+
* - env: from the environment - usually CLI var like `SANITY_ORGANIZATION_ID`
|
|
34
|
+
* - module: from the blueprint module - undocumented escape hatch
|
|
35
|
+
* - inferred: legacy `ST-<projectId>` stacks from launch
|
|
36
|
+
*/
|
|
37
|
+
export type ConfigSource = 'config' | 'env' | 'module' | 'inferred';
|
|
30
38
|
/** Result of the blueprint read operation */
|
|
31
39
|
export interface ReadBlueprintResult {
|
|
32
40
|
fileInfo: FileInfo;
|
|
@@ -41,9 +49,17 @@ export interface ReadBlueprintResult {
|
|
|
41
49
|
organizationId?: string;
|
|
42
50
|
projectId?: string;
|
|
43
51
|
stackId?: string;
|
|
52
|
+
sources?: {
|
|
53
|
+
organizationId?: ConfigSource;
|
|
54
|
+
projectId?: ConfigSource;
|
|
55
|
+
stackId?: ConfigSource;
|
|
56
|
+
};
|
|
44
57
|
}
|
|
45
58
|
/**
|
|
46
|
-
* Reads the blueprint file from disk and parses it.
|
|
59
|
+
* Reads the blueprint file from disk and parses it.
|
|
60
|
+
* Overrides config file values with shell environment variables.
|
|
61
|
+
* Can infer stackId from projectId if no stackId is provided and legacy ST-<projectId> stacks from launch are used.
|
|
62
|
+
*
|
|
47
63
|
* @param logger The logger instance
|
|
48
64
|
* @param validate Validation options
|
|
49
65
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
@@ -5,6 +5,7 @@ import { pathToFileURL } from 'node:url';
|
|
|
5
5
|
import blueprintParserValidator from '@sanity/blueprints-parser';
|
|
6
6
|
import { findUpSync } from 'find-up';
|
|
7
7
|
import { createJiti } from 'jiti';
|
|
8
|
+
import { SANITY_FUNCTION_DOCUMENT, SANITY_FUNCTION_MEDIA_LIBRARY_ASSET, SANITY_FUNCTION_SCHEDULE, } from '../../constants.js';
|
|
8
9
|
import { isLocalFunctionResource, } from '../../utils/types.js';
|
|
9
10
|
import { validateResources } from '../../utils/validate/index.js';
|
|
10
11
|
import { validateFunctionResource } from '../../utils/validate/resource.js';
|
|
@@ -65,7 +66,10 @@ export function findBlueprintFile(blueprintPath) {
|
|
|
65
66
|
};
|
|
66
67
|
}
|
|
67
68
|
/**
|
|
68
|
-
* Reads the blueprint file from disk and parses it.
|
|
69
|
+
* Reads the blueprint file from disk and parses it.
|
|
70
|
+
* Overrides config file values with shell environment variables.
|
|
71
|
+
* Can infer stackId from projectId if no stackId is provided and legacy ST-<projectId> stacks from launch are used.
|
|
72
|
+
*
|
|
69
73
|
* @param logger The logger instance
|
|
70
74
|
* @param validate Validation options
|
|
71
75
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
@@ -146,27 +150,46 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
|
146
150
|
}
|
|
147
151
|
catch { }
|
|
148
152
|
}
|
|
153
|
+
const sources = {};
|
|
149
154
|
let organizationId;
|
|
150
|
-
if (envOrganizationId)
|
|
155
|
+
if (envOrganizationId) {
|
|
151
156
|
organizationId = envOrganizationId;
|
|
152
|
-
|
|
157
|
+
sources.organizationId = 'env';
|
|
158
|
+
}
|
|
159
|
+
else if (moduleOrganizationId) {
|
|
153
160
|
organizationId = moduleOrganizationId;
|
|
154
|
-
|
|
161
|
+
sources.organizationId = 'module';
|
|
162
|
+
}
|
|
163
|
+
else if (blueprintConfig?.organizationId) {
|
|
155
164
|
organizationId = blueprintConfig.organizationId;
|
|
165
|
+
sources.organizationId = 'config';
|
|
166
|
+
}
|
|
156
167
|
let projectId;
|
|
157
|
-
if (envProjectId)
|
|
168
|
+
if (envProjectId) {
|
|
158
169
|
projectId = envProjectId;
|
|
159
|
-
|
|
170
|
+
sources.projectId = 'env';
|
|
171
|
+
}
|
|
172
|
+
else if (moduleProjectId) {
|
|
160
173
|
projectId = moduleProjectId;
|
|
161
|
-
|
|
174
|
+
sources.projectId = 'module';
|
|
175
|
+
}
|
|
176
|
+
else if (blueprintConfig?.projectId) {
|
|
162
177
|
projectId = blueprintConfig.projectId;
|
|
178
|
+
sources.projectId = 'config';
|
|
179
|
+
}
|
|
163
180
|
let stackId;
|
|
164
|
-
if (envStackId)
|
|
181
|
+
if (envStackId) {
|
|
165
182
|
stackId = envStackId;
|
|
166
|
-
|
|
183
|
+
sources.stackId = 'env';
|
|
184
|
+
}
|
|
185
|
+
else if (moduleStackId) {
|
|
167
186
|
stackId = moduleStackId;
|
|
168
|
-
|
|
187
|
+
sources.stackId = 'module';
|
|
188
|
+
}
|
|
189
|
+
else if (blueprintConfig?.stackId) {
|
|
169
190
|
stackId = blueprintConfig.stackId;
|
|
191
|
+
sources.stackId = 'config';
|
|
192
|
+
}
|
|
170
193
|
// LAUNCH LIMIT: 1 Stack per Project - infer stackId from projectId
|
|
171
194
|
// this code path exists to handle project-based stacks from initial Blueprints/Functions launch
|
|
172
195
|
if (!stackId && projectId) {
|
|
@@ -177,6 +200,8 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
|
177
200
|
projectId,
|
|
178
201
|
logger,
|
|
179
202
|
});
|
|
203
|
+
if (stackId)
|
|
204
|
+
sources.stackId = 'inferred';
|
|
180
205
|
}
|
|
181
206
|
catch {
|
|
182
207
|
// our assumption was wrong, so we'll leave stackId undefined
|
|
@@ -193,7 +218,13 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
|
193
218
|
scopeType = 'organization';
|
|
194
219
|
scopeId = organizationId;
|
|
195
220
|
}
|
|
196
|
-
const parserResult = blueprintParserValidator(rawBlueprint
|
|
221
|
+
const parserResult = blueprintParserValidator(rawBlueprint, {
|
|
222
|
+
invalidReferenceTypes: [
|
|
223
|
+
SANITY_FUNCTION_DOCUMENT,
|
|
224
|
+
SANITY_FUNCTION_MEDIA_LIBRARY_ASSET,
|
|
225
|
+
SANITY_FUNCTION_SCHEDULE,
|
|
226
|
+
],
|
|
227
|
+
});
|
|
197
228
|
const parsedBlueprint = parserResult.result === 'valid' ? parserResult.blueprint : undefined;
|
|
198
229
|
const errors = parserResult.result !== 'valid' ? parserResult.errors : [];
|
|
199
230
|
// resource validation
|
|
@@ -219,6 +250,7 @@ export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
|
219
250
|
organizationId,
|
|
220
251
|
projectId,
|
|
221
252
|
stackId,
|
|
253
|
+
sources,
|
|
222
254
|
/** @deprecated */
|
|
223
255
|
configPath: blueprintConfig?.configPath,
|
|
224
256
|
// fallback to the raw blueprint if the parser found errors
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { cwd } from 'node:process';
|
|
2
|
-
import {
|
|
2
|
+
import { readLocalBlueprint, } from '../../actions/blueprints/blueprint.js';
|
|
3
3
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
4
4
|
import config from '../../config.js';
|
|
5
5
|
import { capitalize, check, filePathRelativeToCwd, indent, niceId, severe, unsure, } from '../../utils/display/presenters.js';
|
|
@@ -9,14 +9,10 @@ import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
|
|
|
9
9
|
import { blueprintConfigCore } from './config.js';
|
|
10
10
|
const diagLookup = {
|
|
11
11
|
online: 'Online',
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
blueprintPresent: 'Blueprint file present',
|
|
17
|
-
blueprintValid: 'Blueprint file valid',
|
|
18
|
-
stackReady: 'Stack deployment ready',
|
|
19
|
-
userHasAccess: 'User has access to deployed "Stack"',
|
|
12
|
+
tokenValid: 'Authenticated',
|
|
13
|
+
blueprintValid: 'Blueprint valid',
|
|
14
|
+
stackReady: 'Stack ready',
|
|
15
|
+
userHasAccess: 'User has access',
|
|
20
16
|
};
|
|
21
17
|
export async function blueprintDoctorCore(options) {
|
|
22
18
|
const { bin, log, token, validateResources, flags: { verbose: v, path: p, fix }, } = options;
|
|
@@ -50,37 +46,30 @@ export async function blueprintDoctorCore(options) {
|
|
|
50
46
|
}
|
|
51
47
|
// TOKEN
|
|
52
48
|
if (token) {
|
|
53
|
-
diagnostics.tokenPresent = true;
|
|
54
49
|
tokenOrError = await validTokenOrErrorMessage(log, token);
|
|
55
50
|
if (tokenOrError.ok) {
|
|
56
51
|
diagnostics.tokenValid = true;
|
|
57
52
|
}
|
|
58
53
|
else {
|
|
59
|
-
yikes(`Token error: ${tokenOrError.error}`);
|
|
54
|
+
yikes(`Token error: ${tokenOrError.error.message}`);
|
|
60
55
|
diagnostics.tokenValid = false;
|
|
61
56
|
}
|
|
62
57
|
}
|
|
63
58
|
else {
|
|
64
|
-
|
|
59
|
+
yikes('No authentication token found');
|
|
60
|
+
diagnostics.tokenValid = false;
|
|
65
61
|
}
|
|
66
62
|
// BLUEPRINT file
|
|
67
|
-
|
|
68
|
-
if (blueprintFile?.blueprintFilePath) {
|
|
69
|
-
log.verbose(`Found blueprint file at ${blueprintFile.blueprintFilePath.replace(here, '.')}`);
|
|
70
|
-
diagnostics.blueprintPresent = true;
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
diagnostics.blueprintPresent = false;
|
|
74
|
-
}
|
|
75
|
-
let blueprint;
|
|
63
|
+
let localBlueprint;
|
|
76
64
|
try {
|
|
77
|
-
|
|
78
|
-
|
|
65
|
+
localBlueprint = await readLocalBlueprint(log, { resources: options.validateResources || false }, path);
|
|
66
|
+
log.verbose(`Found blueprint file at ${filePathRelativeToCwd(localBlueprint.fileInfo.blueprintFilePath)}`);
|
|
67
|
+
if (localBlueprint.errors.length === 0) {
|
|
79
68
|
log.verbose(`Blueprint has no errors`);
|
|
80
69
|
diagnostics.blueprintValid = true;
|
|
81
70
|
}
|
|
82
71
|
else {
|
|
83
|
-
log.verbose(`Blueprint errors: \n${
|
|
72
|
+
log.verbose(`Blueprint errors: \n${localBlueprint.errors.join('\n ')}`);
|
|
84
73
|
diagnostics.blueprintValid = false;
|
|
85
74
|
}
|
|
86
75
|
}
|
|
@@ -88,32 +77,33 @@ export async function blueprintDoctorCore(options) {
|
|
|
88
77
|
yikes(`Unable to read blueprint`);
|
|
89
78
|
diagnostics.blueprintValid = false;
|
|
90
79
|
}
|
|
91
|
-
if (
|
|
92
|
-
const {
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
diagnostics.configFileValid = false;
|
|
80
|
+
if (localBlueprint) {
|
|
81
|
+
const { scopeType, scopeId, stackId, sources } = localBlueprint;
|
|
82
|
+
const sourceLabel = (source) => {
|
|
83
|
+
switch (source) {
|
|
84
|
+
case 'env':
|
|
85
|
+
return 'environment';
|
|
86
|
+
case 'module':
|
|
87
|
+
return 'blueprint module';
|
|
88
|
+
case 'config':
|
|
89
|
+
return 'config file';
|
|
90
|
+
case 'inferred':
|
|
91
|
+
return 'inferred';
|
|
92
|
+
default:
|
|
93
|
+
return 'unknown';
|
|
108
94
|
}
|
|
95
|
+
};
|
|
96
|
+
if (scopeType && scopeId) {
|
|
97
|
+
const scopeSourceKey = scopeType === 'project' ? 'projectId' : 'organizationId';
|
|
98
|
+
log.verbose(indent(`${capitalize(scopeType)}: ${niceId(scopeId)} (from ${sourceLabel(sources?.[scopeSourceKey])})`));
|
|
109
99
|
}
|
|
110
|
-
|
|
111
|
-
|
|
100
|
+
if (stackId) {
|
|
101
|
+
log.verbose(indent(`Deployment: ${niceId(stackId)} (from ${sourceLabel(sources?.stackId)})`));
|
|
112
102
|
}
|
|
113
103
|
// STACK + ACCESS
|
|
114
|
-
if (diagnostics.online && diagnostics.tokenValid && token && stackId &&
|
|
104
|
+
if (diagnostics.online && diagnostics.tokenValid && token && stackId && scopeType && scopeId) {
|
|
115
105
|
const stackResponse = await getStack({
|
|
116
|
-
auth: { token, scopeType
|
|
106
|
+
auth: { token, scopeType, scopeId },
|
|
117
107
|
stackId,
|
|
118
108
|
logger: log,
|
|
119
109
|
});
|
|
@@ -135,14 +125,22 @@ export async function blueprintDoctorCore(options) {
|
|
|
135
125
|
}
|
|
136
126
|
}
|
|
137
127
|
else {
|
|
138
|
-
if (!diagnostics.online)
|
|
139
|
-
yikes('Unable to connect to Sanity API.');
|
|
140
|
-
if (!diagnostics.tokenValid)
|
|
141
|
-
yikes('Invalid authentication token.');
|
|
142
128
|
if (!stackId)
|
|
143
129
|
yikes(`Blueprints configuration is missing a Stack ID`);
|
|
144
|
-
if (
|
|
145
|
-
|
|
130
|
+
if (scopeType === 'project') {
|
|
131
|
+
if (!scopeId)
|
|
132
|
+
yikes(`Blueprints configuration is missing a Project ID`);
|
|
133
|
+
}
|
|
134
|
+
else if (scopeType === 'organization') {
|
|
135
|
+
if (!scopeId)
|
|
136
|
+
yikes(`Blueprints configuration is missing an Organization ID`);
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
if (!scopeType)
|
|
140
|
+
yikes(`Blueprints configuration is missing a Scope Type`);
|
|
141
|
+
if (!scopeId)
|
|
142
|
+
yikes(`Blueprints configuration is missing a Scope ID`);
|
|
143
|
+
}
|
|
146
144
|
}
|
|
147
145
|
}
|
|
148
146
|
log('');
|
|
@@ -194,7 +192,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
194
192
|
data: { diagnostics },
|
|
195
193
|
};
|
|
196
194
|
}
|
|
197
|
-
if (!
|
|
195
|
+
if (!localBlueprint) {
|
|
198
196
|
return {
|
|
199
197
|
success: false,
|
|
200
198
|
error: `${errorMessage}. Unable to fix: Blueprint is missing or invalid`,
|
|
@@ -205,7 +203,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
205
203
|
bin,
|
|
206
204
|
log,
|
|
207
205
|
token: tokenOrError.value,
|
|
208
|
-
blueprint,
|
|
206
|
+
blueprint: localBlueprint,
|
|
209
207
|
validateResources,
|
|
210
208
|
flags: { edit: true, verbose: v },
|
|
211
209
|
});
|
|
@@ -82,7 +82,17 @@ function projects() {
|
|
|
82
82
|
return fetch('/projects')
|
|
83
83
|
.then((response) => response.json())
|
|
84
84
|
.then(async (projects) => {
|
|
85
|
-
store.projects = projects
|
|
85
|
+
store.projects = projects.sort((a, b) => {
|
|
86
|
+
const nameA = a.displayName.toUpperCase()
|
|
87
|
+
const nameB = b.displayName.toUpperCase()
|
|
88
|
+
if (nameA < nameB) {
|
|
89
|
+
return -1
|
|
90
|
+
}
|
|
91
|
+
if (nameA > nameB) {
|
|
92
|
+
return 1
|
|
93
|
+
}
|
|
94
|
+
return 0
|
|
95
|
+
})
|
|
86
96
|
store.selectedProject = store.defaultProject ? store.defaultProject : projects[0].id
|
|
87
97
|
await datasets(store.selectedProject)
|
|
88
98
|
})
|
|
@@ -98,7 +108,17 @@ function datasets(selectedProject) {
|
|
|
98
108
|
return fetch(`/datasets?project=${selectedProject}`)
|
|
99
109
|
.then((response) => response.json())
|
|
100
110
|
.then((datasets) => {
|
|
101
|
-
store.datasets = datasets
|
|
111
|
+
store.datasets = datasets.sort((a, b) => {
|
|
112
|
+
const nameA = a.name.toUpperCase()
|
|
113
|
+
const nameB = b.name.toUpperCase()
|
|
114
|
+
if (nameA < nameB) {
|
|
115
|
+
return -1
|
|
116
|
+
}
|
|
117
|
+
if (nameA > nameB) {
|
|
118
|
+
return 1
|
|
119
|
+
}
|
|
120
|
+
return 0
|
|
121
|
+
})
|
|
102
122
|
store.selectedDataset = datasets[0].name
|
|
103
123
|
})
|
|
104
124
|
.catch(() => {
|
|
@@ -78,11 +78,9 @@ class RunPanel extends ApiBaseElement {
|
|
|
78
78
|
this.api.invoke({context, event, metadata})
|
|
79
79
|
}
|
|
80
80
|
createPayloadText = (doc) => {
|
|
81
|
-
if (doc
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
if (doc.children) {
|
|
85
|
-
return doc.children.map((child) => child.text.join('')).join('') || '{}'
|
|
81
|
+
if (doc) {
|
|
82
|
+
const payload = doc.toString().trim()
|
|
83
|
+
return payload ? payload : '{}'
|
|
86
84
|
}
|
|
87
85
|
return '{}'
|
|
88
86
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sanity/runtime-cli",
|
|
3
3
|
"description": "Sanity's Runtime CLI for Blueprints and Functions",
|
|
4
|
-
"version": "13.2.
|
|
4
|
+
"version": "13.2.3",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -102,7 +102,7 @@
|
|
|
102
102
|
"@oclif/core": "^4.8.0",
|
|
103
103
|
"@oclif/plugin-help": "^6.2.36",
|
|
104
104
|
"@sanity/blueprints": "^0.9.0",
|
|
105
|
-
"@sanity/blueprints-parser": "^0.
|
|
105
|
+
"@sanity/blueprints-parser": "^0.4.0",
|
|
106
106
|
"@sanity/client": "^7.14.0",
|
|
107
107
|
"adm-zip": "^0.5.16",
|
|
108
108
|
"array-treeify": "^0.1.5",
|