@sanity/runtime-cli 8.0.0 → 8.0.1

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 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/8.0.0 linux-x64 node-v22.16.0
23
+ @sanity/runtime-cli/8.0.1 linux-x64 node-v22.16.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -85,7 +85,7 @@ EXAMPLES
85
85
  $ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
86
86
  ```
87
87
 
88
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/add.ts)_
88
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/add.ts)_
89
89
 
90
90
  ## `sanity-run blueprints config`
91
91
 
@@ -116,7 +116,7 @@ EXAMPLES
116
116
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
117
117
  ```
118
118
 
119
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/config.ts)_
119
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/config.ts)_
120
120
 
121
121
  ## `sanity-run blueprints deploy`
122
122
 
@@ -138,7 +138,7 @@ EXAMPLES
138
138
  $ sanity-run blueprints deploy --no-wait
139
139
  ```
140
140
 
141
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/deploy.ts)_
141
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/deploy.ts)_
142
142
 
143
143
  ## `sanity-run blueprints destroy`
144
144
 
@@ -163,7 +163,7 @@ EXAMPLES
163
163
  $ sanity-run blueprints destroy --stack-id <stackId> --project-id <projectId> --force --no-wait
164
164
  ```
165
165
 
166
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/destroy.ts)_
166
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/destroy.ts)_
167
167
 
168
168
  ## `sanity-run blueprints info`
169
169
 
@@ -185,7 +185,7 @@ EXAMPLES
185
185
  $ sanity-run blueprints info --stack-id <stackId>
186
186
  ```
187
187
 
188
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/info.ts)_
188
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/info.ts)_
189
189
 
190
190
  ## `sanity-run blueprints init [DIR]`
191
191
 
@@ -222,7 +222,7 @@ EXAMPLES
222
222
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
223
223
  ```
224
224
 
225
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/init.ts)_
225
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/init.ts)_
226
226
 
227
227
  ## `sanity-run blueprints logs`
228
228
 
@@ -244,7 +244,7 @@ EXAMPLES
244
244
  $ sanity-run blueprints logs --watch
245
245
  ```
246
246
 
247
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/logs.ts)_
247
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/logs.ts)_
248
248
 
249
249
  ## `sanity-run blueprints plan`
250
250
 
@@ -261,7 +261,7 @@ EXAMPLES
261
261
  $ sanity-run blueprints plan
262
262
  ```
263
263
 
264
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/plan.ts)_
264
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/plan.ts)_
265
265
 
266
266
  ## `sanity-run blueprints stacks`
267
267
 
@@ -283,7 +283,7 @@ EXAMPLES
283
283
  $ sanity-run blueprints stacks --project-id <projectId>
284
284
  ```
285
285
 
286
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/blueprints/stacks.ts)_
286
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/blueprints/stacks.ts)_
287
287
 
288
288
  ## `sanity-run functions dev`
289
289
 
@@ -303,7 +303,7 @@ EXAMPLES
303
303
  $ sanity-run functions dev --port 8974
304
304
  ```
305
305
 
306
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/dev.ts)_
306
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/dev.ts)_
307
307
 
308
308
  ## `sanity-run functions env add NAME KEY VALUE`
309
309
 
@@ -325,7 +325,7 @@ EXAMPLES
325
325
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
326
326
  ```
327
327
 
328
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/env/add.ts)_
328
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/env/add.ts)_
329
329
 
330
330
  ## `sanity-run functions env list NAME`
331
331
 
@@ -345,7 +345,7 @@ EXAMPLES
345
345
  $ sanity-run functions env list MyFunction
346
346
  ```
347
347
 
348
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/env/list.ts)_
348
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/env/list.ts)_
349
349
 
350
350
  ## `sanity-run functions env remove NAME KEY`
351
351
 
@@ -366,7 +366,7 @@ EXAMPLES
366
366
  $ sanity-run functions env remove MyFunction API_URL
367
367
  ```
368
368
 
369
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/env/remove.ts)_
369
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/env/remove.ts)_
370
370
 
371
371
  ## `sanity-run functions logs NAME`
372
372
 
@@ -400,7 +400,7 @@ EXAMPLES
400
400
  $ sanity-run functions logs <name> --delete
401
401
  ```
402
402
 
403
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/logs.ts)_
403
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/logs.ts)_
404
404
 
405
405
  ## `sanity-run functions test NAME`
406
406
 
@@ -433,7 +433,7 @@ EXAMPLES
433
433
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
434
434
  ```
435
435
 
436
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.0/src/commands/functions/test.ts)_
436
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v8.0.1/src/commands/functions/test.ts)_
437
437
 
438
438
  ## `sanity-run help [COMMAND]`
439
439
 
@@ -2,13 +2,13 @@ import type { BlueprintParserError, LocalBlueprint, LocalResource } from '../../
2
2
  export { BLUEPRINT_CONFIG_FILE, BLUEPRINT_CONFIG_VERSION, BLUEPRINT_DIR } from '../../config.js';
3
3
  declare const SUPPORTED_FILE_EXTENSIONS: readonly [".json", ".js", ".mjs", ".ts"];
4
4
  type BlueprintFileExtension = (typeof SUPPORTED_FILE_EXTENSIONS)[number];
5
- export declare const DEFAULT_BLUEPRINT_CONTENT: {
5
+ export declare const JSON_BLUEPRINT_CONTENT: {
6
6
  blueprintVersion: string;
7
7
  resources: never[];
8
8
  };
9
- export declare const RESOURCE_TEMPLATE = "import {defineBlueprint} from '@sanity/blueprints'\n\nexport default defineBlueprint({{CONTENT}})\n";
9
+ export declare const TS_BLUEPRINT_CONTENT = "import {defineBlueprint, defineDocumentFunction} from '@sanity/blueprints'\n\nexport default defineBlueprint({\n resources: [\n // defineDocumentFunction({name: 'my-function'}),\n ],\n})\n";
10
10
  export declare const GITIGNORE_FOR_FUNCTIONS = "\n# Sanity Functions\nfunctions/**/.env*\nfunctions/**/.build/\nfunctions/**/node_modules/\n";
11
- export declare const GITIGNORE_TEMPLATE = "\nnode_modules\n.env\n\n# Sanity Functions\nfunctions/**/.env*\nfunctions/**/.build/\nfunctions/**/node_modules/\n\n";
11
+ export declare const GITIGNORE_TEMPLATE = "node_modules\n.env\n\n# Sanity Functions\nfunctions/**/.env*\nfunctions/**/.build/\nfunctions/**/node_modules/\n\n";
12
12
  export type BlueprintModule = ((args?: unknown) => Record<string, unknown>) & {
13
13
  organizationId?: string;
14
14
  projectId?: string;
@@ -46,9 +46,9 @@ export interface ReadBlueprintResult {
46
46
  * @returns Known information about the Blueprint, config, and Stack
47
47
  */
48
48
  export declare function readLocalBlueprint(blueprintPath?: string): Promise<ReadBlueprintResult>;
49
- export declare function writeBlueprintToDisk({ blueprintFilePath, content, }: {
49
+ export declare function writeBlueprintToDisk({ blueprintFilePath, jsonContent, }: {
50
50
  blueprintFilePath: string;
51
- content?: LocalBlueprint;
51
+ jsonContent?: LocalBlueprint;
52
52
  }): string;
53
53
  export declare function writeOrUpdateNodeDependency({ blueprintFilePath, dependency, }: {
54
54
  blueprintFilePath: string;
@@ -10,18 +10,22 @@ import { validateFunctionResource } from '../../utils/validate/resource.js';
10
10
  import { blueprintParserValidator } from '../../utils/vendor/parser-validator.js';
11
11
  export { BLUEPRINT_CONFIG_FILE, BLUEPRINT_CONFIG_VERSION, BLUEPRINT_DIR } from '../../config.js';
12
12
  const SUPPORTED_FILE_EXTENSIONS = ['.json', '.js', '.mjs', '.ts'];
13
- let SUPPORTED_FILE_NAMES_IN_PRIORITY_ORDER = SUPPORTED_FILE_EXTENSIONS.map((ext) => `blueprint${ext}`);
14
- SUPPORTED_FILE_NAMES_IN_PRIORITY_ORDER = [
15
- ...SUPPORTED_FILE_NAMES_IN_PRIORITY_ORDER,
16
- ...SUPPORTED_FILE_NAMES_IN_PRIORITY_ORDER.map((name) => `sanity.${name}`),
13
+ let SUPPORTED_FILE_NAMES = SUPPORTED_FILE_EXTENSIONS.map((ext) => `blueprint${ext}`);
14
+ SUPPORTED_FILE_NAMES = [
15
+ ...SUPPORTED_FILE_NAMES,
16
+ ...SUPPORTED_FILE_NAMES.map((name) => `sanity.${name}`),
17
17
  ];
18
- export const DEFAULT_BLUEPRINT_CONTENT = {
18
+ export const JSON_BLUEPRINT_CONTENT = {
19
19
  blueprintVersion: '2024-10-01',
20
20
  resources: [],
21
21
  };
22
- export const RESOURCE_TEMPLATE = `import {defineBlueprint} from '@sanity/blueprints'
22
+ export const TS_BLUEPRINT_CONTENT = `import {defineBlueprint, defineDocumentFunction} from '@sanity/blueprints'
23
23
 
24
- export default defineBlueprint({{CONTENT}})
24
+ export default defineBlueprint({
25
+ resources: [
26
+ // defineDocumentFunction({name: 'my-function'}),
27
+ ],
28
+ })
25
29
  `;
26
30
  export const GITIGNORE_FOR_FUNCTIONS = `
27
31
  # Sanity Functions
@@ -29,8 +33,7 @@ functions/**/.env*
29
33
  functions/**/.build/
30
34
  functions/**/node_modules/
31
35
  `;
32
- export const GITIGNORE_TEMPLATE = `
33
- node_modules
36
+ export const GITIGNORE_TEMPLATE = `node_modules
34
37
  .env
35
38
  ${GITIGNORE_FOR_FUNCTIONS}
36
39
  `;
@@ -57,7 +60,7 @@ export function findBlueprintFile(blueprintPath) {
57
60
  dirToSearch = blueprintPath;
58
61
  }
59
62
  }
60
- const blueprintFile = findUpSync(SUPPORTED_FILE_NAMES_IN_PRIORITY_ORDER, {
63
+ const blueprintFile = findUpSync(SUPPORTED_FILE_NAMES, {
61
64
  cwd: dirToSearch,
62
65
  type: 'file',
63
66
  allowSymlinks: false,
@@ -165,20 +168,19 @@ export async function readLocalBlueprint(blueprintPath) {
165
168
  parsedBlueprint,
166
169
  };
167
170
  }
168
- export function writeBlueprintToDisk({ blueprintFilePath, content = DEFAULT_BLUEPRINT_CONTENT, }) {
171
+ export function writeBlueprintToDisk({ blueprintFilePath, jsonContent = JSON_BLUEPRINT_CONTENT, }) {
169
172
  const dir = dirname(blueprintFilePath);
170
173
  const extension = extname(blueprintFilePath);
171
174
  let blueprintContent;
172
175
  switch (extension) {
173
176
  case '.json': {
174
- blueprintContent = JSON.stringify(content, null, 2);
177
+ blueprintContent = JSON.stringify(jsonContent, null, 2);
175
178
  break;
176
179
  }
177
180
  case '.js':
178
181
  case '.mjs':
179
182
  case '.ts': {
180
- content.blueprintVersion = undefined; // remove blueprintVersion from content
181
- blueprintContent = RESOURCE_TEMPLATE.replace('{{CONTENT}}', JSON.stringify(content, null, 2));
183
+ blueprintContent = TS_BLUEPRINT_CONTENT;
182
184
  break;
183
185
  }
184
186
  default: {
@@ -5,9 +5,6 @@ import inquirer from 'inquirer';
5
5
  import { createFunctionResource } from '../../actions/blueprints/resources.js';
6
6
  import { validateFunctionName } from '../../utils/validate/resource.js';
7
7
  const FUNCTION_BLUEPRINT_RESOURCE_TEMPLATE = `
8
- import {defineBlueprint, defineDocumentFunction} from '@sanity/blueprints'
9
- // update imports ↑
10
-
11
8
  export default defineBlueprint({
12
9
  // ...
13
10
  resources: [
@@ -54,10 +54,7 @@ export async function blueprintInitCore(options) {
54
54
  }
55
55
  const fileName = `sanity.blueprint.${blueprintExtension}`;
56
56
  const filePath = join(dir, fileName);
57
- writeBlueprintToDisk({
58
- blueprintFilePath: filePath,
59
- // content: {resources: [] /*projectId, stackId*/}, // TODO: in the future maybe set config in blueprint
60
- });
57
+ writeBlueprintToDisk({ blueprintFilePath: filePath });
61
58
  if (providedDir)
62
59
  log(check(`${chalk.bold('New folder created:')} ${providedDir}/`));
63
60
  log(check(`${chalk.bold('Created Blueprint:')} ${providedDir ?? '.'}/${fileName}`));
@@ -84,8 +81,8 @@ export async function blueprintInitCore(options) {
84
81
  if (blueprintExtension !== 'json')
85
82
  nextStepParts.push('npm install');
86
83
  nextStepParts.push(`${bin} blueprints --help`);
87
- const nextStep = `Run \`${nextStepParts.join(' && ')}\``;
88
- log(`\n ${chalk.dim(nextStep)} to get started`);
84
+ const nextStep = `Run ${chalk.bold.magenta(nextStepParts.join(' && '))}`;
85
+ log(`\n ${nextStep} to get started`);
89
86
  return { success: true };
90
87
  }
91
88
  catch (error) {
@@ -838,5 +838,5 @@
838
838
  ]
839
839
  }
840
840
  },
841
- "version": "8.0.0"
841
+ "version": "8.0.1"
842
842
  }
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": "8.0.0",
4
+ "version": "8.0.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",