@nimtech/nimpress 2.8.1 → 2.9.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/.claude/skills/nimpress/SKILL.md +2 -0
- package/README.md +1 -0
- package/config.schema.json +37 -0
- package/dist/cli.es.js +4 -1
- package/dist/commands.es.js +48 -0
- package/dist/{plugin-DOHMact8.js → plugin-B3XIiXAk.js} +2145 -2018
- package/dist/plugin.es.js +1 -1
- package/dist/src/cli/init.d.ts.map +1 -1
- package/dist/src/commands/index.d.ts +15 -0
- package/dist/src/commands/index.d.ts.map +1 -0
- package/dist/src/commands/server.d.ts +9 -0
- package/dist/src/commands/server.d.ts.map +1 -0
- package/dist/src/config/defaults.d.ts.map +1 -1
- package/dist/src/config/schema.d.ts +21 -0
- package/dist/src/config/schema.d.ts.map +1 -1
- package/dist/src/modules/harness.d.ts.map +1 -1
- package/dist/src/types.d.ts +7 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +5 -1
|
@@ -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`. 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; command ui sits behind `{#if commandsEnabled}` or `v-if="commandsEnabled"` and is tree shaken out of the build with everything it calls.
|
|
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
|
package/config.schema.json
CHANGED
|
@@ -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-
|
|
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-B3XIiXAk.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,48 @@
|
|
|
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
|
+
try {
|
|
6
|
+
return new Error(String(JSON.parse(n).error ?? `command request returned ${r.status}`));
|
|
7
|
+
} catch {
|
|
8
|
+
return new Error(`command request returned ${r.status}`);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
async function l(r, n) {
|
|
12
|
+
const t = { code: null, stdout: "", stderr: "" }, d = r.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
|
+
`, n(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 w(r, n = {}) {
|
|
36
|
+
const t = await fetch(u, {
|
|
37
|
+
method: "POST",
|
|
38
|
+
headers: { "Content-Type": "application/json" },
|
|
39
|
+
body: JSON.stringify({ command: r, args: n.args ?? [], stdin: n.stdin, stream: !!n.onLine }),
|
|
40
|
+
signal: n.signal
|
|
41
|
+
});
|
|
42
|
+
if (!t.ok) throw await m(t);
|
|
43
|
+
return n.onLine ? l(t, n.onLine) : (await t.json()).data;
|
|
44
|
+
}
|
|
45
|
+
export {
|
|
46
|
+
f as commandsEnabled,
|
|
47
|
+
w as postCommand
|
|
48
|
+
};
|