@sanity/runtime-cli 17.21.5 → 17.21.6-next.g813863a
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/assets.d.ts +2 -1
- package/dist/actions/blueprints/assets.js +8 -2
- package/dist/actions/blueprints/pre-deploy.js +3 -0
- package/dist/actions/blueprints/process-assets.d.ts +1 -0
- package/dist/actions/blueprints/process-assets.js +10 -2
- package/dist/utils/bundles/prepare-asset.d.ts +6 -2
- package/dist/utils/bundles/prepare-asset.js +11 -8
- package/dist/utils/bundles/resolve-resource-bindings.d.ts +10 -0
- package/dist/utils/bundles/resolve-resource-bindings.js +37 -0
- package/dist/utils/types.d.ts +2 -2
- package/oclif.manifest.json +1 -1
- package/package.json +5 -5
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.
|
|
93
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
130
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
186
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
224
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
256
|
+
_See code: [src/commands/blueprints/doctor.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
294
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
358
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
404
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
449
|
+
_See code: [src/commands/blueprints/mint-deploy-token.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
482
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
518
|
+
_See code: [src/commands/blueprints/promote.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
559
|
+
_See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
611
|
+
_See code: [src/commands/functions/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
646
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
679
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
709
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
741
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
781
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/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.
|
|
839
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v17.21.6-next.g813863a/src/commands/functions/test.ts)_
|
|
840
840
|
|
|
841
841
|
## `sanity-run help [COMMAND]`
|
|
842
842
|
|
|
@@ -18,9 +18,10 @@ export type StashAssetResult = {
|
|
|
18
18
|
success: false;
|
|
19
19
|
error: string;
|
|
20
20
|
};
|
|
21
|
-
export declare function stashAsset<R extends BlueprintResource>({ resolvedResource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }: {
|
|
21
|
+
export declare function stashAsset<R extends BlueprintResource>({ resolvedResource, prepAsset, stackId, auth, blueprintFileDir, fetchFn, installer, }: {
|
|
22
22
|
resolvedResource: ResolvedResource<R>;
|
|
23
23
|
prepAsset: PrepAssetFn<R>;
|
|
24
|
+
stackId: string;
|
|
24
25
|
auth: AuthParams;
|
|
25
26
|
blueprintFileDir: string;
|
|
26
27
|
fetchFn: typeof fetch;
|
|
@@ -4,10 +4,16 @@ import getHeaders from '../../utils/get-headers.js';
|
|
|
4
4
|
const assetsUrl = blueprintsUrl('assets');
|
|
5
5
|
export const assetCheckUrl = `${assetsUrl}/check`;
|
|
6
6
|
export const assetStashUrl = `${assetsUrl}/stash`;
|
|
7
|
-
export async function stashAsset({ resolvedResource, prepAsset, auth, blueprintFileDir, fetchFn, installer, }) {
|
|
7
|
+
export async function stashAsset({ resolvedResource, prepAsset, stackId, auth, blueprintFileDir, fetchFn, installer, }) {
|
|
8
8
|
let cleanup = async () => { };
|
|
9
9
|
try {
|
|
10
|
-
const prepResult = await prepAsset({
|
|
10
|
+
const prepResult = await prepAsset({
|
|
11
|
+
resolvedResource,
|
|
12
|
+
blueprintFileDir,
|
|
13
|
+
installer,
|
|
14
|
+
stackId,
|
|
15
|
+
auth,
|
|
16
|
+
});
|
|
11
17
|
if (prepResult.success === false) {
|
|
12
18
|
await prepResult.cleanup();
|
|
13
19
|
return {
|
|
@@ -21,6 +21,8 @@ const preDeployConfigs = [
|
|
|
21
21
|
return prepareBundleAsset({
|
|
22
22
|
resolvedResource: options.resolvedResource,
|
|
23
23
|
blueprintFileDir: options.blueprintFileDir,
|
|
24
|
+
stackId: options.stackId,
|
|
25
|
+
token: options.auth.token,
|
|
24
26
|
});
|
|
25
27
|
},
|
|
26
28
|
async prepareResource(options) {
|
|
@@ -94,6 +96,7 @@ export async function preDeploy(options) {
|
|
|
94
96
|
try {
|
|
95
97
|
processedAssets = await processAssets({
|
|
96
98
|
assetResources,
|
|
99
|
+
stackId,
|
|
97
100
|
auth,
|
|
98
101
|
blueprintFileDir,
|
|
99
102
|
installer,
|
|
@@ -2,6 +2,7 @@ import type { BlueprintResource } from '@sanity/blueprints';
|
|
|
2
2
|
import type { AssetResource, AuthParams, InstallerType } from '../../utils/types.js';
|
|
3
3
|
type ProcessAssetsOptions<R extends BlueprintResource> = {
|
|
4
4
|
assetResources: AssetResource<R>[];
|
|
5
|
+
stackId: string;
|
|
5
6
|
auth: AuthParams;
|
|
6
7
|
blueprintFileDir: string;
|
|
7
8
|
installer: InstallerType;
|
|
@@ -44,12 +44,20 @@ function getAssetConcurrency() {
|
|
|
44
44
|
}
|
|
45
45
|
async function processAsset(resolvedResource, prepAsset, options) {
|
|
46
46
|
const { resource } = resolvedResource;
|
|
47
|
-
const { auth, blueprintFileDir, installer, fetchFn } = options;
|
|
47
|
+
const { stackId, auth, blueprintFileDir, installer, fetchFn } = options;
|
|
48
48
|
let assetTimeoutTimer;
|
|
49
49
|
let result;
|
|
50
50
|
try {
|
|
51
51
|
result = await Promise.race([
|
|
52
|
-
stashAsset({
|
|
52
|
+
stashAsset({
|
|
53
|
+
resolvedResource,
|
|
54
|
+
prepAsset,
|
|
55
|
+
blueprintFileDir,
|
|
56
|
+
stackId,
|
|
57
|
+
auth,
|
|
58
|
+
fetchFn,
|
|
59
|
+
installer,
|
|
60
|
+
}),
|
|
53
61
|
new Promise((_, reject) => {
|
|
54
62
|
assetTimeoutTimer = setTimeout(() => {
|
|
55
63
|
reject(new Error(`Processing ${resource.name} timed out after ${assetTimeoutS}s`));
|
|
@@ -2,6 +2,7 @@ import type { BlueprintApplicationResource, BlueprintInstallationConfigResource,
|
|
|
2
2
|
import { type BuildStudioEventListener } from '@sanity/cli-build/_internal/build';
|
|
3
3
|
import type { Output } from '@sanity/cli-core';
|
|
4
4
|
import type { AssetPrepResult, ResolvedResource } from '../types.js';
|
|
5
|
+
import { type ResourceBinding } from './resolve-resource-bindings.js';
|
|
5
6
|
export type BundleResource = BlueprintStudioResource | BlueprintApplicationResource | BlueprintInstallationConfigResource;
|
|
6
7
|
type BuildContext<R extends BundleResource> = {
|
|
7
8
|
resource: R;
|
|
@@ -9,6 +10,7 @@ type BuildContext<R extends BundleResource> = {
|
|
|
9
10
|
workDir: string;
|
|
10
11
|
outDir: string;
|
|
11
12
|
output: Output;
|
|
13
|
+
resourceBindings: ResourceBinding[];
|
|
12
14
|
eventListener: Partial<BuildStudioEventListener>;
|
|
13
15
|
};
|
|
14
16
|
type BuildResult = {
|
|
@@ -28,11 +30,13 @@ export declare const BUNDLE_SPECS: {
|
|
|
28
30
|
build: typeof buildInstallationConfigBundle;
|
|
29
31
|
};
|
|
30
32
|
};
|
|
31
|
-
export declare function prepareBundleAsset<R extends BundleResource>({ blueprintFileDir, resolvedResource, }: {
|
|
33
|
+
export declare function prepareBundleAsset<R extends BundleResource>({ blueprintFileDir, resolvedResource, stackId, token, }: {
|
|
32
34
|
blueprintFileDir: string;
|
|
33
35
|
resolvedResource: ResolvedResource<R>;
|
|
36
|
+
stackId: string;
|
|
37
|
+
token: string;
|
|
34
38
|
}): Promise<AssetPrepResult>;
|
|
35
|
-
declare function buildStudioBundle({ resource, appId, workDir, outDir, output, eventListener, }: BuildContext<BlueprintStudioResource>): Promise<BuildResult>;
|
|
39
|
+
declare function buildStudioBundle({ resource, appId, workDir, outDir, output, resourceBindings, eventListener, }: BuildContext<BlueprintStudioResource>): Promise<BuildResult>;
|
|
36
40
|
declare function buildApplicationBundle({ resource, appId, workDir, outDir, output, eventListener, }: BuildContext<BlueprintApplicationResource>): Promise<BuildResult>;
|
|
37
41
|
declare function buildInstallationConfigBundle({ resource, workDir, outDir, output, eventListener, }: BuildContext<BlueprintInstallationConfigResource>): Promise<BuildResult>;
|
|
38
42
|
export {};
|
|
@@ -9,12 +9,13 @@ import { buildStudioSchemasAndManifests } from '@sanity/cli-build/_internal/extr
|
|
|
9
9
|
import { getLocalPackageVersion } from '@sanity/cli-core';
|
|
10
10
|
import { pack } from 'tar-fs';
|
|
11
11
|
import { isRecord } from '../is-record.js';
|
|
12
|
+
import { resolveResourceBindings } from './resolve-resource-bindings.js';
|
|
12
13
|
export const BUNDLE_SPECS = {
|
|
13
14
|
'sanity.studio': { requiresAppId: true, build: buildStudioBundle },
|
|
14
15
|
'sanity.application': { requiresAppId: true, build: buildApplicationBundle },
|
|
15
16
|
'sanity.installation.config': { requiresAppId: false, build: buildInstallationConfigBundle },
|
|
16
17
|
};
|
|
17
|
-
export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, }) {
|
|
18
|
+
export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, stackId, token, }) {
|
|
18
19
|
const resource = resolvedResource.resource;
|
|
19
20
|
// The lookup can't prove it yields the spec matching this R, so it's asserted once here.
|
|
20
21
|
const spec = BUNDLE_SPECS[resource.type];
|
|
@@ -63,6 +64,11 @@ export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, }
|
|
|
63
64
|
await rm(outDir, { force: true, recursive: true });
|
|
64
65
|
await rm(outFile, { force: true });
|
|
65
66
|
};
|
|
67
|
+
const resourceBindings = await resolveResourceBindings({
|
|
68
|
+
projectRootDir: workDir,
|
|
69
|
+
stackId,
|
|
70
|
+
token,
|
|
71
|
+
});
|
|
66
72
|
let mismatchedPackages;
|
|
67
73
|
try {
|
|
68
74
|
;
|
|
@@ -72,6 +78,7 @@ export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, }
|
|
|
72
78
|
workDir,
|
|
73
79
|
outDir,
|
|
74
80
|
output: createSilentOutput(),
|
|
81
|
+
resourceBindings,
|
|
75
82
|
eventListener,
|
|
76
83
|
}));
|
|
77
84
|
}
|
|
@@ -106,14 +113,10 @@ export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, }
|
|
|
106
113
|
};
|
|
107
114
|
}
|
|
108
115
|
}
|
|
109
|
-
async function buildStudioBundle({ resource, appId, workDir, outDir, output, eventListener, }) {
|
|
116
|
+
async function buildStudioBundle({ resource, appId, workDir, outDir, output, resourceBindings, eventListener, }) {
|
|
110
117
|
// this has been checked before we got here but this helps the type checker
|
|
111
118
|
if (!appId)
|
|
112
119
|
throw new Error(`Unable to determine appId for ${resource.type} resource '${resource.name}'`);
|
|
113
|
-
// currently we only support hard-coded project, support for dynamic project id to be added
|
|
114
|
-
const projectId = resource.project;
|
|
115
|
-
if (!projectId || projectId.startsWith('$.'))
|
|
116
|
-
throw new Error(`Unable to determine project for ${resource.type} resource '${resource.name}'`);
|
|
117
120
|
let mismatchedPackages;
|
|
118
121
|
const { mfManifest } = await buildStudio({
|
|
119
122
|
appId,
|
|
@@ -125,7 +128,7 @@ async function buildStudioBundle({ resource, appId, workDir, outDir, output, eve
|
|
|
125
128
|
return result;
|
|
126
129
|
},
|
|
127
130
|
determineBasePath() {
|
|
128
|
-
return
|
|
131
|
+
return '/';
|
|
129
132
|
},
|
|
130
133
|
isApp: false,
|
|
131
134
|
isBlueprints: true,
|
|
@@ -152,7 +155,7 @@ async function buildStudioBundle({ resource, appId, workDir, outDir, output, eve
|
|
|
152
155
|
configPath: resource.root,
|
|
153
156
|
isExternal: false,
|
|
154
157
|
outPath: outDir,
|
|
155
|
-
|
|
158
|
+
resourceBindings,
|
|
156
159
|
schemaRequired: false,
|
|
157
160
|
verbose: false,
|
|
158
161
|
workDir,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type ResourceBinding = {
|
|
2
|
+
type: string;
|
|
3
|
+
name: string;
|
|
4
|
+
id: string;
|
|
5
|
+
};
|
|
6
|
+
export declare function resolveResourceBindings({ projectRootDir, stackId, token, }: {
|
|
7
|
+
projectRootDir: string;
|
|
8
|
+
stackId: string;
|
|
9
|
+
token: string;
|
|
10
|
+
}): Promise<ResourceBinding[]>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { dirname, resolve } from 'node:path';
|
|
2
|
+
import { findBlueprintFile, readBlueprint, readStack } from '@sanity/blueprints/resolve';
|
|
3
|
+
export async function resolveResourceBindings({ projectRootDir, stackId, token, }) {
|
|
4
|
+
try {
|
|
5
|
+
const blueprintFile = findBlueprintFile(projectRootDir);
|
|
6
|
+
if (!blueprintFile)
|
|
7
|
+
return [];
|
|
8
|
+
const localBlueprint = await readBlueprint({
|
|
9
|
+
path: blueprintFile,
|
|
10
|
+
});
|
|
11
|
+
const blueprintReferencesStudio = localBlueprint.resources.some((r) => {
|
|
12
|
+
if ('root' in r && typeof r.root === 'string') {
|
|
13
|
+
const root = resolve(dirname(blueprintFile), r.root);
|
|
14
|
+
return root === projectRootDir;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
});
|
|
18
|
+
if (!blueprintReferencesStudio)
|
|
19
|
+
return [];
|
|
20
|
+
const stack = await readStack({
|
|
21
|
+
token,
|
|
22
|
+
overrides: { stackId },
|
|
23
|
+
});
|
|
24
|
+
return stack.resources
|
|
25
|
+
.filter((r) => r.externalId)
|
|
26
|
+
.map((r) => ({
|
|
27
|
+
type: r.type,
|
|
28
|
+
name: r.name,
|
|
29
|
+
id: r.externalId || '',
|
|
30
|
+
}));
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw new Error(`Unable to resolve resources from blueprint in ${projectRootDir}`, {
|
|
34
|
+
cause: error,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -395,9 +395,9 @@ export type AssetPrepResult = {
|
|
|
395
395
|
export type PrepAssetFn<R extends BlueprintResource> = (options: {
|
|
396
396
|
resolvedResource: ResolvedResource<R>;
|
|
397
397
|
blueprintFileDir: string;
|
|
398
|
+
stackId: string;
|
|
399
|
+
auth: AuthParams;
|
|
398
400
|
installer?: InstallerType;
|
|
399
|
-
/** Deploy auth; the agent prep uses `auth.scopeId` for the manifest `sanityID`. */
|
|
400
|
-
auth?: AuthParams;
|
|
401
401
|
}) => Promise<AssetPrepResult>;
|
|
402
402
|
export type PrepResourceFn<R extends BlueprintResource> = (options: {
|
|
403
403
|
resource: R;
|
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.
|
|
4
|
+
"version": "17.21.6-next.g813863a",
|
|
5
5
|
"author": "Sanity Runtime Team",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"license": "MIT",
|
|
@@ -70,11 +70,11 @@
|
|
|
70
70
|
"@oclif/core": "^4.14.0",
|
|
71
71
|
"@oclif/plugin-help": "^6.3.0",
|
|
72
72
|
"@sanity-labs/oclif-plugin-skills-flag": "^0.2.1",
|
|
73
|
-
"@sanity/blueprints": "^0.34.
|
|
73
|
+
"@sanity/blueprints": "^0.34.1",
|
|
74
74
|
"@sanity/blueprints-parser": "^0.5.0",
|
|
75
|
-
"@sanity/cli-build": "^7.
|
|
76
|
-
"@sanity/cli-core": "^3.
|
|
77
|
-
"@sanity/client": "^8.
|
|
75
|
+
"@sanity/cli-build": "^7.4.0",
|
|
76
|
+
"@sanity/cli-core": "^3.15.1",
|
|
77
|
+
"@sanity/client": "^8.16.0",
|
|
78
78
|
"adm-zip": "^0.6.1",
|
|
79
79
|
"array-treeify": "^0.2.0",
|
|
80
80
|
"cardinal": "^2.1.1",
|