@sanity/runtime-cli 4.2.0 → 4.3.0

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 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/4.2.0 linux-x64 node-v22.14.0
23
+ @sanity/runtime-cli/4.3.0 linux-x64 node-v22.14.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -40,6 +40,7 @@ USAGE
40
40
  * [`sanity-run blueprints stacks`](#sanity-run-blueprints-stacks)
41
41
  * [`sanity-run functions dev`](#sanity-run-functions-dev)
42
42
  * [`sanity-run functions env add NAME KEY VALUE`](#sanity-run-functions-env-add-name-key-value)
43
+ * [`sanity-run functions env list NAME`](#sanity-run-functions-env-list-name)
43
44
  * [`sanity-run functions env remove NAME KEY`](#sanity-run-functions-env-remove-name-key)
44
45
  * [`sanity-run functions invoke NAME`](#sanity-run-functions-invoke-name)
45
46
  * [`sanity-run functions logs NAME`](#sanity-run-functions-logs-name)
@@ -73,7 +74,7 @@ EXAMPLES
73
74
  $ sanity-run blueprints add function --name my-function --function-type document-publish
74
75
  ```
75
76
 
76
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/add.ts)_
77
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/add.ts)_
77
78
 
78
79
  ## `sanity-run blueprints config`
79
80
 
@@ -102,7 +103,7 @@ EXAMPLES
102
103
  $ sanity-run blueprints config --edit --project-id <projectId> --stack-id <stackId>
103
104
  ```
104
105
 
105
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/config.ts)_
106
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/config.ts)_
106
107
 
107
108
  ## `sanity-run blueprints deploy`
108
109
 
@@ -122,7 +123,7 @@ EXAMPLES
122
123
  $ sanity-run blueprints deploy
123
124
  ```
124
125
 
125
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/deploy.ts)_
126
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/deploy.ts)_
126
127
 
127
128
  ## `sanity-run blueprints destroy`
128
129
 
@@ -145,7 +146,7 @@ EXAMPLES
145
146
  $ sanity-run blueprints destroy --id ST-a1b2c3
146
147
  ```
147
148
 
148
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/destroy.ts)_
149
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/destroy.ts)_
149
150
 
150
151
  ## `sanity-run blueprints info`
151
152
 
@@ -167,7 +168,7 @@ EXAMPLES
167
168
  $ sanity-run blueprints info --id ST-a1b2c3
168
169
  ```
169
170
 
170
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/info.ts)_
171
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/info.ts)_
171
172
 
172
173
  ## `sanity-run blueprints init`
173
174
 
@@ -197,7 +198,7 @@ EXAMPLES
197
198
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId> --stack-name <stackName>
198
199
  ```
199
200
 
200
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/init.ts)_
201
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/init.ts)_
201
202
 
202
203
  ## `sanity-run blueprints logs`
203
204
 
@@ -219,7 +220,7 @@ EXAMPLES
219
220
  $ sanity-run blueprints logs --watch
220
221
  ```
221
222
 
222
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/logs.ts)_
223
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/logs.ts)_
223
224
 
224
225
  ## `sanity-run blueprints plan`
225
226
 
@@ -236,7 +237,7 @@ EXAMPLES
236
237
  $ sanity-run blueprints plan
237
238
  ```
238
239
 
239
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/plan.ts)_
240
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/plan.ts)_
240
241
 
241
242
  ## `sanity-run blueprints stacks`
242
243
 
@@ -258,7 +259,7 @@ EXAMPLES
258
259
  $ sanity-run blueprints stacks --projectId a1b2c3
259
260
  ```
260
261
 
261
- _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/blueprints/stacks.ts)_
262
+ _See code: [src/commands/blueprints/stacks.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/blueprints/stacks.ts)_
262
263
 
263
264
  ## `sanity-run functions dev`
264
265
 
@@ -278,7 +279,7 @@ EXAMPLES
278
279
  $ sanity-run functions dev --port 8974
279
280
  ```
280
281
 
281
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/dev.ts)_
282
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/dev.ts)_
282
283
 
283
284
  ## `sanity-run functions env add NAME KEY VALUE`
284
285
 
@@ -300,7 +301,27 @@ EXAMPLES
300
301
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
301
302
  ```
302
303
 
303
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/env/add.ts)_
304
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/env/add.ts)_
305
+
306
+ ## `sanity-run functions env list NAME`
307
+
308
+ List the environment variables for a Sanity function
309
+
310
+ ```
311
+ USAGE
312
+ $ sanity-run functions env list NAME
313
+
314
+ ARGUMENTS
315
+ NAME The name of the Sanity Function
316
+
317
+ DESCRIPTION
318
+ List the environment variables for a Sanity function
319
+
320
+ EXAMPLES
321
+ $ sanity-run functions env list MyFunction
322
+ ```
323
+
324
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/env/list.ts)_
304
325
 
305
326
  ## `sanity-run functions env remove NAME KEY`
306
327
 
@@ -321,7 +342,7 @@ EXAMPLES
321
342
  $ sanity-run functions env remove MyFunction API_URL
322
343
  ```
323
344
 
324
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/env/remove.ts)_
345
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/env/remove.ts)_
325
346
 
326
347
  ## `sanity-run functions invoke NAME`
327
348
 
@@ -347,7 +368,7 @@ EXAMPLES
347
368
  $ sanity-run functions invoke <name> --file 'payload.json'
348
369
  ```
349
370
 
350
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/invoke.ts)_
371
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/invoke.ts)_
351
372
 
352
373
  ## `sanity-run functions logs NAME`
353
374
 
@@ -379,7 +400,7 @@ EXAMPLES
379
400
  $ sanity-run functions logs <name> --delete
380
401
  ```
381
402
 
382
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/logs.ts)_
403
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/logs.ts)_
383
404
 
384
405
  ## `sanity-run functions test NAME`
385
406
 
@@ -412,7 +433,7 @@ EXAMPLES
412
433
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
413
434
  ```
414
435
 
415
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v4.2.0/src/commands/functions/test.ts)_
436
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v4.3.0/src/commands/functions/test.ts)_
416
437
 
417
438
  ## `sanity-run help [COMMAND]`
418
439
 
@@ -1,2 +1,3 @@
1
+ export * from './list.js';
1
2
  export * from './remove.js';
2
3
  export * from './update.js';
@@ -1,2 +1,3 @@
1
+ export * from './list.js';
1
2
  export * from './remove.js';
2
3
  export * from './update.js';
@@ -0,0 +1,6 @@
1
+ import type { AuthParams } from '../../../utils/types.js';
2
+ export declare function list(id: string, auth: AuthParams): Promise<{
3
+ ok: boolean;
4
+ envvars: any;
5
+ error: any;
6
+ }>;
@@ -0,0 +1,15 @@
1
+ import config from '../../../config.js';
2
+ import getHeaders from '../../../utils/get-headers.js';
3
+ const { functions } = config.server;
4
+ export async function list(id, auth) {
5
+ const response = await fetch(`${functions}vX/functions/${id}/envvars`, {
6
+ headers: getHeaders(auth),
7
+ method: 'GET',
8
+ });
9
+ const json = await response.json();
10
+ return {
11
+ ok: response.ok,
12
+ envvars: json.envvars,
13
+ error: response.ok ? null : json?.error?.message,
14
+ };
15
+ }
@@ -0,0 +1,9 @@
1
+ import { Command } from '@oclif/core';
2
+ export default class List extends Command {
3
+ static args: {
4
+ name: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
5
+ };
6
+ static description: string;
7
+ static examples: string[];
8
+ run(): Promise<void>;
9
+ }
@@ -0,0 +1,30 @@
1
+ import { Args, Command } from '@oclif/core';
2
+ import { readBlueprintOnDisk } from '../../../actions/blueprints/blueprint.js';
3
+ import { list } from '../../../actions/functions/env/list.js';
4
+ import config from '../../../config.js';
5
+ import { findFunctionByName } from '../../../utils/find-function.js';
6
+ export default class List extends Command {
7
+ static args = {
8
+ name: Args.string({ description: 'The name of the Sanity Function', required: true }),
9
+ };
10
+ static description = 'List the environment variables for a Sanity function';
11
+ static examples = ['<%= config.bin %> <%= command.id %> MyFunction'];
12
+ async run() {
13
+ const { args } = await this.parse(List);
14
+ const { deployedStack } = await readBlueprintOnDisk({ getStack: true, token: config.token });
15
+ if (!deployedStack)
16
+ this.error('Stack not found. Is it deployed?'); // returns
17
+ const { projectId } = deployedStack;
18
+ const { externalId } = findFunctionByName(deployedStack, args.name);
19
+ const result = await list(externalId, {
20
+ token: config.token,
21
+ projectId,
22
+ });
23
+ if (!result.ok) {
24
+ this.error(`Error: ${result.error || 'Unknown error'}`);
25
+ }
26
+ for (const key of result.envvars) {
27
+ this.log(key);
28
+ }
29
+ }
30
+ }
@@ -701,6 +701,37 @@
701
701
  "add.js"
702
702
  ]
703
703
  },
704
+ "functions:env:list": {
705
+ "aliases": [],
706
+ "args": {
707
+ "name": {
708
+ "description": "The name of the Sanity Function",
709
+ "name": "name",
710
+ "required": true
711
+ }
712
+ },
713
+ "description": "List the environment variables for a Sanity function",
714
+ "examples": [
715
+ "<%= config.bin %> <%= command.id %> MyFunction"
716
+ ],
717
+ "flags": {},
718
+ "hasDynamicHelp": false,
719
+ "hiddenAliases": [],
720
+ "id": "functions:env:list",
721
+ "pluginAlias": "@sanity/runtime-cli",
722
+ "pluginName": "@sanity/runtime-cli",
723
+ "pluginType": "core",
724
+ "strict": true,
725
+ "enableJsonFlag": false,
726
+ "isESM": true,
727
+ "relativePath": [
728
+ "dist",
729
+ "commands",
730
+ "functions",
731
+ "env",
732
+ "list.js"
733
+ ]
734
+ },
704
735
  "functions:env:remove": {
705
736
  "aliases": [],
706
737
  "args": {
@@ -738,5 +769,5 @@
738
769
  ]
739
770
  }
740
771
  },
741
- "version": "4.2.0"
772
+ "version": "4.3.0"
742
773
  }
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": "4.2.0",
4
+ "version": "4.3.0",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",