@sanity/runtime-cli 17.16.0 → 17.17.0-next.gde08b17
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 +25 -25
- package/dist/actions/blueprints/assets.d.ts +3 -3
- package/dist/actions/blueprints/assets.js +3 -3
- package/dist/actions/blueprints/pre-deploy.js +3 -3
- package/dist/actions/blueprints/process-assets.js +3 -2
- package/dist/actions/blueprints/resources.js +94 -1
- package/dist/config.js +4 -1
- package/dist/constants.d.ts +3 -0
- package/dist/constants.js +3 -0
- package/dist/cores/functions/add.js +12 -2
- package/dist/cores/functions/logs.d.ts +7 -0
- package/dist/cores/functions/logs.js +29 -16
- package/dist/cores/functions/test.js +15 -4
- package/dist/server/app.js +2 -2
- package/dist/server/static/vendor/vendor.bundle.js +21 -42
- package/dist/utils/blueprints/group-resources.d.ts +2 -1
- package/dist/utils/blueprints/group-resources.js +3 -3
- package/dist/utils/blueprints/resolve-deployed-resources.d.ts +2 -2
- package/dist/utils/blueprints/resolve-deployed-resources.js +4 -4
- package/dist/utils/bundles/prepare-asset.d.ts +3 -3
- package/dist/utils/bundles/prepare-asset.js +46 -12
- package/dist/utils/functions/child-runtime/durable.js +141 -23
- package/dist/utils/functions/child-runtime/getBatchResults.js +75 -0
- package/dist/utils/functions/child-runtime/step-history.d.ts +15 -0
- package/dist/utils/functions/child-runtime/step-history.js +52 -0
- package/dist/utils/functions/invoke/local.js +19 -8
- package/dist/utils/functions/invoke/resolve-invoke-type.d.ts +2 -2
- package/dist/utils/functions/invoke/resolve-invoke-type.js +2 -2
- package/dist/utils/functions/transpile/function.js +3 -0
- package/dist/utils/types.d.ts +21 -13
- package/dist/utils/types.js +1 -1
- package/oclif.manifest.json +993 -991
- package/package.json +5 -5
|
@@ -55,7 +55,7 @@ export async function functionTestCore(options) {
|
|
|
55
55
|
apiHost: config.apiUrl,
|
|
56
56
|
token: config.token || undefined,
|
|
57
57
|
withUserToken,
|
|
58
|
-
|
|
58
|
+
resolvedResources,
|
|
59
59
|
blueprintFileDir: dirname(blueprint.fileInfo.blueprintFilePath),
|
|
60
60
|
log,
|
|
61
61
|
};
|
|
@@ -116,7 +116,9 @@ export async function functionTestCore(options) {
|
|
|
116
116
|
}
|
|
117
117
|
};
|
|
118
118
|
const logNestedRuns = () => {
|
|
119
|
-
|
|
119
|
+
// Remove buffered logs for durable runs
|
|
120
|
+
const runs = plan.isDurable ? nestedRuns.splice(0) : [...nestedRuns];
|
|
121
|
+
for (const run of runs.sort((a, b) => a.order - b.order)) {
|
|
120
122
|
// Skip if is Durable so log ordering is retained
|
|
121
123
|
if (run.isLiveDurable)
|
|
122
124
|
continue;
|
|
@@ -155,10 +157,19 @@ export async function functionTestCore(options) {
|
|
|
155
157
|
if (event.kind === 'delegate') {
|
|
156
158
|
logNestedRuns();
|
|
157
159
|
}
|
|
158
|
-
const
|
|
160
|
+
const willRetry = event.phase === 'error' && typeof event.retryDelayMs === 'number';
|
|
161
|
+
const glyph = willRetry ? '⟳' : (STEP_PHASE_GLYPH[event.phase] ?? '•');
|
|
159
162
|
const duration = typeof event.durationMs === 'number' ? ` (${Math.round(event.durationMs)}ms)` : '';
|
|
163
|
+
const retriesPerformed = (event.attempt ?? 1) - 1;
|
|
164
|
+
let retryNote = '';
|
|
165
|
+
if (willRetry) {
|
|
166
|
+
retryNote = ` retry ${event.attempt} of ${event.maxAttempts}`;
|
|
167
|
+
}
|
|
168
|
+
else if (event.phase === 'error' && retriesPerformed > 0) {
|
|
169
|
+
retryNote = ` failed after ${retriesPerformed} retries`;
|
|
170
|
+
}
|
|
160
171
|
const detail = event.phase === 'error' && event.error ? ` ${event.error.message}` : '';
|
|
161
|
-
lines.push(` ${glyph} ${event.name} [${event.kind}]${duration}${detail}`);
|
|
172
|
+
lines.push(` ${glyph} ${event.name} [${event.kind}]${duration}${detail}${retryNote}`);
|
|
162
173
|
}
|
|
163
174
|
return lines;
|
|
164
175
|
}
|
package/dist/server/app.js
CHANGED
|
@@ -8,7 +8,7 @@ import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/
|
|
|
8
8
|
import { readConfigFile } from '../actions/blueprints/config.js';
|
|
9
9
|
import config from '../config.js';
|
|
10
10
|
import { isRecord } from '../utils/is-record.js';
|
|
11
|
-
import { isEventType,
|
|
11
|
+
import { isEventType, } from '../utils/types.js';
|
|
12
12
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
13
13
|
const app = (host, port, validateResources, executionOptions) => {
|
|
14
14
|
// Send a JSON envelope to every connected UI client.
|
|
@@ -75,7 +75,7 @@ const app = (host, port, validateResources, executionOptions) => {
|
|
|
75
75
|
const { data, func: functionName, metadata, } = parseInvokeRequest(Buffer.concat(body), dirname(fileInfo.blueprintFilePath));
|
|
76
76
|
const { context, event } = data;
|
|
77
77
|
// replace user token if required
|
|
78
|
-
if (
|
|
78
|
+
if ('clientOptions' in context) {
|
|
79
79
|
if (context.clientOptions.token) {
|
|
80
80
|
context.clientOptions.token = config.token || undefined;
|
|
81
81
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// node_modules/@lezer/common/dist/index.js
|
|
2
2
|
/**
|
|
3
3
|
The default maximum length of a `TreeBuffer` node.
|
|
4
4
|
*/
|
|
@@ -1517,8 +1517,7 @@ var StringInput = class {
|
|
|
1517
1517
|
}
|
|
1518
1518
|
};
|
|
1519
1519
|
new NodeProp({ perNode: true });
|
|
1520
|
-
|
|
1521
|
-
//#region node_modules/@lezer/lr/dist/index.js
|
|
1520
|
+
// node_modules/@lezer/lr/dist/index.js
|
|
1522
1521
|
/**
|
|
1523
1522
|
A parse stack. These are used internally by the parser to track
|
|
1524
1523
|
parsing progress. They also provide some properties and methods
|
|
@@ -2963,8 +2962,7 @@ function getSpecializer(spec) {
|
|
|
2963
2962
|
}
|
|
2964
2963
|
return spec.get;
|
|
2965
2964
|
}
|
|
2966
|
-
|
|
2967
|
-
//#region node_modules/@lezer/highlight/dist/index.js
|
|
2965
|
+
// node_modules/@lezer/highlight/dist/index.js
|
|
2968
2966
|
var nextTagID = 0;
|
|
2969
2967
|
/**
|
|
2970
2968
|
Highlighting tags are markers that denote a highlighting category.
|
|
@@ -3836,8 +3834,7 @@ tagHighlighter([
|
|
|
3836
3834
|
class: "tok-punctuation"
|
|
3837
3835
|
}
|
|
3838
3836
|
]);
|
|
3839
|
-
|
|
3840
|
-
//#region node_modules/@lezer/json/dist/index.js
|
|
3837
|
+
// node_modules/@lezer/json/dist/index.js
|
|
3841
3838
|
var jsonHighlighting = styleTags({
|
|
3842
3839
|
String: tags.string,
|
|
3843
3840
|
Number: tags.number,
|
|
@@ -3886,8 +3883,7 @@ var parser = LRParser.deserialize({
|
|
|
3886
3883
|
topRules: { "JsonText": [0, 1] },
|
|
3887
3884
|
tokenPrec: 0
|
|
3888
3885
|
});
|
|
3889
|
-
|
|
3890
|
-
//#region node_modules/@marijn/find-cluster-break/src/index.js
|
|
3886
|
+
// node_modules/@marijn/find-cluster-break/src/index.js
|
|
3891
3887
|
var rangeFrom = [];
|
|
3892
3888
|
var rangeTo = [];
|
|
3893
3889
|
(() => {
|
|
@@ -3957,8 +3953,7 @@ function surrogateHigh$1(ch) {
|
|
|
3957
3953
|
function codePointSize$1(code) {
|
|
3958
3954
|
return code < 65536 ? 1 : 2;
|
|
3959
3955
|
}
|
|
3960
|
-
|
|
3961
|
-
//#region node_modules/@codemirror/state/dist/index.js
|
|
3956
|
+
// node_modules/@codemirror/state/dist/index.js
|
|
3962
3957
|
/**
|
|
3963
3958
|
The data structure for documents. @nonabstract
|
|
3964
3959
|
*/
|
|
@@ -7368,8 +7363,7 @@ function findColumn(string, col, tabSize, strict) {
|
|
|
7368
7363
|
}
|
|
7369
7364
|
return strict === true ? -1 : string.length;
|
|
7370
7365
|
}
|
|
7371
|
-
|
|
7372
|
-
//#region node_modules/style-mod/src/style-mod.js
|
|
7366
|
+
// node_modules/style-mod/src/style-mod.js
|
|
7373
7367
|
var C = "ͼ";
|
|
7374
7368
|
var COUNT = typeof Symbol == "undefined" ? "__ͼ" : Symbol.for(C);
|
|
7375
7369
|
var SET = typeof Symbol == "undefined" ? "__styleSet" + Math.floor(Math.random() * 1e8) : Symbol("styleSet");
|
|
@@ -7460,8 +7454,7 @@ var StyleSet = class {
|
|
|
7460
7454
|
if (this.styleTag && this.styleTag.getAttribute("nonce") != nonce) this.styleTag.setAttribute("nonce", nonce);
|
|
7461
7455
|
}
|
|
7462
7456
|
};
|
|
7463
|
-
|
|
7464
|
-
//#region node_modules/w3c-keyname/index.js
|
|
7457
|
+
// node_modules/w3c-keyname/index.js
|
|
7465
7458
|
var base = {
|
|
7466
7459
|
8: "Backspace",
|
|
7467
7460
|
9: "Tab",
|
|
@@ -7561,8 +7554,7 @@ function keyName(event) {
|
|
|
7561
7554
|
if (name == "Down") name = "ArrowDown";
|
|
7562
7555
|
return name;
|
|
7563
7556
|
}
|
|
7564
|
-
|
|
7565
|
-
//#region node_modules/crelt/index.js
|
|
7557
|
+
// node_modules/crelt/index.js
|
|
7566
7558
|
function crelt() {
|
|
7567
7559
|
var elt = arguments[0];
|
|
7568
7560
|
if (typeof elt == "string") elt = document.createElement(elt);
|
|
@@ -7584,8 +7576,7 @@ function add(elt, child) {
|
|
|
7584
7576
|
else if (Array.isArray(child)) for (var i = 0; i < child.length; i++) add(elt, child[i]);
|
|
7585
7577
|
else throw new RangeError("Unsupported child node: " + child);
|
|
7586
7578
|
}
|
|
7587
|
-
|
|
7588
|
-
//#region node_modules/@codemirror/view/dist/index.js
|
|
7579
|
+
// node_modules/@codemirror/view/dist/index.js
|
|
7589
7580
|
var nav = typeof navigator != "undefined" ? navigator : {
|
|
7590
7581
|
userAgent: "",
|
|
7591
7582
|
vendor: "",
|
|
@@ -17373,8 +17364,7 @@ line](https://codemirror.net/6/docs/ref/#view.highlightActiveLine).
|
|
|
17373
17364
|
function highlightActiveLineGutter() {
|
|
17374
17365
|
return activeLineGutterHighlighter;
|
|
17375
17366
|
}
|
|
17376
|
-
|
|
17377
|
-
//#region node_modules/@codemirror/language/dist/index.js
|
|
17367
|
+
// node_modules/@codemirror/language/dist/index.js
|
|
17378
17368
|
var _a;
|
|
17379
17369
|
/**
|
|
17380
17370
|
Node prop stored in a parser's top syntax node to provide the
|
|
@@ -19120,8 +19110,7 @@ function createTokenType(extra, tagStr) {
|
|
|
19120
19110
|
return type.id;
|
|
19121
19111
|
}
|
|
19122
19112
|
Direction.RTL, Direction.LTR;
|
|
19123
|
-
|
|
19124
|
-
//#region node_modules/@codemirror/lang-json/dist/index.js
|
|
19113
|
+
// node_modules/@codemirror/lang-json/dist/index.js
|
|
19125
19114
|
/**
|
|
19126
19115
|
A language provider that provides JSON parsing.
|
|
19127
19116
|
*/
|
|
@@ -19146,8 +19135,7 @@ JSON language support.
|
|
|
19146
19135
|
function json() {
|
|
19147
19136
|
return new LanguageSupport(jsonLanguage);
|
|
19148
19137
|
}
|
|
19149
|
-
|
|
19150
|
-
//#region node_modules/@enhance/store/index.mjs
|
|
19138
|
+
// node_modules/@enhance/store/index.mjs
|
|
19151
19139
|
var _state = {};
|
|
19152
19140
|
var dirtyProps = [];
|
|
19153
19141
|
var listeners = [];
|
|
@@ -19217,8 +19205,7 @@ function notify() {
|
|
|
19217
19205
|
});
|
|
19218
19206
|
dirtyProps.length = 0;
|
|
19219
19207
|
}
|
|
19220
|
-
|
|
19221
|
-
//#region node_modules/@codemirror/commands/dist/index.js
|
|
19208
|
+
// node_modules/@codemirror/commands/dist/index.js
|
|
19222
19209
|
/**
|
|
19223
19210
|
Comment or uncomment the current selection. Will use line comments
|
|
19224
19211
|
if available, otherwise falling back to block comments.
|
|
@@ -20929,8 +20916,7 @@ var defaultKeymap = /*@__PURE__*/ [
|
|
|
20929
20916
|
run: toggleTabFocusMode
|
|
20930
20917
|
}
|
|
20931
20918
|
].concat(standardKeymap);
|
|
20932
|
-
|
|
20933
|
-
//#region node_modules/@codemirror/search/dist/index.js
|
|
20919
|
+
// node_modules/@codemirror/search/dist/index.js
|
|
20934
20920
|
var basicNormalize = typeof String.prototype.normalize == "function" ? (x) => x.normalize("NFKD") : (x) => x;
|
|
20935
20921
|
/**
|
|
20936
20922
|
A search cursor provides an iterator over text matches in a
|
|
@@ -22070,8 +22056,7 @@ var searchExtensions = [
|
|
|
22070
22056
|
/*@__PURE__*/ Prec.low(searchHighlighter),
|
|
22071
22057
|
baseTheme$2
|
|
22072
22058
|
];
|
|
22073
|
-
|
|
22074
|
-
//#region node_modules/@codemirror/autocomplete/dist/index.js
|
|
22059
|
+
// node_modules/@codemirror/autocomplete/dist/index.js
|
|
22075
22060
|
/**
|
|
22076
22061
|
An instance of this is passed to completion source functions.
|
|
22077
22062
|
*/
|
|
@@ -23549,8 +23534,7 @@ var completionKeymap = [
|
|
|
23549
23534
|
}
|
|
23550
23535
|
];
|
|
23551
23536
|
var completionKeymapExt = /*@__PURE__*/ Prec.highest(/*@__PURE__*/ keymap.computeN([completionConfig], (state) => state.facet(completionConfig).defaultKeymap ? [completionKeymap] : []));
|
|
23552
|
-
|
|
23553
|
-
//#region node_modules/@codemirror/lint/dist/index.js
|
|
23537
|
+
// node_modules/@codemirror/lint/dist/index.js
|
|
23554
23538
|
var SelectedDiagnostic = class {
|
|
23555
23539
|
constructor(from, to, diagnostic) {
|
|
23556
23540
|
this.from = from;
|
|
@@ -24112,8 +24096,7 @@ var lintExtensions = [
|
|
|
24112
24096
|
lintHover,
|
|
24113
24097
|
baseTheme
|
|
24114
24098
|
];
|
|
24115
|
-
|
|
24116
|
-
//#region node_modules/codemirror/dist/index.js
|
|
24099
|
+
// node_modules/codemirror/dist/index.js
|
|
24117
24100
|
/**
|
|
24118
24101
|
This is an extension value that just pulls together a number of
|
|
24119
24102
|
extensions that you might want in a basic editor. It is meant as a
|
|
@@ -24179,8 +24162,7 @@ var basicSetup = /*@__PURE__*/ (() => [
|
|
|
24179
24162
|
...lintKeymap
|
|
24180
24163
|
])
|
|
24181
24164
|
])();
|
|
24182
|
-
|
|
24183
|
-
//#region node_modules/pretty-bytes/index.js
|
|
24165
|
+
// node_modules/pretty-bytes/index.js
|
|
24184
24166
|
var BYTE_UNITS = [
|
|
24185
24167
|
"B",
|
|
24186
24168
|
"kB",
|
|
@@ -24296,8 +24278,7 @@ function prettyBytes(number, options) {
|
|
|
24296
24278
|
}
|
|
24297
24279
|
return applyFixedWidth(prefix + toLocaleString(number, options.locale, localeOptions) + separator + UNITS[exponent], options.fixedWidth);
|
|
24298
24280
|
}
|
|
24299
|
-
|
|
24300
|
-
//#region node_modules/parse-ms/index.js
|
|
24281
|
+
// node_modules/parse-ms/index.js
|
|
24301
24282
|
var toZeroIfInfinity = (value) => Number.isFinite(value) ? value : 0;
|
|
24302
24283
|
function parseNumber(milliseconds) {
|
|
24303
24284
|
return {
|
|
@@ -24330,8 +24311,7 @@ function parseMilliseconds(milliseconds) {
|
|
|
24330
24311
|
}
|
|
24331
24312
|
throw new TypeError("Expected a finite number or bigint");
|
|
24332
24313
|
}
|
|
24333
|
-
|
|
24334
|
-
//#region node_modules/pretty-ms/index.js
|
|
24314
|
+
// node_modules/pretty-ms/index.js
|
|
24335
24315
|
var isZero = (value) => value === 0 || value === 0n;
|
|
24336
24316
|
var pluralize = (word, count) => count === 1 || count === 1n ? word : `${word}s`;
|
|
24337
24317
|
var SECOND_ROUNDING_EPSILON = 1e-7;
|
|
@@ -24410,5 +24390,4 @@ function prettyMilliseconds(milliseconds, options) {
|
|
|
24410
24390
|
if (typeof options.unitCount === "number") result = result.slice(0, Math.max(options.unitCount, 1));
|
|
24411
24391
|
return sign + result.join(separator);
|
|
24412
24392
|
}
|
|
24413
|
-
//#endregion
|
|
24414
24393
|
export { Compartment, EditorState, EditorView, HighlightStyle, Store, basicSetup, json, prettyBytes, prettyMilliseconds, syntaxHighlighting, tags };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
|
+
import type { ResolvedResource } from '../types.js';
|
|
2
3
|
export type GroupedBlueprintResource = {
|
|
3
4
|
id: string;
|
|
4
5
|
name: string;
|
|
5
6
|
type: string;
|
|
6
7
|
};
|
|
7
8
|
export type GroupedBlueprintResources = Record<string, GroupedBlueprintResource[]>;
|
|
8
|
-
export declare function groupBlueprintResources(blueprintResources: BlueprintResource[]): GroupedBlueprintResources;
|
|
9
|
+
export declare function groupBlueprintResources(blueprintResources: ResolvedResource<BlueprintResource>[]): GroupedBlueprintResources;
|
|
@@ -8,7 +8,8 @@ const BLUEPRINT_TYPE_TO_KEY = {
|
|
|
8
8
|
};
|
|
9
9
|
export function groupBlueprintResources(blueprintResources) {
|
|
10
10
|
const grouped = {};
|
|
11
|
-
for (const
|
|
11
|
+
for (const resolvedResource of blueprintResources) {
|
|
12
|
+
const resource = resolvedResource.resource;
|
|
12
13
|
if (resource.type === 'sanity.access.robot')
|
|
13
14
|
continue;
|
|
14
15
|
const key = (resource.type?.startsWith('sanity.function.')
|
|
@@ -18,9 +19,8 @@ export function groupBlueprintResources(blueprintResources) {
|
|
|
18
19
|
continue;
|
|
19
20
|
if (!grouped[key])
|
|
20
21
|
grouped[key] = [];
|
|
21
|
-
const externalId = resource.externalId;
|
|
22
22
|
grouped[key].push({
|
|
23
|
-
id: externalId || 'not-deployed',
|
|
23
|
+
id: resolvedResource.externalId || 'not-deployed',
|
|
24
24
|
name: resource.name,
|
|
25
25
|
type: resource.type,
|
|
26
26
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { BlueprintResource } from '@sanity/blueprints';
|
|
2
|
-
import type { AuthParams } from '../types.js';
|
|
2
|
+
import type { AuthParams, ResolvedResource } from '../types.js';
|
|
3
3
|
interface ResolveOptions {
|
|
4
4
|
resources: BlueprintResource[];
|
|
5
5
|
stackId?: string;
|
|
@@ -12,5 +12,5 @@ interface ResolveOptions {
|
|
|
12
12
|
* resources that aren't yet deployed are preserved without an externalId.
|
|
13
13
|
* Any failure to fetch the stack falls back to the raw local resources.
|
|
14
14
|
*/
|
|
15
|
-
export declare function resolveDeployedResources({ resources, stackId, auth, fetchFn, }: ResolveOptions): Promise<BlueprintResource[]>;
|
|
15
|
+
export declare function resolveDeployedResources({ resources, stackId, auth, fetchFn, }: ResolveOptions): Promise<ResolvedResource<BlueprintResource>[]>;
|
|
16
16
|
export {};
|
|
@@ -7,11 +7,11 @@ import { getStack } from '../../actions/blueprints/stacks.js';
|
|
|
7
7
|
*/
|
|
8
8
|
export async function resolveDeployedResources({ resources, stackId, auth, fetchFn, }) {
|
|
9
9
|
if (!stackId || !auth?.token || !auth.scopeType || !auth.scopeId)
|
|
10
|
-
return resources;
|
|
10
|
+
return resources.map((r) => ({ resource: r }));
|
|
11
11
|
try {
|
|
12
12
|
const response = await getStack({ stackId, auth, fetchFn });
|
|
13
13
|
if (!response.ok || !Array.isArray(response.stack?.resources))
|
|
14
|
-
return resources;
|
|
14
|
+
return resources.map((r) => ({ resource: r }));
|
|
15
15
|
const deployedByKey = new Map();
|
|
16
16
|
for (const deployed of response.stack.resources) {
|
|
17
17
|
if (deployed.externalId) {
|
|
@@ -20,10 +20,10 @@ export async function resolveDeployedResources({ resources, stackId, auth, fetch
|
|
|
20
20
|
}
|
|
21
21
|
return resources.map((resource) => {
|
|
22
22
|
const externalId = deployedByKey.get(`${resource.type}:${resource.name}`);
|
|
23
|
-
return
|
|
23
|
+
return { resource, externalId };
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
catch {
|
|
27
|
-
return resources;
|
|
27
|
+
return resources.map((r) => ({ resource: r }));
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { BlueprintApplicationResource, BlueprintInstallationConfigResource, BlueprintStudioResource } from '@sanity/blueprints';
|
|
2
2
|
import { type BuildStudioEventListener } from '@sanity/cli-build/_internal/build';
|
|
3
3
|
import type { Output } from '@sanity/cli-core';
|
|
4
|
-
import type { AssetPrepResult } from '../types.js';
|
|
4
|
+
import type { AssetPrepResult, ResolvedResource } from '../types.js';
|
|
5
5
|
export type BundleResource = BlueprintStudioResource | BlueprintApplicationResource | BlueprintInstallationConfigResource;
|
|
6
6
|
type BuildContext<R extends BundleResource> = {
|
|
7
7
|
resource: R;
|
|
@@ -28,9 +28,9 @@ export declare const BUNDLE_SPECS: {
|
|
|
28
28
|
build: typeof buildInstallationConfigBundle;
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
|
-
export declare function prepareBundleAsset<R extends BundleResource>({ blueprintFileDir,
|
|
31
|
+
export declare function prepareBundleAsset<R extends BundleResource>({ blueprintFileDir, resolvedResource, }: {
|
|
32
32
|
blueprintFileDir: string;
|
|
33
|
-
|
|
33
|
+
resolvedResource: ResolvedResource<R>;
|
|
34
34
|
}): Promise<AssetPrepResult>;
|
|
35
35
|
declare function buildStudioBundle({ resource, appId, workDir, outDir, output, eventListener, }: BuildContext<BlueprintStudioResource>): Promise<BuildResult>;
|
|
36
36
|
declare function buildApplicationBundle({ resource, appId, workDir, outDir, output, eventListener, }: BuildContext<BlueprintApplicationResource>): Promise<BuildResult>;
|
|
@@ -5,6 +5,7 @@ import path, { basename, dirname, join } from 'node:path';
|
|
|
5
5
|
import { pipeline } from 'node:stream/promises';
|
|
6
6
|
import { createGzip } from 'node:zlib';
|
|
7
7
|
import { buildApp, buildStudio, compareDependencyVersions, } from '@sanity/cli-build/_internal/build';
|
|
8
|
+
import { buildStudioSchemasAndManifests } from '@sanity/cli-build/_internal/extract';
|
|
8
9
|
import { getLocalPackageVersion } from '@sanity/cli-core';
|
|
9
10
|
import { pack } from 'tar-fs';
|
|
10
11
|
export const BUNDLE_SPECS = {
|
|
@@ -12,10 +13,11 @@ export const BUNDLE_SPECS = {
|
|
|
12
13
|
'sanity.application': { requiresAppId: true, build: buildApplicationBundle },
|
|
13
14
|
'sanity.installation.config': { requiresAppId: false, build: buildInstallationConfigBundle },
|
|
14
15
|
};
|
|
15
|
-
export async function prepareBundleAsset({ blueprintFileDir,
|
|
16
|
+
export async function prepareBundleAsset({ blueprintFileDir, resolvedResource, }) {
|
|
17
|
+
const resource = resolvedResource.resource;
|
|
16
18
|
// The lookup can't prove it yields the spec matching this R, so it's asserted once here.
|
|
17
19
|
const spec = BUNDLE_SPECS[resource.type];
|
|
18
|
-
const appId = getAppId(
|
|
20
|
+
const appId = getAppId(resolvedResource);
|
|
19
21
|
if (spec.requiresAppId && !appId) {
|
|
20
22
|
return {
|
|
21
23
|
success: false,
|
|
@@ -104,8 +106,15 @@ export async function prepareBundleAsset({ blueprintFileDir, resource, }) {
|
|
|
104
106
|
}
|
|
105
107
|
}
|
|
106
108
|
async function buildStudioBundle({ resource, appId, workDir, outDir, output, eventListener, }) {
|
|
109
|
+
// this has been checked before we got here but this helps the type checker
|
|
110
|
+
if (!appId)
|
|
111
|
+
throw new Error(`Unable to determine appId for ${resource.type} resource '${resource.name}'`);
|
|
112
|
+
// currently we only support hard-coded project, support for dynamic project id to be added
|
|
113
|
+
const projectId = resource.project;
|
|
114
|
+
if (!projectId || projectId.startsWith('$.'))
|
|
115
|
+
throw new Error(`Unable to determine project for ${resource.type} resource '${resource.name}'`);
|
|
107
116
|
let mismatchedPackages;
|
|
108
|
-
await buildStudio({
|
|
117
|
+
const { mfManifest } = await buildStudio({
|
|
109
118
|
appId,
|
|
110
119
|
autoUpdatesEnabled: resource.autoUpdates.enabled,
|
|
111
120
|
checkAppId() { },
|
|
@@ -117,10 +126,12 @@ async function buildStudioBundle({ resource, appId, workDir, outDir, output, eve
|
|
|
117
126
|
determineBasePath() {
|
|
118
127
|
return resource.basePath ?? '/';
|
|
119
128
|
},
|
|
120
|
-
// a studio is a standalone app, not a workbench module-federation app
|
|
121
129
|
isApp: false,
|
|
122
130
|
isBlueprints: true,
|
|
123
|
-
|
|
131
|
+
// federated so the build emits mf-manifest.json for Brett; like `sanity build` for a
|
|
132
|
+
// `defineApplication` studio, this drops the auto-updates import map
|
|
133
|
+
isWorkbenchApp: true,
|
|
134
|
+
workbenchAppId: appId,
|
|
124
135
|
minify: resource.minify ?? true,
|
|
125
136
|
outDir,
|
|
126
137
|
output,
|
|
@@ -134,6 +145,21 @@ async function buildStudioBundle({ resource, appId, workDir, outDir, output, eve
|
|
|
134
145
|
workDir,
|
|
135
146
|
eventListener,
|
|
136
147
|
});
|
|
148
|
+
if (mfManifest) {
|
|
149
|
+
resource.mfManifest = mfManifest;
|
|
150
|
+
}
|
|
151
|
+
const { schemaInputs } = await buildStudioSchemasAndManifests(appId, {
|
|
152
|
+
configPath: resource.root,
|
|
153
|
+
isExternal: false,
|
|
154
|
+
outPath: outDir,
|
|
155
|
+
projectId,
|
|
156
|
+
schemaRequired: false,
|
|
157
|
+
verbose: false,
|
|
158
|
+
workDir,
|
|
159
|
+
});
|
|
160
|
+
if (schemaInputs) {
|
|
161
|
+
resource.schemaInputs = schemaInputs;
|
|
162
|
+
}
|
|
137
163
|
return { mismatchedPackages };
|
|
138
164
|
}
|
|
139
165
|
async function buildApplicationBundle({ resource, appId, workDir, outDir, output, eventListener, }) {
|
|
@@ -142,7 +168,7 @@ async function buildApplicationBundle({ resource, appId, workDir, outDir, output
|
|
|
142
168
|
if (extraWindow) {
|
|
143
169
|
throw new Error(`Application resource '${resource.name}' declares more than one window view; at most one is allowed`);
|
|
144
170
|
}
|
|
145
|
-
await buildApp({
|
|
171
|
+
const { mfManifest } = await buildApp({
|
|
146
172
|
...sharedBuildAppOptions({ appId, workDir, outDir, output, eventListener }),
|
|
147
173
|
appId,
|
|
148
174
|
appTitle: resource.title,
|
|
@@ -153,11 +179,14 @@ async function buildApplicationBundle({ resource, appId, workDir, outDir, output
|
|
|
153
179
|
webWorkers: resource.webWorkers,
|
|
154
180
|
},
|
|
155
181
|
});
|
|
182
|
+
if (mfManifest) {
|
|
183
|
+
resource.mfManifest = mfManifest;
|
|
184
|
+
}
|
|
156
185
|
// a workbench app never auto-updates, so no dependency mismatches are compared
|
|
157
186
|
return {};
|
|
158
187
|
}
|
|
159
188
|
async function buildInstallationConfigBundle({ resource, workDir, outDir, output, eventListener, }) {
|
|
160
|
-
await buildApp({
|
|
189
|
+
const { mfManifest } = await buildApp({
|
|
161
190
|
...sharedBuildAppOptions({ appId: undefined, workDir, outDir, output, eventListener }),
|
|
162
191
|
appId: undefined,
|
|
163
192
|
appTitle: undefined,
|
|
@@ -165,6 +194,9 @@ async function buildInstallationConfigBundle({ resource, workDir, outDir, output
|
|
|
165
194
|
workbenchAppId: undefined,
|
|
166
195
|
exposes: { config: { appType: resource.appType, fields: resource.fields } },
|
|
167
196
|
});
|
|
197
|
+
if (mfManifest) {
|
|
198
|
+
resource.mfManifest = mfManifest;
|
|
199
|
+
}
|
|
168
200
|
return {};
|
|
169
201
|
}
|
|
170
202
|
// Options a workbench build (application or installation config) always sets the
|
|
@@ -247,6 +279,8 @@ function createSilentOutput() {
|
|
|
247
279
|
return undefined;
|
|
248
280
|
},
|
|
249
281
|
log() { },
|
|
282
|
+
logDiagnostic(_message) { },
|
|
283
|
+
logJson(_json) { },
|
|
250
284
|
warn(input) {
|
|
251
285
|
return input;
|
|
252
286
|
},
|
|
@@ -260,12 +294,12 @@ async function getInstalledSanityVersion(workDir) {
|
|
|
260
294
|
return undefined;
|
|
261
295
|
}
|
|
262
296
|
}
|
|
263
|
-
function getAppId(
|
|
264
|
-
if (
|
|
265
|
-
return
|
|
297
|
+
function getAppId(resolvedResource) {
|
|
298
|
+
if (resolvedResource.externalId) {
|
|
299
|
+
return resolvedResource.externalId;
|
|
266
300
|
}
|
|
267
|
-
else if (resource.lifecycle?.ownershipAction?.type === 'attach') {
|
|
268
|
-
return resource.lifecycle.ownershipAction.id;
|
|
301
|
+
else if (resolvedResource.resource.lifecycle?.ownershipAction?.type === 'attach') {
|
|
302
|
+
return resolvedResource.resource.lifecycle.ownershipAction.id;
|
|
269
303
|
}
|
|
270
304
|
return undefined;
|
|
271
305
|
}
|