@sanity/runtime-cli 7.6.0 → 7.6.2
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 +15 -15
- package/dist/actions/functions/test.js +1 -1
- package/dist/cores/index.d.ts +5 -2
- package/dist/cores/index.js +12 -4
- package/dist/server/app.js +1 -1
- package/dist/utils/invoke-local.d.ts +2 -2
- package/dist/utils/invoke-local.js +3 -1
- package/dist/utils/types.d.ts +5 -0
- package/oclif.manifest.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
|
|
|
20
20
|
$ sanity-run COMMAND
|
|
21
21
|
running command...
|
|
22
22
|
$ sanity-run (--version)
|
|
23
|
-
@sanity/runtime-cli/7.6.
|
|
23
|
+
@sanity/runtime-cli/7.6.2 linux-x64 node-v22.16.0
|
|
24
24
|
$ sanity-run --help [COMMAND]
|
|
25
25
|
USAGE
|
|
26
26
|
$ sanity-run COMMAND
|
|
@@ -84,7 +84,7 @@ EXAMPLES
|
|
|
84
84
|
$ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
|
|
85
85
|
```
|
|
86
86
|
|
|
87
|
-
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
87
|
+
_See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/add.ts)_
|
|
88
88
|
|
|
89
89
|
## `sanity-run blueprints config`
|
|
90
90
|
|
|
@@ -112,7 +112,7 @@ EXAMPLES
|
|
|
112
112
|
$ sanity-run blueprints config --edit --project-id <projectId>
|
|
113
113
|
```
|
|
114
114
|
|
|
115
|
-
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
115
|
+
_See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/config.ts)_
|
|
116
116
|
|
|
117
117
|
## `sanity-run blueprints deploy`
|
|
118
118
|
|
|
@@ -134,7 +134,7 @@ EXAMPLES
|
|
|
134
134
|
$ sanity-run blueprints deploy --no-wait
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
137
|
+
_See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/deploy.ts)_
|
|
138
138
|
|
|
139
139
|
## `sanity-run blueprints destroy`
|
|
140
140
|
|
|
@@ -155,7 +155,7 @@ EXAMPLES
|
|
|
155
155
|
$ sanity-run blueprints destroy
|
|
156
156
|
```
|
|
157
157
|
|
|
158
|
-
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
158
|
+
_See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/destroy.ts)_
|
|
159
159
|
|
|
160
160
|
## `sanity-run blueprints info`
|
|
161
161
|
|
|
@@ -172,7 +172,7 @@ EXAMPLES
|
|
|
172
172
|
$ sanity-run blueprints info
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
175
|
+
_See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/info.ts)_
|
|
176
176
|
|
|
177
177
|
## `sanity-run blueprints init [DIR]`
|
|
178
178
|
|
|
@@ -204,7 +204,7 @@ EXAMPLES
|
|
|
204
204
|
$ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId>
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
-
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
207
|
+
_See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/init.ts)_
|
|
208
208
|
|
|
209
209
|
## `sanity-run blueprints logs`
|
|
210
210
|
|
|
@@ -226,7 +226,7 @@ EXAMPLES
|
|
|
226
226
|
$ sanity-run blueprints logs --watch
|
|
227
227
|
```
|
|
228
228
|
|
|
229
|
-
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
229
|
+
_See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/logs.ts)_
|
|
230
230
|
|
|
231
231
|
## `sanity-run blueprints plan`
|
|
232
232
|
|
|
@@ -243,7 +243,7 @@ EXAMPLES
|
|
|
243
243
|
$ sanity-run blueprints plan
|
|
244
244
|
```
|
|
245
245
|
|
|
246
|
-
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
246
|
+
_See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/blueprints/plan.ts)_
|
|
247
247
|
|
|
248
248
|
## `sanity-run functions dev`
|
|
249
249
|
|
|
@@ -263,7 +263,7 @@ EXAMPLES
|
|
|
263
263
|
$ sanity-run functions dev --port 8974
|
|
264
264
|
```
|
|
265
265
|
|
|
266
|
-
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
266
|
+
_See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/dev.ts)_
|
|
267
267
|
|
|
268
268
|
## `sanity-run functions env add NAME KEY VALUE`
|
|
269
269
|
|
|
@@ -285,7 +285,7 @@ EXAMPLES
|
|
|
285
285
|
$ sanity-run functions env add MyFunction API_URL https://api.example.com/
|
|
286
286
|
```
|
|
287
287
|
|
|
288
|
-
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
288
|
+
_See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/env/add.ts)_
|
|
289
289
|
|
|
290
290
|
## `sanity-run functions env list NAME`
|
|
291
291
|
|
|
@@ -305,7 +305,7 @@ EXAMPLES
|
|
|
305
305
|
$ sanity-run functions env list MyFunction
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
308
|
+
_See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/env/list.ts)_
|
|
309
309
|
|
|
310
310
|
## `sanity-run functions env remove NAME KEY`
|
|
311
311
|
|
|
@@ -326,7 +326,7 @@ EXAMPLES
|
|
|
326
326
|
$ sanity-run functions env remove MyFunction API_URL
|
|
327
327
|
```
|
|
328
328
|
|
|
329
|
-
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
329
|
+
_See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/env/remove.ts)_
|
|
330
330
|
|
|
331
331
|
## `sanity-run functions logs NAME`
|
|
332
332
|
|
|
@@ -360,7 +360,7 @@ EXAMPLES
|
|
|
360
360
|
$ sanity-run functions logs <name> --delete
|
|
361
361
|
```
|
|
362
362
|
|
|
363
|
-
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
363
|
+
_See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/logs.ts)_
|
|
364
364
|
|
|
365
365
|
## `sanity-run functions test NAME`
|
|
366
366
|
|
|
@@ -393,7 +393,7 @@ EXAMPLES
|
|
|
393
393
|
$ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
|
|
394
394
|
```
|
|
395
395
|
|
|
396
|
-
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.
|
|
396
|
+
_See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v7.6.2/src/commands/functions/test.ts)_
|
|
397
397
|
|
|
398
398
|
## `sanity-run help [COMMAND]`
|
|
399
399
|
|
|
@@ -2,7 +2,7 @@ import invoke from '../../utils/invoke-local.js';
|
|
|
2
2
|
export async function testAction(resource, options, context) {
|
|
3
3
|
const { payload = null, timeout } = options;
|
|
4
4
|
try {
|
|
5
|
-
const { json, logs } = await invoke(resource, payload, context, timeout);
|
|
5
|
+
const { json, logs } = await invoke(resource, payload, context, { timeout });
|
|
6
6
|
return { error: undefined, json, logs };
|
|
7
7
|
}
|
|
8
8
|
catch (error) {
|
package/dist/cores/index.d.ts
CHANGED
|
@@ -31,9 +31,12 @@ export type CoreResult = {
|
|
|
31
31
|
streaming?: Promise<void>;
|
|
32
32
|
error?: never;
|
|
33
33
|
};
|
|
34
|
-
export declare function initBlueprintConfig({ bin, log, token, }: {
|
|
34
|
+
export declare function initBlueprintConfig({ bin, log, token, validateToken, }: {
|
|
35
35
|
bin: string;
|
|
36
36
|
log: (msg: string) => void;
|
|
37
37
|
token: string;
|
|
38
|
+
validateToken?: boolean;
|
|
38
39
|
}): Promise<Result<BlueprintConfig>>;
|
|
39
|
-
export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'token'>
|
|
40
|
+
export declare function initDeployedBlueprintConfig(config: Partial<BlueprintConfig> & Pick<BlueprintConfig, 'bin' | 'log' | 'token'> & {
|
|
41
|
+
validateToken?: boolean;
|
|
42
|
+
}): Promise<Result<DeployedBlueprintConfig>>;
|
package/dist/cores/index.js
CHANGED
|
@@ -2,9 +2,18 @@ import { readLocalBlueprint } from '../actions/blueprints/blueprint.js';
|
|
|
2
2
|
import { getStack } from '../actions/blueprints/stacks.js';
|
|
3
3
|
import { presentBlueprintParserErrors } from '../utils/display/errors.js';
|
|
4
4
|
import { niceId } from '../utils/display/presenters.js';
|
|
5
|
+
import { validTokenOrErrorMessage } from '../utils/validated-token.js';
|
|
5
6
|
export * as blueprintsCores from './blueprints/index.js';
|
|
6
7
|
export * as functionsCores from './functions/index.js';
|
|
7
|
-
export async function initBlueprintConfig({ bin, log, token, }) {
|
|
8
|
+
export async function initBlueprintConfig({ bin, log, token, validateToken = true, }) {
|
|
9
|
+
let checkedToken = token;
|
|
10
|
+
if (validateToken) {
|
|
11
|
+
const tokenCheck = await validTokenOrErrorMessage(token);
|
|
12
|
+
if (tokenCheck.error) {
|
|
13
|
+
return { ok: false, error: tokenCheck.error.message };
|
|
14
|
+
}
|
|
15
|
+
checkedToken = tokenCheck.token;
|
|
16
|
+
}
|
|
8
17
|
const blueprint = await readLocalBlueprint();
|
|
9
18
|
if (blueprint.errors.length > 0) {
|
|
10
19
|
log(presentBlueprintParserErrors(blueprint.errors));
|
|
@@ -16,16 +25,15 @@ export async function initBlueprintConfig({ bin, log, token, }) {
|
|
|
16
25
|
bin,
|
|
17
26
|
blueprint,
|
|
18
27
|
log,
|
|
19
|
-
token,
|
|
28
|
+
token: checkedToken,
|
|
20
29
|
},
|
|
21
30
|
};
|
|
22
31
|
}
|
|
23
32
|
export async function initDeployedBlueprintConfig(config) {
|
|
24
33
|
if (!config.blueprint) {
|
|
25
34
|
const blueprintResult = await initBlueprintConfig(config);
|
|
26
|
-
if (!blueprintResult.ok)
|
|
35
|
+
if (!blueprintResult.ok)
|
|
27
36
|
return blueprintResult;
|
|
28
|
-
}
|
|
29
37
|
config.blueprint = blueprintResult.value.blueprint;
|
|
30
38
|
config.token = blueprintResult.value.token;
|
|
31
39
|
}
|
package/dist/server/app.js
CHANGED
|
@@ -38,7 +38,7 @@ const app = (port) => {
|
|
|
38
38
|
const { parsedBlueprint } = await readLocalBlueprint();
|
|
39
39
|
const resource = findFunctionByName(parsedBlueprint, functionName);
|
|
40
40
|
const readBlueprintTime = performance.now() - start;
|
|
41
|
-
const response = await invoke(resource, event, context);
|
|
41
|
+
const response = await invoke(resource, event, context, { forceColor: false });
|
|
42
42
|
const timings = { ...response.timings, 'blueprint:read': readBlueprintTime };
|
|
43
43
|
const timingHeaders = [];
|
|
44
44
|
for (const [key, value] of Object.entries(timings)) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GroqRule, InvocationResponse, InvokeContextOptions, LocalFunctionResource } from './types.js';
|
|
1
|
+
import type { GroqRule, InvocationResponse, InvokeContextOptions, InvokeExecutionOptions, LocalFunctionResource } from './types.js';
|
|
2
2
|
export declare function sanitizeLogs(logs: string): string;
|
|
3
3
|
export declare const DEFAULT_GROQ_RULE: {
|
|
4
4
|
on: string[];
|
|
@@ -7,4 +7,4 @@ export declare const DEFAULT_GROQ_RULE: {
|
|
|
7
7
|
};
|
|
8
8
|
export declare function isDefaultGROQRule(rule: GroqRule | undefined): boolean;
|
|
9
9
|
export declare function applyGroqRule(resource: LocalFunctionResource, data: Record<string, unknown> | null): Promise<any>;
|
|
10
|
-
export default function invoke(resource: LocalFunctionResource, data: Record<string, unknown> | null, context: InvokeContextOptions,
|
|
10
|
+
export default function invoke(resource: LocalFunctionResource, data: Record<string, unknown> | null, context: InvokeContextOptions, options: InvokeExecutionOptions): Promise<InvocationResponse>;
|
|
@@ -48,10 +48,11 @@ export async function applyGroqRule(resource, data) {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
export default async function invoke(resource, data, context,
|
|
51
|
+
export default async function invoke(resource, data, context, options) {
|
|
52
52
|
if (!resource.src) {
|
|
53
53
|
throw new Error(`Function resource "${resource.name}" is missing the 'src' property.`);
|
|
54
54
|
}
|
|
55
|
+
const { forceColor = true, timeout = 10 } = options;
|
|
55
56
|
const filteredData = await applyGroqRule(resource, data);
|
|
56
57
|
let cleanupBundle = async () => { };
|
|
57
58
|
let functionPath = '';
|
|
@@ -74,6 +75,7 @@ export default async function invoke(resource, data, context, timeout = 10) {
|
|
|
74
75
|
child = spawn('node', ['--enable-source-maps', getChildProcessWrapperPath()], {
|
|
75
76
|
cwd: cwd(),
|
|
76
77
|
stdio: ['inherit', 'inherit', 'inherit', 'ipc'],
|
|
78
|
+
env: { ...process.env, FORCE_COLOR: forceColor ? '1' : '0' },
|
|
77
79
|
});
|
|
78
80
|
child.on('message', (data) => {
|
|
79
81
|
const executionTimeMs = performance.now() - executionStart;
|
package/dist/utils/types.d.ts
CHANGED
|
@@ -134,6 +134,11 @@ export interface InvokeContextOptions {
|
|
|
134
134
|
};
|
|
135
135
|
}
|
|
136
136
|
/** @internal */
|
|
137
|
+
export interface InvokeExecutionOptions {
|
|
138
|
+
forceColor?: boolean;
|
|
139
|
+
timeout?: number;
|
|
140
|
+
}
|
|
141
|
+
/** @internal */
|
|
137
142
|
export interface InvocationResponse {
|
|
138
143
|
error: undefined | unknown;
|
|
139
144
|
json: object | undefined;
|
package/oclif.manifest.json
CHANGED