@nimtech/nimpress 2.9.0 → 2.9.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.
@@ -45,7 +45,7 @@ nimpress dev --view
45
45
 
46
46
  Serves the site and starts one harness server for every configured component system. It stays running and binds the vite cli shortcuts. `--view` serves the central docs site this repo publishes into instead, with the exported pages in place, the same run as `view` below.
47
47
 
48
- The dev server also runs cli commands for a page on localhost, never in a build. `commands.allow` in the config is `none` by default, `all`, or a list of entries such as `git log **`: the first word is the command, every further word matches one argument with `*` for any characters inside it, and a trailing `**` matches any remaining arguments. A page or component calls `postCommand(command, { args, stdin })` from `@nimtech/nimpress/commands` for `{ code, stdout, stderr }`, and passes `onLine(line, stream)` to listen to every line as it is written. A command outside the list is refused with `<command> is not in commands.allow`.
48
+ The dev server also runs cli commands for a page on localhost, never in a build. `commands.allow` in the config is `none` by default, `all`, or a list of entries such as `git log **`: the first word is the command, every further word matches one argument with `*` for any characters inside it, and a trailing `**` matches any remaining arguments. A page or component calls `postCommand(command, { args, stdin })` from `@nimtech/nimpress/commands` for `{ code, stdout, stderr }`, and passes `onLine(line, stream)` to listen to every line as it is written. A command outside the list is refused with `<command> is not in commands.allow`. In `nimpress build` and a component build the plugin swaps the module for one where `commandsEnabled` is `false` and `postCommand` only throws, so the client and the route never reach the static output; a `postCommand` left outside the guard fails the build with `postCommand reaches the static build from <files>`; command ui sits behind `{#if commandsEnabled}` or `v-if="commandsEnabled"` and is tree shaken out of the build with everything it calls.
49
49
 
50
50
  ### build
51
51
 
package/dist/cli.es.js CHANGED
@@ -1,4 +1,4 @@
1
- import { d as B, c as xe, r as Je, s as Qt, p as Xt, a as lt, b as me, e as qt, f as es, g as Te, h as ut, i as ts, j as pt, k as ss, l as ns, m as os, C as we, n as rs, o as Be, q as Ke, w as fe, t as mt, u as is, v as as, x as $e, y as cs, z as ls, A as us, B as ps, D as ms, E as Ye, F as fs, G as ds } from "./plugin-HmlfCdpc.js";
1
+ import { d as B, c as xe, r as Je, s as Qt, p as Xt, a as lt, b as me, e as qt, f as es, g as Te, h as ut, i as ts, j as pt, k as ss, l as ns, m as os, C as we, n as rs, o as Be, q as Ke, w as fe, t as mt, u as is, v as as, x as $e, y as cs, z as ls, A as us, B as ps, D as ms, E as Ye, F as fs, G as ds } from "./plugin-q_t1YeRV.js";
2
2
  import { join as d, dirname as O, relative as E, sep as z, extname as de, resolve as j, basename as W } from "node:path";
3
3
  import { readdirSync as ce, existsSync as y, writeFileSync as N, mkdirSync as L, rmSync as se, readFileSync as S, statSync as ft, watch as Qe, openSync as hs } from "node:fs";
4
4
  import pe from "gray-matter";
@@ -1,15 +1,15 @@
1
- const u = "/__nimpress/command";
2
- async function m(n) {
3
- if (n.status === 404) return new Error("commands run only under nimpress dev, a built site has no command server");
4
- const r = await n.text();
1
+ const u = "/__nimpress/command", f = !0;
2
+ async function m(r) {
3
+ if (r.status === 404) return new Error("commands run only under nimpress dev, a built site has no command server");
4
+ const n = await r.text();
5
5
  try {
6
- return new Error(String(JSON.parse(r).error ?? `command request returned ${n.status}`));
6
+ return new Error(String(JSON.parse(n).error ?? `command request returned ${r.status}`));
7
7
  } catch {
8
- return new Error(`command request returned ${n.status}`);
8
+ return new Error(`command request returned ${r.status}`);
9
9
  }
10
10
  }
11
- async function l(n, r) {
12
- const t = { code: null, stdout: "", stderr: "" }, d = n.body.pipeThrough(new TextDecoderStream()).getReader();
11
+ async function l(r, n) {
12
+ const t = { code: null, stdout: "", stderr: "" }, d = r.body.pipeThrough(new TextDecoderStream()).getReader();
13
13
  let a = "";
14
14
  const s = (o) => {
15
15
  if (!o) return;
@@ -17,7 +17,7 @@ async function l(n, r) {
17
17
  if (e.error !== void 0) throw new Error(e.error);
18
18
  if (e.stream && e.line !== void 0) {
19
19
  t[e.stream] += e.line + `
20
- `, r(e.line, e.stream);
20
+ `, n(e.line, e.stream);
21
21
  return;
22
22
  }
23
23
  "code" in e && (t.code = e.code ?? null);
@@ -32,16 +32,17 @@ async function l(n, r) {
32
32
  }
33
33
  return s(a), t;
34
34
  }
35
- async function f(n, r = {}) {
35
+ async function w(r, n = {}) {
36
36
  const t = await fetch(u, {
37
37
  method: "POST",
38
38
  headers: { "Content-Type": "application/json" },
39
- body: JSON.stringify({ command: n, args: r.args ?? [], stdin: r.stdin, stream: !!r.onLine }),
40
- signal: r.signal
39
+ body: JSON.stringify({ command: r, args: n.args ?? [], stdin: n.stdin, stream: !!n.onLine }),
40
+ signal: n.signal
41
41
  });
42
42
  if (!t.ok) throw await m(t);
43
- return r.onLine ? l(t, r.onLine) : (await t.json()).data;
43
+ return n.onLine ? l(t, n.onLine) : (await t.json()).data;
44
44
  }
45
45
  export {
46
- f as postCommand
46
+ f as commandsEnabled,
47
+ w as postCommand
47
48
  };