@sanity/runtime-cli 17.21.3-app-functions.g1a9a040 → 17.21.3-next.g9e6e127
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 +19 -19
- package/dist/actions/blueprints/stacks.d.ts +3 -9
- package/dist/actions/blueprints/stacks.js +8 -11
- package/dist/actions/blueprints/wait-for-operation.d.ts +0 -1
- package/dist/actions/blueprints/wait-for-operation.js +1 -1
- package/dist/cores/blueprints/deploy.d.ts +0 -8
- package/dist/cores/blueprints/deploy.js +4 -12
- package/dist/cores/blueprints/destroy.d.ts +1 -14
- package/dist/cores/blueprints/destroy.js +1 -2
- package/dist/utils/bundles/stamp-config-version.js +8 -27
- package/dist/utils/functions/transpile/function.d.ts +1 -7
- package/dist/utils/functions/transpile/function.js +9 -15
- package/oclif.manifest.json +1 -1
- package/package.json +2 -23
- package/dist/functions/artifacts.d.ts +0 -13
- package/dist/functions/artifacts.js +0 -26
- package/dist/functions/build.d.ts +0 -15
- package/dist/functions/build.js +0 -30
- package/dist/functions/contractPlugin.d.ts +0 -7
- package/dist/functions/contractPlugin.js +0 -32
- package/dist/functions/contracts/schema.d.ts +0 -22
- package/dist/functions/contracts/schema.js +0 -99
- package/dist/functions/contracts/validation.d.ts +0 -3
- package/dist/functions/contracts/validation.js +0 -66
- package/dist/functions/contracts.d.ts +0 -33
- package/dist/functions/contracts.js +0 -162
- package/dist/functions/deploy.d.ts +0 -16
- package/dist/functions/deploy.js +0 -69
- package/dist/functions/schedule.d.ts +0 -21
- package/dist/functions/schedule.js +0 -34
- package/dist/functions/stack.d.ts +0 -41
- package/dist/functions/stack.js +0 -153
package/README.md
CHANGED
|
@@ -90,7 +90,7 @@ EXAMPLES
|
|
|
90
90
|
$ sanity-run blueprints add function --name my-function --fn-type document-create --fn-type document-update --lang js
|
|
91
91
|
```
|
|
92
92
|
|
|
93
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
93
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/add.ts)_
|
|
94
94
|
|
|
95
95
|
## `sanity-run blueprints config`
|
|
96
96
|
|
|
@@ -127,7 +127,7 @@ EXAMPLES
|
|
|
127
127
|
$ sanity-run blueprints config --edit --project-id <projectId> --stack <name-or-id>
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
130
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/config.ts)_
|
|
131
131
|
|
|
132
132
|
## `sanity-run blueprints deploy`
|
|
133
133
|
|
|
@@ -183,7 +183,7 @@ EXAMPLES
|
|
|
183
183
|
$ sanity-run blueprints deploy --new-stack-name <new-name>
|
|
184
184
|
```
|
|
185
185
|
|
|
186
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
186
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/deploy.ts)_
|
|
187
187
|
|
|
188
188
|
## `sanity-run blueprints destroy`
|
|
189
189
|
|
|
@@ -221,7 +221,7 @@ EXAMPLES
|
|
|
221
221
|
$ sanity-run blueprints destroy --stack <name-or-id> --project-id <projectId> --force --no-wait
|
|
222
222
|
```
|
|
223
223
|
|
|
224
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
224
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/destroy.ts)_
|
|
225
225
|
|
|
226
226
|
## `sanity-run blueprints doctor`
|
|
227
227
|
|
|
@@ -253,7 +253,7 @@ EXAMPLES
|
|
|
253
253
|
$ sanity-run blueprints doctor --fix
|
|
254
254
|
```
|
|
255
255
|
|
|
256
|
-
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
256
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/doctor.ts)_
|
|
257
257
|
|
|
258
258
|
## `sanity-run blueprints info`
|
|
259
259
|
|
|
@@ -291,7 +291,7 @@ EXAMPLES
|
|
|
291
291
|
$ sanity-run blueprints info --organization-id <orgId> --stack <name-or-id>
|
|
292
292
|
```
|
|
293
293
|
|
|
294
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
294
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/info.ts)_
|
|
295
295
|
|
|
296
296
|
## `sanity-run blueprints init [DIR]`
|
|
297
297
|
|
|
@@ -355,7 +355,7 @@ EXAMPLES
|
|
|
355
355
|
$ sanity-run blueprints init old-stack --type <json|js|ts> --project-id <projectId> --stack-id <existingStackId>
|
|
356
356
|
```
|
|
357
357
|
|
|
358
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
358
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/init.ts)_
|
|
359
359
|
|
|
360
360
|
## `sanity-run blueprints logs`
|
|
361
361
|
|
|
@@ -401,7 +401,7 @@ EXAMPLES
|
|
|
401
401
|
$ sanity-run blueprints logs --before 2026-05-01T00:00:00Z
|
|
402
402
|
```
|
|
403
403
|
|
|
404
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
404
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/logs.ts)_
|
|
405
405
|
|
|
406
406
|
## `sanity-run blueprints mint-deploy-token`
|
|
407
407
|
|
|
@@ -446,7 +446,7 @@ EXAMPLES
|
|
|
446
446
|
$ sanity-run blueprints mint-deploy-token --organization-id <orgId>
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
449
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/mint-deploy-token.ts)_
|
|
450
450
|
|
|
451
451
|
## `sanity-run blueprints plan`
|
|
452
452
|
|
|
@@ -479,7 +479,7 @@ EXAMPLES
|
|
|
479
479
|
$ sanity-run blueprints plan --organization-id <orgId> --stack <name-or-id>
|
|
480
480
|
```
|
|
481
481
|
|
|
482
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
482
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/plan.ts)_
|
|
483
483
|
|
|
484
484
|
## `sanity-run blueprints promote`
|
|
485
485
|
|
|
@@ -515,7 +515,7 @@ EXAMPLES
|
|
|
515
515
|
$ sanity-run blueprints promote --new-stack-name <new-name>
|
|
516
516
|
```
|
|
517
517
|
|
|
518
|
-
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
518
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/promote.ts)_
|
|
519
519
|
|
|
520
520
|
## `sanity-run blueprints stacks`
|
|
521
521
|
|
|
@@ -556,7 +556,7 @@ EXAMPLES
|
|
|
556
556
|
$ sanity-run blueprints stacks --organization-id <organizationId> --include-projects
|
|
557
557
|
```
|
|
558
558
|
|
|
559
|
-
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
559
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/blueprints/stacks.ts)_
|
|
560
560
|
|
|
561
561
|
## `sanity-run functions add`
|
|
562
562
|
|
|
@@ -608,7 +608,7 @@ EXAMPLES
|
|
|
608
608
|
$ sanity-run functions add --name my-function --type document-create --type document-update --lang js
|
|
609
609
|
```
|
|
610
610
|
|
|
611
|
-
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
611
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/add.ts)_
|
|
612
612
|
|
|
613
613
|
## `sanity-run functions dev`
|
|
614
614
|
|
|
@@ -643,7 +643,7 @@ EXAMPLES
|
|
|
643
643
|
$ sanity-run functions dev --timeout 60
|
|
644
644
|
```
|
|
645
645
|
|
|
646
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
646
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/dev.ts)_
|
|
647
647
|
|
|
648
648
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
649
649
|
|
|
@@ -676,7 +676,7 @@ EXAMPLES
|
|
|
676
676
|
$ sanity-run functions env add --stack <name-or-id> MyFunction API_URL https://api.example.com/
|
|
677
677
|
```
|
|
678
678
|
|
|
679
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
679
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/env/add.ts)_
|
|
680
680
|
|
|
681
681
|
## `sanity-run functions env list NAME`
|
|
682
682
|
|
|
@@ -706,7 +706,7 @@ EXAMPLES
|
|
|
706
706
|
$ sanity-run functions env list --stack <name-or-id> MyFunction
|
|
707
707
|
```
|
|
708
708
|
|
|
709
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
709
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/env/list.ts)_
|
|
710
710
|
|
|
711
711
|
## `sanity-run functions env remove NAME KEY`
|
|
712
712
|
|
|
@@ -738,7 +738,7 @@ EXAMPLES
|
|
|
738
738
|
$ sanity-run functions env remove --stack <name-or-id> MyFunction API_URL
|
|
739
739
|
```
|
|
740
740
|
|
|
741
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
741
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/env/remove.ts)_
|
|
742
742
|
|
|
743
743
|
## `sanity-run functions logs [NAME]`
|
|
744
744
|
|
|
@@ -778,7 +778,7 @@ EXAMPLES
|
|
|
778
778
|
$ sanity-run functions logs <name> --delete
|
|
779
779
|
```
|
|
780
780
|
|
|
781
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
781
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/logs.ts)_
|
|
782
782
|
|
|
783
783
|
## `sanity-run functions test [NAME]`
|
|
784
784
|
|
|
@@ -836,7 +836,7 @@ EXAMPLES
|
|
|
836
836
|
$ sanity-run functions test <name> --event update --data-before '{ "title": "before" }' --data-after '{ "title": "after" }'
|
|
837
837
|
```
|
|
838
838
|
|
|
839
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-
|
|
839
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.3-next.g9e6e127/src/commands/functions/test.ts)_
|
|
840
840
|
|
|
841
841
|
## `sanity-run help [COMMAND]`
|
|
842
842
|
|
|
@@ -13,11 +13,7 @@ type ListStacksResponse = {
|
|
|
13
13
|
stacks?: unknown;
|
|
14
14
|
response?: Response;
|
|
15
15
|
};
|
|
16
|
-
export declare function listStacks(auth: AuthParams, logger: Logger
|
|
17
|
-
fetchFn?: typeof fetch;
|
|
18
|
-
cursor?: string;
|
|
19
|
-
limit?: number;
|
|
20
|
-
}): Promise<ListStacksResponse>;
|
|
16
|
+
export declare function listStacks(auth: AuthParams, logger: Logger): Promise<ListStacksResponse>;
|
|
21
17
|
type GetStackResponse = {
|
|
22
18
|
ok: true;
|
|
23
19
|
error: null;
|
|
@@ -35,11 +31,10 @@ export declare function getStack({ stackId, auth, fetchFn, }: {
|
|
|
35
31
|
fetchFn: typeof fetch;
|
|
36
32
|
}): Promise<GetStackResponse>;
|
|
37
33
|
type CreateStackResponse = GetStackResponse;
|
|
38
|
-
export declare function createStack({ stackMutation, auth, logger,
|
|
34
|
+
export declare function createStack({ stackMutation, auth, logger, }: {
|
|
39
35
|
stackMutation: StackMutation;
|
|
40
36
|
auth: AuthParams;
|
|
41
37
|
logger: Logger;
|
|
42
|
-
fetchFn?: typeof fetch;
|
|
43
38
|
}): Promise<CreateStackResponse>;
|
|
44
39
|
export declare function createEmptyStack({ token, scopeType, scopeId, name, logger, }: {
|
|
45
40
|
token: string;
|
|
@@ -138,10 +133,9 @@ export declare function promoteStack({ stackId, auth, logger, name, }: {
|
|
|
138
133
|
name?: string;
|
|
139
134
|
}): Promise<PromoteStackResponse>;
|
|
140
135
|
type DestroyStackResponse = UpdateStackResponse;
|
|
141
|
-
export declare function destroyStack({ stackId, auth, logger,
|
|
136
|
+
export declare function destroyStack({ stackId, auth, logger, }: {
|
|
142
137
|
stackId: string;
|
|
143
138
|
auth: AuthParams;
|
|
144
139
|
logger: Logger;
|
|
145
|
-
fetchFn?: typeof fetch;
|
|
146
140
|
}): Promise<DestroyStackResponse>;
|
|
147
141
|
export {};
|
|
@@ -3,15 +3,10 @@ import getHeaders from '../../utils/get-headers.js';
|
|
|
3
3
|
import { getRequestId } from '../../utils/request-id.js';
|
|
4
4
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
5
5
|
export const stacksUrl = blueprintsUrl('stacks');
|
|
6
|
-
export async function listStacks(auth, logger
|
|
7
|
-
const fetchFn =
|
|
8
|
-
const url = new URL(stacksUrl);
|
|
9
|
-
if (options.cursor)
|
|
10
|
-
url.searchParams.set('cursor', options.cursor);
|
|
11
|
-
if (options.limit !== undefined)
|
|
12
|
-
url.searchParams.set('limit', String(options.limit));
|
|
6
|
+
export async function listStacks(auth, logger) {
|
|
7
|
+
const fetchFn = createTracedFetch(logger);
|
|
13
8
|
try {
|
|
14
|
-
const response = await fetchFn(
|
|
9
|
+
const response = await fetchFn(stacksUrl, {
|
|
15
10
|
method: 'GET',
|
|
16
11
|
headers: getHeaders(auth),
|
|
17
12
|
});
|
|
@@ -32,7 +27,7 @@ export async function listStacks(auth, logger, options = {}) {
|
|
|
32
27
|
}
|
|
33
28
|
export async function getStack({ stackId, auth, fetchFn, }) {
|
|
34
29
|
try {
|
|
35
|
-
const response = await fetchFn(`${stacksUrl}/${
|
|
30
|
+
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
36
31
|
method: 'GET',
|
|
37
32
|
headers: getHeaders(auth),
|
|
38
33
|
});
|
|
@@ -51,8 +46,9 @@ export async function getStack({ stackId, auth, fetchFn, }) {
|
|
|
51
46
|
};
|
|
52
47
|
}
|
|
53
48
|
}
|
|
54
|
-
export async function createStack({ stackMutation, auth, logger,
|
|
49
|
+
export async function createStack({ stackMutation, auth, logger, }) {
|
|
55
50
|
try {
|
|
51
|
+
const fetchFn = createTracedFetch(logger);
|
|
56
52
|
const response = await fetchFn(stacksUrl, {
|
|
57
53
|
method: 'POST',
|
|
58
54
|
headers: getHeaders(auth),
|
|
@@ -198,7 +194,8 @@ export async function promoteStack({ stackId, auth, logger, name, }) {
|
|
|
198
194
|
};
|
|
199
195
|
}
|
|
200
196
|
}
|
|
201
|
-
export async function destroyStack({ stackId, auth, logger,
|
|
197
|
+
export async function destroyStack({ stackId, auth, logger, }) {
|
|
198
|
+
const fetchFn = createTracedFetch(logger);
|
|
202
199
|
try {
|
|
203
200
|
const response = await fetchFn(`${stacksUrl}/${stackId}`, {
|
|
204
201
|
method: 'DELETE',
|
|
@@ -8,7 +8,6 @@ export interface WaitForOperationOptions {
|
|
|
8
8
|
log: Logger;
|
|
9
9
|
bin: string;
|
|
10
10
|
verbose?: boolean;
|
|
11
|
-
fetchFn?: typeof fetch;
|
|
12
11
|
/** Keep the operation queryable after the stack is gone (destroy). */
|
|
13
12
|
includeDestroyed?: boolean;
|
|
14
13
|
/** Noun for the idle message, e.g. "deployment" or "destruction". */
|
|
@@ -9,7 +9,7 @@ import { classifyOperationPoll, getOperation } from './operations.js';
|
|
|
9
9
|
*/
|
|
10
10
|
export async function waitForOperation(options) {
|
|
11
11
|
const { stackId, operationId, auth, log, bin, verbose = false, includeDestroyed, progressNoun, } = options;
|
|
12
|
-
const fetchFn =
|
|
12
|
+
const fetchFn = createTracedFetch(log);
|
|
13
13
|
const waitFor = createWaitFor({
|
|
14
14
|
bin,
|
|
15
15
|
log,
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
1
|
import type { ReadBlueprintResult } from '../../actions/blueprints/blueprint.js';
|
|
3
2
|
import type { AuthParams, ScopeType, Stack } from '../../utils/types.js';
|
|
4
3
|
import type { CoreConfig, CoreResult } from '../index.js';
|
|
@@ -20,10 +19,3 @@ export interface BlueprintDeployOptions extends CoreConfig {
|
|
|
20
19
|
};
|
|
21
20
|
}
|
|
22
21
|
export declare function blueprintDeployCore(options: BlueprintDeployOptions): Promise<CoreResult>;
|
|
23
|
-
export interface ResourceDeployOptions extends Omit<BlueprintDeployOptions, 'blueprint'> {
|
|
24
|
-
resources: BlueprintResource[];
|
|
25
|
-
workDir: string;
|
|
26
|
-
fetchFn?: typeof fetch;
|
|
27
|
-
}
|
|
28
|
-
/** Deploy an in-memory resource list using the same pipeline as a Blueprint file. */
|
|
29
|
-
export declare function deployResourcesCore(options: ResourceDeployOptions): Promise<CoreResult>;
|
|
@@ -14,23 +14,16 @@ import { styleText } from '../../utils/style-text.js';
|
|
|
14
14
|
import { createTracedFetch } from '../../utils/traced-fetch.js';
|
|
15
15
|
import { getWarnings } from '../../utils/warnings.js';
|
|
16
16
|
export async function blueprintDeployCore(options) {
|
|
17
|
-
|
|
18
|
-
...options,
|
|
19
|
-
resources: options.blueprint.resources,
|
|
20
|
-
workDir: dirname(options.blueprint.fileInfo.blueprintFilePath),
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
/** Deploy an in-memory resource list using the same pipeline as a Blueprint file. */
|
|
24
|
-
export async function deployResourcesCore(options) {
|
|
25
|
-
const { bin = 'sanity', log: logger, auth, stackId, scopeType, scopeId, deployedStack, workDir: blueprintFileDir, cliVersion, flags, } = options;
|
|
17
|
+
const { bin = 'sanity', log: logger, auth, stackId, scopeType, scopeId, deployedStack, blueprint, cliVersion, flags, } = options;
|
|
26
18
|
const { verbose } = flags;
|
|
27
19
|
const noWait = flags['no-wait'] || false;
|
|
28
20
|
const stackName = flags['new-stack-name'] ?? deployedStack.name;
|
|
29
21
|
const installer = flags['fn-installer'] || undefined;
|
|
22
|
+
const blueprintFileDir = dirname(blueprint.fileInfo.blueprintFilePath);
|
|
30
23
|
const workspaceWarnings = getWarnings({ dir: blueprintFileDir });
|
|
31
24
|
logger(`Deploying "${stackName}" ${niceId(deployedStack.id)}...`);
|
|
32
25
|
try {
|
|
33
|
-
const fetchFn =
|
|
26
|
+
const fetchFn = createTracedFetch(logger);
|
|
34
27
|
const { ok: checkOk, stack: currentStack } = await getStack({ stackId, auth, fetchFn });
|
|
35
28
|
if (!checkOk) {
|
|
36
29
|
return { success: false, error: 'Failed to check current Stack status' };
|
|
@@ -46,7 +39,7 @@ export async function deployResourcesCore(options) {
|
|
|
46
39
|
],
|
|
47
40
|
};
|
|
48
41
|
}
|
|
49
|
-
const resources = [...
|
|
42
|
+
const resources = [...blueprint.resources];
|
|
50
43
|
let spinner;
|
|
51
44
|
const preDeployResult = await preDeploy({
|
|
52
45
|
scopeType,
|
|
@@ -150,7 +143,6 @@ export async function deployResourcesCore(options) {
|
|
|
150
143
|
bin,
|
|
151
144
|
verbose,
|
|
152
145
|
progressNoun: 'deployment',
|
|
153
|
-
fetchFn,
|
|
154
146
|
});
|
|
155
147
|
if (outcome.type === 'completed') {
|
|
156
148
|
logger(styleText(['bold', 'green'], 'Stack deployment completed!'));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type LocatedBlueprintsConfig } from '../../actions/blueprints/config.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ScopeType } from '../../utils/types.js';
|
|
3
3
|
import type { CoreConfig, CoreResult } from '../index.js';
|
|
4
4
|
export interface BlueprintDestroyOptions extends CoreConfig {
|
|
5
5
|
token: string;
|
|
@@ -20,16 +20,3 @@ export interface BlueprintDestroyOptions extends CoreConfig {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export declare function blueprintDestroyCore(options: BlueprintDestroyOptions): Promise<CoreResult>;
|
|
23
|
-
type WaitForDestructionOptions = {
|
|
24
|
-
stackId: string;
|
|
25
|
-
stackName: string;
|
|
26
|
-
operationId: string;
|
|
27
|
-
requestId?: string;
|
|
28
|
-
auth: AuthParams;
|
|
29
|
-
log: CoreConfig['log'];
|
|
30
|
-
bin: string;
|
|
31
|
-
verbose?: boolean;
|
|
32
|
-
fetchFn?: typeof fetch;
|
|
33
|
-
};
|
|
34
|
-
export declare function waitForDestruction(options: WaitForDestructionOptions): Promise<CoreResult>;
|
|
35
|
-
export {};
|
|
@@ -150,7 +150,7 @@ function afterDestroyAccepted(options) {
|
|
|
150
150
|
}
|
|
151
151
|
return waitForDestruction(options);
|
|
152
152
|
}
|
|
153
|
-
|
|
153
|
+
async function waitForDestruction(options) {
|
|
154
154
|
const { stackId, stackName, operationId, requestId, auth, log, bin, verbose = false } = options;
|
|
155
155
|
log(styleText('dim', 'Stack destruction progress:'));
|
|
156
156
|
log('');
|
|
@@ -163,7 +163,6 @@ export async function waitForDestruction(options) {
|
|
|
163
163
|
verbose,
|
|
164
164
|
includeDestroyed: true,
|
|
165
165
|
progressNoun: 'destruction',
|
|
166
|
-
fetchFn: options.fetchFn,
|
|
167
166
|
});
|
|
168
167
|
if (outcome.type === 'completed') {
|
|
169
168
|
log(styleText(['bold', 'magenta'], 'Stack destruction completed!'));
|
|
@@ -5,41 +5,22 @@ import { SANITY_INSTALLATION_CONFIG, SANITY_STUDIO } from '../../constants.js';
|
|
|
5
5
|
* Stamps the installed `sanity` version onto each media-library config resource and studio resource.
|
|
6
6
|
*/
|
|
7
7
|
export const stampConfigVersion = async (resource, blueprintFileDir) => {
|
|
8
|
-
|
|
9
|
-
let root;
|
|
10
|
-
if (resource.type === SANITY_INSTALLATION_CONFIG) {
|
|
8
|
+
if (resource.type === SANITY_INSTALLATION_CONFIG || resource.type === SANITY_STUDIO) {
|
|
11
9
|
const config = resource;
|
|
12
|
-
|
|
10
|
+
// skip non-media library configs
|
|
11
|
+
if (resource.type === SANITY_INSTALLATION_CONFIG &&
|
|
12
|
+
'appType' in config &&
|
|
13
|
+
config.appType !== 'media-library')
|
|
13
14
|
return;
|
|
14
|
-
// Leave values included in the blueprint
|
|
15
|
+
// Leave values included in the blueprint
|
|
15
16
|
if (config.version !== undefined)
|
|
16
17
|
return;
|
|
17
|
-
root = config.root;
|
|
18
|
-
update = (version) => {
|
|
19
|
-
config.version = version;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
else if (resource.type === SANITY_STUDIO) {
|
|
23
|
-
const config = resource;
|
|
24
|
-
// Leave values included in the blueprint.
|
|
25
|
-
if (config.autoUpdates?.version !== undefined)
|
|
26
|
-
return;
|
|
27
|
-
root = config.root;
|
|
28
|
-
update = (version) => {
|
|
29
|
-
if (config.autoUpdates) {
|
|
30
|
-
config.autoUpdates.version = version;
|
|
31
|
-
}
|
|
32
|
-
else {
|
|
33
|
-
config.autoUpdates = { enabled: true, version };
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (update && root) {
|
|
18
|
+
const root = config.root;
|
|
38
19
|
const workDir = resolve(blueprintFileDir, root);
|
|
39
20
|
const version = await getLocalPackageVersion('sanity', workDir);
|
|
40
21
|
if (!version) {
|
|
41
22
|
throw new Error(`Unable to determine the installed 'sanity' version for resource '${resource.name}'; is 'sanity' installed in '${root}'?`);
|
|
42
23
|
}
|
|
43
|
-
|
|
24
|
+
config.version = version;
|
|
44
25
|
}
|
|
45
26
|
};
|
|
@@ -1,16 +1,10 @@
|
|
|
1
|
-
import type { Plugin } from 'vite';
|
|
2
1
|
import type { FunctionResource, InstallerType } from '../../types.js';
|
|
3
2
|
export declare const resolveViteRoot: (entry: string) => string;
|
|
4
|
-
export declare function transpileFunction({ resource, functionPath, entryPoint, installer,
|
|
3
|
+
export declare function transpileFunction({ resource, functionPath, entryPoint, installer, }: {
|
|
5
4
|
resource: FunctionResource;
|
|
6
5
|
functionPath: string;
|
|
7
6
|
entryPoint: string;
|
|
8
7
|
installer?: InstallerType;
|
|
9
|
-
workDir?: string;
|
|
10
|
-
outDir?: string;
|
|
11
|
-
outputFileName?: string;
|
|
12
|
-
bundle?: boolean;
|
|
13
|
-
plugins?: Plugin[];
|
|
14
8
|
}): Promise<{
|
|
15
9
|
type: string;
|
|
16
10
|
outputDir: string;
|
|
@@ -13,7 +13,7 @@ export const resolveViteRoot = (entry) => {
|
|
|
13
13
|
const nodeModulesDir = find.dir('node_modules', { cwd: entry });
|
|
14
14
|
return nodeModulesDir ? path.dirname(nodeModulesDir) : entry;
|
|
15
15
|
};
|
|
16
|
-
export async function transpileFunction({ resource, functionPath, entryPoint, installer,
|
|
16
|
+
export async function transpileFunction({ resource, functionPath, entryPoint, installer, }) {
|
|
17
17
|
if (!resource.src)
|
|
18
18
|
throw new Error('Resource src is required');
|
|
19
19
|
if (!resource.name)
|
|
@@ -23,8 +23,8 @@ export async function transpileFunction({ resource, functionPath, entryPoint, in
|
|
|
23
23
|
const stats = await stat(functionPath);
|
|
24
24
|
const entryDir = stats.isFile() ? path.dirname(functionPath) : functionPath;
|
|
25
25
|
const outputPathStart = performance.now();
|
|
26
|
-
const outputDir = await getTranspileOutputPath(entryDir, resource.name
|
|
27
|
-
const outputFile = path.join(outputDir,
|
|
26
|
+
const outputDir = await getTranspileOutputPath(entryDir, resource.name);
|
|
27
|
+
const outputFile = path.join(outputDir, getOutputFilename(entryPoint));
|
|
28
28
|
const fnRootDir = resolveViteRoot(entryDir);
|
|
29
29
|
timings['transpile:setupOutput'] = performance.now() - outputPathStart;
|
|
30
30
|
async function cleanupTmpDir() {
|
|
@@ -34,8 +34,7 @@ export async function transpileFunction({ resource, functionPath, entryPoint, in
|
|
|
34
34
|
try {
|
|
35
35
|
const viteStart = performance.now();
|
|
36
36
|
// Always bundle the code if pnpm usage is detected or specified by the user
|
|
37
|
-
const bundle =
|
|
38
|
-
(!!find.file('pnpm-workspace.yaml', { cwd: workDir }) || installer === 'pnpm');
|
|
37
|
+
const bundle = !!find.file('pnpm-workspace.yaml') || installer === 'pnpm';
|
|
39
38
|
const result = await viteBuild({
|
|
40
39
|
root: fnRootDir,
|
|
41
40
|
// Don't pick up the surrounding project's public/ folder or vite.config.*
|
|
@@ -53,7 +52,7 @@ export async function transpileFunction({ resource, functionPath, entryPoint, in
|
|
|
53
52
|
input: entryPoint,
|
|
54
53
|
output: {
|
|
55
54
|
format: 'esm',
|
|
56
|
-
entryFileNames:
|
|
55
|
+
entryFileNames: getOutputFilename(entryPoint),
|
|
57
56
|
...(bundle
|
|
58
57
|
? {}
|
|
59
58
|
: {
|
|
@@ -75,10 +74,7 @@ export async function transpileFunction({ resource, functionPath, entryPoint, in
|
|
|
75
74
|
conditions: ['node'],
|
|
76
75
|
},
|
|
77
76
|
},
|
|
78
|
-
plugins: [
|
|
79
|
-
...(bundle ? [detectNativeModulesPlugin(), pnpmResolvePlugin(workDir)] : []),
|
|
80
|
-
...extraPlugins,
|
|
81
|
-
],
|
|
77
|
+
plugins: bundle ? [detectNativeModulesPlugin(), pnpmResolvePlugin(cwd())] : [],
|
|
82
78
|
});
|
|
83
79
|
timings['transpile:build'] = performance.now() - viteStart;
|
|
84
80
|
const verifyStart = performance.now();
|
|
@@ -88,7 +84,7 @@ export async function transpileFunction({ resource, functionPath, entryPoint, in
|
|
|
88
84
|
await writeTranspiledPackageJson(entryDir, outputFile);
|
|
89
85
|
timings['transpile:writePackage'] = performance.now() - pkgStart;
|
|
90
86
|
const cleanupStart = performance.now();
|
|
91
|
-
await cleanupSourceMaps(
|
|
87
|
+
await cleanupSourceMaps(functionPath, outputDir);
|
|
92
88
|
timings['transpile:cleanupMaps'] = performance.now() - cleanupStart;
|
|
93
89
|
timings.bundle = performance.now() - transpileStart;
|
|
94
90
|
return {
|
|
@@ -155,10 +151,8 @@ async function writeTranspiledPackageJson(inputDir, outputFilePath) {
|
|
|
155
151
|
const pkgJsonOutputPath = path.join(path.dirname(outputFilePath), 'package.json');
|
|
156
152
|
await writeFile(pkgJsonOutputPath, JSON.stringify(bundled, null, 2));
|
|
157
153
|
}
|
|
158
|
-
async function getTranspileOutputPath(entryDir, fnName
|
|
159
|
-
const tmpPath =
|
|
160
|
-
? path.resolve(outDir)
|
|
161
|
-
: path.resolve(entryDir, '.build', `function-${fnName}`);
|
|
154
|
+
async function getTranspileOutputPath(entryDir, fnName) {
|
|
155
|
+
const tmpPath = path.resolve(entryDir, '.build', `function-${fnName}`);
|
|
162
156
|
await rm(tmpPath, { recursive: true, force: true }).catch(logCleanupFailure);
|
|
163
157
|
await mkdir(tmpPath, { recursive: true });
|
|
164
158
|
return tmpPath;
|
package/oclif.manifest.json
CHANGED
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": "17.21.3-
|
|
4
|
+
"version": "17.21.3-next.g9e6e127",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -14,26 +14,6 @@
|
|
|
14
14
|
"main": "dist/index.js",
|
|
15
15
|
"types": "dist/index.d.ts",
|
|
16
16
|
"exports": {
|
|
17
|
-
"./functions/stack": {
|
|
18
|
-
"types": "./dist/functions/stack.d.ts",
|
|
19
|
-
"import": "./dist/functions/stack.js",
|
|
20
|
-
"require": "./dist/functions/stack.js"
|
|
21
|
-
},
|
|
22
|
-
"./functions/contracts": {
|
|
23
|
-
"types": "./dist/functions/contracts.d.ts",
|
|
24
|
-
"import": "./dist/functions/contracts.js",
|
|
25
|
-
"require": "./dist/functions/contracts.js"
|
|
26
|
-
},
|
|
27
|
-
"./functions/deploy": {
|
|
28
|
-
"types": "./dist/functions/deploy.d.ts",
|
|
29
|
-
"import": "./dist/functions/deploy.js",
|
|
30
|
-
"require": "./dist/functions/deploy.js"
|
|
31
|
-
},
|
|
32
|
-
"./functions/build": {
|
|
33
|
-
"types": "./dist/functions/build.d.ts",
|
|
34
|
-
"import": "./dist/functions/build.js",
|
|
35
|
-
"require": "./dist/functions/build.js"
|
|
36
|
-
},
|
|
37
17
|
".": {
|
|
38
18
|
"types": "./dist/index.d.ts",
|
|
39
19
|
"import": "./dist/index.js",
|
|
@@ -88,7 +68,7 @@
|
|
|
88
68
|
"@oclif/core": "^4.14.0",
|
|
89
69
|
"@oclif/plugin-help": "^6.3.0",
|
|
90
70
|
"@sanity-labs/oclif-plugin-skills-flag": "^0.2.1",
|
|
91
|
-
"@sanity/blueprints": "^0.
|
|
71
|
+
"@sanity/blueprints": "^0.34.0",
|
|
92
72
|
"@sanity/blueprints-parser": "^0.5.0",
|
|
93
73
|
"@sanity/cli-build": "^7.1.1",
|
|
94
74
|
"@sanity/cli-core": "^3.14.1",
|
|
@@ -106,7 +86,6 @@
|
|
|
106
86
|
"strip-ansi": "^7.2.0",
|
|
107
87
|
"tar-fs": "^3.1.3",
|
|
108
88
|
"tar-stream": "^3.2.2",
|
|
109
|
-
"typescript-compiler": "npm:typescript@^6.0.3",
|
|
110
89
|
"vite": "^8.3.6",
|
|
111
90
|
"ws": "^8.22.1",
|
|
112
91
|
"xdg-basedir": "^5.1.0"
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export declare const functionOutputFileName = "index.js";
|
|
2
|
-
/** Metadata for a compiled function, resolved without loading its handler. */
|
|
3
|
-
export interface FunctionBuild {
|
|
4
|
-
name: string;
|
|
5
|
-
src: string;
|
|
6
|
-
entryPoint: string;
|
|
7
|
-
}
|
|
8
|
-
/** Validate artifacts produced by buildFunction before packaging or deployment. */
|
|
9
|
-
export declare function readFunctionBuild(options: {
|
|
10
|
-
name: string;
|
|
11
|
-
src: string;
|
|
12
|
-
workDir: string;
|
|
13
|
-
}): Promise<FunctionBuild>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { readFile } from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { findFunctionEntryPoint } from '../utils/functions/find-entry-point.js';
|
|
4
|
-
export const functionOutputFileName = 'index.js';
|
|
5
|
-
/** Validate artifacts produced by buildFunction before packaging or deployment. */
|
|
6
|
-
export async function readFunctionBuild(options) {
|
|
7
|
-
const { name, workDir } = options;
|
|
8
|
-
const src = path.resolve(workDir, options.src);
|
|
9
|
-
try {
|
|
10
|
-
const pkg = JSON.parse(await readFile(path.join(src, 'package.json'), 'utf8'));
|
|
11
|
-
if (!pkg ||
|
|
12
|
-
typeof pkg !== 'object' ||
|
|
13
|
-
!('main' in pkg) ||
|
|
14
|
-
pkg.main !== functionOutputFileName ||
|
|
15
|
-
!('type' in pkg) ||
|
|
16
|
-
pkg.type !== 'module')
|
|
17
|
-
throw new Error('The function package metadata does not match its build format.');
|
|
18
|
-
const entryPoint = await findFunctionEntryPoint(src, name);
|
|
19
|
-
if (entryPoint !== path.join(src, functionOutputFileName))
|
|
20
|
-
throw new Error(`The compiled entry ${functionOutputFileName} is missing.`);
|
|
21
|
-
return { name, src, entryPoint };
|
|
22
|
-
}
|
|
23
|
-
catch (error) {
|
|
24
|
-
throw new Error(`Function "${name}" is not built. Run sanity build first.`, { cause: error });
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type FunctionContract } from './contracts.js';
|
|
2
|
-
export interface BuildFunctionOptions {
|
|
3
|
-
name: string;
|
|
4
|
-
contract?: FunctionContract;
|
|
5
|
-
/** Function directory or entry file, relative to workDir. */
|
|
6
|
-
src: string;
|
|
7
|
-
workDir: string;
|
|
8
|
-
/** Build output directory, relative to workDir. Its contents are replaced. */
|
|
9
|
-
outDir: string;
|
|
10
|
-
}
|
|
11
|
-
/** Build a standalone ESM function bundle without a blueprint, stack, or ZIP. */
|
|
12
|
-
export declare function buildFunction({ name, src, workDir, outDir, contract, }: BuildFunctionOptions): Promise<{
|
|
13
|
-
outputDir: string;
|
|
14
|
-
}>;
|
|
15
|
-
export { type FunctionBuild, readFunctionBuild } from './artifacts.js';
|