@nimtech/nimpress 2.4.0 → 2.6.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.
- package/.claude/skills/nimpress/SKILL.md +20 -3
- package/config.schema.json +70 -0
- package/dist/cli.es.js +810 -609
- package/dist/nimpress.es.js +6977 -6860
- package/dist/{plugin-DOmbMyy0.js → plugin-Bj4U3kPF.js} +1264 -1206
- package/dist/plugin.es.js +1 -1
- package/dist/src/cli/completion.d.ts +12 -0
- package/dist/src/cli/completion.d.ts.map +1 -1
- package/dist/src/cli/mcp.d.ts +2 -0
- package/dist/src/cli/mcp.d.ts.map +1 -0
- package/dist/src/cli/plugin.d.ts +3 -0
- package/dist/src/cli/plugin.d.ts.map +1 -0
- package/dist/src/cli.d.ts.map +1 -1
- package/dist/src/config/defaults.d.ts +3 -0
- package/dist/src/config/defaults.d.ts.map +1 -1
- package/dist/src/config/html.d.ts.map +1 -1
- package/dist/src/config/load.d.ts +3 -0
- package/dist/src/config/load.d.ts.map +1 -1
- package/dist/src/config/schema.d.ts +33 -24
- package/dist/src/config/schema.d.ts.map +1 -1
- package/dist/src/framework/components.d.ts +5 -0
- package/dist/src/framework/components.d.ts.map +1 -0
- package/dist/src/framework/createNimpressApp.d.ts.map +1 -1
- package/dist/src/framework/stores/theme.d.ts +4 -0
- package/dist/src/framework/stores/theme.d.ts.map +1 -1
- package/dist/src/index.d.ts +11 -2
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/layout/ThemeMenu.svelte.d.ts +1 -0
- package/dist/src/types.d.ts +15 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +2 -1
- package/src/styles/themes/glass.css +379 -0
- package/src/styles/tokens.css +37 -0
package/dist/cli.es.js
CHANGED
|
@@ -1,29 +1,30 @@
|
|
|
1
|
-
import { d as
|
|
2
|
-
import { join as d, dirname as _, relative as D, sep as I, extname as
|
|
3
|
-
import { readdirSync as
|
|
4
|
-
import
|
|
5
|
-
import { readFile as
|
|
6
|
-
import { s as
|
|
7
|
-
import { createServer as
|
|
8
|
-
import { createHash as
|
|
9
|
-
import { createInterface as
|
|
10
|
-
import { fileURLToPath as
|
|
11
|
-
import { homedir as
|
|
12
|
-
import { spawnSync as
|
|
13
|
-
import {
|
|
14
|
-
|
|
1
|
+
import { d as z, c as Pe, r as Me, s as Jt, p as Bt, a as et, b as ue, e as Gt, f as Ht, g as De, h as tt, i as Ut, j as st, k as Zt, l as Vt, m as Kt, C as ge, n as Yt, o as nt, q as Ge, w as pe, t as ot, u as Qt, v as Xt, x as qt, y as es, z as ts, A as ss, B as we } from "./plugin-Bj4U3kPF.js";
|
|
2
|
+
import { join as d, dirname as _, relative as D, sep as I, extname as me, resolve as j, basename as F } from "node:path";
|
|
3
|
+
import { readdirSync as se, existsSync as $, writeFileSync as W, mkdirSync as H, rmSync as ne, readFileSync as C, statSync as rt, watch as He } from "node:fs";
|
|
4
|
+
import fe from "gray-matter";
|
|
5
|
+
import { readFile as Se, readdir as ns, writeFile as Q, mkdir as Ne, copyFile as it } from "node:fs/promises";
|
|
6
|
+
import { s as os, r as $e } from "./typeMembers-CNvE92EX.js";
|
|
7
|
+
import { createServer as at, build as ct } from "vite";
|
|
8
|
+
import { createHash as lt } from "node:crypto";
|
|
9
|
+
import { createInterface as ut } from "node:readline/promises";
|
|
10
|
+
import { fileURLToPath as pt } from "node:url";
|
|
11
|
+
import { homedir as K, platform as rs } from "node:os";
|
|
12
|
+
import { spawnSync as X, spawn as Ie } from "node:child_process";
|
|
13
|
+
import { createInterface as is } from "node:readline";
|
|
14
|
+
import { parse as as } from "yaml";
|
|
15
|
+
function N(e, t) {
|
|
15
16
|
return e.find((n) => n.startsWith(`--${t}=`))?.slice(t.length + 3);
|
|
16
17
|
}
|
|
17
18
|
function M(e, t) {
|
|
18
19
|
return e.includes(`--${t}`);
|
|
19
20
|
}
|
|
20
|
-
function
|
|
21
|
+
function re(e, t) {
|
|
21
22
|
return e.filter((n) => !n.startsWith("--"))[t];
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function oe(e, t = []) {
|
|
24
25
|
let s;
|
|
25
26
|
try {
|
|
26
|
-
s =
|
|
27
|
+
s = se(e, { withFileTypes: !0 });
|
|
27
28
|
} catch {
|
|
28
29
|
return t;
|
|
29
30
|
}
|
|
@@ -31,12 +32,12 @@ function se(e, t = []) {
|
|
|
31
32
|
const o = d(e, n.name);
|
|
32
33
|
if (n.isDirectory()) {
|
|
33
34
|
if (n.name === "node_modules" || n.name.startsWith(".")) continue;
|
|
34
|
-
|
|
35
|
+
oe(o, t);
|
|
35
36
|
} else n.isFile() && t.push(o);
|
|
36
37
|
}
|
|
37
38
|
return t;
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function _e(e, t, s) {
|
|
40
41
|
if (t.length) {
|
|
41
42
|
console.error(`${e} failed with ${t.length} problems`);
|
|
42
43
|
for (const n of t) console.error(` ${n}`);
|
|
@@ -44,7 +45,7 @@ function Oe(e, t, s) {
|
|
|
44
45
|
}
|
|
45
46
|
console.log(s);
|
|
46
47
|
}
|
|
47
|
-
function
|
|
48
|
+
function cs() {
|
|
48
49
|
return `import { defineConfig } from '@nimtech/nimpress/plugin'
|
|
49
50
|
|
|
50
51
|
/**
|
|
@@ -54,15 +55,15 @@ function es() {
|
|
|
54
55
|
*/
|
|
55
56
|
export default defineConfig({
|
|
56
57
|
/** Site title shown in the header and the tab. */
|
|
57
|
-
title: ${JSON.stringify(
|
|
58
|
+
title: ${JSON.stringify(z.title)},
|
|
58
59
|
|
|
59
|
-
/** Folder holding the markdown content. Default ${JSON.stringify(
|
|
60
|
+
/** Folder holding the markdown content. Default ${JSON.stringify(z.contentDir)}. */
|
|
60
61
|
// contentDir: 'docs',
|
|
61
62
|
|
|
62
|
-
/** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(
|
|
63
|
+
/** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(z.assetsDir)}. */
|
|
63
64
|
// assetsDir: 'assets',
|
|
64
65
|
|
|
65
|
-
/** Url base the assets folder serves under. Default ${JSON.stringify(
|
|
66
|
+
/** Url base the assets folder serves under. Default ${JSON.stringify(z.assetUrlBase)}. */
|
|
66
67
|
// assetUrlBase: '/assets',
|
|
67
68
|
|
|
68
69
|
/**
|
|
@@ -180,21 +181,21 @@ export default defineConfig({
|
|
|
180
181
|
})
|
|
181
182
|
`;
|
|
182
183
|
}
|
|
183
|
-
function
|
|
184
|
+
function ls() {
|
|
184
185
|
return JSON.stringify(
|
|
185
186
|
{
|
|
186
187
|
$schema: "./node_modules/@nimtech/nimpress/config.schema.json",
|
|
187
|
-
title:
|
|
188
|
-
contentDir:
|
|
189
|
-
assetsDir:
|
|
190
|
-
assetUrlBase:
|
|
188
|
+
title: z.title,
|
|
189
|
+
contentDir: z.contentDir,
|
|
190
|
+
assetsDir: z.assetsDir,
|
|
191
|
+
assetUrlBase: z.assetUrlBase
|
|
191
192
|
},
|
|
192
193
|
null,
|
|
193
194
|
2
|
|
194
195
|
) + `
|
|
195
196
|
`;
|
|
196
197
|
}
|
|
197
|
-
function
|
|
198
|
+
function us(e) {
|
|
198
199
|
return `# Nimpress project
|
|
199
200
|
|
|
200
201
|
This site is built with @nimtech/nimpress. Content lives in \`${e}/\` as markdown with typed frontmatter.
|
|
@@ -236,11 +237,11 @@ The authoritative AI working rules ship inside the package at \`node_modules/@ni
|
|
|
236
237
|
8. \`nimpress guard map\` and \`nimpress guard apply\` wire gated pages, marked with the \`gate:\` frontmatter field, to the auth provider artifacts.
|
|
237
238
|
`;
|
|
238
239
|
}
|
|
239
|
-
function
|
|
240
|
+
function ps(e) {
|
|
240
241
|
const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = M(process.argv.slice(2), "json");
|
|
241
|
-
!$(t) && !$(s) && (n ? (
|
|
242
|
-
const o = d(e,
|
|
243
|
-
(!$(o) ||
|
|
242
|
+
!$(t) && !$(s) && (n ? (W(s, ls()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, cs()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
|
|
243
|
+
const o = d(e, z.contentDir);
|
|
244
|
+
(!$(o) || se(o).length === 0) && (H(o, { recursive: !0 }), W(
|
|
244
245
|
d(o, "index.md"),
|
|
245
246
|
`---
|
|
246
247
|
title: Home
|
|
@@ -249,167 +250,167 @@ title: Home
|
|
|
249
250
|
Welcome to your Nimpress site.
|
|
250
251
|
`
|
|
251
252
|
));
|
|
252
|
-
const i =
|
|
253
|
+
const i = us(z.contentDir);
|
|
253
254
|
for (const c of ["CLAUDE.md", "AGENTS.md"]) {
|
|
254
|
-
const
|
|
255
|
-
$(
|
|
255
|
+
const l = d(e, c);
|
|
256
|
+
$(l) || (W(l, i), console.log(`nimpress init: ${c} written, pointing at the packaged rules in node_modules/@nimtech/nimpress/.claude/rules/`));
|
|
256
257
|
}
|
|
257
258
|
}
|
|
258
|
-
const
|
|
259
|
-
function
|
|
259
|
+
const ms = { vue: "vueStory", svelte: "svelteStory" }, fs = { vue: ".svelte", svelte: ".vue" };
|
|
260
|
+
function ie(e) {
|
|
260
261
|
return `run nimpress modules update ${e}`;
|
|
261
262
|
}
|
|
262
|
-
async function
|
|
263
|
+
async function ds(e) {
|
|
263
264
|
let t;
|
|
264
265
|
try {
|
|
265
|
-
t = await
|
|
266
|
+
t = await ns(e, { withFileTypes: !0 });
|
|
266
267
|
} catch {
|
|
267
268
|
return [];
|
|
268
269
|
}
|
|
269
270
|
return t.filter((s) => s.isFile() && /\.story\.tsx?$/.test(s.name)).map((s) => s.name);
|
|
270
271
|
}
|
|
271
|
-
function
|
|
272
|
+
function hs(e, t) {
|
|
272
273
|
const s = t === "integer" ? "number" : t;
|
|
273
274
|
return e.every((n) => typeof n === s);
|
|
274
275
|
}
|
|
275
|
-
function
|
|
276
|
+
function gs(e, t, s, n, o) {
|
|
276
277
|
const r = [], i = n.properties ?? {}, c = o.properties ?? {};
|
|
277
278
|
for (const m of Object.keys(c))
|
|
278
|
-
m in i || r.push(`${e}: prop ${m} is missing from the schema, ${
|
|
279
|
+
m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ie(t)}`);
|
|
279
280
|
for (const m of Object.keys(i))
|
|
280
281
|
m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${s}, remove it or restore the prop`);
|
|
281
282
|
for (const [m, f] of Object.entries(i)) {
|
|
282
283
|
const h = c[m];
|
|
283
284
|
if (h && (f.type && h.type && f.type !== h.type && !f.enum && r.push(
|
|
284
|
-
`${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${
|
|
285
|
-
), f.enum && h.type && !
|
|
285
|
+
`${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ie(t)}`
|
|
286
|
+
), f.enum && h.type && !hs(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
|
|
286
287
|
const g = new Set(h.enum.map((v) => JSON.stringify(v))), w = f.enum.filter((v) => !g.has(JSON.stringify(v)));
|
|
287
288
|
w.length && r.push(
|
|
288
289
|
`${e}: prop ${m} enum carries ${w.map((v) => JSON.stringify(v)).join(", ")} outside the source union`
|
|
289
290
|
);
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
|
-
const
|
|
293
|
+
const l = n.slots ?? {}, a = o.slots ?? {};
|
|
293
294
|
for (const m of Object.keys(a))
|
|
294
|
-
m in
|
|
295
|
-
for (const m of Object.keys(
|
|
295
|
+
m in l || r.push(`${e}: slot ${m} is missing from the schema, ${ie(t)}`);
|
|
296
|
+
for (const m of Object.keys(l))
|
|
296
297
|
m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${s}`);
|
|
297
|
-
const p = new Set(n.emits ?? []),
|
|
298
|
-
for (const m of
|
|
299
|
-
p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${
|
|
298
|
+
const p = new Set(n.emits ?? []), u = new Set(o.emits ?? []);
|
|
299
|
+
for (const m of u)
|
|
300
|
+
p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ie(t)}`);
|
|
300
301
|
for (const m of p)
|
|
301
|
-
|
|
302
|
+
u.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
|
|
302
303
|
return r;
|
|
303
304
|
}
|
|
304
|
-
async function
|
|
305
|
-
const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await
|
|
305
|
+
async function mt(e, t, s) {
|
|
306
|
+
const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Pe(e, t.contentDir);
|
|
306
307
|
for (const i of n) {
|
|
307
308
|
const c = t.modules.systems[i];
|
|
308
309
|
if (!c) {
|
|
309
310
|
o.push(`${i}: not a configured system`);
|
|
310
311
|
continue;
|
|
311
312
|
}
|
|
312
|
-
const
|
|
313
|
-
for (const
|
|
314
|
-
if (
|
|
315
|
-
const m = _(
|
|
316
|
-
h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${
|
|
313
|
+
const l = c.framework, a = ms[l === "vue" ? "svelte" : "vue"], p = fs[l];
|
|
314
|
+
for (const u of r) {
|
|
315
|
+
if (u.system !== i) continue;
|
|
316
|
+
const m = _(u.pageFile), f = D(e, m).split(I).join("/"), h = await ds(m);
|
|
317
|
+
h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${u.component}`);
|
|
317
318
|
const g = /* @__PURE__ */ new Set();
|
|
318
319
|
for (const x of h) {
|
|
319
|
-
let
|
|
320
|
+
let R;
|
|
320
321
|
try {
|
|
321
|
-
|
|
322
|
+
R = await Se(d(m, x), "utf-8");
|
|
322
323
|
} catch {
|
|
323
324
|
continue;
|
|
324
325
|
}
|
|
325
|
-
(/\bharness\s*:/.test(
|
|
326
|
-
for (const y of
|
|
327
|
-
|
|
326
|
+
(/\bharness\s*:/.test(R) || /\brender\s*:/.test(R)) && g.add(x), R.includes(a) && o.push(`${f}/${x}: uses ${a} inside the ${l} system ${i}`);
|
|
327
|
+
for (const y of R.matchAll(/from\s+['"]([^'"]+)['"]/g))
|
|
328
|
+
me(y[1]) === p && o.push(`${f}/${x}: imports ${y[1]} inside the ${l} system ${i}`);
|
|
328
329
|
}
|
|
329
|
-
const w =
|
|
330
|
-
if (w &&
|
|
331
|
-
`${f}: component file ${D(e, w.componentFile)} mismatches the ${
|
|
330
|
+
const w = Me(e, t.modules, i, u.component, u.file);
|
|
331
|
+
if (w && me(w.componentFile) === p && o.push(
|
|
332
|
+
`${f}: component file ${D(e, w.componentFile)} mismatches the ${l} system ${i}`
|
|
332
333
|
), $(d(m, "schema.json")) && $(d(m, "schema.yml"))) {
|
|
333
334
|
o.push(`${f}: both schema.json and schema.yml exist, keep one`);
|
|
334
335
|
continue;
|
|
335
336
|
}
|
|
336
|
-
const v =
|
|
337
|
+
const v = Jt(m);
|
|
337
338
|
if (!v) {
|
|
338
|
-
o.push(`${f}: schema file missing, ${
|
|
339
|
+
o.push(`${f}: schema file missing, ${ie(u.component)}`);
|
|
339
340
|
continue;
|
|
340
341
|
}
|
|
341
|
-
let
|
|
342
|
+
let O;
|
|
342
343
|
try {
|
|
343
|
-
|
|
344
|
+
O = await Se(v.path, "utf-8");
|
|
344
345
|
} catch {
|
|
345
346
|
o.push(`${f}: ${v.form} schema unreadable`);
|
|
346
347
|
continue;
|
|
347
348
|
}
|
|
348
349
|
let E;
|
|
349
350
|
try {
|
|
350
|
-
E =
|
|
351
|
+
E = Bt(O, v.form);
|
|
351
352
|
} catch {
|
|
352
353
|
o.push(`${f}: schema is not valid ${v.form}, fix it by hand`);
|
|
353
354
|
continue;
|
|
354
355
|
}
|
|
355
356
|
const k = new Set(Object.keys(E.properties ?? {}));
|
|
356
|
-
for (const x of await
|
|
357
|
+
for (const x of await et(m))
|
|
357
358
|
if (!g.has(x.file))
|
|
358
|
-
for (const
|
|
359
|
-
k.has(
|
|
360
|
-
const T = w ? await
|
|
359
|
+
for (const R of Object.keys(x.props ?? {}))
|
|
360
|
+
k.has(R) || o.push(`${f}/${x.file}: prop ${R} is absent from the schema, ${ie(u.component)}`);
|
|
361
|
+
const T = w ? await Se(w.componentFile, "utf-8").catch(() => {
|
|
361
362
|
}) : void 0;
|
|
362
363
|
if (w) {
|
|
363
|
-
const x = await
|
|
364
|
+
const x = await ue(w.componentFile, l, u.component);
|
|
364
365
|
if (x) {
|
|
365
|
-
const
|
|
366
|
+
const R = os(u.component, x.props, x.slots, x.emits);
|
|
366
367
|
o.push(
|
|
367
|
-
...
|
|
368
|
+
...gs(f, u.component, D(e, w.componentFile), E, R)
|
|
368
369
|
);
|
|
369
370
|
}
|
|
370
371
|
}
|
|
371
|
-
|
|
372
|
+
Gt(Ht(u.component, E, { sourceFile: w?.componentFile, sourceText: T }));
|
|
372
373
|
}
|
|
373
374
|
}
|
|
374
|
-
return
|
|
375
|
+
return De(e), o;
|
|
375
376
|
}
|
|
376
|
-
function
|
|
377
|
+
function ft(e) {
|
|
377
378
|
return Object.entries(e.modules.systems).filter(([, t]) => t.visibility !== "dev-only").map(([t]) => t);
|
|
378
379
|
}
|
|
379
|
-
async function
|
|
380
|
+
async function dt(e, t, s) {
|
|
380
381
|
for (const n of s)
|
|
381
382
|
try {
|
|
382
|
-
await (await
|
|
383
|
+
await (await at(await st(e, t, n, "serve"))).listen(), console.log(`nimpress modules: ${n} harness on port ${Zt(t.modules, n)}`);
|
|
383
384
|
} catch (o) {
|
|
384
385
|
console.warn(`nimpress modules: harness for ${n} failed to start: ${String(o)}`);
|
|
385
386
|
}
|
|
386
387
|
}
|
|
387
|
-
async function
|
|
388
|
+
async function ht(e, t, s) {
|
|
388
389
|
for (const n of s)
|
|
389
|
-
await
|
|
390
|
+
await ct(await st(e, t, n, "build")), console.log(`nimpress modules: built ${n}`);
|
|
390
391
|
}
|
|
391
|
-
async function
|
|
392
|
-
const s = await
|
|
393
|
-
await s.listen(), await
|
|
392
|
+
async function ws(e, t) {
|
|
393
|
+
const s = await at(tt({ cwd: e, command: "serve", resolved: t }));
|
|
394
|
+
await s.listen(), await dt(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
|
|
394
395
|
}
|
|
395
|
-
async function
|
|
396
|
+
async function gt(e, t) {
|
|
396
397
|
const s = d(e, "index.html"), n = !$(s);
|
|
397
|
-
n &&
|
|
398
|
+
n && W(s, Ut(t));
|
|
398
399
|
const o = () => {
|
|
399
|
-
n &&
|
|
400
|
+
n && ne(s, { force: !0 });
|
|
400
401
|
}, r = () => {
|
|
401
402
|
o(), process.exit(130);
|
|
402
403
|
};
|
|
403
404
|
process.once("SIGINT", r), process.once("SIGTERM", r);
|
|
404
405
|
try {
|
|
405
|
-
await
|
|
406
|
+
await ct(tt({ cwd: e, command: "build", resolved: t, htmlInput: s }));
|
|
406
407
|
} finally {
|
|
407
408
|
process.off("SIGINT", r), process.off("SIGTERM", r), o();
|
|
408
409
|
}
|
|
409
|
-
await
|
|
410
|
+
await ht(e, t, ft(t));
|
|
410
411
|
}
|
|
411
|
-
const
|
|
412
|
-
function
|
|
412
|
+
const $s = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], ys = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ue = /^[a-z0-9][a-z0-9.-]*$/, bs = /^[A-Z][A-Za-z0-9]*$/;
|
|
413
|
+
function vs(e) {
|
|
413
414
|
const t = e.resolve;
|
|
414
415
|
if (!t || typeof t != "object") return [];
|
|
415
416
|
const s = t.alias;
|
|
@@ -421,7 +422,7 @@ function fs(e) {
|
|
|
421
422
|
([n, o]) => typeof o == "string" ? [{ find: n, replacement: o }] : []
|
|
422
423
|
);
|
|
423
424
|
}
|
|
424
|
-
function
|
|
425
|
+
function ks(e) {
|
|
425
426
|
const t = [], s = [
|
|
426
427
|
/(?:^|\n)[ \t]*import[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
|
|
427
428
|
/(?:^|\n)[ \t]*export[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
|
|
@@ -434,21 +435,21 @@ function ds(e) {
|
|
|
434
435
|
}
|
|
435
436
|
return t;
|
|
436
437
|
}
|
|
437
|
-
function
|
|
438
|
-
return
|
|
438
|
+
function Ze(e) {
|
|
439
|
+
return ys.some((t) => {
|
|
439
440
|
const s = e + t;
|
|
440
441
|
if (!$(s)) return !1;
|
|
441
442
|
try {
|
|
442
|
-
return
|
|
443
|
+
return rt(s).isFile();
|
|
443
444
|
} catch {
|
|
444
445
|
return !1;
|
|
445
446
|
}
|
|
446
447
|
});
|
|
447
448
|
}
|
|
448
|
-
function
|
|
449
|
-
const s = j(e, t.contentDir), n =
|
|
450
|
-
for (const r of
|
|
451
|
-
if (
|
|
449
|
+
function xs(e, t) {
|
|
450
|
+
const s = j(e, t.contentDir), n = vs(t.vite), o = [];
|
|
451
|
+
for (const r of oe(s)) {
|
|
452
|
+
if (!$s.some((l) => r.endsWith(l))) continue;
|
|
452
453
|
let i;
|
|
453
454
|
try {
|
|
454
455
|
i = C(r, "utf-8");
|
|
@@ -456,115 +457,115 @@ function hs(e, t) {
|
|
|
456
457
|
continue;
|
|
457
458
|
}
|
|
458
459
|
const c = D(s, r).split(I).join("/");
|
|
459
|
-
for (const
|
|
460
|
-
if (
|
|
460
|
+
for (const l of ks(i)) {
|
|
461
|
+
if (l.includes("_shared/") || l.startsWith("_shared")) {
|
|
461
462
|
o.push(
|
|
462
|
-
`${c}: imports ${
|
|
463
|
+
`${c}: imports ${l}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
|
|
463
464
|
);
|
|
464
465
|
continue;
|
|
465
466
|
}
|
|
466
|
-
const a =
|
|
467
|
+
const a = l.split("?")[0];
|
|
467
468
|
if (a.startsWith("./") || a.startsWith("../")) {
|
|
468
|
-
const
|
|
469
|
-
|
|
469
|
+
const u = j(_(r), a);
|
|
470
|
+
Ze(u) || o.push(`${c}: unresolved import ${l}, fix the path or create the file`);
|
|
470
471
|
continue;
|
|
471
472
|
}
|
|
472
|
-
const p = n.find((
|
|
473
|
+
const p = n.find((u) => a === u.find || a.startsWith(u.find + "/"));
|
|
473
474
|
if (p) {
|
|
474
|
-
const
|
|
475
|
-
|
|
475
|
+
const u = j(e, p.replacement + a.slice(p.find.length));
|
|
476
|
+
Ze(u) || o.push(`${c}: unresolved import ${l} via alias ${p.find}`);
|
|
476
477
|
}
|
|
477
478
|
}
|
|
478
479
|
}
|
|
479
480
|
return o;
|
|
480
481
|
}
|
|
481
|
-
function
|
|
482
|
+
function Ss(e, t) {
|
|
482
483
|
const s = j(e, t.contentDir), n = [];
|
|
483
484
|
if (!$(s)) return [`${t.contentDir}: contentDir does not exist`];
|
|
484
485
|
const o = /* @__PURE__ */ new Map();
|
|
485
486
|
let r, i;
|
|
486
487
|
const c = /* @__PURE__ */ new Map();
|
|
487
|
-
for (const a of
|
|
488
|
-
const p = D(s, a).split(I).join("/"),
|
|
488
|
+
for (const a of oe(s)) {
|
|
489
|
+
const p = D(s, a).split(I).join("/"), u = _(a), m = F(a);
|
|
489
490
|
if (m.endsWith(".md")) {
|
|
490
|
-
const f = c.get(
|
|
491
|
-
f.push(a), c.set(
|
|
491
|
+
const f = c.get(u) ?? [];
|
|
492
|
+
f.push(a), c.set(u, f);
|
|
492
493
|
const h = m.slice(0, -3);
|
|
493
|
-
|
|
494
|
+
Ue.test(h) || n.push(`${p}: markdown file names are lowercase kebab case, rename to ${h.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9.-]+/g, "-")}.md`);
|
|
494
495
|
let g;
|
|
495
496
|
try {
|
|
496
|
-
g =
|
|
497
|
+
g = fe(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
|
|
497
498
|
} catch {
|
|
498
499
|
continue;
|
|
499
500
|
}
|
|
500
|
-
if (g?.type === "glossary" && (i ? n.push(`${p}: second type glossary page in the site, ${D(s, i).split(I).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(
|
|
501
|
-
const w = o.get(
|
|
502
|
-
w ? n.push(`${p}: second type component page in one folder, ${D(s, w).split(I).join("/")} already owns it, one component per folder`) : o.set(
|
|
501
|
+
if (g?.type === "glossary" && (i ? n.push(`${p}: second type glossary page in the site, ${D(s, i).split(I).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(fe(C(a, "utf-8")).content) || n.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${I}index.md`) && n.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${p}: second type 404 page in the site, ${D(s, r).split(I).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
|
|
502
|
+
const w = o.get(u);
|
|
503
|
+
w ? n.push(`${p}: second type component page in one folder, ${D(s, w).split(I).join("/")} already owns it, one component per folder`) : o.set(u, a);
|
|
503
504
|
}
|
|
504
505
|
if (g?.type === "dbml") {
|
|
505
506
|
const w = typeof g.spec == "string" ? g.spec : "";
|
|
506
|
-
w ? $(j(
|
|
507
|
+
w ? $(j(u, w)) || n.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
|
|
507
508
|
}
|
|
508
509
|
g?.type === "changelog" && typeof g.path == "string" && n.push(`${p}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
|
|
509
510
|
}
|
|
510
|
-
if (m.endsWith(".css") && !m.startsWith("_") &&
|
|
511
|
+
if (m.endsWith(".css") && !m.startsWith("_") && F(_(a)) === "styles" && _(_(a)) === s) {
|
|
511
512
|
const f = m.replace(/\.css$/, "");
|
|
512
|
-
|
|
513
|
+
ge.includes(f) || n.push(`${p}: ${f} is not a component class root, name the file after one of ${ge.join(", ")}`);
|
|
513
514
|
continue;
|
|
514
515
|
}
|
|
515
516
|
if (m.endsWith(".css") && !m.startsWith("_") && m.split(".").length > 2) {
|
|
516
|
-
const f = m.split(".")[0], h =
|
|
517
|
+
const f = m.split(".")[0], h = Yt(m, f);
|
|
517
518
|
if (h && $(d(_(a), `${f}.md`))) {
|
|
518
|
-
|
|
519
|
+
ge.includes(h) || n.push(`${p}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
|
|
519
520
|
continue;
|
|
520
521
|
}
|
|
521
522
|
}
|
|
522
523
|
if (m.endsWith(".css") && !m.startsWith("_")) {
|
|
523
524
|
const f = a.replace(/\.css$/, ".md");
|
|
524
|
-
$(f) || n.push(`${p}: page css without a matching ${
|
|
525
|
+
$(f) || n.push(`${p}: page css without a matching ${F(f)}, page styles are named after the page they scope`);
|
|
525
526
|
}
|
|
526
527
|
}
|
|
527
528
|
for (const [a, p] of c) {
|
|
528
|
-
const
|
|
529
|
+
const u = D(s, a).split(I).join("/") || ".", m = o.has(a);
|
|
529
530
|
let f = [];
|
|
530
531
|
try {
|
|
531
|
-
f =
|
|
532
|
+
f = se(a);
|
|
532
533
|
} catch {
|
|
533
534
|
continue;
|
|
534
535
|
}
|
|
535
|
-
f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && n.push(`${
|
|
536
|
+
f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && n.push(`${u}: story files without a type component page, add the component index.md or move the stories`);
|
|
536
537
|
for (const g of ["schema.json", "schema.yml"])
|
|
537
|
-
f.includes(g) && !m && n.push(`${
|
|
538
|
+
f.includes(g) && !m && n.push(`${u}: ${g} without a type component page, it belongs beside the component index.md`);
|
|
538
539
|
if (m && p.length > 1) {
|
|
539
|
-
const g = p.filter((w) => w !== o.get(a)).map((w) =>
|
|
540
|
-
n.push(`${
|
|
540
|
+
const g = p.filter((w) => w !== o.get(a)).map((w) => F(w));
|
|
541
|
+
n.push(`${u}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
|
|
541
542
|
}
|
|
542
543
|
}
|
|
543
|
-
const
|
|
544
|
+
const l = (a) => {
|
|
544
545
|
let p;
|
|
545
546
|
try {
|
|
546
|
-
p =
|
|
547
|
+
p = se(a, { withFileTypes: !0 });
|
|
547
548
|
} catch {
|
|
548
549
|
return;
|
|
549
550
|
}
|
|
550
|
-
for (const
|
|
551
|
-
if (
|
|
552
|
-
if (!
|
|
553
|
-
const m = D(s, d(a,
|
|
551
|
+
for (const u of p)
|
|
552
|
+
if (u.isDirectory() && !(u.name.startsWith(".") || u.name === "node_modules")) {
|
|
553
|
+
if (!Ue.test(u.name) && !bs.test(u.name)) {
|
|
554
|
+
const m = D(s, d(a, u.name)).split(I).join("/");
|
|
554
555
|
n.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
|
|
555
556
|
}
|
|
556
|
-
|
|
557
|
+
l(d(a, u.name));
|
|
557
558
|
}
|
|
558
559
|
};
|
|
559
|
-
return
|
|
560
|
+
return l(s), n;
|
|
560
561
|
}
|
|
561
|
-
async function
|
|
562
|
-
const s =
|
|
562
|
+
async function js(e, t) {
|
|
563
|
+
const s = nt(e, t, "lint"), n = () => ne(s, { recursive: !0, force: !0 }), o = () => {
|
|
563
564
|
n(), process.exit(130);
|
|
564
565
|
};
|
|
565
566
|
process.once("SIGINT", o), process.once("SIGTERM", o);
|
|
566
567
|
try {
|
|
567
|
-
return await
|
|
568
|
+
return await gt(e, { ...t, paths: { ...t.paths, out: s } }), [];
|
|
568
569
|
} catch (r) {
|
|
569
570
|
return (r instanceof Error ? r.message : String(r)).split(`
|
|
570
571
|
`).filter((c) => c.trim()).map((c) => `build: ${c.trim()}`);
|
|
@@ -572,23 +573,23 @@ async function ws(e, t) {
|
|
|
572
573
|
process.off("SIGINT", o), process.off("SIGTERM", o), n();
|
|
573
574
|
}
|
|
574
575
|
}
|
|
575
|
-
async function
|
|
576
|
+
async function Cs(e, t) {
|
|
576
577
|
const s = process.argv.slice(2), n = [
|
|
577
|
-
...
|
|
578
|
-
...(
|
|
579
|
-
...
|
|
580
|
-
...await
|
|
578
|
+
...Ss(e, t),
|
|
579
|
+
...(Vt(e, t.pageTypes ?? {}), await Kt(e, t.contentDir)),
|
|
580
|
+
...xs(e, t),
|
|
581
|
+
...await mt(e, t)
|
|
581
582
|
];
|
|
582
583
|
if (n.length) {
|
|
583
|
-
|
|
584
|
+
_e("nimpress lint", n, "");
|
|
584
585
|
return;
|
|
585
586
|
}
|
|
586
587
|
if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(s, "no-build")) return;
|
|
587
588
|
console.log("nimpress lint: building to verify the output compiles");
|
|
588
|
-
const o = await
|
|
589
|
-
|
|
589
|
+
const o = await js(e, t);
|
|
590
|
+
_e("nimpress lint", o, "nimpress lint: build ok, everything passes");
|
|
590
591
|
}
|
|
591
|
-
const
|
|
592
|
+
const Es = {
|
|
592
593
|
".json": "application/json",
|
|
593
594
|
".xml": "application/rss+xml",
|
|
594
595
|
".html": "text/html",
|
|
@@ -601,29 +602,29 @@ const ys = {
|
|
|
601
602
|
".webp": "image/webp",
|
|
602
603
|
".pdf": "application/pdf"
|
|
603
604
|
};
|
|
604
|
-
function
|
|
605
|
-
const n = s[0], o = d(e,
|
|
605
|
+
function Os(e, t, s) {
|
|
606
|
+
const n = s[0], o = d(e, N(s, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
|
|
606
607
|
if (!$(i))
|
|
607
608
|
throw new Error(`[nimpress] guard: ${i} not found, run a build first`);
|
|
608
609
|
const c = JSON.parse(C(i, "utf-8"));
|
|
609
610
|
if (n === "map") {
|
|
610
|
-
const
|
|
611
|
-
const v = D(
|
|
611
|
+
const l = Ge(o, t), a = d(o, "guard.map.json"), p = $(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, u = $(l) ? oe(l) : [], m = p.prefix ?? r, f = u.map((w) => {
|
|
612
|
+
const v = D(l, w).split("\\").join("/"), O = v.split("/")[0] ?? "", E = [
|
|
612
613
|
...new Set(
|
|
613
|
-
Object.values(p.routes ?? {}).filter((T) => T.bundle ===
|
|
614
|
+
Object.values(p.routes ?? {}).filter((T) => T.bundle === O && T.gate).map((T) => T.gate)
|
|
614
615
|
)
|
|
615
616
|
], k = C(w);
|
|
616
617
|
return {
|
|
617
618
|
path: `${m}${v}`,
|
|
618
619
|
file: v,
|
|
619
|
-
bundle:
|
|
620
|
-
sha256:
|
|
621
|
-
size:
|
|
622
|
-
mime:
|
|
620
|
+
bundle: O,
|
|
621
|
+
sha256: lt("sha256").update(k).digest("hex"),
|
|
622
|
+
size: rt(w).size,
|
|
623
|
+
mime: Es[me(w).toLowerCase()] ?? "application/octet-stream",
|
|
623
624
|
gates: E
|
|
624
625
|
};
|
|
625
|
-
}), h =
|
|
626
|
-
|
|
626
|
+
}), h = N(s, "out"), g = h ? d(e, h) : a;
|
|
627
|
+
W(
|
|
627
628
|
g,
|
|
628
629
|
JSON.stringify({ ...p, prefix: m, files: f }, null, 2) + `
|
|
629
630
|
`
|
|
@@ -631,9 +632,9 @@ function bs(e, t, s) {
|
|
|
631
632
|
return;
|
|
632
633
|
}
|
|
633
634
|
if (n === "apply") {
|
|
634
|
-
const
|
|
635
|
-
if (!
|
|
636
|
-
const a = JSON.parse(C(d(e,
|
|
635
|
+
const l = N(s, "map");
|
|
636
|
+
if (!l) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
|
|
637
|
+
const a = JSON.parse(C(d(e, l), "utf-8"));
|
|
637
638
|
if (!a.base) throw new Error("[nimpress] guard apply: mapping json carries no base url");
|
|
638
639
|
c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((p) => ({
|
|
639
640
|
path: p.path,
|
|
@@ -641,59 +642,59 @@ function bs(e, t, s) {
|
|
|
641
642
|
bundle: p.bundle,
|
|
642
643
|
asset_id: p.asset_id,
|
|
643
644
|
url: p.url
|
|
644
|
-
})),
|
|
645
|
-
`),
|
|
645
|
+
})), W(i, JSON.stringify(c, null, 2) + `
|
|
646
|
+
`), ne(Ge(o, t), { recursive: !0, force: !0 }), ne(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
|
|
646
647
|
return;
|
|
647
648
|
}
|
|
648
649
|
throw new Error("[nimpress] guard expects map or apply");
|
|
649
650
|
}
|
|
650
|
-
function
|
|
651
|
-
const t =
|
|
651
|
+
function wt(e) {
|
|
652
|
+
const t = me(e);
|
|
652
653
|
return t === ".vue" ? "vue" : t === ".svelte" ? "svelte" : null;
|
|
653
654
|
}
|
|
654
|
-
async function
|
|
655
|
-
const i = (await
|
|
655
|
+
async function Le(e, t, s, n, o) {
|
|
656
|
+
const i = (await Pe(e, t.contentDir)).find((m) => m.system === s && m.component === n);
|
|
656
657
|
if (!i)
|
|
657
658
|
return console.warn(`[nimpress] modules story: no type component page found for ${s}/${n}`), null;
|
|
658
|
-
const c =
|
|
659
|
+
const c = Me(e, t.modules, s, n, i.file);
|
|
659
660
|
if (!c)
|
|
660
661
|
return console.warn(`[nimpress] modules story: no source found for ${s}/${n}`), null;
|
|
661
|
-
const
|
|
662
|
-
if (!
|
|
662
|
+
const l = o ?? wt(c.componentFile);
|
|
663
|
+
if (!l)
|
|
663
664
|
throw new Error(
|
|
664
665
|
`[nimpress] modules story: failed to detect framework for ${c.componentFile}, pass --framework=vue or --framework=svelte`
|
|
665
666
|
);
|
|
666
|
-
const a =
|
|
667
|
+
const a = l === "vue" ? "vueStory" : "svelteStory", p = `import { ${a} } from '@nimtech/nimpress/story'
|
|
667
668
|
|
|
668
669
|
// story: Default
|
|
669
670
|
export default ${a}({
|
|
670
671
|
name: "Default"
|
|
671
672
|
})
|
|
672
|
-
`,
|
|
673
|
-
return $(
|
|
673
|
+
`, u = d(_(i.pageFile), "default.story.tsx");
|
|
674
|
+
return $(u) ? (console.warn(`[nimpress] modules story: ${u} exists, not overwriting`), null) : (await Q(u, p), u);
|
|
674
675
|
}
|
|
675
|
-
async function
|
|
676
|
-
const n = await
|
|
676
|
+
async function Fs(e, t, s) {
|
|
677
|
+
const n = await Pe(e, t.contentDir);
|
|
677
678
|
let o = 0;
|
|
678
679
|
for (const r of n)
|
|
679
|
-
if (!(r.system !== s || (await
|
|
680
|
+
if (!(r.system !== s || (await et(_(r.pageFile))).length))
|
|
680
681
|
try {
|
|
681
|
-
await
|
|
682
|
+
await Le(e, t, s, r.component) && o++;
|
|
682
683
|
} catch (c) {
|
|
683
684
|
console.warn(String(c));
|
|
684
685
|
}
|
|
685
686
|
return o;
|
|
686
687
|
}
|
|
687
|
-
async function
|
|
688
|
+
async function Ds(e, t, s, n, o) {
|
|
688
689
|
const r = t.modules.systems[s];
|
|
689
690
|
if (!r) throw new Error(`[nimpress] modules create: unknown system ${s}`);
|
|
690
691
|
const i = d(e, t.contentDir, "components", "Components", n), c = d(i, "index.md");
|
|
691
692
|
if ($(c))
|
|
692
693
|
throw new Error(`[nimpress] modules create: ${c} exists`);
|
|
693
|
-
const { mkdir:
|
|
694
|
-
await
|
|
694
|
+
const { mkdir: l } = await import("node:fs/promises");
|
|
695
|
+
await l(i, { recursive: !0 });
|
|
695
696
|
const a = r.package;
|
|
696
|
-
await
|
|
697
|
+
await Q(
|
|
697
698
|
c,
|
|
698
699
|
`---
|
|
699
700
|
title: ${n}
|
|
@@ -711,18 +712,18 @@ import { ${n} } from "${a ?? s}";
|
|
|
711
712
|
\`\`\`
|
|
712
713
|
`
|
|
713
714
|
);
|
|
714
|
-
const p =
|
|
715
|
+
const p = Me(e, t.modules, s, n);
|
|
715
716
|
if (p) {
|
|
716
|
-
const
|
|
717
|
-
await
|
|
717
|
+
const u = o ?? wt(p.componentFile) ?? r.framework;
|
|
718
|
+
await pe(i, n, await ue(p.componentFile, u, n)), await Le(e, t, s, n, o);
|
|
718
719
|
} else {
|
|
719
|
-
const
|
|
720
|
-
await
|
|
720
|
+
const u = r.framework === "vue" ? "vueStory" : "svelteStory";
|
|
721
|
+
await Q(
|
|
721
722
|
d(i, "default.story.tsx"),
|
|
722
|
-
`import { ${
|
|
723
|
+
`import { ${u} } from '@nimtech/nimpress/story'
|
|
723
724
|
|
|
724
725
|
// story: Default
|
|
725
|
-
export default ${
|
|
726
|
+
export default ${u}({
|
|
726
727
|
name: "Default",
|
|
727
728
|
props: {}
|
|
728
729
|
})
|
|
@@ -733,17 +734,17 @@ export default ${l}({
|
|
|
733
734
|
}
|
|
734
735
|
return i;
|
|
735
736
|
}
|
|
736
|
-
function
|
|
737
|
+
function ye(e) {
|
|
737
738
|
try {
|
|
738
739
|
return JSON.parse(JSON.stringify(e, (t, s) => typeof s == "function" ? void 0 : s));
|
|
739
740
|
} catch {
|
|
740
741
|
return {};
|
|
741
742
|
}
|
|
742
743
|
}
|
|
743
|
-
function
|
|
744
|
+
function be(e, t = []) {
|
|
744
745
|
let s;
|
|
745
746
|
try {
|
|
746
|
-
s =
|
|
747
|
+
s = se(e, { withFileTypes: !0 });
|
|
747
748
|
} catch {
|
|
748
749
|
return t;
|
|
749
750
|
}
|
|
@@ -751,15 +752,15 @@ function we(e, t = []) {
|
|
|
751
752
|
const o = d(e, n.name);
|
|
752
753
|
if (n.isDirectory()) {
|
|
753
754
|
if (n.name === "node_modules" || n.name.startsWith(".")) continue;
|
|
754
|
-
|
|
755
|
+
be(o, t);
|
|
755
756
|
} else n.isFile() && t.push(o);
|
|
756
757
|
}
|
|
757
758
|
return t;
|
|
758
759
|
}
|
|
759
|
-
function
|
|
760
|
+
function We(e) {
|
|
760
761
|
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
761
762
|
}
|
|
762
|
-
function
|
|
763
|
+
function Te(e) {
|
|
763
764
|
const t = C(e, "utf-8"), s = t.split(`
|
|
764
765
|
`), n = [];
|
|
765
766
|
let o = 0;
|
|
@@ -789,10 +790,10 @@ function We(e) {
|
|
|
789
790
|
const g = c(h);
|
|
790
791
|
g?.kind === "data" && i.push(g.abs);
|
|
791
792
|
}
|
|
792
|
-
const
|
|
793
|
+
const l = n.filter((f) => !f.includes("@storybook")).map(
|
|
793
794
|
(f) => f.replace(/from\s+["'](\.\.?\/[^"']+)["']/g, (h, g) => {
|
|
794
795
|
const w = c(g);
|
|
795
|
-
return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${
|
|
796
|
+
return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${F(g).replace(/\.ts$/, "")}"`;
|
|
796
797
|
})
|
|
797
798
|
).join(`
|
|
798
799
|
`);
|
|
@@ -807,13 +808,13 @@ function We(e) {
|
|
|
807
808
|
`, h) + 1);
|
|
808
809
|
return;
|
|
809
810
|
}
|
|
810
|
-
const w =
|
|
811
|
-
a = a.slice(0, h) + a.slice(v +
|
|
811
|
+
const w = $e(a, g + 1), v = g + 1 + w.length + 1, O = a.slice(v).match(/^[^\n]*/)?.[0] ?? "";
|
|
812
|
+
a = a.slice(0, h) + a.slice(v + O.length);
|
|
812
813
|
};
|
|
813
814
|
p(/^const meta\b[^\n]*/m), a = a.replace(/^export default meta;?\s*$/m, ""), a = a.replace(/^(?:export )?type \w+[^\n]*\n(?:[ \t]+[^\n]*\n?)*/gm, "");
|
|
814
|
-
let
|
|
815
|
-
for (; /^(?:export )?interface \w+/m.test(a) &&
|
|
816
|
-
p(/^(?:export )?interface \w+[^\n]*/m),
|
|
815
|
+
let u = 0;
|
|
816
|
+
for (; /^(?:export )?interface \w+/m.test(a) && u < 50; )
|
|
817
|
+
p(/^(?:export )?interface \w+[^\n]*/m), u++;
|
|
817
818
|
let m = 0;
|
|
818
819
|
for (; /^export const \w+/m.test(a) && m < 200; )
|
|
819
820
|
p(/^export const \w+[^\n]*/m), m++;
|
|
@@ -822,12 +823,12 @@ function We(e) {
|
|
|
822
823
|
text: t,
|
|
823
824
|
title: t.match(/\btitle:\s*["']([^"']+)["']/)?.[1],
|
|
824
825
|
metaComponent: t.match(/\bcomponent:\s*([A-Za-z_$][\w$]*)\s*[,\n}]/)?.[1],
|
|
825
|
-
imports:
|
|
826
|
+
imports: l,
|
|
826
827
|
declarations: a.trim(),
|
|
827
828
|
dataModules: i
|
|
828
829
|
};
|
|
829
830
|
}
|
|
830
|
-
function
|
|
831
|
+
function Ns(e, t) {
|
|
831
832
|
const s = e.indexOf(":", t) + 1;
|
|
832
833
|
let n = 0, o = null;
|
|
833
834
|
for (let r = s; r < e.length; r++) {
|
|
@@ -846,56 +847,56 @@ function xs(e, t) {
|
|
|
846
847
|
}
|
|
847
848
|
return e.slice(s).trim();
|
|
848
849
|
}
|
|
849
|
-
function
|
|
850
|
+
function $t(e) {
|
|
850
851
|
return e.replace(/\bsatisfies\s+[A-Za-z_$][\w$.]*(?:<[^>]*>)?/g, "").replace(/\bas\s+const\b/g, "").replace(/\)\s*:\s*[A-Za-z_$][\w$<>\[\], .|&]*\s*=>/g, ") =>").replace(/\(\s*([A-Za-z_$][\w$]*)\s*:\s*[A-Za-z_$][\w$<>\[\], .|&]*\)/g, "($1)");
|
|
851
852
|
}
|
|
852
|
-
function
|
|
853
|
+
function yt(e) {
|
|
853
854
|
const t = [], s = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
|
|
854
855
|
let n;
|
|
855
856
|
for (; n = s.exec(e.text); ) {
|
|
856
857
|
const o = n[1];
|
|
857
858
|
if (o === "default" || o === "meta") continue;
|
|
858
|
-
const r =
|
|
859
|
+
const r = $e(e.text, s.lastIndex), i = r.search(/\brender\s*:/);
|
|
859
860
|
if (i >= 0) {
|
|
860
|
-
const a =
|
|
861
|
+
const a = Ns(r, i);
|
|
861
862
|
if (a) {
|
|
862
863
|
t.push({ name: o, renderFn: a });
|
|
863
864
|
continue;
|
|
864
865
|
}
|
|
865
866
|
}
|
|
866
867
|
const c = r.search(/\bargs\s*:/);
|
|
867
|
-
let
|
|
868
|
+
let l = {};
|
|
868
869
|
if (c >= 0) {
|
|
869
870
|
const a = r.indexOf("{", c);
|
|
870
871
|
if (a >= 0) {
|
|
871
|
-
const p =
|
|
872
|
+
const p = $e(r, a + 1);
|
|
872
873
|
try {
|
|
873
|
-
|
|
874
|
+
l = ye(new Function(`${$t(e.declarations)}
|
|
874
875
|
return {${p}}`)());
|
|
875
876
|
} catch {
|
|
876
877
|
try {
|
|
877
|
-
|
|
878
|
+
l = ye(new Function(`return {${p}}`)());
|
|
878
879
|
} catch {
|
|
879
|
-
|
|
880
|
+
l = {};
|
|
880
881
|
}
|
|
881
882
|
}
|
|
882
883
|
}
|
|
883
884
|
}
|
|
884
|
-
t.push({ name: o, props:
|
|
885
|
+
t.push({ name: o, props: l });
|
|
885
886
|
}
|
|
886
887
|
return t;
|
|
887
888
|
}
|
|
888
|
-
function
|
|
889
|
+
function bt(e) {
|
|
889
890
|
const t = e.text.search(/\bargTypes\s*:\s*\{/);
|
|
890
891
|
if (t < 0) return;
|
|
891
|
-
const s = e.text.indexOf("{", t), n =
|
|
892
|
+
const s = e.text.indexOf("{", t), n = $e(e.text, s + 1);
|
|
892
893
|
let o;
|
|
893
894
|
try {
|
|
894
|
-
o =
|
|
895
|
+
o = ye(new Function(`return {${n}}`)());
|
|
895
896
|
} catch {
|
|
896
897
|
try {
|
|
897
|
-
o =
|
|
898
|
-
new Function(`${
|
|
898
|
+
o = ye(
|
|
899
|
+
new Function(`${$t(e.declarations)}
|
|
899
900
|
return {${n}}`)()
|
|
900
901
|
);
|
|
901
902
|
} catch {
|
|
@@ -905,16 +906,16 @@ return {${n}}`)()
|
|
|
905
906
|
const r = {};
|
|
906
907
|
for (const [i, c] of Object.entries(o)) {
|
|
907
908
|
if (!c || typeof c != "object") continue;
|
|
908
|
-
const
|
|
909
|
-
typeof c.description == "string" && (
|
|
909
|
+
const l = c.control, a = typeof l == "string" ? l : String(l?.type ?? ""), p = c.options ?? (typeof l == "object" ? l?.options : void 0), u = {};
|
|
910
|
+
typeof c.description == "string" && (u.description = c.description), Array.isArray(p) ? u.enum = p : a === "boolean" ? u.type = "boolean" : a === "number" || a === "range" ? u.type = "number" : a === "text" || a === "color" || a === "date" ? u.type = "string" : a === "object" && (u.type = "object"), c.defaultValue !== void 0 && (u.default = c.defaultValue), Object.keys(u).length && (r[i] = u);
|
|
910
911
|
}
|
|
911
912
|
return Object.keys(r).length ? r : void 0;
|
|
912
913
|
}
|
|
913
|
-
async function
|
|
914
|
+
async function vt(e) {
|
|
914
915
|
const t = [...e].sort();
|
|
915
916
|
for (let i = 0; i < t.length; i++)
|
|
916
917
|
console.log(`${String(i + 1).padStart(4)} ${t[i]}`);
|
|
917
|
-
const s =
|
|
918
|
+
const s = ut({ input: process.stdin, output: process.stdout }), n = await s.question(
|
|
918
919
|
"select components to import, comma separated numbers, names, or /regex/, empty imports all: "
|
|
919
920
|
);
|
|
920
921
|
s.close();
|
|
@@ -924,20 +925,20 @@ async function gt(e) {
|
|
|
924
925
|
for (const i of o.split(",").map((c) => c.trim()).filter(Boolean)) {
|
|
925
926
|
const c = i.match(/^\/(.+)\/$/);
|
|
926
927
|
if (c) {
|
|
927
|
-
const
|
|
928
|
-
for (const a of t)
|
|
928
|
+
const l = new RegExp(c[1]);
|
|
929
|
+
for (const a of t) l.test(a) && r.add(a);
|
|
929
930
|
continue;
|
|
930
931
|
}
|
|
931
932
|
if (/^\d+$/.test(i)) {
|
|
932
|
-
const
|
|
933
|
-
|
|
933
|
+
const l = t[Number(i) - 1];
|
|
934
|
+
l && r.add(l);
|
|
934
935
|
continue;
|
|
935
936
|
}
|
|
936
|
-
for (const
|
|
937
|
+
for (const l of t) l === i && r.add(l);
|
|
937
938
|
}
|
|
938
939
|
return r;
|
|
939
940
|
}
|
|
940
|
-
function
|
|
941
|
+
function kt(e, t) {
|
|
941
942
|
const s = /* @__PURE__ */ new Map(), n = d(e, "node_modules", t, "index.mjs");
|
|
942
943
|
if (!$(n)) return s;
|
|
943
944
|
const o = C(n, "utf-8");
|
|
@@ -945,143 +946,143 @@ function wt(e, t) {
|
|
|
945
946
|
s.set(r[1].toLowerCase(), r[1]);
|
|
946
947
|
return s;
|
|
947
948
|
}
|
|
948
|
-
async function
|
|
949
|
+
async function _s(e, t, s, n) {
|
|
949
950
|
const o = t.modules.systems[s];
|
|
950
951
|
if (!o) throw new Error(`[nimpress] modules import: unknown system ${s}`);
|
|
951
|
-
const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"),
|
|
952
|
+
const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), l = o.package, a = n.match ? new RegExp(n.match) : null;
|
|
952
953
|
if (n.file) {
|
|
953
954
|
const y = j(e, n.file);
|
|
954
955
|
if (!$(y)) throw new Error(`[nimpress] modules import: ${y} not found`);
|
|
955
|
-
if (
|
|
956
|
+
if (me(y) !== i)
|
|
956
957
|
throw new Error(`[nimpress] modules import: ${y} does not match system framework ${r}`);
|
|
957
|
-
const b = n.name ??
|
|
958
|
-
await
|
|
959
|
-
const P = D(
|
|
960
|
-
await
|
|
958
|
+
const b = n.name ?? F(y, i), U = o.source ? j(e, o.source) : e, A = d(c, "Components", b);
|
|
959
|
+
await Ne(A, { recursive: !0 });
|
|
960
|
+
const P = D(U, y);
|
|
961
|
+
await Q(d(A, "index.md"), Re(s, b, l, P)), await pe(A, b, await ue(y, r, b)), console.log(`nimpress modules: imported ${b} at ${D(e, A)}`);
|
|
961
962
|
return;
|
|
962
963
|
}
|
|
963
964
|
if (n.fromStories) {
|
|
964
|
-
await
|
|
965
|
+
await Ws(e, t, s, n);
|
|
965
966
|
return;
|
|
966
967
|
}
|
|
967
968
|
const p = j(e, n.source ?? o.source ?? "");
|
|
968
969
|
if (!$(p))
|
|
969
970
|
throw new Error(`[nimpress] modules import: source ${p} not found`);
|
|
970
|
-
const
|
|
971
|
+
const u = be(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = u.filter((y) => y.endsWith(".stories.ts")), g = n.stories ? [j(e, n.stories)] : [];
|
|
971
972
|
for (const y of g)
|
|
972
|
-
for (const b of
|
|
973
|
+
for (const b of be(y))
|
|
973
974
|
b.endsWith(".stories.ts") && h.push(b);
|
|
974
|
-
const w =
|
|
975
|
-
(y) => y.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(
|
|
976
|
-
), v = new Set(w.map((y) =>
|
|
975
|
+
const w = u.filter(
|
|
976
|
+
(y) => y.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(F(y, i))
|
|
977
|
+
), v = new Set(w.map((y) => F(y, i))), O = l && !o.source ? kt(e, l) : null;
|
|
977
978
|
for (const y of h) {
|
|
978
|
-
const b =
|
|
979
|
+
const b = Te(y);
|
|
979
980
|
if (b.title?.includes("/")) {
|
|
980
|
-
const [
|
|
981
|
-
m.set(
|
|
981
|
+
const [J, L] = b.title.split("/");
|
|
982
|
+
m.set(L, J.replace(/\s+/g, ""));
|
|
982
983
|
}
|
|
983
|
-
const
|
|
984
|
-
let P = $(d(_(y), `${
|
|
984
|
+
const U = F(y, ".stories.ts");
|
|
985
|
+
let P = $(d(_(y), `${U}${i}`)) ? U : b.metaComponent ?? U;
|
|
985
986
|
if (!v.has(P)) {
|
|
986
|
-
let
|
|
987
|
-
for (const
|
|
988
|
-
|
|
989
|
-
|
|
987
|
+
let J = "";
|
|
988
|
+
for (const L of v)
|
|
989
|
+
U.startsWith(L) && L.length > J.length && (J = L);
|
|
990
|
+
J ? P = J : console.warn(`nimpress modules: ${F(y)} targets ${P} which has no component page`);
|
|
990
991
|
}
|
|
991
|
-
const S =
|
|
992
|
-
|
|
992
|
+
const S = O?.get(P.toLowerCase()) ?? P, Z = f.get(S) ?? [];
|
|
993
|
+
Z.push(b), f.set(S, Z);
|
|
993
994
|
}
|
|
994
995
|
const E = /* @__PURE__ */ new Map();
|
|
995
996
|
let k = 0, T = 0;
|
|
996
|
-
const x = w.filter((y) => !a || a.test(
|
|
997
|
+
const x = w.filter((y) => !a || a.test(F(y, i))), R = n.select ? await vt(x.map((y) => F(y, i))) : null;
|
|
997
998
|
for (const y of x) {
|
|
998
|
-
const b =
|
|
999
|
-
if (
|
|
999
|
+
const b = F(y, i);
|
|
1000
|
+
if (R && !R.has(b)) continue;
|
|
1000
1001
|
if (E.has(b)) {
|
|
1001
1002
|
console.warn(`nimpress modules: skip duplicate ${b}, kept ${E.get(b)}`);
|
|
1002
1003
|
continue;
|
|
1003
1004
|
}
|
|
1004
1005
|
E.set(b, D(p, y));
|
|
1005
|
-
const
|
|
1006
|
-
await
|
|
1007
|
-
const P = D(p, y), S = P === `${b}/${b}${i}` || P === `${b}${i}`,
|
|
1008
|
-
(B,
|
|
1006
|
+
const U = m.get(b) ?? "Components", A = d(c, U, b);
|
|
1007
|
+
await Ne(A, { recursive: !0 });
|
|
1008
|
+
const P = D(p, y), S = P === `${b}/${b}${i}` || P === `${b}${i}`, Z = (f.get(b) ?? []).map((B) => bt(B)).reduce(
|
|
1009
|
+
(B, q) => q ? { ...B ?? {}, ...q } : B,
|
|
1009
1010
|
void 0
|
|
1010
1011
|
);
|
|
1011
|
-
await
|
|
1012
|
-
const
|
|
1013
|
-
for (const B of
|
|
1014
|
-
const
|
|
1015
|
-
|
|
1016
|
-
for (const
|
|
1017
|
-
await
|
|
1018
|
-
for (const
|
|
1019
|
-
const
|
|
1020
|
-
let
|
|
1021
|
-
|
|
1022
|
-
const
|
|
1023
|
-
|
|
1012
|
+
await Q(d(A, "index.md"), Re(s, b, l, S ? void 0 : P)), await pe(A, b, await ue(y, r, b)), Z && await ot(A, { properties: Z }), k++;
|
|
1013
|
+
const J = f.get(b) ?? [], L = /* @__PURE__ */ new Set();
|
|
1014
|
+
for (const B of J) {
|
|
1015
|
+
const q = F(B.file, ".stories.ts"), ze = yt(B);
|
|
1016
|
+
ze.length || console.warn(`nimpress modules: no stories mined from ${F(B.file)}`);
|
|
1017
|
+
for (const Y of B.dataModules)
|
|
1018
|
+
await it(Y, d(A, F(Y)));
|
|
1019
|
+
for (const Y of ze) {
|
|
1020
|
+
const Je = Y.name === b ? "Default" : q === b ? Y.name : `${q} ${Y.name}`;
|
|
1021
|
+
let he = We(Je);
|
|
1022
|
+
L.has(he) && (he = We(`${q}-${Y.name}`));
|
|
1023
|
+
const Be = d(A, `${he}.story.tsx`);
|
|
1024
|
+
L.add(he), !$(Be) && (await Q(Be, xt(r, Je, q, Y, B)), T++);
|
|
1024
1025
|
}
|
|
1025
1026
|
}
|
|
1026
1027
|
}
|
|
1027
1028
|
console.log(`nimpress modules: imported ${k} components with ${T} stories for ${s}`);
|
|
1028
1029
|
}
|
|
1029
|
-
async function
|
|
1030
|
+
async function Ws(e, t, s, n) {
|
|
1030
1031
|
const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = j(e, n.stories ?? "");
|
|
1031
1032
|
if (!n.stories || !$(c))
|
|
1032
1033
|
throw new Error("[nimpress] modules import --from-stories requires --stories=<csf dir>");
|
|
1033
|
-
const
|
|
1034
|
-
let
|
|
1035
|
-
const f =
|
|
1036
|
-
f.map((g) =>
|
|
1034
|
+
const l = o.source ? j(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, p = /* @__PURE__ */ new Set();
|
|
1035
|
+
let u = 0, m = 0;
|
|
1036
|
+
const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await vt(
|
|
1037
|
+
f.map((g) => Te(g).metaComponent ?? F(g, ".stories.ts"))
|
|
1037
1038
|
) : null;
|
|
1038
1039
|
for (const g of f) {
|
|
1039
|
-
const w =
|
|
1040
|
-
if (h && !h.has(
|
|
1040
|
+
const w = Te(g), v = F(g, ".stories.ts"), O = w.metaComponent ?? v;
|
|
1041
|
+
if (h && !h.has(O)) continue;
|
|
1041
1042
|
const E = w.text.match(
|
|
1042
|
-
new RegExp(`import\\s+(?:\\{\\s*)?${
|
|
1043
|
+
new RegExp(`import\\s+(?:\\{\\s*)?${O}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
|
|
1043
1044
|
)?.[1];
|
|
1044
|
-
let k =
|
|
1045
|
+
let k = O, T = o.package, x;
|
|
1045
1046
|
if (E && !E.startsWith(".") && !E.startsWith("@/")) {
|
|
1046
1047
|
const S = E.split("/")[0].startsWith("@") ? E.split("/").slice(0, 2).join("/") : E.split("/")[0];
|
|
1047
|
-
T = S, k =
|
|
1048
|
+
T = S, k = kt(e, S).get(O.toLowerCase()) ?? O;
|
|
1048
1049
|
} else if (E?.startsWith("@/components/")) {
|
|
1049
1050
|
const S = E.slice(13);
|
|
1050
1051
|
S === k || S === `${k}/${k}.vue` || (x = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${k}.vue`);
|
|
1051
1052
|
} else if (E?.startsWith(".")) {
|
|
1052
1053
|
const S = j(_(g), E);
|
|
1053
|
-
x = D(
|
|
1054
|
+
x = D(l, S);
|
|
1054
1055
|
}
|
|
1055
1056
|
if (a && !a.test(k)) continue;
|
|
1056
1057
|
if (p.has(k)) {
|
|
1057
|
-
console.warn(`nimpress modules: skip duplicate ${k} from ${
|
|
1058
|
+
console.warn(`nimpress modules: skip duplicate ${k} from ${F(g)}`);
|
|
1058
1059
|
continue;
|
|
1059
1060
|
}
|
|
1060
1061
|
p.add(k);
|
|
1061
|
-
const
|
|
1062
|
-
await
|
|
1063
|
-
const b = r === "vue" ? ".vue" : ".svelte",
|
|
1064
|
-
d(
|
|
1065
|
-
d(
|
|
1062
|
+
const R = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", y = d(i, R, k);
|
|
1063
|
+
await Ne(y, { recursive: !0 }), await Q(d(y, "index.md"), Re(s, k, T, x));
|
|
1064
|
+
const b = r === "vue" ? ".vue" : ".svelte", A = (x ? [j(l, x)] : [
|
|
1065
|
+
d(l, k, `${k}${b}`),
|
|
1066
|
+
d(l, `${k}${b}`)
|
|
1066
1067
|
]).find((S) => $(S));
|
|
1067
|
-
if (
|
|
1068
|
-
await
|
|
1068
|
+
if (A)
|
|
1069
|
+
await pe(y, k, await ue(A, r, k));
|
|
1069
1070
|
else if (T) {
|
|
1070
|
-
const S =
|
|
1071
|
-
S ? await
|
|
1071
|
+
const S = Qt(e, T, k);
|
|
1072
|
+
S ? await pe(y, k, Xt(C(S, "utf-8"), k)) : console.warn(`nimpress modules: no source or d.ts found for ${k}, the schema seed is skipped`);
|
|
1072
1073
|
}
|
|
1073
|
-
const P =
|
|
1074
|
-
P && await
|
|
1074
|
+
const P = bt(w);
|
|
1075
|
+
P && await ot(y, { properties: P }), u++;
|
|
1075
1076
|
for (const S of w.dataModules)
|
|
1076
|
-
await
|
|
1077
|
-
for (const S of
|
|
1078
|
-
const
|
|
1079
|
-
$(
|
|
1077
|
+
await it(S, d(y, F(S)));
|
|
1078
|
+
for (const S of yt(w)) {
|
|
1079
|
+
const Z = S.name === k ? "Default" : S.name, J = We(Z), L = d(y, `${J}.story.tsx`);
|
|
1080
|
+
$(L) || (await Q(L, xt(r, Z, v, S, w)), m++);
|
|
1080
1081
|
}
|
|
1081
1082
|
}
|
|
1082
|
-
console.log(`nimpress modules: imported ${
|
|
1083
|
+
console.log(`nimpress modules: imported ${u} components with ${m} stories for ${s} from stories`);
|
|
1083
1084
|
}
|
|
1084
|
-
function
|
|
1085
|
+
function Re(e, t, s, n) {
|
|
1085
1086
|
const o = s ? `
|
|
1086
1087
|
package: "${s}"` : "", r = n ? `
|
|
1087
1088
|
file: ${JSON.stringify(n)}` : "";
|
|
@@ -1100,7 +1101,7 @@ import { ${t} } from "${s ?? e}";
|
|
|
1100
1101
|
\`\`\`
|
|
1101
1102
|
`;
|
|
1102
1103
|
}
|
|
1103
|
-
function
|
|
1104
|
+
function xt(e, t, s, n, o) {
|
|
1104
1105
|
const r = e === "vue" ? "vueStory" : "svelteStory";
|
|
1105
1106
|
return n.renderFn ? `import { ${r} } from '@nimtech/nimpress/story'
|
|
1106
1107
|
${o.imports}
|
|
@@ -1122,16 +1123,16 @@ export default ${r}({
|
|
|
1122
1123
|
})
|
|
1123
1124
|
`;
|
|
1124
1125
|
}
|
|
1125
|
-
function
|
|
1126
|
-
const s =
|
|
1126
|
+
function le(e, t) {
|
|
1127
|
+
const s = N(t, "system");
|
|
1127
1128
|
if (s === void 0) return;
|
|
1128
1129
|
const n = Object.keys(e.modules.systems);
|
|
1129
1130
|
if (!n.includes(s))
|
|
1130
1131
|
throw new Error(`[nimpress] modules: unknown system ${s}, configured: ${n.join(", ") || "none"}`);
|
|
1131
1132
|
return s;
|
|
1132
1133
|
}
|
|
1133
|
-
function
|
|
1134
|
-
const n =
|
|
1134
|
+
function je(e, t, s) {
|
|
1135
|
+
const n = le(e, t);
|
|
1135
1136
|
if (n) return n;
|
|
1136
1137
|
const o = Object.keys(e.modules.systems);
|
|
1137
1138
|
if (o.length === 1) return o[0];
|
|
@@ -1139,96 +1140,96 @@ function ke(e, t, s) {
|
|
|
1139
1140
|
`[nimpress] modules ${s}: several systems configured (${o.join(", ")}), pass --system=<name>`
|
|
1140
1141
|
) : new Error(`[nimpress] modules ${s}: no systems configured`);
|
|
1141
1142
|
}
|
|
1142
|
-
async function
|
|
1143
|
+
async function Ts(e, t, s) {
|
|
1143
1144
|
const n = s[0], o = s.slice(1), r = Object.keys(t.modules.systems);
|
|
1144
1145
|
if (n === "init") {
|
|
1145
|
-
|
|
1146
|
+
Rs(e, t);
|
|
1146
1147
|
return;
|
|
1147
1148
|
}
|
|
1148
1149
|
if (n === "dev") {
|
|
1149
|
-
const i =
|
|
1150
|
+
const i = le(t, o), c = i ? [i] : r;
|
|
1150
1151
|
if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
|
|
1151
|
-
await
|
|
1152
|
+
await dt(e, t, c), await new Promise(() => {
|
|
1152
1153
|
});
|
|
1153
1154
|
}
|
|
1154
1155
|
if (n === "build") {
|
|
1155
|
-
const i =
|
|
1156
|
+
const i = le(t, o), c = i ? [i] : ft(t);
|
|
1156
1157
|
if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
|
|
1157
|
-
await
|
|
1158
|
+
await ht(e, t, c);
|
|
1158
1159
|
return;
|
|
1159
1160
|
}
|
|
1160
1161
|
if (n === "lint") {
|
|
1161
|
-
const i = await
|
|
1162
|
-
|
|
1162
|
+
const i = await mt(e, t, le(t, o));
|
|
1163
|
+
_e("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
|
|
1163
1164
|
return;
|
|
1164
1165
|
}
|
|
1165
1166
|
if (n === "story") {
|
|
1166
|
-
const i =
|
|
1167
|
+
const i = je(t, o, "story"), c = re(o, 0), l = N(o, "framework");
|
|
1167
1168
|
if (c) {
|
|
1168
|
-
const p = await
|
|
1169
|
+
const p = await Le(e, t, i, c, l);
|
|
1169
1170
|
p && console.log(`nimpress modules: story written to ${p}`);
|
|
1170
1171
|
return;
|
|
1171
1172
|
}
|
|
1172
|
-
const a = await
|
|
1173
|
+
const a = await Fs(e, t, i);
|
|
1173
1174
|
console.log(`nimpress modules: ${a} auto stories written for ${i}`);
|
|
1174
1175
|
return;
|
|
1175
1176
|
}
|
|
1176
1177
|
if (n === "import") {
|
|
1177
|
-
const i =
|
|
1178
|
-
await
|
|
1178
|
+
const i = je(t, o, "import"), c = re(o, 0);
|
|
1179
|
+
await _s(e, t, i, {
|
|
1179
1180
|
file: c,
|
|
1180
|
-
name:
|
|
1181
|
-
source:
|
|
1182
|
-
stories:
|
|
1183
|
-
match:
|
|
1181
|
+
name: N(o, "name"),
|
|
1182
|
+
source: N(o, "source"),
|
|
1183
|
+
stories: N(o, "stories"),
|
|
1184
|
+
match: N(o, "match"),
|
|
1184
1185
|
fromStories: o.includes("--from-stories"),
|
|
1185
1186
|
select: o.includes("--select")
|
|
1186
|
-
}),
|
|
1187
|
+
}), De(e);
|
|
1187
1188
|
return;
|
|
1188
1189
|
}
|
|
1189
1190
|
if (n === "update") {
|
|
1190
|
-
const i =
|
|
1191
|
-
console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`),
|
|
1191
|
+
const i = N(o, "component") ?? re(o, 0), c = await qt(e, t, { ref: i, system: le(t, o) });
|
|
1192
|
+
console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), De(e);
|
|
1192
1193
|
return;
|
|
1193
1194
|
}
|
|
1194
1195
|
if (n === "create") {
|
|
1195
|
-
const i =
|
|
1196
|
+
const i = N(o, "component");
|
|
1196
1197
|
if (i) {
|
|
1197
1198
|
if (!M(o, "schema"))
|
|
1198
1199
|
throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
|
|
1199
|
-
const
|
|
1200
|
-
console.log(`nimpress modules: schema upserted at ${
|
|
1200
|
+
const u = await es(e, t, i);
|
|
1201
|
+
console.log(`nimpress modules: schema upserted at ${u}`);
|
|
1201
1202
|
return;
|
|
1202
1203
|
}
|
|
1203
|
-
const c =
|
|
1204
|
+
const c = re(o, 0);
|
|
1204
1205
|
if (!c)
|
|
1205
1206
|
throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
|
|
1206
|
-
const
|
|
1207
|
+
const l = je(t, o, "create"), a = N(o, "framework"), p = await Ds(e, t, l, c, a);
|
|
1207
1208
|
console.log(`nimpress modules: created ${c} at ${D(e, p)}`);
|
|
1208
1209
|
return;
|
|
1209
1210
|
}
|
|
1210
1211
|
throw new Error("[nimpress] modules expects init, dev, build, lint, story, import, create or update");
|
|
1211
1212
|
}
|
|
1212
|
-
function
|
|
1213
|
+
function Rs(e, t) {
|
|
1213
1214
|
const s = d(e, t.modules.dir);
|
|
1214
|
-
|
|
1215
|
+
H(s, { recursive: !0 });
|
|
1215
1216
|
const n = d(e, "nimpress.config.json");
|
|
1216
1217
|
if ($(n)) {
|
|
1217
1218
|
const o = JSON.parse(C(n, "utf-8"));
|
|
1218
|
-
o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} },
|
|
1219
|
+
o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} }, W(n, JSON.stringify(o, null, 2) + `
|
|
1219
1220
|
`), console.log(`nimpress modules: modules block added to ${n}`));
|
|
1220
1221
|
} else
|
|
1221
1222
|
console.log("nimpress modules: add a modules block with systems entries to your nimpress config");
|
|
1222
1223
|
console.log(`nimpress modules: folder ready at ${s}`);
|
|
1223
1224
|
}
|
|
1224
|
-
function
|
|
1225
|
+
function St(e) {
|
|
1225
1226
|
if (!e.startsWith(`---
|
|
1226
1227
|
`)) return null;
|
|
1227
1228
|
const t = e.indexOf(`
|
|
1228
1229
|
---`, 4);
|
|
1229
1230
|
return t < 0 ? null : e.slice(4, t);
|
|
1230
1231
|
}
|
|
1231
|
-
function
|
|
1232
|
+
function As(e) {
|
|
1232
1233
|
for (const t of e.split(`
|
|
1233
1234
|
`)) {
|
|
1234
1235
|
if (!t.startsWith("export:")) continue;
|
|
@@ -1237,8 +1238,8 @@ function Fs(e) {
|
|
|
1237
1238
|
}
|
|
1238
1239
|
return null;
|
|
1239
1240
|
}
|
|
1240
|
-
function
|
|
1241
|
-
const s =
|
|
1241
|
+
function Ps(e, t) {
|
|
1242
|
+
const s = St(e);
|
|
1242
1243
|
if (s === null) return e;
|
|
1243
1244
|
const n = s.split(`
|
|
1244
1245
|
`).filter((r) => !r.startsWith("export:") && !r.startsWith(" file:")), o = n.findIndex((r) => r.startsWith(" package:"));
|
|
@@ -1246,8 +1247,8 @@ function Os(e, t) {
|
|
|
1246
1247
|
${n.join(`
|
|
1247
1248
|
`)}${e.slice(4 + s.length)}`;
|
|
1248
1249
|
}
|
|
1249
|
-
function
|
|
1250
|
-
const n =
|
|
1250
|
+
function Ae(e, t, s) {
|
|
1251
|
+
const n = N(s, "target") ?? "", o = d(e, N(s, "out") ?? t.paths.export), r = d(e, t.contentDir);
|
|
1251
1252
|
let i = "";
|
|
1252
1253
|
try {
|
|
1253
1254
|
i = JSON.parse(C(d(e, "package.json"), "utf-8")).version ?? "";
|
|
@@ -1255,32 +1256,32 @@ function Ne(e, t, s) {
|
|
|
1255
1256
|
i = "";
|
|
1256
1257
|
}
|
|
1257
1258
|
let c = 0;
|
|
1258
|
-
for (const
|
|
1259
|
-
if (!
|
|
1260
|
-
const a = C(
|
|
1259
|
+
for (const l of oe(r)) {
|
|
1260
|
+
if (!l.endsWith(".md")) continue;
|
|
1261
|
+
const a = C(l, "utf-8"), p = St(a);
|
|
1261
1262
|
if (p === null) continue;
|
|
1262
|
-
const
|
|
1263
|
-
if (
|
|
1264
|
-
const m = _(
|
|
1265
|
-
|
|
1266
|
-
for (const h of
|
|
1263
|
+
const u = As(p);
|
|
1264
|
+
if (u === null || n && u !== n && u !== "true") continue;
|
|
1265
|
+
const m = _(l), f = d(o, D(r, m));
|
|
1266
|
+
H(f, { recursive: !0 });
|
|
1267
|
+
for (const h of se(m, { withFileTypes: !0 })) {
|
|
1267
1268
|
if (!h.isFile()) continue;
|
|
1268
1269
|
const g = C(d(m, h.name), "utf-8");
|
|
1269
|
-
|
|
1270
|
+
W(
|
|
1270
1271
|
d(f, h.name),
|
|
1271
|
-
h.name.endsWith(".md") ?
|
|
1272
|
+
h.name.endsWith(".md") ? Ps(g, i) : g
|
|
1272
1273
|
);
|
|
1273
1274
|
}
|
|
1274
1275
|
c++;
|
|
1275
1276
|
}
|
|
1276
1277
|
console.log(`nimpress export: ${c} pages collected into ${o}`);
|
|
1277
1278
|
}
|
|
1278
|
-
const
|
|
1279
|
-
function
|
|
1280
|
-
const e = _(
|
|
1281
|
-
j(e,
|
|
1282
|
-
j(e, "..",
|
|
1283
|
-
j(e, "..", "..",
|
|
1279
|
+
const Ce = d(".claude", "skills", "nimpress", "SKILL.md");
|
|
1280
|
+
function jt() {
|
|
1281
|
+
const e = _(pt(import.meta.url)), t = [
|
|
1282
|
+
j(e, Ce),
|
|
1283
|
+
j(e, "..", Ce),
|
|
1284
|
+
j(e, "..", "..", Ce)
|
|
1284
1285
|
];
|
|
1285
1286
|
for (const s of t)
|
|
1286
1287
|
try {
|
|
@@ -1289,33 +1290,51 @@ function bt() {
|
|
|
1289
1290
|
}
|
|
1290
1291
|
throw new Error(`[nimpress] skill: SKILL.md not found, looked in ${t.join(", ")}`);
|
|
1291
1292
|
}
|
|
1292
|
-
function
|
|
1293
|
-
const s = t ? d(
|
|
1294
|
-
|
|
1293
|
+
function Ct(e, t) {
|
|
1294
|
+
const s = t ? d(K(), ".claude") : d(e, ".claude"), n = d(s, "skills", "nimpress");
|
|
1295
|
+
H(n, { recursive: !0 });
|
|
1295
1296
|
const o = d(n, "SKILL.md");
|
|
1296
|
-
return
|
|
1297
|
+
return W(o, jt()), console.log(`wrote ${o}`), o;
|
|
1297
1298
|
}
|
|
1298
|
-
function
|
|
1299
|
+
function Ms(e, t) {
|
|
1299
1300
|
const s = t[0];
|
|
1300
1301
|
if (s === "get") {
|
|
1301
|
-
process.stdout.write(
|
|
1302
|
+
process.stdout.write(jt());
|
|
1302
1303
|
return;
|
|
1303
1304
|
}
|
|
1304
1305
|
if (s === "put") {
|
|
1305
|
-
|
|
1306
|
+
Ct(e, !M(t, "project"));
|
|
1306
1307
|
return;
|
|
1307
1308
|
}
|
|
1308
1309
|
throw new Error("[nimpress] skill expects get or put");
|
|
1309
1310
|
}
|
|
1310
|
-
const
|
|
1311
|
+
const Is = "nimling/nimpress", Ls = "nimpress@nimpress";
|
|
1312
|
+
function Ve(e, t) {
|
|
1313
|
+
console.log(`claude ${t.join(" ")}`);
|
|
1314
|
+
const s = X("claude", t, { cwd: e, stdio: "inherit" });
|
|
1315
|
+
if (s.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${s.error.message}`);
|
|
1316
|
+
if (s.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${s.status}`);
|
|
1317
|
+
}
|
|
1318
|
+
function zs(e, t) {
|
|
1319
|
+
const s = t ? "user" : "project";
|
|
1320
|
+
Ve(e, ["plugin", "marketplace", "add", Is, "--scope", s]), Ve(e, ["plugin", "install", Ls, "--scope", s]);
|
|
1321
|
+
}
|
|
1322
|
+
function Js(e, t) {
|
|
1323
|
+
if (t[0] === "put") {
|
|
1324
|
+
zs(e, !M(t, "project"));
|
|
1325
|
+
return;
|
|
1326
|
+
}
|
|
1327
|
+
throw new Error("[nimpress] plugin expects put");
|
|
1328
|
+
}
|
|
1329
|
+
const ee = {
|
|
1311
1330
|
name: "--system",
|
|
1312
1331
|
value: !0,
|
|
1313
1332
|
describe: "the configured component system to act on"
|
|
1314
|
-
},
|
|
1333
|
+
}, Ke = {
|
|
1315
1334
|
name: "--framework",
|
|
1316
1335
|
value: !0,
|
|
1317
1336
|
describe: "vue or svelte, overriding the framework of the system"
|
|
1318
|
-
},
|
|
1337
|
+
}, V = [
|
|
1319
1338
|
{
|
|
1320
1339
|
name: "init",
|
|
1321
1340
|
describe: "Write the config, the content folder, and the agent guide",
|
|
@@ -1352,15 +1371,15 @@ const Q = {
|
|
|
1352
1371
|
flags: [],
|
|
1353
1372
|
subs: [
|
|
1354
1373
|
{ name: "init", describe: "Create the modules folder and the config block", flags: [], subs: [] },
|
|
1355
|
-
{ name: "dev", describe: "Serve the harnesses and stay running", flags: [
|
|
1356
|
-
{ name: "build", describe: "Build the harness bundles", flags: [
|
|
1357
|
-
{ name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [
|
|
1358
|
-
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [
|
|
1374
|
+
{ name: "dev", describe: "Serve the harnesses and stay running", flags: [ee], subs: [] },
|
|
1375
|
+
{ name: "build", describe: "Build the harness bundles", flags: [ee], subs: [] },
|
|
1376
|
+
{ name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [ee], subs: [] },
|
|
1377
|
+
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [ee, Ke], subs: [] },
|
|
1359
1378
|
{
|
|
1360
1379
|
name: "import",
|
|
1361
1380
|
describe: "Import components and storybook stories into component pages",
|
|
1362
1381
|
flags: [
|
|
1363
|
-
|
|
1382
|
+
ee,
|
|
1364
1383
|
{ name: "--name", value: !0, describe: "the component name when a single file is imported" },
|
|
1365
1384
|
{ name: "--source", value: !0, describe: "the component source root, overriding the system source" },
|
|
1366
1385
|
{ name: "--stories", value: !0, describe: "an extra folder of storybook csf files" },
|
|
@@ -1374,8 +1393,8 @@ const Q = {
|
|
|
1374
1393
|
name: "create",
|
|
1375
1394
|
describe: "Create a component page, or upsert one schema",
|
|
1376
1395
|
flags: [
|
|
1377
|
-
|
|
1378
|
-
|
|
1396
|
+
ee,
|
|
1397
|
+
Ke,
|
|
1379
1398
|
{ name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
|
|
1380
1399
|
{ name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
|
|
1381
1400
|
],
|
|
@@ -1384,7 +1403,7 @@ const Q = {
|
|
|
1384
1403
|
{
|
|
1385
1404
|
name: "update",
|
|
1386
1405
|
describe: "Upsert the component schemas from the component types",
|
|
1387
|
-
flags: [
|
|
1406
|
+
flags: [ee, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
|
|
1388
1407
|
subs: []
|
|
1389
1408
|
}
|
|
1390
1409
|
]
|
|
@@ -1466,6 +1485,25 @@ const Q = {
|
|
|
1466
1485
|
}
|
|
1467
1486
|
]
|
|
1468
1487
|
},
|
|
1488
|
+
{
|
|
1489
|
+
name: "plugin",
|
|
1490
|
+
describe: "The claude plugin that carries the skill and the nimpress mcp server",
|
|
1491
|
+
flags: [],
|
|
1492
|
+
subs: [
|
|
1493
|
+
{
|
|
1494
|
+
name: "put",
|
|
1495
|
+
describe: "Add the nimpress marketplace and install the plugin for the user, or for the current project with --project",
|
|
1496
|
+
flags: [{ name: "--project", value: !1, describe: "install into the project settings of the current directory instead of the user settings" }],
|
|
1497
|
+
subs: []
|
|
1498
|
+
}
|
|
1499
|
+
]
|
|
1500
|
+
},
|
|
1501
|
+
{
|
|
1502
|
+
name: "mcp",
|
|
1503
|
+
describe: "Serve every command as a tool over the model context protocol on stdio",
|
|
1504
|
+
flags: [],
|
|
1505
|
+
subs: []
|
|
1506
|
+
},
|
|
1469
1507
|
{
|
|
1470
1508
|
name: "completion",
|
|
1471
1509
|
describe: "Print the shell completion script, or wire it up with --auto",
|
|
@@ -1480,55 +1518,55 @@ const Q = {
|
|
|
1480
1518
|
{ name: "powershell", describe: "the powershell completion script", flags: [], subs: [] }
|
|
1481
1519
|
]
|
|
1482
1520
|
}
|
|
1483
|
-
],
|
|
1484
|
-
function
|
|
1521
|
+
], Et = ["bash", "zsh", "fish", "powershell"];
|
|
1522
|
+
function ke(e) {
|
|
1485
1523
|
const t = [];
|
|
1486
1524
|
for (const s of [...e.flags, ...e.subs.flatMap((n) => n.flags)])
|
|
1487
1525
|
t.some((n) => n.name === s.name) || t.push(s);
|
|
1488
1526
|
return t;
|
|
1489
1527
|
}
|
|
1490
|
-
function
|
|
1528
|
+
function xe(e, t) {
|
|
1491
1529
|
return t && e.value ? `${e.name}=` : e.name;
|
|
1492
1530
|
}
|
|
1493
|
-
function
|
|
1531
|
+
function Bs() {
|
|
1494
1532
|
const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
|
|
1495
|
-
e.push(` local words="${
|
|
1496
|
-
for (const t of
|
|
1497
|
-
const s = [...t.subs.map((n) => n.name), ...
|
|
1533
|
+
e.push(` local words="${V.map((t) => t.name).join(" ")}"`), e.push(' if [ "$COMP_CWORD" -gt 1 ]; then'), e.push(' case "${COMP_WORDS[1]}" in');
|
|
1534
|
+
for (const t of V) {
|
|
1535
|
+
const s = [...t.subs.map((n) => n.name), ...ke(t).map((n) => xe(n, !1))];
|
|
1498
1536
|
e.push(` ${t.name}) words="${s.join(" ")}" ;;`);
|
|
1499
1537
|
}
|
|
1500
1538
|
return e.push(' *) words="" ;;'), e.push(" esac"), e.push(" fi"), e.push(' COMPREPLY=( $(compgen -W "$words" -- "$cur") )'), e.push("}"), e.push("complete -o default -F _nimpress nimpress"), e.join(`
|
|
1501
1539
|
`) + `
|
|
1502
1540
|
`;
|
|
1503
1541
|
}
|
|
1504
|
-
function
|
|
1542
|
+
function Ee(e, t, s) {
|
|
1505
1543
|
const n = [`${e}entries=(`];
|
|
1506
1544
|
for (const o of s) n.push(`${e} ${o}`);
|
|
1507
1545
|
return n.push(`${e})`), n.push(`${e}_describe '${t}' entries`), n.push(`${e}return`), n;
|
|
1508
1546
|
}
|
|
1509
|
-
function
|
|
1547
|
+
function Gs() {
|
|
1510
1548
|
const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
|
|
1511
1549
|
e.push(
|
|
1512
|
-
...
|
|
1550
|
+
...Ee(
|
|
1513
1551
|
" ",
|
|
1514
1552
|
"nimpress command",
|
|
1515
|
-
|
|
1553
|
+
V.map((t) => `'${t.name}:${t.describe}'`)
|
|
1516
1554
|
)
|
|
1517
1555
|
), e.push(" fi"), e.push(' case "$words[2]" in');
|
|
1518
|
-
for (const t of
|
|
1556
|
+
for (const t of V) {
|
|
1519
1557
|
e.push(` ${t.name})`), t.subs.length && (e.push(" if (( CURRENT == 3 )); then"), e.push(
|
|
1520
|
-
...
|
|
1558
|
+
...Ee(
|
|
1521
1559
|
" ",
|
|
1522
1560
|
`${t.name} argument`,
|
|
1523
1561
|
t.subs.map((n) => `'${n.name}:${n.describe}'`)
|
|
1524
1562
|
)
|
|
1525
1563
|
), e.push(" fi"));
|
|
1526
|
-
const s =
|
|
1564
|
+
const s = ke(t);
|
|
1527
1565
|
s.length ? e.push(
|
|
1528
|
-
...
|
|
1566
|
+
...Ee(
|
|
1529
1567
|
" ",
|
|
1530
1568
|
"nimpress flag",
|
|
1531
|
-
s.map((n) => `'${
|
|
1569
|
+
s.map((n) => `'${xe(n, !0)}:${n.describe}'`)
|
|
1532
1570
|
)
|
|
1533
1571
|
) : e.push(" return"), e.push(" ;;");
|
|
1534
1572
|
}
|
|
@@ -1536,58 +1574,58 @@ function _s() {
|
|
|
1536
1574
|
`) + `
|
|
1537
1575
|
`;
|
|
1538
1576
|
}
|
|
1539
|
-
function
|
|
1577
|
+
function Hs() {
|
|
1540
1578
|
const e = ["complete -c nimpress -f"];
|
|
1541
|
-
for (const t of
|
|
1579
|
+
for (const t of V)
|
|
1542
1580
|
e.push(
|
|
1543
1581
|
`complete -c nimpress -n '__fish_use_subcommand' -a '${t.name}' -d '${t.describe}'`
|
|
1544
1582
|
);
|
|
1545
|
-
for (const t of
|
|
1583
|
+
for (const t of V) {
|
|
1546
1584
|
const s = `__fish_seen_subcommand_from ${t.name}`;
|
|
1547
1585
|
for (const n of t.subs)
|
|
1548
1586
|
e.push(`complete -c nimpress -n '${s}' -a '${n.name}' -d '${n.describe}'`);
|
|
1549
|
-
for (const n of
|
|
1587
|
+
for (const n of ke(t))
|
|
1550
1588
|
e.push(
|
|
1551
|
-
`complete -c nimpress -n '${s}' -a '${
|
|
1589
|
+
`complete -c nimpress -n '${s}' -a '${xe(n, !0)}' -d '${n.describe}'`
|
|
1552
1590
|
);
|
|
1553
1591
|
}
|
|
1554
1592
|
return e.join(`
|
|
1555
1593
|
`) + `
|
|
1556
1594
|
`;
|
|
1557
1595
|
}
|
|
1558
|
-
function
|
|
1596
|
+
function Us() {
|
|
1559
1597
|
const e = [
|
|
1560
1598
|
"Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
|
|
1561
1599
|
" param($wordToComplete, $commandAst, $cursorPosition)",
|
|
1562
1600
|
" $words = @($commandAst.CommandElements | ForEach-Object { $_.ToString() })",
|
|
1563
1601
|
" $candidates = @()",
|
|
1564
1602
|
" if ($words.Count -le 2) {",
|
|
1565
|
-
` $candidates = @(${
|
|
1603
|
+
` $candidates = @(${V.map((t) => `'${t.name}'`).join(", ")})`,
|
|
1566
1604
|
" } else {",
|
|
1567
1605
|
" switch ($words[1]) {"
|
|
1568
1606
|
];
|
|
1569
|
-
for (const t of
|
|
1570
|
-
const s = [...t.subs.map((n) => n.name), ...
|
|
1607
|
+
for (const t of V) {
|
|
1608
|
+
const s = [...t.subs.map((n) => n.name), ...ke(t).map((n) => xe(n, !0))];
|
|
1571
1609
|
e.push(` '${t.name}' { $candidates = @(${s.map((n) => `'${n}'`).join(", ")}) }`);
|
|
1572
1610
|
}
|
|
1573
1611
|
return e.push(" }"), e.push(" }"), e.push(' $candidates | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {'), e.push(" [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)"), e.push(" }"), e.push("}"), e.join(`
|
|
1574
1612
|
`) + `
|
|
1575
1613
|
`;
|
|
1576
1614
|
}
|
|
1577
|
-
function
|
|
1578
|
-
if (e === "bash") return
|
|
1579
|
-
if (e === "zsh") return
|
|
1580
|
-
if (e === "fish") return
|
|
1581
|
-
if (e === "powershell") return
|
|
1582
|
-
throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${
|
|
1583
|
-
}
|
|
1584
|
-
function
|
|
1585
|
-
const e =
|
|
1615
|
+
function Ot(e) {
|
|
1616
|
+
if (e === "bash") return Bs();
|
|
1617
|
+
if (e === "zsh") return Gs();
|
|
1618
|
+
if (e === "fish") return Hs();
|
|
1619
|
+
if (e === "powershell") return Us();
|
|
1620
|
+
throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Et.join(", ")}`);
|
|
1621
|
+
}
|
|
1622
|
+
function Zs() {
|
|
1623
|
+
const e = F(process.env.SHELL ?? "");
|
|
1586
1624
|
for (const t of ["zsh", "bash", "fish"])
|
|
1587
1625
|
if (e.includes(t)) return t;
|
|
1588
1626
|
return "";
|
|
1589
1627
|
}
|
|
1590
|
-
function
|
|
1628
|
+
function Vs(e, t) {
|
|
1591
1629
|
const s = "# >>> nimpress completion >>>", n = "# <<< nimpress completion <<<", o = `${s}
|
|
1592
1630
|
${t}
|
|
1593
1631
|
${n}`, r = e.indexOf(s), i = e.indexOf(n);
|
|
@@ -1598,475 +1636,638 @@ ${n}`, r = e.indexOf(s), i = e.indexOf(n);
|
|
|
1598
1636
|
`) + o + `
|
|
1599
1637
|
`;
|
|
1600
1638
|
}
|
|
1601
|
-
function
|
|
1639
|
+
function Ks(e, t) {
|
|
1602
1640
|
let s = "";
|
|
1603
1641
|
try {
|
|
1604
1642
|
s = C(e, "utf-8");
|
|
1605
1643
|
} catch {
|
|
1606
1644
|
s = "";
|
|
1607
1645
|
}
|
|
1608
|
-
|
|
1646
|
+
W(e, Vs(s, t));
|
|
1609
1647
|
}
|
|
1610
|
-
function
|
|
1611
|
-
const t = e ||
|
|
1648
|
+
function Ys(e) {
|
|
1649
|
+
const t = e || Zs();
|
|
1612
1650
|
if (!t)
|
|
1613
1651
|
throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
|
|
1614
|
-
const s =
|
|
1652
|
+
const s = Ot(t), n = K();
|
|
1615
1653
|
if (t === "fish") {
|
|
1616
|
-
const
|
|
1617
|
-
|
|
1618
|
-
const a = d(
|
|
1619
|
-
|
|
1654
|
+
const l = d(n, ".config", "fish", "completions");
|
|
1655
|
+
H(l, { recursive: !0 });
|
|
1656
|
+
const a = d(l, "nimpress.fish");
|
|
1657
|
+
W(a, s), console.log(`wrote ${a}`), console.log("fish loads it on the next shell");
|
|
1620
1658
|
return;
|
|
1621
1659
|
}
|
|
1622
1660
|
if (t !== "bash" && t !== "zsh")
|
|
1623
1661
|
throw new Error(`[nimpress] completion: auto install covers bash, zsh, and fish, for ${t} run: nimpress completion ${t}`);
|
|
1624
1662
|
const o = d(n, ".config", "nimpress", "completions");
|
|
1625
|
-
|
|
1663
|
+
H(o, { recursive: !0 });
|
|
1626
1664
|
const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
|
|
1627
|
-
|
|
1665
|
+
W(r, s), console.log(`wrote ${r}`);
|
|
1628
1666
|
const i = d(n, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
|
|
1629
1667
|
autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`;
|
|
1630
|
-
|
|
1668
|
+
Ks(i, c), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
|
|
1631
1669
|
}
|
|
1632
|
-
function
|
|
1633
|
-
const s =
|
|
1670
|
+
function Qs(e, t) {
|
|
1671
|
+
const s = re(t, 0) ?? "", n = M(t, "auto"), o = M(t, "skill");
|
|
1634
1672
|
if (!n) {
|
|
1635
1673
|
if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
|
|
1636
|
-
if (!s) throw new Error(`[nimpress] completion: name a shell (${
|
|
1637
|
-
process.stdout.write(
|
|
1674
|
+
if (!s) throw new Error(`[nimpress] completion: name a shell (${Et.join(", ")}) or pass --auto`);
|
|
1675
|
+
process.stdout.write(Ot(s));
|
|
1638
1676
|
return;
|
|
1639
1677
|
}
|
|
1640
|
-
|
|
1678
|
+
Ys(s), o && Ct(e, !0);
|
|
1679
|
+
}
|
|
1680
|
+
const Xs = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), qs = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), en = 2e4, de = /* @__PURE__ */ new Map();
|
|
1681
|
+
function Ft(e, t) {
|
|
1682
|
+
const s = [...t, e.name];
|
|
1683
|
+
return e.subs.length ? e.subs.flatMap((n) => Ft(n, s)) : [
|
|
1684
|
+
{
|
|
1685
|
+
name: s.join("_"),
|
|
1686
|
+
argv: s,
|
|
1687
|
+
describe: e.describe,
|
|
1688
|
+
flags: e.flags,
|
|
1689
|
+
serves: qs.has(s.join(" "))
|
|
1690
|
+
}
|
|
1691
|
+
];
|
|
1692
|
+
}
|
|
1693
|
+
const Dt = V.filter((e) => !Xs.has(e.name)).flatMap((e) => Ft(e, []));
|
|
1694
|
+
function tn() {
|
|
1695
|
+
const e = _(pt(import.meta.url));
|
|
1696
|
+
for (const t of [j(e, "..", "package.json"), j(e, "..", "..", "package.json")])
|
|
1697
|
+
try {
|
|
1698
|
+
return JSON.parse(C(t, "utf-8")).version;
|
|
1699
|
+
} catch {
|
|
1700
|
+
}
|
|
1701
|
+
return "0.0.0";
|
|
1702
|
+
}
|
|
1703
|
+
function sn(e) {
|
|
1704
|
+
const t = {};
|
|
1705
|
+
for (const s of e.flags)
|
|
1706
|
+
t[s.name.slice(2)] = { type: s.value ? "string" : "boolean", description: s.describe };
|
|
1707
|
+
return {
|
|
1708
|
+
type: "object",
|
|
1709
|
+
properties: {
|
|
1710
|
+
cwd: { type: "string", description: "the site root the command runs in, relative to the project root, the project root by default" },
|
|
1711
|
+
args: { type: "array", items: { type: "string" }, description: "positional arguments, such as a component name or a file" },
|
|
1712
|
+
flags: { type: "object", properties: t, additionalProperties: !1 }
|
|
1713
|
+
},
|
|
1714
|
+
additionalProperties: !1
|
|
1715
|
+
};
|
|
1716
|
+
}
|
|
1717
|
+
function nn() {
|
|
1718
|
+
return [
|
|
1719
|
+
...Dt.map((e) => ({
|
|
1720
|
+
name: e.name,
|
|
1721
|
+
description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
|
|
1722
|
+
inputSchema: sn(e)
|
|
1723
|
+
})),
|
|
1724
|
+
{
|
|
1725
|
+
name: "stop",
|
|
1726
|
+
description: "Stop a server a dev, view, or modules dev tool started, by its pid",
|
|
1727
|
+
inputSchema: {
|
|
1728
|
+
type: "object",
|
|
1729
|
+
properties: { pid: { type: "number", description: "the pid the serving tool returned" } },
|
|
1730
|
+
required: ["pid"],
|
|
1731
|
+
additionalProperties: !1
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
];
|
|
1735
|
+
}
|
|
1736
|
+
function on(e, t) {
|
|
1737
|
+
const s = [...e.argv, ...t.args ?? []];
|
|
1738
|
+
for (const [n, o] of Object.entries(t.flags ?? {}))
|
|
1739
|
+
o === !0 ? s.push(`--${n}`) : typeof o == "string" && s.push(`--${n}=${o}`);
|
|
1740
|
+
return s;
|
|
1741
|
+
}
|
|
1742
|
+
function G(e, t = !1) {
|
|
1743
|
+
return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
|
|
1744
|
+
}
|
|
1745
|
+
function Nt(e, t, s) {
|
|
1746
|
+
return Ie(process.execPath, [process.argv[1], ...on(t, s)], {
|
|
1747
|
+
cwd: j(e, s.cwd ?? "."),
|
|
1748
|
+
env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
|
|
1749
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
1750
|
+
});
|
|
1751
|
+
}
|
|
1752
|
+
function rn(e, t, s) {
|
|
1753
|
+
const n = Nt(e, t, s);
|
|
1754
|
+
let o = "";
|
|
1755
|
+
return n.stdout?.on("data", (r) => o += r), n.stderr?.on("data", (r) => o += r), new Promise((r) => {
|
|
1756
|
+
n.on("error", (i) => r(G(`${o}${i.message}`, !0))), n.on("close", (i) => r(G(o, i !== 0)));
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
function an(e, t, s) {
|
|
1760
|
+
const n = Nt(e, t, s);
|
|
1761
|
+
let o = "";
|
|
1762
|
+
return new Promise((r) => {
|
|
1763
|
+
const i = (a) => {
|
|
1764
|
+
clearTimeout(l), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
|
|
1765
|
+
}, c = (a) => {
|
|
1766
|
+
o += a, /https?:\/\/\S+/.test(o) && i(G(`pid ${n.pid}
|
|
1767
|
+
${o}`));
|
|
1768
|
+
}, l = setTimeout(() => i(G(`pid ${n.pid}
|
|
1769
|
+
${o}`)), en);
|
|
1770
|
+
n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(G(`${o}${a.message}`, !0))), n.on("exit", (a) => {
|
|
1771
|
+
de.delete(n.pid ?? -1), i(G(o, a !== 0));
|
|
1772
|
+
}), n.pid && de.set(n.pid, n);
|
|
1773
|
+
});
|
|
1774
|
+
}
|
|
1775
|
+
function cn(e) {
|
|
1776
|
+
const t = de.get(e);
|
|
1777
|
+
return t ? (t.kill("SIGTERM"), de.delete(e), G(`stopped ${e}`)) : G(`no server with pid ${e} was started by this session`, !0);
|
|
1778
|
+
}
|
|
1779
|
+
async function ln(e, t) {
|
|
1780
|
+
const s = String(t.name ?? ""), n = t.arguments ?? {};
|
|
1781
|
+
if (s === "stop") return cn(Number(n.pid));
|
|
1782
|
+
const o = Dt.find((r) => r.name === s);
|
|
1783
|
+
return o ? $(j(e, n.cwd ?? ".")) ? o.serves ? an(e, o, n) : rn(e, o, n) : G(`no folder ${n.cwd} under ${e}`, !0) : G(`unknown tool ${s}`, !0);
|
|
1784
|
+
}
|
|
1785
|
+
function te(e, t) {
|
|
1786
|
+
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
|
|
1787
|
+
`);
|
|
1788
|
+
}
|
|
1789
|
+
async function un(e, t) {
|
|
1790
|
+
if (t.id !== void 0) {
|
|
1791
|
+
if (t.method === "initialize") {
|
|
1792
|
+
te(t.id, {
|
|
1793
|
+
result: {
|
|
1794
|
+
protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
|
|
1795
|
+
capabilities: { tools: {} },
|
|
1796
|
+
serverInfo: { name: "nimpress", version: tn() }
|
|
1797
|
+
}
|
|
1798
|
+
});
|
|
1799
|
+
return;
|
|
1800
|
+
}
|
|
1801
|
+
if (t.method === "ping") {
|
|
1802
|
+
te(t.id, { result: {} });
|
|
1803
|
+
return;
|
|
1804
|
+
}
|
|
1805
|
+
if (t.method === "tools/list") {
|
|
1806
|
+
te(t.id, { result: { tools: nn() } });
|
|
1807
|
+
return;
|
|
1808
|
+
}
|
|
1809
|
+
if (t.method === "tools/call") {
|
|
1810
|
+
te(t.id, { result: await ln(e, t.params ?? {}) });
|
|
1811
|
+
return;
|
|
1812
|
+
}
|
|
1813
|
+
te(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
|
|
1814
|
+
}
|
|
1815
|
+
}
|
|
1816
|
+
function pn(e) {
|
|
1817
|
+
const t = is({ input: process.stdin }), s = /* @__PURE__ */ new Set();
|
|
1818
|
+
t.on("line", (n) => {
|
|
1819
|
+
if (!n.trim()) return;
|
|
1820
|
+
let o;
|
|
1821
|
+
try {
|
|
1822
|
+
o = JSON.parse(n);
|
|
1823
|
+
} catch {
|
|
1824
|
+
te(null, { error: { code: -32700, message: "parse error" } });
|
|
1825
|
+
return;
|
|
1826
|
+
}
|
|
1827
|
+
const r = un(e, o).catch((i) => te(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
|
|
1828
|
+
s.add(r);
|
|
1829
|
+
}), t.on("close", async () => {
|
|
1830
|
+
await Promise.all(s);
|
|
1831
|
+
for (const n of de.values()) n.kill("SIGTERM");
|
|
1832
|
+
process.exit(0);
|
|
1833
|
+
});
|
|
1641
1834
|
}
|
|
1642
|
-
function
|
|
1835
|
+
function mn(e, t, s) {
|
|
1643
1836
|
if (typeof s.path == "string") return s.path.startsWith("/") ? s.path : `/${s.path}`;
|
|
1644
1837
|
const n = D(e, t).split(I).join("/").replace(/\.md$/, "");
|
|
1645
1838
|
return n === "index" ? "/" : `/${n.replace(/\/index$/, "")}`;
|
|
1646
1839
|
}
|
|
1647
|
-
function
|
|
1840
|
+
function Ye(e) {
|
|
1648
1841
|
return e ? (Array.isArray(e) ? e : String(e).split(",")).map((s) => String(s).trim()).filter(Boolean) : [];
|
|
1649
1842
|
}
|
|
1650
|
-
function
|
|
1843
|
+
function fn(e) {
|
|
1651
1844
|
return e.split(`
|
|
1652
1845
|
`).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
|
|
1653
1846
|
}
|
|
1654
|
-
function
|
|
1655
|
-
const s = j(e, t.contentDir), o =
|
|
1656
|
-
const { data: p, content:
|
|
1657
|
-
return { file: a, data: p, content:
|
|
1847
|
+
function dn(e, t) {
|
|
1848
|
+
const s = j(e, t.contentDir), o = oe(s).filter((a) => a.endsWith(".md")).map((a) => {
|
|
1849
|
+
const { data: p, content: u } = fe(C(a, "utf-8"));
|
|
1850
|
+
return { file: a, data: p, content: u };
|
|
1658
1851
|
}).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
|
|
1659
1852
|
slug: a.file,
|
|
1660
1853
|
title: String(a.data.title),
|
|
1661
|
-
headings:
|
|
1662
|
-
tags:
|
|
1854
|
+
headings: fn(a.content),
|
|
1855
|
+
tags: Ye(a.data.tags),
|
|
1663
1856
|
body: a.content
|
|
1664
|
-
})), i =
|
|
1857
|
+
})), i = ts(r), c = t.site?.url?.replace(/\/$/, "") ?? "", l = t.base.replace(/\/$/, "");
|
|
1665
1858
|
return o.map((a) => {
|
|
1666
|
-
const p = i.get(a.file) ?? { keywords: [], description: "" },
|
|
1859
|
+
const p = i.get(a.file) ?? { keywords: [], description: "" }, u = a.data.meta ?? {}, m = Array.isArray(u.keywords) ? u.keywords : typeof u.keywords == "string" ? [u.keywords] : void 0, f = typeof u.description == "string" ? u.description : typeof a.data.description == "string" ? a.data.description : void 0, h = u.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : p.keywords.length ? p.keywords : m ?? [] : m ?? Ye(a.data.tags), v = g ? h && f ? f : p.description || f || "" : f ?? "", O = mn(s, a.file, a.data);
|
|
1667
1860
|
return {
|
|
1668
|
-
path:
|
|
1861
|
+
path: O,
|
|
1669
1862
|
file: D(e, a.file).split(I).join("/"),
|
|
1670
1863
|
title: String(a.data.title),
|
|
1671
1864
|
keywords: w,
|
|
1672
1865
|
description: v,
|
|
1673
|
-
robots:
|
|
1674
|
-
canonical: typeof
|
|
1866
|
+
robots: ss(typeof u.robots == "string" ? u.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof u.ai == "boolean" ? u.ai : void 0),
|
|
1867
|
+
canonical: typeof u.canonical == "string" ? u.canonical : c ? `${c}${l}${O === "/" ? "/" : O}` : "",
|
|
1675
1868
|
generated: p,
|
|
1676
|
-
authored: { keywords: m, description: f, override: h, ai: typeof
|
|
1869
|
+
authored: { keywords: m, description: f, override: h, ai: typeof u.ai == "boolean" ? u.ai : void 0 }
|
|
1677
1870
|
};
|
|
1678
1871
|
});
|
|
1679
1872
|
}
|
|
1680
|
-
function
|
|
1873
|
+
function hn(e, t) {
|
|
1681
1874
|
let s = 0;
|
|
1682
1875
|
for (const n of t) {
|
|
1683
|
-
const o = j(e, n.file), { data: r, content: i } =
|
|
1684
|
-
let
|
|
1685
|
-
c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords,
|
|
1876
|
+
const o = j(e, n.file), { data: r, content: i } = fe(C(o, "utf-8")), c = { ...r.meta ?? {} };
|
|
1877
|
+
let l = !1;
|
|
1878
|
+
c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, l = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, l = !0), l && (W(o, fe.stringify(i, { ...r, meta: c })), s += 1);
|
|
1686
1879
|
}
|
|
1687
1880
|
return s;
|
|
1688
1881
|
}
|
|
1689
|
-
function
|
|
1690
|
-
const n =
|
|
1882
|
+
function gn(e, t, s) {
|
|
1883
|
+
const n = dn(e, t), o = N(s, "out") ?? "seo.map.json";
|
|
1691
1884
|
for (const r of n) {
|
|
1692
1885
|
const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
|
|
1693
1886
|
console.log(`${r.path.padEnd(40)} ${String(r.keywords.length).padStart(2)} keywords ${String(r.description.length).padStart(3)} chars ${r.robots.includes("noai") ? "noai" : "ai ok"} ${i}`);
|
|
1694
1887
|
}
|
|
1695
|
-
if (
|
|
1888
|
+
if (W(j(e, o), JSON.stringify(n, null, 2) + `
|
|
1696
1889
|
`), console.log(`nimpress seo: ${n.length} pages, map written to ${o}`), s.includes("--write")) {
|
|
1697
|
-
const r =
|
|
1890
|
+
const r = hn(e, n);
|
|
1698
1891
|
console.log(`nimpress seo: generated fields written into ${r} pages`);
|
|
1699
1892
|
}
|
|
1700
1893
|
}
|
|
1701
|
-
function
|
|
1894
|
+
function _t(e = K()) {
|
|
1702
1895
|
return d(e, ".nimpress", "config.json");
|
|
1703
1896
|
}
|
|
1704
|
-
function
|
|
1897
|
+
function Wt(e = K()) {
|
|
1705
1898
|
return d(e, ".tide", "nimpress", "sites");
|
|
1706
1899
|
}
|
|
1707
|
-
function
|
|
1708
|
-
const t =
|
|
1900
|
+
function Tt(e = K()) {
|
|
1901
|
+
const t = _t(e);
|
|
1709
1902
|
return $(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
|
|
1710
1903
|
}
|
|
1711
|
-
function
|
|
1712
|
-
const s =
|
|
1713
|
-
|
|
1904
|
+
function Rt(e, t = K()) {
|
|
1905
|
+
const s = _t(t);
|
|
1906
|
+
H(_(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
|
|
1714
1907
|
`);
|
|
1715
1908
|
}
|
|
1716
|
-
function
|
|
1909
|
+
function ve(e) {
|
|
1717
1910
|
const t = e.trim().replace(/\.git$/, "").replace(/\/+$/, ""), s = t.match(/[:/]([^/:]+)\/([^/]+)$/);
|
|
1718
1911
|
if (s && t.includes("github.com")) return `${s[1]}/${s[2]}`;
|
|
1719
1912
|
const n = t.match(/^([^/\s]+)\/([^/\s]+)$/);
|
|
1720
1913
|
if (n) return `${n[1]}/${n[2]}`;
|
|
1721
1914
|
throw new Error(`[nimpress] view: cannot read owner/repo from ${e}`);
|
|
1722
1915
|
}
|
|
1723
|
-
function
|
|
1916
|
+
function Oe(e) {
|
|
1724
1917
|
const t = e.trim();
|
|
1725
|
-
return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${
|
|
1918
|
+
return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ve(t)}.git`;
|
|
1726
1919
|
}
|
|
1727
|
-
function
|
|
1920
|
+
function At(e) {
|
|
1728
1921
|
const t = d(e, ".github", "workflows");
|
|
1729
|
-
return $(t) ?
|
|
1922
|
+
return $(t) ? se(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
|
|
1730
1923
|
}
|
|
1731
|
-
function
|
|
1924
|
+
function Pt(e) {
|
|
1732
1925
|
try {
|
|
1733
|
-
const t =
|
|
1926
|
+
const t = as(C(e, "utf-8"));
|
|
1734
1927
|
return typeof t == "object" && t !== null ? t : null;
|
|
1735
1928
|
} catch {
|
|
1736
1929
|
return null;
|
|
1737
1930
|
}
|
|
1738
1931
|
}
|
|
1739
|
-
function
|
|
1932
|
+
function ae(e, t) {
|
|
1740
1933
|
return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (n, o) => {
|
|
1741
1934
|
for (const r of t)
|
|
1742
1935
|
if (r && r[o] !== void 0) return String(r[o]);
|
|
1743
1936
|
return "";
|
|
1744
1937
|
}).trim();
|
|
1745
1938
|
}
|
|
1746
|
-
function
|
|
1939
|
+
function Mt(e, t) {
|
|
1747
1940
|
const s = [];
|
|
1748
1941
|
for (const n of Object.values(e.jobs ?? {}))
|
|
1749
1942
|
for (const o of n.steps ?? [])
|
|
1750
1943
|
typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && s.push({ step: o, scopes: [o.env, n.env, e.env] });
|
|
1751
1944
|
return s;
|
|
1752
1945
|
}
|
|
1753
|
-
function
|
|
1946
|
+
function wn(e) {
|
|
1754
1947
|
const t = /* @__PURE__ */ new Map();
|
|
1755
|
-
for (const s of
|
|
1756
|
-
const n =
|
|
1948
|
+
for (const s of At(e)) {
|
|
1949
|
+
const n = Pt(s);
|
|
1757
1950
|
if (n)
|
|
1758
|
-
for (const { step: o, scopes: r } of
|
|
1759
|
-
const i =
|
|
1951
|
+
for (const { step: o, scopes: r } of Mt(n, "docs-notify")) {
|
|
1952
|
+
const i = ae(o.with?.["docs-repo"], r);
|
|
1760
1953
|
if (!i) continue;
|
|
1761
|
-
const c =
|
|
1954
|
+
const c = ae(o.with?.["export-dir"], r) || ".nimpress";
|
|
1762
1955
|
t.set(i, { repo: i, exportDir: c });
|
|
1763
1956
|
}
|
|
1764
1957
|
}
|
|
1765
1958
|
return [...t.values()];
|
|
1766
1959
|
}
|
|
1767
|
-
function
|
|
1960
|
+
function Qe(e) {
|
|
1768
1961
|
return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
|
|
1769
1962
|
}
|
|
1770
|
-
function
|
|
1963
|
+
function $n(e, t) {
|
|
1771
1964
|
const s = {
|
|
1772
1965
|
contentRoot: t,
|
|
1773
1966
|
mapping: $(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
|
|
1774
1967
|
defaults: {}
|
|
1775
1968
|
};
|
|
1776
|
-
for (const n of
|
|
1777
|
-
const o =
|
|
1969
|
+
for (const n of At(e)) {
|
|
1970
|
+
const o = Pt(n);
|
|
1778
1971
|
if (o)
|
|
1779
|
-
for (const { step: r, scopes: i } of
|
|
1780
|
-
const c =
|
|
1781
|
-
const f =
|
|
1972
|
+
for (const { step: r, scopes: i } of Mt(o, "docs-sync")) {
|
|
1973
|
+
const c = Qe(ae(r.with?.["docs-dir"], i)), l = (m) => {
|
|
1974
|
+
const f = Qe(m);
|
|
1782
1975
|
return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
|
|
1783
|
-
}, a =
|
|
1784
|
-
a && (s.contentRoot =
|
|
1785
|
-
const p =
|
|
1786
|
-
p && (s.mapping =
|
|
1787
|
-
const
|
|
1788
|
-
return
|
|
1976
|
+
}, a = ae(r.with?.["content-root"], i);
|
|
1977
|
+
a && (s.contentRoot = l(a));
|
|
1978
|
+
const p = ae(r.with?.mapping, i);
|
|
1979
|
+
p && (s.mapping = l(p));
|
|
1980
|
+
const u = ae(r.with?.defaults, i);
|
|
1981
|
+
return u && (s.defaults = JSON.parse(u)), s;
|
|
1789
1982
|
}
|
|
1790
1983
|
}
|
|
1791
1984
|
return s;
|
|
1792
1985
|
}
|
|
1793
|
-
function
|
|
1986
|
+
function yn(e, t) {
|
|
1794
1987
|
const s = { ...e };
|
|
1795
1988
|
return t.target && (s.target = t.target), t.targets?.length && (s.targets = t.targets), t.mode && (s.mode = t.mode), s;
|
|
1796
1989
|
}
|
|
1797
|
-
function
|
|
1990
|
+
function bn(e) {
|
|
1798
1991
|
const t = e.mode || "mirror";
|
|
1799
1992
|
return e.targets?.length ? e.targets.map((s) => ({ from: s.from ?? "", to: s.to, mode: s.mode || t })) : e.target ? [{ from: "", to: e.target, mode: t }] : [];
|
|
1800
1993
|
}
|
|
1801
|
-
function
|
|
1994
|
+
function vn(e, t, s) {
|
|
1802
1995
|
let n = t.defaults;
|
|
1803
1996
|
const o = t.mapping ? d(e, t.mapping) : "";
|
|
1804
1997
|
if (o && $(o)) {
|
|
1805
1998
|
const i = JSON.parse(C(o, "utf-8")).sources?.[s];
|
|
1806
|
-
i && (n =
|
|
1999
|
+
i && (n = yn(n, i));
|
|
1807
2000
|
}
|
|
1808
2001
|
return n;
|
|
1809
2002
|
}
|
|
1810
|
-
function
|
|
2003
|
+
function Xe(e) {
|
|
1811
2004
|
const t = /* @__PURE__ */ new Map();
|
|
1812
2005
|
if (!$(e)) return t;
|
|
1813
|
-
for (const s of
|
|
2006
|
+
for (const s of oe(e))
|
|
1814
2007
|
t.set(D(e, s).split(I).join("/"), C(s));
|
|
1815
2008
|
return t;
|
|
1816
2009
|
}
|
|
1817
|
-
function
|
|
1818
|
-
const n = { added: [], modified: [], deleted: [] }, o =
|
|
2010
|
+
function kn(e, t, s) {
|
|
2011
|
+
const n = { added: [], modified: [], deleted: [] }, o = Xe(e), r = Xe(t);
|
|
1819
2012
|
for (const [i, c] of o) {
|
|
1820
|
-
const
|
|
1821
|
-
if (
|
|
2013
|
+
const l = r.get(i);
|
|
2014
|
+
if (l && l.equals(c)) continue;
|
|
1822
2015
|
const a = d(t, ...i.split("/"));
|
|
1823
|
-
|
|
2016
|
+
H(_(a), { recursive: !0 }), W(a, c), l ? n.modified.push(i) : n.added.push(i);
|
|
1824
2017
|
}
|
|
1825
2018
|
if (s === "mirror")
|
|
1826
2019
|
for (const i of r.keys())
|
|
1827
|
-
o.has(i) || (
|
|
2020
|
+
o.has(i) || (ne(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
|
|
1828
2021
|
return n;
|
|
1829
2022
|
}
|
|
1830
|
-
function
|
|
1831
|
-
const n =
|
|
2023
|
+
function ce(e, t, s) {
|
|
2024
|
+
const n = X("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
|
|
1832
2025
|
return { ok: n.status === 0, out: `${n.stdout ?? ""}${n.stderr ?? ""}`.trim() };
|
|
1833
2026
|
}
|
|
1834
|
-
function
|
|
1835
|
-
const t =
|
|
2027
|
+
function It(e) {
|
|
2028
|
+
const t = ce(["rev-parse", "--show-toplevel"], e);
|
|
1836
2029
|
return t.ok ? t.out : e;
|
|
1837
2030
|
}
|
|
1838
|
-
function
|
|
1839
|
-
const t =
|
|
2031
|
+
function xn(e) {
|
|
2032
|
+
const t = ce(["remote", "get-url", "origin"], e);
|
|
1840
2033
|
if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
|
|
1841
|
-
return
|
|
2034
|
+
return ve(t.out);
|
|
1842
2035
|
}
|
|
1843
|
-
function
|
|
1844
|
-
return
|
|
2036
|
+
function Sn() {
|
|
2037
|
+
return X("gh", ["--version"], { encoding: "utf-8" }).status === 0;
|
|
1845
2038
|
}
|
|
1846
|
-
function
|
|
2039
|
+
function Lt(e) {
|
|
1847
2040
|
return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
|
|
1848
2041
|
}
|
|
1849
|
-
function
|
|
1850
|
-
return e.login?.method === "gh" ?
|
|
2042
|
+
function Fe(e) {
|
|
2043
|
+
return e.login?.method === "gh" ? X("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : ce(["ls-remote", "--exit-code", "-h", e.url], void 0, Lt(e.login)).ok;
|
|
1851
2044
|
}
|
|
1852
|
-
async function
|
|
1853
|
-
const t =
|
|
2045
|
+
async function zt(e) {
|
|
2046
|
+
const t = ut({ input: process.stdin, output: process.stdout });
|
|
1854
2047
|
try {
|
|
1855
2048
|
return (await t.question(e)).trim();
|
|
1856
2049
|
} finally {
|
|
1857
2050
|
t.close();
|
|
1858
2051
|
}
|
|
1859
2052
|
}
|
|
1860
|
-
async function
|
|
1861
|
-
if (
|
|
1862
|
-
if (console.log(`nimpress view: ${e.url} refused the connection`),
|
|
1863
|
-
if (console.log("nimpress view: logging in through gh"),
|
|
2053
|
+
async function jn(e) {
|
|
2054
|
+
if (Fe(e)) return e;
|
|
2055
|
+
if (console.log(`nimpress view: ${e.url} refused the connection`), Sn()) {
|
|
2056
|
+
if (console.log("nimpress view: logging in through gh"), X("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
|
|
1864
2057
|
const o = { ...e, login: { method: "gh" } };
|
|
1865
|
-
if (
|
|
2058
|
+
if (Fe(o)) return o;
|
|
1866
2059
|
throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
|
|
1867
2060
|
}
|
|
1868
|
-
const t = await
|
|
2061
|
+
const t = await zt("nimpress view: path to the ssh key with access to the repo: ");
|
|
1869
2062
|
if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
|
|
1870
|
-
const s = { ...e, login: { method: "ssh", key: j(t.replace(/^~/,
|
|
1871
|
-
if (
|
|
2063
|
+
const s = { ...e, login: { method: "ssh", key: j(t.replace(/^~/, K())) } };
|
|
2064
|
+
if (Fe(s)) return s;
|
|
1872
2065
|
throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${s.login.key}, ask for access to it`);
|
|
1873
2066
|
}
|
|
1874
|
-
async function
|
|
1875
|
-
const n =
|
|
1876
|
-
let
|
|
2067
|
+
async function Cn(e, t, s = K()) {
|
|
2068
|
+
const n = It(e), o = Tt(s), r = o.links[n] ?? [], i = wn(n), c = N(t, "docs-repo");
|
|
2069
|
+
let l;
|
|
1877
2070
|
if (c) {
|
|
1878
|
-
const p =
|
|
1879
|
-
|
|
2071
|
+
const p = ve(c), u = i.find((m) => m.repo === p)?.exportDir ?? N(t, "export-dir") ?? ".nimpress";
|
|
2072
|
+
l = [{ repo: p, url: Oe(c), exportDir: u, login: r.find((m) => m.repo === p)?.login }];
|
|
1880
2073
|
} else if (i.length)
|
|
1881
|
-
|
|
2074
|
+
l = i.map((p) => ({
|
|
1882
2075
|
repo: p.repo,
|
|
1883
|
-
url: r.find((
|
|
2076
|
+
url: r.find((u) => u.repo === p.repo)?.url ?? Oe(p.repo),
|
|
1884
2077
|
exportDir: p.exportDir,
|
|
1885
|
-
login: r.find((
|
|
2078
|
+
login: r.find((u) => u.repo === p.repo)?.login
|
|
1886
2079
|
}));
|
|
1887
2080
|
else if (r.length)
|
|
1888
|
-
|
|
2081
|
+
l = r;
|
|
1889
2082
|
else {
|
|
1890
2083
|
console.log(`nimpress view: no workflow under ${n} names a docs site`);
|
|
1891
|
-
const p = await
|
|
2084
|
+
const p = await zt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
|
|
1892
2085
|
if (!p) throw new Error("[nimpress] view: no docs site given");
|
|
1893
|
-
|
|
2086
|
+
l = [{ repo: ve(p), url: Oe(p), exportDir: N(t, "export-dir") ?? ".nimpress" }];
|
|
1894
2087
|
}
|
|
1895
2088
|
const a = [];
|
|
1896
|
-
for (const p of
|
|
1897
|
-
return o.links[n] = a,
|
|
2089
|
+
for (const p of l) a.push(await jn(p));
|
|
2090
|
+
return o.links[n] = a, Rt(o, s), a;
|
|
1898
2091
|
}
|
|
1899
|
-
function
|
|
1900
|
-
return d(
|
|
2092
|
+
function En(e, t = K()) {
|
|
2093
|
+
return d(Wt(t), e.repo.replace("/", "__"));
|
|
1901
2094
|
}
|
|
1902
|
-
function
|
|
1903
|
-
const n =
|
|
2095
|
+
function On(e, t, s) {
|
|
2096
|
+
const n = Lt(e.login);
|
|
1904
2097
|
if (!$(d(t, ".git"))) {
|
|
1905
|
-
|
|
1906
|
-
const r = e.login?.method === "gh" ?
|
|
2098
|
+
H(_(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
|
|
2099
|
+
const r = e.login?.method === "gh" ? X("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : X("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
|
|
1907
2100
|
if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
|
|
1908
2101
|
${r.stderr ?? ""}`);
|
|
1909
2102
|
return;
|
|
1910
2103
|
}
|
|
1911
2104
|
if (s) return;
|
|
1912
|
-
const o =
|
|
2105
|
+
const o = ce(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
|
|
1913
2106
|
if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
|
|
1914
2107
|
${o.out}`);
|
|
1915
|
-
|
|
2108
|
+
ce(["reset", "--hard", "FETCH_HEAD"], t), ce(["clean", "-fd"], t);
|
|
1916
2109
|
}
|
|
1917
|
-
function
|
|
2110
|
+
function Fn(e) {
|
|
1918
2111
|
const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => $(s));
|
|
1919
|
-
return t ?
|
|
2112
|
+
return t ? lt("sha256").update(C(t)).digest("hex") : "";
|
|
1920
2113
|
}
|
|
1921
|
-
function
|
|
1922
|
-
const t = d(e,
|
|
2114
|
+
function Dn(e) {
|
|
2115
|
+
const t = d(e, z.paths.cache, "view", "lockfile.sha256"), s = Fn(e);
|
|
1923
2116
|
if ($(d(e, "node_modules")) && $(t) && C(t, "utf-8").trim() === s) return;
|
|
1924
|
-
if (console.log("nimpress view: installing the docs site dependencies"),
|
|
1925
|
-
|
|
2117
|
+
if (console.log("nimpress view: installing the docs site dependencies"), X("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
|
|
2118
|
+
H(_(t), { recursive: !0 }), W(t, `${s}
|
|
1926
2119
|
`);
|
|
1927
2120
|
}
|
|
1928
|
-
function
|
|
1929
|
-
const t =
|
|
2121
|
+
function Nn(e) {
|
|
2122
|
+
const t = rs(), s = t === "darwin" ? ["open", e] : t === "win32" ? ["cmd", "/c", "start", "", e] : ["xdg-open", e], n = Ie(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
|
|
1930
2123
|
n.on("error", () => console.log(`nimpress view: open ${e} in a browser`)), n.unref();
|
|
1931
2124
|
}
|
|
1932
|
-
function
|
|
2125
|
+
function qe(e, t) {
|
|
1933
2126
|
let s;
|
|
1934
2127
|
return () => {
|
|
1935
2128
|
s && clearTimeout(s), s = setTimeout(e, t);
|
|
1936
2129
|
};
|
|
1937
2130
|
}
|
|
1938
|
-
function
|
|
2131
|
+
function _n(e, t) {
|
|
1939
2132
|
t.added.length + t.modified.length + t.deleted.length !== 0 && console.log(`nimpress view: ${e} ${t.added.length} added, ${t.modified.length} modified, ${t.deleted.length} deleted`);
|
|
1940
2133
|
}
|
|
1941
|
-
function
|
|
1942
|
-
const t =
|
|
2134
|
+
function Wn(e) {
|
|
2135
|
+
const t = Ie("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), s = new Promise((n, o) => {
|
|
1943
2136
|
let r = !1;
|
|
1944
2137
|
t.stdout?.on("data", (i) => {
|
|
1945
2138
|
const c = i.toString();
|
|
1946
2139
|
if (process.stdout.write(c), r) return;
|
|
1947
|
-
const
|
|
1948
|
-
|
|
2140
|
+
const l = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
|
|
2141
|
+
l && (r = !0, n(l[1]));
|
|
1949
2142
|
}), t.on("exit", (i) => {
|
|
1950
2143
|
r || o(new Error(`[nimpress] view: the docs site dev server exited with ${i ?? "a signal"} before it printed a url`));
|
|
1951
2144
|
}), t.on("error", (i) => o(new Error(`[nimpress] view: cannot run the docs site dev server, ${i.message}`)));
|
|
1952
2145
|
});
|
|
1953
2146
|
return { child: t, origin: s };
|
|
1954
2147
|
}
|
|
1955
|
-
async function
|
|
1956
|
-
const s = M(t, "offline"), n = await
|
|
2148
|
+
async function Tn(e, t) {
|
|
2149
|
+
const s = M(t, "offline"), n = await Cn(e, t), o = xn(e), r = It(e), i = await we(e), c = N(t, "target") ? [`--target=${N(t, "target")}`] : [], l = [];
|
|
1957
2150
|
for (const p of n) {
|
|
1958
|
-
const
|
|
1959
|
-
if (i.configFile &&
|
|
1960
|
-
throw new Error(`[nimpress] view: no export folder at ${
|
|
1961
|
-
const m =
|
|
1962
|
-
|
|
1963
|
-
const f = await
|
|
2151
|
+
const u = j(r, p.exportDir);
|
|
2152
|
+
if (i.configFile && Ae(e, i.resolved, [...c, `--out=${u}`]), !$(u))
|
|
2153
|
+
throw new Error(`[nimpress] view: no export folder at ${u}, write the pages there or mark pages with export: and add a config`);
|
|
2154
|
+
const m = En(p);
|
|
2155
|
+
On(p, m, s), Dn(m);
|
|
2156
|
+
const f = await we(m);
|
|
1964
2157
|
if (!f.configFile) throw new Error(`[nimpress] view: ${p.repo} carries no nimpress config, so it is not a docs site`);
|
|
1965
|
-
const h =
|
|
2158
|
+
const h = $n(m, f.resolved.contentDir), g = bn(vn(m, h, o));
|
|
1966
2159
|
if (!g.length)
|
|
1967
2160
|
throw new Error(
|
|
1968
2161
|
`[nimpress] view: ${p.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
|
|
1969
2162
|
);
|
|
1970
2163
|
const w = j(m, h.contentRoot), v = () => {
|
|
1971
2164
|
for (const x of g)
|
|
1972
|
-
|
|
2165
|
+
_n(x.to, kn(d(u, ...x.from.split("/").filter(Boolean)), d(w, ...x.to.split("/")), x.mode));
|
|
1973
2166
|
};
|
|
1974
2167
|
v();
|
|
1975
|
-
const
|
|
1976
|
-
if (
|
|
1977
|
-
const x =
|
|
2168
|
+
const O = He(u, { recursive: !0 }, qe(v, 150));
|
|
2169
|
+
if (l.push(() => O.close()), i.configFile) {
|
|
2170
|
+
const x = He(
|
|
1978
2171
|
j(e, i.resolved.contentDir),
|
|
1979
2172
|
{ recursive: !0 },
|
|
1980
|
-
|
|
2173
|
+
qe(() => Ae(e, i.resolved, [...c, `--out=${u}`]), 150)
|
|
1981
2174
|
);
|
|
1982
|
-
|
|
2175
|
+
l.push(() => x.close());
|
|
1983
2176
|
}
|
|
1984
|
-
const { child: E, origin: k } =
|
|
1985
|
-
|
|
2177
|
+
const { child: E, origin: k } = Wn(m);
|
|
2178
|
+
l.push(() => E.kill());
|
|
1986
2179
|
const T = `${(await k).replace(/\/$/, "")}/${g[0].to}`;
|
|
1987
|
-
console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), M(t, "no-browser") ||
|
|
2180
|
+
console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), M(t, "no-browser") || Nn(T);
|
|
1988
2181
|
}
|
|
1989
2182
|
const a = () => {
|
|
1990
|
-
for (const p of
|
|
2183
|
+
for (const p of l) p();
|
|
1991
2184
|
process.exit(0);
|
|
1992
2185
|
};
|
|
1993
2186
|
process.on("SIGINT", a), process.on("SIGTERM", a);
|
|
1994
2187
|
}
|
|
1995
|
-
async function
|
|
1996
|
-
const s =
|
|
2188
|
+
async function Rn(e, t) {
|
|
2189
|
+
const s = re(t, 0);
|
|
1997
2190
|
if (s !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${s ?? ""}, use clear`);
|
|
1998
2191
|
const n = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !n && !o && !r;
|
|
1999
2192
|
if (n || i) {
|
|
2000
|
-
const c =
|
|
2001
|
-
|
|
2193
|
+
const c = Tt(), l = Object.keys(c.links).length;
|
|
2194
|
+
Rt({ links: {} }), console.log(`nimpress cache: cleared ${l} links`);
|
|
2002
2195
|
}
|
|
2003
2196
|
if (o || i) {
|
|
2004
|
-
const c =
|
|
2005
|
-
|
|
2197
|
+
const c = Wt();
|
|
2198
|
+
ne(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
|
|
2006
2199
|
}
|
|
2007
2200
|
if (r) {
|
|
2008
|
-
const { resolved: c, configFile:
|
|
2009
|
-
if (!
|
|
2010
|
-
const a =
|
|
2011
|
-
$(a) &&
|
|
2201
|
+
const { resolved: c, configFile: l } = await we(e);
|
|
2202
|
+
if (!l) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
|
|
2203
|
+
const a = nt(e, c);
|
|
2204
|
+
$(a) && ne(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
|
|
2012
2205
|
}
|
|
2013
2206
|
}
|
|
2014
|
-
async function
|
|
2207
|
+
async function Qn(e) {
|
|
2015
2208
|
const t = e[0] ?? "dev", s = e.slice(1), n = process.cwd();
|
|
2016
2209
|
if (t === "init") {
|
|
2017
|
-
|
|
2210
|
+
ps(n);
|
|
2018
2211
|
return;
|
|
2019
2212
|
}
|
|
2020
2213
|
if (t === "skill") {
|
|
2021
|
-
|
|
2214
|
+
Ms(n, s);
|
|
2215
|
+
return;
|
|
2216
|
+
}
|
|
2217
|
+
if (t === "plugin") {
|
|
2218
|
+
Js(n, s);
|
|
2219
|
+
return;
|
|
2220
|
+
}
|
|
2221
|
+
if (t === "mcp") {
|
|
2222
|
+
pn(n);
|
|
2022
2223
|
return;
|
|
2023
2224
|
}
|
|
2024
2225
|
if (t === "completion") {
|
|
2025
|
-
|
|
2226
|
+
Qs(n, s);
|
|
2026
2227
|
return;
|
|
2027
2228
|
}
|
|
2028
2229
|
if (t === "view" || t === "dev" && M(s, "view")) {
|
|
2029
|
-
await
|
|
2230
|
+
await Tn(n, s);
|
|
2030
2231
|
return;
|
|
2031
2232
|
}
|
|
2032
2233
|
if (t === "cache") {
|
|
2033
|
-
await
|
|
2234
|
+
await Rn(n, s);
|
|
2034
2235
|
return;
|
|
2035
2236
|
}
|
|
2036
|
-
const { resolved: o } = await
|
|
2237
|
+
const { resolved: o } = await we(n);
|
|
2037
2238
|
if (t === "seo") {
|
|
2038
|
-
|
|
2239
|
+
gn(n, o, s);
|
|
2039
2240
|
return;
|
|
2040
2241
|
}
|
|
2041
2242
|
if (t === "lint") {
|
|
2042
|
-
await
|
|
2243
|
+
await Cs(n, o);
|
|
2043
2244
|
return;
|
|
2044
2245
|
}
|
|
2045
2246
|
if (t === "dev") {
|
|
2046
|
-
await
|
|
2247
|
+
await ws(n, o);
|
|
2047
2248
|
return;
|
|
2048
2249
|
}
|
|
2049
2250
|
if (t === "build") {
|
|
2050
|
-
await
|
|
2251
|
+
await gt(n, o);
|
|
2051
2252
|
return;
|
|
2052
2253
|
}
|
|
2053
2254
|
if (t === "guard") {
|
|
2054
|
-
|
|
2255
|
+
Os(n, o, s);
|
|
2055
2256
|
return;
|
|
2056
2257
|
}
|
|
2057
2258
|
if (t === "modules") {
|
|
2058
|
-
await
|
|
2259
|
+
await Ts(n, o, s);
|
|
2059
2260
|
return;
|
|
2060
2261
|
}
|
|
2061
2262
|
if (t === "export") {
|
|
2062
|
-
|
|
2263
|
+
Ae(n, o, s);
|
|
2063
2264
|
return;
|
|
2064
2265
|
}
|
|
2065
2266
|
throw new Error(`[nimpress] unknown command: ${t}`);
|
|
2066
2267
|
}
|
|
2067
2268
|
export {
|
|
2068
|
-
|
|
2069
|
-
|
|
2070
|
-
|
|
2071
|
-
|
|
2269
|
+
tt as buildViteConfig,
|
|
2270
|
+
Ut as indexHtml,
|
|
2271
|
+
we as loadNimpressConfig,
|
|
2272
|
+
Qn as run
|
|
2072
2273
|
};
|