@nimtech/nimpress 2.6.10 → 2.6.12
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 +19 -3
- package/dist/cli.es.js +597 -570
- package/dist/nimpress.es.js +5134 -5110
- package/dist/{plugin-BDy913Zy.js → plugin-DnnKU6ST.js} +1502 -1483
- package/dist/plugin.es.js +11 -11
- package/dist/src/cli/completion.d.ts.map +1 -1
- package/dist/src/cli/modules.d.ts.map +1 -1
- package/dist/src/config/schema.d.ts +6 -6
- package/dist/src/framework/stores/theme.d.ts.map +1 -1
- package/dist/src/modules/harness.d.ts +4 -0
- package/dist/src/modules/harness.d.ts.map +1 -1
- package/dist/src/modules/stories.d.ts +13 -1
- package/dist/src/modules/stories.d.ts.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/styles/themes/glass.css +155 -89
package/dist/cli.es.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import { d as
|
|
1
|
+
import { d as z, c as Ae, r as Me, s as Gt, p as Ht, a as st, b as pe, e as Ut, f as Zt, g as De, h as nt, i as Vt, j as ot, k as Kt, l as Yt, m as Qt, C as ge, n as Xt, o as rt, q as Ge, w as me, t as it, u as qt, v as es, x as He, y as ts, z as ss, A as ns, B as os, D as we, E as rs } from "./plugin-DnnKU6ST.js";
|
|
2
2
|
import { join as d, dirname as N, relative as F, sep as L, extname as fe, resolve as x, basename as D } from "node:path";
|
|
3
|
-
import { readdirSync as
|
|
4
|
-
import
|
|
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
|
|
12
|
-
import { spawnSync as
|
|
13
|
-
import { createInterface as
|
|
14
|
-
import { parse as
|
|
3
|
+
import { readdirSync as ie, existsSync as b, writeFileSync as W, mkdirSync as B, rmSync as ee, readFileSync as C, statSync as at, watch as Ue } from "node:fs";
|
|
4
|
+
import ue from "gray-matter";
|
|
5
|
+
import { readFile as Se, readdir as is, writeFile as q, mkdir as _e, copyFile as ct } from "node:fs/promises";
|
|
6
|
+
import { s as as, r as $e } from "./typeMembers-CNvE92EX.js";
|
|
7
|
+
import { createServer as lt, build as ut } from "vite";
|
|
8
|
+
import { createHash as pt } from "node:crypto";
|
|
9
|
+
import { createInterface as mt } from "node:readline/promises";
|
|
10
|
+
import { fileURLToPath as ft } from "node:url";
|
|
11
|
+
import { homedir as K, platform as cs } from "node:os";
|
|
12
|
+
import { spawnSync as te, spawn as Ie } from "node:child_process";
|
|
13
|
+
import { createInterface as ls } from "node:readline";
|
|
14
|
+
import { parse as us } from "yaml";
|
|
15
15
|
function _(e, t) {
|
|
16
16
|
return e.find((n) => n.startsWith(`--${t}=`))?.slice(t.length + 3);
|
|
17
17
|
}
|
|
18
|
-
function
|
|
18
|
+
function M(e, t) {
|
|
19
19
|
return e.includes(`--${t}`);
|
|
20
20
|
}
|
|
21
|
-
function
|
|
21
|
+
function ne(e, t) {
|
|
22
22
|
return e.filter((n) => !n.startsWith("--"))[t];
|
|
23
23
|
}
|
|
24
24
|
function Y(e, t = []) {
|
|
25
25
|
let s;
|
|
26
26
|
try {
|
|
27
|
-
s =
|
|
27
|
+
s = ie(e, { withFileTypes: !0 });
|
|
28
28
|
} catch {
|
|
29
29
|
return t;
|
|
30
30
|
}
|
|
@@ -45,7 +45,7 @@ function Ne(e, t, s) {
|
|
|
45
45
|
}
|
|
46
46
|
console.log(s);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function ps() {
|
|
49
49
|
return `import { defineConfig } from '@nimtech/nimpress/plugin'
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -55,15 +55,15 @@ function us() {
|
|
|
55
55
|
*/
|
|
56
56
|
export default defineConfig({
|
|
57
57
|
/** Site title shown in the header and the tab. */
|
|
58
|
-
title: ${JSON.stringify(
|
|
58
|
+
title: ${JSON.stringify(z.title)},
|
|
59
59
|
|
|
60
|
-
/** Folder holding the markdown content. Default ${JSON.stringify(
|
|
60
|
+
/** Folder holding the markdown content. Default ${JSON.stringify(z.contentDir)}. */
|
|
61
61
|
// contentDir: 'docs',
|
|
62
62
|
|
|
63
|
-
/** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(
|
|
63
|
+
/** Root assets folder copied into the build, never inside contentDir. Default ${JSON.stringify(z.assetsDir)}. */
|
|
64
64
|
// assetsDir: 'assets',
|
|
65
65
|
|
|
66
|
-
/** Url base the assets folder serves under. Default ${JSON.stringify(
|
|
66
|
+
/** Url base the assets folder serves under. Default ${JSON.stringify(z.assetUrlBase)}. */
|
|
67
67
|
// assetUrlBase: '/assets',
|
|
68
68
|
|
|
69
69
|
/**
|
|
@@ -181,21 +181,21 @@ export default defineConfig({
|
|
|
181
181
|
})
|
|
182
182
|
`;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function ms() {
|
|
185
185
|
return JSON.stringify(
|
|
186
186
|
{
|
|
187
187
|
$schema: "./node_modules/@nimtech/nimpress/config.schema.json",
|
|
188
|
-
title:
|
|
189
|
-
contentDir:
|
|
190
|
-
assetsDir:
|
|
191
|
-
assetUrlBase:
|
|
188
|
+
title: z.title,
|
|
189
|
+
contentDir: z.contentDir,
|
|
190
|
+
assetsDir: z.assetsDir,
|
|
191
|
+
assetUrlBase: z.assetUrlBase
|
|
192
192
|
},
|
|
193
193
|
null,
|
|
194
194
|
2
|
|
195
195
|
) + `
|
|
196
196
|
`;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function fs(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
|
|
241
|
-
const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n =
|
|
242
|
-
!b(t) && !b(s) && (n ? (W(s,
|
|
243
|
-
const o = d(e,
|
|
244
|
-
(!b(o) ||
|
|
240
|
+
function ds(e) {
|
|
241
|
+
const t = d(e, "nimpress.config.ts"), s = d(e, "nimpress.config.json"), n = M(process.argv.slice(2), "json");
|
|
242
|
+
!b(t) && !b(s) && (n ? (W(s, ms()), console.log(`nimpress init: ${s} written, field descriptions come from the referenced config.schema.json`)) : (W(t, ps()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
|
|
243
|
+
const o = d(e, z.contentDir);
|
|
244
|
+
(!b(o) || ie(o).length === 0) && (B(o, { recursive: !0 }), W(
|
|
245
245
|
d(o, "index.md"),
|
|
246
246
|
`---
|
|
247
247
|
title: Home
|
|
@@ -250,59 +250,59 @@ title: Home
|
|
|
250
250
|
Welcome to your Nimpress site.
|
|
251
251
|
`
|
|
252
252
|
));
|
|
253
|
-
const i =
|
|
253
|
+
const i = fs(z.contentDir);
|
|
254
254
|
for (const c of ["CLAUDE.md", "AGENTS.md"]) {
|
|
255
|
-
const
|
|
256
|
-
b(
|
|
255
|
+
const p = d(e, c);
|
|
256
|
+
b(p) || (W(p, 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
|
|
260
|
-
function
|
|
259
|
+
const hs = { vue: "vueStory", svelte: "svelteStory" }, gs = { vue: ".svelte", svelte: ".vue" };
|
|
260
|
+
function ce(e) {
|
|
261
261
|
return `run nimpress modules update ${e}`;
|
|
262
262
|
}
|
|
263
|
-
async function
|
|
263
|
+
async function ws(e) {
|
|
264
264
|
let t;
|
|
265
265
|
try {
|
|
266
|
-
t = await
|
|
266
|
+
t = await is(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 $s(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 ys(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
|
-
m in i || r.push(`${e}: prop ${m} is missing from the schema, ${
|
|
279
|
+
m in i || r.push(`${e}: prop ${m} is missing from the schema, ${ce(t)}`);
|
|
280
280
|
for (const m of Object.keys(i))
|
|
281
281
|
m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${s}, remove it or restore the prop`);
|
|
282
282
|
for (const [m, f] of Object.entries(i)) {
|
|
283
283
|
const h = c[m];
|
|
284
284
|
if (h && (f.type && h.type && f.type !== h.type && !f.enum && r.push(
|
|
285
|
-
`${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${
|
|
286
|
-
), f.enum && h.type &&
|
|
285
|
+
`${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${ce(t)}`
|
|
286
|
+
), f.enum && h.type && !$s(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((k) => JSON.stringify(k))), w = f.enum.filter((k) => !g.has(JSON.stringify(k)));
|
|
288
288
|
w.length && r.push(
|
|
289
289
|
`${e}: prop ${m} enum carries ${w.map((k) => JSON.stringify(k)).join(", ")} outside the source union`
|
|
290
290
|
);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
const
|
|
293
|
+
const p = 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 p || r.push(`${e}: slot ${m} is missing from the schema, ${ce(t)}`);
|
|
296
|
+
for (const m of Object.keys(p))
|
|
297
297
|
m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${s}`);
|
|
298
|
-
const
|
|
298
|
+
const l = new Set(n.emits ?? []), u = new Set(o.emits ?? []);
|
|
299
|
+
for (const m of u)
|
|
300
|
+
l.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ce(t)}`);
|
|
299
301
|
for (const m of l)
|
|
300
|
-
|
|
301
|
-
for (const m of p)
|
|
302
|
-
l.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${s}`);
|
|
302
|
+
u.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 dt(e, t, s) {
|
|
306
306
|
const n = s ? [s] : Object.keys(t.modules.systems), o = [], r = await Ae(e, t.contentDir);
|
|
307
307
|
for (const i of n) {
|
|
308
308
|
const c = t.modules.systems[i];
|
|
@@ -310,11 +310,11 @@ async function ft(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 = N(
|
|
317
|
-
h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${
|
|
313
|
+
const p = c.framework, a = hs[p === "vue" ? "svelte" : "vue"], l = gs[p];
|
|
314
|
+
for (const u of r) {
|
|
315
|
+
if (u.system !== i) continue;
|
|
316
|
+
const m = N(u.pageFile), f = F(e, m).split(L).join("/"), h = await ws(m);
|
|
317
|
+
h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${u.component}`);
|
|
318
318
|
const g = /* @__PURE__ */ new Set();
|
|
319
319
|
for (const O of h) {
|
|
320
320
|
let T;
|
|
@@ -323,20 +323,20 @@ async function ft(e, t, s) {
|
|
|
323
323
|
} catch {
|
|
324
324
|
continue;
|
|
325
325
|
}
|
|
326
|
-
(/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(O), T.includes(a) && o.push(`${f}/${O}: uses ${a} inside the ${
|
|
326
|
+
(/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(O), T.includes(a) && o.push(`${f}/${O}: uses ${a} inside the ${p} system ${i}`);
|
|
327
327
|
for (const $ of T.matchAll(/from\s+['"]([^'"]+)['"]/g))
|
|
328
|
-
fe($[1]) ===
|
|
328
|
+
fe($[1]) === l && o.push(`${f}/${O}: imports ${$[1]} inside the ${p} system ${i}`);
|
|
329
329
|
}
|
|
330
|
-
const w = Me(e, t.modules, i,
|
|
331
|
-
if (w && fe(w.componentFile) ===
|
|
332
|
-
`${f}: component file ${F(e, w.componentFile)} mismatches the ${
|
|
330
|
+
const w = Me(e, t.modules, i, u.component, u.file);
|
|
331
|
+
if (w && fe(w.componentFile) === l && o.push(
|
|
332
|
+
`${f}: component file ${F(e, w.componentFile)} mismatches the ${p} system ${i}`
|
|
333
333
|
), b(d(m, "schema.json")) && b(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 k =
|
|
337
|
+
const k = Gt(m);
|
|
338
338
|
if (!k) {
|
|
339
|
-
o.push(`${f}: schema file missing, ${
|
|
339
|
+
o.push(`${f}: schema file missing, ${ce(u.component)}`);
|
|
340
340
|
continue;
|
|
341
341
|
}
|
|
342
342
|
let j;
|
|
@@ -348,69 +348,69 @@ async function ft(e, t, s) {
|
|
|
348
348
|
}
|
|
349
349
|
let E;
|
|
350
350
|
try {
|
|
351
|
-
E =
|
|
351
|
+
E = Ht(j, k.form);
|
|
352
352
|
} catch {
|
|
353
353
|
o.push(`${f}: schema is not valid ${k.form}, fix it by hand`);
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
356
356
|
const v = new Set(Object.keys(E.properties ?? {}));
|
|
357
|
-
for (const O of await
|
|
357
|
+
for (const O of await st(m))
|
|
358
358
|
if (!g.has(O.file))
|
|
359
359
|
for (const T of Object.keys(O.props ?? {}))
|
|
360
|
-
v.has(T) || o.push(`${f}/${O.file}: prop ${T} is absent from the schema, ${
|
|
360
|
+
v.has(T) || o.push(`${f}/${O.file}: prop ${T} is absent from the schema, ${ce(u.component)}`);
|
|
361
361
|
const R = w ? await Se(w.componentFile, "utf-8").catch(() => {
|
|
362
362
|
}) : void 0;
|
|
363
363
|
if (w) {
|
|
364
|
-
const O = await pe(w.componentFile,
|
|
364
|
+
const O = await pe(w.componentFile, p, u.component);
|
|
365
365
|
if (O) {
|
|
366
|
-
const T =
|
|
366
|
+
const T = as(u.component, O.props, O.slots, O.emits);
|
|
367
367
|
o.push(
|
|
368
|
-
|
|
368
|
+
...ys(f, u.component, F(e, w.componentFile), E, T)
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
|
|
372
|
+
Ut(Zt(u.component, E, { sourceFile: w?.componentFile, sourceText: R }));
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
375
|
return De(e), o;
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function ht(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 gt(e, t, s) {
|
|
381
381
|
for (const n of s)
|
|
382
382
|
try {
|
|
383
|
-
await (await
|
|
383
|
+
await (await lt(await ot(e, t, n, "serve"))).listen(), console.log(`nimpress modules: ${n} harness on port ${Kt(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 wt(e, t, s) {
|
|
389
389
|
for (const n of s)
|
|
390
|
-
await
|
|
390
|
+
await ut(await ot(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 bs(e, t) {
|
|
393
|
+
const s = await lt(await nt({ cwd: e, command: "serve", resolved: t }));
|
|
394
|
+
await s.listen(), await gt(e, t, Object.keys(t.modules.systems)), s.printUrls(), s.bindCLIShortcuts({ print: !0 });
|
|
395
395
|
}
|
|
396
|
-
async function
|
|
396
|
+
async function $t(e, t) {
|
|
397
397
|
const s = d(e, "index.html"), n = !b(s);
|
|
398
|
-
n && W(s,
|
|
398
|
+
n && W(s, Vt(t));
|
|
399
399
|
const o = () => {
|
|
400
|
-
n &&
|
|
400
|
+
n && ee(s, { force: !0 });
|
|
401
401
|
}, r = () => {
|
|
402
402
|
o(), process.exit(130);
|
|
403
403
|
};
|
|
404
404
|
process.once("SIGINT", r), process.once("SIGTERM", r);
|
|
405
405
|
try {
|
|
406
|
-
await
|
|
406
|
+
await ut(await nt({ 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 wt(e, t, ht(t));
|
|
411
411
|
}
|
|
412
|
-
const
|
|
413
|
-
function
|
|
412
|
+
const vs = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], ks = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Ze = /^[a-z0-9][a-z0-9.-]*$/, xs = /^[A-Z][A-Za-z0-9]*$/;
|
|
413
|
+
function Ss(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 xs(e) {
|
|
|
422
422
|
([n, o]) => typeof o == "string" ? [{ find: n, replacement: o }] : []
|
|
423
423
|
);
|
|
424
424
|
}
|
|
425
|
-
function
|
|
425
|
+
function js(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,
|
|
@@ -435,21 +435,21 @@ function Ss(e) {
|
|
|
435
435
|
}
|
|
436
436
|
return t;
|
|
437
437
|
}
|
|
438
|
-
function
|
|
439
|
-
return
|
|
438
|
+
function Ve(e) {
|
|
439
|
+
return ks.some((t) => {
|
|
440
440
|
const s = e + t;
|
|
441
441
|
if (!b(s)) return !1;
|
|
442
442
|
try {
|
|
443
|
-
return
|
|
443
|
+
return at(s).isFile();
|
|
444
444
|
} catch {
|
|
445
445
|
return !1;
|
|
446
446
|
}
|
|
447
447
|
});
|
|
448
448
|
}
|
|
449
|
-
function
|
|
450
|
-
const s = x(e, t.contentDir), n =
|
|
449
|
+
function Cs(e, t) {
|
|
450
|
+
const s = x(e, t.contentDir), n = Ss(t.vite), o = [];
|
|
451
451
|
for (const r of Y(s)) {
|
|
452
|
-
if (!
|
|
452
|
+
if (!vs.some((p) => r.endsWith(p))) continue;
|
|
453
453
|
let i;
|
|
454
454
|
try {
|
|
455
455
|
i = C(r, "utf-8");
|
|
@@ -457,115 +457,115 @@ function js(e, t) {
|
|
|
457
457
|
continue;
|
|
458
458
|
}
|
|
459
459
|
const c = F(s, r).split(L).join("/");
|
|
460
|
-
for (const
|
|
461
|
-
if (
|
|
460
|
+
for (const p of js(i)) {
|
|
461
|
+
if (p.includes("_shared/") || p.startsWith("_shared")) {
|
|
462
462
|
o.push(
|
|
463
|
-
`${c}: imports ${
|
|
463
|
+
`${c}: imports ${p}, 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 = p.split("?")[0];
|
|
468
468
|
if (a.startsWith("./") || a.startsWith("../")) {
|
|
469
|
-
const
|
|
470
|
-
|
|
469
|
+
const u = x(N(r), a);
|
|
470
|
+
Ve(u) || o.push(`${c}: unresolved import ${p}, fix the path or create the file`);
|
|
471
471
|
continue;
|
|
472
472
|
}
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
const
|
|
476
|
-
|
|
473
|
+
const l = n.find((u) => a === u.find || a.startsWith(u.find + "/"));
|
|
474
|
+
if (l) {
|
|
475
|
+
const u = x(e, l.replacement + a.slice(l.find.length));
|
|
476
|
+
Ve(u) || o.push(`${c}: unresolved import ${p} via alias ${l.find}`);
|
|
477
477
|
}
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
return o;
|
|
481
481
|
}
|
|
482
|
-
function
|
|
482
|
+
function Es(e, t) {
|
|
483
483
|
const s = x(e, t.contentDir), n = [];
|
|
484
484
|
if (!b(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 Y(s)) {
|
|
489
|
-
const
|
|
489
|
+
const l = F(s, a).split(L).join("/"), u = N(a), m = D(a);
|
|
490
490
|
if (m.endsWith(".md")) {
|
|
491
|
-
const f = c.get(
|
|
492
|
-
f.push(a), c.set(
|
|
491
|
+
const f = c.get(u) ?? [];
|
|
492
|
+
f.push(a), c.set(u, f);
|
|
493
493
|
const h = m.slice(0, -3);
|
|
494
|
-
|
|
494
|
+
Ze.test(h) || n.push(`${l}: 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;
|
|
496
496
|
try {
|
|
497
|
-
g =
|
|
497
|
+
g = ue(C(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
|
|
498
498
|
} catch {
|
|
499
499
|
continue;
|
|
500
500
|
}
|
|
501
|
-
if (g?.type === "glossary" && (i ? n.push(`${
|
|
502
|
-
const w = o.get(
|
|
503
|
-
w ? n.push(`${
|
|
501
|
+
if (g?.type === "glossary" && (i ? n.push(`${l}: second type glossary page in the site, ${F(s, i).split(L).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(ue(C(a, "utf-8")).content) || n.push(`${l}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${L}index.md`) && n.push(`${l}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? n.push(`${l}: second type 404 page in the site, ${F(s, r).split(L).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
|
|
502
|
+
const w = o.get(u);
|
|
503
|
+
w ? n.push(`${l}: second type component page in one folder, ${F(s, w).split(L).join("/")} already owns it, one component per folder`) : o.set(u, a);
|
|
504
504
|
}
|
|
505
505
|
if (g?.type === "dbml") {
|
|
506
506
|
const w = typeof g.spec == "string" ? g.spec : "";
|
|
507
|
-
w ? b(x(
|
|
507
|
+
w ? b(x(u, w)) || n.push(`${l}: spec ${w} does not resolve, create the file or fix the path`) : n.push(`${l}: type dbml needs a spec field pointing at the .dbml file`);
|
|
508
508
|
}
|
|
509
|
-
g?.type === "changelog" && typeof g.path == "string" && n.push(`${
|
|
509
|
+
g?.type === "changelog" && typeof g.path == "string" && n.push(`${l}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
|
|
510
510
|
}
|
|
511
511
|
if (m.endsWith(".css") && !m.startsWith("_") && D(N(a)) === "styles" && N(N(a)) === s) {
|
|
512
512
|
const f = m.replace(/\.css$/, "");
|
|
513
|
-
ge.includes(f) || n.push(`${
|
|
513
|
+
ge.includes(f) || n.push(`${l}: ${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 =
|
|
517
|
+
const f = m.split(".")[0], h = Xt(m, f);
|
|
518
518
|
if (h && b(d(N(a), `${f}.md`))) {
|
|
519
|
-
ge.includes(h) || n.push(`${
|
|
519
|
+
ge.includes(h) || n.push(`${l}: ${h} is not a component class root, name the file after one of ${ge.join(", ")}`);
|
|
520
520
|
continue;
|
|
521
521
|
}
|
|
522
522
|
}
|
|
523
523
|
if (m.endsWith(".css") && !m.startsWith("_")) {
|
|
524
524
|
const f = a.replace(/\.css$/, ".md");
|
|
525
|
-
b(f) || n.push(`${
|
|
525
|
+
b(f) || n.push(`${l}: page css without a matching ${D(f)}, page styles are named after the page they scope`);
|
|
526
526
|
}
|
|
527
527
|
}
|
|
528
|
-
for (const [a,
|
|
529
|
-
const
|
|
528
|
+
for (const [a, l] of c) {
|
|
529
|
+
const u = F(s, a).split(L).join("/") || ".", m = o.has(a);
|
|
530
530
|
let f = [];
|
|
531
531
|
try {
|
|
532
|
-
f =
|
|
532
|
+
f = ie(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(`${u}: 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(`${
|
|
539
|
-
if (m &&
|
|
540
|
-
const g =
|
|
541
|
-
n.push(`${
|
|
538
|
+
f.includes(g) && !m && n.push(`${u}: ${g} without a type component page, it belongs beside the component index.md`);
|
|
539
|
+
if (m && l.length > 1) {
|
|
540
|
+
const g = l.filter((w) => w !== o.get(a)).map((w) => D(w));
|
|
541
|
+
n.push(`${u}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
|
|
542
542
|
}
|
|
543
543
|
}
|
|
544
|
-
const
|
|
545
|
-
let
|
|
544
|
+
const p = (a) => {
|
|
545
|
+
let l;
|
|
546
546
|
try {
|
|
547
|
-
|
|
547
|
+
l = ie(a, { withFileTypes: !0 });
|
|
548
548
|
} catch {
|
|
549
549
|
return;
|
|
550
550
|
}
|
|
551
|
-
for (const
|
|
552
|
-
if (
|
|
553
|
-
if (!
|
|
554
|
-
const m = F(s, d(a,
|
|
551
|
+
for (const u of l)
|
|
552
|
+
if (u.isDirectory() && !(u.name.startsWith(".") || u.name === "node_modules")) {
|
|
553
|
+
if (!Ze.test(u.name) && !xs.test(u.name)) {
|
|
554
|
+
const m = F(s, d(a, u.name)).split(L).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
|
+
p(d(a, u.name));
|
|
558
558
|
}
|
|
559
559
|
};
|
|
560
|
-
return
|
|
560
|
+
return p(s), n;
|
|
561
561
|
}
|
|
562
|
-
async function
|
|
563
|
-
const s =
|
|
562
|
+
async function Os(e, t) {
|
|
563
|
+
const s = rt(e, t, "lint"), n = () => ee(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 $t(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 Es(e, t) {
|
|
|
573
573
|
process.off("SIGINT", o), process.off("SIGTERM", o), n();
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
|
-
async function
|
|
576
|
+
async function Fs(e, t) {
|
|
577
577
|
const s = process.argv.slice(2), n = [
|
|
578
|
+
...Es(e, t),
|
|
579
|
+
...(Yt(e, t.pageTypes ?? {}), await Qt(e, t.contentDir)),
|
|
578
580
|
...Cs(e, t),
|
|
579
|
-
...
|
|
580
|
-
...js(e, t),
|
|
581
|
-
...await ft(e, t)
|
|
581
|
+
...await dt(e, t)
|
|
582
582
|
];
|
|
583
583
|
if (n.length) {
|
|
584
584
|
Ne("nimpress lint", n, "");
|
|
585
585
|
return;
|
|
586
586
|
}
|
|
587
|
-
if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"),
|
|
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
|
|
589
|
+
const o = await Os(e, t);
|
|
590
590
|
Ne("nimpress lint", o, "nimpress lint: build ok, everything passes");
|
|
591
591
|
}
|
|
592
|
-
const
|
|
592
|
+
const Ds = {
|
|
593
593
|
".json": "application/json",
|
|
594
594
|
".xml": "application/rss+xml",
|
|
595
595
|
".html": "text/html",
|
|
@@ -602,53 +602,53 @@ const Fs = {
|
|
|
602
602
|
".webp": "image/webp",
|
|
603
603
|
".pdf": "application/pdf"
|
|
604
604
|
};
|
|
605
|
-
function
|
|
605
|
+
function _s(e, t, s) {
|
|
606
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 (!b(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 k = F(
|
|
611
|
+
const p = Ge(o, t), a = d(o, "guard.map.json"), l = b(a) ? JSON.parse(C(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, u = b(p) ? Y(p) : [], m = l.prefix ?? r, f = u.map((w) => {
|
|
612
|
+
const k = F(p, w).split("\\").join("/"), j = k.split("/")[0] ?? "", E = [
|
|
613
613
|
...new Set(
|
|
614
|
-
Object.values(
|
|
614
|
+
Object.values(l.routes ?? {}).filter((R) => R.bundle === j && R.gate).map((R) => R.gate)
|
|
615
615
|
)
|
|
616
616
|
], v = C(w);
|
|
617
617
|
return {
|
|
618
618
|
path: `${m}${k}`,
|
|
619
619
|
file: k,
|
|
620
620
|
bundle: j,
|
|
621
|
-
sha256:
|
|
622
|
-
size:
|
|
623
|
-
mime:
|
|
621
|
+
sha256: pt("sha256").update(v).digest("hex"),
|
|
622
|
+
size: at(w).size,
|
|
623
|
+
mime: Ds[fe(w).toLowerCase()] ?? "application/octet-stream",
|
|
624
624
|
gates: E
|
|
625
625
|
};
|
|
626
626
|
}), h = _(s, "out"), g = h ? d(e, h) : a;
|
|
627
627
|
W(
|
|
628
628
|
g,
|
|
629
|
-
JSON.stringify({ ...
|
|
629
|
+
JSON.stringify({ ...l, prefix: m, files: f }, null, 2) + `
|
|
630
630
|
`
|
|
631
631
|
), console.log(`nimpress guard: mapped ${f.length} guarded files to ${g}`);
|
|
632
632
|
return;
|
|
633
633
|
}
|
|
634
634
|
if (n === "apply") {
|
|
635
|
-
const
|
|
636
|
-
if (!
|
|
637
|
-
const a = JSON.parse(C(d(e,
|
|
635
|
+
const p = _(s, "map");
|
|
636
|
+
if (!p) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
|
|
637
|
+
const a = JSON.parse(C(d(e, p), "utf-8"));
|
|
638
638
|
if (!a.base) throw new Error("[nimpress] guard apply: mapping json carries no base url");
|
|
639
|
-
c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((
|
|
640
|
-
path:
|
|
641
|
-
file:
|
|
642
|
-
bundle:
|
|
643
|
-
asset_id:
|
|
644
|
-
url:
|
|
639
|
+
c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((l) => ({
|
|
640
|
+
path: l.path,
|
|
641
|
+
file: l.file,
|
|
642
|
+
bundle: l.bundle,
|
|
643
|
+
asset_id: l.asset_id,
|
|
644
|
+
url: l.url
|
|
645
645
|
})), W(i, JSON.stringify(c, null, 2) + `
|
|
646
|
-
`),
|
|
646
|
+
`), ee(Ge(o, t), { recursive: !0, force: !0 }), ee(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
|
|
647
647
|
return;
|
|
648
648
|
}
|
|
649
649
|
throw new Error("[nimpress] guard expects map or apply");
|
|
650
650
|
}
|
|
651
|
-
function
|
|
651
|
+
function yt(e) {
|
|
652
652
|
const t = fe(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 p = o ?? yt(c.componentFile);
|
|
663
|
+
if (!p)
|
|
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 = p === "vue" ? "vueStory" : "svelteStory", l = `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 b(
|
|
673
|
+
`, u = d(N(i.pageFile), "default.story.tsx");
|
|
674
|
+
return b(u) ? (console.warn(`[nimpress] modules story: ${u} exists, not overwriting`), null) : (await q(u, l), u);
|
|
675
675
|
}
|
|
676
|
-
async function
|
|
676
|
+
async function Ns(e, t, s) {
|
|
677
677
|
const n = await Ae(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 st(N(r.pageFile))).length))
|
|
681
681
|
try {
|
|
682
682
|
await Le(e, t, s, r.component) && o++;
|
|
683
683
|
} catch (c) {
|
|
@@ -685,16 +685,16 @@ async function _s(e, t, s) {
|
|
|
685
685
|
}
|
|
686
686
|
return o;
|
|
687
687
|
}
|
|
688
|
-
async function
|
|
688
|
+
async function Ws(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 (b(c))
|
|
693
693
|
throw new Error(`[nimpress] modules create: ${c} exists`);
|
|
694
|
-
const { mkdir:
|
|
695
|
-
await
|
|
694
|
+
const { mkdir: p } = await import("node:fs/promises");
|
|
695
|
+
await p(i, { recursive: !0 });
|
|
696
696
|
const a = r.package;
|
|
697
|
-
await
|
|
697
|
+
await q(
|
|
698
698
|
c,
|
|
699
699
|
`---
|
|
700
700
|
title: ${n}
|
|
@@ -712,18 +712,18 @@ import { ${n} } from "${a ?? s}";
|
|
|
712
712
|
\`\`\`
|
|
713
713
|
`
|
|
714
714
|
);
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const
|
|
718
|
-
await me(i, n, await pe(
|
|
715
|
+
const l = Me(e, t.modules, s, n);
|
|
716
|
+
if (l) {
|
|
717
|
+
const u = o ?? yt(l.componentFile) ?? r.framework;
|
|
718
|
+
await me(i, n, await pe(l.componentFile, u, n)), await Le(e, t, s, n, o);
|
|
719
719
|
} else {
|
|
720
|
-
const
|
|
721
|
-
await
|
|
720
|
+
const u = r.framework === "vue" ? "vueStory" : "svelteStory";
|
|
721
|
+
await q(
|
|
722
722
|
d(i, "default.story.tsx"),
|
|
723
|
-
`import { ${
|
|
723
|
+
`import { ${u} } from '@nimtech/nimpress/story'
|
|
724
724
|
|
|
725
725
|
// story: Default
|
|
726
|
-
export default ${
|
|
726
|
+
export default ${u}({
|
|
727
727
|
name: "Default",
|
|
728
728
|
props: {}
|
|
729
729
|
})
|
|
@@ -744,7 +744,7 @@ function ye(e) {
|
|
|
744
744
|
function be(e, t = []) {
|
|
745
745
|
let s;
|
|
746
746
|
try {
|
|
747
|
-
s =
|
|
747
|
+
s = ie(e, { withFileTypes: !0 });
|
|
748
748
|
} catch {
|
|
749
749
|
return t;
|
|
750
750
|
}
|
|
@@ -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 p = 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 "./${D(g).replace(/\.ts$/, "")}"`;
|
|
@@ -799,7 +799,7 @@ function Te(e) {
|
|
|
799
799
|
`);
|
|
800
800
|
let a = t.slice(s.slice(0, o).join(`
|
|
801
801
|
`).length);
|
|
802
|
-
const
|
|
802
|
+
const l = (f) => {
|
|
803
803
|
const h = a.search(f);
|
|
804
804
|
if (h < 0) return;
|
|
805
805
|
const g = a.indexOf("{", h);
|
|
@@ -811,24 +811,24 @@ function Te(e) {
|
|
|
811
811
|
const w = $e(a, g + 1), k = g + 1 + w.length + 1, j = a.slice(k).match(/^[^\n]*/)?.[0] ?? "";
|
|
812
812
|
a = a.slice(0, h) + a.slice(k + j.length);
|
|
813
813
|
};
|
|
814
|
-
|
|
815
|
-
let
|
|
816
|
-
for (; /^(?:export )?interface \w+/m.test(a) &&
|
|
817
|
-
|
|
814
|
+
l(/^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 u = 0;
|
|
816
|
+
for (; /^(?:export )?interface \w+/m.test(a) && u < 50; )
|
|
817
|
+
l(/^(?:export )?interface \w+[^\n]*/m), u++;
|
|
818
818
|
let m = 0;
|
|
819
819
|
for (; /^export const \w+/m.test(a) && m < 200; )
|
|
820
|
-
|
|
820
|
+
l(/^export const \w+[^\n]*/m), m++;
|
|
821
821
|
return {
|
|
822
822
|
file: 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: p,
|
|
827
827
|
declarations: a.trim(),
|
|
828
828
|
dataModules: i
|
|
829
829
|
};
|
|
830
830
|
}
|
|
831
|
-
function
|
|
831
|
+
function Ts(e, t) {
|
|
832
832
|
const s = e.indexOf(":", t) + 1;
|
|
833
833
|
let n = 0, o = null;
|
|
834
834
|
for (let r = s; r < e.length; r++) {
|
|
@@ -847,10 +847,10 @@ function Ws(e, t) {
|
|
|
847
847
|
}
|
|
848
848
|
return e.slice(s).trim();
|
|
849
849
|
}
|
|
850
|
-
function
|
|
850
|
+
function bt(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 vt(e) {
|
|
854
854
|
const t = [], s = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
|
|
855
855
|
let n;
|
|
856
856
|
for (; n = s.exec(e.text); ) {
|
|
@@ -858,35 +858,35 @@ function bt(e) {
|
|
|
858
858
|
if (o === "default" || o === "meta") continue;
|
|
859
859
|
const r = $e(e.text, s.lastIndex), i = r.search(/\brender\s*:/);
|
|
860
860
|
if (i >= 0) {
|
|
861
|
-
const a =
|
|
861
|
+
const a = Ts(r, i);
|
|
862
862
|
if (a) {
|
|
863
863
|
t.push({ name: o, renderFn: a });
|
|
864
864
|
continue;
|
|
865
865
|
}
|
|
866
866
|
}
|
|
867
867
|
const c = r.search(/\bargs\s*:/);
|
|
868
|
-
let
|
|
868
|
+
let p = {};
|
|
869
869
|
if (c >= 0) {
|
|
870
870
|
const a = r.indexOf("{", c);
|
|
871
871
|
if (a >= 0) {
|
|
872
|
-
const
|
|
872
|
+
const l = $e(r, a + 1);
|
|
873
873
|
try {
|
|
874
|
-
|
|
875
|
-
return {${
|
|
874
|
+
p = ye(new Function(`${bt(e.declarations)}
|
|
875
|
+
return {${l}}`)());
|
|
876
876
|
} catch {
|
|
877
877
|
try {
|
|
878
|
-
|
|
878
|
+
p = ye(new Function(`return {${l}}`)());
|
|
879
879
|
} catch {
|
|
880
|
-
|
|
880
|
+
p = {};
|
|
881
881
|
}
|
|
882
882
|
}
|
|
883
883
|
}
|
|
884
884
|
}
|
|
885
|
-
t.push({ name: o, props:
|
|
885
|
+
t.push({ name: o, props: p });
|
|
886
886
|
}
|
|
887
887
|
return t;
|
|
888
888
|
}
|
|
889
|
-
function
|
|
889
|
+
function kt(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 vt(e) {
|
|
|
896
896
|
} catch {
|
|
897
897
|
try {
|
|
898
898
|
o = ye(
|
|
899
|
-
new Function(`${
|
|
899
|
+
new Function(`${bt(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 p = c.control, a = typeof p == "string" ? p : String(p?.type ?? ""), l = c.options ?? (typeof p == "object" ? p?.options : void 0), u = {};
|
|
910
|
+
typeof c.description == "string" && (u.description = c.description), Array.isArray(l) ? u.enum = l : a === "boolean" ? u.type = "boolean" : a === "number" || a === "range" ? u.type = "number" : a === "text" || a === "color" || a === "date" ? u.type = "string" : a === "object" && (u.type = "object"), c.defaultValue !== void 0 && (u.default = c.defaultValue), Object.keys(u).length && (r[i] = u);
|
|
911
911
|
}
|
|
912
912
|
return Object.keys(r).length ? r : void 0;
|
|
913
913
|
}
|
|
914
|
-
async function
|
|
914
|
+
async function xt(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 = mt({ 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 kt(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 p = new RegExp(c[1]);
|
|
929
|
+
for (const a of t) p.test(a) && r.add(a);
|
|
930
930
|
continue;
|
|
931
931
|
}
|
|
932
932
|
if (/^\d+$/.test(i)) {
|
|
933
|
-
const
|
|
934
|
-
|
|
933
|
+
const p = t[Number(i) - 1];
|
|
934
|
+
p && r.add(p);
|
|
935
935
|
continue;
|
|
936
936
|
}
|
|
937
|
-
for (const
|
|
937
|
+
for (const p of t) p === i && r.add(p);
|
|
938
938
|
}
|
|
939
939
|
return r;
|
|
940
940
|
}
|
|
941
|
-
function
|
|
941
|
+
function St(e, t) {
|
|
942
942
|
const s = /* @__PURE__ */ new Map(), n = d(e, "node_modules", t, "index.mjs");
|
|
943
943
|
if (!b(n)) return s;
|
|
944
944
|
const o = C(n, "utf-8");
|
|
@@ -946,47 +946,47 @@ function xt(e, t) {
|
|
|
946
946
|
s.set(r[1].toLowerCase(), r[1]);
|
|
947
947
|
return s;
|
|
948
948
|
}
|
|
949
|
-
async function
|
|
949
|
+
async function Ps(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"), p = o.package, a = n.match ? new RegExp(n.match) : null;
|
|
953
953
|
if (n.file) {
|
|
954
954
|
const $ = x(e, n.file);
|
|
955
955
|
if (!b($)) throw new Error(`[nimpress] modules import: ${$} not found`);
|
|
956
956
|
if (fe($) !== i)
|
|
957
957
|
throw new Error(`[nimpress] modules import: ${$} does not match system framework ${r}`);
|
|
958
|
-
const y = n.name ?? D($, i),
|
|
958
|
+
const y = n.name ?? D($, i), I = o.source ? x(e, o.source) : e, P = d(c, "Components", y);
|
|
959
959
|
await _e(P, { recursive: !0 });
|
|
960
|
-
const A = F(
|
|
961
|
-
await
|
|
960
|
+
const A = F(I, $);
|
|
961
|
+
await q(d(P, "index.md"), Pe(s, y, p, A)), await me(P, y, await pe($, r, y)), console.log(`nimpress modules: imported ${y} at ${F(e, P)}`);
|
|
962
962
|
return;
|
|
963
963
|
}
|
|
964
964
|
if (n.fromStories) {
|
|
965
|
-
await
|
|
965
|
+
await Rs(e, t, s, n);
|
|
966
966
|
return;
|
|
967
967
|
}
|
|
968
|
-
const
|
|
969
|
-
if (!b(
|
|
970
|
-
throw new Error(`[nimpress] modules import: source ${
|
|
971
|
-
const
|
|
968
|
+
const l = x(e, n.source ?? o.source ?? "");
|
|
969
|
+
if (!b(l))
|
|
970
|
+
throw new Error(`[nimpress] modules import: source ${l} not found`);
|
|
971
|
+
const u = be(l), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = u.filter(($) => $.endsWith(".stories.ts")), g = n.stories ? [x(e, n.stories)] : [];
|
|
972
972
|
for (const $ of g)
|
|
973
973
|
for (const y of be($))
|
|
974
974
|
y.endsWith(".stories.ts") && h.push(y);
|
|
975
|
-
const w =
|
|
975
|
+
const w = u.filter(
|
|
976
976
|
($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(D($, i))
|
|
977
|
-
), k = new Set(w.map(($) => D($, i))), j =
|
|
977
|
+
), k = new Set(w.map(($) => D($, i))), j = p && !o.source ? St(e, p) : null;
|
|
978
978
|
for (const $ of h) {
|
|
979
979
|
const y = Te($);
|
|
980
980
|
if (y.title?.includes("/")) {
|
|
981
|
-
const [G,
|
|
982
|
-
m.set(
|
|
981
|
+
const [G, J] = y.title.split("/");
|
|
982
|
+
m.set(J, G.replace(/\s+/g, ""));
|
|
983
983
|
}
|
|
984
|
-
const
|
|
985
|
-
let A = b(d(N($), `${
|
|
984
|
+
const I = D($, ".stories.ts");
|
|
985
|
+
let A = b(d(N($), `${I}${i}`)) ? I : y.metaComponent ?? I;
|
|
986
986
|
if (!k.has(A)) {
|
|
987
987
|
let G = "";
|
|
988
|
-
for (const
|
|
989
|
-
|
|
988
|
+
for (const J of k)
|
|
989
|
+
I.startsWith(J) && J.length > G.length && (G = J);
|
|
990
990
|
G ? A = G : console.warn(`nimpress modules: ${D($)} targets ${A} which has no component page`);
|
|
991
991
|
}
|
|
992
992
|
const S = j?.get(A.toLowerCase()) ?? A, Z = f.get(S) ?? [];
|
|
@@ -994,7 +994,7 @@ async function Ts(e, t, s, n) {
|
|
|
994
994
|
}
|
|
995
995
|
const E = /* @__PURE__ */ new Map();
|
|
996
996
|
let v = 0, R = 0;
|
|
997
|
-
const O = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await
|
|
997
|
+
const O = w.filter(($) => !a || a.test(D($, i))), T = n.select ? await xt(O.map(($) => D($, i))) : null;
|
|
998
998
|
for (const $ of O) {
|
|
999
999
|
const y = D($, i);
|
|
1000
1000
|
if (T && !T.has(y)) continue;
|
|
@@ -1002,38 +1002,38 @@ async function Ts(e, t, s, n) {
|
|
|
1002
1002
|
console.warn(`nimpress modules: skip duplicate ${y}, kept ${E.get(y)}`);
|
|
1003
1003
|
continue;
|
|
1004
1004
|
}
|
|
1005
|
-
E.set(y, F(
|
|
1006
|
-
const
|
|
1005
|
+
E.set(y, F(l, $));
|
|
1006
|
+
const I = m.get(y) ?? "Components", P = d(c, I, y);
|
|
1007
1007
|
await _e(P, { recursive: !0 });
|
|
1008
|
-
const A = F(
|
|
1009
|
-
(H,
|
|
1008
|
+
const A = F(l, $), S = A === `${y}/${y}${i}` || A === `${y}${i}`, Z = (f.get(y) ?? []).map((H) => kt(H)).reduce(
|
|
1009
|
+
(H, se) => se ? { ...H ?? {}, ...se } : H,
|
|
1010
1010
|
void 0
|
|
1011
1011
|
);
|
|
1012
|
-
await
|
|
1013
|
-
const G = f.get(y) ?? [],
|
|
1012
|
+
await q(d(P, "index.md"), Pe(s, y, p, S ? void 0 : A)), await me(P, y, await pe($, r, y)), Z && await it(P, { properties: Z }), v++;
|
|
1013
|
+
const G = f.get(y) ?? [], J = /* @__PURE__ */ new Set();
|
|
1014
1014
|
for (const H of G) {
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1015
|
+
const se = D(H.file, ".stories.ts"), Je = vt(H);
|
|
1016
|
+
Je.length || console.warn(`nimpress modules: no stories mined from ${D(H.file)}`);
|
|
1017
1017
|
for (const Q of H.dataModules)
|
|
1018
|
-
await
|
|
1019
|
-
for (const Q of
|
|
1020
|
-
const
|
|
1021
|
-
let he = We(
|
|
1022
|
-
|
|
1018
|
+
await ct(Q, d(P, D(Q)));
|
|
1019
|
+
for (const Q of Je) {
|
|
1020
|
+
const ze = Q.name === y ? "Default" : se === y ? Q.name : `${se} ${Q.name}`;
|
|
1021
|
+
let he = We(ze);
|
|
1022
|
+
J.has(he) && (he = We(`${se}-${Q.name}`));
|
|
1023
1023
|
const Be = d(P, `${he}.story.tsx`);
|
|
1024
|
-
|
|
1024
|
+
J.add(he), !b(Be) && (await q(Be, jt(r, ze, se, Q, H)), R++);
|
|
1025
1025
|
}
|
|
1026
1026
|
}
|
|
1027
1027
|
}
|
|
1028
1028
|
console.log(`nimpress modules: imported ${v} components with ${R} stories for ${s}`);
|
|
1029
1029
|
}
|
|
1030
|
-
async function
|
|
1030
|
+
async function Rs(e, t, s, n) {
|
|
1031
1031
|
const o = t.modules.systems[s], r = o.framework, i = d(e, t.contentDir, "components"), c = x(e, n.stories ?? "");
|
|
1032
1032
|
if (!n.stories || !b(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 p = o.source ? x(e, o.source) : e, a = n.match ? new RegExp(n.match) : null, l = /* @__PURE__ */ new Set();
|
|
1035
|
+
let u = 0, m = 0;
|
|
1036
|
+
const f = be(c).filter((g) => g.endsWith(".stories.ts")), h = n.select ? await xt(
|
|
1037
1037
|
f.map((g) => Te(g).metaComponent ?? D(g, ".stories.ts"))
|
|
1038
1038
|
) : null;
|
|
1039
1039
|
for (const g of f) {
|
|
@@ -1045,42 +1045,42 @@ async function Ps(e, t, s, n) {
|
|
|
1045
1045
|
let v = j, R = o.package, O;
|
|
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
|
-
R = S, v =
|
|
1048
|
+
R = S, v = St(e, S).get(j.toLowerCase()) ?? j;
|
|
1049
1049
|
} else if (E?.startsWith("@/components/")) {
|
|
1050
1050
|
const S = E.slice(13);
|
|
1051
1051
|
S === v || S === `${v}/${v}.vue` || (O = S.endsWith(".vue") || S.endsWith(".svelte") ? S : `${S}/${v}.vue`);
|
|
1052
1052
|
} else if (E?.startsWith(".")) {
|
|
1053
1053
|
const S = x(N(g), E);
|
|
1054
|
-
O = F(
|
|
1054
|
+
O = F(p, S);
|
|
1055
1055
|
}
|
|
1056
1056
|
if (a && !a.test(v)) continue;
|
|
1057
|
-
if (
|
|
1057
|
+
if (l.has(v)) {
|
|
1058
1058
|
console.warn(`nimpress modules: skip duplicate ${v} from ${D(g)}`);
|
|
1059
1059
|
continue;
|
|
1060
1060
|
}
|
|
1061
|
-
|
|
1061
|
+
l.add(v);
|
|
1062
1062
|
const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, v);
|
|
1063
|
-
await _e($, { recursive: !0 }), await
|
|
1064
|
-
const y = r === "vue" ? ".vue" : ".svelte", P = (O ? [x(
|
|
1065
|
-
d(
|
|
1066
|
-
d(
|
|
1063
|
+
await _e($, { recursive: !0 }), await q(d($, "index.md"), Pe(s, v, R, O));
|
|
1064
|
+
const y = r === "vue" ? ".vue" : ".svelte", P = (O ? [x(p, O)] : [
|
|
1065
|
+
d(p, v, `${v}${y}`),
|
|
1066
|
+
d(p, `${v}${y}`)
|
|
1067
1067
|
]).find((S) => b(S));
|
|
1068
1068
|
if (P)
|
|
1069
1069
|
await me($, v, await pe(P, r, v));
|
|
1070
1070
|
else if (R) {
|
|
1071
|
-
const S =
|
|
1072
|
-
S ? await me($, v,
|
|
1071
|
+
const S = qt(e, R, v);
|
|
1072
|
+
S ? await me($, v, es(C(S, "utf-8"), v)) : console.warn(`nimpress modules: no source or d.ts found for ${v}, the schema seed is skipped`);
|
|
1073
1073
|
}
|
|
1074
|
-
const A =
|
|
1075
|
-
A && await
|
|
1074
|
+
const A = kt(w);
|
|
1075
|
+
A && await it($, { properties: A }), u++;
|
|
1076
1076
|
for (const S of w.dataModules)
|
|
1077
|
-
await
|
|
1078
|
-
for (const S of
|
|
1079
|
-
const Z = S.name === v ? "Default" : S.name, G = We(Z),
|
|
1080
|
-
b(
|
|
1077
|
+
await ct(S, d($, D(S)));
|
|
1078
|
+
for (const S of vt(w)) {
|
|
1079
|
+
const Z = S.name === v ? "Default" : S.name, G = We(Z), J = d($, `${G}.story.tsx`);
|
|
1080
|
+
b(J) || (await q(J, jt(r, Z, k, S, w)), m++);
|
|
1081
1081
|
}
|
|
1082
1082
|
}
|
|
1083
|
-
console.log(`nimpress modules: imported ${
|
|
1083
|
+
console.log(`nimpress modules: imported ${u} components with ${m} stories for ${s} from stories`);
|
|
1084
1084
|
}
|
|
1085
1085
|
function Pe(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 jt(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}
|
|
@@ -1123,7 +1123,7 @@ export default ${r}({
|
|
|
1123
1123
|
})
|
|
1124
1124
|
`;
|
|
1125
1125
|
}
|
|
1126
|
-
function
|
|
1126
|
+
function ae(e, t) {
|
|
1127
1127
|
const s = _(t, "system");
|
|
1128
1128
|
if (s === void 0) return;
|
|
1129
1129
|
const n = Object.keys(e.modules.systems);
|
|
@@ -1132,7 +1132,7 @@ function ue(e, t) {
|
|
|
1132
1132
|
return s;
|
|
1133
1133
|
}
|
|
1134
1134
|
function je(e, t, s) {
|
|
1135
|
-
const n =
|
|
1135
|
+
const n = ae(e, t);
|
|
1136
1136
|
if (n) return n;
|
|
1137
1137
|
const o = Object.keys(e.modules.systems);
|
|
1138
1138
|
if (o.length === 1) return o[0];
|
|
@@ -1140,43 +1140,64 @@ 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 As(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
|
+
Ms(e, t);
|
|
1147
1147
|
return;
|
|
1148
1148
|
}
|
|
1149
1149
|
if (n === "dev") {
|
|
1150
|
-
const i =
|
|
1150
|
+
const i = ae(t, o), c = i ? [i] : r;
|
|
1151
1151
|
if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
|
|
1152
|
-
await
|
|
1152
|
+
await gt(e, t, c), await new Promise(() => {
|
|
1153
1153
|
});
|
|
1154
1154
|
}
|
|
1155
1155
|
if (n === "build") {
|
|
1156
|
-
const i =
|
|
1156
|
+
const i = ae(t, o), c = i ? [i] : ht(t);
|
|
1157
1157
|
if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
|
|
1158
|
-
await
|
|
1158
|
+
await wt(e, t, c);
|
|
1159
1159
|
return;
|
|
1160
1160
|
}
|
|
1161
1161
|
if (n === "lint") {
|
|
1162
|
-
const i = await
|
|
1162
|
+
const i = await dt(e, t, ae(t, o));
|
|
1163
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 =
|
|
1167
|
+
const i = je(t, o, "story"), c = ne(o, 0), p = _(o, "framework");
|
|
1168
1168
|
if (c) {
|
|
1169
|
-
const
|
|
1170
|
-
|
|
1169
|
+
const l = await Le(e, t, i, c, p);
|
|
1170
|
+
l && console.log(`nimpress modules: story written to ${l}`);
|
|
1171
1171
|
return;
|
|
1172
1172
|
}
|
|
1173
|
-
const a = await
|
|
1173
|
+
const a = await Ns(e, t, i);
|
|
1174
1174
|
console.log(`nimpress modules: ${a} auto stories written for ${i}`);
|
|
1175
1175
|
return;
|
|
1176
1176
|
}
|
|
1177
|
+
if (n === "stories") {
|
|
1178
|
+
const i = ne(o, 0), c = ae(t, o), p = await He(e, t, { component: i, system: c });
|
|
1179
|
+
if (i && !p.length) {
|
|
1180
|
+
const a = (await He(e, t, { system: c })).map((l) => `${l.system}/${l.component}`).filter((l, u, m) => m.indexOf(l) === u && l.toLowerCase().includes(i.toLowerCase()));
|
|
1181
|
+
throw new Error(
|
|
1182
|
+
`[nimpress] modules stories: no stories for ${i}${c ? ` in ${c}` : ""}` + (a.length ? `, did you mean ${a.slice(0, 8).join(", ")}` : "")
|
|
1183
|
+
);
|
|
1184
|
+
}
|
|
1185
|
+
if (M(o, "json")) {
|
|
1186
|
+
console.log(JSON.stringify(p, null, 2));
|
|
1187
|
+
return;
|
|
1188
|
+
}
|
|
1189
|
+
if (!i) {
|
|
1190
|
+
const a = /* @__PURE__ */ new Map();
|
|
1191
|
+
for (const l of p) a.set(`${l.system} ${l.component}`, (a.get(`${l.system} ${l.component}`) ?? 0) + 1);
|
|
1192
|
+
for (const [l, u] of a) console.log(`${l} ${u}`);
|
|
1193
|
+
return;
|
|
1194
|
+
}
|
|
1195
|
+
for (const a of p) console.log(`${a.system} ${a.component} ${a.story} ${a.route}`);
|
|
1196
|
+
return;
|
|
1197
|
+
}
|
|
1177
1198
|
if (n === "import") {
|
|
1178
|
-
const i = je(t, o, "import"), c =
|
|
1179
|
-
await
|
|
1199
|
+
const i = je(t, o, "import"), c = ne(o, 0);
|
|
1200
|
+
await Ps(e, t, i, {
|
|
1180
1201
|
file: c,
|
|
1181
1202
|
name: _(o, "name"),
|
|
1182
1203
|
source: _(o, "source"),
|
|
@@ -1188,29 +1209,29 @@ async function Rs(e, t, s) {
|
|
|
1188
1209
|
return;
|
|
1189
1210
|
}
|
|
1190
1211
|
if (n === "update") {
|
|
1191
|
-
const i = _(o, "component") ??
|
|
1212
|
+
const i = _(o, "component") ?? ne(o, 0), c = await ts(e, t, { ref: i, system: ae(t, o) });
|
|
1192
1213
|
console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), De(e);
|
|
1193
1214
|
return;
|
|
1194
1215
|
}
|
|
1195
1216
|
if (n === "create") {
|
|
1196
1217
|
const i = _(o, "component");
|
|
1197
1218
|
if (i) {
|
|
1198
|
-
if (!
|
|
1219
|
+
if (!M(o, "schema"))
|
|
1199
1220
|
throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
|
|
1200
|
-
const
|
|
1201
|
-
console.log(`nimpress modules: schema upserted at ${
|
|
1221
|
+
const u = await ss(e, t, i);
|
|
1222
|
+
console.log(`nimpress modules: schema upserted at ${u}`);
|
|
1202
1223
|
return;
|
|
1203
1224
|
}
|
|
1204
|
-
const c =
|
|
1225
|
+
const c = ne(o, 0);
|
|
1205
1226
|
if (!c)
|
|
1206
1227
|
throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
|
|
1207
|
-
const
|
|
1208
|
-
console.log(`nimpress modules: created ${c} at ${F(e,
|
|
1228
|
+
const p = je(t, o, "create"), a = _(o, "framework"), l = await Ws(e, t, p, c, a);
|
|
1229
|
+
console.log(`nimpress modules: created ${c} at ${F(e, l)}`);
|
|
1209
1230
|
return;
|
|
1210
1231
|
}
|
|
1211
|
-
throw new Error("[nimpress] modules expects init, dev, build, lint, story, import, create or update");
|
|
1232
|
+
throw new Error("[nimpress] modules expects init, dev, build, lint, story, stories, import, create or update");
|
|
1212
1233
|
}
|
|
1213
|
-
function
|
|
1234
|
+
function Ms(e, t) {
|
|
1214
1235
|
const s = d(e, t.modules.dir);
|
|
1215
1236
|
B(s, { recursive: !0 });
|
|
1216
1237
|
const n = d(e, "nimpress.config.json");
|
|
@@ -1222,14 +1243,14 @@ function As(e, t) {
|
|
|
1222
1243
|
console.log("nimpress modules: add a modules block with systems entries to your nimpress config");
|
|
1223
1244
|
console.log(`nimpress modules: folder ready at ${s}`);
|
|
1224
1245
|
}
|
|
1225
|
-
function
|
|
1246
|
+
function Ct(e) {
|
|
1226
1247
|
if (!e.startsWith(`---
|
|
1227
1248
|
`)) return null;
|
|
1228
1249
|
const t = e.indexOf(`
|
|
1229
1250
|
---`, 4);
|
|
1230
1251
|
return t < 0 ? null : e.slice(4, t);
|
|
1231
1252
|
}
|
|
1232
|
-
function
|
|
1253
|
+
function Is(e) {
|
|
1233
1254
|
for (const t of e.split(`
|
|
1234
1255
|
`)) {
|
|
1235
1256
|
if (!t.startsWith("export:")) continue;
|
|
@@ -1238,8 +1259,8 @@ function Ms(e) {
|
|
|
1238
1259
|
}
|
|
1239
1260
|
return null;
|
|
1240
1261
|
}
|
|
1241
|
-
function
|
|
1242
|
-
const s =
|
|
1262
|
+
function Ls(e, t) {
|
|
1263
|
+
const s = Ct(e);
|
|
1243
1264
|
if (s === null) return e;
|
|
1244
1265
|
const n = s.split(`
|
|
1245
1266
|
`).filter((r) => !r.startsWith("export:") && !r.startsWith(" file:")), o = n.findIndex((r) => r.startsWith(" package:"));
|
|
@@ -1256,20 +1277,20 @@ function Re(e, t, s) {
|
|
|
1256
1277
|
i = "";
|
|
1257
1278
|
}
|
|
1258
1279
|
let c = 0;
|
|
1259
|
-
for (const
|
|
1260
|
-
if (!
|
|
1261
|
-
const a = C(
|
|
1262
|
-
if (
|
|
1263
|
-
const
|
|
1264
|
-
if (
|
|
1265
|
-
const m = N(
|
|
1280
|
+
for (const p of Y(r)) {
|
|
1281
|
+
if (!p.endsWith(".md")) continue;
|
|
1282
|
+
const a = C(p, "utf-8"), l = Ct(a);
|
|
1283
|
+
if (l === null) continue;
|
|
1284
|
+
const u = Is(l);
|
|
1285
|
+
if (u === null || n && u !== n && u !== "true") continue;
|
|
1286
|
+
const m = N(p), f = d(o, F(r, m));
|
|
1266
1287
|
B(f, { recursive: !0 });
|
|
1267
|
-
for (const h of
|
|
1288
|
+
for (const h of ie(m, { withFileTypes: !0 })) {
|
|
1268
1289
|
if (!h.isFile()) continue;
|
|
1269
1290
|
const g = C(d(m, h.name), "utf-8");
|
|
1270
1291
|
W(
|
|
1271
1292
|
d(f, h.name),
|
|
1272
|
-
h.name.endsWith(".md") ?
|
|
1293
|
+
h.name.endsWith(".md") ? Ls(g, i) : g
|
|
1273
1294
|
);
|
|
1274
1295
|
}
|
|
1275
1296
|
c++;
|
|
@@ -1277,8 +1298,8 @@ function Re(e, t, s) {
|
|
|
1277
1298
|
console.log(`nimpress export: ${c} pages collected into ${o}`);
|
|
1278
1299
|
}
|
|
1279
1300
|
const Ce = d(".claude", "skills", "nimpress", "SKILL.md");
|
|
1280
|
-
function
|
|
1281
|
-
const e = N(
|
|
1301
|
+
function Et() {
|
|
1302
|
+
const e = N(ft(import.meta.url)), t = [
|
|
1282
1303
|
x(e, Ce),
|
|
1283
1304
|
x(e, "..", Ce),
|
|
1284
1305
|
x(e, "..", "..", Ce)
|
|
@@ -1290,47 +1311,47 @@ function Ct() {
|
|
|
1290
1311
|
}
|
|
1291
1312
|
throw new Error(`[nimpress] skill: SKILL.md not found, looked in ${t.join(", ")}`);
|
|
1292
1313
|
}
|
|
1293
|
-
function
|
|
1314
|
+
function Ot(e, t) {
|
|
1294
1315
|
const s = t ? d(K(), ".claude") : d(e, ".claude"), n = d(s, "skills", "nimpress");
|
|
1295
1316
|
B(n, { recursive: !0 });
|
|
1296
1317
|
const o = d(n, "SKILL.md");
|
|
1297
|
-
return W(o,
|
|
1318
|
+
return W(o, Et()), console.log(`wrote ${o}`), o;
|
|
1298
1319
|
}
|
|
1299
|
-
function
|
|
1320
|
+
function Js(e, t) {
|
|
1300
1321
|
const s = t[0];
|
|
1301
1322
|
if (s === "get") {
|
|
1302
|
-
process.stdout.write(
|
|
1323
|
+
process.stdout.write(Et());
|
|
1303
1324
|
return;
|
|
1304
1325
|
}
|
|
1305
1326
|
if (s === "put") {
|
|
1306
|
-
|
|
1327
|
+
Ot(e, !M(t, "project"));
|
|
1307
1328
|
return;
|
|
1308
1329
|
}
|
|
1309
1330
|
throw new Error("[nimpress] skill expects get or put");
|
|
1310
1331
|
}
|
|
1311
|
-
const zs = "nimling/nimpress",
|
|
1312
|
-
function
|
|
1332
|
+
const zs = "nimling/nimpress", Bs = "nimpress@nimpress";
|
|
1333
|
+
function Ke(e, t) {
|
|
1313
1334
|
console.log(`claude ${t.join(" ")}`);
|
|
1314
|
-
const s =
|
|
1335
|
+
const s = te("claude", t, { cwd: e, stdio: "inherit" });
|
|
1315
1336
|
if (s.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${s.error.message}`);
|
|
1316
1337
|
if (s.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${s.status}`);
|
|
1317
1338
|
}
|
|
1318
|
-
function
|
|
1339
|
+
function Gs(e, t) {
|
|
1319
1340
|
const s = t ? "user" : "project";
|
|
1320
|
-
|
|
1341
|
+
Ke(e, ["plugin", "marketplace", "add", zs, "--scope", s]), Ke(e, ["plugin", "install", Bs, "--scope", s]);
|
|
1321
1342
|
}
|
|
1322
|
-
function
|
|
1343
|
+
function Hs(e, t) {
|
|
1323
1344
|
if (t[0] === "put") {
|
|
1324
|
-
|
|
1345
|
+
Gs(e, !M(t, "project"));
|
|
1325
1346
|
return;
|
|
1326
1347
|
}
|
|
1327
1348
|
throw new Error("[nimpress] plugin expects put");
|
|
1328
1349
|
}
|
|
1329
|
-
const
|
|
1350
|
+
const X = {
|
|
1330
1351
|
name: "--system",
|
|
1331
1352
|
value: !0,
|
|
1332
1353
|
describe: "the configured component system to act on"
|
|
1333
|
-
},
|
|
1354
|
+
}, Ye = {
|
|
1334
1355
|
name: "--framework",
|
|
1335
1356
|
value: !0,
|
|
1336
1357
|
describe: "vue or svelte, overriding the framework of the system"
|
|
@@ -1371,15 +1392,21 @@ const se = {
|
|
|
1371
1392
|
flags: [],
|
|
1372
1393
|
subs: [
|
|
1373
1394
|
{ name: "init", describe: "Create the modules folder and the config block", flags: [], subs: [] },
|
|
1374
|
-
{ name: "dev", describe: "Serve the harnesses and stay running", flags: [
|
|
1375
|
-
{ name: "build", describe: "Build the harness bundles", flags: [
|
|
1376
|
-
{ name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [
|
|
1377
|
-
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [
|
|
1395
|
+
{ name: "dev", describe: "Serve the harnesses and stay running", flags: [X], subs: [] },
|
|
1396
|
+
{ name: "build", describe: "Build the harness bundles", flags: [X], subs: [] },
|
|
1397
|
+
{ name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [X], subs: [] },
|
|
1398
|
+
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [X, Ye], subs: [] },
|
|
1399
|
+
{
|
|
1400
|
+
name: "stories",
|
|
1401
|
+
describe: "List the stories of one component in every system that carries it, with the harness route that renders each story alone, or every component and its story count",
|
|
1402
|
+
flags: [X, { name: "--json", value: !1, describe: "print the routes as json" }],
|
|
1403
|
+
subs: []
|
|
1404
|
+
},
|
|
1378
1405
|
{
|
|
1379
1406
|
name: "import",
|
|
1380
1407
|
describe: "Import components and storybook stories into component pages",
|
|
1381
1408
|
flags: [
|
|
1382
|
-
|
|
1409
|
+
X,
|
|
1383
1410
|
{ name: "--name", value: !0, describe: "the component name when a single file is imported" },
|
|
1384
1411
|
{ name: "--source", value: !0, describe: "the component source root, overriding the system source" },
|
|
1385
1412
|
{ name: "--stories", value: !0, describe: "an extra folder of storybook csf files" },
|
|
@@ -1393,8 +1420,8 @@ const se = {
|
|
|
1393
1420
|
name: "create",
|
|
1394
1421
|
describe: "Create a component page, or upsert one schema",
|
|
1395
1422
|
flags: [
|
|
1396
|
-
|
|
1397
|
-
|
|
1423
|
+
X,
|
|
1424
|
+
Ye,
|
|
1398
1425
|
{ name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
|
|
1399
1426
|
{ name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
|
|
1400
1427
|
],
|
|
@@ -1403,7 +1430,7 @@ const se = {
|
|
|
1403
1430
|
{
|
|
1404
1431
|
name: "update",
|
|
1405
1432
|
describe: "Upsert the component schemas from the component types",
|
|
1406
|
-
flags: [
|
|
1433
|
+
flags: [X, { name: "--component", value: !0, describe: "limit the upsert to one component reference" }],
|
|
1407
1434
|
subs: []
|
|
1408
1435
|
}
|
|
1409
1436
|
]
|
|
@@ -1518,7 +1545,7 @@ const se = {
|
|
|
1518
1545
|
{ name: "powershell", describe: "the powershell completion script", flags: [], subs: [] }
|
|
1519
1546
|
]
|
|
1520
1547
|
}
|
|
1521
|
-
],
|
|
1548
|
+
], Ft = ["bash", "zsh", "fish", "powershell"];
|
|
1522
1549
|
function ke(e) {
|
|
1523
1550
|
const t = [];
|
|
1524
1551
|
for (const s of [...e.flags, ...e.subs.flatMap((n) => n.flags)])
|
|
@@ -1528,7 +1555,7 @@ function ke(e) {
|
|
|
1528
1555
|
function xe(e, t) {
|
|
1529
1556
|
return t && e.value ? `${e.name}=` : e.name;
|
|
1530
1557
|
}
|
|
1531
|
-
function
|
|
1558
|
+
function Us() {
|
|
1532
1559
|
const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
|
|
1533
1560
|
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
1561
|
for (const t of V) {
|
|
@@ -1544,7 +1571,7 @@ function Ee(e, t, s) {
|
|
|
1544
1571
|
for (const o of s) n.push(`${e} ${o}`);
|
|
1545
1572
|
return n.push(`${e})`), n.push(`${e}_describe '${t}' entries`), n.push(`${e}return`), n;
|
|
1546
1573
|
}
|
|
1547
|
-
function
|
|
1574
|
+
function Zs() {
|
|
1548
1575
|
const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
|
|
1549
1576
|
e.push(
|
|
1550
1577
|
...Ee(
|
|
@@ -1574,7 +1601,7 @@ function Us() {
|
|
|
1574
1601
|
`) + `
|
|
1575
1602
|
`;
|
|
1576
1603
|
}
|
|
1577
|
-
function
|
|
1604
|
+
function Vs() {
|
|
1578
1605
|
const e = ["complete -c nimpress -f"];
|
|
1579
1606
|
for (const t of V)
|
|
1580
1607
|
e.push(
|
|
@@ -1593,7 +1620,7 @@ function Zs() {
|
|
|
1593
1620
|
`) + `
|
|
1594
1621
|
`;
|
|
1595
1622
|
}
|
|
1596
|
-
function
|
|
1623
|
+
function Ks() {
|
|
1597
1624
|
const e = [
|
|
1598
1625
|
"Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
|
|
1599
1626
|
" param($wordToComplete, $commandAst, $cursorPosition)",
|
|
@@ -1612,14 +1639,14 @@ function Vs() {
|
|
|
1612
1639
|
`) + `
|
|
1613
1640
|
`;
|
|
1614
1641
|
}
|
|
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 ${
|
|
1642
|
+
function Dt(e) {
|
|
1643
|
+
if (e === "bash") return Us();
|
|
1644
|
+
if (e === "zsh") return Zs();
|
|
1645
|
+
if (e === "fish") return Vs();
|
|
1646
|
+
if (e === "powershell") return Ks();
|
|
1647
|
+
throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ft.join(", ")}`);
|
|
1621
1648
|
}
|
|
1622
|
-
function
|
|
1649
|
+
function Qe(e) {
|
|
1623
1650
|
return e === "fish" ? [
|
|
1624
1651
|
"function nimpress",
|
|
1625
1652
|
" if test -x node_modules/.bin/nimpress",
|
|
@@ -1641,13 +1668,13 @@ function Ye(e) {
|
|
|
1641
1668
|
].join(`
|
|
1642
1669
|
`);
|
|
1643
1670
|
}
|
|
1644
|
-
function
|
|
1671
|
+
function Ys() {
|
|
1645
1672
|
const e = D(process.env.SHELL ?? "");
|
|
1646
1673
|
for (const t of ["zsh", "bash", "fish"])
|
|
1647
1674
|
if (e.includes(t)) return t;
|
|
1648
1675
|
return "";
|
|
1649
1676
|
}
|
|
1650
|
-
function
|
|
1677
|
+
function Qs(e, t) {
|
|
1651
1678
|
const s = "# >>> nimpress completion >>>", n = "# <<< nimpress completion <<<", o = `${s}
|
|
1652
1679
|
${t}
|
|
1653
1680
|
${n}`, r = e.indexOf(s), i = e.indexOf(n);
|
|
@@ -1658,29 +1685,29 @@ ${n}`, r = e.indexOf(s), i = e.indexOf(n);
|
|
|
1658
1685
|
`) + o + `
|
|
1659
1686
|
`;
|
|
1660
1687
|
}
|
|
1661
|
-
function
|
|
1688
|
+
function Xs(e, t) {
|
|
1662
1689
|
let s = "";
|
|
1663
1690
|
try {
|
|
1664
1691
|
s = C(e, "utf-8");
|
|
1665
1692
|
} catch {
|
|
1666
1693
|
s = "";
|
|
1667
1694
|
}
|
|
1668
|
-
W(e,
|
|
1695
|
+
W(e, Qs(s, t));
|
|
1669
1696
|
}
|
|
1670
|
-
function
|
|
1671
|
-
const t = e ||
|
|
1697
|
+
function qs(e) {
|
|
1698
|
+
const t = e || Ys();
|
|
1672
1699
|
if (!t)
|
|
1673
1700
|
throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
|
|
1674
|
-
const s =
|
|
1701
|
+
const s = Dt(t), n = K();
|
|
1675
1702
|
if (t === "fish") {
|
|
1676
1703
|
const a = d(n, ".config", "fish", "completions");
|
|
1677
1704
|
B(a, { recursive: !0 });
|
|
1678
|
-
const
|
|
1679
|
-
W(
|
|
1680
|
-
const
|
|
1681
|
-
B(
|
|
1682
|
-
const m = d(
|
|
1683
|
-
W(m,
|
|
1705
|
+
const l = d(a, "nimpress.fish");
|
|
1706
|
+
W(l, s), console.log(`wrote ${l}`);
|
|
1707
|
+
const u = d(n, ".config", "fish", "functions");
|
|
1708
|
+
B(u, { recursive: !0 });
|
|
1709
|
+
const m = d(u, "nimpress.fish");
|
|
1710
|
+
W(m, Qe(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
|
|
1684
1711
|
return;
|
|
1685
1712
|
}
|
|
1686
1713
|
if (t !== "bash" && t !== "zsh")
|
|
@@ -1690,36 +1717,36 @@ function Xs(e) {
|
|
|
1690
1717
|
const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
|
|
1691
1718
|
W(r, s), console.log(`wrote ${r}`);
|
|
1692
1719
|
const i = d(n, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
|
|
1693
|
-
autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`,
|
|
1720
|
+
autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, p = `${Qe(t)}
|
|
1694
1721
|
${c}`;
|
|
1695
|
-
|
|
1722
|
+
Xs(i, p), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
|
|
1696
1723
|
}
|
|
1697
|
-
function
|
|
1698
|
-
const s =
|
|
1724
|
+
function en(e, t) {
|
|
1725
|
+
const s = ne(t, 0) ?? "", n = M(t, "auto"), o = M(t, "skill");
|
|
1699
1726
|
if (!n) {
|
|
1700
1727
|
if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
|
|
1701
|
-
if (!s) throw new Error(`[nimpress] completion: name a shell (${
|
|
1702
|
-
process.stdout.write(
|
|
1728
|
+
if (!s) throw new Error(`[nimpress] completion: name a shell (${Ft.join(", ")}) or pass --auto`);
|
|
1729
|
+
process.stdout.write(Dt(s));
|
|
1703
1730
|
return;
|
|
1704
1731
|
}
|
|
1705
|
-
|
|
1732
|
+
qs(s), o && Ot(e, !0);
|
|
1706
1733
|
}
|
|
1707
|
-
const
|
|
1708
|
-
function
|
|
1734
|
+
const tn = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), sn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), nn = 2e4, de = /* @__PURE__ */ new Map();
|
|
1735
|
+
function _t(e, t) {
|
|
1709
1736
|
const s = [...t, e.name];
|
|
1710
|
-
return e.subs.length ? e.subs.flatMap((n) =>
|
|
1737
|
+
return e.subs.length ? e.subs.flatMap((n) => _t(n, s)) : [
|
|
1711
1738
|
{
|
|
1712
1739
|
name: s.join("_"),
|
|
1713
1740
|
argv: s,
|
|
1714
1741
|
describe: e.describe,
|
|
1715
1742
|
flags: e.flags,
|
|
1716
|
-
serves:
|
|
1743
|
+
serves: sn.has(s.join(" "))
|
|
1717
1744
|
}
|
|
1718
1745
|
];
|
|
1719
1746
|
}
|
|
1720
|
-
const
|
|
1721
|
-
function
|
|
1722
|
-
const e = N(
|
|
1747
|
+
const Nt = V.filter((e) => !tn.has(e.name)).flatMap((e) => _t(e, []));
|
|
1748
|
+
function on() {
|
|
1749
|
+
const e = N(ft(import.meta.url));
|
|
1723
1750
|
for (const t of [x(e, "..", "package.json"), x(e, "..", "..", "package.json")])
|
|
1724
1751
|
try {
|
|
1725
1752
|
return JSON.parse(C(t, "utf-8")).version;
|
|
@@ -1727,7 +1754,7 @@ function nn() {
|
|
|
1727
1754
|
}
|
|
1728
1755
|
return "0.0.0";
|
|
1729
1756
|
}
|
|
1730
|
-
function
|
|
1757
|
+
function rn(e) {
|
|
1731
1758
|
const t = {};
|
|
1732
1759
|
for (const s of e.flags)
|
|
1733
1760
|
t[s.name.slice(2)] = { type: s.value ? "string" : "boolean", description: s.describe };
|
|
@@ -1741,12 +1768,12 @@ function on(e) {
|
|
|
1741
1768
|
additionalProperties: !1
|
|
1742
1769
|
};
|
|
1743
1770
|
}
|
|
1744
|
-
function
|
|
1771
|
+
function an() {
|
|
1745
1772
|
return [
|
|
1746
|
-
...
|
|
1773
|
+
...Nt.map((e) => ({
|
|
1747
1774
|
name: e.name,
|
|
1748
1775
|
description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
|
|
1749
|
-
inputSchema:
|
|
1776
|
+
inputSchema: rn(e)
|
|
1750
1777
|
})),
|
|
1751
1778
|
{
|
|
1752
1779
|
name: "stop",
|
|
@@ -1760,7 +1787,7 @@ function rn() {
|
|
|
1760
1787
|
}
|
|
1761
1788
|
];
|
|
1762
1789
|
}
|
|
1763
|
-
function
|
|
1790
|
+
function cn(e, t) {
|
|
1764
1791
|
const s = [...e.argv, ...t.args ?? []];
|
|
1765
1792
|
for (const [n, o] of Object.entries(t.flags ?? {}))
|
|
1766
1793
|
o === !0 ? s.push(`--${n}`) : typeof o == "string" && s.push(`--${n}=${o}`);
|
|
@@ -1769,89 +1796,89 @@ function an(e, t) {
|
|
|
1769
1796
|
function U(e, t = !1) {
|
|
1770
1797
|
return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
|
|
1771
1798
|
}
|
|
1772
|
-
function
|
|
1773
|
-
return Ie(process.execPath, [process.argv[1], ...
|
|
1799
|
+
function Wt(e, t, s) {
|
|
1800
|
+
return Ie(process.execPath, [process.argv[1], ...cn(t, s)], {
|
|
1774
1801
|
cwd: x(e, s.cwd ?? "."),
|
|
1775
1802
|
env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
|
|
1776
1803
|
stdio: ["ignore", "pipe", "pipe"]
|
|
1777
1804
|
});
|
|
1778
1805
|
}
|
|
1779
|
-
function
|
|
1780
|
-
const n =
|
|
1806
|
+
function ln(e, t, s) {
|
|
1807
|
+
const n = Wt(e, t, s);
|
|
1781
1808
|
let o = "";
|
|
1782
1809
|
return n.stdout?.on("data", (r) => o += r), n.stderr?.on("data", (r) => o += r), new Promise((r) => {
|
|
1783
1810
|
n.on("error", (i) => r(U(`${o}${i.message}`, !0))), n.on("close", (i) => r(U(o, i !== 0)));
|
|
1784
1811
|
});
|
|
1785
1812
|
}
|
|
1786
|
-
function
|
|
1787
|
-
const n =
|
|
1813
|
+
function un(e, t, s) {
|
|
1814
|
+
const n = Wt(e, t, s);
|
|
1788
1815
|
let o = "";
|
|
1789
1816
|
return new Promise((r) => {
|
|
1790
1817
|
const i = (a) => {
|
|
1791
|
-
clearTimeout(
|
|
1818
|
+
clearTimeout(p), n.stdout?.removeAllListeners("data"), n.stderr?.removeAllListeners("data"), n.stdout?.resume(), n.stderr?.resume(), r(a);
|
|
1792
1819
|
}, c = (a) => {
|
|
1793
1820
|
o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${n.pid}
|
|
1794
1821
|
${o}`));
|
|
1795
|
-
},
|
|
1796
|
-
${o}`)),
|
|
1822
|
+
}, p = setTimeout(() => i(U(`pid ${n.pid}
|
|
1823
|
+
${o}`)), nn);
|
|
1797
1824
|
n.stdout?.on("data", c), n.stderr?.on("data", c), n.on("error", (a) => i(U(`${o}${a.message}`, !0))), n.on("exit", (a) => {
|
|
1798
1825
|
de.delete(n.pid ?? -1), i(U(o, a !== 0));
|
|
1799
1826
|
}), n.pid && de.set(n.pid, n);
|
|
1800
1827
|
});
|
|
1801
1828
|
}
|
|
1802
|
-
function
|
|
1829
|
+
function pn(e) {
|
|
1803
1830
|
const t = de.get(e);
|
|
1804
1831
|
return t ? (t.kill("SIGTERM"), de.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
|
|
1805
1832
|
}
|
|
1806
|
-
async function
|
|
1833
|
+
async function mn(e, t) {
|
|
1807
1834
|
const s = String(t.name ?? ""), n = t.arguments ?? {};
|
|
1808
|
-
if (s === "stop") return
|
|
1809
|
-
const o =
|
|
1810
|
-
return o ? b(x(e, n.cwd ?? ".")) ? o.serves ?
|
|
1835
|
+
if (s === "stop") return pn(Number(n.pid));
|
|
1836
|
+
const o = Nt.find((r) => r.name === s);
|
|
1837
|
+
return o ? b(x(e, n.cwd ?? ".")) ? o.serves ? un(e, o, n) : ln(e, o, n) : U(`no folder ${n.cwd} under ${e}`, !0) : U(`unknown tool ${s}`, !0);
|
|
1811
1838
|
}
|
|
1812
|
-
function
|
|
1839
|
+
function oe(e, t) {
|
|
1813
1840
|
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
|
|
1814
1841
|
`);
|
|
1815
1842
|
}
|
|
1816
|
-
async function
|
|
1843
|
+
async function fn(e, t) {
|
|
1817
1844
|
if (t.id !== void 0) {
|
|
1818
1845
|
if (t.method === "initialize") {
|
|
1819
|
-
|
|
1846
|
+
oe(t.id, {
|
|
1820
1847
|
result: {
|
|
1821
1848
|
protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
|
|
1822
1849
|
capabilities: { tools: {} },
|
|
1823
|
-
serverInfo: { name: "nimpress", version:
|
|
1850
|
+
serverInfo: { name: "nimpress", version: on() }
|
|
1824
1851
|
}
|
|
1825
1852
|
});
|
|
1826
1853
|
return;
|
|
1827
1854
|
}
|
|
1828
1855
|
if (t.method === "ping") {
|
|
1829
|
-
|
|
1856
|
+
oe(t.id, { result: {} });
|
|
1830
1857
|
return;
|
|
1831
1858
|
}
|
|
1832
1859
|
if (t.method === "tools/list") {
|
|
1833
|
-
|
|
1860
|
+
oe(t.id, { result: { tools: an() } });
|
|
1834
1861
|
return;
|
|
1835
1862
|
}
|
|
1836
1863
|
if (t.method === "tools/call") {
|
|
1837
|
-
|
|
1864
|
+
oe(t.id, { result: await mn(e, t.params ?? {}) });
|
|
1838
1865
|
return;
|
|
1839
1866
|
}
|
|
1840
|
-
|
|
1867
|
+
oe(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
|
|
1841
1868
|
}
|
|
1842
1869
|
}
|
|
1843
|
-
function
|
|
1844
|
-
const t =
|
|
1870
|
+
function dn(e) {
|
|
1871
|
+
const t = ls({ input: process.stdin }), s = /* @__PURE__ */ new Set();
|
|
1845
1872
|
t.on("line", (n) => {
|
|
1846
1873
|
if (!n.trim()) return;
|
|
1847
1874
|
let o;
|
|
1848
1875
|
try {
|
|
1849
1876
|
o = JSON.parse(n);
|
|
1850
1877
|
} catch {
|
|
1851
|
-
|
|
1878
|
+
oe(null, { error: { code: -32700, message: "parse error" } });
|
|
1852
1879
|
return;
|
|
1853
1880
|
}
|
|
1854
|
-
const r =
|
|
1881
|
+
const r = fn(e, o).catch((i) => oe(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => s.delete(r));
|
|
1855
1882
|
s.add(r);
|
|
1856
1883
|
}), t.on("close", async () => {
|
|
1857
1884
|
await Promise.all(s);
|
|
@@ -1859,77 +1886,77 @@ function fn(e) {
|
|
|
1859
1886
|
process.exit(0);
|
|
1860
1887
|
});
|
|
1861
1888
|
}
|
|
1862
|
-
function
|
|
1889
|
+
function hn(e, t, s) {
|
|
1863
1890
|
if (typeof s.path == "string") return s.path.startsWith("/") ? s.path : `/${s.path}`;
|
|
1864
1891
|
const n = F(e, t).split(L).join("/").replace(/\.md$/, "");
|
|
1865
1892
|
return n === "index" ? "/" : `/${n.replace(/\/index$/, "")}`;
|
|
1866
1893
|
}
|
|
1867
|
-
function
|
|
1894
|
+
function Xe(e) {
|
|
1868
1895
|
return e ? (Array.isArray(e) ? e : String(e).split(",")).map((s) => String(s).trim()).filter(Boolean) : [];
|
|
1869
1896
|
}
|
|
1870
|
-
function
|
|
1897
|
+
function gn(e) {
|
|
1871
1898
|
return e.split(`
|
|
1872
1899
|
`).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
|
|
1873
1900
|
}
|
|
1874
|
-
function
|
|
1901
|
+
function wn(e, t) {
|
|
1875
1902
|
const s = x(e, t.contentDir), o = Y(s).filter((a) => a.endsWith(".md")).map((a) => {
|
|
1876
|
-
const { data:
|
|
1877
|
-
return { file: a, data:
|
|
1903
|
+
const { data: l, content: u } = ue(C(a, "utf-8"));
|
|
1904
|
+
return { file: a, data: l, content: u };
|
|
1878
1905
|
}).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
|
|
1879
1906
|
slug: a.file,
|
|
1880
1907
|
title: String(a.data.title),
|
|
1881
|
-
headings:
|
|
1882
|
-
tags:
|
|
1908
|
+
headings: gn(a.content),
|
|
1909
|
+
tags: Xe(a.data.tags),
|
|
1883
1910
|
body: a.content
|
|
1884
|
-
})), i =
|
|
1911
|
+
})), i = ns(r), c = t.site?.url?.replace(/\/$/, "") ?? "", p = t.base.replace(/\/$/, "");
|
|
1885
1912
|
return o.map((a) => {
|
|
1886
|
-
const
|
|
1913
|
+
const l = i.get(a.file) ?? { keywords: [], description: "" }, u = a.data.meta ?? {}, m = Array.isArray(u.keywords) ? u.keywords : typeof u.keywords == "string" ? [u.keywords] : void 0, f = typeof u.description == "string" ? u.description : typeof a.data.description == "string" ? a.data.description : void 0, h = u.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : l.keywords.length ? l.keywords : m ?? [] : m ?? Xe(a.data.tags), k = g ? h && f ? f : l.description || f || "" : f ?? "", j = hn(s, a.file, a.data);
|
|
1887
1914
|
return {
|
|
1888
1915
|
path: j,
|
|
1889
1916
|
file: F(e, a.file).split(L).join("/"),
|
|
1890
1917
|
title: String(a.data.title),
|
|
1891
1918
|
keywords: w,
|
|
1892
1919
|
description: k,
|
|
1893
|
-
robots:
|
|
1894
|
-
canonical: typeof
|
|
1895
|
-
generated:
|
|
1896
|
-
authored: { keywords: m, description: f, override: h, ai: typeof
|
|
1920
|
+
robots: os(typeof u.robots == "string" ? u.robots : "index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1", t.seo?.ai?.index, typeof u.ai == "boolean" ? u.ai : void 0),
|
|
1921
|
+
canonical: typeof u.canonical == "string" ? u.canonical : c ? `${c}${p}${j === "/" ? "/" : j}` : "",
|
|
1922
|
+
generated: l,
|
|
1923
|
+
authored: { keywords: m, description: f, override: h, ai: typeof u.ai == "boolean" ? u.ai : void 0 }
|
|
1897
1924
|
};
|
|
1898
1925
|
});
|
|
1899
1926
|
}
|
|
1900
|
-
function
|
|
1927
|
+
function $n(e, t) {
|
|
1901
1928
|
let s = 0;
|
|
1902
1929
|
for (const n of t) {
|
|
1903
|
-
const o = x(e, n.file), { data: r, content: i } =
|
|
1904
|
-
let
|
|
1905
|
-
c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords,
|
|
1930
|
+
const o = x(e, n.file), { data: r, content: i } = ue(C(o, "utf-8")), c = { ...r.meta ?? {} };
|
|
1931
|
+
let p = !1;
|
|
1932
|
+
c.keywords === void 0 && n.generated.keywords.length && (c.keywords = n.generated.keywords, p = !0), c.description === void 0 && n.generated.description && (c.description = n.generated.description, p = !0), p && (W(o, ue.stringify(i, { ...r, meta: c })), s += 1);
|
|
1906
1933
|
}
|
|
1907
1934
|
return s;
|
|
1908
1935
|
}
|
|
1909
|
-
function
|
|
1910
|
-
const n =
|
|
1936
|
+
function yn(e, t, s) {
|
|
1937
|
+
const n = wn(e, t), o = _(s, "out") ?? "seo.map.json";
|
|
1911
1938
|
for (const r of n) {
|
|
1912
1939
|
const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
|
|
1913
1940
|
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}`);
|
|
1914
1941
|
}
|
|
1915
1942
|
if (W(x(e, o), JSON.stringify(n, null, 2) + `
|
|
1916
1943
|
`), console.log(`nimpress seo: ${n.length} pages, map written to ${o}`), s.includes("--write")) {
|
|
1917
|
-
const r =
|
|
1944
|
+
const r = $n(e, n);
|
|
1918
1945
|
console.log(`nimpress seo: generated fields written into ${r} pages`);
|
|
1919
1946
|
}
|
|
1920
1947
|
}
|
|
1921
|
-
function
|
|
1948
|
+
function Tt(e = K()) {
|
|
1922
1949
|
return d(e, ".nimpress", "config.json");
|
|
1923
1950
|
}
|
|
1924
|
-
function
|
|
1951
|
+
function Pt(e = K()) {
|
|
1925
1952
|
return d(e, ".tide", "nimpress", "sites");
|
|
1926
1953
|
}
|
|
1927
|
-
function
|
|
1928
|
-
const t =
|
|
1954
|
+
function Rt(e = K()) {
|
|
1955
|
+
const t = Tt(e);
|
|
1929
1956
|
return b(t) ? { links: JSON.parse(C(t, "utf-8")).links ?? {} } : { links: {} };
|
|
1930
1957
|
}
|
|
1931
|
-
function
|
|
1932
|
-
const s =
|
|
1958
|
+
function At(e, t = K()) {
|
|
1959
|
+
const s = Tt(t);
|
|
1933
1960
|
B(N(s), { recursive: !0 }), W(s, `${JSON.stringify(e, null, 2)}
|
|
1934
1961
|
`);
|
|
1935
1962
|
}
|
|
@@ -1944,114 +1971,114 @@ function Oe(e) {
|
|
|
1944
1971
|
const t = e.trim();
|
|
1945
1972
|
return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ve(t)}.git`;
|
|
1946
1973
|
}
|
|
1947
|
-
function
|
|
1974
|
+
function Mt(e) {
|
|
1948
1975
|
const t = d(e, ".github", "workflows");
|
|
1949
|
-
return b(t) ?
|
|
1976
|
+
return b(t) ? ie(t).filter((s) => s.endsWith(".yml") || s.endsWith(".yaml")).sort().map((s) => d(t, s)) : [];
|
|
1950
1977
|
}
|
|
1951
|
-
function
|
|
1978
|
+
function It(e) {
|
|
1952
1979
|
try {
|
|
1953
|
-
const t =
|
|
1980
|
+
const t = us(C(e, "utf-8"));
|
|
1954
1981
|
return typeof t == "object" && t !== null ? t : null;
|
|
1955
1982
|
} catch {
|
|
1956
1983
|
return null;
|
|
1957
1984
|
}
|
|
1958
1985
|
}
|
|
1959
|
-
function
|
|
1986
|
+
function le(e, t) {
|
|
1960
1987
|
return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (n, o) => {
|
|
1961
1988
|
for (const r of t)
|
|
1962
1989
|
if (r && r[o] !== void 0) return String(r[o]);
|
|
1963
1990
|
return "";
|
|
1964
1991
|
}).trim();
|
|
1965
1992
|
}
|
|
1966
|
-
function
|
|
1993
|
+
function Lt(e, t) {
|
|
1967
1994
|
const s = [];
|
|
1968
1995
|
for (const n of Object.values(e.jobs ?? {}))
|
|
1969
1996
|
for (const o of n.steps ?? [])
|
|
1970
1997
|
typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && s.push({ step: o, scopes: [o.env, n.env, e.env] });
|
|
1971
1998
|
return s;
|
|
1972
1999
|
}
|
|
1973
|
-
function
|
|
2000
|
+
function bn(e) {
|
|
1974
2001
|
const t = /* @__PURE__ */ new Map();
|
|
1975
|
-
for (const s of
|
|
1976
|
-
const n =
|
|
2002
|
+
for (const s of Mt(e)) {
|
|
2003
|
+
const n = It(s);
|
|
1977
2004
|
if (n)
|
|
1978
|
-
for (const { step: o, scopes: r } of
|
|
1979
|
-
const i =
|
|
2005
|
+
for (const { step: o, scopes: r } of Lt(n, "docs-notify")) {
|
|
2006
|
+
const i = le(o.with?.["docs-repo"], r);
|
|
1980
2007
|
if (!i) continue;
|
|
1981
|
-
const c =
|
|
2008
|
+
const c = le(o.with?.["export-dir"], r) || ".nimpress";
|
|
1982
2009
|
t.set(i, { repo: i, exportDir: c });
|
|
1983
2010
|
}
|
|
1984
2011
|
}
|
|
1985
2012
|
return [...t.values()];
|
|
1986
2013
|
}
|
|
1987
|
-
function
|
|
2014
|
+
function qe(e) {
|
|
1988
2015
|
return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
|
|
1989
2016
|
}
|
|
1990
|
-
function
|
|
2017
|
+
function vn(e, t) {
|
|
1991
2018
|
const s = {
|
|
1992
2019
|
contentRoot: t,
|
|
1993
2020
|
mapping: b(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
|
|
1994
2021
|
defaults: {}
|
|
1995
2022
|
};
|
|
1996
|
-
for (const n of
|
|
1997
|
-
const o =
|
|
2023
|
+
for (const n of Mt(e)) {
|
|
2024
|
+
const o = It(n);
|
|
1998
2025
|
if (o)
|
|
1999
|
-
for (const { step: r, scopes: i } of
|
|
2000
|
-
const c =
|
|
2001
|
-
const f =
|
|
2026
|
+
for (const { step: r, scopes: i } of Lt(o, "docs-sync")) {
|
|
2027
|
+
const c = qe(le(r.with?.["docs-dir"], i)), p = (m) => {
|
|
2028
|
+
const f = qe(m);
|
|
2002
2029
|
return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
|
|
2003
|
-
}, a =
|
|
2004
|
-
a && (s.contentRoot =
|
|
2005
|
-
const
|
|
2006
|
-
|
|
2007
|
-
const
|
|
2008
|
-
return
|
|
2030
|
+
}, a = le(r.with?.["content-root"], i);
|
|
2031
|
+
a && (s.contentRoot = p(a));
|
|
2032
|
+
const l = le(r.with?.mapping, i);
|
|
2033
|
+
l && (s.mapping = p(l));
|
|
2034
|
+
const u = le(r.with?.defaults, i);
|
|
2035
|
+
return u && (s.defaults = JSON.parse(u)), s;
|
|
2009
2036
|
}
|
|
2010
2037
|
}
|
|
2011
2038
|
return s;
|
|
2012
2039
|
}
|
|
2013
|
-
function
|
|
2040
|
+
function kn(e, t) {
|
|
2014
2041
|
const s = { ...e };
|
|
2015
2042
|
return t.target && (s.target = t.target), t.targets?.length && (s.targets = t.targets), t.mode && (s.mode = t.mode), s;
|
|
2016
2043
|
}
|
|
2017
|
-
function
|
|
2044
|
+
function xn(e) {
|
|
2018
2045
|
const t = e.mode || "mirror";
|
|
2019
2046
|
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 }] : [];
|
|
2020
2047
|
}
|
|
2021
|
-
function
|
|
2048
|
+
function Sn(e, t, s) {
|
|
2022
2049
|
let n = t.defaults;
|
|
2023
2050
|
const o = t.mapping ? d(e, t.mapping) : "";
|
|
2024
2051
|
if (o && b(o)) {
|
|
2025
2052
|
const i = JSON.parse(C(o, "utf-8")).sources?.[s];
|
|
2026
|
-
i && (n =
|
|
2053
|
+
i && (n = kn(n, i));
|
|
2027
2054
|
}
|
|
2028
2055
|
return n;
|
|
2029
2056
|
}
|
|
2030
|
-
function
|
|
2057
|
+
function et(e) {
|
|
2031
2058
|
const t = /* @__PURE__ */ new Map();
|
|
2032
2059
|
if (!b(e)) return t;
|
|
2033
2060
|
for (const s of Y(e))
|
|
2034
2061
|
t.set(F(e, s).split(L).join("/"), C(s));
|
|
2035
2062
|
return t;
|
|
2036
2063
|
}
|
|
2037
|
-
function
|
|
2038
|
-
const n = { added: [], modified: [], deleted: [] }, o =
|
|
2064
|
+
function jn(e, t, s) {
|
|
2065
|
+
const n = { added: [], modified: [], deleted: [] }, o = et(e), r = et(t);
|
|
2039
2066
|
for (const [i, c] of o) {
|
|
2040
|
-
const
|
|
2041
|
-
if (
|
|
2067
|
+
const p = r.get(i);
|
|
2068
|
+
if (p && p.equals(c)) continue;
|
|
2042
2069
|
const a = d(t, ...i.split("/"));
|
|
2043
|
-
B(N(a), { recursive: !0 }), W(a, c),
|
|
2070
|
+
B(N(a), { recursive: !0 }), W(a, c), p ? n.modified.push(i) : n.added.push(i);
|
|
2044
2071
|
}
|
|
2045
2072
|
if (s === "mirror")
|
|
2046
2073
|
for (const i of r.keys())
|
|
2047
|
-
o.has(i) || (
|
|
2074
|
+
o.has(i) || (ee(d(t, ...i.split("/")), { force: !0 }), n.deleted.push(i));
|
|
2048
2075
|
return n;
|
|
2049
2076
|
}
|
|
2050
|
-
function
|
|
2077
|
+
function Cn(e, t) {
|
|
2051
2078
|
const s = /* @__PURE__ */ new Map();
|
|
2052
2079
|
for (const o of Y(e)) {
|
|
2053
2080
|
if (!o.endsWith(".md")) continue;
|
|
2054
|
-
const r =
|
|
2081
|
+
const r = ue(C(o, "utf-8")).data.path, i = rs(e, o, typeof r == "string" ? r : void 0);
|
|
2055
2082
|
s.set(i, [...s.get(i) ?? [], o]);
|
|
2056
2083
|
}
|
|
2057
2084
|
const n = [];
|
|
@@ -2059,253 +2086,253 @@ function jn(e, t) {
|
|
|
2059
2086
|
o.some((r) => t.has(r)) && n.push(...o.filter((r) => !t.has(r)));
|
|
2060
2087
|
return n.sort();
|
|
2061
2088
|
}
|
|
2062
|
-
function
|
|
2063
|
-
const n =
|
|
2089
|
+
function re(e, t, s) {
|
|
2090
|
+
const n = te("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...s } });
|
|
2064
2091
|
return { ok: n.status === 0, out: `${n.stdout ?? ""}${n.stderr ?? ""}`.trim() };
|
|
2065
2092
|
}
|
|
2066
|
-
function
|
|
2067
|
-
const t =
|
|
2093
|
+
function Jt(e) {
|
|
2094
|
+
const t = re(["rev-parse", "--show-toplevel"], e);
|
|
2068
2095
|
return t.ok ? t.out : e;
|
|
2069
2096
|
}
|
|
2070
|
-
function
|
|
2071
|
-
const t =
|
|
2097
|
+
function En(e) {
|
|
2098
|
+
const t = re(["remote", "get-url", "origin"], e);
|
|
2072
2099
|
if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
|
|
2073
2100
|
return ve(t.out);
|
|
2074
2101
|
}
|
|
2075
|
-
function
|
|
2076
|
-
return
|
|
2102
|
+
function On() {
|
|
2103
|
+
return te("gh", ["--version"], { encoding: "utf-8" }).status === 0;
|
|
2077
2104
|
}
|
|
2078
2105
|
function zt(e) {
|
|
2079
2106
|
return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
|
|
2080
2107
|
}
|
|
2081
2108
|
function Fe(e) {
|
|
2082
|
-
return e.login?.method === "gh" ?
|
|
2109
|
+
return e.login?.method === "gh" ? te("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : re(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
|
|
2083
2110
|
}
|
|
2084
|
-
async function
|
|
2085
|
-
const t =
|
|
2111
|
+
async function Bt(e) {
|
|
2112
|
+
const t = mt({ input: process.stdin, output: process.stdout });
|
|
2086
2113
|
try {
|
|
2087
2114
|
return (await t.question(e)).trim();
|
|
2088
2115
|
} finally {
|
|
2089
2116
|
t.close();
|
|
2090
2117
|
}
|
|
2091
2118
|
}
|
|
2092
|
-
async function
|
|
2119
|
+
async function Fn(e) {
|
|
2093
2120
|
if (Fe(e)) return e;
|
|
2094
|
-
if (console.log(`nimpress view: ${e.url} refused the connection`),
|
|
2095
|
-
if (console.log("nimpress view: logging in through gh"),
|
|
2121
|
+
if (console.log(`nimpress view: ${e.url} refused the connection`), On()) {
|
|
2122
|
+
if (console.log("nimpress view: logging in through gh"), te("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
|
|
2096
2123
|
const o = { ...e, login: { method: "gh" } };
|
|
2097
2124
|
if (Fe(o)) return o;
|
|
2098
2125
|
throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
|
|
2099
2126
|
}
|
|
2100
|
-
const t = await
|
|
2127
|
+
const t = await Bt("nimpress view: path to the ssh key with access to the repo: ");
|
|
2101
2128
|
if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
|
|
2102
2129
|
const s = { ...e, login: { method: "ssh", key: x(t.replace(/^~/, K())) } };
|
|
2103
2130
|
if (Fe(s)) return s;
|
|
2104
2131
|
throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${s.login.key}, ask for access to it`);
|
|
2105
2132
|
}
|
|
2106
|
-
async function
|
|
2107
|
-
const n =
|
|
2108
|
-
let
|
|
2133
|
+
async function Dn(e, t, s = K()) {
|
|
2134
|
+
const n = Jt(e), o = Rt(s), r = o.links[n] ?? [], i = bn(n), c = _(t, "docs-repo");
|
|
2135
|
+
let p;
|
|
2109
2136
|
if (c) {
|
|
2110
|
-
const
|
|
2111
|
-
|
|
2137
|
+
const l = ve(c), u = i.find((m) => m.repo === l)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
|
|
2138
|
+
p = [{ repo: l, url: Oe(c), exportDir: u, login: r.find((m) => m.repo === l)?.login }];
|
|
2112
2139
|
} else if (i.length)
|
|
2113
|
-
|
|
2114
|
-
repo:
|
|
2115
|
-
url: r.find((
|
|
2116
|
-
exportDir:
|
|
2117
|
-
login: r.find((
|
|
2140
|
+
p = i.map((l) => ({
|
|
2141
|
+
repo: l.repo,
|
|
2142
|
+
url: r.find((u) => u.repo === l.repo)?.url ?? Oe(l.repo),
|
|
2143
|
+
exportDir: l.exportDir,
|
|
2144
|
+
login: r.find((u) => u.repo === l.repo)?.login
|
|
2118
2145
|
}));
|
|
2119
2146
|
else if (r.length)
|
|
2120
|
-
|
|
2147
|
+
p = r;
|
|
2121
2148
|
else {
|
|
2122
2149
|
console.log(`nimpress view: no workflow under ${n} names a docs site`);
|
|
2123
|
-
const
|
|
2124
|
-
if (!
|
|
2125
|
-
|
|
2150
|
+
const l = await Bt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
|
|
2151
|
+
if (!l) throw new Error("[nimpress] view: no docs site given");
|
|
2152
|
+
p = [{ repo: ve(l), url: Oe(l), exportDir: _(t, "export-dir") ?? ".nimpress" }];
|
|
2126
2153
|
}
|
|
2127
2154
|
const a = [];
|
|
2128
|
-
for (const
|
|
2129
|
-
return o.links[n] = a,
|
|
2155
|
+
for (const l of p) a.push(await Fn(l));
|
|
2156
|
+
return o.links[n] = a, At(o, s), a;
|
|
2130
2157
|
}
|
|
2131
|
-
function
|
|
2132
|
-
return d(
|
|
2158
|
+
function _n(e, t = K()) {
|
|
2159
|
+
return d(Pt(t), e.repo.replace("/", "__"));
|
|
2133
2160
|
}
|
|
2134
|
-
function
|
|
2161
|
+
function Nn(e, t, s) {
|
|
2135
2162
|
const n = zt(e.login);
|
|
2136
2163
|
if (!b(d(t, ".git"))) {
|
|
2137
2164
|
B(N(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
|
|
2138
|
-
const r = e.login?.method === "gh" ?
|
|
2165
|
+
const r = e.login?.method === "gh" ? te("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : te("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...n } });
|
|
2139
2166
|
if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
|
|
2140
2167
|
${r.stderr ?? ""}`);
|
|
2141
2168
|
return;
|
|
2142
2169
|
}
|
|
2143
2170
|
if (s) return;
|
|
2144
|
-
const o =
|
|
2171
|
+
const o = re(["fetch", "--depth", "1", "origin", "HEAD"], t, n);
|
|
2145
2172
|
if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
|
|
2146
2173
|
${o.out}`);
|
|
2147
|
-
|
|
2174
|
+
re(["reset", "--hard", "FETCH_HEAD"], t), re(["clean", "-fd"], t);
|
|
2148
2175
|
}
|
|
2149
|
-
function
|
|
2176
|
+
function Wn(e) {
|
|
2150
2177
|
const t = ["pnpm-lock.yaml", "package.json"].map((s) => d(e, s)).find((s) => b(s));
|
|
2151
|
-
return t ?
|
|
2178
|
+
return t ? pt("sha256").update(C(t)).digest("hex") : "";
|
|
2152
2179
|
}
|
|
2153
|
-
function
|
|
2154
|
-
const t = d(e,
|
|
2180
|
+
function Tn(e) {
|
|
2181
|
+
const t = d(e, z.paths.cache, "view", "lockfile.sha256"), s = Wn(e);
|
|
2155
2182
|
if (b(d(e, "node_modules")) && b(t) && C(t, "utf-8").trim() === s) return;
|
|
2156
|
-
if (console.log("nimpress view: installing the docs site dependencies"),
|
|
2183
|
+
if (console.log("nimpress view: installing the docs site dependencies"), te("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
|
|
2157
2184
|
B(N(t), { recursive: !0 }), W(t, `${s}
|
|
2158
2185
|
`);
|
|
2159
2186
|
}
|
|
2160
|
-
function
|
|
2161
|
-
const t =
|
|
2187
|
+
function Pn(e) {
|
|
2188
|
+
const t = cs(), 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 });
|
|
2162
2189
|
n.on("error", () => console.log(`nimpress view: open ${e} in a browser`)), n.unref();
|
|
2163
2190
|
}
|
|
2164
|
-
function
|
|
2191
|
+
function tt(e, t) {
|
|
2165
2192
|
let s;
|
|
2166
2193
|
return () => {
|
|
2167
2194
|
s && clearTimeout(s), s = setTimeout(e, t);
|
|
2168
2195
|
};
|
|
2169
2196
|
}
|
|
2170
|
-
function
|
|
2197
|
+
function Rn(e, t) {
|
|
2171
2198
|
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`);
|
|
2172
2199
|
}
|
|
2173
|
-
function
|
|
2200
|
+
function An(e) {
|
|
2174
2201
|
const t = Ie("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), s = new Promise((n, o) => {
|
|
2175
2202
|
let r = !1;
|
|
2176
2203
|
t.stdout?.on("data", (i) => {
|
|
2177
2204
|
const c = i.toString();
|
|
2178
2205
|
if (process.stdout.write(c), r) return;
|
|
2179
|
-
const
|
|
2180
|
-
|
|
2206
|
+
const p = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
|
|
2207
|
+
p && (r = !0, n(p[1]));
|
|
2181
2208
|
}), t.on("exit", (i) => {
|
|
2182
2209
|
r || o(new Error(`[nimpress] view: the docs site dev server exited with ${i ?? "a signal"} before it printed a url`));
|
|
2183
2210
|
}), t.on("error", (i) => o(new Error(`[nimpress] view: cannot run the docs site dev server, ${i.message}`)));
|
|
2184
2211
|
});
|
|
2185
2212
|
return { child: t, origin: s };
|
|
2186
2213
|
}
|
|
2187
|
-
async function
|
|
2188
|
-
const s =
|
|
2189
|
-
for (const
|
|
2190
|
-
const
|
|
2191
|
-
if (i.configFile && Re(e, i.resolved, [...c, `--out=${
|
|
2192
|
-
throw new Error(`[nimpress] view: no export folder at ${
|
|
2193
|
-
const m =
|
|
2194
|
-
|
|
2214
|
+
async function Mn(e, t) {
|
|
2215
|
+
const s = M(t, "offline"), n = await Dn(e, t), o = En(e), r = Jt(e), i = await we(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], p = [];
|
|
2216
|
+
for (const l of n) {
|
|
2217
|
+
const u = x(r, l.exportDir);
|
|
2218
|
+
if (i.configFile && Re(e, i.resolved, [...c, `--out=${u}`]), !b(u))
|
|
2219
|
+
throw new Error(`[nimpress] view: no export folder at ${u}, write the pages there or mark pages with export: and add a config`);
|
|
2220
|
+
const m = _n(l);
|
|
2221
|
+
Nn(l, m, s), Tn(m);
|
|
2195
2222
|
const f = await we(m);
|
|
2196
|
-
if (!f.configFile) throw new Error(`[nimpress] view: ${
|
|
2197
|
-
const h =
|
|
2223
|
+
if (!f.configFile) throw new Error(`[nimpress] view: ${l.repo} carries no nimpress config, so it is not a docs site`);
|
|
2224
|
+
const h = vn(m, f.resolved.contentDir), g = xn(Sn(m, h, o));
|
|
2198
2225
|
if (!g.length)
|
|
2199
2226
|
throw new Error(
|
|
2200
|
-
`[nimpress] view: ${
|
|
2227
|
+
`[nimpress] view: ${l.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
|
|
2201
2228
|
);
|
|
2202
2229
|
const w = x(m, h.contentRoot), k = x(m, f.resolved.contentDir);
|
|
2203
2230
|
let j = [];
|
|
2204
2231
|
const E = () => {
|
|
2205
|
-
j.length &&
|
|
2232
|
+
j.length && re(["checkout", "--", ...j], m);
|
|
2206
2233
|
const $ = /* @__PURE__ */ new Set();
|
|
2207
2234
|
for (const y of g) {
|
|
2208
|
-
const
|
|
2209
|
-
|
|
2210
|
-
for (const A of Y(
|
|
2235
|
+
const I = d(u, ...y.from.split("/").filter(Boolean)), P = d(w, ...y.to.split("/"));
|
|
2236
|
+
Rn(y.to, jn(I, P, y.mode));
|
|
2237
|
+
for (const A of Y(I)) $.add(d(P, F(I, A)));
|
|
2211
2238
|
}
|
|
2212
|
-
j =
|
|
2213
|
-
for (const y of j)
|
|
2239
|
+
j = Cn(k, $);
|
|
2240
|
+
for (const y of j) ee(y);
|
|
2214
2241
|
j.length && console.log(`nimpress view: the local pages replace ${j.map((y) => F(m, y)).join(", ")}`);
|
|
2215
2242
|
};
|
|
2216
2243
|
E();
|
|
2217
|
-
const v =
|
|
2218
|
-
if (
|
|
2219
|
-
const $ =
|
|
2244
|
+
const v = Ue(u, { recursive: !0 }, tt(E, 150));
|
|
2245
|
+
if (p.push(() => v.close()), i.configFile) {
|
|
2246
|
+
const $ = Ue(
|
|
2220
2247
|
x(e, i.resolved.contentDir),
|
|
2221
2248
|
{ recursive: !0 },
|
|
2222
|
-
|
|
2249
|
+
tt(() => Re(e, i.resolved, [...c, `--out=${u}`]), 150)
|
|
2223
2250
|
);
|
|
2224
|
-
|
|
2251
|
+
p.push(() => $.close());
|
|
2225
2252
|
}
|
|
2226
|
-
const { child: R, origin: O } =
|
|
2227
|
-
|
|
2253
|
+
const { child: R, origin: O } = An(m);
|
|
2254
|
+
p.push(() => R.kill());
|
|
2228
2255
|
const T = `${(await O).replace(/\/$/, "")}/${g[0].to}`;
|
|
2229
|
-
console.log(`nimpress view: ${o} inside ${
|
|
2256
|
+
console.log(`nimpress view: ${o} inside ${l.repo} at ${T}`), M(t, "no-browser") || Pn(T);
|
|
2230
2257
|
}
|
|
2231
2258
|
const a = () => {
|
|
2232
|
-
for (const
|
|
2259
|
+
for (const l of p) l();
|
|
2233
2260
|
process.exit(0);
|
|
2234
2261
|
};
|
|
2235
2262
|
process.on("SIGINT", a), process.on("SIGTERM", a);
|
|
2236
2263
|
}
|
|
2237
|
-
async function
|
|
2238
|
-
const s =
|
|
2264
|
+
async function In(e, t) {
|
|
2265
|
+
const s = ne(t, 0);
|
|
2239
2266
|
if (s !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${s ?? ""}, use clear`);
|
|
2240
|
-
const n =
|
|
2267
|
+
const n = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !n && !o && !r;
|
|
2241
2268
|
if (n || i) {
|
|
2242
|
-
const c =
|
|
2243
|
-
|
|
2269
|
+
const c = Rt(), p = Object.keys(c.links).length;
|
|
2270
|
+
At({ links: {} }), console.log(`nimpress cache: cleared ${p} links`);
|
|
2244
2271
|
}
|
|
2245
2272
|
if (o || i) {
|
|
2246
|
-
const c =
|
|
2247
|
-
|
|
2273
|
+
const c = Pt();
|
|
2274
|
+
ee(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
|
|
2248
2275
|
}
|
|
2249
2276
|
if (r) {
|
|
2250
|
-
const { resolved: c, configFile:
|
|
2251
|
-
if (!
|
|
2252
|
-
const a =
|
|
2253
|
-
b(a) &&
|
|
2277
|
+
const { resolved: c, configFile: p } = await we(e);
|
|
2278
|
+
if (!p) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
|
|
2279
|
+
const a = rt(e, c);
|
|
2280
|
+
b(a) && ee(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
|
|
2254
2281
|
}
|
|
2255
2282
|
}
|
|
2256
|
-
async function
|
|
2283
|
+
async function to(e) {
|
|
2257
2284
|
const t = e[0] ?? "dev", s = e.slice(1), n = process.cwd();
|
|
2258
2285
|
if (t === "init") {
|
|
2259
|
-
|
|
2286
|
+
ds(n);
|
|
2260
2287
|
return;
|
|
2261
2288
|
}
|
|
2262
2289
|
if (t === "skill") {
|
|
2263
|
-
|
|
2290
|
+
Js(n, s);
|
|
2264
2291
|
return;
|
|
2265
2292
|
}
|
|
2266
2293
|
if (t === "plugin") {
|
|
2267
|
-
|
|
2294
|
+
Hs(n, s);
|
|
2268
2295
|
return;
|
|
2269
2296
|
}
|
|
2270
2297
|
if (t === "mcp") {
|
|
2271
|
-
|
|
2298
|
+
dn(n);
|
|
2272
2299
|
return;
|
|
2273
2300
|
}
|
|
2274
2301
|
if (t === "completion") {
|
|
2275
|
-
|
|
2302
|
+
en(n, s);
|
|
2276
2303
|
return;
|
|
2277
2304
|
}
|
|
2278
|
-
if (t === "view" || t === "dev" &&
|
|
2279
|
-
await
|
|
2305
|
+
if (t === "view" || t === "dev" && M(s, "view")) {
|
|
2306
|
+
await Mn(n, s);
|
|
2280
2307
|
return;
|
|
2281
2308
|
}
|
|
2282
2309
|
if (t === "cache") {
|
|
2283
|
-
await
|
|
2310
|
+
await In(n, s);
|
|
2284
2311
|
return;
|
|
2285
2312
|
}
|
|
2286
2313
|
const { resolved: o } = await we(n);
|
|
2287
2314
|
if (t === "seo") {
|
|
2288
|
-
|
|
2315
|
+
yn(n, o, s);
|
|
2289
2316
|
return;
|
|
2290
2317
|
}
|
|
2291
2318
|
if (t === "lint") {
|
|
2292
|
-
await
|
|
2319
|
+
await Fs(n, o);
|
|
2293
2320
|
return;
|
|
2294
2321
|
}
|
|
2295
2322
|
if (t === "dev") {
|
|
2296
|
-
await
|
|
2323
|
+
await bs(n, o);
|
|
2297
2324
|
return;
|
|
2298
2325
|
}
|
|
2299
2326
|
if (t === "build") {
|
|
2300
|
-
await
|
|
2327
|
+
await $t(n, o);
|
|
2301
2328
|
return;
|
|
2302
2329
|
}
|
|
2303
2330
|
if (t === "guard") {
|
|
2304
|
-
|
|
2331
|
+
_s(n, o, s);
|
|
2305
2332
|
return;
|
|
2306
2333
|
}
|
|
2307
2334
|
if (t === "modules") {
|
|
2308
|
-
await
|
|
2335
|
+
await As(n, o, s);
|
|
2309
2336
|
return;
|
|
2310
2337
|
}
|
|
2311
2338
|
if (t === "export") {
|
|
@@ -2315,8 +2342,8 @@ async function eo(e) {
|
|
|
2315
2342
|
throw new Error(`[nimpress] unknown command: ${t}`);
|
|
2316
2343
|
}
|
|
2317
2344
|
export {
|
|
2318
|
-
|
|
2319
|
-
|
|
2345
|
+
nt as buildViteConfig,
|
|
2346
|
+
Vt as indexHtml,
|
|
2320
2347
|
we as loadNimpressConfig,
|
|
2321
|
-
|
|
2348
|
+
to as run
|
|
2322
2349
|
};
|