@sanity/runtime-cli 15.0.0 → 15.0.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.0.0 linux-x64 node-v24.14.1
23
+ @sanity/runtime-cli/15.0.2 linux-x64 node-v24.14.1
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.0.0/src/commands/blueprints/add.ts)_
106
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.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.0.0/src/commands/blueprints/config.ts)_
143
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.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.0.0/src/commands/blueprints/deploy.ts)_
194
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.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.0.0/src/commands/blueprints/destroy.ts)_
229
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.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.0.0/src/commands/blueprints/doctor.ts)_
260
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.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.0.0/src/commands/blueprints/info.ts)_
297
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/info.ts)_
298
298
 
299
299
  ## `sanity-run blueprints init [DIR]`
300
300
 
@@ -345,7 +345,7 @@ EXAMPLES
345
345
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --stack-name <stackName>
346
346
  ```
347
347
 
348
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/init.ts)_
348
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/init.ts)_
349
349
 
350
350
  ## `sanity-run blueprints logs`
351
351
 
@@ -391,7 +391,7 @@ EXAMPLES
391
391
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
392
392
  ```
393
393
 
394
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/logs.ts)_
394
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/logs.ts)_
395
395
 
396
396
  ## `sanity-run blueprints mint-deploy-token`
397
397
 
@@ -436,7 +436,7 @@ EXAMPLES
436
436
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
437
437
  ```
438
438
 
439
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/mint-deploy-token.ts)_
439
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/mint-deploy-token.ts)_
440
440
 
441
441
  ## `sanity-run blueprints plan`
442
442
 
@@ -469,7 +469,7 @@ EXAMPLES
469
469
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
470
470
  ```
471
471
 
472
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/plan.ts)_
472
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/plan.ts)_
473
473
 
474
474
  ## `sanity-run blueprints promote`
475
475
 
@@ -505,7 +505,7 @@ EXAMPLES
505
505
  $ sanity-run blueprints promote --new-stack-name <new-name>
506
506
  ```
507
507
 
508
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/promote.ts)_
508
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/promote.ts)_
509
509
 
510
510
  ## `sanity-run blueprints stacks`
511
511
 
@@ -541,7 +541,7 @@ EXAMPLES
541
541
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
542
542
  ```
543
543
 
544
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/blueprints/stacks.ts)_
544
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/blueprints/stacks.ts)_
545
545
 
546
546
  ## `sanity-run functions add`
547
547
 
@@ -593,7 +593,7 @@ EXAMPLES
593
593
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
594
594
  ```
595
595
 
596
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/add.ts)_
596
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/add.ts)_
597
597
 
598
598
  ## `sanity-run functions dev`
599
599
 
@@ -628,7 +628,7 @@ EXAMPLES
628
628
  $ sanity-run functions dev --timeout 60
629
629
  ```
630
630
 
631
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/dev.ts)_
631
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/dev.ts)_
632
632
 
633
633
  ## `sanity-run functions env add NAME KEY VALUE`
634
634
 
@@ -658,7 +658,7 @@ EXAMPLES
658
658
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
659
659
  ```
660
660
 
661
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/env/add.ts)_
661
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/env/add.ts)_
662
662
 
663
663
  ## `sanity-run functions env list NAME`
664
664
 
@@ -685,7 +685,7 @@ EXAMPLES
685
685
  $ sanity-run functions env list MyFunction
686
686
  ```
687
687
 
688
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/env/list.ts)_
688
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/env/list.ts)_
689
689
 
690
690
  ## `sanity-run functions env remove NAME KEY`
691
691
 
@@ -714,7 +714,7 @@ EXAMPLES
714
714
  $ sanity-run functions env remove MyFunction API_URL
715
715
  ```
716
716
 
717
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/env/remove.ts)_
717
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/env/remove.ts)_
718
718
 
719
719
  ## `sanity-run functions logs [NAME]`
720
720
 
@@ -754,7 +754,7 @@ EXAMPLES
754
754
  $ sanity-run functions logs <name> --delete
755
755
  ```
756
756
 
757
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/logs.ts)_
757
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/logs.ts)_
758
758
 
759
759
  ## `sanity-run functions test [NAME]`
760
760
 
@@ -811,7 +811,7 @@ EXAMPLES
811
811
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
812
812
  ```
813
813
 
814
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.0/src/commands/functions/test.ts)_
814
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.0.2/src/commands/functions/test.ts)_
815
815
 
816
816
  ## `sanity-run help [COMMAND]`
817
817
 
@@ -11,5 +11,6 @@ export interface BlueprintMintDeployTokenOptions extends CoreConfig {
11
11
  verbose?: boolean;
12
12
  };
13
13
  }
14
+ export declare function isRoleUnavailableError(error: string): boolean;
14
15
  export declare function defaultLabel(scopeType: ScopeType): string;
15
16
  export declare function blueprintMintDeployTokenCore(options: BlueprintMintDeployTokenOptions): Promise<CoreResult>;
@@ -7,6 +7,10 @@ const ROLE_BY_SCOPE = {
7
7
  project: 'blueprints-deployer',
8
8
  organization: 'blueprints-deployer-robot',
9
9
  };
10
+ // Matches Access API's "Role not found: <name>" 404 message.
11
+ export function isRoleUnavailableError(error) {
12
+ return /^\s*role not found\b/i.test(error);
13
+ }
10
14
  export function defaultLabel(scopeType) {
11
15
  const date = new Date().toISOString().slice(0, 10);
12
16
  let host = 'unknown-host';
@@ -33,6 +37,14 @@ export async function blueprintMintDeployTokenCore(options) {
33
37
  });
34
38
  if (!ok || !robot) {
35
39
  spinner.fail('Failed to mint deploy token');
40
+ if (error && isRoleUnavailableError(error)) {
41
+ return {
42
+ success: false,
43
+ error: `The "${roleName}" role is not available in this ${scopeType}.`,
44
+ code: 'ROLE_UNAVAILABLE',
45
+ suggestions: [],
46
+ };
47
+ }
36
48
  const suggestions = [];
37
49
  if (error && /access|permission|forbidden|role/i.test(error)) {
38
50
  suggestions.push(scopeType === 'organization'
@@ -72,7 +72,16 @@ export function formatLogEntry(log, verbose = false, previousLog) {
72
72
  return line;
73
73
  }
74
74
  export function formatLogs(logs, verbose = false) {
75
- const sorted = [...logs].sort((a, b) => new Date(a.timestamp).getTime() - new Date(b.timestamp).getTime());
75
+ const sorted = [...logs].sort((a, b) => {
76
+ const aTime = new Date(a.timestamp).getTime();
77
+ const bTime = new Date(b.timestamp).getTime();
78
+ const diff = aTime - bTime;
79
+ if (diff !== 0)
80
+ return diff;
81
+ const aSeq = Number.parseInt(a.seq, 10);
82
+ const bSeq = Number.parseInt(b.seq, 10);
83
+ return aSeq - bSeq;
84
+ });
76
85
  return sorted
77
86
  .map((log, i) => formatLogEntry(log, verbose, sorted[i - 1]))
78
87
  .join('\n');
@@ -4,6 +4,7 @@ export declare const errorMessage: (elements: string[]) => string;
4
4
  * Scan the given path. Flag any packages that contain files matching known native module patterns, and return a list of their names.
5
5
  */
6
6
  export declare const detectNativeModules: (nodeModules: string) => string[];
7
+ export declare const findPackageDir: (pathName: string) => string | null;
7
8
  /**
8
9
  * A vite plugin that compares resolved deps of a function against known native module patterns, and throws an error if any are found.
9
10
  */
@@ -59,14 +59,20 @@ export const detectNativeModules = (nodeModules) => {
59
59
  });
60
60
  return packages.filter(({ dir }) => hasNativeFiles(dir)).map(({ name }) => name);
61
61
  };
62
- const findPackageDir = (pathName) => {
62
+ export const findPackageDir = (pathName) => {
63
+ if (!path.isAbsolute(pathName))
64
+ return null;
63
65
  let currentDir = path.dirname(pathName);
64
66
  while (currentDir !== path.parse(currentDir).root) {
65
67
  // look for node_module package.json to locate top level
66
68
  if (existsSync(path.join(currentDir, 'package.json'))) {
67
69
  return currentDir;
68
70
  }
69
- currentDir = path.dirname(currentDir);
71
+ const parent = path.dirname(currentDir);
72
+ // guard against infinite loop, especially if relative paths are being used ie: '.'
73
+ if (parent === currentDir)
74
+ return null;
75
+ currentDir = parent;
70
76
  }
71
77
  return null;
72
78
  };
@@ -1,4 +1,5 @@
1
1
  import type { FunctionResource, InstallerType } from '../types.js';
2
+ export declare const resolveViteRoot: (entry: string) => string;
2
3
  export declare function transpileFunction(resource: FunctionResource, { installer }?: {
3
4
  installer?: InstallerType;
4
5
  }): Promise<{
@@ -10,6 +10,10 @@ import { findFunctionEntryPoint } from '../functions/find-entry-point.js';
10
10
  import { createPnpmRequire } from '../pnpm.js';
11
11
  import { cleanupSourceMaps } from './cleanup-source-maps.js';
12
12
  import { verifyHandler } from './verify-handler.js';
13
+ export const resolveViteRoot = (entry) => {
14
+ const nodeModulesDir = find.dir('node_modules', { cwd: entry });
15
+ return nodeModulesDir ? path.dirname(nodeModulesDir) : entry;
16
+ };
13
17
  export async function transpileFunction(resource, { installer } = {}) {
14
18
  if (!resource.src)
15
19
  throw new Error('Resource src is required');
@@ -27,7 +31,7 @@ export async function transpileFunction(resource, { installer } = {}) {
27
31
  const outputPathStart = performance.now();
28
32
  const outputDir = await getTranspileOutputPath(entryDir, resource.name);
29
33
  const outputFile = path.join(outputDir, getOutputFilename(entry));
30
- const fnRootDir = find.dir('node_modules', { cwd: entryDir }) ?? entryDir;
34
+ const fnRootDir = resolveViteRoot(entryDir);
31
35
  timings['transpile:setupOutput'] = performance.now() - outputPathStart;
32
36
  async function cleanupTmpDir() {
33
37
  // Feel a certain way about leaving things uncleaned, but helps with debugging for now
@@ -167,6 +167,9 @@ export interface BlueprintLog {
167
167
  operationId: string;
168
168
  resourceId: string | null;
169
169
  requestId: string | null;
170
+ scopeType: ScopeType;
171
+ scopeId: string;
172
+ seq: string;
170
173
  }
171
174
  /** @internal */
172
175
  export interface FunctionLog {
@@ -2994,5 +2994,5 @@
2994
2994
  ]
2995
2995
  }
2996
2996
  },
2997
- "version": "15.0.0"
2997
+ "version": "15.0.2"
2998
2998
  }
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.0.0",
4
+ "version": "15.0.2",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",