@sanity/runtime-cli 13.0.3 → 13.2.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 +18 -18
- package/dist/actions/blueprints/blueprint.d.ts +6 -3
- package/dist/actions/blueprints/blueprint.js +18 -8
- package/dist/actions/functions/dev.d.ts +1 -1
- package/dist/actions/functions/dev.js +2 -2
- package/dist/actions/git.d.ts +4 -1
- package/dist/actions/git.js +3 -3
- package/dist/baseCommands.d.ts +4 -0
- package/dist/baseCommands.js +8 -0
- package/dist/commands/blueprints/add.js +1 -0
- package/dist/commands/blueprints/config.js +1 -0
- package/dist/commands/blueprints/deploy.js +1 -0
- package/dist/commands/blueprints/destroy.js +1 -0
- package/dist/commands/blueprints/doctor.js +1 -0
- package/dist/commands/blueprints/info.js +1 -0
- package/dist/commands/blueprints/init.js +1 -0
- package/dist/commands/blueprints/logs.js +1 -0
- package/dist/commands/blueprints/plan.js +1 -0
- package/dist/commands/blueprints/stacks.js +1 -0
- package/dist/commands/functions/add.js +1 -0
- package/dist/commands/functions/dev.js +1 -0
- package/dist/commands/functions/env/add.js +1 -0
- package/dist/commands/functions/env/list.js +1 -0
- package/dist/commands/functions/env/remove.js +1 -0
- package/dist/commands/functions/logs.js +1 -0
- package/dist/commands/functions/test.js +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.js +1 -0
- package/dist/cores/blueprints/doctor.js +3 -2
- package/dist/cores/blueprints/init.d.ts +2 -0
- package/dist/cores/blueprints/init.js +40 -9
- package/dist/cores/functions/add.js +12 -1
- package/dist/cores/functions/dev.js +1 -1
- package/dist/cores/functions/logs.js +6 -1
- package/dist/cores/index.d.ts +4 -2
- package/dist/cores/index.js +4 -2
- package/dist/server/app.d.ts +1 -1
- package/dist/server/app.js +6 -4
- package/dist/server/handlers/invoke.d.ts +1 -1
- package/dist/server/handlers/invoke.js +2 -2
- package/dist/server/static/api.d.ts +41 -0
- package/dist/server/static/api.js +29 -6
- package/dist/server/static/components/filters.js +62 -56
- package/dist/server/static/components/function-list.js +1 -1
- package/dist/server/static/components/payload-panel.js +33 -4
- package/dist/server/static/components/run-panel.js +12 -4
- package/dist/server/static/vendor/vendor.bundle.js +19 -10
- package/dist/utils/child-process-wrapper.js +3 -2
- package/dist/utils/display/blueprints-formatting.d.ts +2 -2
- package/dist/utils/display/blueprints-formatting.js +10 -3
- package/dist/utils/display/prompt.js +22 -15
- package/dist/utils/display/resources-formatting.d.ts +2 -1
- package/dist/utils/display/resources-formatting.js +31 -0
- package/dist/utils/find-function.js +6 -1
- package/dist/utils/functions/resource-to-arc.js +11 -2
- package/dist/utils/types.d.ts +10 -4
- package/dist/utils/types.js +4 -1
- package/dist/utils/validate/index.d.ts +3 -0
- package/dist/utils/validate/index.js +35 -0
- package/oclif.manifest.json +120 -1
- package/package.json +16 -17
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.0
|
|
23
|
+
@sanity/runtime-cli/13.2.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/v13.0
|
|
101
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
136
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
166
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
198
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
224
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
254
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
304
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
332
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
355
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
384
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
433
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
467
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
494
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
518
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
544
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
583
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/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.0
|
|
637
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v13.2.0/src/commands/functions/test.ts)_
|
|
638
638
|
|
|
639
639
|
## `sanity-run help [COMMAND]`
|
|
640
640
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
2
|
import { type Blueprint } from '@sanity/blueprints-parser';
|
|
3
3
|
import type { Logger } from '../../utils/logger.js';
|
|
4
|
-
import type
|
|
5
|
-
import { type ScopeType } from '../../utils/types.js';
|
|
4
|
+
import { type BlueprintParserError, type ScopeType } from '../../utils/types.js';
|
|
6
5
|
import { type LocatedBlueprintsConfig } from './config.js';
|
|
7
6
|
declare const SUPPORTED_FILE_EXTENSIONS: readonly [".json", ".js", ".mjs", ".ts"];
|
|
8
7
|
type BlueprintFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
|
|
@@ -45,10 +44,14 @@ export interface ReadBlueprintResult {
|
|
|
45
44
|
}
|
|
46
45
|
/**
|
|
47
46
|
* Reads the blueprint file from disk and parses it. Greedily looks for Blueprint config
|
|
47
|
+
* @param logger The logger instance
|
|
48
|
+
* @param validate Validation options
|
|
48
49
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
49
50
|
* @returns Known information about the Blueprint, config, and Stack
|
|
50
51
|
*/
|
|
51
|
-
export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>,
|
|
52
|
+
export declare function readLocalBlueprint(logger: ReturnType<typeof Logger>, validate: {
|
|
53
|
+
resources: boolean;
|
|
54
|
+
}, blueprintPath?: string): Promise<ReadBlueprintResult>;
|
|
52
55
|
export declare function writeBlueprintToDisk({ blueprintFilePath, jsonContent, }: {
|
|
53
56
|
blueprintFilePath: string;
|
|
54
57
|
jsonContent?: Blueprint;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
2
2
|
import { basename, dirname, extname } from 'node:path';
|
|
3
3
|
import { cwd, env } from 'node:process';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
4
5
|
import blueprintParserValidator from '@sanity/blueprints-parser';
|
|
5
6
|
import { findUpSync } from 'find-up';
|
|
6
7
|
import { createJiti } from 'jiti';
|
|
7
|
-
import { isLocalFunctionResource } from '../../utils/types.js';
|
|
8
|
+
import { isLocalFunctionResource, } from '../../utils/types.js';
|
|
9
|
+
import { validateResources } from '../../utils/validate/index.js';
|
|
8
10
|
import { validateFunctionResource } from '../../utils/validate/resource.js';
|
|
9
11
|
import { backfillOrganizationId, backfillProjectBasedStackId, readConfigFile, } from './config.js';
|
|
10
12
|
const SUPPORTED_FILE_EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
|
|
@@ -64,10 +66,12 @@ export function findBlueprintFile(blueprintPath) {
|
|
|
64
66
|
}
|
|
65
67
|
/**
|
|
66
68
|
* Reads the blueprint file from disk and parses it. Greedily looks for Blueprint config
|
|
69
|
+
* @param logger The logger instance
|
|
70
|
+
* @param validate Validation options
|
|
67
71
|
* @param blueprintPath - The path of the blueprint file or directory- will search up the directory tree!
|
|
68
72
|
* @returns Known information about the Blueprint, config, and Stack
|
|
69
73
|
*/
|
|
70
|
-
export async function readLocalBlueprint(logger, blueprintPath) {
|
|
74
|
+
export async function readLocalBlueprint(logger, validate, blueprintPath) {
|
|
71
75
|
const blueprintFile = findBlueprintFile(blueprintPath);
|
|
72
76
|
if (!blueprintFile)
|
|
73
77
|
throw Error('Could not find Blueprint file! Use the `blueprints init` command.');
|
|
@@ -89,7 +93,7 @@ export async function readLocalBlueprint(logger, blueprintPath) {
|
|
|
89
93
|
}
|
|
90
94
|
case '.ts': {
|
|
91
95
|
const jiti = createJiti(dirname(foundFilePath));
|
|
92
|
-
const modDefault = await jiti.import(
|
|
96
|
+
const modDefault = await jiti.import(pathToFileURL(foundFilePath).href, { default: true });
|
|
93
97
|
blueprintModule = modDefault;
|
|
94
98
|
break;
|
|
95
99
|
}
|
|
@@ -192,12 +196,18 @@ export async function readLocalBlueprint(logger, blueprintPath) {
|
|
|
192
196
|
const parserResult = blueprintParserValidator(rawBlueprint);
|
|
193
197
|
const parsedBlueprint = parserResult.result === 'valid' ? parserResult.blueprint : undefined;
|
|
194
198
|
const errors = parserResult.result !== 'valid' ? parserResult.errors : [];
|
|
195
|
-
//
|
|
199
|
+
// resource validation
|
|
196
200
|
if (parsedBlueprint?.resources) {
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
+
if (validate.resources) {
|
|
202
|
+
// validate function resources
|
|
203
|
+
errors.push(...validateResources(parsedBlueprint.resources));
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
// backwards compat: fallback to the previous validation if validation was not explicitly enabled
|
|
207
|
+
const functionResources = parsedBlueprint.resources.filter(isLocalFunctionResource);
|
|
208
|
+
const fnErrors = functionResources.map((r) => validateFunctionResource(r));
|
|
209
|
+
errors.push(...fnErrors.flat());
|
|
210
|
+
}
|
|
201
211
|
}
|
|
202
212
|
return {
|
|
203
213
|
fileInfo: { blueprintFilePath: foundFilePath, fileName, extension },
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Logger } from '../../utils/logger.js';
|
|
2
2
|
import type { InvokeExecutionOptions } from '../../utils/types.js';
|
|
3
|
-
export declare function dev(host: string, port: number, logger: ReturnType<typeof Logger>, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
|
|
3
|
+
export declare function dev(host: string, port: number, logger: ReturnType<typeof Logger>, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<void>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { app } from '../../server/app.js';
|
|
2
|
-
export async function dev(host, port, logger, executionOptions) {
|
|
3
|
-
app(host, Number(port), logger, executionOptions);
|
|
2
|
+
export async function dev(host, port, logger, validateResources, executionOptions) {
|
|
3
|
+
app(host, Number(port), logger, validateResources, executionOptions);
|
|
4
4
|
}
|
package/dist/actions/git.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export declare const GITIGNORE_FOR_FUNCTIONS = "\n# Sanity Functions\nfunctions/**/.env*\nfunctions/**/.build/\nfunctions/**/node_modules/\n";
|
|
2
2
|
export declare const GITIGNORE_TEMPLATE = "node_modules\n.env\n\n# Sanity Functions\nfunctions/**/.env*\nfunctions/**/.build/\nfunctions/**/node_modules/\n\n";
|
|
3
|
-
export
|
|
3
|
+
export type GitignoreResult = {
|
|
4
|
+
action: 'created' | 'updated' | 'unchanged';
|
|
5
|
+
};
|
|
6
|
+
export declare function writeGitignoreFile(nearFilePath: string): GitignoreResult;
|
package/dist/actions/git.js
CHANGED
|
@@ -20,9 +20,9 @@ export function writeGitignoreFile(nearFilePath) {
|
|
|
20
20
|
// append GITIGNORE_FOR_FUNCTIONS to existing .gitignore
|
|
21
21
|
const existingContent = readFileSync(gitignorePath, 'utf8').toString();
|
|
22
22
|
if (existingContent.includes(GITIGNORE_FOR_FUNCTIONS))
|
|
23
|
-
return
|
|
24
|
-
content = `${existingContent}\n${GITIGNORE_FOR_FUNCTIONS}`;
|
|
23
|
+
return { action: 'unchanged' };
|
|
24
|
+
content = `${existingContent.trimEnd()}\n${GITIGNORE_FOR_FUNCTIONS}`;
|
|
25
25
|
}
|
|
26
26
|
writeFileSync(gitignorePath, content);
|
|
27
|
-
return
|
|
27
|
+
return { action: gitignoreExists ? 'updated' : 'created' };
|
|
28
28
|
}
|
package/dist/baseCommands.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare const baseFlags: {
|
|
|
8
8
|
json: Interfaces.BooleanFlag<boolean>;
|
|
9
9
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
10
10
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
11
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
11
12
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
12
13
|
};
|
|
13
14
|
/**
|
|
@@ -27,6 +28,7 @@ export declare abstract class RuntimeCommand<T extends typeof Command> extends C
|
|
|
27
28
|
json: Interfaces.BooleanFlag<boolean>;
|
|
28
29
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
29
30
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
31
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
30
32
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
31
33
|
};
|
|
32
34
|
static enableJsonFlag: boolean;
|
|
@@ -52,6 +54,7 @@ export declare abstract class LocalBlueprintCommand<T extends typeof Command> ex
|
|
|
52
54
|
json: Interfaces.BooleanFlag<boolean>;
|
|
53
55
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
54
56
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
57
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
55
58
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
56
59
|
};
|
|
57
60
|
init(): Promise<void>;
|
|
@@ -75,6 +78,7 @@ export declare abstract class DeployedStackCommand<T extends typeof Command> ext
|
|
|
75
78
|
json: Interfaces.BooleanFlag<boolean>;
|
|
76
79
|
path: Interfaces.OptionFlag<string | undefined, Interfaces.CustomOptions>;
|
|
77
80
|
trace: Interfaces.BooleanFlag<boolean>;
|
|
81
|
+
'validate-resources': Interfaces.BooleanFlag<boolean>;
|
|
78
82
|
verbose: Interfaces.BooleanFlag<boolean>;
|
|
79
83
|
};
|
|
80
84
|
init(): Promise<void>;
|
package/dist/baseCommands.js
CHANGED
|
@@ -18,6 +18,12 @@ export const baseFlags = {
|
|
|
18
18
|
default: false,
|
|
19
19
|
hidden,
|
|
20
20
|
}),
|
|
21
|
+
'validate-resources': OclifFlags.boolean({
|
|
22
|
+
description: 'Validate resources',
|
|
23
|
+
default: false,
|
|
24
|
+
allowNo: true,
|
|
25
|
+
hidden, // TODO: reveal this once support is added in main CLI
|
|
26
|
+
}),
|
|
21
27
|
verbose: OclifFlags.boolean({
|
|
22
28
|
description: 'Verbose output',
|
|
23
29
|
default: false,
|
|
@@ -111,6 +117,7 @@ export class LocalBlueprintCommand extends RuntimeCommand {
|
|
|
111
117
|
const result = await initBlueprintConfig({
|
|
112
118
|
bin: this.config.bin,
|
|
113
119
|
log: Logger(this.log.bind(this), this.flags),
|
|
120
|
+
validateResources: this.flags['validate-resources'],
|
|
114
121
|
});
|
|
115
122
|
if (!result.ok) {
|
|
116
123
|
this.error(result.error);
|
|
@@ -148,6 +155,7 @@ export class DeployedStackCommand extends LocalBlueprintCommand {
|
|
|
148
155
|
log: Logger(this.log.bind(this), this.flags),
|
|
149
156
|
token: this.sanityToken,
|
|
150
157
|
validateToken: false,
|
|
158
|
+
validateResources: this.flags['validate-resources'],
|
|
151
159
|
});
|
|
152
160
|
if (!result.ok) {
|
|
153
161
|
this.error(result.error);
|
|
@@ -98,6 +98,7 @@ After adding a function, use 'functions dev' to test locally, then 'blueprints d
|
|
|
98
98
|
bin,
|
|
99
99
|
log: Logger(this.log.bind(this), this.flags),
|
|
100
100
|
blueprint,
|
|
101
|
+
validateResources: flags['validate-resources'],
|
|
101
102
|
flags: {
|
|
102
103
|
example: flags.example,
|
|
103
104
|
name: flags.name,
|
|
@@ -44,6 +44,7 @@ If you need to switch your Blueprint to a different Stack, use --edit --stack-id
|
|
|
44
44
|
log: Logger(this.log.bind(this), this.flags),
|
|
45
45
|
blueprint: this.blueprint,
|
|
46
46
|
token: this.sanityToken,
|
|
47
|
+
validateResources: this.flags['validate-resources'],
|
|
47
48
|
flags: this.flags,
|
|
48
49
|
});
|
|
49
50
|
if (!success)
|
|
@@ -29,6 +29,7 @@ Use --no-wait to queue the deployment and return immediately without waiting for
|
|
|
29
29
|
scopeId: this.scopeId,
|
|
30
30
|
deployedStack: this.deployedStack,
|
|
31
31
|
blueprint: this.blueprint,
|
|
32
|
+
validateResources: this.flags['validate-resources'],
|
|
32
33
|
flags: this.flags,
|
|
33
34
|
});
|
|
34
35
|
if (!success)
|
|
@@ -47,6 +47,7 @@ Use this to clean up test environments or decommission a Stack you no longer nee
|
|
|
47
47
|
log: Logger(this.log.bind(this), this.flags),
|
|
48
48
|
token: this.sanityToken,
|
|
49
49
|
blueprint: this.blueprint,
|
|
50
|
+
validateResources: this.flags['validate-resources'],
|
|
50
51
|
flags: this.flags,
|
|
51
52
|
});
|
|
52
53
|
if (!success)
|
|
@@ -25,6 +25,7 @@ Run this command when encountering errors with other Blueprint commands. Use --f
|
|
|
25
25
|
bin: this.config.bin,
|
|
26
26
|
log: Logger(this.log.bind(this), this.flags),
|
|
27
27
|
token,
|
|
28
|
+
validateResources: this.flags['validate-resources'],
|
|
28
29
|
flags: this.flags,
|
|
29
30
|
});
|
|
30
31
|
const { success, error } = result;
|
|
@@ -25,6 +25,7 @@ Run 'blueprints stacks' to see all available Stacks in your project or organizat
|
|
|
25
25
|
auth: this.auth,
|
|
26
26
|
stackId: this.stackId,
|
|
27
27
|
deployedStack: this.deployedStack,
|
|
28
|
+
validateResources: this.flags['validate-resources'],
|
|
28
29
|
flags: this.flags,
|
|
29
30
|
});
|
|
30
31
|
if (!success)
|
|
@@ -27,6 +27,7 @@ If you're not seeing expected logs, verify your Stack is deployed with 'blueprin
|
|
|
27
27
|
auth: this.auth,
|
|
28
28
|
stackId: this.stackId,
|
|
29
29
|
deployedStack: this.deployedStack,
|
|
30
|
+
validateResources: this.flags['validate-resources'],
|
|
30
31
|
flags: this.flags,
|
|
31
32
|
});
|
|
32
33
|
if (streaming)
|
|
@@ -13,6 +13,7 @@ Run 'blueprints plan' after making local changes to your Blueprint manifest to v
|
|
|
13
13
|
log: Logger(this.log.bind(this), this.flags),
|
|
14
14
|
token: this.sanityToken,
|
|
15
15
|
blueprint: this.blueprint,
|
|
16
|
+
validateResources: this.flags['validate-resources'],
|
|
16
17
|
flags: this.flags,
|
|
17
18
|
});
|
|
18
19
|
if (!success)
|
|
@@ -31,6 +31,7 @@ Use this to discover existing Stacks you can scope a local Blueprint to (using '
|
|
|
31
31
|
log: Logger(this.log.bind(this), this.flags),
|
|
32
32
|
token: this.sanityToken,
|
|
33
33
|
blueprint: this.blueprint,
|
|
34
|
+
validateResources: this.flags['validate-resources'],
|
|
34
35
|
flags: this.flags,
|
|
35
36
|
});
|
|
36
37
|
if (!success)
|
|
@@ -71,6 +71,7 @@ After adding, use 'functions dev' to test locally, then 'blueprints deploy' to p
|
|
|
71
71
|
bin: this.config.bin,
|
|
72
72
|
log: Logger(this.log.bind(this), this.flags),
|
|
73
73
|
blueprint: this.blueprint,
|
|
74
|
+
validateResources: this.flags['validate-resources'],
|
|
74
75
|
flags: this.flags,
|
|
75
76
|
});
|
|
76
77
|
if (!success)
|
|
@@ -37,6 +37,7 @@ To invoke a function with the CLI, use 'functions test'.`;
|
|
|
37
37
|
const { success, error, streaming } = await functionDevCore({
|
|
38
38
|
bin: this.config.bin,
|
|
39
39
|
log: Logger(this.log.bind(this), this.flags),
|
|
40
|
+
validateResources: this.flags['validate-resources'],
|
|
40
41
|
flags,
|
|
41
42
|
});
|
|
42
43
|
if (!success)
|
|
@@ -27,6 +27,7 @@ Environment variables are useful for API keys, configuration values, and other s
|
|
|
27
27
|
scopeId: this.scopeId,
|
|
28
28
|
token: this.sanityToken,
|
|
29
29
|
stackId: this.stackId,
|
|
30
|
+
validateResources: this.flags['validate-resources'],
|
|
30
31
|
});
|
|
31
32
|
if (!success)
|
|
32
33
|
this.error(error);
|
|
@@ -23,6 +23,7 @@ Use 'functions env add' to set variables or 'functions env remove' to delete the
|
|
|
23
23
|
scopeId: this.scopeId,
|
|
24
24
|
token: this.sanityToken,
|
|
25
25
|
stackId: this.stackId,
|
|
26
|
+
validateResources: this.flags['validate-resources'],
|
|
26
27
|
});
|
|
27
28
|
if (!success)
|
|
28
29
|
this.error(error);
|
|
@@ -66,6 +66,7 @@ Use --watch (-w) to stream logs in real-time. Use --delete to clear all logs for
|
|
|
66
66
|
token: this.sanityToken,
|
|
67
67
|
stackId: this.stackId,
|
|
68
68
|
helpText: LogsCommand.getHelpText(this.config.bin, 'functions logs'),
|
|
69
|
+
validateResources: this.flags['validate-resources'],
|
|
69
70
|
});
|
|
70
71
|
if (!success)
|
|
71
72
|
this.error(error);
|
|
@@ -176,6 +176,7 @@ Provide test data via --data (inline JSON), --file (JSON file), or --document-id
|
|
|
176
176
|
flags: this.flags,
|
|
177
177
|
blueprint: this.blueprint,
|
|
178
178
|
helpText: TestCommand.getHelpText(this.config.bin, 'functions test'),
|
|
179
|
+
validateResources: this.flags['validate-resources'],
|
|
179
180
|
});
|
|
180
181
|
if (!success)
|
|
181
182
|
this.error(error);
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const SANITY_ACCESS_ROLE = "sanity.access.role";
|
|
2
|
+
export declare const SANITY_ACCESS_ROBOT = "sanity.access.robot";
|
|
2
3
|
export declare const SANITY_FUNCTION_DOCUMENT = "sanity.function.document";
|
|
3
4
|
export declare const SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = "sanity.function.media-library.asset";
|
|
4
5
|
export declare const SANITY_FUNCTION_SCHEDULE = "sanity.function.cron";
|
package/dist/constants.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export const SANITY_ACCESS_ROLE = 'sanity.access.role';
|
|
2
|
+
export const SANITY_ACCESS_ROBOT = 'sanity.access.robot';
|
|
2
3
|
export const SANITY_FUNCTION_DOCUMENT = 'sanity.function.document';
|
|
3
4
|
export const SANITY_FUNCTION_MEDIA_LIBRARY_ASSET = 'sanity.function.media-library.asset';
|
|
4
5
|
export const SANITY_FUNCTION_SCHEDULE = 'sanity.function.cron';
|
|
@@ -19,7 +19,7 @@ const diagLookup = {
|
|
|
19
19
|
userHasAccess: 'User has access to deployed "Stack"',
|
|
20
20
|
};
|
|
21
21
|
export async function blueprintDoctorCore(options) {
|
|
22
|
-
const { bin, log, token, flags: { verbose: v, path: p, fix }, } = options;
|
|
22
|
+
const { bin, log, token, validateResources, flags: { verbose: v, path: p, fix }, } = options;
|
|
23
23
|
const yikes = (s) => {
|
|
24
24
|
log.error(chalk.bgRedBright.whiteBright.bold(` ${s} `));
|
|
25
25
|
};
|
|
@@ -74,7 +74,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
74
74
|
}
|
|
75
75
|
let blueprint;
|
|
76
76
|
try {
|
|
77
|
-
blueprint = await readLocalBlueprint(log, path);
|
|
77
|
+
blueprint = await readLocalBlueprint(log, { resources: options.validateResources || false }, path);
|
|
78
78
|
if (blueprint.errors.length === 0) {
|
|
79
79
|
log.verbose(`Blueprint has no errors`);
|
|
80
80
|
diagnostics.blueprintValid = true;
|
|
@@ -206,6 +206,7 @@ export async function blueprintDoctorCore(options) {
|
|
|
206
206
|
log,
|
|
207
207
|
token: tokenOrError.value,
|
|
208
208
|
blueprint,
|
|
209
|
+
validateResources,
|
|
209
210
|
flags: { edit: true, verbose: v },
|
|
210
211
|
});
|
|
211
212
|
}
|
|
@@ -2,6 +2,7 @@ import type { ScopeType } from '../../utils/types.js';
|
|
|
2
2
|
import type { CoreConfig, CoreResult } from '../index.js';
|
|
3
3
|
export interface BlueprintInitOptions extends CoreConfig {
|
|
4
4
|
token: string;
|
|
5
|
+
knownProjectId?: string;
|
|
5
6
|
args: {
|
|
6
7
|
dir?: string;
|
|
7
8
|
};
|
|
@@ -33,6 +34,7 @@ export declare function resolveScopeAndStack(params: {
|
|
|
33
34
|
organizationId: string | undefined;
|
|
34
35
|
stackId: string | undefined;
|
|
35
36
|
stackName: string | undefined;
|
|
37
|
+
knownProjectId?: string;
|
|
36
38
|
log: CoreConfig['log'];
|
|
37
39
|
token: string;
|
|
38
40
|
}): Promise<ResolvedScope>;
|