@sanity/runtime-cli 15.1.1 → 15.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity-run COMMAND
21
21
  running command...
22
22
  $ sanity-run (--version)
23
- @sanity/runtime-cli/15.1.1 linux-x64 node-v24.15.0
23
+ @sanity/runtime-cli/15.1.2 linux-x64 node-v24.15.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -103,7 +103,7 @@ EXAMPLES
103
103
  $ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
104
104
  ```
105
105
 
106
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/add.ts)_
106
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/add.ts)_
107
107
 
108
108
  ## `sanity-run blueprints config`
109
109
 
@@ -140,7 +140,7 @@ EXAMPLES
140
140
  $ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
141
141
  ```
142
142
 
143
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/config.ts)_
143
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/config.ts)_
144
144
 
145
145
  ## `sanity-run blueprints deploy`
146
146
 
@@ -191,7 +191,7 @@ EXAMPLES
191
191
  $ sanity-run blueprints deploy --new-stack-name <new-name>
192
192
  ```
193
193
 
194
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/deploy.ts)_
194
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/deploy.ts)_
195
195
 
196
196
  ## `sanity-run blueprints destroy`
197
197
 
@@ -226,7 +226,7 @@ EXAMPLES
226
226
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
227
227
  ```
228
228
 
229
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/destroy.ts)_
229
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/destroy.ts)_
230
230
 
231
231
  ## `sanity-run blueprints doctor`
232
232
 
@@ -257,7 +257,7 @@ EXAMPLES
257
257
  $ sanity-run blueprints doctor --fix
258
258
  ```
259
259
 
260
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/doctor.ts)_
260
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/doctor.ts)_
261
261
 
262
262
  ## `sanity-run blueprints info`
263
263
 
@@ -294,7 +294,7 @@ EXAMPLES
294
294
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
295
295
  ```
296
296
 
297
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/info.ts)_
297
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/info.ts)_
298
298
 
299
299
  ## `sanity-run blueprints init [DIR]`
300
300
 
@@ -353,7 +353,7 @@ EXAMPLES
353
353
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
354
354
  ```
355
355
 
356
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/init.ts)_
356
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/init.ts)_
357
357
 
358
358
  ## `sanity-run blueprints logs`
359
359
 
@@ -399,7 +399,7 @@ EXAMPLES
399
399
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
400
400
  ```
401
401
 
402
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/logs.ts)_
402
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/logs.ts)_
403
403
 
404
404
  ## `sanity-run blueprints mint-deploy-token`
405
405
 
@@ -444,7 +444,7 @@ EXAMPLES
444
444
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
445
445
  ```
446
446
 
447
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/mint-deploy-token.ts)_
447
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/mint-deploy-token.ts)_
448
448
 
449
449
  ## `sanity-run blueprints plan`
450
450
 
@@ -477,7 +477,7 @@ EXAMPLES
477
477
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
478
478
  ```
479
479
 
480
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/plan.ts)_
480
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/plan.ts)_
481
481
 
482
482
  ## `sanity-run blueprints promote`
483
483
 
@@ -513,7 +513,7 @@ EXAMPLES
513
513
  $ sanity-run blueprints promote --new-stack-name <new-name>
514
514
  ```
515
515
 
516
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/promote.ts)_
516
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/promote.ts)_
517
517
 
518
518
  ## `sanity-run blueprints stacks`
519
519
 
@@ -549,7 +549,7 @@ EXAMPLES
549
549
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
550
550
  ```
551
551
 
552
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/blueprints/stacks.ts)_
552
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/blueprints/stacks.ts)_
553
553
 
554
554
  ## `sanity-run functions add`
555
555
 
@@ -601,7 +601,7 @@ EXAMPLES
601
601
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
602
602
  ```
603
603
 
604
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/add.ts)_
604
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/add.ts)_
605
605
 
606
606
  ## `sanity-run functions dev`
607
607
 
@@ -636,7 +636,7 @@ EXAMPLES
636
636
  $ sanity-run functions dev --timeout 60
637
637
  ```
638
638
 
639
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/dev.ts)_
639
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/dev.ts)_
640
640
 
641
641
  ## `sanity-run functions env add NAME KEY VALUE`
642
642
 
@@ -666,7 +666,7 @@ EXAMPLES
666
666
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
667
667
  ```
668
668
 
669
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/env/add.ts)_
669
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/add.ts)_
670
670
 
671
671
  ## `sanity-run functions env list NAME`
672
672
 
@@ -693,7 +693,7 @@ EXAMPLES
693
693
  $ sanity-run functions env list MyFunction
694
694
  ```
695
695
 
696
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/env/list.ts)_
696
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/list.ts)_
697
697
 
698
698
  ## `sanity-run functions env remove NAME KEY`
699
699
 
@@ -722,7 +722,7 @@ EXAMPLES
722
722
  $ sanity-run functions env remove MyFunction API_URL
723
723
  ```
724
724
 
725
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/env/remove.ts)_
725
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/env/remove.ts)_
726
726
 
727
727
  ## `sanity-run functions logs [NAME]`
728
728
 
@@ -762,7 +762,7 @@ EXAMPLES
762
762
  $ sanity-run functions logs <name> --delete
763
763
  ```
764
764
 
765
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/logs.ts)_
765
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/logs.ts)_
766
766
 
767
767
  ## `sanity-run functions test [NAME]`
768
768
 
@@ -819,7 +819,7 @@ EXAMPLES
819
819
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
820
820
  ```
821
821
 
822
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.1/src/commands/functions/test.ts)_
822
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.1.2/src/commands/functions/test.ts)_
823
823
 
824
824
  ## `sanity-run help [COMMAND]`
825
825
 
@@ -2,6 +2,7 @@ import type { Interfaces } from '@oclif/core';
2
2
  import { Command } from '@oclif/core';
3
3
  import { type ReadBlueprintResult } from './actions/blueprints/blueprint.js';
4
4
  import type { CoreResult } from './cores/index.js';
5
+ import type { Warning } from './utils/blueprints/warnings.js';
5
6
  import type { AuthParams, ScopeType, Stack } from './utils/types.js';
6
7
  export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof RuntimeCommand)['baseFlags'] & T['flags']>;
7
8
  export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
@@ -63,6 +64,10 @@ export declare abstract class RuntimeCommand<T extends typeof Command> extends C
63
64
  protected coreError(result: CoreResult & {
64
65
  success: false;
65
66
  }): never;
67
+ /**
68
+ * Renders any actionable items the user can take that don't warrant throwing an error.
69
+ */
70
+ protected renderWarnings(warnings: Warning[]): void;
66
71
  /**
67
72
  * If an error doesn't have suggestions, match against known patterns to
68
73
  * attach relevant suggestions before oclif renders the error.
@@ -6,6 +6,7 @@ import { resolveIds } from './actions/blueprints/resolve.js';
6
6
  import { getStack, resolveStackIdByNameOrId } from './actions/blueprints/stacks.js';
7
7
  import { presentBlueprintParserErrors } from './utils/display/errors.js';
8
8
  import { Logger } from './utils/logger.js';
9
+ import { styleText } from './utils/style-text.js';
9
10
  import { validTokenOrErrorMessage } from './utils/validated-token.js';
10
11
  /**
11
12
  * Fallback error-to-hint patterns for RuntimeCommand.catch().
@@ -137,6 +138,22 @@ export class RuntimeCommand extends Command {
137
138
  code: result.code,
138
139
  });
139
140
  }
141
+ /**
142
+ * Renders any actionable items the user can take that don't warrant throwing an error.
143
+ */
144
+ renderWarnings(warnings) {
145
+ if (!warnings.length)
146
+ return;
147
+ this.log('');
148
+ this.log(styleText(['bold', 'yellow'], 'Suggestions'));
149
+ this.log('');
150
+ for (const entry of warnings) {
151
+ entry.suggestions.forEach((sug) => {
152
+ this.log(` ${styleText('dim', sug)}`);
153
+ });
154
+ this.log('');
155
+ }
156
+ }
140
157
  /**
141
158
  * If an error doesn't have suggestions, match against known patterns to
142
159
  * attach relevant suggestions before oclif renders the error.
@@ -36,6 +36,8 @@ Run this command when encountering errors with other Blueprint commands. Use --f
36
36
  });
37
37
  if (!result.success)
38
38
  this.coreError(result);
39
+ if (result.warnings)
40
+ this.renderWarnings(result?.warnings);
39
41
  return result.json;
40
42
  }
41
43
  }
@@ -1,4 +1,5 @@
1
1
  import { readFileSync } from 'node:fs';
2
+ import { dirname } from 'node:path';
2
3
  import { arch, cwd, env, version as nodeVersion, platform } from 'node:process';
3
4
  import * as resolve from 'empathic/resolve';
4
5
  import ora from 'ora';
@@ -7,8 +8,9 @@ import { readConfigFile } from '../../actions/blueprints/config.js';
7
8
  import { resolveIds } from '../../actions/blueprints/resolve.js';
8
9
  import { getStack } from '../../actions/blueprints/stacks.js';
9
10
  import config, { RUNTIME_CLI_VERSION } from '../../config.js';
11
+ import { getWarnings } from '../../utils/blueprints/warnings.js';
10
12
  import { formatDateTime } from '../../utils/display/dates.js';
11
- import { check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
13
+ import { advise, check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
12
14
  import { styleText } from '../../utils/style-text.js';
13
15
  import { createTracedFetch } from '../../utils/traced-fetch.js';
14
16
  import { validTokenOrErrorMessage } from '../../utils/validated-token.js';
@@ -20,6 +22,9 @@ const diagLookup = {
20
22
  stackReady: 'Stack ready',
21
23
  userHasAccess: 'User has access',
22
24
  };
25
+ const warnLookup = {
26
+ projectLayout: 'Project layout',
27
+ };
23
28
  function sourceLabel(source) {
24
29
  switch (source) {
25
30
  case 'env':
@@ -42,6 +47,7 @@ export async function blueprintDoctorCore(options) {
42
47
  for (const key in diagLookup) {
43
48
  diagnostics[key] = { status: null };
44
49
  }
50
+ const warningDiagnostics = {};
45
51
  const envRows = [['Directory', p ? filePathRelativeToCwd(path) : path]];
46
52
  if (bin && bin !== 'sanity')
47
53
  envRows.push(['CLI', bin]);
@@ -234,6 +240,21 @@ export async function blueprintDoctorCore(options) {
234
240
  diagnostics.userHasAccess = { status: null, detail };
235
241
  }
236
242
  }
243
+ for (const key in warnLookup) {
244
+ warningDiagnostics[key] = { status: null };
245
+ }
246
+ // LAYOUT ISSUES; IE Functions in Studio
247
+ let layoutWarnings = [];
248
+ if (localBlueprint) {
249
+ const blueprintDir = dirname(localBlueprint.fileInfo.blueprintFilePath || '.');
250
+ layoutWarnings = getWarnings({ dir: blueprintDir });
251
+ if (layoutWarnings.length) {
252
+ warningDiagnostics.projectLayout = {
253
+ status: true,
254
+ detail: 'Blueprint config in the Studio dir',
255
+ };
256
+ }
257
+ }
237
258
  // --- RENDER REPORT ---
238
259
  spinner.stop();
239
260
  // Environment (verbose)
@@ -270,6 +291,20 @@ export async function blueprintDoctorCore(options) {
270
291
  break;
271
292
  }
272
293
  }
294
+ let hasWarnings = false;
295
+ if (Object.values(warningDiagnostics).some((entry) => entry.status === true)) {
296
+ hasWarnings = true;
297
+ const maxLabel = Math.max(...Object.values(warnLookup).map((l) => l.length));
298
+ log(styleText('bold', 'Warnings'));
299
+ for (const [key, entry] of Object.entries(warningDiagnostics)) {
300
+ if (entry.status) {
301
+ const label = warnLookup[key].padEnd(maxLabel);
302
+ const detail = entry.detail ? ` ${styleText('dim', entry.detail)}` : '';
303
+ log(` ${advise(label)}${detail}`);
304
+ }
305
+ }
306
+ log('');
307
+ }
273
308
  // Result
274
309
  const flatDiagnostics = {};
275
310
  for (const [key, entry] of Object.entries(diagnostics)) {
@@ -285,6 +320,7 @@ export async function blueprintDoctorCore(options) {
285
320
  success: true,
286
321
  json: { diagnostics: flatDiagnostics },
287
322
  data: { diagnostics: flatDiagnostics },
323
+ warnings: hasWarnings ? layoutWarnings : undefined,
288
324
  };
289
325
  }
290
326
  if (fix) {
@@ -319,7 +355,7 @@ export async function blueprintDoctorCore(options) {
319
355
  data: { diagnostics: flatDiagnostics },
320
356
  };
321
357
  }
322
- return blueprintConfigCore({
358
+ const fixResult = await blueprintConfigCore({
323
359
  bin,
324
360
  log,
325
361
  token: tokenOrError.value,
@@ -327,6 +363,10 @@ export async function blueprintDoctorCore(options) {
327
363
  validateResources,
328
364
  flags: { edit: true, verbose: v },
329
365
  });
366
+ if (fixResult.success) {
367
+ return { ...fixResult, warnings: hasWarnings ? layoutWarnings : undefined };
368
+ }
369
+ return fixResult;
330
370
  }
331
371
  return {
332
372
  success: false,
@@ -1,4 +1,5 @@
1
1
  import { type ReadBlueprintResult } from '../actions/blueprints/blueprint.js';
2
+ import type { Warning } from '../utils/blueprints/warnings.js';
2
3
  import type { Logger } from '../utils/logger.js';
3
4
  import type { AuthParams, Result, ScopeType, Stack } from '../utils/types.js';
4
5
  export interface CoreConfig {
@@ -52,6 +53,10 @@ export type CoreResult = {
52
53
  * Commands should return this value from `run()` for oclif to serialize.
53
54
  */
54
55
  json?: Record<string, unknown>;
56
+ /**
57
+ * Actionable items displayed to the user that we don't error out on.
58
+ */
59
+ warnings?: Warning[];
55
60
  });
56
61
  type InitBlueprintConfigParams = CoreConfig & ({
57
62
  validateToken: true;
@@ -0,0 +1,19 @@
1
+ export type Warning = {
2
+ label: string;
3
+ suggestions: string[];
4
+ };
5
+ export type WarningContext = {
6
+ dir: string;
7
+ };
8
+ export type WarningEntryCheck = {
9
+ label: string;
10
+ suggestions: string[];
11
+ check: (ctx: WarningContext) => boolean;
12
+ };
13
+ /**
14
+ * Checks if the given directory contains files Sanity Studio specific files.
15
+ * Directory is either the cwd where `init` is run or during the `doctor` command
16
+ */
17
+ export declare const isStudioDir: (filePath: string) => boolean;
18
+ export declare const warningCheck: WarningEntryCheck[];
19
+ export declare const getWarnings: (ctx: WarningContext) => Warning[];
@@ -0,0 +1,36 @@
1
+ import { readdirSync } from 'node:fs';
2
+ import { resolve } from 'node:path';
3
+ /**
4
+ * Checks if the given directory contains files Sanity Studio specific files.
5
+ * Directory is either the cwd where `init` is run or during the `doctor` command
6
+ */
7
+ export const isStudioDir = (filePath) => {
8
+ try {
9
+ const dir = resolve(filePath);
10
+ return readdirSync(dir, { withFileTypes: true }).some((entry) => {
11
+ if (entry.isFile()) {
12
+ return entry.name.startsWith('sanity.config') || entry.name.startsWith('sanity.cli');
13
+ }
14
+ return false;
15
+ });
16
+ }
17
+ catch (_err) {
18
+ return false;
19
+ }
20
+ };
21
+ export const warningCheck = [
22
+ {
23
+ label: 'Project layout',
24
+ suggestions: [
25
+ 'A Blueprints file is co-located with a Sanity Studio. Please see the docs for better layout options',
26
+ // @todo: this will need to updated once the layout is published.
27
+ 'https://www.sanity.io/docs/blueprints/blueprints-introduction#aaeea93bdd42',
28
+ ],
29
+ check: ({ dir }) => isStudioDir(dir),
30
+ },
31
+ ];
32
+ export const getWarnings = (ctx) => {
33
+ return warningCheck
34
+ .filter(({ check }) => check(ctx))
35
+ .map(({ label, suggestions }) => ({ label, suggestions }));
36
+ };
@@ -1,6 +1,7 @@
1
1
  export declare function check(str: string): string;
2
2
  export declare function info(str: string): string;
3
3
  export declare function warn(str: string): string;
4
+ export declare function advise(str: string): string;
4
5
  export declare function unsure(str: string): string;
5
6
  export declare function severe(str: string): string;
6
7
  export declare function niceId(id: string | undefined): string;
@@ -9,6 +9,9 @@ export function info(str) {
9
9
  export function warn(str) {
10
10
  return `${styleText(['bold', 'yellow'], '▶︎')} ${str}`;
11
11
  }
12
+ export function advise(str) {
13
+ return `${styleText(['bold', 'yellow'], '!')} ${str}`;
14
+ }
12
15
  export function unsure(str) {
13
16
  return `${styleText(['bold', 'cyan'], '?')} ${str}`;
14
17
  }
@@ -2998,5 +2998,5 @@
2998
2998
  ]
2999
2999
  }
3000
3000
  },
3001
- "version": "15.1.1"
3001
+ "version": "15.1.2"
3002
3002
  }
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": "15.1.1",
4
+ "version": "15.1.2",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",