@sanity/runtime-cli 5.0.3 → 5.0.4

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/5.0.3 linux-x64 node-v22.15.0
23
+ @sanity/runtime-cli/5.0.4 linux-x64 node-v22.15.0
24
24
  $ sanity-run --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity-run COMMAND
@@ -78,7 +78,7 @@ EXAMPLES
78
78
  $ sanity-run blueprints add function --name my-function --fn-type document-publish --lang js
79
79
  ```
80
80
 
81
- _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/add.ts)_
81
+ _See code: [src/commands/blueprints/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/add.ts)_
82
82
 
83
83
  ## `sanity-run blueprints config`
84
84
 
@@ -106,7 +106,7 @@ EXAMPLES
106
106
  $ sanity-run blueprints config --edit --project-id <projectId>
107
107
  ```
108
108
 
109
- _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/config.ts)_
109
+ _See code: [src/commands/blueprints/config.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/config.ts)_
110
110
 
111
111
  ## `sanity-run blueprints deploy`
112
112
 
@@ -128,7 +128,7 @@ EXAMPLES
128
128
  $ sanity-run blueprints deploy --no-wait
129
129
  ```
130
130
 
131
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/deploy.ts)_
131
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/deploy.ts)_
132
132
 
133
133
  ## `sanity-run blueprints destroy`
134
134
 
@@ -148,7 +148,7 @@ EXAMPLES
148
148
  $ sanity-run blueprints destroy
149
149
  ```
150
150
 
151
- _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/destroy.ts)_
151
+ _See code: [src/commands/blueprints/destroy.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/destroy.ts)_
152
152
 
153
153
  ## `sanity-run blueprints info`
154
154
 
@@ -165,7 +165,7 @@ EXAMPLES
165
165
  $ sanity-run blueprints info
166
166
  ```
167
167
 
168
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/info.ts)_
168
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/info.ts)_
169
169
 
170
170
  ## `sanity-run blueprints init [DIR]`
171
171
 
@@ -197,7 +197,7 @@ EXAMPLES
197
197
  $ sanity-run blueprints init --blueprint-type <json|js|ts> --project-id <projectId>
198
198
  ```
199
199
 
200
- _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/init.ts)_
200
+ _See code: [src/commands/blueprints/init.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/init.ts)_
201
201
 
202
202
  ## `sanity-run blueprints logs`
203
203
 
@@ -219,7 +219,7 @@ EXAMPLES
219
219
  $ sanity-run blueprints logs --watch
220
220
  ```
221
221
 
222
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/logs.ts)_
222
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/logs.ts)_
223
223
 
224
224
  ## `sanity-run blueprints plan`
225
225
 
@@ -236,7 +236,7 @@ EXAMPLES
236
236
  $ sanity-run blueprints plan
237
237
  ```
238
238
 
239
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/blueprints/plan.ts)_
239
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/blueprints/plan.ts)_
240
240
 
241
241
  ## `sanity-run functions dev`
242
242
 
@@ -256,7 +256,7 @@ EXAMPLES
256
256
  $ sanity-run functions dev --port 8974
257
257
  ```
258
258
 
259
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/dev.ts)_
259
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/dev.ts)_
260
260
 
261
261
  ## `sanity-run functions env add NAME KEY VALUE`
262
262
 
@@ -278,7 +278,7 @@ EXAMPLES
278
278
  $ sanity-run functions env add MyFunction API_URL https://api.example.com/
279
279
  ```
280
280
 
281
- _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/env/add.ts)_
281
+ _See code: [src/commands/functions/env/add.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/add.ts)_
282
282
 
283
283
  ## `sanity-run functions env list NAME`
284
284
 
@@ -298,7 +298,7 @@ EXAMPLES
298
298
  $ sanity-run functions env list MyFunction
299
299
  ```
300
300
 
301
- _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/env/list.ts)_
301
+ _See code: [src/commands/functions/env/list.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/list.ts)_
302
302
 
303
303
  ## `sanity-run functions env remove NAME KEY`
304
304
 
@@ -319,7 +319,7 @@ EXAMPLES
319
319
  $ sanity-run functions env remove MyFunction API_URL
320
320
  ```
321
321
 
322
- _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/env/remove.ts)_
322
+ _See code: [src/commands/functions/env/remove.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/env/remove.ts)_
323
323
 
324
324
  ## `sanity-run functions invoke NAME`
325
325
 
@@ -345,7 +345,7 @@ EXAMPLES
345
345
  $ sanity-run functions invoke <name> --file 'payload.json'
346
346
  ```
347
347
 
348
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/invoke.ts)_
348
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/invoke.ts)_
349
349
 
350
350
  ## `sanity-run functions logs NAME`
351
351
 
@@ -377,7 +377,7 @@ EXAMPLES
377
377
  $ sanity-run functions logs <name> --delete
378
378
  ```
379
379
 
380
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/logs.ts)_
380
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/logs.ts)_
381
381
 
382
382
  ## `sanity-run functions test NAME`
383
383
 
@@ -410,7 +410,7 @@ EXAMPLES
410
410
  $ sanity-run functions test <name> --data '{ "id": 1 }' --timeout 60
411
411
  ```
412
412
 
413
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.3/src/commands/functions/test.ts)_
413
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v5.0.4/src/commands/functions/test.ts)_
414
414
 
415
415
  ## `sanity-run help [COMMAND]`
416
416
 
@@ -30,7 +30,21 @@ process.on('message', async (data) => {
30
30
  let json = null
31
31
 
32
32
  // Import the function code
33
- const {handler} = await import(getFunctionSource(srcPath))
33
+ const entry = await import(getFunctionSource(srcPath))
34
+
35
+ let eventHandler = null
36
+
37
+ if (typeof entry.handler === 'function') {
38
+ eventHandler = entry.handler
39
+ } else if (typeof entry.default === 'function') {
40
+ eventHandler = entry.default
41
+ }
42
+
43
+ if (!eventHandler) {
44
+ throw new Error(
45
+ 'No valid handler found. Please provide a default export or a named export, "handler"',
46
+ )
47
+ }
34
48
 
35
49
  // backup stdout
36
50
  const originalStdoutWrite = process.stdout.write.bind(process.stdout)
@@ -43,9 +57,7 @@ process.on('message', async (data) => {
43
57
  return true
44
58
  }
45
59
 
46
- if (handler && typeof handler === 'function') {
47
- json = await handler({context, event})
48
- }
60
+ json = await eventHandler({context, event})
49
61
 
50
62
  // revert changes to stdout
51
63
  process.stdout.write = originalStdoutWrite
@@ -817,5 +817,5 @@
817
817
  ]
818
818
  }
819
819
  },
820
- "version": "5.0.3"
820
+ "version": "5.0.4"
821
821
  }
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": "5.0.3",
4
+ "version": "5.0.4",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",