@sanity/runtime-cli 1.2.0 → 1.2.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.2.0 linux-x64 node-v22.14.0
23
+ @sanity/runtime-cli/1.2.1 linux-x64 node-v22.14.0
24
24
  $ sanity --help [COMMAND]
25
25
  USAGE
26
26
  $ sanity COMMAND
@@ -63,7 +63,7 @@ EXAMPLES
63
63
  $ sanity blueprints deploy
64
64
  ```
65
65
 
66
- _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/blueprints/deploy.ts)_
66
+ _See code: [src/commands/blueprints/deploy.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/blueprints/deploy.ts)_
67
67
 
68
68
  ## `sanity blueprints info`
69
69
 
@@ -80,7 +80,7 @@ EXAMPLES
80
80
  $ sanity blueprints info
81
81
  ```
82
82
 
83
- _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/blueprints/info.ts)_
83
+ _See code: [src/commands/blueprints/info.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/blueprints/info.ts)_
84
84
 
85
85
  ## `sanity blueprints plan`
86
86
 
@@ -97,7 +97,7 @@ EXAMPLES
97
97
  $ sanity blueprints plan
98
98
  ```
99
99
 
100
- _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/blueprints/plan.ts)_
100
+ _See code: [src/commands/blueprints/plan.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/blueprints/plan.ts)_
101
101
 
102
102
  ## `sanity functions dev`
103
103
 
@@ -117,7 +117,7 @@ EXAMPLES
117
117
  $ sanity functions dev --port 8974
118
118
  ```
119
119
 
120
- _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/functions/dev.ts)_
120
+ _See code: [src/commands/functions/dev.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/functions/dev.ts)_
121
121
 
122
122
  ## `sanity functions invoke ID`
123
123
 
@@ -143,7 +143,7 @@ EXAMPLES
143
143
  $ sanity functions invoke <ID> --file 'payload.json'
144
144
  ```
145
145
 
146
- _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/functions/invoke.ts)_
146
+ _See code: [src/commands/functions/invoke.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/functions/invoke.ts)_
147
147
 
148
148
  ## `sanity functions logs ID`
149
149
 
@@ -163,7 +163,7 @@ EXAMPLES
163
163
  $ sanity functions logs <ID>
164
164
  ```
165
165
 
166
- _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/functions/logs.ts)_
166
+ _See code: [src/commands/functions/logs.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/functions/logs.ts)_
167
167
 
168
168
  ## `sanity functions test PATH`
169
169
 
@@ -192,7 +192,7 @@ EXAMPLES
192
192
  $ sanity functions test ./test.ts --data '{ "id": 1 }' --timeout 60
193
193
  ```
194
194
 
195
- _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.0/src/commands/functions/test.ts)_
195
+ _See code: [src/commands/functions/test.ts](https://github.com/sanity-io/runtime-cli/blob/v1.2.1/src/commands/functions/test.ts)_
196
196
 
197
197
  ## `sanity help [COMMAND]`
198
198
 
@@ -212,7 +212,7 @@ DESCRIPTION
212
212
  Display help for sanity.
213
213
  ```
214
214
 
215
- _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.25/src/commands/help.ts)_
215
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.26/src/commands/help.ts)_
216
216
 
217
217
  ## `sanity plugins`
218
218
 
@@ -235,7 +235,7 @@ EXAMPLES
235
235
  $ sanity plugins
236
236
  ```
237
237
 
238
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/index.ts)_
238
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/index.ts)_
239
239
 
240
240
  ## `sanity plugins add PLUGIN`
241
241
 
@@ -309,7 +309,7 @@ EXAMPLES
309
309
  $ sanity plugins inspect myplugin
310
310
  ```
311
311
 
312
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/inspect.ts)_
312
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/inspect.ts)_
313
313
 
314
314
  ## `sanity plugins install PLUGIN`
315
315
 
@@ -358,7 +358,7 @@ EXAMPLES
358
358
  $ sanity plugins install someuser/someplugin
359
359
  ```
360
360
 
361
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/install.ts)_
361
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/install.ts)_
362
362
 
363
363
  ## `sanity plugins link PATH`
364
364
 
@@ -389,7 +389,7 @@ EXAMPLES
389
389
  $ sanity plugins link myplugin
390
390
  ```
391
391
 
392
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/link.ts)_
392
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/link.ts)_
393
393
 
394
394
  ## `sanity plugins remove [PLUGIN]`
395
395
 
@@ -430,7 +430,7 @@ FLAGS
430
430
  --reinstall Reinstall all plugins after uninstalling.
431
431
  ```
432
432
 
433
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/reset.ts)_
433
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/reset.ts)_
434
434
 
435
435
  ## `sanity plugins uninstall [PLUGIN]`
436
436
 
@@ -458,7 +458,7 @@ EXAMPLES
458
458
  $ sanity plugins uninstall myplugin
459
459
  ```
460
460
 
461
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/uninstall.ts)_
461
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/uninstall.ts)_
462
462
 
463
463
  ## `sanity plugins unlink [PLUGIN]`
464
464
 
@@ -502,7 +502,7 @@ DESCRIPTION
502
502
  Update installed plugins.
503
503
  ```
504
504
 
505
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/update.ts)_
505
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
506
506
  <!-- commandsstop -->
507
507
  * [`sanity functions dev`](#sanity-functions-dev)
508
508
  * [`sanity functions invoke`](#sanity-functions-invoke)
@@ -1,5 +1,4 @@
1
- import { serve } from '@hono/node-server';
2
1
  import app from '../../server/app.js';
3
2
  export async function dev(port) {
4
- serve({ fetch: app.fetch, port: Number(port) });
3
+ app(Number(port));
5
4
  }
@@ -1,3 +1,2 @@
1
- import { Hono } from 'hono';
2
- declare const app: Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
1
+ declare const app: (port: number) => void;
3
2
  export default app;
@@ -1,36 +1,66 @@
1
- import { readFileSync } from 'node:fs';
1
+ import { existsSync, readFileSync } from 'node:fs';
2
2
  import { join } from 'node:path';
3
3
  import { cwd } from 'node:process';
4
- import { serveStatic } from '@hono/node-server/serve-static';
5
- import { Hono } from 'hono';
4
+ import { default as mime } from 'mime-types';
6
5
  import invoke from '../utils/invoke-local.js';
7
- import isDependency from '../utils/is-dependency.js';
8
- function errorResponse(code, message, details = {}) {
9
- return { error: { code, details, message } };
10
- }
11
- function getStaticPath() {
12
- return isDependency('./server/static')
13
- ? './node_modules/@sanity/runtime-cli/dist/server/static'
14
- : './src/server/static';
15
- }
16
- const app = new Hono();
17
- app.use('*', serveStatic({ root: getStaticPath() }));
18
- app.get('/blueprint', async (c) => {
19
- const response = JSON.parse(readFileSync(join(cwd(), './blueprint.json')).toString());
20
- return c.json(response);
21
- });
22
- app.post('/invoke', async (c) => {
23
- const { data = {}, func } = await c.req.json();
24
- const response = await invoke(func, { data: JSON.parse(data) });
25
- return c.json(response);
26
- });
27
- app
28
- .notFound((c) => c.json(errorResponse('NOT_FOUND', 'Not Found', {
29
- method: c.req.method,
30
- path: c.req.path,
31
- }), 404))
32
- .onError((err, c) => c.json(errorResponse('INTERNAL_SERVER_ERROR', 'Internal Server Error', {
33
- error: err.message,
34
- stack: err,
35
- }), 500));
6
+ import * as http from 'node:http';
7
+ const host = 'localhost';
8
+ const app = (port) => {
9
+ const requestListener = async (req, res) => {
10
+ res.setHeader('Content-Type', 'application/json');
11
+ switch (req.url) {
12
+ 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);
17
+ break;
18
+ }
19
+ case '/invoke': {
20
+ if (req.method === 'POST') {
21
+ let body = '';
22
+ req.on('data', (data) => {
23
+ body += data;
24
+ });
25
+ req.on('end', async () => {
26
+ const { data, func } = JSON.parse(body);
27
+ res.setHeader('Content-Type', 'application/json');
28
+ try {
29
+ const response = await invoke(func, { data: JSON.parse(data) });
30
+ res.writeHead(200);
31
+ res.end(JSON.stringify(response));
32
+ }
33
+ catch (error) {
34
+ const response = { logs: '', error: '' };
35
+ if (error instanceof Error) {
36
+ response.logs = error.message;
37
+ }
38
+ res.writeHead(200);
39
+ res.end(JSON.stringify(response));
40
+ }
41
+ });
42
+ }
43
+ break;
44
+ }
45
+ default: {
46
+ const requestPath = req.url?.endsWith('/') ? `${req.url}index.html` : req.url;
47
+ const filePath = new URL(`./static${requestPath}`, import.meta.url).pathname;
48
+ if (existsSync(filePath)) {
49
+ const mimeType = mime.lookup(filePath) || 'text/plain';
50
+ res.setHeader('Content-Type', mimeType);
51
+ const content = readFileSync(filePath).toString();
52
+ res.writeHead(200);
53
+ res.end(content);
54
+ }
55
+ else {
56
+ res.writeHead(404);
57
+ res.end();
58
+ }
59
+ break;
60
+ }
61
+ }
62
+ };
63
+ const server = http.createServer(requestListener);
64
+ server.listen(port, host, () => { });
65
+ };
36
66
  export default app;
@@ -8787,14 +8787,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
8787
8787
  let moveX = 0, moveY = 0;
8788
8788
  if (y == "nearest") {
8789
8789
  if (rect.top < bounding.top) {
8790
- moveY = -(bounding.top - rect.top + yMargin);
8790
+ moveY = rect.top - (bounding.top + yMargin);
8791
8791
  if (side > 0 && rect.bottom > bounding.bottom + moveY)
8792
- moveY = rect.bottom - bounding.bottom + moveY + yMargin;
8792
+ moveY = rect.bottom - bounding.bottom + yMargin;
8793
8793
  }
8794
8794
  else if (rect.bottom > bounding.bottom) {
8795
8795
  moveY = rect.bottom - bounding.bottom + yMargin;
8796
8796
  if (side < 0 && (rect.top - moveY) < bounding.top)
8797
- moveY = -(bounding.top + moveY - rect.top + yMargin);
8797
+ moveY = rect.top - (bounding.top + yMargin);
8798
8798
  }
8799
8799
  }
8800
8800
  else {
@@ -8806,14 +8806,14 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
8806
8806
  }
8807
8807
  if (x == "nearest") {
8808
8808
  if (rect.left < bounding.left) {
8809
- moveX = -(bounding.left - rect.left + xMargin);
8809
+ moveX = rect.left - (bounding.left + xMargin);
8810
8810
  if (side > 0 && rect.right > bounding.right + moveX)
8811
- moveX = rect.right - bounding.right + moveX + xMargin;
8811
+ moveX = rect.right - bounding.right + xMargin;
8812
8812
  }
8813
8813
  else if (rect.right > bounding.right) {
8814
8814
  moveX = rect.right - bounding.right + xMargin;
8815
8815
  if (side < 0 && rect.left < bounding.left + moveX)
8816
- moveX = -(bounding.left + moveX - rect.left + xMargin);
8816
+ moveX = rect.left - (bounding.left + xMargin);
8817
8817
  }
8818
8818
  }
8819
8819
  else {
@@ -8848,6 +8848,10 @@ function scrollRectIntoView(dom, rect, side, x, y, xMargin, yMargin, ltr) {
8848
8848
  }
8849
8849
  if (top)
8850
8850
  break;
8851
+ if (rect.top < bounding.top || rect.bottom > bounding.bottom ||
8852
+ rect.left < bounding.left || rect.right > bounding.right)
8853
+ rect = { left: Math.max(rect.left, bounding.left), right: Math.min(rect.right, bounding.right),
8854
+ top: Math.max(rect.top, bounding.top), bottom: Math.min(rect.bottom, bounding.bottom) };
8851
8855
  cur = cur.assignedSlot || cur.parentNode;
8852
8856
  }
8853
8857
  else if (cur.nodeType == 11) { // A shadow root
@@ -23360,7 +23364,15 @@ function createLineDialog(view) {
23360
23364
  event.preventDefault();
23361
23365
  go();
23362
23366
  }
23363
- }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", { class: "cm-button", type: "submit" }, view.state.phrase("go")));
23367
+ }, crelt("label", view.state.phrase("Go to line"), ": ", input), " ", crelt("button", { class: "cm-button", type: "submit" }, view.state.phrase("go")), crelt("button", {
23368
+ name: "close",
23369
+ onclick: () => {
23370
+ view.dispatch({ effects: dialogEffect.of(false) });
23371
+ view.focus();
23372
+ },
23373
+ "aria-label": view.state.phrase("close"),
23374
+ type: "button"
23375
+ }, ["×"]));
23364
23376
  function go() {
23365
23377
  let match = /^([+-])?(\d+)?(:\d+)?(%)?$/.exec(input.value);
23366
23378
  if (!match)
@@ -23424,7 +23436,17 @@ const gotoLine = view => {
23424
23436
  const baseTheme$1$1 = /*@__PURE__*/EditorView.baseTheme({
23425
23437
  ".cm-panel.cm-gotoLine": {
23426
23438
  padding: "2px 6px 4px",
23427
- "& label": { fontSize: "80%" }
23439
+ position: "relative",
23440
+ "& label": { fontSize: "80%" },
23441
+ "& [name=close]": {
23442
+ position: "absolute",
23443
+ top: "0", bottom: "0",
23444
+ right: "4px",
23445
+ backgroundColor: "inherit",
23446
+ border: "none",
23447
+ font: "inherit",
23448
+ padding: "0"
23449
+ }
23428
23450
  }
23429
23451
  });
23430
23452
 
@@ -1,12 +1,8 @@
1
1
  import { spawn } from 'node:child_process';
2
- import { join } from 'node:path';
3
2
  import { cwd } from 'node:process';
4
3
  import { setTimeout } from 'node:timers';
5
- import isDependency from './is-dependency.js';
6
4
  function getChildProcessWrapperPath() {
7
- return isDependency('./utils/child-process-wrapper.js')
8
- ? join(cwd(), './node_modules/@sanity/runtime-cli/dist/utils/child-process-wrapper.js')
9
- : join(cwd(), './src/utils/child-process-wrapper.js');
5
+ return new URL('./child-process-wrapper.js', import.meta.url).pathname;
10
6
  }
11
7
  export default async function invoke(srcPath, payload, timeout = 5) {
12
8
  return new Promise((resolve, reject) => {
@@ -247,5 +247,5 @@
247
247
  ]
248
248
  }
249
249
  },
250
- "version": "1.2.0"
250
+ "version": "1.2.1"
251
251
  }
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.2.0",
4
+ "version": "1.2.1",
5
5
  "author": "Sanity Runtime Team",
6
6
  "type": "module",
7
7
  "license": "MIT",
@@ -35,12 +35,11 @@
35
35
  "version": "oclif readme && git add README.md"
36
36
  },
37
37
  "dependencies": {
38
- "@hono/node-server": "^1.13.8",
39
38
  "@oclif/core": "^4",
40
39
  "@oclif/plugin-help": "^6",
41
40
  "@oclif/plugin-plugins": "^5",
42
- "hono": "^4.7.2",
43
41
  "jszip": "^3.10.1",
42
+ "mime-types": "^2.1.35",
44
43
  "xdg-basedir": "^5.1.0"
45
44
  },
46
45
  "devDependencies": {
@@ -52,6 +51,7 @@
52
51
  "@oclif/test": "^4",
53
52
  "@rollup/plugin-node-resolve": "^16.0.0",
54
53
  "@types/chai": "^5",
54
+ "@types/mime-types": "^2.1.4",
55
55
  "@types/mocha": "^10",
56
56
  "@types/node": "^20",
57
57
  "chai": "^5",