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