@nimtech/nimpress 2.7.1 → 2.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/rules/docs-sync.md +5 -1
- package/.claude/rules/frontmatter.md +2 -0
- package/dist/cli.es.js +1017 -972
- package/dist/{plugin-BZgsCxCz.js → plugin-DOHMact8.js} +1 -0
- package/dist/plugin.es.js +1 -1
- package/dist/src/cli/export.d.ts +1 -1
- package/dist/src/cli/export.d.ts.map +1 -1
- package/dist/src/cli/site.d.ts.map +1 -1
- package/dist/src/types.d.ts +4 -0
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/cli.es.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import { d as B, c as
|
|
2
|
-
import { join as d, dirname as
|
|
3
|
-
import { readdirSync as
|
|
4
|
-
import
|
|
5
|
-
import { readFile as
|
|
6
|
-
import { s as
|
|
7
|
-
import { createServer as
|
|
8
|
-
import { createHash as
|
|
9
|
-
import { spawnSync as
|
|
10
|
-
import { createInterface as
|
|
11
|
-
import { homedir as Q, platform as
|
|
12
|
-
import { parse as
|
|
13
|
-
import { fileURLToPath as
|
|
14
|
-
import { createInterface as
|
|
1
|
+
import { d as B, c as xe, r as Je, s as Qt, p as Xt, a as lt, b as me, e as qt, f as es, g as Te, h as ut, i as ts, j as pt, k as ss, l as ns, m as os, C as we, n as rs, o as Be, q as Ke, w as fe, t as mt, u as is, v as as, x as $e, y as cs, z as ls, A as us, B as ps, D as ms, E as Ye, F as fs, G as ds } from "./plugin-DOHMact8.js";
|
|
2
|
+
import { join as d, dirname as O, relative as E, sep as z, extname as de, resolve as j, basename as W } from "node:path";
|
|
3
|
+
import { readdirSync as ce, existsSync as y, writeFileSync as N, mkdirSync as L, rmSync as se, readFileSync as S, statSync as ft, watch as Qe, openSync as hs } from "node:fs";
|
|
4
|
+
import pe from "gray-matter";
|
|
5
|
+
import { readFile as Ee, readdir as gs, writeFile as te, mkdir as Pe, copyFile as dt } from "node:fs/promises";
|
|
6
|
+
import { s as ws, r as ye } from "./typeMembers-CNvE92EX.js";
|
|
7
|
+
import { createServer as ht, build as gt } from "vite";
|
|
8
|
+
import { createHash as wt } from "node:crypto";
|
|
9
|
+
import { spawnSync as ne, spawn as Se } from "node:child_process";
|
|
10
|
+
import { createInterface as $t } from "node:readline/promises";
|
|
11
|
+
import { homedir as Q, platform as $s } from "node:os";
|
|
12
|
+
import { parse as ys } from "yaml";
|
|
13
|
+
import { fileURLToPath as yt } from "node:url";
|
|
14
|
+
import { createInterface as bs } from "node:readline";
|
|
15
15
|
function _(e, t) {
|
|
16
|
-
return e.find((
|
|
16
|
+
return e.find((s) => s.startsWith(`--${t}=`))?.slice(t.length + 3);
|
|
17
17
|
}
|
|
18
18
|
function M(e, t) {
|
|
19
19
|
return e.includes(`--${t}`);
|
|
20
20
|
}
|
|
21
21
|
function K(e, t) {
|
|
22
|
-
return e.filter((
|
|
22
|
+
return e.filter((s) => !s.startsWith("--"))[t];
|
|
23
23
|
}
|
|
24
24
|
function X(e, t = []) {
|
|
25
|
-
let
|
|
25
|
+
let n;
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
n = ce(e, { withFileTypes: !0 });
|
|
28
28
|
} catch {
|
|
29
29
|
return t;
|
|
30
30
|
}
|
|
31
|
-
for (const
|
|
32
|
-
const o = d(e,
|
|
33
|
-
if (
|
|
34
|
-
if (
|
|
31
|
+
for (const s of n) {
|
|
32
|
+
const o = d(e, s.name);
|
|
33
|
+
if (s.isDirectory()) {
|
|
34
|
+
if (s.name === "node_modules" || s.name.startsWith(".")) continue;
|
|
35
35
|
X(o, t);
|
|
36
|
-
} else
|
|
36
|
+
} else s.isFile() && t.push(o);
|
|
37
37
|
}
|
|
38
38
|
return t;
|
|
39
39
|
}
|
|
40
|
-
function
|
|
40
|
+
function Re(e, t, n) {
|
|
41
41
|
if (t.length) {
|
|
42
42
|
console.error(`${e} failed with ${t.length} problems`);
|
|
43
|
-
for (const
|
|
43
|
+
for (const s of t) console.error(` ${s}`);
|
|
44
44
|
process.exit(1);
|
|
45
45
|
}
|
|
46
|
-
console.log(
|
|
46
|
+
console.log(n);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function vs() {
|
|
49
49
|
return `import { defineConfig } from '@nimtech/nimpress/plugin'
|
|
50
50
|
|
|
51
51
|
/**
|
|
@@ -181,7 +181,7 @@ export default defineConfig({
|
|
|
181
181
|
})
|
|
182
182
|
`;
|
|
183
183
|
}
|
|
184
|
-
function
|
|
184
|
+
function ks() {
|
|
185
185
|
return JSON.stringify(
|
|
186
186
|
{
|
|
187
187
|
$schema: "./node_modules/@nimtech/nimpress/config.schema.json",
|
|
@@ -195,7 +195,7 @@ function $s() {
|
|
|
195
195
|
) + `
|
|
196
196
|
`;
|
|
197
197
|
}
|
|
198
|
-
function
|
|
198
|
+
function xs(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"),
|
|
242
|
-
!
|
|
240
|
+
function Ss(e) {
|
|
241
|
+
const t = d(e, "nimpress.config.ts"), n = d(e, "nimpress.config.json"), s = M(process.argv.slice(2), "json");
|
|
242
|
+
!y(t) && !y(n) && (s ? (N(n, ks()), console.log(`nimpress init: ${n} written, field descriptions come from the referenced config.schema.json`)) : (N(t, vs()), console.log(`nimpress init: ${t} written with every field documented, uncomment what you need`)));
|
|
243
243
|
const o = d(e, B.contentDir);
|
|
244
|
-
(!
|
|
244
|
+
(!y(o) || ce(o).length === 0) && (L(o, { recursive: !0 }), N(
|
|
245
245
|
d(o, "index.md"),
|
|
246
246
|
`---
|
|
247
247
|
title: Home
|
|
@@ -250,214 +250,220 @@ title: Home
|
|
|
250
250
|
Welcome to your Nimpress site.
|
|
251
251
|
`
|
|
252
252
|
));
|
|
253
|
-
const i =
|
|
253
|
+
const i = xs(B.contentDir);
|
|
254
254
|
for (const c of ["CLAUDE.md", "AGENTS.md"]) {
|
|
255
255
|
const l = d(e, c);
|
|
256
|
-
|
|
256
|
+
y(l) || (N(l, 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 js = { vue: "vueStory", svelte: "svelteStory" }, Cs = { vue: ".svelte", svelte: ".vue" };
|
|
260
|
+
function le(e) {
|
|
261
261
|
return `run nimpress modules update ${e}`;
|
|
262
262
|
}
|
|
263
|
-
async function
|
|
263
|
+
async function Es(e) {
|
|
264
264
|
let t;
|
|
265
265
|
try {
|
|
266
|
-
t = await
|
|
266
|
+
t = await gs(e, { withFileTypes: !0 });
|
|
267
267
|
} catch {
|
|
268
268
|
return [];
|
|
269
269
|
}
|
|
270
|
-
return t.filter((
|
|
270
|
+
return t.filter((n) => n.isFile() && /\.story\.tsx?$/.test(n.name)).map((n) => n.name);
|
|
271
271
|
}
|
|
272
|
-
function
|
|
273
|
-
const
|
|
274
|
-
return e.every((
|
|
272
|
+
function Os(e, t) {
|
|
273
|
+
const n = t === "integer" ? "number" : t;
|
|
274
|
+
return e.every((s) => typeof s === n);
|
|
275
275
|
}
|
|
276
|
-
function
|
|
277
|
-
const r = [], i =
|
|
276
|
+
function Fs(e, t, n, s, o) {
|
|
277
|
+
const r = [], i = s.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, ${le(t)}`);
|
|
280
280
|
for (const m of Object.keys(i))
|
|
281
|
-
m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${
|
|
281
|
+
m in c || r.push(`${e}: schema prop ${m} has no counterpart in ${n}, 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 && !
|
|
287
|
-
const g = new Set(h.enum.map((
|
|
285
|
+
`${e}: prop ${m} schema type ${f.type} conflicts with source type ${h.type}, ${le(t)}`
|
|
286
|
+
), f.enum && h.type && !Os(f.enum, h.type) && r.push(`${e}: prop ${m} enum values mismatch the source type ${h.type}`), f.enum && h.enum)) {
|
|
287
|
+
const g = new Set(h.enum.map((v) => JSON.stringify(v))), w = f.enum.filter((v) => !g.has(JSON.stringify(v)));
|
|
288
288
|
w.length && r.push(
|
|
289
|
-
`${e}: prop ${m} enum carries ${w.map((
|
|
289
|
+
`${e}: prop ${m} enum carries ${w.map((v) => JSON.stringify(v)).join(", ")} outside the source union`
|
|
290
290
|
);
|
|
291
291
|
}
|
|
292
292
|
}
|
|
293
|
-
const l =
|
|
293
|
+
const l = s.slots ?? {}, a = o.slots ?? {};
|
|
294
294
|
for (const m of Object.keys(a))
|
|
295
|
-
m in l || r.push(`${e}: slot ${m} is missing from the schema, ${
|
|
295
|
+
m in l || r.push(`${e}: slot ${m} is missing from the schema, ${le(t)}`);
|
|
296
296
|
for (const m of Object.keys(l))
|
|
297
|
-
m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${
|
|
298
|
-
const
|
|
299
|
-
for (const m of p)
|
|
300
|
-
u.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${ce(t)}`);
|
|
297
|
+
m in a || r.push(`${e}: schema slot ${m} has no counterpart in ${n}`);
|
|
298
|
+
const p = new Set(s.emits ?? []), u = new Set(o.emits ?? []);
|
|
301
299
|
for (const m of u)
|
|
302
|
-
p.has(m) || r.push(`${e}:
|
|
300
|
+
p.has(m) || r.push(`${e}: emit ${m} is missing from the schema, ${le(t)}`);
|
|
301
|
+
for (const m of p)
|
|
302
|
+
u.has(m) || r.push(`${e}: schema emit ${m} has no counterpart in ${n}`);
|
|
303
303
|
return r;
|
|
304
304
|
}
|
|
305
|
-
async function
|
|
306
|
-
const
|
|
307
|
-
for (const i of
|
|
305
|
+
async function bt(e, t, n) {
|
|
306
|
+
const s = n ? [n] : Object.keys(t.modules.systems), o = [], r = await xe(e, t.contentDir);
|
|
307
|
+
for (const i of s) {
|
|
308
308
|
const c = t.modules.systems[i];
|
|
309
309
|
if (!c) {
|
|
310
310
|
o.push(`${i}: not a configured system`);
|
|
311
311
|
continue;
|
|
312
312
|
}
|
|
313
|
-
const l = c.framework, a =
|
|
314
|
-
for (const
|
|
315
|
-
if (
|
|
316
|
-
const m =
|
|
317
|
-
h.length || o.push(`${f}: no story, run nimpress modules story --system=${i} ${
|
|
313
|
+
const l = c.framework, a = js[l === "vue" ? "svelte" : "vue"], p = Cs[l];
|
|
314
|
+
for (const u of r) {
|
|
315
|
+
if (u.system !== i) continue;
|
|
316
|
+
const m = O(u.pageFile), f = E(e, m).split(z).join("/"), h = await Es(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
|
-
for (const
|
|
319
|
+
for (const D of h) {
|
|
320
320
|
let T;
|
|
321
321
|
try {
|
|
322
|
-
T = await
|
|
322
|
+
T = await Ee(d(m, D), "utf-8");
|
|
323
323
|
} catch {
|
|
324
324
|
continue;
|
|
325
325
|
}
|
|
326
|
-
(/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(
|
|
326
|
+
(/\bharness\s*:/.test(T) || /\brender\s*:/.test(T)) && g.add(D), T.includes(a) && o.push(`${f}/${D}: uses ${a} inside the ${l} system ${i}`);
|
|
327
327
|
for (const $ of T.matchAll(/from\s+['"]([^'"]+)['"]/g))
|
|
328
|
-
|
|
328
|
+
de($[1]) === p && o.push(`${f}/${D}: imports ${$[1]} inside the ${l} system ${i}`);
|
|
329
329
|
}
|
|
330
|
-
const w =
|
|
331
|
-
if (w &&
|
|
330
|
+
const w = Je(e, t.modules, i, u.component, u.file);
|
|
331
|
+
if (w && de(w.componentFile) === p && o.push(
|
|
332
332
|
`${f}: component file ${E(e, w.componentFile)} mismatches the ${l} system ${i}`
|
|
333
|
-
),
|
|
333
|
+
), y(d(m, "schema.json")) && y(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
|
|
338
|
-
if (!
|
|
339
|
-
o.push(`${f}: schema file missing, ${
|
|
337
|
+
const v = Qt(m);
|
|
338
|
+
if (!v) {
|
|
339
|
+
o.push(`${f}: schema file missing, ${le(u.component)}`);
|
|
340
340
|
continue;
|
|
341
341
|
}
|
|
342
|
-
let
|
|
342
|
+
let k;
|
|
343
343
|
try {
|
|
344
|
-
|
|
344
|
+
k = await Ee(v.path, "utf-8");
|
|
345
345
|
} catch {
|
|
346
|
-
o.push(`${f}: ${
|
|
346
|
+
o.push(`${f}: ${v.form} schema unreadable`);
|
|
347
347
|
continue;
|
|
348
348
|
}
|
|
349
|
-
let
|
|
349
|
+
let F;
|
|
350
350
|
try {
|
|
351
|
-
|
|
351
|
+
F = Xt(k, v.form);
|
|
352
352
|
} catch {
|
|
353
|
-
o.push(`${f}: schema is not valid ${
|
|
353
|
+
o.push(`${f}: schema is not valid ${v.form}, fix it by hand`);
|
|
354
354
|
continue;
|
|
355
355
|
}
|
|
356
|
-
const
|
|
357
|
-
for (const
|
|
358
|
-
if (!g.has(
|
|
359
|
-
for (const T of Object.keys(
|
|
360
|
-
|
|
361
|
-
const R = w ? await
|
|
356
|
+
const x = new Set(Object.keys(F.properties ?? {}));
|
|
357
|
+
for (const D of await lt(m))
|
|
358
|
+
if (!g.has(D.file))
|
|
359
|
+
for (const T of Object.keys(D.props ?? {}))
|
|
360
|
+
x.has(T) || o.push(`${f}/${D.file}: prop ${T} is absent from the schema, ${le(u.component)}`);
|
|
361
|
+
const R = w ? await Ee(w.componentFile, "utf-8").catch(() => {
|
|
362
362
|
}) : void 0;
|
|
363
363
|
if (w) {
|
|
364
|
-
const
|
|
365
|
-
if (
|
|
366
|
-
const T =
|
|
364
|
+
const D = await me(w.componentFile, l, u.component);
|
|
365
|
+
if (D) {
|
|
366
|
+
const T = ws(u.component, D.props, D.slots, D.emits);
|
|
367
367
|
o.push(
|
|
368
|
-
...
|
|
368
|
+
...Fs(f, u.component, E(e, w.componentFile), F, T)
|
|
369
369
|
);
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
|
-
|
|
372
|
+
qt(es(u.component, F, { sourceFile: w?.componentFile, sourceText: R }));
|
|
373
373
|
}
|
|
374
374
|
}
|
|
375
|
-
return
|
|
375
|
+
return Te(e), o;
|
|
376
376
|
}
|
|
377
|
-
function
|
|
377
|
+
function vt(e) {
|
|
378
378
|
return Object.entries(e.modules.systems).filter(([, t]) => t.visibility !== "dev-only").map(([t]) => t);
|
|
379
379
|
}
|
|
380
|
-
async function
|
|
381
|
-
for (const
|
|
380
|
+
async function kt(e, t, n) {
|
|
381
|
+
for (const s of n)
|
|
382
382
|
try {
|
|
383
|
-
await (await
|
|
383
|
+
await (await ht(await pt(e, t, s, "serve"))).listen(), console.log(`nimpress modules: ${s} harness on port ${ss(t.modules, s)}`);
|
|
384
384
|
} catch (o) {
|
|
385
|
-
console.warn(`nimpress modules: harness for ${
|
|
385
|
+
console.warn(`nimpress modules: harness for ${s} failed to start: ${String(o)}`);
|
|
386
386
|
}
|
|
387
387
|
}
|
|
388
|
-
async function
|
|
389
|
-
|
|
390
|
-
|
|
388
|
+
async function xt(e, t, n) {
|
|
389
|
+
const s = await xe(e, t.contentDir);
|
|
390
|
+
for (const o of n) {
|
|
391
|
+
if (!s.some((r) => r.system === o)) {
|
|
392
|
+
console.log(`nimpress modules: ${o} has no component pages, no harness built`);
|
|
393
|
+
continue;
|
|
394
|
+
}
|
|
395
|
+
await gt(await pt(e, t, o, "build")), console.log(`nimpress modules: built ${o}`);
|
|
396
|
+
}
|
|
391
397
|
}
|
|
392
|
-
async function
|
|
393
|
-
const
|
|
394
|
-
await
|
|
398
|
+
async function Ds(e, t) {
|
|
399
|
+
const n = await ht(await ut({ cwd: e, command: "serve", resolved: t }));
|
|
400
|
+
await n.listen(), await kt(e, t, Object.keys(t.modules.systems)), n.printUrls(), n.bindCLIShortcuts({ print: !0 });
|
|
395
401
|
}
|
|
396
|
-
async function
|
|
397
|
-
const
|
|
398
|
-
|
|
402
|
+
async function St(e, t) {
|
|
403
|
+
const n = d(e, "index.html"), s = !y(n);
|
|
404
|
+
s && N(n, ts(t));
|
|
399
405
|
const o = () => {
|
|
400
|
-
|
|
406
|
+
s && se(n, { force: !0 });
|
|
401
407
|
}, r = () => {
|
|
402
408
|
o(), process.exit(130);
|
|
403
409
|
};
|
|
404
410
|
process.once("SIGINT", r), process.once("SIGTERM", r);
|
|
405
411
|
try {
|
|
406
|
-
await
|
|
412
|
+
await gt(await ut({ cwd: e, command: "build", resolved: t, htmlInput: n }));
|
|
407
413
|
} finally {
|
|
408
414
|
process.off("SIGINT", r), process.off("SIGTERM", r), o();
|
|
409
415
|
}
|
|
410
|
-
await
|
|
416
|
+
await xt(e, t, vt(t));
|
|
411
417
|
}
|
|
412
|
-
const
|
|
413
|
-
function
|
|
418
|
+
const Ws = [".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte"], _s = ["", ".ts", ".tsx", ".js", ".mjs", ".vue", ".svelte", "/index.ts", "/index.js"], Xe = /^[a-z0-9][a-z0-9.-]*$/, Ns = /^[A-Z][A-Za-z0-9]*$/;
|
|
419
|
+
function Ts(e) {
|
|
414
420
|
const t = e.resolve;
|
|
415
421
|
if (!t || typeof t != "object") return [];
|
|
416
|
-
const
|
|
417
|
-
return !
|
|
418
|
-
if (!
|
|
419
|
-
const { find: o, replacement: r } =
|
|
422
|
+
const n = t.alias;
|
|
423
|
+
return !n || typeof n != "object" ? [] : Array.isArray(n) ? n.flatMap((s) => {
|
|
424
|
+
if (!s || typeof s != "object") return [];
|
|
425
|
+
const { find: o, replacement: r } = s;
|
|
420
426
|
return typeof o != "string" || typeof r != "string" ? [] : [{ find: o, replacement: r }];
|
|
421
|
-
}) : Object.entries(
|
|
422
|
-
([
|
|
427
|
+
}) : Object.entries(n).flatMap(
|
|
428
|
+
([s, o]) => typeof o == "string" ? [{ find: s, replacement: o }] : []
|
|
423
429
|
);
|
|
424
430
|
}
|
|
425
|
-
function
|
|
426
|
-
const t = [],
|
|
431
|
+
function Ps(e) {
|
|
432
|
+
const t = [], n = [
|
|
427
433
|
/(?:^|\n)[ \t]*import[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
|
|
428
434
|
/(?:^|\n)[ \t]*export[^'"\n]*?from[ \t]*['"]([^'"\n]+)['"]/g,
|
|
429
435
|
/(?:^|\n)[ \t]*import[ \t]+['"]([^'"\n]+)['"]/g,
|
|
430
436
|
/\bimport\(\s*['"]([^'"\n]+)['"]\s*\)/g
|
|
431
437
|
];
|
|
432
|
-
for (const
|
|
438
|
+
for (const s of n) {
|
|
433
439
|
let o;
|
|
434
|
-
for (; o =
|
|
440
|
+
for (; o = s.exec(e); ) t.push(o[1]);
|
|
435
441
|
}
|
|
436
442
|
return t;
|
|
437
443
|
}
|
|
438
|
-
function
|
|
439
|
-
return
|
|
440
|
-
const
|
|
441
|
-
if (!
|
|
444
|
+
function qe(e) {
|
|
445
|
+
return _s.some((t) => {
|
|
446
|
+
const n = e + t;
|
|
447
|
+
if (!y(n)) return !1;
|
|
442
448
|
try {
|
|
443
|
-
return
|
|
449
|
+
return ft(n).isFile();
|
|
444
450
|
} catch {
|
|
445
451
|
return !1;
|
|
446
452
|
}
|
|
447
453
|
});
|
|
448
454
|
}
|
|
449
|
-
function
|
|
450
|
-
const
|
|
451
|
-
for (const r of X(
|
|
452
|
-
if (!
|
|
455
|
+
function Rs(e, t) {
|
|
456
|
+
const n = j(e, t.contentDir), s = Ts(t.vite), o = [];
|
|
457
|
+
for (const r of X(n)) {
|
|
458
|
+
if (!Ws.some((l) => r.endsWith(l))) continue;
|
|
453
459
|
let i;
|
|
454
460
|
try {
|
|
455
|
-
i =
|
|
461
|
+
i = S(r, "utf-8");
|
|
456
462
|
} catch {
|
|
457
463
|
continue;
|
|
458
464
|
}
|
|
459
|
-
const c = E(
|
|
460
|
-
for (const l of
|
|
465
|
+
const c = E(n, r).split(z).join("/");
|
|
466
|
+
for (const l of Ps(i)) {
|
|
461
467
|
if (l.includes("_shared/") || l.startsWith("_shared")) {
|
|
462
468
|
o.push(
|
|
463
469
|
`${c}: imports ${l}, shared fixture folders are forbidden, stories are self contained and shared setup lives in a group harness component`
|
|
@@ -466,130 +472,130 @@ function Ns(e, t) {
|
|
|
466
472
|
}
|
|
467
473
|
const a = l.split("?")[0];
|
|
468
474
|
if (a.startsWith("./") || a.startsWith("../")) {
|
|
469
|
-
const
|
|
470
|
-
|
|
475
|
+
const u = j(O(r), a);
|
|
476
|
+
qe(u) || o.push(`${c}: unresolved import ${l}, fix the path or create the file`);
|
|
471
477
|
continue;
|
|
472
478
|
}
|
|
473
|
-
const
|
|
474
|
-
if (
|
|
475
|
-
const
|
|
476
|
-
|
|
479
|
+
const p = s.find((u) => a === u.find || a.startsWith(u.find + "/"));
|
|
480
|
+
if (p) {
|
|
481
|
+
const u = j(e, p.replacement + a.slice(p.find.length));
|
|
482
|
+
qe(u) || o.push(`${c}: unresolved import ${l} via alias ${p.find}`);
|
|
477
483
|
}
|
|
478
484
|
}
|
|
479
485
|
}
|
|
480
486
|
return o;
|
|
481
487
|
}
|
|
482
|
-
function
|
|
483
|
-
const
|
|
484
|
-
if (!
|
|
488
|
+
function As(e, t) {
|
|
489
|
+
const n = j(e, t.contentDir), s = [];
|
|
490
|
+
if (!y(n)) return [`${t.contentDir}: contentDir does not exist`];
|
|
485
491
|
const o = /* @__PURE__ */ new Map();
|
|
486
492
|
let r, i;
|
|
487
493
|
const c = /* @__PURE__ */ new Map();
|
|
488
|
-
for (const a of X(
|
|
489
|
-
const
|
|
494
|
+
for (const a of X(n)) {
|
|
495
|
+
const p = E(n, a).split(z).join("/"), u = O(a), m = W(a);
|
|
490
496
|
if (m.endsWith(".md")) {
|
|
491
|
-
const f = c.get(
|
|
492
|
-
f.push(a), c.set(
|
|
497
|
+
const f = c.get(u) ?? [];
|
|
498
|
+
f.push(a), c.set(u, f);
|
|
493
499
|
const h = m.slice(0, -3);
|
|
494
|
-
|
|
500
|
+
Xe.test(h) || s.push(`${p}: markdown file names are lowercase kebab case, rename to ${h.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9.-]+/g, "-")}.md`);
|
|
495
501
|
let g;
|
|
496
502
|
try {
|
|
497
|
-
g =
|
|
503
|
+
g = pe(S(a, "utf-8")).data, typeof g.type == "number" && (g.type = String(g.type));
|
|
498
504
|
} catch {
|
|
499
505
|
continue;
|
|
500
506
|
}
|
|
501
|
-
if (g?.type === "glossary" && (i ?
|
|
502
|
-
const w = o.get(
|
|
503
|
-
w ?
|
|
507
|
+
if (g?.type === "glossary" && (i ? s.push(`${p}: second type glossary page in the site, ${E(n, i).split(z).join("/")} already owns it, one glossary per site`) : i = a, /^: /m.test(pe(S(a, "utf-8")).content) || s.push(`${p}: type glossary needs a definition list body, term lines followed by lines starting with a colon`)), g?.type === "section" && !a.endsWith(`${z}index.md`) && s.push(`${p}: type section belongs on a folder index.md, move the page or drop the type`), g?.type === "404" && (r ? s.push(`${p}: second type 404 page in the site, ${E(n, r).split(z).join("/")} already owns it, one not found page per site`) : r = a), g?.type === "component") {
|
|
508
|
+
const w = o.get(u);
|
|
509
|
+
w ? s.push(`${p}: second type component page in one folder, ${E(n, w).split(z).join("/")} already owns it, one component per folder`) : o.set(u, a);
|
|
504
510
|
}
|
|
505
511
|
if (g?.type === "dbml") {
|
|
506
512
|
const w = typeof g.spec == "string" ? g.spec : "";
|
|
507
|
-
w ?
|
|
513
|
+
w ? y(j(u, w)) || s.push(`${p}: spec ${w} does not resolve, create the file or fix the path`) : s.push(`${p}: type dbml needs a spec field pointing at the .dbml file`);
|
|
508
514
|
}
|
|
509
|
-
g?.type === "changelog" && typeof g.path == "string" &&
|
|
515
|
+
g?.type === "changelog" && typeof g.path == "string" && s.push(`${p}: changelog entries never set path, the collection mounts at the folder route, remove the path field`);
|
|
510
516
|
}
|
|
511
|
-
if (m.endsWith(".css") && !m.startsWith("_") &&
|
|
517
|
+
if (m.endsWith(".css") && !m.startsWith("_") && W(O(a)) === "styles" && O(O(a)) === n) {
|
|
512
518
|
const f = m.replace(/\.css$/, "");
|
|
513
|
-
|
|
519
|
+
we.includes(f) || s.push(`${p}: ${f} is not a component class root, name the file after one of ${we.join(", ")}`);
|
|
514
520
|
continue;
|
|
515
521
|
}
|
|
516
522
|
if (m.endsWith(".css") && !m.startsWith("_") && m.split(".").length > 2) {
|
|
517
|
-
const f = m.split(".")[0], h =
|
|
518
|
-
if (h &&
|
|
519
|
-
|
|
523
|
+
const f = m.split(".")[0], h = rs(m, f);
|
|
524
|
+
if (h && y(d(O(a), `${f}.md`))) {
|
|
525
|
+
we.includes(h) || s.push(`${p}: ${h} is not a component class root, name the file after one of ${we.join(", ")}`);
|
|
520
526
|
continue;
|
|
521
527
|
}
|
|
522
528
|
}
|
|
523
529
|
if (m.endsWith(".css") && !m.startsWith("_")) {
|
|
524
530
|
const f = a.replace(/\.css$/, ".md");
|
|
525
|
-
|
|
531
|
+
y(f) || s.push(`${p}: page css without a matching ${W(f)}, page styles are named after the page they scope`);
|
|
526
532
|
}
|
|
527
533
|
}
|
|
528
|
-
for (const [a,
|
|
529
|
-
const
|
|
534
|
+
for (const [a, p] of c) {
|
|
535
|
+
const u = E(n, a).split(z).join("/") || ".", m = o.has(a);
|
|
530
536
|
let f = [];
|
|
531
537
|
try {
|
|
532
|
-
f =
|
|
538
|
+
f = ce(a);
|
|
533
539
|
} catch {
|
|
534
540
|
continue;
|
|
535
541
|
}
|
|
536
|
-
f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m &&
|
|
542
|
+
f.filter((g) => /\.story\.tsx?$/.test(g)).length && !m && s.push(`${u}: story files without a type component page, add the component index.md or move the stories`);
|
|
537
543
|
for (const g of ["schema.json", "schema.yml"])
|
|
538
|
-
f.includes(g) && !m &&
|
|
539
|
-
if (m &&
|
|
540
|
-
const g =
|
|
541
|
-
|
|
544
|
+
f.includes(g) && !m && s.push(`${u}: ${g} without a type component page, it belongs beside the component index.md`);
|
|
545
|
+
if (m && p.length > 1) {
|
|
546
|
+
const g = p.filter((w) => w !== o.get(a)).map((w) => W(w));
|
|
547
|
+
s.push(`${u}: a component folder holds exactly one md file, move ${g.join(", ")} out`);
|
|
542
548
|
}
|
|
543
549
|
}
|
|
544
550
|
const l = (a) => {
|
|
545
|
-
let
|
|
551
|
+
let p;
|
|
546
552
|
try {
|
|
547
|
-
|
|
553
|
+
p = ce(a, { withFileTypes: !0 });
|
|
548
554
|
} catch {
|
|
549
555
|
return;
|
|
550
556
|
}
|
|
551
|
-
for (const
|
|
552
|
-
if (
|
|
553
|
-
if (!
|
|
554
|
-
const m = E(
|
|
555
|
-
|
|
557
|
+
for (const u of p)
|
|
558
|
+
if (u.isDirectory() && !(u.name.startsWith(".") || u.name === "node_modules")) {
|
|
559
|
+
if (!Xe.test(u.name) && !Ns.test(u.name)) {
|
|
560
|
+
const m = E(n, d(a, u.name)).split(z).join("/");
|
|
561
|
+
s.push(`${m}/: folder names are lowercase kebab case, or PascalCase for component and group folders, rename it`);
|
|
556
562
|
}
|
|
557
|
-
l(d(a,
|
|
563
|
+
l(d(a, u.name));
|
|
558
564
|
}
|
|
559
565
|
};
|
|
560
|
-
return l(
|
|
566
|
+
return l(n), s;
|
|
561
567
|
}
|
|
562
|
-
async function
|
|
563
|
-
const
|
|
564
|
-
|
|
568
|
+
async function Ms(e, t) {
|
|
569
|
+
const n = Be(e, t, "lint"), s = () => se(n, { recursive: !0, force: !0 }), o = () => {
|
|
570
|
+
s(), process.exit(130);
|
|
565
571
|
};
|
|
566
572
|
process.once("SIGINT", o), process.once("SIGTERM", o);
|
|
567
573
|
try {
|
|
568
|
-
return await
|
|
574
|
+
return await St(e, { ...t, paths: { ...t.paths, out: n } }), [];
|
|
569
575
|
} catch (r) {
|
|
570
576
|
return (r instanceof Error ? r.message : String(r)).split(`
|
|
571
577
|
`).filter((c) => c.trim()).map((c) => `build: ${c.trim()}`);
|
|
572
578
|
} finally {
|
|
573
|
-
process.off("SIGINT", o), process.off("SIGTERM", o),
|
|
579
|
+
process.off("SIGINT", o), process.off("SIGTERM", o), s();
|
|
574
580
|
}
|
|
575
581
|
}
|
|
576
|
-
async function
|
|
577
|
-
const
|
|
578
|
-
...
|
|
579
|
-
...(
|
|
580
|
-
...
|
|
581
|
-
...await
|
|
582
|
+
async function Is(e, t) {
|
|
583
|
+
const n = process.argv.slice(2), s = [
|
|
584
|
+
...As(e, t),
|
|
585
|
+
...(ns(e, t.pageTypes ?? {}), await os(e, t.contentDir)),
|
|
586
|
+
...Rs(e, t),
|
|
587
|
+
...await bt(e, t)
|
|
582
588
|
];
|
|
583
|
-
if (
|
|
584
|
-
|
|
589
|
+
if (s.length) {
|
|
590
|
+
Re("nimpress lint", s, "");
|
|
585
591
|
return;
|
|
586
592
|
}
|
|
587
|
-
if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(
|
|
593
|
+
if (console.log("nimpress lint: structure, frontmatter, imports, and modules ok"), M(n, "no-build")) return;
|
|
588
594
|
console.log("nimpress lint: building to verify the output compiles");
|
|
589
|
-
const o = await
|
|
590
|
-
|
|
595
|
+
const o = await Ms(e, t);
|
|
596
|
+
Re("nimpress lint", o, "nimpress lint: build ok, everything passes");
|
|
591
597
|
}
|
|
592
|
-
const
|
|
598
|
+
const Ls = {
|
|
593
599
|
".json": "application/json",
|
|
594
600
|
".xml": "application/rss+xml",
|
|
595
601
|
".html": "text/html",
|
|
@@ -602,176 +608,176 @@ const Rs = {
|
|
|
602
608
|
".webp": "image/webp",
|
|
603
609
|
".pdf": "application/pdf"
|
|
604
610
|
};
|
|
605
|
-
function
|
|
606
|
-
const
|
|
607
|
-
if (!
|
|
611
|
+
function zs(e, t, n) {
|
|
612
|
+
const s = n[0], o = d(e, _(n, "dist") ?? t.paths.out), r = `/${t.paths.guarded}/`, i = d(o, "access.json");
|
|
613
|
+
if (!y(i))
|
|
608
614
|
throw new Error(`[nimpress] guard: ${i} not found, run a build first`);
|
|
609
|
-
const c = JSON.parse(
|
|
610
|
-
if (
|
|
611
|
-
const l =
|
|
612
|
-
const
|
|
615
|
+
const c = JSON.parse(S(i, "utf-8"));
|
|
616
|
+
if (s === "map") {
|
|
617
|
+
const l = Ke(o, t), a = d(o, "guard.map.json"), p = y(a) ? JSON.parse(S(a, "utf-8")) : { prefix: c.prefix ?? r, routes: c.routes, bundles: {} }, u = y(l) ? X(l) : [], m = p.prefix ?? r, f = u.map((w) => {
|
|
618
|
+
const v = E(l, w).split("\\").join("/"), k = v.split("/")[0] ?? "", F = [
|
|
613
619
|
...new Set(
|
|
614
|
-
Object.values(
|
|
620
|
+
Object.values(p.routes ?? {}).filter((R) => R.bundle === k && R.gate).map((R) => R.gate)
|
|
615
621
|
)
|
|
616
|
-
],
|
|
622
|
+
], x = S(w);
|
|
617
623
|
return {
|
|
618
|
-
path: `${m}${
|
|
619
|
-
file:
|
|
620
|
-
bundle:
|
|
621
|
-
sha256:
|
|
622
|
-
size:
|
|
623
|
-
mime:
|
|
624
|
-
gates:
|
|
624
|
+
path: `${m}${v}`,
|
|
625
|
+
file: v,
|
|
626
|
+
bundle: k,
|
|
627
|
+
sha256: wt("sha256").update(x).digest("hex"),
|
|
628
|
+
size: ft(w).size,
|
|
629
|
+
mime: Ls[de(w).toLowerCase()] ?? "application/octet-stream",
|
|
630
|
+
gates: F
|
|
625
631
|
};
|
|
626
|
-
}), h = _(
|
|
627
|
-
|
|
632
|
+
}), h = _(n, "out"), g = h ? d(e, h) : a;
|
|
633
|
+
N(
|
|
628
634
|
g,
|
|
629
|
-
JSON.stringify({ ...
|
|
635
|
+
JSON.stringify({ ...p, prefix: m, files: f }, null, 2) + `
|
|
630
636
|
`
|
|
631
637
|
), console.log(`nimpress guard: mapped ${f.length} guarded files to ${g}`);
|
|
632
638
|
return;
|
|
633
639
|
}
|
|
634
|
-
if (
|
|
635
|
-
const l = _(
|
|
640
|
+
if (s === "apply") {
|
|
641
|
+
const l = _(n, "map");
|
|
636
642
|
if (!l) throw new Error("[nimpress] guard apply requires --map=<uploaded mapping json>");
|
|
637
|
-
const a = JSON.parse(
|
|
643
|
+
const a = JSON.parse(S(d(e, l), "utf-8"));
|
|
638
644
|
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:
|
|
645
|
-
})),
|
|
646
|
-
`),
|
|
645
|
+
c.base = a.base.replace(/\/$/, ""), c.files = (a.files ?? []).map((p) => ({
|
|
646
|
+
path: p.path,
|
|
647
|
+
file: p.file,
|
|
648
|
+
bundle: p.bundle,
|
|
649
|
+
asset_id: p.asset_id,
|
|
650
|
+
url: p.url
|
|
651
|
+
})), N(i, JSON.stringify(c, null, 2) + `
|
|
652
|
+
`), se(Ke(o, t), { recursive: !0, force: !0 }), se(d(o, "guard.map.json"), { force: !0 }), console.log(`nimpress guard: base ${c.base} applied, ${t.paths.guarded} removed from ${o}`);
|
|
647
653
|
return;
|
|
648
654
|
}
|
|
649
655
|
throw new Error("[nimpress] guard expects map or apply");
|
|
650
656
|
}
|
|
651
|
-
function
|
|
652
|
-
const t =
|
|
657
|
+
function jt(e) {
|
|
658
|
+
const t = de(e);
|
|
653
659
|
return t === ".vue" ? "vue" : t === ".svelte" ? "svelte" : null;
|
|
654
660
|
}
|
|
655
|
-
async function
|
|
656
|
-
const i = (await
|
|
661
|
+
async function Ge(e, t, n, s, o) {
|
|
662
|
+
const i = (await xe(e, t.contentDir)).find((m) => m.system === n && m.component === s);
|
|
657
663
|
if (!i)
|
|
658
|
-
return console.warn(`[nimpress] modules story: no type component page found for ${
|
|
659
|
-
const c =
|
|
664
|
+
return console.warn(`[nimpress] modules story: no type component page found for ${n}/${s}`), null;
|
|
665
|
+
const c = Je(e, t.modules, n, s, i.file);
|
|
660
666
|
if (!c)
|
|
661
|
-
return console.warn(`[nimpress] modules story: no source found for ${
|
|
662
|
-
const l = o ??
|
|
667
|
+
return console.warn(`[nimpress] modules story: no source found for ${n}/${s}`), null;
|
|
668
|
+
const l = o ?? jt(c.componentFile);
|
|
663
669
|
if (!l)
|
|
664
670
|
throw new Error(
|
|
665
671
|
`[nimpress] modules story: failed to detect framework for ${c.componentFile}, pass --framework=vue or --framework=svelte`
|
|
666
672
|
);
|
|
667
|
-
const a = l === "vue" ? "vueStory" : "svelteStory",
|
|
673
|
+
const a = l === "vue" ? "vueStory" : "svelteStory", p = `import { ${a} } from '@nimtech/nimpress/story'
|
|
668
674
|
|
|
669
675
|
// story: Default
|
|
670
676
|
export default ${a}({
|
|
671
677
|
name: "Default"
|
|
672
678
|
})
|
|
673
|
-
`,
|
|
674
|
-
return
|
|
679
|
+
`, u = d(O(i.pageFile), "default.story.tsx");
|
|
680
|
+
return y(u) ? (console.warn(`[nimpress] modules story: ${u} exists, not overwriting`), null) : (await te(u, p), u);
|
|
675
681
|
}
|
|
676
|
-
async function
|
|
677
|
-
const
|
|
682
|
+
async function Js(e, t, n) {
|
|
683
|
+
const s = await xe(e, t.contentDir);
|
|
678
684
|
let o = 0;
|
|
679
|
-
for (const r of
|
|
680
|
-
if (!(r.system !==
|
|
685
|
+
for (const r of s)
|
|
686
|
+
if (!(r.system !== n || (await lt(O(r.pageFile))).length))
|
|
681
687
|
try {
|
|
682
|
-
await
|
|
688
|
+
await Ge(e, t, n, r.component) && o++;
|
|
683
689
|
} catch (c) {
|
|
684
690
|
console.warn(String(c));
|
|
685
691
|
}
|
|
686
692
|
return o;
|
|
687
693
|
}
|
|
688
|
-
async function
|
|
689
|
-
const r = t.modules.systems[
|
|
690
|
-
if (!r) throw new Error(`[nimpress] modules create: unknown system ${
|
|
691
|
-
const i = d(e, t.contentDir, "components", "Components",
|
|
692
|
-
if (
|
|
694
|
+
async function Bs(e, t, n, s, o) {
|
|
695
|
+
const r = t.modules.systems[n];
|
|
696
|
+
if (!r) throw new Error(`[nimpress] modules create: unknown system ${n}`);
|
|
697
|
+
const i = d(e, t.contentDir, "components", "Components", s), c = d(i, "index.md");
|
|
698
|
+
if (y(c))
|
|
693
699
|
throw new Error(`[nimpress] modules create: ${c} exists`);
|
|
694
700
|
const { mkdir: l } = await import("node:fs/promises");
|
|
695
701
|
await l(i, { recursive: !0 });
|
|
696
702
|
const a = r.package;
|
|
697
|
-
await
|
|
703
|
+
await te(
|
|
698
704
|
c,
|
|
699
705
|
`---
|
|
700
|
-
title: ${
|
|
706
|
+
title: ${s}
|
|
701
707
|
type: component
|
|
702
708
|
data:
|
|
703
|
-
system: ${
|
|
704
|
-
component: ${
|
|
709
|
+
system: ${n}
|
|
710
|
+
component: ${s}${a ? `
|
|
705
711
|
package: "${a}"` : ""}
|
|
706
712
|
---
|
|
707
713
|
|
|
708
714
|
## Usage
|
|
709
715
|
|
|
710
716
|
\`\`\`ts
|
|
711
|
-
import { ${
|
|
717
|
+
import { ${s} } from "${a ?? n}";
|
|
712
718
|
\`\`\`
|
|
713
719
|
`
|
|
714
720
|
);
|
|
715
|
-
const
|
|
716
|
-
if (
|
|
717
|
-
const
|
|
718
|
-
await
|
|
721
|
+
const p = Je(e, t.modules, n, s);
|
|
722
|
+
if (p) {
|
|
723
|
+
const u = o ?? jt(p.componentFile) ?? r.framework;
|
|
724
|
+
await fe(i, s, await me(p.componentFile, u, s)), await Ge(e, t, n, s, o);
|
|
719
725
|
} else {
|
|
720
|
-
const
|
|
721
|
-
await
|
|
726
|
+
const u = r.framework === "vue" ? "vueStory" : "svelteStory";
|
|
727
|
+
await te(
|
|
722
728
|
d(i, "default.story.tsx"),
|
|
723
|
-
`import { ${
|
|
729
|
+
`import { ${u} } from '@nimtech/nimpress/story'
|
|
724
730
|
|
|
725
731
|
// story: Default
|
|
726
|
-
export default ${
|
|
732
|
+
export default ${u}({
|
|
727
733
|
name: "Default",
|
|
728
734
|
props: {}
|
|
729
735
|
})
|
|
730
736
|
`
|
|
731
737
|
), console.warn(
|
|
732
|
-
`nimpress modules: no source found for ${
|
|
738
|
+
`nimpress modules: no source found for ${s}, wrote a stub story, schema.json follows once the component exists and import or create runs again`
|
|
733
739
|
);
|
|
734
740
|
}
|
|
735
741
|
return i;
|
|
736
742
|
}
|
|
737
|
-
function
|
|
743
|
+
function be(e) {
|
|
738
744
|
try {
|
|
739
|
-
return JSON.parse(JSON.stringify(e, (t,
|
|
745
|
+
return JSON.parse(JSON.stringify(e, (t, n) => typeof n == "function" ? void 0 : n));
|
|
740
746
|
} catch {
|
|
741
747
|
return {};
|
|
742
748
|
}
|
|
743
749
|
}
|
|
744
|
-
function
|
|
745
|
-
let
|
|
750
|
+
function ve(e, t = []) {
|
|
751
|
+
let n;
|
|
746
752
|
try {
|
|
747
|
-
|
|
753
|
+
n = ce(e, { withFileTypes: !0 });
|
|
748
754
|
} catch {
|
|
749
755
|
return t;
|
|
750
756
|
}
|
|
751
|
-
for (const
|
|
752
|
-
const o = d(e,
|
|
753
|
-
if (
|
|
754
|
-
if (
|
|
755
|
-
|
|
756
|
-
} else
|
|
757
|
+
for (const s of n) {
|
|
758
|
+
const o = d(e, s.name);
|
|
759
|
+
if (s.isDirectory()) {
|
|
760
|
+
if (s.name === "node_modules" || s.name.startsWith(".")) continue;
|
|
761
|
+
ve(o, t);
|
|
762
|
+
} else s.isFile() && t.push(o);
|
|
757
763
|
}
|
|
758
764
|
return t;
|
|
759
765
|
}
|
|
760
|
-
function
|
|
766
|
+
function Ae(e) {
|
|
761
767
|
return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
762
768
|
}
|
|
763
|
-
function
|
|
764
|
-
const t =
|
|
765
|
-
`),
|
|
769
|
+
function Me(e) {
|
|
770
|
+
const t = S(e, "utf-8"), n = t.split(`
|
|
771
|
+
`), s = [];
|
|
766
772
|
let o = 0;
|
|
767
|
-
for (; o <
|
|
768
|
-
const f =
|
|
773
|
+
for (; o < n.length; ) {
|
|
774
|
+
const f = n[o];
|
|
769
775
|
if (/^\s*import\b/.test(f)) {
|
|
770
776
|
let h = f;
|
|
771
|
-
for (; !/from\s+["'][^"']+["'];?\s*$/.test(h) && !/^\s*import\s+["'][^"']+["'];?\s*$/.test(h) && o + 1 <
|
|
777
|
+
for (; !/from\s+["'][^"']+["'];?\s*$/.test(h) && !/^\s*import\s+["'][^"']+["'];?\s*$/.test(h) && o + 1 < n.length; )
|
|
772
778
|
o++, h += `
|
|
773
|
-
` +
|
|
774
|
-
|
|
779
|
+
` + n[o];
|
|
780
|
+
s.push(h), o++;
|
|
775
781
|
continue;
|
|
776
782
|
}
|
|
777
783
|
if (/^\s*$/.test(f)) {
|
|
@@ -780,26 +786,26 @@ function Pe(e) {
|
|
|
780
786
|
}
|
|
781
787
|
break;
|
|
782
788
|
}
|
|
783
|
-
const r =
|
|
784
|
-
const h =
|
|
785
|
-
return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ?
|
|
789
|
+
const r = O(e), i = [], c = (f) => {
|
|
790
|
+
const h = j(r, f);
|
|
791
|
+
return /\.(vue|svelte)$/.test(f) ? { kind: "source", abs: h } : f.endsWith(".ts") ? y(h) ? { kind: "data", abs: h } : null : y(`${h}.ts`) ? { kind: "data", abs: `${h}.ts` } : y(`${h}.vue`) || y(`${h}.svelte`) || y(d(h, "index.ts")) ? { kind: "source", abs: h } : null;
|
|
786
792
|
};
|
|
787
|
-
for (const f of
|
|
793
|
+
for (const f of s) {
|
|
788
794
|
const h = f.match(/from\s+["'](\.\.?\/[^"']+)["']/)?.[1];
|
|
789
795
|
if (!h) continue;
|
|
790
796
|
const g = c(h);
|
|
791
797
|
g?.kind === "data" && i.push(g.abs);
|
|
792
798
|
}
|
|
793
|
-
const l =
|
|
799
|
+
const l = s.filter((f) => !f.includes("@storybook")).map(
|
|
794
800
|
(f) => f.replace(/from\s+["'](\.\.?\/[^"']+)["']/g, (h, g) => {
|
|
795
801
|
const w = c(g);
|
|
796
|
-
return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${
|
|
802
|
+
return w?.kind === "source" ? `from ${JSON.stringify(w.abs)}` : `from "./${W(g).replace(/\.ts$/, "")}"`;
|
|
797
803
|
})
|
|
798
804
|
).join(`
|
|
799
805
|
`);
|
|
800
|
-
let a = t.slice(
|
|
806
|
+
let a = t.slice(n.slice(0, o).join(`
|
|
801
807
|
`).length);
|
|
802
|
-
const
|
|
808
|
+
const p = (f) => {
|
|
803
809
|
const h = a.search(f);
|
|
804
810
|
if (h < 0) return;
|
|
805
811
|
const g = a.indexOf("{", h);
|
|
@@ -808,16 +814,16 @@ function Pe(e) {
|
|
|
808
814
|
`, h) + 1);
|
|
809
815
|
return;
|
|
810
816
|
}
|
|
811
|
-
const w =
|
|
812
|
-
a = a.slice(0, h) + a.slice(
|
|
817
|
+
const w = ye(a, g + 1), v = g + 1 + w.length + 1, k = a.slice(v).match(/^[^\n]*/)?.[0] ?? "";
|
|
818
|
+
a = a.slice(0, h) + a.slice(v + k.length);
|
|
813
819
|
};
|
|
814
|
-
|
|
815
|
-
let
|
|
816
|
-
for (; /^(?:export )?interface \w+/m.test(a) &&
|
|
817
|
-
|
|
820
|
+
p(/^const meta\b[^\n]*/m), a = a.replace(/^export default meta;?\s*$/m, ""), a = a.replace(/^(?:export )?type \w+[^\n]*\n(?:[ \t]+[^\n]*\n?)*/gm, "");
|
|
821
|
+
let u = 0;
|
|
822
|
+
for (; /^(?:export )?interface \w+/m.test(a) && u < 50; )
|
|
823
|
+
p(/^(?:export )?interface \w+[^\n]*/m), u++;
|
|
818
824
|
let m = 0;
|
|
819
825
|
for (; /^export const \w+/m.test(a) && m < 200; )
|
|
820
|
-
|
|
826
|
+
p(/^export const \w+[^\n]*/m), m++;
|
|
821
827
|
return {
|
|
822
828
|
file: e,
|
|
823
829
|
text: t,
|
|
@@ -828,10 +834,10 @@ function Pe(e) {
|
|
|
828
834
|
dataModules: i
|
|
829
835
|
};
|
|
830
836
|
}
|
|
831
|
-
function
|
|
832
|
-
const
|
|
833
|
-
let
|
|
834
|
-
for (let r =
|
|
837
|
+
function Gs(e, t) {
|
|
838
|
+
const n = e.indexOf(":", t) + 1;
|
|
839
|
+
let s = 0, o = null;
|
|
840
|
+
for (let r = n; r < e.length; r++) {
|
|
835
841
|
const i = e[r], c = e[r - 1];
|
|
836
842
|
if (o) {
|
|
837
843
|
i === o && c !== "\\" && (o = null);
|
|
@@ -841,24 +847,24 @@ function Ls(e, t) {
|
|
|
841
847
|
o = i;
|
|
842
848
|
continue;
|
|
843
849
|
}
|
|
844
|
-
if (i === "{" || i === "(" || i === "[")
|
|
845
|
-
else if (i === "}" || i === ")" || i === "]")
|
|
846
|
-
else if (i === "," &&
|
|
850
|
+
if (i === "{" || i === "(" || i === "[") s++;
|
|
851
|
+
else if (i === "}" || i === ")" || i === "]") s--;
|
|
852
|
+
else if (i === "," && s === 0) return e.slice(n, r).trim();
|
|
847
853
|
}
|
|
848
|
-
return e.slice(
|
|
854
|
+
return e.slice(n).trim();
|
|
849
855
|
}
|
|
850
|
-
function
|
|
856
|
+
function Ct(e) {
|
|
851
857
|
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
858
|
}
|
|
853
|
-
function
|
|
854
|
-
const t = [],
|
|
855
|
-
let
|
|
856
|
-
for (;
|
|
857
|
-
const o =
|
|
859
|
+
function Et(e) {
|
|
860
|
+
const t = [], n = /export const (\w+)\s*(?::[^=]*)?=\s*\{/g;
|
|
861
|
+
let s;
|
|
862
|
+
for (; s = n.exec(e.text); ) {
|
|
863
|
+
const o = s[1];
|
|
858
864
|
if (o === "default" || o === "meta") continue;
|
|
859
|
-
const r =
|
|
865
|
+
const r = ye(e.text, n.lastIndex), i = r.search(/\brender\s*:/);
|
|
860
866
|
if (i >= 0) {
|
|
861
|
-
const a =
|
|
867
|
+
const a = Gs(r, i);
|
|
862
868
|
if (a) {
|
|
863
869
|
t.push({ name: o, renderFn: a });
|
|
864
870
|
continue;
|
|
@@ -869,13 +875,13 @@ function xt(e) {
|
|
|
869
875
|
if (c >= 0) {
|
|
870
876
|
const a = r.indexOf("{", c);
|
|
871
877
|
if (a >= 0) {
|
|
872
|
-
const
|
|
878
|
+
const p = ye(r, a + 1);
|
|
873
879
|
try {
|
|
874
|
-
l =
|
|
875
|
-
return {${
|
|
880
|
+
l = be(new Function(`${Ct(e.declarations)}
|
|
881
|
+
return {${p}}`)());
|
|
876
882
|
} catch {
|
|
877
883
|
try {
|
|
878
|
-
l =
|
|
884
|
+
l = be(new Function(`return {${p}}`)());
|
|
879
885
|
} catch {
|
|
880
886
|
l = {};
|
|
881
887
|
}
|
|
@@ -886,18 +892,18 @@ return {${u}}`)());
|
|
|
886
892
|
}
|
|
887
893
|
return t;
|
|
888
894
|
}
|
|
889
|
-
function
|
|
895
|
+
function Ot(e) {
|
|
890
896
|
const t = e.text.search(/\bargTypes\s*:\s*\{/);
|
|
891
897
|
if (t < 0) return;
|
|
892
|
-
const
|
|
898
|
+
const n = e.text.indexOf("{", t), s = ye(e.text, n + 1);
|
|
893
899
|
let o;
|
|
894
900
|
try {
|
|
895
|
-
o =
|
|
901
|
+
o = be(new Function(`return {${s}}`)());
|
|
896
902
|
} catch {
|
|
897
903
|
try {
|
|
898
|
-
o =
|
|
899
|
-
new Function(`${
|
|
900
|
-
return {${
|
|
904
|
+
o = be(
|
|
905
|
+
new Function(`${Ct(e.declarations)}
|
|
906
|
+
return {${s}}`)()
|
|
901
907
|
);
|
|
902
908
|
} catch {
|
|
903
909
|
return;
|
|
@@ -906,20 +912,20 @@ return {${n}}`)()
|
|
|
906
912
|
const r = {};
|
|
907
913
|
for (const [i, c] of Object.entries(o)) {
|
|
908
914
|
if (!c || typeof c != "object") continue;
|
|
909
|
-
const l = c.control, a = typeof l == "string" ? l : String(l?.type ?? ""),
|
|
910
|
-
typeof c.description == "string" && (
|
|
915
|
+
const l = c.control, a = typeof l == "string" ? l : String(l?.type ?? ""), p = c.options ?? (typeof l == "object" ? l?.options : void 0), u = {};
|
|
916
|
+
typeof c.description == "string" && (u.description = c.description), Array.isArray(p) ? u.enum = p : a === "boolean" ? u.type = "boolean" : a === "number" || a === "range" ? u.type = "number" : a === "text" || a === "color" || a === "date" ? u.type = "string" : a === "object" && (u.type = "object"), c.defaultValue !== void 0 && (u.default = c.defaultValue), Object.keys(u).length && (r[i] = u);
|
|
911
917
|
}
|
|
912
918
|
return Object.keys(r).length ? r : void 0;
|
|
913
919
|
}
|
|
914
|
-
async function
|
|
920
|
+
async function Ft(e) {
|
|
915
921
|
const t = [...e].sort();
|
|
916
922
|
for (let i = 0; i < t.length; i++)
|
|
917
923
|
console.log(`${String(i + 1).padStart(4)} ${t[i]}`);
|
|
918
|
-
const
|
|
924
|
+
const n = $t({ input: process.stdin, output: process.stdout }), s = await n.question(
|
|
919
925
|
"select components to import, comma separated numbers, names, or /regex/, empty imports all: "
|
|
920
926
|
);
|
|
921
|
-
|
|
922
|
-
const o =
|
|
927
|
+
n.close();
|
|
928
|
+
const o = s.trim();
|
|
923
929
|
if (!o) return new Set(t);
|
|
924
930
|
const r = /* @__PURE__ */ new Set();
|
|
925
931
|
for (const i of o.split(",").map((c) => c.trim()).filter(Boolean)) {
|
|
@@ -938,154 +944,154 @@ async function jt(e) {
|
|
|
938
944
|
}
|
|
939
945
|
return r;
|
|
940
946
|
}
|
|
941
|
-
function
|
|
942
|
-
const
|
|
943
|
-
if (!
|
|
944
|
-
const o =
|
|
947
|
+
function Dt(e, t) {
|
|
948
|
+
const n = /* @__PURE__ */ new Map(), s = d(e, "node_modules", t, "index.mjs");
|
|
949
|
+
if (!y(s)) return n;
|
|
950
|
+
const o = S(s, "utf-8");
|
|
945
951
|
for (const r of o.matchAll(/export \{ default as ([A-Za-z]+) \}/g))
|
|
946
|
-
|
|
947
|
-
return
|
|
952
|
+
n.set(r[1].toLowerCase(), r[1]);
|
|
953
|
+
return n;
|
|
948
954
|
}
|
|
949
|
-
async function
|
|
950
|
-
const o = t.modules.systems[
|
|
951
|
-
if (!o) throw new Error(`[nimpress] modules import: unknown system ${
|
|
952
|
-
const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), l = o.package, a =
|
|
953
|
-
if (
|
|
954
|
-
const $ =
|
|
955
|
-
if (!
|
|
956
|
-
if (
|
|
955
|
+
async function Hs(e, t, n, s) {
|
|
956
|
+
const o = t.modules.systems[n];
|
|
957
|
+
if (!o) throw new Error(`[nimpress] modules import: unknown system ${n}`);
|
|
958
|
+
const r = o.framework, i = r === "vue" ? ".vue" : ".svelte", c = d(e, t.contentDir, "components"), l = o.package, a = s.match ? new RegExp(s.match) : null;
|
|
959
|
+
if (s.file) {
|
|
960
|
+
const $ = j(e, s.file);
|
|
961
|
+
if (!y($)) throw new Error(`[nimpress] modules import: ${$} not found`);
|
|
962
|
+
if (de($) !== i)
|
|
957
963
|
throw new Error(`[nimpress] modules import: ${$} does not match system framework ${r}`);
|
|
958
|
-
const
|
|
959
|
-
await
|
|
964
|
+
const b = s.name ?? W($, i), I = o.source ? j(e, o.source) : e, P = d(c, "Components", b);
|
|
965
|
+
await Pe(P, { recursive: !0 });
|
|
960
966
|
const A = E(I, $);
|
|
961
|
-
await
|
|
967
|
+
await te(d(P, "index.md"), Ie(n, b, l, A)), await fe(P, b, await me($, r, b)), console.log(`nimpress modules: imported ${b} at ${E(e, P)}`);
|
|
962
968
|
return;
|
|
963
969
|
}
|
|
964
|
-
if (
|
|
965
|
-
await
|
|
970
|
+
if (s.fromStories) {
|
|
971
|
+
await Us(e, t, n, s);
|
|
966
972
|
return;
|
|
967
973
|
}
|
|
968
|
-
const
|
|
969
|
-
if (!
|
|
970
|
-
throw new Error(`[nimpress] modules import: source ${
|
|
971
|
-
const
|
|
974
|
+
const p = j(e, s.source ?? o.source ?? "");
|
|
975
|
+
if (!y(p))
|
|
976
|
+
throw new Error(`[nimpress] modules import: source ${p} not found`);
|
|
977
|
+
const u = ve(p), m = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), h = u.filter(($) => $.endsWith(".stories.ts")), g = s.stories ? [j(e, s.stories)] : [];
|
|
972
978
|
for (const $ of g)
|
|
973
|
-
for (const
|
|
974
|
-
|
|
975
|
-
const w =
|
|
976
|
-
($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(
|
|
977
|
-
),
|
|
979
|
+
for (const b of ve($))
|
|
980
|
+
b.endsWith(".stories.ts") && h.push(b);
|
|
981
|
+
const w = u.filter(
|
|
982
|
+
($) => $.endsWith(i) && /^[A-Z][A-Za-z0-9]*$/.test(W($, i))
|
|
983
|
+
), v = new Set(w.map(($) => W($, i))), k = l && !o.source ? Dt(e, l) : null;
|
|
978
984
|
for (const $ of h) {
|
|
979
|
-
const
|
|
980
|
-
if (
|
|
981
|
-
const [G,
|
|
982
|
-
m.set(
|
|
985
|
+
const b = Me($);
|
|
986
|
+
if (b.title?.includes("/")) {
|
|
987
|
+
const [G, J] = b.title.split("/");
|
|
988
|
+
m.set(J, G.replace(/\s+/g, ""));
|
|
983
989
|
}
|
|
984
|
-
const I =
|
|
985
|
-
let A =
|
|
986
|
-
if (!
|
|
990
|
+
const I = W($, ".stories.ts");
|
|
991
|
+
let A = y(d(O($), `${I}${i}`)) ? I : b.metaComponent ?? I;
|
|
992
|
+
if (!v.has(A)) {
|
|
987
993
|
let G = "";
|
|
988
|
-
for (const
|
|
989
|
-
I.startsWith(
|
|
990
|
-
G ? A = G : console.warn(`nimpress modules: ${
|
|
994
|
+
for (const J of v)
|
|
995
|
+
I.startsWith(J) && J.length > G.length && (G = J);
|
|
996
|
+
G ? A = G : console.warn(`nimpress modules: ${W($)} targets ${A} which has no component page`);
|
|
991
997
|
}
|
|
992
|
-
const
|
|
993
|
-
Z.push(
|
|
994
|
-
}
|
|
995
|
-
const
|
|
996
|
-
let
|
|
997
|
-
const
|
|
998
|
-
for (const $ of
|
|
999
|
-
const
|
|
1000
|
-
if (T && !T.has(
|
|
1001
|
-
if (
|
|
1002
|
-
console.warn(`nimpress modules: skip duplicate ${
|
|
998
|
+
const C = k?.get(A.toLowerCase()) ?? A, Z = f.get(C) ?? [];
|
|
999
|
+
Z.push(b), f.set(C, Z);
|
|
1000
|
+
}
|
|
1001
|
+
const F = /* @__PURE__ */ new Map();
|
|
1002
|
+
let x = 0, R = 0;
|
|
1003
|
+
const D = w.filter(($) => !a || a.test(W($, i))), T = s.select ? await Ft(D.map(($) => W($, i))) : null;
|
|
1004
|
+
for (const $ of D) {
|
|
1005
|
+
const b = W($, i);
|
|
1006
|
+
if (T && !T.has(b)) continue;
|
|
1007
|
+
if (F.has(b)) {
|
|
1008
|
+
console.warn(`nimpress modules: skip duplicate ${b}, kept ${F.get(b)}`);
|
|
1003
1009
|
continue;
|
|
1004
1010
|
}
|
|
1005
|
-
|
|
1006
|
-
const I = m.get(
|
|
1007
|
-
await
|
|
1008
|
-
const A = E(
|
|
1009
|
-
(H,
|
|
1011
|
+
F.set(b, E(p, $));
|
|
1012
|
+
const I = m.get(b) ?? "Components", P = d(c, I, b);
|
|
1013
|
+
await Pe(P, { recursive: !0 });
|
|
1014
|
+
const A = E(p, $), C = A === `${b}/${b}${i}` || A === `${b}${i}`, Z = (f.get(b) ?? []).map((H) => Ot(H)).reduce(
|
|
1015
|
+
(H, oe) => oe ? { ...H ?? {}, ...oe } : H,
|
|
1010
1016
|
void 0
|
|
1011
1017
|
);
|
|
1012
|
-
await
|
|
1013
|
-
const G = f.get(
|
|
1018
|
+
await te(d(P, "index.md"), Ie(n, b, l, C ? void 0 : A)), await fe(P, b, await me($, r, b)), Z && await mt(P, { properties: Z }), x++;
|
|
1019
|
+
const G = f.get(b) ?? [], J = /* @__PURE__ */ new Set();
|
|
1014
1020
|
for (const H of G) {
|
|
1015
|
-
const
|
|
1016
|
-
|
|
1021
|
+
const oe = W(H.file, ".stories.ts"), Ue = Et(H);
|
|
1022
|
+
Ue.length || console.warn(`nimpress modules: no stories mined from ${W(H.file)}`);
|
|
1017
1023
|
for (const q of H.dataModules)
|
|
1018
|
-
await
|
|
1019
|
-
for (const q of
|
|
1020
|
-
const
|
|
1021
|
-
let
|
|
1022
|
-
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1024
|
+
await dt(q, d(P, W(q)));
|
|
1025
|
+
for (const q of Ue) {
|
|
1026
|
+
const Ze = q.name === b ? "Default" : oe === b ? q.name : `${oe} ${q.name}`;
|
|
1027
|
+
let ge = Ae(Ze);
|
|
1028
|
+
J.has(ge) && (ge = Ae(`${oe}-${q.name}`));
|
|
1029
|
+
const Ve = d(P, `${ge}.story.tsx`);
|
|
1030
|
+
J.add(ge), !y(Ve) && (await te(Ve, Wt(r, Ze, oe, q, H)), R++);
|
|
1025
1031
|
}
|
|
1026
1032
|
}
|
|
1027
1033
|
}
|
|
1028
|
-
console.log(`nimpress modules: imported ${
|
|
1034
|
+
console.log(`nimpress modules: imported ${x} components with ${R} stories for ${n}`);
|
|
1029
1035
|
}
|
|
1030
|
-
async function
|
|
1031
|
-
const o = t.modules.systems[
|
|
1032
|
-
if (!
|
|
1036
|
+
async function Us(e, t, n, s) {
|
|
1037
|
+
const o = t.modules.systems[n], r = o.framework, i = d(e, t.contentDir, "components"), c = j(e, s.stories ?? "");
|
|
1038
|
+
if (!s.stories || !y(c))
|
|
1033
1039
|
throw new Error("[nimpress] modules import --from-stories requires --stories=<csf dir>");
|
|
1034
|
-
const l = o.source ?
|
|
1035
|
-
let
|
|
1036
|
-
const f =
|
|
1037
|
-
f.map((g) =>
|
|
1040
|
+
const l = o.source ? j(e, o.source) : e, a = s.match ? new RegExp(s.match) : null, p = /* @__PURE__ */ new Set();
|
|
1041
|
+
let u = 0, m = 0;
|
|
1042
|
+
const f = ve(c).filter((g) => g.endsWith(".stories.ts")), h = s.select ? await Ft(
|
|
1043
|
+
f.map((g) => Me(g).metaComponent ?? W(g, ".stories.ts"))
|
|
1038
1044
|
) : null;
|
|
1039
1045
|
for (const g of f) {
|
|
1040
|
-
const w =
|
|
1041
|
-
if (h && !h.has(
|
|
1042
|
-
const
|
|
1043
|
-
new RegExp(`import\\s+(?:\\{\\s*)?${
|
|
1046
|
+
const w = Me(g), v = W(g, ".stories.ts"), k = w.metaComponent ?? v;
|
|
1047
|
+
if (h && !h.has(k)) continue;
|
|
1048
|
+
const F = w.text.match(
|
|
1049
|
+
new RegExp(`import\\s+(?:\\{\\s*)?${k}(?:\\s*\\})?\\s+from\\s+["']([^"']+)["']`)
|
|
1044
1050
|
)?.[1];
|
|
1045
|
-
let
|
|
1046
|
-
if (
|
|
1047
|
-
const
|
|
1048
|
-
R =
|
|
1049
|
-
} else if (
|
|
1050
|
-
const
|
|
1051
|
-
|
|
1052
|
-
} else if (
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1051
|
+
let x = k, R = o.package, D;
|
|
1052
|
+
if (F && !F.startsWith(".") && !F.startsWith("@/")) {
|
|
1053
|
+
const C = F.split("/")[0].startsWith("@") ? F.split("/").slice(0, 2).join("/") : F.split("/")[0];
|
|
1054
|
+
R = C, x = Dt(e, C).get(k.toLowerCase()) ?? k;
|
|
1055
|
+
} else if (F?.startsWith("@/components/")) {
|
|
1056
|
+
const C = F.slice(13);
|
|
1057
|
+
C === x || C === `${x}/${x}.vue` || (D = C.endsWith(".vue") || C.endsWith(".svelte") ? C : `${C}/${x}.vue`);
|
|
1058
|
+
} else if (F?.startsWith(".")) {
|
|
1059
|
+
const C = j(O(g), F);
|
|
1060
|
+
D = E(l, C);
|
|
1055
1061
|
}
|
|
1056
|
-
if (a && !a.test(
|
|
1057
|
-
if (
|
|
1058
|
-
console.warn(`nimpress modules: skip duplicate ${
|
|
1062
|
+
if (a && !a.test(x)) continue;
|
|
1063
|
+
if (p.has(x)) {
|
|
1064
|
+
console.warn(`nimpress modules: skip duplicate ${x} from ${W(g)}`);
|
|
1059
1065
|
continue;
|
|
1060
1066
|
}
|
|
1061
|
-
|
|
1062
|
-
const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T,
|
|
1063
|
-
await
|
|
1064
|
-
const
|
|
1065
|
-
d(l,
|
|
1066
|
-
d(l, `${
|
|
1067
|
-
]).find((
|
|
1067
|
+
p.add(x);
|
|
1068
|
+
const T = w.title?.includes("/") ? w.title.split("/")[0].replace(/\s+/g, "") : "Components", $ = d(i, T, x);
|
|
1069
|
+
await Pe($, { recursive: !0 }), await te(d($, "index.md"), Ie(n, x, R, D));
|
|
1070
|
+
const b = r === "vue" ? ".vue" : ".svelte", P = (D ? [j(l, D)] : [
|
|
1071
|
+
d(l, x, `${x}${b}`),
|
|
1072
|
+
d(l, `${x}${b}`)
|
|
1073
|
+
]).find((C) => y(C));
|
|
1068
1074
|
if (P)
|
|
1069
|
-
await
|
|
1075
|
+
await fe($, x, await me(P, r, x));
|
|
1070
1076
|
else if (R) {
|
|
1071
|
-
const
|
|
1072
|
-
|
|
1077
|
+
const C = is(e, R, x);
|
|
1078
|
+
C ? await fe($, x, as(S(C, "utf-8"), x)) : console.warn(`nimpress modules: no source or d.ts found for ${x}, the schema seed is skipped`);
|
|
1073
1079
|
}
|
|
1074
|
-
const A =
|
|
1075
|
-
A && await
|
|
1076
|
-
for (const
|
|
1077
|
-
await
|
|
1078
|
-
for (const
|
|
1079
|
-
const Z =
|
|
1080
|
-
|
|
1080
|
+
const A = Ot(w);
|
|
1081
|
+
A && await mt($, { properties: A }), u++;
|
|
1082
|
+
for (const C of w.dataModules)
|
|
1083
|
+
await dt(C, d($, W(C)));
|
|
1084
|
+
for (const C of Et(w)) {
|
|
1085
|
+
const Z = C.name === x ? "Default" : C.name, G = Ae(Z), J = d($, `${G}.story.tsx`);
|
|
1086
|
+
y(J) || (await te(J, Wt(r, Z, v, C, w)), m++);
|
|
1081
1087
|
}
|
|
1082
1088
|
}
|
|
1083
|
-
console.log(`nimpress modules: imported ${
|
|
1089
|
+
console.log(`nimpress modules: imported ${u} components with ${m} stories for ${n} from stories`);
|
|
1084
1090
|
}
|
|
1085
|
-
function
|
|
1086
|
-
const o =
|
|
1087
|
-
package: "${
|
|
1088
|
-
file: ${JSON.stringify(
|
|
1091
|
+
function Ie(e, t, n, s) {
|
|
1092
|
+
const o = n ? `
|
|
1093
|
+
package: "${n}"` : "", r = s ? `
|
|
1094
|
+
file: ${JSON.stringify(s)}` : "";
|
|
1089
1095
|
return `---
|
|
1090
1096
|
title: ${t}
|
|
1091
1097
|
type: component
|
|
@@ -1097,13 +1103,13 @@ data:
|
|
|
1097
1103
|
## Usage
|
|
1098
1104
|
|
|
1099
1105
|
\`\`\`ts
|
|
1100
|
-
import { ${t} } from "${
|
|
1106
|
+
import { ${t} } from "${n ?? e}";
|
|
1101
1107
|
\`\`\`
|
|
1102
1108
|
`;
|
|
1103
1109
|
}
|
|
1104
|
-
function
|
|
1110
|
+
function Wt(e, t, n, s, o) {
|
|
1105
1111
|
const r = e === "vue" ? "vueStory" : "svelteStory";
|
|
1106
|
-
return
|
|
1112
|
+
return s.renderFn ? `import { ${r} } from '@nimtech/nimpress/story'
|
|
1107
1113
|
${o.imports}
|
|
1108
1114
|
|
|
1109
1115
|
${o.declarations}
|
|
@@ -1111,442 +1117,481 @@ ${o.declarations}
|
|
|
1111
1117
|
// story: ${t}
|
|
1112
1118
|
export default ${r}({
|
|
1113
1119
|
name: ${JSON.stringify(t)},
|
|
1114
|
-
description: ${JSON.stringify(`Scenario from ${
|
|
1115
|
-
render: ${
|
|
1120
|
+
description: ${JSON.stringify(`Scenario from ${n}`)},
|
|
1121
|
+
render: ${s.renderFn}
|
|
1116
1122
|
})
|
|
1117
1123
|
` : `import { ${r} } from '@nimtech/nimpress/story'
|
|
1118
1124
|
|
|
1119
1125
|
// story: ${t}
|
|
1120
1126
|
export default ${r}({
|
|
1121
1127
|
name: ${JSON.stringify(t)},
|
|
1122
|
-
props: ${JSON.stringify(
|
|
1128
|
+
props: ${JSON.stringify(s.props ?? {}, null, 2)}
|
|
1123
1129
|
})
|
|
1124
1130
|
`;
|
|
1125
1131
|
}
|
|
1126
|
-
|
|
1132
|
+
const ee = { target: "", gate: "", set: !1, off: !1 };
|
|
1133
|
+
function He(e) {
|
|
1127
1134
|
if (!e.startsWith(`---
|
|
1128
1135
|
`)) return null;
|
|
1129
1136
|
const t = e.indexOf(`
|
|
1130
1137
|
---`, 4);
|
|
1131
1138
|
return t < 0 ? null : e.slice(4, t);
|
|
1132
1139
|
}
|
|
1133
|
-
function
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
const
|
|
1140
|
+
function Oe(e) {
|
|
1141
|
+
return e.trim().replace(/^["']|["']$/g, "");
|
|
1142
|
+
}
|
|
1143
|
+
function _t(e) {
|
|
1144
|
+
const t = e.split(`
|
|
1145
|
+
`), n = t.findIndex((r) => r.startsWith("export:"));
|
|
1146
|
+
if (n < 0) return ee;
|
|
1147
|
+
const s = Oe(t[n].slice(7));
|
|
1148
|
+
if (s === "false") return { ...ee, set: !0, off: !0 };
|
|
1149
|
+
if (s !== "") return { ...ee, target: s, set: !0 };
|
|
1150
|
+
const o = { ...ee, set: !0 };
|
|
1151
|
+
for (const r of t.slice(n + 1)) {
|
|
1152
|
+
if (!r.startsWith(" ")) break;
|
|
1153
|
+
const [i, ...c] = r.trim().split(":");
|
|
1154
|
+
i === "target" && (o.target = Oe(c.join(":"))), i === "gate" && (o.gate = Oe(c.join(":")));
|
|
1155
|
+
}
|
|
1156
|
+
return o.target || (o.target = "true"), o;
|
|
1157
|
+
}
|
|
1158
|
+
function Zs(e) {
|
|
1159
|
+
if (!y(e)) return ee;
|
|
1160
|
+
const t = He(S(e, "utf-8"));
|
|
1161
|
+
return t === null ? ee : _t(t);
|
|
1162
|
+
}
|
|
1163
|
+
function Le(e, t, n) {
|
|
1164
|
+
const s = n.get(t);
|
|
1165
|
+
if (s) return s;
|
|
1166
|
+
const o = Zs(d(t, "index.md")), r = t === e || !t.startsWith(e) ? ee : Le(e, O(t), n), i = o.set ? o.off ? ee : o : r;
|
|
1167
|
+
return n.set(t, i), i;
|
|
1168
|
+
}
|
|
1169
|
+
function Vs(e, t, n = "") {
|
|
1170
|
+
const s = He(e);
|
|
1144
1171
|
if (s === null) return e;
|
|
1145
|
-
const
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1172
|
+
const o = [];
|
|
1173
|
+
let r = !1;
|
|
1174
|
+
for (const c of s.split(`
|
|
1175
|
+
`))
|
|
1176
|
+
r && c.startsWith(" ") || (r = c.startsWith("export:"), !(r || c.startsWith(" file:")) && o.push(c));
|
|
1177
|
+
const i = o.findIndex((c) => c.startsWith(" package:"));
|
|
1178
|
+
return t && i >= 0 && !o.some((c) => c.startsWith(" version:")) && o.splice(i + 1, 0, ` version: ${JSON.stringify(t)}`), n && !o.some((c) => c.startsWith("gate:")) && o.push(`gate: ${n}`), `---
|
|
1179
|
+
${o.join(`
|
|
1149
1180
|
`)}${e.slice(4 + s.length)}`;
|
|
1150
1181
|
}
|
|
1151
|
-
function
|
|
1152
|
-
const
|
|
1182
|
+
function ze(e, t, n) {
|
|
1183
|
+
const s = _(n, "target") ?? "", o = d(e, _(n, "out") ?? t.paths.export), r = d(e, t.contentDir);
|
|
1153
1184
|
let i = "";
|
|
1154
1185
|
try {
|
|
1155
|
-
i = JSON.parse(
|
|
1186
|
+
i = JSON.parse(S(d(e, "package.json"), "utf-8")).version ?? "";
|
|
1156
1187
|
} catch {
|
|
1157
1188
|
i = "";
|
|
1158
1189
|
}
|
|
1159
|
-
|
|
1160
|
-
for (const
|
|
1161
|
-
if (!
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
const m =
|
|
1167
|
-
|
|
1168
|
-
|
|
1190
|
+
const c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map(), a = [];
|
|
1191
|
+
for (const u of X(r)) {
|
|
1192
|
+
if (!u.endsWith(".md")) {
|
|
1193
|
+
const v = Le(r, O(u), c);
|
|
1194
|
+
v.set && (!s || v.target === s || v.target === "true") && a.push(u);
|
|
1195
|
+
continue;
|
|
1196
|
+
}
|
|
1197
|
+
const m = He(S(u, "utf-8"));
|
|
1198
|
+
if (m === null) continue;
|
|
1199
|
+
const f = _t(m), h = Le(r, O(u), c), g = h.set && !(f.set && f.off) && (!f.set || W(u) === "index.md"), w = g ? h : f;
|
|
1200
|
+
!w.set || w.off || s && w.target !== s && w.target !== "true" || l.set(u, { spec: w, folder: g });
|
|
1201
|
+
}
|
|
1202
|
+
const p = /* @__PURE__ */ new Set();
|
|
1203
|
+
for (const u of a) {
|
|
1204
|
+
const m = d(o, E(r, u));
|
|
1205
|
+
L(O(m), { recursive: !0 }), N(m, S(u)), p.add(u);
|
|
1206
|
+
}
|
|
1207
|
+
for (const [u, m] of l) {
|
|
1208
|
+
const f = O(u);
|
|
1209
|
+
for (const h of ce(f, { withFileTypes: !0 })) {
|
|
1169
1210
|
if (!h.isFile()) continue;
|
|
1170
|
-
const g =
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1211
|
+
const g = d(f, h.name);
|
|
1212
|
+
if (p.has(g)) continue;
|
|
1213
|
+
let w = m.spec.gate;
|
|
1214
|
+
if (h.name.endsWith(".md")) {
|
|
1215
|
+
const k = l.get(g);
|
|
1216
|
+
if (!k && m.folder) continue;
|
|
1217
|
+
k && (w = k.spec.gate);
|
|
1218
|
+
}
|
|
1219
|
+
const v = d(o, E(r, g));
|
|
1220
|
+
L(O(v), { recursive: !0 }), N(v, h.name.endsWith(".md") ? Vs(S(g, "utf-8"), i, w) : S(g)), p.add(g);
|
|
1175
1221
|
}
|
|
1176
|
-
c++;
|
|
1177
1222
|
}
|
|
1178
|
-
console.log(`nimpress export: ${
|
|
1223
|
+
console.log(`nimpress export: ${l.size} pages collected into ${o}`);
|
|
1179
1224
|
}
|
|
1180
|
-
function
|
|
1225
|
+
function Nt(e = Q()) {
|
|
1181
1226
|
return d(e, ".nimpress", "config.json");
|
|
1182
1227
|
}
|
|
1183
|
-
function
|
|
1228
|
+
function Tt(e = Q()) {
|
|
1184
1229
|
return d(e, ".tide", "nimpress", "sites");
|
|
1185
1230
|
}
|
|
1186
|
-
function
|
|
1187
|
-
const t =
|
|
1188
|
-
return
|
|
1231
|
+
function Pt(e = Q()) {
|
|
1232
|
+
const t = Nt(e);
|
|
1233
|
+
return y(t) ? { links: JSON.parse(S(t, "utf-8")).links ?? {} } : { links: {} };
|
|
1189
1234
|
}
|
|
1190
|
-
function
|
|
1191
|
-
const
|
|
1192
|
-
|
|
1235
|
+
function Rt(e, t = Q()) {
|
|
1236
|
+
const n = Nt(t);
|
|
1237
|
+
L(O(n), { recursive: !0 }), N(n, `${JSON.stringify(e, null, 2)}
|
|
1193
1238
|
`);
|
|
1194
1239
|
}
|
|
1195
|
-
function
|
|
1196
|
-
const t = e.trim().replace(/\.git$/, "").replace(/\/+$/, ""),
|
|
1197
|
-
if (
|
|
1198
|
-
const
|
|
1199
|
-
if (
|
|
1240
|
+
function ke(e) {
|
|
1241
|
+
const t = e.trim().replace(/\.git$/, "").replace(/\/+$/, ""), n = t.match(/[:/]([^/:]+)\/([^/]+)$/);
|
|
1242
|
+
if (n && t.includes("github.com")) return `${n[1]}/${n[2]}`;
|
|
1243
|
+
const s = t.match(/^([^/\s]+)\/([^/\s]+)$/);
|
|
1244
|
+
if (s) return `${s[1]}/${s[2]}`;
|
|
1200
1245
|
throw new Error(`[nimpress] view: cannot read owner/repo from ${e}`);
|
|
1201
1246
|
}
|
|
1202
|
-
function
|
|
1247
|
+
function Fe(e) {
|
|
1203
1248
|
const t = e.trim();
|
|
1204
|
-
return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${
|
|
1249
|
+
return /^(https?:\/\/|git@|ssh:\/\/)/.test(t) ? t : `https://github.com/${ke(t)}.git`;
|
|
1205
1250
|
}
|
|
1206
|
-
function
|
|
1251
|
+
function At(e) {
|
|
1207
1252
|
const t = d(e, ".github", "workflows");
|
|
1208
|
-
return
|
|
1253
|
+
return y(t) ? ce(t).filter((n) => n.endsWith(".yml") || n.endsWith(".yaml")).sort().map((n) => d(t, n)) : [];
|
|
1209
1254
|
}
|
|
1210
|
-
function
|
|
1255
|
+
function Mt(e) {
|
|
1211
1256
|
try {
|
|
1212
|
-
const t =
|
|
1257
|
+
const t = ys(S(e, "utf-8"));
|
|
1213
1258
|
return typeof t == "object" && t !== null ? t : null;
|
|
1214
1259
|
} catch {
|
|
1215
1260
|
return null;
|
|
1216
1261
|
}
|
|
1217
1262
|
}
|
|
1218
|
-
function
|
|
1219
|
-
return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (
|
|
1263
|
+
function ue(e, t) {
|
|
1264
|
+
return String(e ?? "").replace(/\$\{\{\s*env\.([A-Za-z_][A-Za-z0-9_]*)\s*\}\}/g, (s, o) => {
|
|
1220
1265
|
for (const r of t)
|
|
1221
1266
|
if (r && r[o] !== void 0) return String(r[o]);
|
|
1222
1267
|
return "";
|
|
1223
1268
|
}).trim();
|
|
1224
1269
|
}
|
|
1225
|
-
function
|
|
1226
|
-
const
|
|
1227
|
-
for (const
|
|
1228
|
-
for (const o of
|
|
1229
|
-
typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) &&
|
|
1230
|
-
return
|
|
1270
|
+
function It(e, t) {
|
|
1271
|
+
const n = [];
|
|
1272
|
+
for (const s of Object.values(e.jobs ?? {}))
|
|
1273
|
+
for (const o of s.steps ?? [])
|
|
1274
|
+
typeof o.uses == "string" && o.uses.includes(`/actions/${t}@`) && n.push({ step: o, scopes: [o.env, s.env, e.env] });
|
|
1275
|
+
return n;
|
|
1231
1276
|
}
|
|
1232
|
-
function
|
|
1277
|
+
function Ks(e) {
|
|
1233
1278
|
const t = /* @__PURE__ */ new Map();
|
|
1234
|
-
for (const
|
|
1235
|
-
const
|
|
1236
|
-
if (
|
|
1237
|
-
for (const { step: o, scopes: r } of
|
|
1238
|
-
const i =
|
|
1279
|
+
for (const n of At(e)) {
|
|
1280
|
+
const s = Mt(n);
|
|
1281
|
+
if (s)
|
|
1282
|
+
for (const { step: o, scopes: r } of It(s, "docs-notify")) {
|
|
1283
|
+
const i = ue(o.with?.["docs-repo"], r);
|
|
1239
1284
|
if (!i) continue;
|
|
1240
|
-
const c =
|
|
1285
|
+
const c = ue(o.with?.["export-dir"], r) || ".nimpress";
|
|
1241
1286
|
t.set(i, { repo: i, exportDir: c });
|
|
1242
1287
|
}
|
|
1243
1288
|
}
|
|
1244
1289
|
return [...t.values()];
|
|
1245
1290
|
}
|
|
1246
|
-
function
|
|
1291
|
+
function et(e) {
|
|
1247
1292
|
return e.replace(/\$\{\{\s*github\.workspace\s*\}\}\/?/g, "").replace(/^\.\//, "");
|
|
1248
1293
|
}
|
|
1249
|
-
function
|
|
1250
|
-
const
|
|
1294
|
+
function Ys(e, t) {
|
|
1295
|
+
const n = {
|
|
1251
1296
|
contentRoot: t,
|
|
1252
|
-
mapping:
|
|
1297
|
+
mapping: y(d(e, "nimpress.sources.json")) ? "nimpress.sources.json" : "",
|
|
1253
1298
|
defaults: {}
|
|
1254
1299
|
};
|
|
1255
|
-
for (const
|
|
1256
|
-
const o =
|
|
1300
|
+
for (const s of At(e)) {
|
|
1301
|
+
const o = Mt(s);
|
|
1257
1302
|
if (o)
|
|
1258
|
-
for (const { step: r, scopes: i } of
|
|
1259
|
-
const c =
|
|
1260
|
-
const f =
|
|
1303
|
+
for (const { step: r, scopes: i } of It(o, "docs-sync")) {
|
|
1304
|
+
const c = et(ue(r.with?.["docs-dir"], i)), l = (m) => {
|
|
1305
|
+
const f = et(m);
|
|
1261
1306
|
return (c && f.startsWith(`${c}/`) ? f.slice(c.length + 1) : f).replace(/\/+$/, "");
|
|
1262
|
-
}, a =
|
|
1263
|
-
a && (
|
|
1264
|
-
const
|
|
1265
|
-
|
|
1266
|
-
const
|
|
1267
|
-
return
|
|
1307
|
+
}, a = ue(r.with?.["content-root"], i);
|
|
1308
|
+
a && (n.contentRoot = l(a));
|
|
1309
|
+
const p = ue(r.with?.mapping, i);
|
|
1310
|
+
p && (n.mapping = l(p));
|
|
1311
|
+
const u = ue(r.with?.defaults, i);
|
|
1312
|
+
return u && (n.defaults = JSON.parse(u)), n;
|
|
1268
1313
|
}
|
|
1269
1314
|
}
|
|
1270
|
-
return
|
|
1315
|
+
return n;
|
|
1271
1316
|
}
|
|
1272
|
-
function
|
|
1273
|
-
const
|
|
1274
|
-
return t.target && (
|
|
1317
|
+
function Qs(e, t) {
|
|
1318
|
+
const n = { ...e };
|
|
1319
|
+
return t.target && (n.target = t.target), t.targets?.length && (n.targets = t.targets), t.mode && (n.mode = t.mode), n;
|
|
1275
1320
|
}
|
|
1276
|
-
function
|
|
1321
|
+
function Xs(e) {
|
|
1277
1322
|
const t = e.mode || "mirror";
|
|
1278
|
-
return e.targets?.length ? e.targets.map((
|
|
1323
|
+
return e.targets?.length ? e.targets.map((n) => ({ from: n.from ?? "", to: n.to, mode: n.mode || t })) : e.target ? [{ from: "", to: e.target, mode: t }] : [];
|
|
1279
1324
|
}
|
|
1280
|
-
function
|
|
1281
|
-
let
|
|
1325
|
+
function qs(e, t, n) {
|
|
1326
|
+
let s = t.defaults;
|
|
1282
1327
|
const o = t.mapping ? d(e, t.mapping) : "";
|
|
1283
|
-
if (o &&
|
|
1284
|
-
const i = JSON.parse(
|
|
1285
|
-
i && (
|
|
1328
|
+
if (o && y(o)) {
|
|
1329
|
+
const i = JSON.parse(S(o, "utf-8")).sources?.[n];
|
|
1330
|
+
i && (s = Qs(s, i));
|
|
1286
1331
|
}
|
|
1287
|
-
return
|
|
1332
|
+
return s;
|
|
1288
1333
|
}
|
|
1289
|
-
function
|
|
1334
|
+
function tt(e) {
|
|
1290
1335
|
const t = /* @__PURE__ */ new Map();
|
|
1291
|
-
if (!
|
|
1292
|
-
for (const
|
|
1293
|
-
t.set(E(e,
|
|
1336
|
+
if (!y(e)) return t;
|
|
1337
|
+
for (const n of X(e))
|
|
1338
|
+
t.set(E(e, n).split(z).join("/"), S(n));
|
|
1294
1339
|
return t;
|
|
1295
1340
|
}
|
|
1296
|
-
function
|
|
1297
|
-
const
|
|
1341
|
+
function en(e, t, n) {
|
|
1342
|
+
const s = { added: [], modified: [], deleted: [] }, o = tt(e), r = tt(t);
|
|
1298
1343
|
for (const [i, c] of o) {
|
|
1299
1344
|
const l = r.get(i);
|
|
1300
1345
|
if (l && l.equals(c)) continue;
|
|
1301
1346
|
const a = d(t, ...i.split("/"));
|
|
1302
|
-
|
|
1347
|
+
L(O(a), { recursive: !0 }), N(a, c), l ? s.modified.push(i) : s.added.push(i);
|
|
1303
1348
|
}
|
|
1304
|
-
if (
|
|
1349
|
+
if (n === "mirror")
|
|
1305
1350
|
for (const i of r.keys())
|
|
1306
|
-
o.has(i) || (
|
|
1307
|
-
return
|
|
1351
|
+
o.has(i) || (se(d(t, ...i.split("/")), { force: !0 }), s.deleted.push(i));
|
|
1352
|
+
return s;
|
|
1308
1353
|
}
|
|
1309
|
-
function
|
|
1310
|
-
const
|
|
1354
|
+
function tn(e, t) {
|
|
1355
|
+
const n = /* @__PURE__ */ new Map();
|
|
1311
1356
|
for (const o of X(e)) {
|
|
1312
1357
|
if (!o.endsWith(".md")) continue;
|
|
1313
|
-
const r =
|
|
1314
|
-
|
|
1358
|
+
const r = pe(S(o, "utf-8")).data.path, i = cs(e, o, typeof r == "string" ? r : void 0);
|
|
1359
|
+
n.set(i, [...n.get(i) ?? [], o]);
|
|
1315
1360
|
}
|
|
1316
|
-
const
|
|
1317
|
-
for (const o of
|
|
1318
|
-
o.some((r) => t.has(r)) &&
|
|
1319
|
-
return
|
|
1361
|
+
const s = [];
|
|
1362
|
+
for (const o of n.values())
|
|
1363
|
+
o.some((r) => t.has(r)) && s.push(...o.filter((r) => !t.has(r)));
|
|
1364
|
+
return s.sort();
|
|
1320
1365
|
}
|
|
1321
|
-
function
|
|
1322
|
-
const
|
|
1323
|
-
return { ok:
|
|
1366
|
+
function ae(e, t, n) {
|
|
1367
|
+
const s = ne("git", e, { cwd: t, encoding: "utf-8", env: { ...process.env, ...n } });
|
|
1368
|
+
return { ok: s.status === 0, out: `${s.stdout ?? ""}${s.stderr ?? ""}`.trim() };
|
|
1324
1369
|
}
|
|
1325
|
-
function
|
|
1326
|
-
const t =
|
|
1370
|
+
function Lt(e) {
|
|
1371
|
+
const t = ae(["rev-parse", "--show-toplevel"], e);
|
|
1327
1372
|
return t.ok ? t.out : e;
|
|
1328
1373
|
}
|
|
1329
|
-
function
|
|
1330
|
-
const t =
|
|
1374
|
+
function sn(e) {
|
|
1375
|
+
const t = ae(["remote", "get-url", "origin"], e);
|
|
1331
1376
|
if (!t.ok) throw new Error(`[nimpress] view: ${e} has no origin remote, so its docs site mapping cannot be looked up`);
|
|
1332
|
-
return
|
|
1377
|
+
return ke(t.out);
|
|
1333
1378
|
}
|
|
1334
|
-
function
|
|
1335
|
-
return
|
|
1379
|
+
function nn() {
|
|
1380
|
+
return ne("gh", ["--version"], { encoding: "utf-8" }).status === 0;
|
|
1336
1381
|
}
|
|
1337
|
-
function
|
|
1382
|
+
function zt(e) {
|
|
1338
1383
|
return e?.method === "ssh" && e.key ? { GIT_SSH_COMMAND: `ssh -i ${e.key} -o IdentitiesOnly=yes` } : {};
|
|
1339
1384
|
}
|
|
1340
|
-
function
|
|
1341
|
-
return e.login?.method === "gh" ?
|
|
1385
|
+
function De(e) {
|
|
1386
|
+
return e.login?.method === "gh" ? ne("gh", ["repo", "view", e.repo, "--json", "name"], { encoding: "utf-8" }).status === 0 : ae(["ls-remote", "--exit-code", "-h", e.url], void 0, zt(e.login)).ok;
|
|
1342
1387
|
}
|
|
1343
|
-
async function
|
|
1344
|
-
const t =
|
|
1388
|
+
async function Jt(e) {
|
|
1389
|
+
const t = $t({ input: process.stdin, output: process.stdout });
|
|
1345
1390
|
try {
|
|
1346
1391
|
return (await t.question(e)).trim();
|
|
1347
1392
|
} finally {
|
|
1348
1393
|
t.close();
|
|
1349
1394
|
}
|
|
1350
1395
|
}
|
|
1351
|
-
async function
|
|
1352
|
-
if (
|
|
1353
|
-
if (console.log(`nimpress view: ${e.url} refused the connection`),
|
|
1354
|
-
if (console.log("nimpress view: logging in through gh"),
|
|
1396
|
+
async function on(e) {
|
|
1397
|
+
if (De(e)) return e;
|
|
1398
|
+
if (console.log(`nimpress view: ${e.url} refused the connection`), nn()) {
|
|
1399
|
+
if (console.log("nimpress view: logging in through gh"), ne("gh", ["auth", "login"], { stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: gh auth login did not complete");
|
|
1355
1400
|
const o = { ...e, login: { method: "gh" } };
|
|
1356
|
-
if (
|
|
1401
|
+
if (De(o)) return o;
|
|
1357
1402
|
throw new Error(`[nimpress] view: ${e.repo} is still unreachable after the gh login, ask for access to it`);
|
|
1358
1403
|
}
|
|
1359
|
-
const t = await
|
|
1404
|
+
const t = await Jt("nimpress view: path to the ssh key with access to the repo: ");
|
|
1360
1405
|
if (!t) throw new Error("[nimpress] view: no ssh key given and gh is not installed");
|
|
1361
|
-
const
|
|
1362
|
-
if (
|
|
1363
|
-
throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${
|
|
1406
|
+
const n = { ...e, login: { method: "ssh", key: j(t.replace(/^~/, Q())) } };
|
|
1407
|
+
if (De(n)) return n;
|
|
1408
|
+
throw new Error(`[nimpress] view: ${e.repo} is still unreachable with ${n.login.key}, ask for access to it`);
|
|
1364
1409
|
}
|
|
1365
|
-
async function
|
|
1366
|
-
const
|
|
1410
|
+
async function rn(e, t, n = Q()) {
|
|
1411
|
+
const s = Lt(e), o = Pt(n), r = o.links[s] ?? [], i = Ks(s), c = _(t, "docs-repo");
|
|
1367
1412
|
let l;
|
|
1368
1413
|
if (c) {
|
|
1369
|
-
const
|
|
1370
|
-
l = [{ repo:
|
|
1414
|
+
const p = ke(c), u = i.find((m) => m.repo === p)?.exportDir ?? _(t, "export-dir") ?? ".nimpress";
|
|
1415
|
+
l = [{ repo: p, url: Fe(c), exportDir: u, login: r.find((m) => m.repo === p)?.login }];
|
|
1371
1416
|
} else if (i.length)
|
|
1372
|
-
l = i.map((
|
|
1373
|
-
repo:
|
|
1374
|
-
url: r.find((
|
|
1375
|
-
exportDir:
|
|
1376
|
-
login: r.find((
|
|
1417
|
+
l = i.map((p) => ({
|
|
1418
|
+
repo: p.repo,
|
|
1419
|
+
url: r.find((u) => u.repo === p.repo)?.url ?? Fe(p.repo),
|
|
1420
|
+
exportDir: p.exportDir,
|
|
1421
|
+
login: r.find((u) => u.repo === p.repo)?.login
|
|
1377
1422
|
}));
|
|
1378
1423
|
else if (r.length)
|
|
1379
1424
|
l = r;
|
|
1380
1425
|
else {
|
|
1381
|
-
console.log(`nimpress view: no workflow under ${
|
|
1382
|
-
const
|
|
1383
|
-
if (!
|
|
1384
|
-
l = [{ repo:
|
|
1426
|
+
console.log(`nimpress view: no workflow under ${s} names a docs site`);
|
|
1427
|
+
const p = await Jt("nimpress view: docs site repo, owner/repo or a url, http or ssh: ");
|
|
1428
|
+
if (!p) throw new Error("[nimpress] view: no docs site given");
|
|
1429
|
+
l = [{ repo: ke(p), url: Fe(p), exportDir: _(t, "export-dir") ?? ".nimpress" }];
|
|
1385
1430
|
}
|
|
1386
1431
|
const a = [];
|
|
1387
|
-
for (const
|
|
1388
|
-
return o.links[
|
|
1432
|
+
for (const p of l) a.push(await on(p));
|
|
1433
|
+
return o.links[s] = a, Rt(o, n), a;
|
|
1389
1434
|
}
|
|
1390
|
-
function
|
|
1391
|
-
return d(
|
|
1435
|
+
function an(e, t = Q()) {
|
|
1436
|
+
return d(Tt(t), e.repo.replace("/", "__"));
|
|
1392
1437
|
}
|
|
1393
|
-
function
|
|
1394
|
-
const
|
|
1395
|
-
if (!
|
|
1396
|
-
|
|
1397
|
-
const r = e.login?.method === "gh" ?
|
|
1438
|
+
function cn(e, t, n) {
|
|
1439
|
+
const s = zt(e.login);
|
|
1440
|
+
if (!y(d(t, ".git"))) {
|
|
1441
|
+
L(O(t), { recursive: !0 }), console.log(`nimpress view: cloning ${e.repo}`);
|
|
1442
|
+
const r = e.login?.method === "gh" ? ne("gh", ["repo", "clone", e.repo, t, "--", "--depth", "1"], { encoding: "utf-8" }) : ne("git", ["clone", "--depth", "1", e.url, t], { encoding: "utf-8", env: { ...process.env, ...s } });
|
|
1398
1443
|
if (r.status !== 0) throw new Error(`[nimpress] view: clone of ${e.repo} failed
|
|
1399
1444
|
${r.stderr ?? ""}`);
|
|
1400
1445
|
return;
|
|
1401
1446
|
}
|
|
1402
|
-
if (
|
|
1403
|
-
const o =
|
|
1447
|
+
if (n) return;
|
|
1448
|
+
const o = ae(["fetch", "--depth", "1", "origin", "HEAD"], t, s);
|
|
1404
1449
|
if (!o.ok) throw new Error(`[nimpress] view: fetch of ${e.repo} failed
|
|
1405
1450
|
${o.out}`);
|
|
1406
|
-
|
|
1451
|
+
ae(["reset", "--hard", "FETCH_HEAD"], t), ae(["clean", "-fd"], t);
|
|
1407
1452
|
}
|
|
1408
|
-
function
|
|
1409
|
-
const t = ["pnpm-lock.yaml", "package.json"].map((
|
|
1410
|
-
return t ?
|
|
1453
|
+
function ln(e) {
|
|
1454
|
+
const t = ["pnpm-lock.yaml", "package.json"].map((n) => d(e, n)).find((n) => y(n));
|
|
1455
|
+
return t ? wt("sha256").update(S(t)).digest("hex") : "";
|
|
1411
1456
|
}
|
|
1412
|
-
function
|
|
1413
|
-
const t = d(e, B.paths.cache, "view", "lockfile.sha256"),
|
|
1414
|
-
if (
|
|
1415
|
-
if (console.log("nimpress view: installing the docs site dependencies"),
|
|
1416
|
-
|
|
1457
|
+
function un(e) {
|
|
1458
|
+
const t = d(e, B.paths.cache, "view", "lockfile.sha256"), n = ln(e);
|
|
1459
|
+
if (y(d(e, "node_modules")) && y(t) && S(t, "utf-8").trim() === n) return;
|
|
1460
|
+
if (console.log("nimpress view: installing the docs site dependencies"), ne("pnpm", ["install"], { cwd: e, stdio: "inherit" }).status !== 0) throw new Error("[nimpress] view: pnpm install failed in the docs site clone");
|
|
1461
|
+
L(O(t), { recursive: !0 }), N(t, `${n}
|
|
1417
1462
|
`);
|
|
1418
1463
|
}
|
|
1419
|
-
function
|
|
1420
|
-
const
|
|
1464
|
+
function Bt(e, t) {
|
|
1465
|
+
const n = $s(), s = n === "darwin" ? ["open", ...t ? ["-a", t] : [], e] : n === "win32" ? ["cmd", "/c", "start", "", ...t ? [t] : [], e] : t ? [t, e] : ["xdg-open", e], o = Se(s[0], s.slice(1), { stdio: "ignore", detached: !0 });
|
|
1421
1466
|
o.on("error", () => console.log(`nimpress: open ${e} in ${t ?? "a browser"}`)), o.unref();
|
|
1422
1467
|
}
|
|
1423
|
-
function
|
|
1424
|
-
let
|
|
1468
|
+
function st(e, t) {
|
|
1469
|
+
let n;
|
|
1425
1470
|
return () => {
|
|
1426
|
-
|
|
1471
|
+
n && clearTimeout(n), n = setTimeout(e, t);
|
|
1427
1472
|
};
|
|
1428
1473
|
}
|
|
1429
|
-
function
|
|
1474
|
+
function pn(e, t) {
|
|
1430
1475
|
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`);
|
|
1431
1476
|
}
|
|
1432
|
-
function
|
|
1433
|
-
const t =
|
|
1477
|
+
function mn(e) {
|
|
1478
|
+
const t = Se("pnpm", ["exec", "nimpress", "dev"], { cwd: e, stdio: ["ignore", "pipe", "inherit"] }), n = new Promise((s, o) => {
|
|
1434
1479
|
let r = !1;
|
|
1435
1480
|
t.stdout?.on("data", (i) => {
|
|
1436
1481
|
const c = i.toString();
|
|
1437
1482
|
if (process.stdout.write(c), r) return;
|
|
1438
1483
|
const l = c.replace(/\x1b\[[0-9;]*m/g, "").match(/Local\s*:?\s+(https?:\/\/\S+)/);
|
|
1439
|
-
l && (r = !0,
|
|
1484
|
+
l && (r = !0, s(l[1]));
|
|
1440
1485
|
}), t.on("exit", (i) => {
|
|
1441
1486
|
r || o(new Error(`[nimpress] view: the docs site dev server exited with ${i ?? "a signal"} before it printed a url`));
|
|
1442
1487
|
}), t.on("error", (i) => o(new Error(`[nimpress] view: cannot run the docs site dev server, ${i.message}`)));
|
|
1443
1488
|
});
|
|
1444
|
-
return { child: t, origin:
|
|
1445
|
-
}
|
|
1446
|
-
async function
|
|
1447
|
-
const
|
|
1448
|
-
for (const
|
|
1449
|
-
const
|
|
1450
|
-
if (i.configFile &&
|
|
1451
|
-
throw new Error(`[nimpress] view: no export folder at ${
|
|
1452
|
-
const m =
|
|
1453
|
-
|
|
1454
|
-
const f = await
|
|
1455
|
-
if (!f.configFile) throw new Error(`[nimpress] view: ${
|
|
1456
|
-
const h =
|
|
1489
|
+
return { child: t, origin: n };
|
|
1490
|
+
}
|
|
1491
|
+
async function fn(e, t) {
|
|
1492
|
+
const n = M(t, "offline"), s = await rn(e, t), o = sn(e), r = Lt(e), i = await $e(e), c = _(t, "target") ? [`--target=${_(t, "target")}`] : [], l = [];
|
|
1493
|
+
for (const p of s) {
|
|
1494
|
+
const u = j(r, p.exportDir);
|
|
1495
|
+
if (i.configFile && ze(e, i.resolved, [...c, `--out=${u}`]), !y(u))
|
|
1496
|
+
throw new Error(`[nimpress] view: no export folder at ${u}, write the pages there or mark pages with export: and add a config`);
|
|
1497
|
+
const m = an(p);
|
|
1498
|
+
cn(p, m, n), un(m);
|
|
1499
|
+
const f = await $e(m);
|
|
1500
|
+
if (!f.configFile) throw new Error(`[nimpress] view: ${p.repo} carries no nimpress config, so it is not a docs site`);
|
|
1501
|
+
const h = Ys(m, f.resolved.contentDir), g = Xs(qs(m, h, o));
|
|
1457
1502
|
if (!g.length)
|
|
1458
1503
|
throw new Error(
|
|
1459
|
-
`[nimpress] view: ${
|
|
1504
|
+
`[nimpress] view: ${p.repo} has no target for ${o}, add it to nimpress.sources.json or the receiver defaults`
|
|
1460
1505
|
);
|
|
1461
|
-
const w =
|
|
1462
|
-
let
|
|
1463
|
-
const
|
|
1464
|
-
|
|
1506
|
+
const w = j(m, h.contentRoot), v = j(m, f.resolved.contentDir);
|
|
1507
|
+
let k = [];
|
|
1508
|
+
const F = () => {
|
|
1509
|
+
k.length && ae(["checkout", "--", ...k], m);
|
|
1465
1510
|
const $ = /* @__PURE__ */ new Set();
|
|
1466
|
-
for (const
|
|
1467
|
-
const I = d(
|
|
1468
|
-
|
|
1511
|
+
for (const b of g) {
|
|
1512
|
+
const I = d(u, ...b.from.split("/").filter(Boolean)), P = d(w, ...b.to.split("/"));
|
|
1513
|
+
pn(b.to, en(I, P, b.mode));
|
|
1469
1514
|
for (const A of X(I)) $.add(d(P, E(I, A)));
|
|
1470
1515
|
}
|
|
1471
|
-
|
|
1472
|
-
for (const
|
|
1473
|
-
|
|
1516
|
+
k = tn(v, $);
|
|
1517
|
+
for (const b of k) se(b);
|
|
1518
|
+
k.length && console.log(`nimpress view: the local pages replace ${k.map((b) => E(m, b)).join(", ")}`);
|
|
1474
1519
|
};
|
|
1475
|
-
|
|
1476
|
-
const
|
|
1477
|
-
if (l.push(() =>
|
|
1478
|
-
const $ =
|
|
1479
|
-
|
|
1520
|
+
F();
|
|
1521
|
+
const x = Qe(u, { recursive: !0 }, st(F, 150));
|
|
1522
|
+
if (l.push(() => x.close()), i.configFile) {
|
|
1523
|
+
const $ = Qe(
|
|
1524
|
+
j(e, i.resolved.contentDir),
|
|
1480
1525
|
{ recursive: !0 },
|
|
1481
|
-
|
|
1526
|
+
st(() => ze(e, i.resolved, [...c, `--out=${u}`]), 150)
|
|
1482
1527
|
);
|
|
1483
1528
|
l.push(() => $.close());
|
|
1484
1529
|
}
|
|
1485
|
-
const { child: R, origin:
|
|
1530
|
+
const { child: R, origin: D } = mn(m);
|
|
1486
1531
|
l.push(() => R.kill());
|
|
1487
|
-
const T = `${(await
|
|
1488
|
-
console.log(`nimpress view: ${o} inside ${
|
|
1532
|
+
const T = `${(await D).replace(/\/$/, "")}/${g[0].to}`;
|
|
1533
|
+
console.log(`nimpress view: ${o} inside ${p.repo} at ${T}`), M(t, "no-browser") || Bt(T);
|
|
1489
1534
|
}
|
|
1490
1535
|
const a = () => {
|
|
1491
|
-
for (const
|
|
1536
|
+
for (const p of l) p();
|
|
1492
1537
|
process.exit(0);
|
|
1493
1538
|
};
|
|
1494
1539
|
process.on("SIGINT", a), process.on("SIGTERM", a);
|
|
1495
1540
|
}
|
|
1496
|
-
const
|
|
1497
|
-
function
|
|
1498
|
-
const
|
|
1499
|
-
if (
|
|
1500
|
-
const
|
|
1501
|
-
if (!
|
|
1502
|
-
throw new Error(`[nimpress] modules: unknown system ${
|
|
1503
|
-
return
|
|
1541
|
+
const dn = 6e4;
|
|
1542
|
+
function re(e, t) {
|
|
1543
|
+
const n = _(t, "system");
|
|
1544
|
+
if (n === void 0) return;
|
|
1545
|
+
const s = Object.keys(e.modules.systems);
|
|
1546
|
+
if (!s.includes(n))
|
|
1547
|
+
throw new Error(`[nimpress] modules: unknown system ${n}, configured: ${s.join(", ") || "none"}`);
|
|
1548
|
+
return n;
|
|
1504
1549
|
}
|
|
1505
|
-
function
|
|
1506
|
-
const
|
|
1507
|
-
if (
|
|
1550
|
+
function We(e, t, n) {
|
|
1551
|
+
const s = re(e, t);
|
|
1552
|
+
if (s) return s;
|
|
1508
1553
|
const o = Object.keys(e.modules.systems);
|
|
1509
1554
|
if (o.length === 1) return o[0];
|
|
1510
1555
|
throw o.length ? new Error(
|
|
1511
|
-
`[nimpress] modules ${
|
|
1512
|
-
) : new Error(`[nimpress] modules ${
|
|
1556
|
+
`[nimpress] modules ${n}: several systems configured (${o.join(", ")}), pass --system=<name>`
|
|
1557
|
+
) : new Error(`[nimpress] modules ${n}: no systems configured`);
|
|
1513
1558
|
}
|
|
1514
|
-
async function
|
|
1515
|
-
const
|
|
1516
|
-
if (
|
|
1517
|
-
|
|
1559
|
+
async function hn(e, t, n) {
|
|
1560
|
+
const s = n[0], o = n.slice(1), r = Object.keys(t.modules.systems);
|
|
1561
|
+
if (s === "init") {
|
|
1562
|
+
wn(e, t);
|
|
1518
1563
|
return;
|
|
1519
1564
|
}
|
|
1520
|
-
if (
|
|
1521
|
-
const i =
|
|
1565
|
+
if (s === "dev") {
|
|
1566
|
+
const i = re(t, o), c = i ? [i] : r;
|
|
1522
1567
|
if (!c.length) throw new Error("[nimpress] modules dev: no systems configured");
|
|
1523
|
-
await
|
|
1568
|
+
await kt(e, t, c), await new Promise(() => {
|
|
1524
1569
|
});
|
|
1525
1570
|
}
|
|
1526
|
-
if (
|
|
1527
|
-
const i =
|
|
1571
|
+
if (s === "build") {
|
|
1572
|
+
const i = re(t, o), c = i ? [i] : vt(t);
|
|
1528
1573
|
if (!c.length) throw new Error("[nimpress] modules build: no systems configured");
|
|
1529
|
-
await
|
|
1574
|
+
await xt(e, t, c);
|
|
1530
1575
|
return;
|
|
1531
1576
|
}
|
|
1532
|
-
if (
|
|
1533
|
-
const i = await
|
|
1534
|
-
|
|
1577
|
+
if (s === "lint") {
|
|
1578
|
+
const i = await bt(e, t, re(t, o));
|
|
1579
|
+
Re("nimpress modules lint", i, "nimpress modules lint: systems, schemas, and stories ok");
|
|
1535
1580
|
return;
|
|
1536
1581
|
}
|
|
1537
|
-
if (
|
|
1538
|
-
const i =
|
|
1582
|
+
if (s === "story") {
|
|
1583
|
+
const i = We(t, o, "story"), c = K(o, 0), l = _(o, "framework");
|
|
1539
1584
|
if (c) {
|
|
1540
|
-
const
|
|
1541
|
-
|
|
1585
|
+
const p = await Ge(e, t, i, c, l);
|
|
1586
|
+
p && console.log(`nimpress modules: story written to ${p}`);
|
|
1542
1587
|
return;
|
|
1543
1588
|
}
|
|
1544
|
-
const a = await
|
|
1589
|
+
const a = await Js(e, t, i);
|
|
1545
1590
|
console.log(`nimpress modules: ${a} auto stories written for ${i}`);
|
|
1546
1591
|
return;
|
|
1547
1592
|
}
|
|
1548
|
-
if (
|
|
1549
|
-
const i = K(o, 0), c = await
|
|
1593
|
+
if (s === "stories") {
|
|
1594
|
+
const i = K(o, 0), c = await nt(e, t, "stories", i, re(t, o));
|
|
1550
1595
|
if (M(o, "json")) {
|
|
1551
1596
|
console.log(JSON.stringify(c, null, 2));
|
|
1552
1597
|
return;
|
|
@@ -1554,31 +1599,31 @@ async function pn(e, t, s) {
|
|
|
1554
1599
|
if (!i) {
|
|
1555
1600
|
const l = /* @__PURE__ */ new Map();
|
|
1556
1601
|
for (const a of c) l.set(`${a.system} ${a.component}`, (l.get(`${a.system} ${a.component}`) ?? 0) + 1);
|
|
1557
|
-
for (const [a,
|
|
1602
|
+
for (const [a, p] of l) console.log(`${a} ${p}`);
|
|
1558
1603
|
return;
|
|
1559
1604
|
}
|
|
1560
1605
|
for (const l of c) console.log(`${l.system} ${l.component} ${l.story} ${l.route}`);
|
|
1561
1606
|
return;
|
|
1562
1607
|
}
|
|
1563
|
-
if (
|
|
1608
|
+
if (s === "open") {
|
|
1564
1609
|
const i = K(o, 0);
|
|
1565
1610
|
if (!i)
|
|
1566
1611
|
throw new Error("[nimpress] modules open expects: nimpress modules open <Component> [story] [--system=<name>] [--browser=<app>]");
|
|
1567
|
-
const c = await
|
|
1612
|
+
const c = await nt(e, t, "open", i, re(t, o)), l = c.map((m) => m.system).filter((m, f, h) => h.indexOf(m) === f);
|
|
1568
1613
|
if (l.length > 1)
|
|
1569
1614
|
throw new Error(`[nimpress] modules open: ${i} is in several systems (${l.join(", ")}), pass --system=<name>`);
|
|
1570
|
-
const a = K(o, 1),
|
|
1571
|
-
if (!
|
|
1615
|
+
const a = K(o, 1), p = ls(c, a);
|
|
1616
|
+
if (!p)
|
|
1572
1617
|
throw new Error(
|
|
1573
1618
|
`[nimpress] modules open: no story ${a} for ${c[0].system}/${c[0].component}, stories: ${c.map((m) => m.story).join(", ")}`
|
|
1574
1619
|
);
|
|
1575
|
-
const
|
|
1576
|
-
await
|
|
1620
|
+
const u = us(t, p);
|
|
1621
|
+
await gn(e, t, p, u), Bt(u, _(o, "browser")), console.log(`nimpress modules open: ${p.system}/${p.component} ${p.story} at ${u}`);
|
|
1577
1622
|
return;
|
|
1578
1623
|
}
|
|
1579
|
-
if (
|
|
1580
|
-
const i =
|
|
1581
|
-
await
|
|
1624
|
+
if (s === "import") {
|
|
1625
|
+
const i = We(t, o, "import"), c = K(o, 0);
|
|
1626
|
+
await Hs(e, t, i, {
|
|
1582
1627
|
file: c,
|
|
1583
1628
|
name: _(o, "name"),
|
|
1584
1629
|
source: _(o, "source"),
|
|
@@ -1586,127 +1631,127 @@ async function pn(e, t, s) {
|
|
|
1586
1631
|
match: _(o, "match"),
|
|
1587
1632
|
fromStories: o.includes("--from-stories"),
|
|
1588
1633
|
select: o.includes("--select")
|
|
1589
|
-
}),
|
|
1634
|
+
}), Te(e);
|
|
1590
1635
|
return;
|
|
1591
1636
|
}
|
|
1592
|
-
if (
|
|
1593
|
-
const i = _(o, "component") ?? K(o, 0), c = await
|
|
1594
|
-
console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`),
|
|
1637
|
+
if (s === "update") {
|
|
1638
|
+
const i = _(o, "component") ?? K(o, 0), c = await ps(e, t, { ref: i, system: re(t, o) });
|
|
1639
|
+
console.log(`nimpress modules: ${c} schema${c === 1 ? "" : "s"} upserted`), Te(e);
|
|
1595
1640
|
return;
|
|
1596
1641
|
}
|
|
1597
|
-
if (
|
|
1642
|
+
if (s === "create") {
|
|
1598
1643
|
const i = _(o, "component");
|
|
1599
1644
|
if (i) {
|
|
1600
1645
|
if (!M(o, "schema"))
|
|
1601
1646
|
throw new Error("[nimpress] modules create --component expects --schema to upsert the schema");
|
|
1602
|
-
const
|
|
1603
|
-
console.log(`nimpress modules: schema upserted at ${
|
|
1647
|
+
const u = await ms(e, t, i);
|
|
1648
|
+
console.log(`nimpress modules: schema upserted at ${u}`);
|
|
1604
1649
|
return;
|
|
1605
1650
|
}
|
|
1606
1651
|
const c = K(o, 0);
|
|
1607
1652
|
if (!c)
|
|
1608
1653
|
throw new Error("[nimpress] modules create expects: nimpress modules create <Component> [--system=<name>], or --component=<ref> --schema");
|
|
1609
|
-
const l =
|
|
1610
|
-
console.log(`nimpress modules: created ${c} at ${E(e,
|
|
1654
|
+
const l = We(t, o, "create"), a = _(o, "framework"), p = await Bs(e, t, l, c, a);
|
|
1655
|
+
console.log(`nimpress modules: created ${c} at ${E(e, p)}`);
|
|
1611
1656
|
return;
|
|
1612
1657
|
}
|
|
1613
1658
|
throw new Error("[nimpress] modules expects init, dev, build, lint, story, stories, open, import, create or update");
|
|
1614
1659
|
}
|
|
1615
|
-
async function
|
|
1616
|
-
const r = await
|
|
1617
|
-
if (
|
|
1618
|
-
const i = (await
|
|
1660
|
+
async function nt(e, t, n, s, o) {
|
|
1661
|
+
const r = await Ye(e, t, { component: s, system: o });
|
|
1662
|
+
if (s && !r.length) {
|
|
1663
|
+
const i = (await Ye(e, t, { system: o })).map((c) => `${c.system}/${c.component}`).filter((c, l, a) => a.indexOf(c) === l && c.toLowerCase().includes(s.toLowerCase()));
|
|
1619
1664
|
throw new Error(
|
|
1620
|
-
`[nimpress] modules ${
|
|
1665
|
+
`[nimpress] modules ${n}: no stories for ${s}${o ? ` in ${o}` : ""}` + (i.length ? `, did you mean ${i.slice(0, 8).join(", ")}` : "")
|
|
1621
1666
|
);
|
|
1622
1667
|
}
|
|
1623
1668
|
return r;
|
|
1624
1669
|
}
|
|
1625
|
-
async function
|
|
1670
|
+
async function ot(e) {
|
|
1626
1671
|
try {
|
|
1627
1672
|
return (await fetch(e, { signal: AbortSignal.timeout(2e3) })).status;
|
|
1628
1673
|
} catch {
|
|
1629
1674
|
return;
|
|
1630
1675
|
}
|
|
1631
1676
|
}
|
|
1632
|
-
async function
|
|
1633
|
-
let o = await
|
|
1677
|
+
async function gn(e, t, n, s) {
|
|
1678
|
+
let o = await ot(s);
|
|
1634
1679
|
if (o === void 0) {
|
|
1635
|
-
const r =
|
|
1636
|
-
|
|
1637
|
-
const i =
|
|
1680
|
+
const r = Be(e, t, "modules", "dev.log");
|
|
1681
|
+
L(O(r), { recursive: !0 });
|
|
1682
|
+
const i = hs(r, "a"), c = Se(process.execPath, [process.argv[1], "dev"], { cwd: e, detached: !0, stdio: ["ignore", i, i] });
|
|
1638
1683
|
c.unref();
|
|
1639
1684
|
let l = !1;
|
|
1640
1685
|
c.on("exit", () => l = !0), console.log(`nimpress modules open: started nimpress dev in the background, pid ${c.pid}, log ${E(e, r)}`);
|
|
1641
|
-
const a = Date.now() +
|
|
1686
|
+
const a = Date.now() + dn;
|
|
1642
1687
|
for (; o === void 0 && !l && Date.now() < a; )
|
|
1643
|
-
await new Promise((
|
|
1688
|
+
await new Promise((p) => setTimeout(p, 500)), o = await ot(s);
|
|
1644
1689
|
if (o === void 0)
|
|
1645
|
-
throw new Error(`[nimpress] modules open: the ${
|
|
1690
|
+
throw new Error(`[nimpress] modules open: the ${n.system} harness did not answer on ${s}, see ${E(e, r)}`);
|
|
1646
1691
|
}
|
|
1647
1692
|
if (o !== 200)
|
|
1648
1693
|
throw new Error(
|
|
1649
|
-
`[nimpress] modules open: the ${
|
|
1694
|
+
`[nimpress] modules open: the ${n.system} harness answers ${o} for ${n.component}, restart nimpress dev so it picks the component up`
|
|
1650
1695
|
);
|
|
1651
1696
|
}
|
|
1652
|
-
function
|
|
1653
|
-
const
|
|
1654
|
-
|
|
1655
|
-
const
|
|
1656
|
-
if (
|
|
1657
|
-
const o = JSON.parse(
|
|
1658
|
-
o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} },
|
|
1659
|
-
`), console.log(`nimpress modules: modules block added to ${
|
|
1697
|
+
function wn(e, t) {
|
|
1698
|
+
const n = d(e, t.modules.dir);
|
|
1699
|
+
L(n, { recursive: !0 });
|
|
1700
|
+
const s = d(e, "nimpress.config.json");
|
|
1701
|
+
if (y(s)) {
|
|
1702
|
+
const o = JSON.parse(S(s, "utf-8"));
|
|
1703
|
+
o.modules || (o.modules = { dir: t.modules.dir, route: t.modules.route, systems: {} }, N(s, JSON.stringify(o, null, 2) + `
|
|
1704
|
+
`), console.log(`nimpress modules: modules block added to ${s}`));
|
|
1660
1705
|
} else
|
|
1661
1706
|
console.log("nimpress modules: add a modules block with systems entries to your nimpress config");
|
|
1662
|
-
console.log(`nimpress modules: folder ready at ${
|
|
1663
|
-
}
|
|
1664
|
-
const
|
|
1665
|
-
function
|
|
1666
|
-
const e =
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1707
|
+
console.log(`nimpress modules: folder ready at ${n}`);
|
|
1708
|
+
}
|
|
1709
|
+
const _e = d(".claude", "skills", "nimpress", "SKILL.md");
|
|
1710
|
+
function Gt() {
|
|
1711
|
+
const e = O(yt(import.meta.url)), t = [
|
|
1712
|
+
j(e, _e),
|
|
1713
|
+
j(e, "..", _e),
|
|
1714
|
+
j(e, "..", "..", _e)
|
|
1670
1715
|
];
|
|
1671
|
-
for (const
|
|
1716
|
+
for (const n of t)
|
|
1672
1717
|
try {
|
|
1673
|
-
return
|
|
1718
|
+
return S(n, "utf-8");
|
|
1674
1719
|
} catch {
|
|
1675
1720
|
}
|
|
1676
1721
|
throw new Error(`[nimpress] skill: SKILL.md not found, looked in ${t.join(", ")}`);
|
|
1677
1722
|
}
|
|
1678
|
-
function
|
|
1679
|
-
const
|
|
1680
|
-
|
|
1681
|
-
const o = d(
|
|
1682
|
-
return
|
|
1723
|
+
function Ht(e, t) {
|
|
1724
|
+
const n = t ? d(Q(), ".claude") : d(e, ".claude"), s = d(n, "skills", "nimpress");
|
|
1725
|
+
L(s, { recursive: !0 });
|
|
1726
|
+
const o = d(s, "SKILL.md");
|
|
1727
|
+
return N(o, Gt()), console.log(`wrote ${o}`), o;
|
|
1683
1728
|
}
|
|
1684
|
-
function
|
|
1685
|
-
const
|
|
1686
|
-
if (
|
|
1687
|
-
process.stdout.write(
|
|
1729
|
+
function $n(e, t) {
|
|
1730
|
+
const n = t[0];
|
|
1731
|
+
if (n === "get") {
|
|
1732
|
+
process.stdout.write(Gt());
|
|
1688
1733
|
return;
|
|
1689
1734
|
}
|
|
1690
|
-
if (
|
|
1691
|
-
|
|
1735
|
+
if (n === "put") {
|
|
1736
|
+
Ht(e, !M(t, "project"));
|
|
1692
1737
|
return;
|
|
1693
1738
|
}
|
|
1694
1739
|
throw new Error("[nimpress] skill expects get or put");
|
|
1695
1740
|
}
|
|
1696
|
-
const
|
|
1697
|
-
function
|
|
1741
|
+
const yn = "nimling/nimpress", bn = "nimpress@nimpress";
|
|
1742
|
+
function rt(e, t) {
|
|
1698
1743
|
console.log(`claude ${t.join(" ")}`);
|
|
1699
|
-
const
|
|
1700
|
-
if (
|
|
1701
|
-
if (
|
|
1744
|
+
const n = ne("claude", t, { cwd: e, stdio: "inherit" });
|
|
1745
|
+
if (n.error) throw new Error(`[nimpress] plugin: could not run claude, install Claude Code first: ${n.error.message}`);
|
|
1746
|
+
if (n.status !== 0) throw new Error(`[nimpress] plugin: claude ${t.join(" ")} exited with ${n.status}`);
|
|
1702
1747
|
}
|
|
1703
|
-
function
|
|
1704
|
-
const
|
|
1705
|
-
|
|
1748
|
+
function vn(e, t) {
|
|
1749
|
+
const n = t ? "user" : "project";
|
|
1750
|
+
rt(e, ["plugin", "marketplace", "add", yn, "--scope", n]), rt(e, ["plugin", "install", bn, "--scope", n]);
|
|
1706
1751
|
}
|
|
1707
|
-
function
|
|
1752
|
+
function kn(e, t) {
|
|
1708
1753
|
if (t[0] === "put") {
|
|
1709
|
-
|
|
1754
|
+
vn(e, !M(t, "project"));
|
|
1710
1755
|
return;
|
|
1711
1756
|
}
|
|
1712
1757
|
throw new Error("[nimpress] plugin expects put");
|
|
@@ -1715,7 +1760,7 @@ const V = {
|
|
|
1715
1760
|
name: "--system",
|
|
1716
1761
|
value: !0,
|
|
1717
1762
|
describe: "the configured component system to act on"
|
|
1718
|
-
},
|
|
1763
|
+
}, it = {
|
|
1719
1764
|
name: "--framework",
|
|
1720
1765
|
value: !0,
|
|
1721
1766
|
describe: "vue or svelte, overriding the framework of the system"
|
|
@@ -1759,7 +1804,7 @@ const V = {
|
|
|
1759
1804
|
{ name: "dev", describe: "Serve the harnesses and stay running", flags: [V], subs: [] },
|
|
1760
1805
|
{ name: "build", describe: "Build the harness bundles", flags: [V], subs: [] },
|
|
1761
1806
|
{ name: "lint", describe: "Check the systems, the schemas, and the stories", flags: [V], subs: [] },
|
|
1762
|
-
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [V,
|
|
1807
|
+
{ name: "story", describe: "Write auto stories for one component or for every component", flags: [V, it], subs: [] },
|
|
1763
1808
|
{
|
|
1764
1809
|
name: "stories",
|
|
1765
1810
|
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",
|
|
@@ -1791,7 +1836,7 @@ const V = {
|
|
|
1791
1836
|
describe: "Create a component page, or upsert one schema",
|
|
1792
1837
|
flags: [
|
|
1793
1838
|
V,
|
|
1794
|
-
|
|
1839
|
+
it,
|
|
1795
1840
|
{ name: "--component", value: !0, describe: "the component reference whose schema is upserted" },
|
|
1796
1841
|
{ name: "--schema", value: !1, describe: "required with --component, upserts the schema" }
|
|
1797
1842
|
],
|
|
@@ -1915,36 +1960,36 @@ const V = {
|
|
|
1915
1960
|
{ name: "powershell", describe: "the powershell completion script", flags: [], subs: [] }
|
|
1916
1961
|
]
|
|
1917
1962
|
}
|
|
1918
|
-
],
|
|
1919
|
-
function
|
|
1963
|
+
], Ut = ["bash", "zsh", "fish", "powershell"];
|
|
1964
|
+
function je(e) {
|
|
1920
1965
|
const t = [];
|
|
1921
|
-
for (const
|
|
1922
|
-
t.some((
|
|
1966
|
+
for (const n of [...e.flags, ...e.subs.flatMap((s) => s.flags)])
|
|
1967
|
+
t.some((s) => s.name === n.name) || t.push(n);
|
|
1923
1968
|
return t;
|
|
1924
1969
|
}
|
|
1925
|
-
function
|
|
1970
|
+
function Ce(e, t) {
|
|
1926
1971
|
return t && e.value ? `${e.name}=` : e.name;
|
|
1927
1972
|
}
|
|
1928
|
-
function
|
|
1973
|
+
function xn() {
|
|
1929
1974
|
const e = ["_nimpress() {", ' local cur="${COMP_WORDS[COMP_CWORD]}"'];
|
|
1930
1975
|
e.push(` local words="${Y.map((t) => t.name).join(" ")}"`), e.push(' if [ "$COMP_CWORD" -gt 1 ]; then'), e.push(' case "${COMP_WORDS[1]}" in');
|
|
1931
1976
|
for (const t of Y) {
|
|
1932
|
-
const
|
|
1933
|
-
e.push(` ${t.name}) words="${
|
|
1977
|
+
const n = [...t.subs.map((s) => s.name), ...je(t).map((s) => Ce(s, !1))];
|
|
1978
|
+
e.push(` ${t.name}) words="${n.join(" ")}" ;;`);
|
|
1934
1979
|
}
|
|
1935
1980
|
return e.push(' *) words="" ;;'), e.push(" esac"), e.push(" fi"), e.push(' COMPREPLY=( $(compgen -W "$words" -- "$cur") )'), e.push("}"), e.push("complete -o default -F _nimpress nimpress"), e.join(`
|
|
1936
1981
|
`) + `
|
|
1937
1982
|
`;
|
|
1938
1983
|
}
|
|
1939
|
-
function
|
|
1940
|
-
const
|
|
1941
|
-
for (const o of
|
|
1942
|
-
return
|
|
1984
|
+
function Ne(e, t, n) {
|
|
1985
|
+
const s = [`${e}entries=(`];
|
|
1986
|
+
for (const o of n) s.push(`${e} ${o}`);
|
|
1987
|
+
return s.push(`${e})`), s.push(`${e}_describe '${t}' entries`), s.push(`${e}return`), s;
|
|
1943
1988
|
}
|
|
1944
|
-
function
|
|
1989
|
+
function Sn() {
|
|
1945
1990
|
const e = ["#compdef nimpress", "", "_nimpress() {", " local -a entries", " if (( CURRENT == 2 )); then"];
|
|
1946
1991
|
e.push(
|
|
1947
|
-
...
|
|
1992
|
+
...Ne(
|
|
1948
1993
|
" ",
|
|
1949
1994
|
"nimpress command",
|
|
1950
1995
|
Y.map((t) => `'${t.name}:${t.describe}'`)
|
|
@@ -1952,18 +1997,18 @@ function bn() {
|
|
|
1952
1997
|
), e.push(" fi"), e.push(' case "$words[2]" in');
|
|
1953
1998
|
for (const t of Y) {
|
|
1954
1999
|
e.push(` ${t.name})`), t.subs.length && (e.push(" if (( CURRENT == 3 )); then"), e.push(
|
|
1955
|
-
...
|
|
2000
|
+
...Ne(
|
|
1956
2001
|
" ",
|
|
1957
2002
|
`${t.name} argument`,
|
|
1958
|
-
t.subs.map((
|
|
2003
|
+
t.subs.map((s) => `'${s.name}:${s.describe}'`)
|
|
1959
2004
|
)
|
|
1960
2005
|
), e.push(" fi"));
|
|
1961
|
-
const
|
|
1962
|
-
|
|
1963
|
-
...
|
|
2006
|
+
const n = je(t);
|
|
2007
|
+
n.length ? e.push(
|
|
2008
|
+
...Ne(
|
|
1964
2009
|
" ",
|
|
1965
2010
|
"nimpress flag",
|
|
1966
|
-
|
|
2011
|
+
n.map((s) => `'${Ce(s, !0)}:${s.describe}'`)
|
|
1967
2012
|
)
|
|
1968
2013
|
) : e.push(" return"), e.push(" ;;");
|
|
1969
2014
|
}
|
|
@@ -1971,26 +2016,26 @@ function bn() {
|
|
|
1971
2016
|
`) + `
|
|
1972
2017
|
`;
|
|
1973
2018
|
}
|
|
1974
|
-
function
|
|
2019
|
+
function jn() {
|
|
1975
2020
|
const e = ["complete -c nimpress -f"];
|
|
1976
2021
|
for (const t of Y)
|
|
1977
2022
|
e.push(
|
|
1978
2023
|
`complete -c nimpress -n '__fish_use_subcommand' -a '${t.name}' -d '${t.describe}'`
|
|
1979
2024
|
);
|
|
1980
2025
|
for (const t of Y) {
|
|
1981
|
-
const
|
|
1982
|
-
for (const
|
|
1983
|
-
e.push(`complete -c nimpress -n '${
|
|
1984
|
-
for (const
|
|
2026
|
+
const n = `__fish_seen_subcommand_from ${t.name}`;
|
|
2027
|
+
for (const s of t.subs)
|
|
2028
|
+
e.push(`complete -c nimpress -n '${n}' -a '${s.name}' -d '${s.describe}'`);
|
|
2029
|
+
for (const s of je(t))
|
|
1985
2030
|
e.push(
|
|
1986
|
-
`complete -c nimpress -n '${
|
|
2031
|
+
`complete -c nimpress -n '${n}' -a '${Ce(s, !0)}' -d '${s.describe}'`
|
|
1987
2032
|
);
|
|
1988
2033
|
}
|
|
1989
2034
|
return e.join(`
|
|
1990
2035
|
`) + `
|
|
1991
2036
|
`;
|
|
1992
2037
|
}
|
|
1993
|
-
function
|
|
2038
|
+
function Cn() {
|
|
1994
2039
|
const e = [
|
|
1995
2040
|
"Register-ArgumentCompleter -Native -CommandName nimpress -ScriptBlock {",
|
|
1996
2041
|
" param($wordToComplete, $commandAst, $cursorPosition)",
|
|
@@ -2002,21 +2047,21 @@ function kn() {
|
|
|
2002
2047
|
" switch ($words[1]) {"
|
|
2003
2048
|
];
|
|
2004
2049
|
for (const t of Y) {
|
|
2005
|
-
const
|
|
2006
|
-
e.push(` '${t.name}' { $candidates = @(${
|
|
2050
|
+
const n = [...t.subs.map((s) => s.name), ...je(t).map((s) => Ce(s, !0))];
|
|
2051
|
+
e.push(` '${t.name}' { $candidates = @(${n.map((s) => `'${s}'`).join(", ")}) }`);
|
|
2007
2052
|
}
|
|
2008
2053
|
return e.push(" }"), e.push(" }"), e.push(' $candidates | Where-Object { $_ -like "$wordToComplete*" } | ForEach-Object {'), e.push(" [System.Management.Automation.CompletionResult]::new($_, $_, 'ParameterValue', $_)"), e.push(" }"), e.push("}"), e.join(`
|
|
2009
2054
|
`) + `
|
|
2010
2055
|
`;
|
|
2011
2056
|
}
|
|
2012
|
-
function
|
|
2013
|
-
if (e === "bash") return
|
|
2014
|
-
if (e === "zsh") return
|
|
2015
|
-
if (e === "fish") return
|
|
2016
|
-
if (e === "powershell") return
|
|
2017
|
-
throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${
|
|
2057
|
+
function Zt(e) {
|
|
2058
|
+
if (e === "bash") return xn();
|
|
2059
|
+
if (e === "zsh") return Sn();
|
|
2060
|
+
if (e === "fish") return jn();
|
|
2061
|
+
if (e === "powershell") return Cn();
|
|
2062
|
+
throw new Error(`[nimpress] completion: unsupported shell ${e}, use ${Ut.join(", ")}`);
|
|
2018
2063
|
}
|
|
2019
|
-
function
|
|
2064
|
+
function at(e) {
|
|
2020
2065
|
return e === "fish" ? [
|
|
2021
2066
|
"function nimpress",
|
|
2022
2067
|
" if test -x node_modules/.bin/nimpress",
|
|
@@ -2038,96 +2083,96 @@ function nt(e) {
|
|
|
2038
2083
|
].join(`
|
|
2039
2084
|
`);
|
|
2040
2085
|
}
|
|
2041
|
-
function
|
|
2042
|
-
const e =
|
|
2086
|
+
function En() {
|
|
2087
|
+
const e = W(process.env.SHELL ?? "");
|
|
2043
2088
|
for (const t of ["zsh", "bash", "fish"])
|
|
2044
2089
|
if (e.includes(t)) return t;
|
|
2045
2090
|
return "";
|
|
2046
2091
|
}
|
|
2047
|
-
function
|
|
2048
|
-
const
|
|
2092
|
+
function On(e, t) {
|
|
2093
|
+
const n = "# >>> nimpress completion >>>", s = "# <<< nimpress completion <<<", o = `${n}
|
|
2049
2094
|
${t}
|
|
2050
|
-
${
|
|
2051
|
-
return r >= 0 && i > r ? e.slice(0, r) + o + e.slice(i +
|
|
2095
|
+
${s}`, r = e.indexOf(n), i = e.indexOf(s);
|
|
2096
|
+
return r >= 0 && i > r ? e.slice(0, r) + o + e.slice(i + s.length) : r >= 0 ? e.replace(/\n+$/, "") + `
|
|
2052
2097
|
` + o + `
|
|
2053
2098
|
` : (e === "" || e.endsWith(`
|
|
2054
2099
|
`) ? e : e + `
|
|
2055
2100
|
`) + o + `
|
|
2056
2101
|
`;
|
|
2057
2102
|
}
|
|
2058
|
-
function
|
|
2059
|
-
let
|
|
2103
|
+
function Fn(e, t) {
|
|
2104
|
+
let n = "";
|
|
2060
2105
|
try {
|
|
2061
|
-
|
|
2106
|
+
n = S(e, "utf-8");
|
|
2062
2107
|
} catch {
|
|
2063
|
-
|
|
2108
|
+
n = "";
|
|
2064
2109
|
}
|
|
2065
|
-
|
|
2110
|
+
N(e, On(n, t));
|
|
2066
2111
|
}
|
|
2067
|
-
function
|
|
2068
|
-
const t = e ||
|
|
2112
|
+
function Dn(e) {
|
|
2113
|
+
const t = e || En();
|
|
2069
2114
|
if (!t)
|
|
2070
2115
|
throw new Error("[nimpress] completion: could not detect the shell from $SHELL, name it: nimpress completion <shell> --auto");
|
|
2071
|
-
const
|
|
2116
|
+
const n = Zt(t), s = Q();
|
|
2072
2117
|
if (t === "fish") {
|
|
2073
|
-
const a = d(
|
|
2074
|
-
|
|
2075
|
-
const
|
|
2076
|
-
|
|
2077
|
-
const
|
|
2078
|
-
|
|
2079
|
-
const m = d(
|
|
2080
|
-
|
|
2118
|
+
const a = d(s, ".config", "fish", "completions");
|
|
2119
|
+
L(a, { recursive: !0 });
|
|
2120
|
+
const p = d(a, "nimpress.fish");
|
|
2121
|
+
N(p, n), console.log(`wrote ${p}`);
|
|
2122
|
+
const u = d(s, ".config", "fish", "functions");
|
|
2123
|
+
L(u, { recursive: !0 });
|
|
2124
|
+
const m = d(u, "nimpress.fish");
|
|
2125
|
+
N(m, at(t)), console.log(`wrote ${m}`), console.log("fish loads them on the next shell");
|
|
2081
2126
|
return;
|
|
2082
2127
|
}
|
|
2083
2128
|
if (t !== "bash" && t !== "zsh")
|
|
2084
2129
|
throw new Error(`[nimpress] completion: auto install covers bash, zsh, and fish, for ${t} run: nimpress completion ${t}`);
|
|
2085
|
-
const o = d(
|
|
2086
|
-
|
|
2130
|
+
const o = d(s, ".config", "nimpress", "completions");
|
|
2131
|
+
L(o, { recursive: !0 });
|
|
2087
2132
|
const r = d(o, t === "zsh" ? "_nimpress" : "nimpress.bash");
|
|
2088
|
-
|
|
2089
|
-
const i = d(
|
|
2090
|
-
autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, l = `${
|
|
2133
|
+
N(r, n), console.log(`wrote ${r}`);
|
|
2134
|
+
const i = d(s, t === "zsh" ? ".zshrc" : ".bashrc"), c = t === "zsh" ? `fpath=("${o}" $fpath)
|
|
2135
|
+
autoload -Uz compinit && compinit -u` : `[ -f "${r}" ] && source "${r}"`, l = `${at(t)}
|
|
2091
2136
|
${c}`;
|
|
2092
|
-
|
|
2137
|
+
Fn(i, l), console.log(`wired ${i}`), console.log(`start a new shell or run: source ${i}`);
|
|
2093
2138
|
}
|
|
2094
|
-
function
|
|
2095
|
-
const
|
|
2096
|
-
if (!
|
|
2139
|
+
function Wn(e, t) {
|
|
2140
|
+
const n = K(t, 0) ?? "", s = M(t, "auto"), o = M(t, "skill");
|
|
2141
|
+
if (!s) {
|
|
2097
2142
|
if (o) throw new Error("[nimpress] completion: --skill installs alongside --auto");
|
|
2098
|
-
if (!
|
|
2099
|
-
process.stdout.write(
|
|
2143
|
+
if (!n) throw new Error(`[nimpress] completion: name a shell (${Ut.join(", ")}) or pass --auto`);
|
|
2144
|
+
process.stdout.write(Zt(n));
|
|
2100
2145
|
return;
|
|
2101
2146
|
}
|
|
2102
|
-
|
|
2147
|
+
Dn(n), o && Ht(e, !0);
|
|
2103
2148
|
}
|
|
2104
|
-
const
|
|
2105
|
-
function
|
|
2106
|
-
const
|
|
2107
|
-
return e.subs.length ? e.subs.flatMap((
|
|
2149
|
+
const _n = /* @__PURE__ */ new Set(["skill", "plugin", "mcp", "completion"]), Nn = /* @__PURE__ */ new Set(["dev", "view", "modules dev"]), Tn = 2e4, he = /* @__PURE__ */ new Map();
|
|
2150
|
+
function Vt(e, t) {
|
|
2151
|
+
const n = [...t, e.name];
|
|
2152
|
+
return e.subs.length ? e.subs.flatMap((s) => Vt(s, n)) : [
|
|
2108
2153
|
{
|
|
2109
|
-
name:
|
|
2110
|
-
argv:
|
|
2154
|
+
name: n.join("_"),
|
|
2155
|
+
argv: n,
|
|
2111
2156
|
describe: e.describe,
|
|
2112
2157
|
flags: e.flags,
|
|
2113
|
-
serves:
|
|
2158
|
+
serves: Nn.has(n.join(" "))
|
|
2114
2159
|
}
|
|
2115
2160
|
];
|
|
2116
2161
|
}
|
|
2117
|
-
const
|
|
2118
|
-
function
|
|
2119
|
-
const e =
|
|
2120
|
-
for (const t of [
|
|
2162
|
+
const Kt = Y.filter((e) => !_n.has(e.name)).flatMap((e) => Vt(e, []));
|
|
2163
|
+
function Pn() {
|
|
2164
|
+
const e = O(yt(import.meta.url));
|
|
2165
|
+
for (const t of [j(e, "..", "package.json"), j(e, "..", "..", "package.json")])
|
|
2121
2166
|
try {
|
|
2122
|
-
return JSON.parse(
|
|
2167
|
+
return JSON.parse(S(t, "utf-8")).version;
|
|
2123
2168
|
} catch {
|
|
2124
2169
|
}
|
|
2125
2170
|
return "0.0.0";
|
|
2126
2171
|
}
|
|
2127
|
-
function
|
|
2172
|
+
function Rn(e) {
|
|
2128
2173
|
const t = {};
|
|
2129
|
-
for (const
|
|
2130
|
-
t[
|
|
2174
|
+
for (const n of e.flags)
|
|
2175
|
+
t[n.name.slice(2)] = { type: n.value ? "string" : "boolean", description: n.describe };
|
|
2131
2176
|
return {
|
|
2132
2177
|
type: "object",
|
|
2133
2178
|
properties: {
|
|
@@ -2138,12 +2183,12 @@ function Nn(e) {
|
|
|
2138
2183
|
additionalProperties: !1
|
|
2139
2184
|
};
|
|
2140
2185
|
}
|
|
2141
|
-
function
|
|
2186
|
+
function An() {
|
|
2142
2187
|
return [
|
|
2143
|
-
...
|
|
2188
|
+
...Kt.map((e) => ({
|
|
2144
2189
|
name: e.name,
|
|
2145
2190
|
description: `nimpress ${e.argv.join(" ")}: ${e.describe}${e.serves ? ". Keeps running in the background and returns its pid with the first output" : ""}`,
|
|
2146
|
-
inputSchema:
|
|
2191
|
+
inputSchema: Rn(e)
|
|
2147
2192
|
})),
|
|
2148
2193
|
{
|
|
2149
2194
|
name: "stop",
|
|
@@ -2157,247 +2202,247 @@ function Wn() {
|
|
|
2157
2202
|
}
|
|
2158
2203
|
];
|
|
2159
2204
|
}
|
|
2160
|
-
function
|
|
2161
|
-
const
|
|
2162
|
-
for (const [
|
|
2163
|
-
o === !0 ?
|
|
2164
|
-
return
|
|
2205
|
+
function Mn(e, t) {
|
|
2206
|
+
const n = [...e.argv, ...t.args ?? []];
|
|
2207
|
+
for (const [s, o] of Object.entries(t.flags ?? {}))
|
|
2208
|
+
o === !0 ? n.push(`--${s}`) : typeof o == "string" && n.push(`--${s}=${o}`);
|
|
2209
|
+
return n;
|
|
2165
2210
|
}
|
|
2166
2211
|
function U(e, t = !1) {
|
|
2167
2212
|
return { content: [{ type: "text", text: e || "(no output)" }], ...t ? { isError: t } : {} };
|
|
2168
2213
|
}
|
|
2169
|
-
function
|
|
2170
|
-
return
|
|
2171
|
-
cwd:
|
|
2214
|
+
function Yt(e, t, n) {
|
|
2215
|
+
return Se(process.execPath, [process.argv[1], ...Mn(t, n)], {
|
|
2216
|
+
cwd: j(e, n.cwd ?? "."),
|
|
2172
2217
|
env: { ...process.env, NO_COLOR: "1", FORCE_COLOR: "0" },
|
|
2173
2218
|
stdio: ["ignore", "pipe", "pipe"]
|
|
2174
2219
|
});
|
|
2175
2220
|
}
|
|
2176
|
-
function
|
|
2177
|
-
const
|
|
2221
|
+
function In(e, t, n) {
|
|
2222
|
+
const s = Yt(e, t, n);
|
|
2178
2223
|
let o = "";
|
|
2179
|
-
return
|
|
2180
|
-
|
|
2224
|
+
return s.stdout?.on("data", (r) => o += r), s.stderr?.on("data", (r) => o += r), new Promise((r) => {
|
|
2225
|
+
s.on("error", (i) => r(U(`${o}${i.message}`, !0))), s.on("close", (i) => r(U(o, i !== 0)));
|
|
2181
2226
|
});
|
|
2182
2227
|
}
|
|
2183
|
-
function
|
|
2184
|
-
const
|
|
2228
|
+
function Ln(e, t, n) {
|
|
2229
|
+
const s = Yt(e, t, n);
|
|
2185
2230
|
let o = "";
|
|
2186
2231
|
return new Promise((r) => {
|
|
2187
2232
|
const i = (a) => {
|
|
2188
|
-
clearTimeout(l),
|
|
2233
|
+
clearTimeout(l), s.stdout?.removeAllListeners("data"), s.stderr?.removeAllListeners("data"), s.stdout?.resume(), s.stderr?.resume(), r(a);
|
|
2189
2234
|
}, c = (a) => {
|
|
2190
|
-
o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${
|
|
2235
|
+
o += a, /https?:\/\/\S+/.test(o) && i(U(`pid ${s.pid}
|
|
2191
2236
|
${o}`));
|
|
2192
|
-
}, l = setTimeout(() => i(U(`pid ${
|
|
2193
|
-
${o}`)),
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
}),
|
|
2237
|
+
}, l = setTimeout(() => i(U(`pid ${s.pid}
|
|
2238
|
+
${o}`)), Tn);
|
|
2239
|
+
s.stdout?.on("data", c), s.stderr?.on("data", c), s.on("error", (a) => i(U(`${o}${a.message}`, !0))), s.on("exit", (a) => {
|
|
2240
|
+
he.delete(s.pid ?? -1), i(U(o, a !== 0));
|
|
2241
|
+
}), s.pid && he.set(s.pid, s);
|
|
2197
2242
|
});
|
|
2198
2243
|
}
|
|
2199
|
-
function
|
|
2200
|
-
const t =
|
|
2201
|
-
return t ? (t.kill("SIGTERM"),
|
|
2244
|
+
function zn(e) {
|
|
2245
|
+
const t = he.get(e);
|
|
2246
|
+
return t ? (t.kill("SIGTERM"), he.delete(e), U(`stopped ${e}`)) : U(`no server with pid ${e} was started by this session`, !0);
|
|
2202
2247
|
}
|
|
2203
|
-
async function
|
|
2204
|
-
const
|
|
2205
|
-
if (
|
|
2206
|
-
const o =
|
|
2207
|
-
return o ?
|
|
2248
|
+
async function Jn(e, t) {
|
|
2249
|
+
const n = String(t.name ?? ""), s = t.arguments ?? {};
|
|
2250
|
+
if (n === "stop") return zn(Number(s.pid));
|
|
2251
|
+
const o = Kt.find((r) => r.name === n);
|
|
2252
|
+
return o ? y(j(e, s.cwd ?? ".")) ? o.serves ? Ln(e, o, s) : In(e, o, s) : U(`no folder ${s.cwd} under ${e}`, !0) : U(`unknown tool ${n}`, !0);
|
|
2208
2253
|
}
|
|
2209
|
-
function
|
|
2254
|
+
function ie(e, t) {
|
|
2210
2255
|
process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: e, ...t }) + `
|
|
2211
2256
|
`);
|
|
2212
2257
|
}
|
|
2213
|
-
async function
|
|
2258
|
+
async function Bn(e, t) {
|
|
2214
2259
|
if (t.id !== void 0) {
|
|
2215
2260
|
if (t.method === "initialize") {
|
|
2216
|
-
|
|
2261
|
+
ie(t.id, {
|
|
2217
2262
|
result: {
|
|
2218
2263
|
protocolVersion: t.params?.protocolVersion ?? "2025-06-18",
|
|
2219
2264
|
capabilities: { tools: {} },
|
|
2220
|
-
serverInfo: { name: "nimpress", version:
|
|
2265
|
+
serverInfo: { name: "nimpress", version: Pn() }
|
|
2221
2266
|
}
|
|
2222
2267
|
});
|
|
2223
2268
|
return;
|
|
2224
2269
|
}
|
|
2225
2270
|
if (t.method === "ping") {
|
|
2226
|
-
|
|
2271
|
+
ie(t.id, { result: {} });
|
|
2227
2272
|
return;
|
|
2228
2273
|
}
|
|
2229
2274
|
if (t.method === "tools/list") {
|
|
2230
|
-
|
|
2275
|
+
ie(t.id, { result: { tools: An() } });
|
|
2231
2276
|
return;
|
|
2232
2277
|
}
|
|
2233
2278
|
if (t.method === "tools/call") {
|
|
2234
|
-
|
|
2279
|
+
ie(t.id, { result: await Jn(e, t.params ?? {}) });
|
|
2235
2280
|
return;
|
|
2236
2281
|
}
|
|
2237
|
-
|
|
2282
|
+
ie(t.id, { error: { code: -32601, message: `method not found: ${t.method}` } });
|
|
2238
2283
|
}
|
|
2239
2284
|
}
|
|
2240
|
-
function
|
|
2241
|
-
const t =
|
|
2242
|
-
t.on("line", (
|
|
2243
|
-
if (!
|
|
2285
|
+
function Gn(e) {
|
|
2286
|
+
const t = bs({ input: process.stdin }), n = /* @__PURE__ */ new Set();
|
|
2287
|
+
t.on("line", (s) => {
|
|
2288
|
+
if (!s.trim()) return;
|
|
2244
2289
|
let o;
|
|
2245
2290
|
try {
|
|
2246
|
-
o = JSON.parse(
|
|
2291
|
+
o = JSON.parse(s);
|
|
2247
2292
|
} catch {
|
|
2248
|
-
|
|
2293
|
+
ie(null, { error: { code: -32700, message: "parse error" } });
|
|
2249
2294
|
return;
|
|
2250
2295
|
}
|
|
2251
|
-
const r =
|
|
2252
|
-
|
|
2296
|
+
const r = Bn(e, o).catch((i) => ie(o.id, { error: { code: -32603, message: String(i?.message ?? i) } })).finally(() => n.delete(r));
|
|
2297
|
+
n.add(r);
|
|
2253
2298
|
}), t.on("close", async () => {
|
|
2254
|
-
await Promise.all(
|
|
2255
|
-
for (const
|
|
2299
|
+
await Promise.all(n);
|
|
2300
|
+
for (const s of he.values()) s.kill("SIGTERM");
|
|
2256
2301
|
process.exit(0);
|
|
2257
2302
|
});
|
|
2258
2303
|
}
|
|
2259
|
-
function
|
|
2260
|
-
if (typeof
|
|
2261
|
-
const
|
|
2262
|
-
return
|
|
2304
|
+
function Hn(e, t, n) {
|
|
2305
|
+
if (typeof n.path == "string") return n.path.startsWith("/") ? n.path : `/${n.path}`;
|
|
2306
|
+
const s = E(e, t).split(z).join("/").replace(/\.md$/, "");
|
|
2307
|
+
return s === "index" ? "/" : `/${s.replace(/\/index$/, "")}`;
|
|
2263
2308
|
}
|
|
2264
|
-
function
|
|
2265
|
-
return e ? (Array.isArray(e) ? e : String(e).split(",")).map((
|
|
2309
|
+
function ct(e) {
|
|
2310
|
+
return e ? (Array.isArray(e) ? e : String(e).split(",")).map((n) => String(n).trim()).filter(Boolean) : [];
|
|
2266
2311
|
}
|
|
2267
|
-
function
|
|
2312
|
+
function Un(e) {
|
|
2268
2313
|
return e.split(`
|
|
2269
2314
|
`).filter((t) => /^#{1,6}\s/.test(t)).map((t) => t.replace(/^#{1,6}\s+/, "").trim());
|
|
2270
2315
|
}
|
|
2271
|
-
function
|
|
2272
|
-
const
|
|
2273
|
-
const { data:
|
|
2274
|
-
return { file: a, data:
|
|
2316
|
+
function Zn(e, t) {
|
|
2317
|
+
const n = j(e, t.contentDir), o = X(n).filter((a) => a.endsWith(".md")).map((a) => {
|
|
2318
|
+
const { data: p, content: u } = pe(S(a, "utf-8"));
|
|
2319
|
+
return { file: a, data: p, content: u };
|
|
2275
2320
|
}).filter((a) => typeof a.data.title == "string" && a.data.visibility !== "hidden" && !a.data.link), r = o.map((a) => ({
|
|
2276
2321
|
slug: a.file,
|
|
2277
2322
|
title: String(a.data.title),
|
|
2278
|
-
headings:
|
|
2279
|
-
tags:
|
|
2323
|
+
headings: Un(a.content),
|
|
2324
|
+
tags: ct(a.data.tags),
|
|
2280
2325
|
body: a.content
|
|
2281
|
-
})), i =
|
|
2326
|
+
})), i = fs(r), c = t.site?.url?.replace(/\/$/, "") ?? "", l = t.base.replace(/\/$/, "");
|
|
2282
2327
|
return o.map((a) => {
|
|
2283
|
-
const
|
|
2328
|
+
const p = i.get(a.file) ?? { keywords: [], description: "" }, u = a.data.meta ?? {}, m = Array.isArray(u.keywords) ? u.keywords : typeof u.keywords == "string" ? [u.keywords] : void 0, f = typeof u.description == "string" ? u.description : typeof a.data.description == "string" ? a.data.description : void 0, h = u.override === !0, g = t.seo?.auto === !0, w = g ? h && m ? m : p.keywords.length ? p.keywords : m ?? [] : m ?? ct(a.data.tags), v = g ? h && f ? f : p.description || f || "" : f ?? "", k = Hn(n, a.file, a.data);
|
|
2284
2329
|
return {
|
|
2285
|
-
path:
|
|
2286
|
-
file: E(e, a.file).split(
|
|
2330
|
+
path: k,
|
|
2331
|
+
file: E(e, a.file).split(z).join("/"),
|
|
2287
2332
|
title: String(a.data.title),
|
|
2288
2333
|
keywords: w,
|
|
2289
|
-
description:
|
|
2290
|
-
robots:
|
|
2291
|
-
canonical: typeof
|
|
2292
|
-
generated:
|
|
2293
|
-
authored: { keywords: m, description: f, override: h, ai: typeof
|
|
2334
|
+
description: v,
|
|
2335
|
+
robots: ds(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),
|
|
2336
|
+
canonical: typeof u.canonical == "string" ? u.canonical : c ? `${c}${l}${k === "/" ? "/" : k}` : "",
|
|
2337
|
+
generated: p,
|
|
2338
|
+
authored: { keywords: m, description: f, override: h, ai: typeof u.ai == "boolean" ? u.ai : void 0 }
|
|
2294
2339
|
};
|
|
2295
2340
|
});
|
|
2296
2341
|
}
|
|
2297
|
-
function
|
|
2298
|
-
let
|
|
2299
|
-
for (const
|
|
2300
|
-
const o =
|
|
2342
|
+
function Vn(e, t) {
|
|
2343
|
+
let n = 0;
|
|
2344
|
+
for (const s of t) {
|
|
2345
|
+
const o = j(e, s.file), { data: r, content: i } = pe(S(o, "utf-8")), c = { ...r.meta ?? {} };
|
|
2301
2346
|
let l = !1;
|
|
2302
|
-
c.keywords === void 0 &&
|
|
2347
|
+
c.keywords === void 0 && s.generated.keywords.length && (c.keywords = s.generated.keywords, l = !0), c.description === void 0 && s.generated.description && (c.description = s.generated.description, l = !0), l && (N(o, pe.stringify(i, { ...r, meta: c })), n += 1);
|
|
2303
2348
|
}
|
|
2304
|
-
return
|
|
2349
|
+
return n;
|
|
2305
2350
|
}
|
|
2306
|
-
function
|
|
2307
|
-
const
|
|
2308
|
-
for (const r of
|
|
2351
|
+
function Kn(e, t, n) {
|
|
2352
|
+
const s = Zn(e, t), o = _(n, "out") ?? "seo.map.json";
|
|
2353
|
+
for (const r of s) {
|
|
2309
2354
|
const i = t.seo?.auto ? r.authored.override ? "authored" : "generated" : "authored";
|
|
2310
2355
|
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}`);
|
|
2311
2356
|
}
|
|
2312
|
-
if (
|
|
2313
|
-
`), console.log(`nimpress seo: ${
|
|
2314
|
-
const r =
|
|
2357
|
+
if (N(j(e, o), JSON.stringify(s, null, 2) + `
|
|
2358
|
+
`), console.log(`nimpress seo: ${s.length} pages, map written to ${o}`), n.includes("--write")) {
|
|
2359
|
+
const r = Vn(e, s);
|
|
2315
2360
|
console.log(`nimpress seo: generated fields written into ${r} pages`);
|
|
2316
2361
|
}
|
|
2317
2362
|
}
|
|
2318
|
-
async function
|
|
2319
|
-
const
|
|
2320
|
-
if (
|
|
2321
|
-
const
|
|
2322
|
-
if (
|
|
2323
|
-
const c =
|
|
2324
|
-
|
|
2363
|
+
async function Yn(e, t) {
|
|
2364
|
+
const n = K(t, 0);
|
|
2365
|
+
if (n !== "clear") throw new Error(`[nimpress] cache: unknown subcommand ${n ?? ""}, use clear`);
|
|
2366
|
+
const s = M(t, "links"), o = M(t, "sites"), r = M(t, "local"), i = !s && !o && !r;
|
|
2367
|
+
if (s || i) {
|
|
2368
|
+
const c = Pt(), l = Object.keys(c.links).length;
|
|
2369
|
+
Rt({ links: {} }), console.log(`nimpress cache: cleared ${l} links`);
|
|
2325
2370
|
}
|
|
2326
2371
|
if (o || i) {
|
|
2327
|
-
const c =
|
|
2328
|
-
|
|
2372
|
+
const c = Tt();
|
|
2373
|
+
se(c, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared the docs site clones under ${c}`);
|
|
2329
2374
|
}
|
|
2330
2375
|
if (r) {
|
|
2331
|
-
const { resolved: c, configFile: l } = await
|
|
2376
|
+
const { resolved: c, configFile: l } = await $e(e);
|
|
2332
2377
|
if (!l) throw new Error(`[nimpress] cache: --local needs a nimpress config in ${e}`);
|
|
2333
|
-
const a =
|
|
2334
|
-
|
|
2378
|
+
const a = Be(e, c);
|
|
2379
|
+
y(a) && se(a, { recursive: !0, force: !0 }), console.log(`nimpress cache: cleared ${a}`);
|
|
2335
2380
|
}
|
|
2336
2381
|
}
|
|
2337
|
-
async function
|
|
2338
|
-
const t = e[0] ?? "dev",
|
|
2382
|
+
async function mo(e) {
|
|
2383
|
+
const t = e[0] ?? "dev", n = e.slice(1), s = process.cwd();
|
|
2339
2384
|
if (t === "init") {
|
|
2340
|
-
|
|
2385
|
+
Ss(s);
|
|
2341
2386
|
return;
|
|
2342
2387
|
}
|
|
2343
2388
|
if (t === "skill") {
|
|
2344
|
-
|
|
2389
|
+
$n(s, n);
|
|
2345
2390
|
return;
|
|
2346
2391
|
}
|
|
2347
2392
|
if (t === "plugin") {
|
|
2348
|
-
|
|
2393
|
+
kn(s, n);
|
|
2349
2394
|
return;
|
|
2350
2395
|
}
|
|
2351
2396
|
if (t === "mcp") {
|
|
2352
|
-
|
|
2397
|
+
Gn(s);
|
|
2353
2398
|
return;
|
|
2354
2399
|
}
|
|
2355
2400
|
if (t === "completion") {
|
|
2356
|
-
|
|
2401
|
+
Wn(s, n);
|
|
2357
2402
|
return;
|
|
2358
2403
|
}
|
|
2359
|
-
if (t === "view" || t === "dev" && M(
|
|
2360
|
-
await
|
|
2404
|
+
if (t === "view" || t === "dev" && M(n, "view")) {
|
|
2405
|
+
await fn(s, n);
|
|
2361
2406
|
return;
|
|
2362
2407
|
}
|
|
2363
2408
|
if (t === "cache") {
|
|
2364
|
-
await
|
|
2409
|
+
await Yn(s, n);
|
|
2365
2410
|
return;
|
|
2366
2411
|
}
|
|
2367
|
-
const { resolved: o } = await
|
|
2412
|
+
const { resolved: o } = await $e(s);
|
|
2368
2413
|
if (t === "seo") {
|
|
2369
|
-
|
|
2414
|
+
Kn(s, o, n);
|
|
2370
2415
|
return;
|
|
2371
2416
|
}
|
|
2372
2417
|
if (t === "lint") {
|
|
2373
|
-
await
|
|
2418
|
+
await Is(s, o);
|
|
2374
2419
|
return;
|
|
2375
2420
|
}
|
|
2376
2421
|
if (t === "dev") {
|
|
2377
|
-
await
|
|
2422
|
+
await Ds(s, o);
|
|
2378
2423
|
return;
|
|
2379
2424
|
}
|
|
2380
2425
|
if (t === "build") {
|
|
2381
|
-
await
|
|
2426
|
+
await St(s, o);
|
|
2382
2427
|
return;
|
|
2383
2428
|
}
|
|
2384
2429
|
if (t === "guard") {
|
|
2385
|
-
|
|
2430
|
+
zs(s, o, n);
|
|
2386
2431
|
return;
|
|
2387
2432
|
}
|
|
2388
2433
|
if (t === "modules") {
|
|
2389
|
-
await
|
|
2434
|
+
await hn(s, o, n);
|
|
2390
2435
|
return;
|
|
2391
2436
|
}
|
|
2392
2437
|
if (t === "export") {
|
|
2393
|
-
|
|
2438
|
+
ze(s, o, n);
|
|
2394
2439
|
return;
|
|
2395
2440
|
}
|
|
2396
2441
|
throw new Error(`[nimpress] unknown command: ${t}`);
|
|
2397
2442
|
}
|
|
2398
2443
|
export {
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2444
|
+
ut as buildViteConfig,
|
|
2445
|
+
ts as indexHtml,
|
|
2446
|
+
$e as loadNimpressConfig,
|
|
2447
|
+
mo as run
|
|
2403
2448
|
};
|