@sanity/runtime-cli 15.2.0 → 16.0.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 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.2.0 linux-x64 node-v24.16.0
23
+ @sanity/runtime-cli/16.0.0 linux-x64 node-v24.16.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.2.0/src/commands/blueprints/add.ts)_
106
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/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.2.0/src/commands/blueprints/config.ts)_
143
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/config.ts)_
144
144
 
145
145
  ## `sanity-run blueprints deploy`
146
146
 
@@ -194,7 +194,7 @@ EXAMPLES
194
194
  $ sanity-run blueprints deploy --new-stack-name <new-name>
195
195
  ```
196
196
 
197
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/deploy.ts)_
197
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/deploy.ts)_
198
198
 
199
199
  ## `sanity-run blueprints destroy`
200
200
 
@@ -232,7 +232,7 @@ EXAMPLES
232
232
  $ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
233
233
  ```
234
234
 
235
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/destroy.ts)_
235
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/destroy.ts)_
236
236
 
237
237
  ## `sanity-run blueprints doctor`
238
238
 
@@ -263,7 +263,7 @@ EXAMPLES
263
263
  $ sanity-run blueprints doctor --fix
264
264
  ```
265
265
 
266
- _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/doctor.ts)_
266
+ _See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/doctor.ts)_
267
267
 
268
268
  ## `sanity-run blueprints info`
269
269
 
@@ -300,7 +300,7 @@ EXAMPLES
300
300
  $ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
301
301
  ```
302
302
 
303
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/info.ts)_
303
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/info.ts)_
304
304
 
305
305
  ## `sanity-run blueprints init [DIR]`
306
306
 
@@ -359,7 +359,7 @@ EXAMPLES
359
359
  $ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
360
360
  ```
361
361
 
362
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/init.ts)_
362
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/init.ts)_
363
363
 
364
364
  ## `sanity-run blueprints logs`
365
365
 
@@ -405,7 +405,7 @@ EXAMPLES
405
405
  $ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
406
406
  ```
407
407
 
408
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/logs.ts)_
408
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/logs.ts)_
409
409
 
410
410
  ## `sanity-run blueprints mint-deploy-token`
411
411
 
@@ -450,7 +450,7 @@ EXAMPLES
450
450
  $ sanity-run blueprints mint-deploy-token --organization-id <orgId>
451
451
  ```
452
452
 
453
- _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/mint-deploy-token.ts)_
453
+ _See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/mint-deploy-token.ts)_
454
454
 
455
455
  ## `sanity-run blueprints plan`
456
456
 
@@ -483,7 +483,7 @@ EXAMPLES
483
483
  $ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
484
484
  ```
485
485
 
486
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/plan.ts)_
486
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/plan.ts)_
487
487
 
488
488
  ## `sanity-run blueprints promote`
489
489
 
@@ -519,7 +519,7 @@ EXAMPLES
519
519
  $ sanity-run blueprints promote --new-stack-name <new-name>
520
520
  ```
521
521
 
522
- _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/promote.ts)_
522
+ _See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/promote.ts)_
523
523
 
524
524
  ## `sanity-run blueprints stacks`
525
525
 
@@ -555,7 +555,7 @@ EXAMPLES
555
555
  $ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
556
556
  ```
557
557
 
558
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/blueprints/stacks.ts)_
558
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/blueprints/stacks.ts)_
559
559
 
560
560
  ## `sanity-run functions add`
561
561
 
@@ -607,7 +607,7 @@ EXAMPLES
607
607
  $ sanity-run functions add --name my-function --type document-create --type document-update --lang js
608
608
  ```
609
609
 
610
- _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/add.ts)_
610
+ _See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/add.ts)_
611
611
 
612
612
  ## `sanity-run functions dev`
613
613
 
@@ -642,7 +642,7 @@ EXAMPLES
642
642
  $ sanity-run functions dev --timeout 60
643
643
  ```
644
644
 
645
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/dev.ts)_
645
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/dev.ts)_
646
646
 
647
647
  ## `sanity-run functions env add NAME KEY VALUE`
648
648
 
@@ -672,7 +672,7 @@ EXAMPLES
672
672
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
673
673
  ```
674
674
 
675
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/env/add.ts)_
675
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/env/add.ts)_
676
676
 
677
677
  ## `sanity-run functions env list NAME`
678
678
 
@@ -699,7 +699,7 @@ EXAMPLES
699
699
  $ sanity-run functions env list MyFunction
700
700
  ```
701
701
 
702
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/env/list.ts)_
702
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/env/list.ts)_
703
703
 
704
704
  ## `sanity-run functions env remove NAME KEY`
705
705
 
@@ -728,7 +728,7 @@ EXAMPLES
728
728
  $ sanity-run functions env remove MyFunction API_URL
729
729
  ```
730
730
 
731
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/env/remove.ts)_
731
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/env/remove.ts)_
732
732
 
733
733
  ## `sanity-run functions logs [NAME]`
734
734
 
@@ -768,7 +768,7 @@ EXAMPLES
768
768
  $ sanity-run functions logs <name> --delete
769
769
  ```
770
770
 
771
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/logs.ts)_
771
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/logs.ts)_
772
772
 
773
773
  ## `sanity-run functions test [NAME]`
774
774
 
@@ -825,7 +825,7 @@ EXAMPLES
825
825
  $ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
826
826
  ```
827
827
 
828
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v15.2.0/src/commands/functions/test.ts)_
828
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v16.0.0/src/commands/functions/test.ts)_
829
829
 
830
830
  ## `sanity-run help [COMMAND]`
831
831
 
@@ -16,16 +16,26 @@ export async function getLogs(params, auth, logger) {
16
16
  url.searchParams.append('before', params.before);
17
17
  if (params.after)
18
18
  url.searchParams.append('after', params.after);
19
- const response = await fetchFn(url.toString(), {
20
- headers: getHeaders(auth),
21
- method: 'GET',
22
- });
23
- const result = await response.json();
24
- const hasMore = response.headers.get('X-Has-More') === 'true';
25
- return {
26
- ok: response.ok,
27
- error: response.ok ? null : result.message || 'Unknown error',
28
- logs: response.ok ? result : [],
29
- hasMore: response.ok ? hasMore : false,
30
- };
19
+ try {
20
+ const response = await fetchFn(url.toString(), {
21
+ headers: getHeaders(auth),
22
+ method: 'GET',
23
+ });
24
+ const result = await response.json();
25
+ const hasMore = response.headers.get('X-Has-More') === 'true';
26
+ return {
27
+ ok: response.ok,
28
+ error: response.ok ? null : result.message || 'Unknown error',
29
+ logs: response.ok ? result : [],
30
+ hasMore: response.ok ? hasMore : false,
31
+ };
32
+ }
33
+ catch (error) {
34
+ return {
35
+ ok: false,
36
+ error: error instanceof Error ? error.message : String(error),
37
+ logs: [],
38
+ hasMore: false,
39
+ };
40
+ }
31
41
  }
@@ -17,7 +17,7 @@ export declare function classifyOperationPoll(options: {
17
17
  operation: StackOperation | undefined;
18
18
  }): 'pending' | 'completed' | 'failed' | 'error';
19
19
  interface GetOperationResponse extends ActionResponse {
20
- operation: StackOperation;
20
+ operation?: StackOperation;
21
21
  response?: Response;
22
22
  }
23
23
  export declare function getOperation({ stackId, operationId, auth, logger, includeDestroyed, }: {
@@ -36,15 +36,23 @@ export async function getOperation({ stackId, operationId, auth, logger, include
36
36
  const url = new URL(`${stacksUrl}/${stackId}/operations/${operationId}`);
37
37
  if (includeDestroyed)
38
38
  url.searchParams.append('includeDestroyed', 'true');
39
- const response = await fetchFn(url.toString(), {
40
- method: 'GET',
41
- headers: getHeaders(auth),
42
- });
43
- const data = await response.json();
44
- return {
45
- ok: response.ok,
46
- error: response.ok ? null : data.message,
47
- operation: data,
48
- response,
49
- };
39
+ try {
40
+ const response = await fetchFn(url.toString(), {
41
+ method: 'GET',
42
+ headers: getHeaders(auth),
43
+ });
44
+ const data = await response.json();
45
+ return {
46
+ ok: response.ok,
47
+ error: response.ok ? null : data.message,
48
+ operation: data,
49
+ response,
50
+ };
51
+ }
52
+ catch (error) {
53
+ return {
54
+ ok: false,
55
+ error: error instanceof Error ? error.message : String(error),
56
+ };
57
+ }
50
58
  }
@@ -1,6 +1,6 @@
1
1
  import type { Blueprint } from '@sanity/blueprints-parser';
2
2
  import type { Logger } from '../../utils/logger.js';
3
- import type { ActionResponse, AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
3
+ import type { AuthParams, ScopeType, Stack, StackMutation, StackSummary } from '../../utils/types.js';
4
4
  export declare const stacksUrl: string;
5
5
  type ListStacksResponse = {
6
6
  ok: true;
@@ -9,21 +9,26 @@ type ListStacksResponse = {
9
9
  } | {
10
10
  ok: false;
11
11
  error: string;
12
- stacks: unknown;
12
+ stacks?: unknown;
13
13
  };
14
14
  export declare function listStacks(auth: AuthParams, logger: Logger): Promise<ListStacksResponse>;
15
- interface GetStackResponse extends ActionResponse {
15
+ type GetStackResponse = {
16
+ ok: true;
17
+ error: null;
16
18
  stack: Stack;
17
19
  response?: Response;
18
- }
20
+ } | {
21
+ ok: false;
22
+ error: string;
23
+ stack?: unknown;
24
+ response?: Response;
25
+ };
19
26
  export declare function getStack({ stackId, auth, logger, }: {
20
27
  stackId: string;
21
28
  auth: AuthParams;
22
29
  logger: Logger;
23
30
  }): Promise<GetStackResponse>;
24
- interface CreateStackResponse extends ActionResponse {
25
- stack: Stack;
26
- }
31
+ type CreateStackResponse = GetStackResponse;
27
32
  export declare function createStack({ stackMutation, auth, logger, }: {
28
33
  stackMutation: StackMutation;
29
34
  auth: AuthParams;
@@ -36,11 +41,17 @@ export declare function createEmptyStack({ token, scopeType, scopeId, name, logg
36
41
  name: string;
37
42
  logger: Logger;
38
43
  }): Promise<Stack>;
39
- interface UpdateStackResponse extends ActionResponse {
44
+ type UpdateStackResponse = {
45
+ ok: true;
46
+ error: null;
40
47
  stack: Stack & {
41
48
  operationId: string;
42
49
  };
43
- }
50
+ } | {
51
+ ok: false;
52
+ error: string;
53
+ stack?: unknown;
54
+ };
44
55
  export declare function updateStack({ stackId, stackMutation, auth, logger, }: {
45
56
  stackId: string;
46
57
  stackMutation: StackMutation;
@@ -97,24 +108,27 @@ export declare function planStack({ stackId, document, auth, logger, }: {
97
108
  auth: AuthParams;
98
109
  logger: Logger;
99
110
  }): Promise<PlanStackResponse>;
100
- interface DestroyStackResponse extends ActionResponse {
101
- stack: Stack & {
102
- operationId: string;
103
- };
104
- }
105
111
  export declare function resolveStackIdByNameOrId(value: string, auth: AuthParams, logger: Logger): Promise<string>;
106
- interface PromoteStackResponse extends ActionResponse {
112
+ type PromoteStackResponse = {
113
+ ok: true;
114
+ error: null;
107
115
  stack: Stack & {
108
116
  alreadyPromoted: boolean;
109
117
  };
110
118
  response?: Response;
111
- }
119
+ } | {
120
+ ok: false;
121
+ error: string;
122
+ stack?: unknown;
123
+ response?: Response;
124
+ };
112
125
  export declare function promoteStack({ stackId, auth, logger, name, }: {
113
126
  stackId: string;
114
127
  auth: AuthParams;
115
128
  logger: Logger;
116
129
  name?: string;
117
130
  }): Promise<PromoteStackResponse>;
131
+ type DestroyStackResponse = UpdateStackResponse;
118
132
  export declare function destroyStack({ stackId, auth, logger, }: {
119
133
  stackId: string;
120
134
  auth: AuthParams;
@@ -5,44 +5,69 @@ const { apiUrl } = config;
5
5
  export const stacksUrl = `${apiUrl}vX/blueprints/stacks`;
6
6
  export async function listStacks(auth, logger) {
7
7
  const fetchFn = createTracedFetch(logger);
8
- const response = await fetchFn(stacksUrl, {
9
- method: 'GET',
10
- headers: getHeaders(auth),
11
- });
12
- const data = await response.json();
13
- return {
14
- ok: response.ok,
15
- error: response.ok ? null : data.message,
16
- stacks: data,
17
- };
8
+ try {
9
+ const response = await fetchFn(stacksUrl, {
10
+ method: 'GET',
11
+ headers: getHeaders(auth),
12
+ });
13
+ const data = await response.json();
14
+ return {
15
+ ok: response.ok,
16
+ error: response.ok ? null : data.message,
17
+ stacks: data,
18
+ };
19
+ }
20
+ catch (error) {
21
+ return {
22
+ ok: false,
23
+ error: error instanceof Error ? error.message : String(error),
24
+ };
25
+ }
18
26
  }
19
27
  export async function getStack({ stackId, auth, logger, }) {
20
28
  const fetchFn = createTracedFetch(logger);
21
- const response = await fetchFn(`${stacksUrl}/${stackId}`, {
22
- method: 'GET',
23
- headers: getHeaders(auth),
24
- });
25
- const data = await response.json();
26
- return {
27
- ok: response.ok,
28
- error: response.ok ? null : data.message,
29
- stack: data,
30
- response,
31
- };
29
+ try {
30
+ const response = await fetchFn(`${stacksUrl}/${stackId}`, {
31
+ method: 'GET',
32
+ headers: getHeaders(auth),
33
+ });
34
+ const data = await response.json();
35
+ return {
36
+ ok: response.ok,
37
+ error: response.ok ? null : data.message,
38
+ stack: data,
39
+ response,
40
+ };
41
+ }
42
+ catch (error) {
43
+ return {
44
+ ok: false,
45
+ error: error instanceof Error ? error.message : String(error),
46
+ };
47
+ }
32
48
  }
33
49
  export async function createStack({ stackMutation, auth, logger, }) {
34
- const fetchFn = createTracedFetch(logger);
35
- const response = await fetchFn(stacksUrl, {
36
- method: 'POST',
37
- headers: getHeaders(auth),
38
- body: JSON.stringify({ ...stackMutation, useProjectBasedId: false }), // API defaults to true as of 2025-11-26
39
- });
40
- const data = await response.json();
41
- return {
42
- ok: response.ok,
43
- error: response.ok ? null : data.message,
44
- stack: data,
45
- };
50
+ try {
51
+ const fetchFn = createTracedFetch(logger);
52
+ const response = await fetchFn(stacksUrl, {
53
+ method: 'POST',
54
+ headers: getHeaders(auth),
55
+ body: JSON.stringify({ ...stackMutation, useProjectBasedId: false }), // API defaults to true as of 2025-11-26
56
+ });
57
+ const data = await response.json();
58
+ return {
59
+ ok: response.ok,
60
+ error: response.ok ? null : data.message,
61
+ stack: data,
62
+ response,
63
+ };
64
+ }
65
+ catch (error) {
66
+ return {
67
+ ok: false,
68
+ error: error instanceof Error ? error.message : String(error),
69
+ };
70
+ }
46
71
  }
47
72
  export async function createEmptyStack({ token, scopeType, scopeId, name, logger, }) {
48
73
  if (!scopeId) {
@@ -69,40 +94,58 @@ export async function createEmptyStack({ token, scopeType, scopeId, name, logger
69
94
  }
70
95
  export async function updateStack({ stackId, stackMutation, auth, logger, }) {
71
96
  const fetchFn = createTracedFetch(logger);
72
- const response = await fetchFn(`${stacksUrl}/${stackId}`, {
73
- method: 'PUT',
74
- headers: getHeaders(auth),
75
- body: JSON.stringify(stackMutation),
76
- });
77
- const data = await response.json();
78
- return {
79
- ok: response.ok,
80
- error: response.ok ? null : data.message,
81
- stack: data,
82
- };
97
+ try {
98
+ const response = await fetchFn(`${stacksUrl}/${stackId}`, {
99
+ method: 'PUT',
100
+ headers: getHeaders(auth),
101
+ body: JSON.stringify(stackMutation),
102
+ });
103
+ const data = await response.json();
104
+ return {
105
+ ok: response.ok,
106
+ error: response.ok ? null : data.message,
107
+ stack: data,
108
+ };
109
+ }
110
+ catch (error) {
111
+ return {
112
+ ok: false,
113
+ error: error instanceof Error ? error.message : String(error),
114
+ };
115
+ }
83
116
  }
84
117
  export async function planStack({ stackId, document, auth, logger, }) {
85
118
  const fetchFn = createTracedFetch(logger);
86
- const response = await fetchFn(`${stacksUrl}/${stackId}/plan`, {
87
- method: 'POST',
88
- headers: getHeaders(auth),
89
- body: JSON.stringify({ document }),
90
- });
91
- const data = await response.json();
92
- if (!response.ok) {
119
+ try {
120
+ const response = await fetchFn(`${stacksUrl}/${stackId}/plan`, {
121
+ method: 'POST',
122
+ headers: getHeaders(auth),
123
+ body: JSON.stringify({ document }),
124
+ });
125
+ const data = await response.json();
126
+ if (!response.ok) {
127
+ return {
128
+ ok: false,
129
+ error: data.message || 'Failed to retrieve deployment plan',
130
+ problems: response.status === 400 && Array.isArray(data.problems) ? data.problems : null,
131
+ deploymentPlan: null,
132
+ };
133
+ }
134
+ return { ok: true, error: null, problems: null, deploymentPlan: data };
135
+ }
136
+ catch (error) {
93
137
  return {
94
138
  ok: false,
95
- error: data.message || 'Failed to retrieve deployment plan',
96
- problems: response.status === 400 && Array.isArray(data.problems) ? data.problems : null,
139
+ error: error instanceof Error ? error.message : String(error),
140
+ problems: null,
97
141
  deploymentPlan: null,
98
142
  };
99
143
  }
100
- return { ok: true, error: null, problems: null, deploymentPlan: data };
101
144
  }
102
145
  export async function resolveStackIdByNameOrId(value, auth, logger) {
146
+ // ID prefixed w 'ST-' standard IDs: 13 old project IDs: 11
103
147
  if (value.startsWith('ST-') && (value.length === 13 || value.length === 11))
104
148
  return value;
105
- // ID prefixed w 'ST-' standard IDs: 13 old project IDs: 11
106
149
  const result = await listStacks(auth, logger);
107
150
  if (!result.ok)
108
151
  throw new Error(result.error || 'Failed to list stacks');
@@ -114,29 +157,45 @@ export async function resolveStackIdByNameOrId(value, auth, logger) {
114
157
  export async function promoteStack({ stackId, auth, logger, name, }) {
115
158
  const fetchFn = createTracedFetch(logger);
116
159
  const hasName = typeof name === 'string' && name.length > 0;
117
- const response = await fetchFn(`${stacksUrl}/${stackId}/promote`, {
118
- method: 'POST',
119
- headers: getHeaders(auth),
120
- body: hasName ? JSON.stringify({ name }) : undefined,
121
- });
122
- const data = await response.json();
123
- return {
124
- ok: response.ok,
125
- error: response.ok ? null : data.message,
126
- stack: data,
127
- response,
128
- };
160
+ try {
161
+ const response = await fetchFn(`${stacksUrl}/${stackId}/promote`, {
162
+ method: 'POST',
163
+ headers: getHeaders(auth),
164
+ body: hasName ? JSON.stringify({ name }) : undefined,
165
+ });
166
+ const data = await response.json();
167
+ return {
168
+ ok: response.ok,
169
+ error: response.ok ? null : data.message,
170
+ stack: data,
171
+ response,
172
+ };
173
+ }
174
+ catch (error) {
175
+ return {
176
+ ok: false,
177
+ error: error instanceof Error ? error.message : String(error),
178
+ };
179
+ }
129
180
  }
130
181
  export async function destroyStack({ stackId, auth, logger, }) {
131
182
  const fetchFn = createTracedFetch(logger);
132
- const response = await fetchFn(`${stacksUrl}/${stackId}`, {
133
- method: 'DELETE',
134
- headers: getHeaders(auth),
135
- });
136
- const data = await response.json();
137
- return {
138
- ok: response.ok,
139
- error: response.ok ? null : data.message,
140
- stack: data,
141
- };
183
+ try {
184
+ const response = await fetchFn(`${stacksUrl}/${stackId}`, {
185
+ method: 'DELETE',
186
+ headers: getHeaders(auth),
187
+ });
188
+ const data = await response.json();
189
+ return {
190
+ ok: response.ok,
191
+ error: response.ok ? null : data.message,
192
+ stack: data,
193
+ };
194
+ }
195
+ catch (error) {
196
+ return {
197
+ ok: false,
198
+ error: error instanceof Error ? error.message : String(error),
199
+ };
200
+ }
142
201
  }
@@ -94,6 +94,9 @@ async function deepListStacks(options) {
94
94
  });
95
95
  allStacks.push(...result.stacks);
96
96
  }
97
+ else if (!result.ok) {
98
+ throw new Error(result.error);
99
+ }
97
100
  }
98
101
  spinner.stop().clear();
99
102
  // 4. Print results
@@ -10,3 +10,9 @@ export declare function transpileFunction(resource: FunctionResource, { installe
10
10
  timings: Record<string, number>;
11
11
  bundled: boolean;
12
12
  }>;
13
+ /**
14
+ * Vite 8's `build()` wraps failures in a `BundleError` whose `message` contains
15
+ * a "Build failed with N errors" preamble and full stack traces. The individual
16
+ * errors on `.errors` carry the original, human-readable messages.
17
+ */
18
+ export declare function formatBuildError(err: unknown): string;
@@ -4,7 +4,6 @@ import { performance } from 'node:perf_hooks';
4
4
  import { cwd } from 'node:process';
5
5
  import * as find from 'empathic/find';
6
6
  import { build as viteBuild } from 'vite';
7
- import tsConfigPaths from 'vite-tsconfig-paths';
8
7
  import { detectNativeModulesPlugin } from '../detect-native-modules.js';
9
8
  import { findFunctionEntryPoint } from '../find-entry-point.js';
10
9
  import { cleanupSourceMaps } from './cleanup-source-maps.js';
@@ -51,7 +50,7 @@ export async function transpileFunction(resource, { installer } = {}) {
51
50
  minify: false,
52
51
  sourcemap: true,
53
52
  ssr: true,
54
- rollupOptions: {
53
+ rolldownOptions: {
55
54
  input: entry,
56
55
  output: {
57
56
  format: 'esm',
@@ -66,16 +65,18 @@ export async function transpileFunction(resource, { installer } = {}) {
66
65
  external: bundle ? [] : [/node_modules/],
67
66
  },
68
67
  },
68
+ resolve: {
69
+ // Replaces the vite-tsconfig-paths plugin; vite 8 resolves tsconfig
70
+ // `compilerOptions.paths` natively
71
+ tsconfigPaths: true,
72
+ },
69
73
  ssr: {
70
74
  noExternal: bundle ? true : [],
71
75
  resolve: {
72
76
  conditions: ['node'],
73
77
  },
74
78
  },
75
- plugins: [
76
- ...(bundle ? [detectNativeModulesPlugin(), pnpmResolvePlugin(cwd())] : []),
77
- tsConfigPaths(),
78
- ],
79
+ plugins: bundle ? [detectNativeModulesPlugin(), pnpmResolvePlugin(cwd())] : [],
79
80
  });
80
81
  timings['transpile:build'] = performance.now() - viteStart;
81
82
  const verifyStart = performance.now();
@@ -99,11 +100,37 @@ export async function transpileFunction(resource, { installer } = {}) {
99
100
  }
100
101
  catch (err) {
101
102
  await cleanupTmpDir();
102
- throw new Error(`Transpiling of function failed: ${err instanceof Error ? err.message : err}`, {
103
+ throw new Error(`Transpiling of function failed: ${formatBuildError(err)}`, {
103
104
  cause: err,
104
105
  });
105
106
  }
106
107
  }
108
+ /**
109
+ * Vite 8's `build()` wraps failures in a `BundleError` whose `message` contains
110
+ * a "Build failed with N errors" preamble and full stack traces. The individual
111
+ * errors on `.errors` carry the original, human-readable messages.
112
+ */
113
+ export function formatBuildError(err) {
114
+ if (!(err instanceof Error))
115
+ return String(err);
116
+ if ('errors' in err && Array.isArray(err.errors) && err.errors.length > 0) {
117
+ return err.errors.map(formatBuildErrorEntry).join('\n');
118
+ }
119
+ return err.message;
120
+ }
121
+ /**
122
+ * A `BundleError.errors` entry may be...
123
+ * a real `Error`,
124
+ * a plain object carrying a `message` (Rolldown/Oxc diagnostics),
125
+ * or unknown
126
+ * Prefer `.message` and fall back to `String()`
127
+ */
128
+ function formatBuildErrorEntry(e) {
129
+ if (e instanceof Error)
130
+ return e.message;
131
+ const message = e?.message;
132
+ return typeof message === 'string' ? message : String(e);
133
+ }
107
134
  async function writeTranspiledPackageJson(inputDir, outputFilePath) {
108
135
  const baseName = path.basename(outputFilePath);
109
136
  let original;
@@ -179,7 +179,7 @@ export function createTracedFetch(logger, options) {
179
179
  const startTime = performance.now();
180
180
  function trace(type, msgTemplate, ...args) {
181
181
  const arrow = type === 'req' ? '→' : type === 'res' ? '←' : styleText('red', '✗');
182
- logger.trace(`${styleText('dim', '[%s]')} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
182
+ logger.trace(`${styleText('dim', '[%s]')} ${styleText('dim', `[${new Date().toISOString()}]`)} HTTP ${arrow} ${msgTemplate}`, requestId, ...args);
183
183
  }
184
184
  // Log request URL
185
185
  trace('req', '%s %s', method, url);
@@ -2998,5 +2998,5 @@
2998
2998
  ]
2999
2999
  }
3000
3000
  },
3001
- "version": "15.2.0"
3001
+ "version": "16.0.0"
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.2.0",
4
+ "version": "16.0.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -75,8 +75,7 @@
75
75
  "mime-types": "^3.0.2",
76
76
  "ora": "^9.4.0",
77
77
  "tar-stream": "^3.2.0",
78
- "vite": "^7.3.3",
79
- "vite-tsconfig-paths": "^6.1.1",
78
+ "vite": "^8.0.16",
80
79
  "ws": "^8.20.0",
81
80
  "xdg-basedir": "^5.1.0"
82
81
  },