@sanity/runtime-cli 1.3.0 → 1.3.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 CHANGED
@@ -20,7 +20,7 @@ $ npm install -g @sanity/runtime-cli
20
20
  $ sanity COMMAND
21
21
  running command...
22
22
  $ sanity (--version)
23
- @sanity/runtime-cli/1.3.0 linux-x64 node-v22.14.0
23
+ @sanity/runtime-cli/1.3.1 linux-x64 node-v22.14.0
24
24
  $ sanity --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity COMMAND
@@ -64,7 +64,7 @@ EXAMPLES
64
64
  $ sanity blueprints deploy
65
65
  ```
66
66
 
67
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/blueprints/deploy.ts)_
67
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/blueprints/deploy.ts)_
68
68
 
69
69
  ## `sanity blueprints info`
70
70
 
@@ -81,7 +81,7 @@ EXAMPLES
81
81
  $ sanity blueprints info
82
82
  ```
83
83
 
84
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/blueprints/info.ts)_
84
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/blueprints/info.ts)_
85
85
 
86
86
  ## `sanity blueprints logs`
87
87
 
@@ -106,7 +106,7 @@ EXAMPLES
106
106
  $ sanity blueprints logs --watch
107
107
  ```
108
108
 
109
- _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/blueprints/logs.ts)_
109
+ _See code: [src/commands/blueprints/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/blueprints/logs.ts)_
110
110
 
111
111
  ## `sanity blueprints plan`
112
112
 
@@ -123,7 +123,7 @@ EXAMPLES
123
123
  $ sanity blueprints plan
124
124
  ```
125
125
 
126
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/blueprints/plan.ts)_
126
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/blueprints/plan.ts)_
127
127
 
128
128
  ## `sanity functions dev`
129
129
 
@@ -143,7 +143,7 @@ EXAMPLES
143
143
  $ sanity functions dev --port 8974
144
144
  ```
145
145
 
146
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/functions/dev.ts)_
146
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/functions/dev.ts)_
147
147
 
148
148
  ## `sanity functions invoke ID`
149
149
 
@@ -169,7 +169,7 @@ EXAMPLES
169
169
  $ sanity functions invoke <ID> --file 'payload.json'
170
170
  ```
171
171
 
172
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/functions/invoke.ts)_
172
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/functions/invoke.ts)_
173
173
 
174
174
  ## `sanity functions logs ID`
175
175
 
@@ -189,7 +189,7 @@ EXAMPLES
189
189
  $ sanity functions logs <ID>
190
190
  ```
191
191
 
192
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/functions/logs.ts)_
192
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/functions/logs.ts)_
193
193
 
194
194
  ## `sanity functions test PATH`
195
195
 
@@ -218,7 +218,7 @@ EXAMPLES
218
218
  $ sanity functions test ./test.ts --data '{ "id": 1 }' --timeout 60
219
219
  ```
220
220
 
221
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.0/src/commands/functions/test.ts)_
221
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.3.1/src/commands/functions/test.ts)_
222
222
 
223
223
  ## `sanity help [COMMAND]`
224
224
 
@@ -1,7 +1,6 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
- import { join } from 'node:path';
3
- import { cwd } from 'node:process';
4
2
  import { default as mime } from 'mime-types';
3
+ import readBlueprintOnDisk from '../actions/blueprints/read-blueprint.js';
5
4
  import invoke from '../utils/invoke-local.js';
6
5
  import * as http from 'node:http';
7
6
  const host = 'localhost';
@@ -10,10 +9,16 @@ const app = (port) => {
10
9
  res.setHeader('Content-Type', 'application/json');
11
10
  switch (req.url) {
12
11
  case '/blueprint': {
13
- res.setHeader('Content-Type', 'application/json');
14
- const blueprint = readFileSync(join(cwd(), './blueprint.json')).toString();
15
- res.writeHead(200);
16
- res.end(blueprint);
12
+ try {
13
+ const blueprint = readBlueprintOnDisk();
14
+ res.setHeader('Content-Type', 'application/json');
15
+ res.writeHead(200);
16
+ res.end(JSON.stringify(blueprint));
17
+ }
18
+ catch {
19
+ res.writeHead(404);
20
+ res.end();
21
+ }
17
22
  break;
18
23
  }
19
24
  case '/invoke': {
@@ -42,9 +42,12 @@ function blueprint() {
42
42
  fetch('/blueprint')
43
43
  .then((response) => response.json())
44
44
  .then((json) => {
45
- const functions = json?.resources.filter((resource) => resource.kind === 'function')
45
+ const functions = json?.document?.resources.filter((resource) => resource.kind === 'function')
46
46
 
47
47
  store.functions = functions
48
48
  store.selectedIndex = functions[0].src
49
49
  })
50
+ .catch(() => {
51
+ store.functions = []
52
+ })
50
53
  }
@@ -15,18 +15,23 @@ class FunctionList extends ApiBaseElement {
15
15
  this.api.store.selectedIndex = event.srcElement.value
16
16
  }
17
17
  renderFunctions = () => {
18
- this.list.innerHTML = this.api.store.functions
19
- .map((func) => {
20
- const selected = this.api.store.selectedIndex === func.src ? 'selected' : ''
21
- return `<li class="pad-sm ${selected}">${func.name}</li>`
22
- })
23
- .join('')
24
- this.select.innerHTML = this.api.store.functions
25
- .map((func) => {
26
- const selected = this.api.store.selectedIndex === func.src ? 'selected' : ''
27
- return `<option value="${func.src}" ${selected}>${func.name}</option>`
28
- })
29
- .join('')
18
+ if (this.api.store.functions.length > 0) {
19
+ this.list.innerHTML = this.api.store.functions
20
+ .map((func) => {
21
+ const selected = this.api.store.selectedIndex === func.src ? 'selected' : ''
22
+ return `<li class="pad-sm ${selected}">${func.name}</li>`
23
+ })
24
+ .join('')
25
+ this.select.innerHTML = this.api.store.functions
26
+ .map((func) => {
27
+ const selected = this.api.store.selectedIndex === func.src ? 'selected' : ''
28
+ return `<option value="${func.src}" ${selected}>${func.name}</option>`
29
+ })
30
+ .join('')
31
+ } else {
32
+ this.list.innerHTML = '<option class="pad-sm">No blueprint.json file found</li>'
33
+ this.select.innerHTML = '<option>No blueprint.json file found</option>'
34
+ }
30
35
  }
31
36
 
32
37
  connectedCallback() {
@@ -291,5 +291,5 @@
291
291
  ]
292
292
  }
293
293
  },
294
- "version": "1.3.0"
294
+ "version": "1.3.1"
295
295
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sanity/runtime-cli",
3
3
  "description": "A new CLI generated with oclif",
4
- "version": "1.3.0",
4
+ "version": "1.3.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",