@sanity/runtime-cli 14.12.0 → 14.12.1
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 -20
- package/dist/actions/blueprints/blueprint.d.ts +17 -0
- package/dist/actions/blueprints/blueprint.js +24 -20
- package/dist/actions/blueprints/resolve.d.ts +11 -6
- package/dist/actions/blueprints/resolve.js +14 -4
- package/dist/actions/functions/dev.d.ts +1 -2
- package/dist/actions/functions/dev.js +2 -2
- package/dist/baseCommands.d.ts +10 -23
- package/dist/baseCommands.js +26 -75
- package/dist/commands/blueprints/add.d.ts +3 -2
- package/dist/commands/blueprints/add.js +3 -2
- package/dist/commands/blueprints/config.d.ts +3 -2
- package/dist/commands/blueprints/config.js +3 -2
- package/dist/commands/blueprints/deploy.d.ts +3 -2
- package/dist/commands/blueprints/deploy.js +4 -3
- package/dist/commands/blueprints/destroy.d.ts +3 -2
- package/dist/commands/blueprints/destroy.js +3 -2
- package/dist/commands/blueprints/doctor.d.ts +0 -1
- package/dist/commands/blueprints/doctor.js +2 -3
- package/dist/commands/blueprints/init.d.ts +0 -1
- package/dist/commands/blueprints/init.js +1 -2
- package/dist/commands/blueprints/logs.d.ts +3 -2
- package/dist/commands/blueprints/logs.js +4 -3
- package/dist/commands/blueprints/plan.d.ts +3 -2
- package/dist/commands/blueprints/plan.js +5 -3
- package/dist/commands/blueprints/promote.d.ts +3 -2
- package/dist/commands/blueprints/promote.js +3 -2
- package/dist/commands/blueprints/stacks.d.ts +3 -2
- package/dist/commands/blueprints/stacks.js +3 -2
- package/dist/commands/functions/add.d.ts +3 -2
- package/dist/commands/functions/add.js +3 -2
- package/dist/commands/functions/build.d.ts +3 -2
- package/dist/commands/functions/build.js +3 -2
- package/dist/commands/functions/dev.d.ts +3 -2
- package/dist/commands/functions/dev.js +3 -2
- package/dist/commands/functions/env/add.d.ts +3 -2
- package/dist/commands/functions/env/add.js +3 -2
- package/dist/commands/functions/env/list.d.ts +3 -2
- package/dist/commands/functions/env/list.js +3 -2
- package/dist/commands/functions/env/remove.d.ts +3 -2
- package/dist/commands/functions/env/remove.js +3 -2
- package/dist/commands/functions/logs.d.ts +3 -2
- package/dist/commands/functions/logs.js +4 -3
- package/dist/commands/functions/test.d.ts +3 -2
- package/dist/commands/functions/test.js +3 -2
- package/dist/cores/blueprints/config.js +9 -4
- package/dist/cores/blueprints/destroy.js +78 -56
- package/dist/cores/blueprints/doctor.js +19 -5
- package/dist/cores/blueprints/init.js +2 -2
- package/dist/cores/functions/dev.js +1 -1
- package/dist/server/app.d.ts +1 -2
- package/dist/server/app.js +16 -8
- package/dist/server/handlers/invoke.d.ts +1 -2
- package/dist/server/handlers/invoke.js +4 -4
- package/oclif.manifest.json +3 -15
- package/package.json +1 -1
|
@@ -2,7 +2,9 @@ import { readFileSync } from 'node:fs';
|
|
|
2
2
|
import { arch, cwd, env, version as nodeVersion, platform } from 'node:process';
|
|
3
3
|
import * as resolve from 'empathic/resolve';
|
|
4
4
|
import ora from 'ora';
|
|
5
|
-
import {
|
|
5
|
+
import { loadAndParseBlueprint, } from '../../actions/blueprints/blueprint.js';
|
|
6
|
+
import { readConfigFile } from '../../actions/blueprints/config.js';
|
|
7
|
+
import { resolveIds } from '../../actions/blueprints/resolve.js';
|
|
6
8
|
import { getStack } from '../../actions/blueprints/stacks.js';
|
|
7
9
|
import config, { RUNTIME_CLI_VERSION } from '../../config.js';
|
|
8
10
|
import { check, filePathRelativeToCwd, niceId, renderSection, severe, unsure, } from '../../utils/display/presenters.js';
|
|
@@ -76,15 +78,27 @@ export async function blueprintDoctorCore(options) {
|
|
|
76
78
|
// --- BLUEPRINT ---
|
|
77
79
|
let localBlueprint;
|
|
78
80
|
try {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
81
|
+
const blueprint = await loadAndParseBlueprint(path, {
|
|
82
|
+
validateResources: options.validateResources || false,
|
|
83
|
+
});
|
|
84
|
+
const blueprintConfig = readConfigFile(blueprint.fileInfo.blueprintFilePath);
|
|
85
|
+
const resolved = resolveIds({
|
|
86
|
+
module: blueprint.module,
|
|
87
|
+
config: blueprintConfig,
|
|
88
|
+
});
|
|
89
|
+
localBlueprint = {
|
|
90
|
+
...blueprint,
|
|
91
|
+
blueprintConfig,
|
|
92
|
+
...resolved,
|
|
93
|
+
};
|
|
94
|
+
envRows.push(['Blueprint', filePathRelativeToCwd(blueprint.fileInfo.blueprintFilePath)]);
|
|
95
|
+
if (blueprint.errors.length === 0) {
|
|
82
96
|
diagnostics.blueprintValid = { status: true };
|
|
83
97
|
}
|
|
84
98
|
else {
|
|
85
99
|
diagnostics.blueprintValid = {
|
|
86
100
|
status: false,
|
|
87
|
-
detail: `${
|
|
101
|
+
detail: `${blueprint.errors.length} error(s)`,
|
|
88
102
|
};
|
|
89
103
|
}
|
|
90
104
|
}
|
|
@@ -17,7 +17,7 @@ const SCOPE_PROJECT = 'project';
|
|
|
17
17
|
const SCOPE_ORGANIZATION = 'organization';
|
|
18
18
|
export async function blueprintInitCore(options) {
|
|
19
19
|
const { bin = 'sanity', log, token, knownProjectId, args, flags, validateResources } = options;
|
|
20
|
-
const { dir: flagDir, example: flagExample, 'blueprint-type': flagBlueprintType, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, 'stack-id': flagStackId, 'stack-name': flagStackName, verbose
|
|
20
|
+
const { dir: flagDir, example: flagExample, 'blueprint-type': flagBlueprintType, 'project-id': flagProjectId, 'organization-id': flagOrganizationId, 'stack-id': flagStackId, 'stack-name': flagStackName, verbose = false, } = flags;
|
|
21
21
|
const { dir: argDir } = args;
|
|
22
22
|
const userProvidedDirName = argDir || flagDir;
|
|
23
23
|
const blueprintDir = userProvidedDirName || '.';
|
|
@@ -44,7 +44,7 @@ export async function blueprintInitCore(options) {
|
|
|
44
44
|
flagOrganizationId,
|
|
45
45
|
flagStackId,
|
|
46
46
|
flagStackName,
|
|
47
|
-
verbose
|
|
47
|
+
verbose,
|
|
48
48
|
});
|
|
49
49
|
}
|
|
50
50
|
// --example flag → scaffold from an example template
|
|
@@ -7,7 +7,7 @@ export async function functionDevCore(options) {
|
|
|
7
7
|
? { timeout }
|
|
8
8
|
: undefined;
|
|
9
9
|
try {
|
|
10
|
-
await dev(host, Number(port),
|
|
10
|
+
await dev(host, Number(port), options.validateResources || false, executionOptions);
|
|
11
11
|
log(`Server is running on http://${host}:${port}\n`);
|
|
12
12
|
return {
|
|
13
13
|
success: true,
|
package/dist/server/app.d.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import type { Logger } from '../utils/logger.js';
|
|
2
1
|
import { type InvokeExecutionOptions } from '../utils/types.js';
|
|
3
|
-
declare const app: (host: string, port: number,
|
|
2
|
+
declare const app: (host: string, port: number, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>) => void;
|
|
4
3
|
declare function parseDocumentUrl(url: string): {
|
|
5
4
|
projectId: string;
|
|
6
5
|
dataset: string;
|
package/dist/server/app.js
CHANGED
|
@@ -2,19 +2,25 @@ import { existsSync, readFileSync, watchFile } from 'node:fs';
|
|
|
2
2
|
import * as http from 'node:http';
|
|
3
3
|
import { default as mime } from 'mime-types';
|
|
4
4
|
import { WebSocketServer } from 'ws';
|
|
5
|
-
import {
|
|
5
|
+
import { findBlueprintFile, loadAndParseBlueprint } from '../actions/blueprints/blueprint.js';
|
|
6
|
+
import { readConfigFile } from '../actions/blueprints/config.js';
|
|
7
|
+
import { resolveIds } from '../actions/blueprints/resolve.js';
|
|
6
8
|
import config from '../config.js';
|
|
7
9
|
import { isRecord } from '../utils/is-record.js';
|
|
8
10
|
import { isEventType, isGroqContextOptions, } from '../utils/types.js';
|
|
9
11
|
import { handleInvokeRequest } from './handlers/invoke.js';
|
|
10
|
-
const app = (host, port,
|
|
12
|
+
const app = (host, port, validateResources, executionOptions) => {
|
|
11
13
|
const requestListener = async (req, res) => {
|
|
12
14
|
res.setHeader('Content-Type', 'application/json');
|
|
13
15
|
switch (true) {
|
|
14
16
|
case req.url === '/blueprint': {
|
|
15
17
|
try {
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
+
const blueprint = await loadAndParseBlueprint(undefined, { validateResources });
|
|
19
|
+
const { parsedBlueprint, fileInfo, module: blueprintModule } = blueprint;
|
|
20
|
+
const blueprintConfig = readConfigFile(fileInfo.blueprintFilePath);
|
|
21
|
+
const { projectId, organizationId } = resolveIds({
|
|
22
|
+
module: blueprintModule,
|
|
23
|
+
config: blueprintConfig,
|
|
18
24
|
});
|
|
19
25
|
res.setHeader('Content-Type', 'application/json');
|
|
20
26
|
res.writeHead(200);
|
|
@@ -44,7 +50,7 @@ const app = (host, port, logger, validateResources, executionOptions) => {
|
|
|
44
50
|
delete context.clientOptions.token;
|
|
45
51
|
}
|
|
46
52
|
}
|
|
47
|
-
const result = await handleInvokeRequest(functionName, event, metadata, context,
|
|
53
|
+
const result = await handleInvokeRequest(functionName, event, metadata, context, validateResources, executionOptions);
|
|
48
54
|
// Add Server-Timing header
|
|
49
55
|
const timingHeaders = [];
|
|
50
56
|
for (const [key, value] of Object.entries(result.timings)) {
|
|
@@ -230,10 +236,12 @@ const app = (host, port, logger, validateResources, executionOptions) => {
|
|
|
230
236
|
const server = http.createServer(requestListener);
|
|
231
237
|
server.listen(port, host, () => { });
|
|
232
238
|
const wss = new WebSocketServer({ port: 8974 });
|
|
233
|
-
wss.on('connection',
|
|
239
|
+
wss.on('connection', function connection(ws) {
|
|
234
240
|
ws.on('error', console.error);
|
|
235
|
-
const
|
|
236
|
-
|
|
241
|
+
const fileInfo = findBlueprintFile();
|
|
242
|
+
if (!fileInfo)
|
|
243
|
+
return;
|
|
244
|
+
watchFile(fileInfo.blueprintFilePath, { interval: 2007 }, () => {
|
|
237
245
|
ws.send('reload-blueprint');
|
|
238
246
|
});
|
|
239
247
|
});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { Logger } from '../../utils/logger.js';
|
|
2
1
|
import type { InvocationResponse, InvokeContextOptions, InvokeExecutionOptions, InvokePayloadMetadata } from '../../utils/types.js';
|
|
3
|
-
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: InvokePayloadMetadata, context: InvokeContextOptions,
|
|
2
|
+
export declare function handleInvokeRequest(functionName: string, event: Record<string, unknown>, metadata: InvokePayloadMetadata, context: InvokeContextOptions, validateResources: boolean, executionOptions?: Partial<InvokeExecutionOptions>): Promise<InvocationResponse & {
|
|
4
3
|
timings: Record<string, number>;
|
|
5
4
|
}>;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { loadAndParseBlueprint } from '../../actions/blueprints/blueprint.js';
|
|
2
2
|
import { findFunctionInResources } from '../../utils/find-function.js';
|
|
3
3
|
import invoke from '../../utils/invoke-local.js';
|
|
4
|
-
export async function handleInvokeRequest(functionName, event, metadata, context,
|
|
4
|
+
export async function handleInvokeRequest(functionName, event, metadata, context, validateResources, executionOptions) {
|
|
5
5
|
const start = performance.now();
|
|
6
|
-
const
|
|
7
|
-
const resource = findFunctionInResources(
|
|
6
|
+
const { resources } = await loadAndParseBlueprint(undefined, { validateResources });
|
|
7
|
+
const resource = findFunctionInResources(resources, functionName);
|
|
8
8
|
const readBlueprintTime = performance.now() - start;
|
|
9
9
|
const payload = {
|
|
10
10
|
payload: event,
|
package/oclif.manifest.json
CHANGED
|
@@ -220,7 +220,6 @@
|
|
|
220
220
|
"summary": "Add a function resource to a Blueprint",
|
|
221
221
|
"enableJsonFlag": true,
|
|
222
222
|
"needs": [
|
|
223
|
-
"token",
|
|
224
223
|
"blueprint"
|
|
225
224
|
],
|
|
226
225
|
"isESM": true,
|
|
@@ -405,7 +404,6 @@
|
|
|
405
404
|
},
|
|
406
405
|
"stack": {
|
|
407
406
|
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
408
|
-
"hidden": false,
|
|
409
407
|
"name": "stack",
|
|
410
408
|
"hasDynamicHelp": false,
|
|
411
409
|
"multiple": false,
|
|
@@ -641,7 +639,6 @@
|
|
|
641
639
|
"flags": {
|
|
642
640
|
"json": {
|
|
643
641
|
"description": "Format output as json",
|
|
644
|
-
"hidden": false,
|
|
645
642
|
"name": "json",
|
|
646
643
|
"allowNo": false,
|
|
647
644
|
"type": "boolean"
|
|
@@ -653,7 +650,6 @@
|
|
|
653
650
|
"char": "p",
|
|
654
651
|
"description": "Path to a Blueprint file or directory containing one",
|
|
655
652
|
"env": "SANITY_BLUEPRINT_PATH",
|
|
656
|
-
"hidden": false,
|
|
657
653
|
"name": "path",
|
|
658
654
|
"hasDynamicHelp": false,
|
|
659
655
|
"multiple": false,
|
|
@@ -857,7 +853,7 @@
|
|
|
857
853
|
},
|
|
858
854
|
"verbose": {
|
|
859
855
|
"description": "Verbose output",
|
|
860
|
-
"hidden":
|
|
856
|
+
"hidden": true,
|
|
861
857
|
"name": "verbose",
|
|
862
858
|
"allowNo": false,
|
|
863
859
|
"type": "boolean"
|
|
@@ -1016,7 +1012,6 @@
|
|
|
1016
1012
|
},
|
|
1017
1013
|
"stack": {
|
|
1018
1014
|
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1019
|
-
"hidden": false,
|
|
1020
1015
|
"name": "stack",
|
|
1021
1016
|
"hasDynamicHelp": false,
|
|
1022
1017
|
"multiple": false,
|
|
@@ -1068,8 +1063,7 @@
|
|
|
1068
1063
|
"summary": "Display logs for the current Blueprint's Stack deployment",
|
|
1069
1064
|
"enableJsonFlag": true,
|
|
1070
1065
|
"needs": [
|
|
1071
|
-
"deployedStack"
|
|
1072
|
-
"blueprint"
|
|
1066
|
+
"deployedStack"
|
|
1073
1067
|
],
|
|
1074
1068
|
"isESM": true,
|
|
1075
1069
|
"relativePath": [
|
|
@@ -1128,7 +1122,6 @@
|
|
|
1128
1122
|
},
|
|
1129
1123
|
"stack": {
|
|
1130
1124
|
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1131
|
-
"hidden": false,
|
|
1132
1125
|
"name": "stack",
|
|
1133
1126
|
"hasDynamicHelp": false,
|
|
1134
1127
|
"multiple": false,
|
|
@@ -1599,7 +1592,6 @@
|
|
|
1599
1592
|
"summary": "Add a Function to your Blueprint",
|
|
1600
1593
|
"enableJsonFlag": true,
|
|
1601
1594
|
"needs": [
|
|
1602
|
-
"token",
|
|
1603
1595
|
"blueprint"
|
|
1604
1596
|
],
|
|
1605
1597
|
"isESM": true,
|
|
@@ -1729,7 +1721,6 @@
|
|
|
1729
1721
|
"summary": "Build Sanity Function(s) to zip archives",
|
|
1730
1722
|
"enableJsonFlag": true,
|
|
1731
1723
|
"needs": [
|
|
1732
|
-
"token",
|
|
1733
1724
|
"blueprint"
|
|
1734
1725
|
],
|
|
1735
1726
|
"isESM": true,
|
|
@@ -1859,7 +1850,6 @@
|
|
|
1859
1850
|
"summary": "Start the Sanity Function emulator",
|
|
1860
1851
|
"enableJsonFlag": true,
|
|
1861
1852
|
"needs": [
|
|
1862
|
-
"token",
|
|
1863
1853
|
"blueprint"
|
|
1864
1854
|
],
|
|
1865
1855
|
"isESM": true,
|
|
@@ -1928,7 +1918,6 @@
|
|
|
1928
1918
|
},
|
|
1929
1919
|
"stack": {
|
|
1930
1920
|
"description": "Stack name or ID to use instead of the locally configured Stack",
|
|
1931
|
-
"hidden": false,
|
|
1932
1921
|
"name": "stack",
|
|
1933
1922
|
"hasDynamicHelp": false,
|
|
1934
1923
|
"multiple": false,
|
|
@@ -2335,7 +2324,6 @@
|
|
|
2335
2324
|
"summary": "Invoke a local Sanity Function",
|
|
2336
2325
|
"enableJsonFlag": true,
|
|
2337
2326
|
"needs": [
|
|
2338
|
-
"token",
|
|
2339
2327
|
"blueprint"
|
|
2340
2328
|
],
|
|
2341
2329
|
"isESM": true,
|
|
@@ -2689,5 +2677,5 @@
|
|
|
2689
2677
|
]
|
|
2690
2678
|
}
|
|
2691
2679
|
},
|
|
2692
|
-
"version": "14.12.
|
|
2680
|
+
"version": "14.12.1"
|
|
2693
2681
|
}
|