@nimtech/nimpress 2.8.0 → 2.9.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.
@@ -30,7 +30,7 @@ The receiver is thin. The `docs-sync` action owns the mirror, the version bump,
30
30
 
31
31
  4. When the dispatch mode is `export`, runs `docs-export@v2` against the checked out source first and hands its output to `docs-sync` as `source-path`.
32
32
 
33
- 5. When the source mapping names a `package`, installs it at the version of the dispatched tag, the `ref` without its leading `v` or the `version` input of a manual run, and passes `include: package.json pnpm-lock.yaml` so the deploy builds against that release. The source then notifies from a workflow that runs after its publish workflow, never in parallel with it.
33
+ 5. When the source mapping names a `package`, installs it at the version of the dispatched tag, the `ref` without its leading `v` or the `version` input of a manual run, and passes `include: package.json pnpm-lock.yaml` so the deploy builds against that release. The receiver waits for the registry to serve that version before it installs it, so the source keeps the standard consumer workflow on its version tag.
34
34
 
35
35
  ## Configuration
36
36
 
@@ -45,6 +45,8 @@ 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`.
49
+
48
50
  ### build
49
51
 
50
52
  ```sh
package/README.md CHANGED
@@ -137,6 +137,7 @@ nimpress/
137
137
  │ ├── dbml/ DBML to diagram model conversion, run at build time
138
138
  │ ├── search/ MiniSearch wrapper and modal
139
139
  │ ├── auth/ Session login guard
140
+ │ ├── commands/ Dev server command route and the postCommand client
140
141
  │ └── styles/ Tokens and preflight
141
142
  ├── tailwind.preset.ts Design tokens exported for consumers
142
143
  └── justfile Task runner
@@ -175,6 +175,43 @@
175
175
  }
176
176
  }
177
177
  },
178
+ "commands": {
179
+ "type": "object",
180
+ "description": "Cli commands a page may call or listen to through the dev server on localhost, never in a build. allow is none by default.",
181
+ "required": [
182
+ "allow"
183
+ ],
184
+ "properties": {
185
+ "allow": {
186
+ "description": "none refuses every command, all runs any command, and a list allows the entries it names: 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.",
187
+ "oneOf": [
188
+ {
189
+ "type": "string",
190
+ "enum": [
191
+ "none",
192
+ "all"
193
+ ]
194
+ },
195
+ {
196
+ "type": "array",
197
+ "items": {
198
+ "type": "string",
199
+ "pattern": "\\S"
200
+ }
201
+ }
202
+ ],
203
+ "examples": [
204
+ "none",
205
+ [
206
+ "git status",
207
+ "git log **",
208
+ "claude -p --model *"
209
+ ]
210
+ ]
211
+ }
212
+ },
213
+ "additionalProperties": false
214
+ },
178
215
  "meta": {
179
216
  "type": "object",
180
217
  "description": "SEO, robots, llms.txt, webmanifest, and security.txt emission.",
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-DOHMact8.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-HmlfCdpc.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";
@@ -147,6 +147,9 @@ export default defineConfig({
147
147
  /** Changelog subscription wiring. */
148
148
  // subscribe: { endpoint: 'https://auth.example.io/api/subscribe', appSlug: 'my-docs' },
149
149
 
150
+ /** Cli commands a page may call or listen to through the dev server on localhost, never in a build: none (default), all, or a list. In a list entry the first word is the command, every further word matches one argument, * matches any characters inside it, and a trailing ** any remaining arguments. */
151
+ // commands: { allow: ['git status', 'git log **', 'claude -p --model *'] },
152
+
150
153
  /** Slug prefixes excluded from the site. */
151
154
  // exclude: ['drafts'],
152
155
 
@@ -0,0 +1,47 @@
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();
5
+ try {
6
+ return new Error(String(JSON.parse(r).error ?? `command request returned ${n.status}`));
7
+ } catch {
8
+ return new Error(`command request returned ${n.status}`);
9
+ }
10
+ }
11
+ async function l(n, r) {
12
+ const t = { code: null, stdout: "", stderr: "" }, d = n.body.pipeThrough(new TextDecoderStream()).getReader();
13
+ let a = "";
14
+ const s = (o) => {
15
+ if (!o) return;
16
+ const e = JSON.parse(o);
17
+ if (e.error !== void 0) throw new Error(e.error);
18
+ if (e.stream && e.line !== void 0) {
19
+ t[e.stream] += e.line + `
20
+ `, r(e.line, e.stream);
21
+ return;
22
+ }
23
+ "code" in e && (t.code = e.code ?? null);
24
+ };
25
+ for (; ; ) {
26
+ const { done: o, value: e } = await d.read();
27
+ if (o) break;
28
+ const i = (a + e).split(`
29
+ `);
30
+ a = i.pop() ?? "";
31
+ for (const c of i) s(c);
32
+ }
33
+ return s(a), t;
34
+ }
35
+ async function f(n, r = {}) {
36
+ const t = await fetch(u, {
37
+ method: "POST",
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
41
+ });
42
+ if (!t.ok) throw await m(t);
43
+ return r.onLine ? l(t, r.onLine) : (await t.json()).data;
44
+ }
45
+ export {
46
+ f as postCommand
47
+ };