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