@iksnerd/blazon 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -19
- package/dist/chunks/{site-builder-vpzUWoiA.js → site-builder-BtGOvjBC.js} +1836 -2111
- package/dist/cli/commands/tokens.d.ts +4 -0
- package/dist/cli/commands/tokens.d.ts.map +1 -1
- package/dist/cli/handlers/brand.d.ts +1 -1
- package/dist/cli/handlers/index.d.ts +2 -2
- package/dist/cli/index.js +915 -941
- package/dist/core/brand/export.d.ts +2 -9
- package/dist/core/brand/export.d.ts.map +1 -1
- package/dist/core/brand/schema.d.ts +0 -58
- package/dist/core/brand/schema.d.ts.map +1 -1
- package/dist/core/brand-theme.d.ts +0 -2
- package/dist/core/brand-theme.d.ts.map +1 -1
- package/dist/core/checker/catalogue.d.ts +18 -2
- package/dist/core/checker/catalogue.d.ts.map +1 -1
- package/dist/core/checker/contrast.d.ts +1 -1
- package/dist/core/checker/variables.d.ts +2 -2
- package/dist/core/checker/variables.d.ts.map +1 -1
- package/dist/core/config/removed-keys.d.ts +6 -0
- package/dist/core/config/removed-keys.d.ts.map +1 -0
- package/dist/core/config/validate.d.ts +1 -1
- package/dist/core/config/validate.d.ts.map +1 -1
- package/dist/core/docs/directives.d.ts +9 -0
- package/dist/core/docs/directives.d.ts.map +1 -1
- package/dist/core/docs/parser.d.ts.map +1 -1
- package/dist/core/emit.d.ts +1 -3
- package/dist/core/emit.d.ts.map +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/operations/list.d.ts.map +1 -1
- package/dist/core/plugin-name.d.ts +1 -1
- package/dist/core/read/token.d.ts +1 -6
- package/dist/core/read/token.d.ts.map +1 -1
- package/dist/core/tokens/walk.d.ts.map +1 -1
- package/dist/index.js +33 -33
- package/dist/plugins/roles/integrate.d.ts +5 -2
- package/dist/plugins/roles/integrate.d.ts.map +1 -1
- package/dist/plugins/roles/roles.d.ts +9 -2
- package/dist/plugins/roles/roles.d.ts.map +1 -1
- package/dist/plugins/wire/profile.d.ts +5 -0
- package/dist/plugins/wire/profile.d.ts.map +1 -1
- package/dist/types/config.d.ts +1 -3
- package/dist/types/config.d.ts.map +1 -1
- package/dist/types/theme.d.ts +0 -3
- package/dist/types/theme.d.ts.map +1 -1
- package/dist/ui/assets/{index-BdbihVvH.js → index-CLKH0m9J.js} +45 -47
- package/dist/ui/index.html +1 -1
- package/package.json +1 -1
- package/plugins/blazon.brand-deck/bin/blazon-blazon.brand-deck./360/237/224/214 +24 -2
- package/plugins/blazon.copy/bin/blazon-blazon.copy./360/237/224/214 +25 -3
- package/plugins/blazon.favicons/bin/blazon-blazon.favicons./360/237/224/214 +26 -3
- package/plugins/blazon.logo-geometry/bin/blazon-blazon.logo-geometry./360/237/224/214 +37 -8
- package/plugins/blazon.logo-kit/bin/blazon-blazon.logo-kit./360/237/224/214 +37 -8
- package/plugins/blazon.office-template/bin/blazon-blazon.office-template./360/237/224/214 +37 -8
- package/plugins/blazon.platform-tokens/bin/blazon-blazon.platform-tokens./360/237/224/214 +37 -9
- package/plugins/blazon.press-kit/bin/blazon-blazon.press-kit./360/237/224/214 +37 -8
- package/plugins/blazon.print-book/README.md +3 -1
- package/plugins/blazon.print-book/bin/blazon-blazon.print-book./360/237/224/214 +43 -8
- package/plugins/blazon.shadcn/README.md +27 -0
- package/plugins/blazon.shadcn/bin/blazon-blazon.shadcn./360/237/224/214 +8273 -0
- package/plugins/blazon.shadcn/package.json +3 -0
- package/plugins/blazon.social-cards/bin/blazon-blazon.social-cards./360/237/224/214 +37 -8
- package/plugins/blazon.tailwind/README.md +23 -0
- package/plugins/blazon.tailwind/bin/blazon-blazon.tailwind./360/237/224/214 +420 -0
- package/plugins/blazon.tailwind/package.json +3 -0
- package/plugins/shipped.lock +24 -10
- package/template/AGENTS.md +1 -1
- package/template/blazon.json +0 -10
- package/template/docs/01-principles.md +1 -1
- package/template/docs/12-web.md +2 -2
- package/dist/core/tokens/formatters/tailwind.d.ts +0 -37
- package/dist/core/tokens/formatters/tailwind.d.ts.map +0 -1
- package/dist/core/tokens/shadcn.d.ts +0 -43
- package/dist/core/tokens/shadcn.d.ts.map +0 -1
package/dist/cli/index.js
CHANGED
|
@@ -1,151 +1,151 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { spawn as
|
|
5
|
-
import
|
|
6
|
-
import { preview as
|
|
7
|
-
import { cac as
|
|
8
|
-
import * as
|
|
1
|
+
import { At as e, Bt as t, C as n, D as r, Dt as i, E as a, F as o, Ft as s, Gt as c, H as l, I as u, It as d, Jt as f, Lt as p, Mt as m, Nt as h, O as g, Ot as _, Qt as v, Rt as y, S as b, St as x, T as S, Tn as C, U as w, V as T, W as ee, Xt as te, Yt as ne, Zt as re, _ as ie, _t as ae, a as oe, an as se, b as ce, bt as le, c as ue, cn as E, d as de, dn as fe, dt as D, f as pe, fn as me, ft as he, g as ge, gt as _e, h as ve, ht as ye, i as be, in as xe, jt as Se, k as O, kt as Ce, l as we, ln as Te, m as Ee, mn as De, mt as Oe, nn as ke, on as Ae, p as je, pt as Me, qt as Ne, rn as Pe, s as Fe, sn as Ie, st as Le, t as Re, u as ze, un as Be, v as Ve, w as He, wn as Ue, wt as k, x as We, xt as Ge, y as Ke } from "../chunks/site-builder-BtGOvjBC.js";
|
|
2
|
+
import A from "node:path";
|
|
3
|
+
import j from "node:fs";
|
|
4
|
+
import { spawn as qe } from "node:child_process";
|
|
5
|
+
import Je from "node:os";
|
|
6
|
+
import { preview as Ye } from "vite";
|
|
7
|
+
import { cac as Xe } from "cac";
|
|
8
|
+
import * as M from "@clack/prompts";
|
|
9
9
|
// src/cli/errors.ts
|
|
10
|
-
var
|
|
10
|
+
var N = class extends Error {
|
|
11
11
|
fix;
|
|
12
12
|
code;
|
|
13
13
|
constructor(e, t, n = "error") {
|
|
14
14
|
super(e), this.fix = t, this.code = n;
|
|
15
15
|
}
|
|
16
|
-
},
|
|
17
|
-
function
|
|
16
|
+
}, P = class extends N {}, Ze = (e) => new P(`port ${e} is in use`, "Pick another with --port, or leave out --strict-port to take the next free one.", "port-in-use"), Qe = (e) => e.replace(/^./, (e) => e.toLowerCase()).replace(/\.$/, "");
|
|
17
|
+
function $e(e, t, n) {
|
|
18
18
|
return `blazon${e ? ` ${e}` : ""}: ${t}${n ? `\n ${n}` : ""}`;
|
|
19
19
|
}
|
|
20
|
-
var
|
|
21
|
-
function
|
|
22
|
-
|
|
20
|
+
var et = (e, t) => t ? `${e}; ${Qe(t)}` : e, tt;
|
|
21
|
+
function nt(e) {
|
|
22
|
+
tt = e;
|
|
23
23
|
}
|
|
24
|
-
function
|
|
24
|
+
function rt(e) {
|
|
25
25
|
console.error(e.replace(/^blazon(?: [a-z]+)*:/, (e) => n.red(e)));
|
|
26
26
|
}
|
|
27
|
-
var
|
|
27
|
+
var it = (e, t, n) => ({
|
|
28
28
|
code: e,
|
|
29
29
|
message: t,
|
|
30
30
|
...n !== void 0 && { fix: n }
|
|
31
31
|
});
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
command:
|
|
32
|
+
function at(e, t, n) {
|
|
33
|
+
tt !== void 0 && process.stdout.write(`${JSON.stringify({
|
|
34
|
+
command: tt,
|
|
35
35
|
passed: !1,
|
|
36
|
-
error:
|
|
36
|
+
error: it(e, t, n)
|
|
37
37
|
})}\n`);
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return
|
|
39
|
+
function F(e, t, n = {}) {
|
|
40
|
+
return rt(e), n.stack && console.error(n.stack), at(t, n.json ?? e.replace(/^blazon(?: [a-z]+)?: /, ""), n.fix), process.exit(2);
|
|
41
41
|
}
|
|
42
|
-
var
|
|
43
|
-
function
|
|
44
|
-
let i = t instanceof
|
|
45
|
-
if (t instanceof
|
|
42
|
+
var ot = (e) => e.replace(/`([^`]*)`/g, "\"$1\"").replace(/^./, (e) => e.toLowerCase()), st = (e) => e instanceof Error && e.name === "CACError";
|
|
43
|
+
function I(e, t, r) {
|
|
44
|
+
let i = t instanceof N ? t.fix : void 0;
|
|
45
|
+
if (t instanceof P) return F($e(e, t.message, i), t.code, {
|
|
46
46
|
stack: r ? t.stack : void 0,
|
|
47
|
-
json:
|
|
47
|
+
json: et(t.message, i),
|
|
48
48
|
fix: i
|
|
49
49
|
});
|
|
50
50
|
let a = t instanceof Error ? t.message : String(t);
|
|
51
|
-
return console.error(),
|
|
51
|
+
return console.error(), rt($e(e, a, i ?? (r || t instanceof N ? void 0 : n.dim("Run again with --debug for the stack.")))), r && t instanceof Error && t.stack && console.error(t.stack), at(t instanceof N ? t.code : "error", et(a, i), i), process.exit(1);
|
|
52
52
|
}
|
|
53
53
|
// src/cli/where.ts
|
|
54
|
-
function
|
|
55
|
-
let n =
|
|
56
|
-
return n === "" ? "" : n.startsWith("..") ||
|
|
54
|
+
function L(e, t = process.cwd()) {
|
|
55
|
+
let n = A.relative(t, A.resolve(t, e));
|
|
56
|
+
return n === "" ? "" : n.startsWith("..") || A.isAbsolute(n) ? A.resolve(t, e) : n.split(A.sep).join("/");
|
|
57
57
|
}
|
|
58
|
-
var
|
|
59
|
-
function
|
|
60
|
-
if (!
|
|
58
|
+
var R = (e, t) => e ? `${e}/${t}` : t, ct = (e) => /^[\w./@%+=:,-]+$/.test(e) ? e : `'${e.replace(/'/g, "'\\''")}'`, z = (e, t) => `blazon ${e}${t ? ` ${ct(t)}` : ""}`, lt = (e) => j.statSync(e, { throwIfNoEntry: !1 })?.isDirectory() ?? !1, ut = (e) => `Run ${z("init", L(e))} to start a brand book there`;
|
|
59
|
+
function dt(e) {
|
|
60
|
+
if (!lt(e)) throw new P(`no folder "${e}"`, `${ut(e)}.`, "no-folder");
|
|
61
61
|
}
|
|
62
|
-
function
|
|
63
|
-
if (!
|
|
62
|
+
function ft(e, t) {
|
|
63
|
+
if (!lt(A.resolve(e, t))) throw new P(`no tokens folder (${t.replace(/^\.\//, "").replace(/\/$/, "")}) in "${e}"`, `${ut(e)}, or set tokensDir in blazon.json.`, "no-tokens-folder");
|
|
64
64
|
}
|
|
65
|
-
async function
|
|
66
|
-
|
|
67
|
-
let n = await
|
|
68
|
-
return
|
|
65
|
+
async function B(e, t) {
|
|
66
|
+
dt(e);
|
|
67
|
+
let n = await f(e, t);
|
|
68
|
+
return ft(e, n.tokensDir), n;
|
|
69
69
|
}
|
|
70
70
|
// src/cli/commands/dev.ts
|
|
71
|
-
var
|
|
72
|
-
async function
|
|
73
|
-
let r = await
|
|
71
|
+
var pt = /* @__PURE__ */ C({ runDev: () => mt });
|
|
72
|
+
async function mt(e = process.cwd(), t, n = {}) {
|
|
73
|
+
let r = await B(e, t ? { port: t } : void 0);
|
|
74
74
|
try {
|
|
75
|
-
await
|
|
75
|
+
await be(r, e, n);
|
|
76
76
|
} catch (e) {
|
|
77
|
-
throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ?
|
|
77
|
+
throw n.strictPort && e instanceof Error && /already in use/.test(e.message) ? Ze(r.port) : e;
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
// src/cli/commands/check.ts
|
|
81
|
-
var
|
|
81
|
+
var ht = class extends N {
|
|
82
82
|
findings;
|
|
83
83
|
constructor(e, t, n, r = "check-failed") {
|
|
84
84
|
super(e, n, r), this.findings = t;
|
|
85
85
|
}
|
|
86
|
-
},
|
|
87
|
-
function
|
|
86
|
+
}, gt = (e) => e?.plugins === !1, _t = (e) => e?.plugin === void 0 ? [] : [e.plugin].flat();
|
|
87
|
+
function vt(e) {
|
|
88
88
|
return e.context ? `${e.path} (${e.context})` : e.path;
|
|
89
89
|
}
|
|
90
|
-
var
|
|
91
|
-
function
|
|
92
|
-
let t = e.slice(0,
|
|
93
|
-
return e.length >
|
|
90
|
+
var yt = 5;
|
|
91
|
+
function bt(e) {
|
|
92
|
+
let t = e.slice(0, yt).join(", ");
|
|
93
|
+
return e.length > yt ? `${t} and ${e.length - yt} more` : t;
|
|
94
94
|
}
|
|
95
|
-
var
|
|
96
|
-
function
|
|
95
|
+
var xt = (e) => e.path.split("/")[0];
|
|
96
|
+
function St(e, t) {
|
|
97
97
|
let r = [], i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), s = e.filter((e) => e.code === "page-review-pending");
|
|
98
|
-
for (let t of e) t.code === "starter-file-unchanged" && a.set(
|
|
98
|
+
for (let t of e) t.code === "starter-file-unchanged" && a.set(xt(t), [...a.get(xt(t)) ?? [], t]), t.code === "review-pending" && o.set(t.message, [...o.get(t.message) ?? [], t]);
|
|
99
99
|
for (let c of e) {
|
|
100
100
|
if (i.has(c)) continue;
|
|
101
|
-
let e = c.code === "starter-file-unchanged" ? a.get(
|
|
102
|
-
if (c.code === "page-review-pending" && s.length > 1) s.forEach((e) => i.add(e)), r.push(`${n.bold(`page-review-pending (${s.length} pages)`)}: ${
|
|
101
|
+
let e = c.code === "starter-file-unchanged" ? a.get(xt(c)) : void 0, l = c.code === "review-pending" ? o.get(c.message) : void 0;
|
|
102
|
+
if (c.code === "page-review-pending" && s.length > 1) s.forEach((e) => i.add(e)), r.push(`${n.bold(`page-review-pending (${s.length} pages)`)}: ${bt(s.map(vt))}: show assets still marked needs-review ${n.dim("[page-review-pending]")}`);
|
|
103
103
|
else if (e && e.length > 1) {
|
|
104
104
|
e.forEach((e) => i.add(e));
|
|
105
|
-
let t =
|
|
106
|
-
r.push(`${n.bold(`${t}/`)}: ${e.length} files are still the starter's text (${
|
|
107
|
-
} else if (l && l.length > 1) l.forEach((e) => i.add(e)), r.push(`${n.bold(`review-pending (${l.length})`)}: ${
|
|
105
|
+
let t = xt(c), a = e.map((e) => e.path.slice(t.length + 1));
|
|
106
|
+
r.push(`${n.bold(`${t}/`)}: ${e.length} files are still the starter's text (${bt(a)}) ${n.dim("[starter-file-unchanged]")}`);
|
|
107
|
+
} else if (l && l.length > 1) l.forEach((e) => i.add(e)), r.push(`${n.bold(`review-pending (${l.length})`)}: ${bt(l.map(vt))}: ${c.message} ${n.dim("[review-pending]")}`);
|
|
108
108
|
else {
|
|
109
|
-
let e =
|
|
109
|
+
let e = je(c, t), i = e === void 0 ? n.bold(vt(c)) : c.path === c.file ? n.bold(e) : `${n.bold(e)} ${vt(c)}`;
|
|
110
110
|
r.push(`${i}: ${c.message} ${n.dim(`[${c.code}]`)}`);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
return r;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
116
|
-
for (let r of
|
|
117
|
-
for (let r of
|
|
118
|
-
for (let r of
|
|
115
|
+
function Ct(e, t = "") {
|
|
116
|
+
for (let r of St(e.errors, t)) console.log(` ${n.bgRed(n.white(" ERROR "))} ${r}`);
|
|
117
|
+
for (let r of St(e.warnings, t)) console.log(` ${n.bgYellow(n.black(" WARN "))} ${r}`);
|
|
118
|
+
for (let r of St(e.infos, t)) console.log(` ${n.bgCyan(n.black(" NOTE "))} ${r}`);
|
|
119
119
|
}
|
|
120
|
-
var
|
|
121
|
-
function
|
|
122
|
-
e.infos.filter((e) => e.code === "starter-file-unchanged").length <
|
|
120
|
+
var wt = 5;
|
|
121
|
+
function Tt(e, t = "") {
|
|
122
|
+
e.infos.filter((e) => e.code === "starter-file-unchanged").length < wt || (console.log(n.bold("Next:")), console.log(` 1. Edit ${n.cyan(R(t, "tokens/colors.json"))} with your colors`), console.log(` 2. Run ${n.cyan(z("dev", t))} to see the book`), console.log(` 3. Replace blazon's artwork in ${n.cyan(R(t, "assets/"))} and the text in ${n.cyan(R(t, "docs/"))}`), console.log());
|
|
123
123
|
}
|
|
124
|
-
var
|
|
125
|
-
function
|
|
124
|
+
var Et = 3;
|
|
125
|
+
function Dt(e, t = "") {
|
|
126
126
|
let r = /* @__PURE__ */ new Map();
|
|
127
127
|
for (let t of e.errors) {
|
|
128
|
-
let e =
|
|
128
|
+
let e = ve(t);
|
|
129
129
|
e && !r.has(`${t.code}\n${e}`) && r.set(`${t.code}\n${e}`, {
|
|
130
130
|
code: t.code,
|
|
131
131
|
fix: e
|
|
132
132
|
});
|
|
133
133
|
}
|
|
134
|
-
let i = [...r.values()].slice(0,
|
|
135
|
-
console.log(n.bold("Next:")), i.forEach(({ code: e, fix: t }, r) => console.log(` ${r + 1}. ${n.cyan(e)}: ${t}`)), console.log(` ${i.length + 1}. Run ${n.cyan(
|
|
134
|
+
let i = [...r.values()].slice(0, Et);
|
|
135
|
+
console.log(n.bold("Next:")), i.forEach(({ code: e, fix: t }, r) => console.log(` ${r + 1}. ${n.cyan(e)}: ${t}`)), console.log(` ${i.length + 1}. Run ${n.cyan(z("check", t))} again`), console.log();
|
|
136
136
|
}
|
|
137
|
-
function
|
|
138
|
-
let n =
|
|
137
|
+
function Ot(e, t = process.cwd()) {
|
|
138
|
+
let n = k(e.findings);
|
|
139
139
|
if (n.all.length === 0) return;
|
|
140
|
-
let r =
|
|
141
|
-
if (console.log(),
|
|
140
|
+
let r = L(t);
|
|
141
|
+
if (console.log(), Ct(n, r), console.log(), n.errors.length > 0) throw new ht(`blazon check found ${n.errors.length} error(s)`, e.findings, `Fix them, or run ${z("check", r)} for details.`);
|
|
142
142
|
}
|
|
143
|
-
async function
|
|
144
|
-
let i = await
|
|
143
|
+
async function kt(e = process.cwd(), t = !1, r) {
|
|
144
|
+
let i = await B(e);
|
|
145
145
|
console.log(n.cyan("\n[blazon] Checking design tokens..."));
|
|
146
|
-
let a = await
|
|
147
|
-
a.findings.push(...
|
|
148
|
-
let o =
|
|
146
|
+
let a = await D(i, e);
|
|
147
|
+
a.findings.push(...ye(e)), gt(r) || await ce(a, i, e, new ge(i, e, { named: _t(r) }));
|
|
148
|
+
let o = k(a.findings, { strict: t });
|
|
149
149
|
if (o.all.length === 0) return console.log(n.green(`\n ✔ ${a.tokens.items.length} tokens, no findings.\n`)), {
|
|
150
150
|
findings: o.all,
|
|
151
151
|
passed: !0
|
|
@@ -154,8 +154,8 @@ async function Mt(e = process.cwd(), t = !1, r) {
|
|
|
154
154
|
o.errors.length > 0 && `${o.errors.length} error(s)`,
|
|
155
155
|
o.warnings.length > 0 && `${o.warnings.length} warning(s)`,
|
|
156
156
|
o.infos.length > 0 && `${o.infos.length} note(s)`
|
|
157
|
-
].filter(Boolean), c = o.errors.length + o.warnings.length > 0 ? `${o.errors.length} error(s) and ${o.warnings.length} warning(s)${o.infos.length > 0 ? ` and ${o.infos.length} note(s)` : ""}` : s.join(" and "), l =
|
|
158
|
-
return console.log(`\nFound ${c}:\n`),
|
|
157
|
+
].filter(Boolean), c = o.errors.length + o.warnings.length > 0 ? `${o.errors.length} error(s) and ${o.warnings.length} warning(s)${o.infos.length > 0 ? ` and ${o.infos.length} note(s)` : ""}` : s.join(" and "), l = L(e);
|
|
158
|
+
return console.log(`\nFound ${c}:\n`), Ct(o, l), console.log(), o.errors.length > 0 ? Dt(o, l) : Tt(o, l), o.passed ? (console.log(o.warnings.length > 0 ? n.yellow("✔ Check passed with warnings.\n") : n.green("✔ Check passed.\n")), {
|
|
159
159
|
findings: o.all,
|
|
160
160
|
passed: !0
|
|
161
161
|
}) : (console.error(n.red(`✖ Check failed${t ? " (--strict treats warnings as errors)" : ""}.\n`)), {
|
|
@@ -164,73 +164,78 @@ async function Mt(e = process.cwd(), t = !1, r) {
|
|
|
164
164
|
});
|
|
165
165
|
}
|
|
166
166
|
// src/cli/commands/build.ts
|
|
167
|
-
async function
|
|
168
|
-
let i = await
|
|
169
|
-
a.findings.push(...
|
|
170
|
-
let o = new
|
|
171
|
-
|
|
172
|
-
let { siteOutDir: s } = await
|
|
167
|
+
async function At(e = process.cwd(), t, r) {
|
|
168
|
+
let i = await B(e, t ? { outDir: t } : void 0), a = await D(i, e);
|
|
169
|
+
a.findings.push(...ye(e));
|
|
170
|
+
let o = new ge(i, e, { named: _t(r) });
|
|
171
|
+
gt(r) || await ce(a, i, e, o), Ot(a, e);
|
|
172
|
+
let { siteOutDir: s } = await Re(i, e, { data: a }), c = gt(r) ? [] : await Ke(a, i, e, o, s);
|
|
173
173
|
if (c.length === 0) return { findings: a.findings };
|
|
174
|
-
let l =
|
|
175
|
-
if (console.log(),
|
|
174
|
+
let l = k(c);
|
|
175
|
+
if (console.log(), Ct(l, L(e)), console.log(), l.errors.length > 0) throw new ht(`a build plugin reported ${l.errors.length} error(s)`, [...a.findings, ...c], "The site is built; the plugin's findings above say what to fix.", "plugin-failed");
|
|
176
176
|
return console.log(n.dim(" Build plugins finished.")), { findings: [...a.findings, ...c] };
|
|
177
177
|
}
|
|
178
178
|
// src/cli/commands/tokens.ts
|
|
179
|
-
async function
|
|
180
|
-
let r = await
|
|
179
|
+
async function jt(e = process.cwd(), t) {
|
|
180
|
+
let r = await B(e);
|
|
181
181
|
console.log(n.cyan("\n[blazon] Compiling design tokens..."));
|
|
182
|
-
let i = await
|
|
183
|
-
i.findings.push(...
|
|
184
|
-
let a =
|
|
182
|
+
let i = await D(r, e);
|
|
183
|
+
i.findings.push(...ye(e));
|
|
184
|
+
let a = new ge(r, e, { named: _t(t) });
|
|
185
|
+
gt(t) || await ce(i, r, e, a), Ot(i, e);
|
|
186
|
+
let o = await he(i, r, e);
|
|
185
187
|
for (let e of [
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
a.tsPath,
|
|
191
|
-
a.jsonPath
|
|
188
|
+
o.cssPath,
|
|
189
|
+
o.typographyPath,
|
|
190
|
+
o.tsPath,
|
|
191
|
+
o.jsonPath
|
|
192
192
|
]) e && console.log(` ${n.green("✔")} Emitted ${n.bold(e)}`);
|
|
193
|
-
|
|
193
|
+
console.log();
|
|
194
|
+
let s = gt(t) ? [] : await Ke(i, r, e, a);
|
|
195
|
+
if (s.length === 0) return { findings: i.findings };
|
|
196
|
+
let c = k(s);
|
|
197
|
+
if (Ct(c, L(e)), console.log(), c.errors.length > 0) throw new ht(`a build plugin reported ${c.errors.length} error(s)`, [...i.findings, ...s], "The token files are written; the plugin's findings above say what to fix.", "plugin-failed");
|
|
198
|
+
return { findings: [...i.findings, ...s] };
|
|
194
199
|
}
|
|
195
200
|
// src/core/drift/compare.ts
|
|
196
|
-
var
|
|
197
|
-
function
|
|
201
|
+
var Mt = /^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i, Nt = /^(-?(?:\d+\.?\d*|\.\d+))(px|rem)$/i, Pt = (e) => e.trim().toLowerCase().replace(/\s+/g, " ");
|
|
202
|
+
function Ft(e) {
|
|
198
203
|
let t = e.trim();
|
|
199
|
-
if (!
|
|
204
|
+
if (!Mt.test(t)) return Pt(t);
|
|
200
205
|
let n = t.slice(1).toLowerCase();
|
|
201
206
|
return `#${n.length <= 4 ? [...n].map((e) => e + e).join("") : n}`;
|
|
202
207
|
}
|
|
203
|
-
function
|
|
204
|
-
let t = e.trim().match(
|
|
205
|
-
return t ? `${Number(t[1])}${t[2].toLowerCase()}` :
|
|
208
|
+
function It(e) {
|
|
209
|
+
let t = e.trim().match(Nt);
|
|
210
|
+
return t ? `${Number(t[1])}${t[2].toLowerCase()}` : Pt(e);
|
|
206
211
|
}
|
|
207
|
-
function
|
|
208
|
-
return e === "color" ?
|
|
212
|
+
function Lt(e, t) {
|
|
213
|
+
return e === "color" ? Ft(t) : e === "dimension" ? It(t) : Pt(t);
|
|
209
214
|
}
|
|
210
|
-
var
|
|
211
|
-
function
|
|
215
|
+
var Rt = /\/\*[\s\S]*?\*\//g, zt = /([^{}]*)\{([^{}]*)\}/g, Bt = /(--[A-Za-z0-9_-]+)\s*:\s*([^;]*?)\s*(?:;|$)/g, Vt = /(^|,)\s*(:root|html)\s*(,|$)/, Ht = /^var\(\s*(--[A-Za-z0-9_-]+)\s*\)$/;
|
|
216
|
+
function Ut(e) {
|
|
212
217
|
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
213
|
-
for (let r of e.replace(
|
|
214
|
-
let e =
|
|
215
|
-
for (let t of r[2].matchAll(
|
|
218
|
+
for (let r of e.replace(Rt, "").matchAll(zt)) {
|
|
219
|
+
let e = Vt.test(r[1].trim()) ? t : n;
|
|
220
|
+
for (let t of r[2].matchAll(Bt)) e.set(t[1], t[2]);
|
|
216
221
|
}
|
|
217
222
|
let r = new Map([...n, ...t]);
|
|
218
223
|
for (let [e, t] of r) {
|
|
219
224
|
let n = t, i = /* @__PURE__ */ new Set([e]);
|
|
220
|
-
for (let e = n.match(
|
|
225
|
+
for (let e = n.match(Ht); e && r.has(e[1]) && !i.has(e[1]); e = n.match(Ht)) i.add(e[1]), n = r.get(e[1]);
|
|
221
226
|
r.set(e, n);
|
|
222
227
|
}
|
|
223
228
|
return r;
|
|
224
229
|
}
|
|
225
|
-
function
|
|
226
|
-
let r =
|
|
230
|
+
function Wt(e, t, n) {
|
|
231
|
+
let r = Lt(e.type, String(e.value)), i = n.get(t);
|
|
227
232
|
if (i === void 0) return {
|
|
228
233
|
path: e.path,
|
|
229
234
|
cssVar: t,
|
|
230
235
|
status: "missing",
|
|
231
236
|
expected: r
|
|
232
237
|
};
|
|
233
|
-
let a =
|
|
238
|
+
let a = Lt(e.type, i);
|
|
234
239
|
return {
|
|
235
240
|
path: e.path,
|
|
236
241
|
cssVar: t,
|
|
@@ -239,21 +244,21 @@ function qt(e, t, n) {
|
|
|
239
244
|
actual: a
|
|
240
245
|
};
|
|
241
246
|
}
|
|
242
|
-
var
|
|
243
|
-
function
|
|
247
|
+
var Gt = 1e4;
|
|
248
|
+
function Kt(e) {
|
|
244
249
|
let t = e instanceof Error ? e.message : String(e), n = e instanceof Error ? e.cause : void 0;
|
|
245
250
|
return n instanceof Error && n.message && n.message !== t ? `${t}: ${n.message}` : t;
|
|
246
251
|
}
|
|
247
|
-
async function
|
|
252
|
+
async function qt(e) {
|
|
248
253
|
let t;
|
|
249
254
|
try {
|
|
250
255
|
t = await fetch(e, {
|
|
251
|
-
signal: AbortSignal.timeout(
|
|
256
|
+
signal: AbortSignal.timeout(Gt),
|
|
252
257
|
redirect: "follow"
|
|
253
258
|
});
|
|
254
259
|
} catch (t) {
|
|
255
260
|
let n = t instanceof Error && (t.name === "TimeoutError" || t.name === "AbortError");
|
|
256
|
-
throw Error(`could not fetch ${e}: ${n ? `no answer in ${
|
|
261
|
+
throw Error(`could not fetch ${e}: ${n ? `no answer in ${Gt / 1e3} s` : Kt(t)}`, { cause: t });
|
|
257
262
|
}
|
|
258
263
|
if (!t.ok) throw Error(`could not fetch ${e}: ${t.status} ${t.statusText}`.trim());
|
|
259
264
|
let n = [], r = 0;
|
|
@@ -267,10 +272,10 @@ async function Xt(e) {
|
|
|
267
272
|
}
|
|
268
273
|
return Buffer.concat(n);
|
|
269
274
|
}
|
|
270
|
-
async function
|
|
271
|
-
return (await
|
|
275
|
+
async function Jt(e) {
|
|
276
|
+
return (await qt(e)).toString("utf8");
|
|
272
277
|
}
|
|
273
|
-
function
|
|
278
|
+
function Yt(e, t) {
|
|
274
279
|
let n = [];
|
|
275
280
|
for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
|
|
276
281
|
let e = (e) => r.match(RegExp(`\\s${e}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i")), i = e("rel"), a = e("href");
|
|
@@ -281,19 +286,19 @@ function Qt(e, t) {
|
|
|
281
286
|
}
|
|
282
287
|
return n;
|
|
283
288
|
}
|
|
284
|
-
async function
|
|
289
|
+
async function Xt(e) {
|
|
285
290
|
if (/^[a-z][a-z0-9+.-]*:\/\//i.test(e)) {
|
|
286
291
|
if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address or a file`);
|
|
287
|
-
let t =
|
|
292
|
+
let t = Yt(await Jt(e), e).slice(0, 20);
|
|
288
293
|
return {
|
|
289
|
-
css: (await Promise.all(t.map(
|
|
294
|
+
css: (await Promise.all(t.map(Jt))).join("\n"),
|
|
290
295
|
sources: t
|
|
291
296
|
};
|
|
292
297
|
}
|
|
293
|
-
let t =
|
|
298
|
+
let t = A.resolve(e), n;
|
|
294
299
|
try {
|
|
295
|
-
if (
|
|
296
|
-
n =
|
|
300
|
+
if (j.statSync(t).size > 5242880) throw Error(`${t} is larger than 5 MB`);
|
|
301
|
+
n = j.readFileSync(t, "utf8");
|
|
297
302
|
} catch (e) {
|
|
298
303
|
throw Error(e instanceof Error && e.message.endsWith("5 MB") ? e.message : `could not read ${t}: ${e instanceof Error ? e.message : String(e)}`, { cause: e });
|
|
299
304
|
}
|
|
@@ -302,60 +307,60 @@ async function $t(e) {
|
|
|
302
307
|
sources: [t]
|
|
303
308
|
};
|
|
304
309
|
}
|
|
305
|
-
async function
|
|
310
|
+
async function Zt(e) {
|
|
306
311
|
if (!/^https?:\/\//i.test(e)) throw Error(`${e} is not an http(s) address`);
|
|
307
|
-
let t = await
|
|
312
|
+
let t = await Jt(e), n = Yt(t, e).slice(0, 20);
|
|
308
313
|
return {
|
|
309
314
|
html: t,
|
|
310
|
-
css: (await Promise.all(n.map(
|
|
315
|
+
css: (await Promise.all(n.map(Jt))).join("\n"),
|
|
311
316
|
sources: n
|
|
312
317
|
};
|
|
313
318
|
}
|
|
314
319
|
// src/core/init/from-site/tree.ts
|
|
315
|
-
var
|
|
316
|
-
function
|
|
317
|
-
return JSON.parse(
|
|
320
|
+
var Qt = (e) => typeof e == "object" && !!e && "$value" in e;
|
|
321
|
+
function $t(e) {
|
|
322
|
+
return JSON.parse(j.readFileSync(e, "utf-8"));
|
|
318
323
|
}
|
|
319
|
-
function
|
|
320
|
-
|
|
324
|
+
function en(e, t) {
|
|
325
|
+
j.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
|
|
321
326
|
}
|
|
322
|
-
var
|
|
323
|
-
function
|
|
327
|
+
var tn = (e) => ({ "dev.blazon": e });
|
|
328
|
+
function nn(e, t = []) {
|
|
324
329
|
let n = [];
|
|
325
|
-
for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (
|
|
330
|
+
for (let [r, i] of Object.entries(e)) !r.startsWith("$") && typeof i == "object" && i && (Qt(i) ? n.push([...t, r].join(".")) : n.push(...nn(i, [...t, r])));
|
|
326
331
|
return n;
|
|
327
332
|
}
|
|
328
|
-
var
|
|
333
|
+
var rn = (e, t) => {
|
|
329
334
|
let n = e;
|
|
330
335
|
for (let e of t.split(".")) {
|
|
331
336
|
if (typeof n != "object" || !n) return;
|
|
332
337
|
n = n[e];
|
|
333
338
|
}
|
|
334
|
-
return
|
|
335
|
-
},
|
|
336
|
-
function
|
|
337
|
-
return
|
|
338
|
-
let r =
|
|
339
|
-
return n.isDirectory() ?
|
|
339
|
+
return Qt(n) ? n : void 0;
|
|
340
|
+
}, an = (e) => [...JSON.stringify(e).matchAll(/\{([A-Za-z0-9_.-]+)\}/g)].map((e) => e[1]);
|
|
341
|
+
function on(e, t) {
|
|
342
|
+
return j.existsSync(e) ? j.readdirSync(e, { withFileTypes: !0 }).flatMap((n) => {
|
|
343
|
+
let r = A.join(e, n.name);
|
|
344
|
+
return n.isDirectory() ? on(r, t) : t.some((e) => n.name.endsWith(e)) ? [r] : [];
|
|
340
345
|
}) : [];
|
|
341
346
|
}
|
|
342
|
-
function
|
|
347
|
+
function sn(e, t) {
|
|
343
348
|
let n = t.split("."), r = [e];
|
|
344
349
|
for (let e of n.slice(0, -1)) r.push(r.at(-1)[e]);
|
|
345
350
|
delete r.at(-1)[n.at(-1)];
|
|
346
351
|
for (let e = r.length - 1; e >= 2 && !Object.keys(r[e]).some((e) => !e.startsWith("$")); e--) delete r[e - 1][n[e - 1]];
|
|
347
352
|
}
|
|
348
353
|
// src/core/init/from-site/clean-colors.ts
|
|
349
|
-
function
|
|
354
|
+
function cn(e) {
|
|
350
355
|
let { tree: t, destDir: n, picks: r, starterColors: i, siteColors: a, note: o, review: s, source: c, result: l } = e, u = (e, n) => {
|
|
351
|
-
let r =
|
|
356
|
+
let r = rn(t, `${e}.${n}`)?.$value, o = typeof r == "string" ? r.match(/^\{(.+)\}$/)?.[1] : void 0;
|
|
352
357
|
return o && i.has(o) && !a.has(o) ? o : void 0;
|
|
353
358
|
}, d = (e, n, r, i = {}) => {
|
|
354
|
-
let [a, c] = e.split("."), u =
|
|
359
|
+
let [a, c] = e.split("."), u = rn(t, e), d = String(u.$value);
|
|
355
360
|
t[a][c] = {
|
|
356
361
|
$value: `{${n}}`,
|
|
357
362
|
...typeof u.$description == "string" && { $description: u.$description },
|
|
358
|
-
$extensions:
|
|
363
|
+
$extensions: tn({
|
|
359
364
|
...i,
|
|
360
365
|
review: r ? {
|
|
361
366
|
...s,
|
|
@@ -386,20 +391,20 @@ function dn(e) {
|
|
|
386
391
|
let [n, r] = e.split("."), i = p(t);
|
|
387
392
|
i && u(n, r) && d(e, f(i), "", { source: c(`:root { ${i.cssVar} }`, i.exact ? i.cssVar : void 0) });
|
|
388
393
|
}
|
|
389
|
-
let m = t.color, { color: h, ...g } = t, _ = new Set(
|
|
390
|
-
for (let e of
|
|
391
|
-
let v = [
|
|
394
|
+
let m = t.color, { color: h, ...g } = t, _ = new Set(an(g));
|
|
395
|
+
for (let e of on(A.join(n, "tokens"), [".json"])) if (A.basename(e) !== "colors.json") for (let t of an($t(e))) _.add(t);
|
|
396
|
+
let v = [A.join(n, "blazon.json"), ...on(A.join(n, "docs"), [".md", ".mdx"])].filter((e) => j.existsSync(e)).map((e) => j.readFileSync(e, "utf-8")).join("\n");
|
|
392
397
|
for (let e of v.matchAll(/(?<![\w.-])color(?:\.[A-Za-z0-9_-]+)+/g)) _.add(e[0]);
|
|
393
398
|
let y = [..._];
|
|
394
399
|
for (; y.length > 0;) {
|
|
395
|
-
let e =
|
|
396
|
-
for (let t of e ?
|
|
400
|
+
let e = rn(t, y.pop());
|
|
401
|
+
for (let t of e ? an(e.$value) : []) _.has(t) || (_.add(t), y.push(t));
|
|
397
402
|
}
|
|
398
|
-
for (let e of [...i].filter((e) => !a.has(e) && !_.has(e)))
|
|
403
|
+
for (let e of [...i].filter((e) => !a.has(e) && !_.has(e))) rn({ color: m }, e) && (sn({ color: m }, e), l.removed.push(`${e} (a starter color nothing uses)`));
|
|
399
404
|
}
|
|
400
405
|
// src/core/init/palette.ts
|
|
401
|
-
var
|
|
402
|
-
function
|
|
406
|
+
var ln = "#ffffff", un = "#0b1120";
|
|
407
|
+
function dn(e) {
|
|
403
408
|
let t = e.trim().match(/^#?([0-9a-f]{3}|[0-9a-f]{6})$/i);
|
|
404
409
|
if (!t) return;
|
|
405
410
|
let n = t[1].length === 3 ? [...t[1]].map((e) => e + e).join("") : t[1];
|
|
@@ -409,38 +414,38 @@ function mn(e) {
|
|
|
409
414
|
4
|
|
410
415
|
].map((e) => parseInt(n.slice(e, e + 2), 16) / 255);
|
|
411
416
|
}
|
|
412
|
-
var
|
|
413
|
-
function
|
|
414
|
-
let t =
|
|
417
|
+
var fn = (e) => e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
418
|
+
function pn(e) {
|
|
419
|
+
let t = dn(e);
|
|
415
420
|
if (!t) throw Error(`not a hex color: ${e}`);
|
|
416
421
|
return t;
|
|
417
422
|
}
|
|
418
|
-
function
|
|
419
|
-
let [t, n, r] =
|
|
423
|
+
function mn(e) {
|
|
424
|
+
let [t, n, r] = pn(e).map(fn);
|
|
420
425
|
return .2126 * t + .7152 * n + .0722 * r;
|
|
421
426
|
}
|
|
422
|
-
function
|
|
423
|
-
let [n, r] = [
|
|
427
|
+
function V(e, t) {
|
|
428
|
+
let [n, r] = [mn(e), mn(t)];
|
|
424
429
|
return (Math.max(n, r) + .05) / (Math.min(n, r) + .05);
|
|
425
430
|
}
|
|
426
|
-
var
|
|
427
|
-
function
|
|
428
|
-
let t =
|
|
431
|
+
var hn = (e) => e >= 7 ? "AAA" : e >= 4.5 ? "AA" : e >= 3 ? "AA-large" : "fail";
|
|
432
|
+
function gn(e) {
|
|
433
|
+
let t = V(e, ln), n = V(e, un);
|
|
429
434
|
return {
|
|
430
435
|
onWhite: {
|
|
431
436
|
ratio: t,
|
|
432
|
-
level:
|
|
437
|
+
level: hn(t)
|
|
433
438
|
},
|
|
434
439
|
onNearBlack: {
|
|
435
440
|
ratio: n,
|
|
436
|
-
level:
|
|
441
|
+
level: hn(n)
|
|
437
442
|
},
|
|
438
443
|
carriesWhiteText: t >= 4.5
|
|
439
444
|
};
|
|
440
445
|
}
|
|
441
|
-
var
|
|
442
|
-
function
|
|
443
|
-
let t =
|
|
446
|
+
var _n = "#1E1F21", vn = "#F2F0EB";
|
|
447
|
+
function yn(e) {
|
|
448
|
+
let t = V(e, _n), n = V(e, vn);
|
|
444
449
|
return t >= n ? {
|
|
445
450
|
ink: "graphite",
|
|
446
451
|
ratio: t,
|
|
@@ -452,42 +457,42 @@ function Sn(e) {
|
|
|
452
457
|
};
|
|
453
458
|
}
|
|
454
459
|
// src/core/init/vocabulary.ts
|
|
455
|
-
var
|
|
456
|
-
function
|
|
460
|
+
var bn = "color.signal.orange", xn = "color.signal.primary", Sn = "color.signal.hazard", Cn = (e) => typeof e == "object" && !!e && "$value" in e;
|
|
461
|
+
function H(e, t) {
|
|
457
462
|
let n = e;
|
|
458
463
|
for (let e of t.split(".")) {
|
|
459
464
|
if (typeof n != "object" || !n) return;
|
|
460
465
|
n = n[e];
|
|
461
466
|
}
|
|
462
|
-
return
|
|
467
|
+
return Cn(n) ? n : void 0;
|
|
463
468
|
}
|
|
464
|
-
function
|
|
469
|
+
function wn(e, t) {
|
|
465
470
|
let n = e.$extensions ??= {}, r = n["dev.blazon"] ??= {};
|
|
466
471
|
r.review === void 0 && (r.review = {
|
|
467
472
|
status: "needs-review",
|
|
468
473
|
note: t
|
|
469
474
|
});
|
|
470
475
|
}
|
|
471
|
-
function
|
|
476
|
+
function Tn(e, t) {
|
|
472
477
|
let n = [], r = e.color, i = r?.signal, a = i?.orange;
|
|
473
|
-
if (!i || !
|
|
478
|
+
if (!i || !Cn(a)) throw Error(`${bn} is not in the tokens`);
|
|
474
479
|
let o = {};
|
|
475
480
|
for (let [e, t] of Object.entries(i)) o[e === "orange" ? "primary" : e] = t;
|
|
476
481
|
r.signal = o;
|
|
477
|
-
let s = JSON.parse(JSON.stringify(e).split(`{${
|
|
482
|
+
let s = JSON.parse(JSON.stringify(e).split(`{${bn}}`).join(`{${xn}}`));
|
|
478
483
|
for (let t of Object.keys(e)) e[t] = s[t];
|
|
479
|
-
let c =
|
|
484
|
+
let c = H(e, xn);
|
|
480
485
|
c.$value = t, c.$description = "Primary signal color";
|
|
481
|
-
let l =
|
|
486
|
+
let l = En(e, t, `{${xn}}`);
|
|
482
487
|
n.push(...l.hints);
|
|
483
|
-
let u =
|
|
484
|
-
return u && (
|
|
488
|
+
let u = H(e, Sn);
|
|
489
|
+
return u && (wn(u, "Still blazon's hazard yellow: it was not chosen to go with your primary. Set the brand's own, or remove it."), n.push(`${Sn} is still blazon's hazard yellow and is marked needs-review: set the brand's own or remove it`)), {
|
|
485
490
|
hints: n,
|
|
486
491
|
label: l.label
|
|
487
492
|
};
|
|
488
493
|
}
|
|
489
|
-
function
|
|
490
|
-
let i = [], a =
|
|
494
|
+
function En(e, t, n, r = !1) {
|
|
495
|
+
let i = [], a = V(t, _n), o = V(t, vn), s = H(e, "text.onSignal"), c = a < 4.5 && o >= 4.5 && s !== void 0;
|
|
491
496
|
if (c ? (s.$value = "{color.base.bone}", s.$description = "Labels on the brand color are bone", i.push(`Labels on ${t} are bone, because graphite is ${a.toFixed(1)}:1 there; blazon's hazard yellow has no label pair now`)) : a < 4.5 && i.push(`Neither graphite (${a.toFixed(1)}:1) nor bone (${o.toFixed(1)}:1) reaches AA (4.5:1) as a label on ${t}: blazon check will report text.onSignal, so choose a lighter or darker color`), c || r) {
|
|
492
497
|
let t = e.text?.$extensions?.["dev.blazon"];
|
|
493
498
|
for (let e of t?.pairs ?? []) e.bg === "{color.signal.*}" && (e.bg = n);
|
|
@@ -497,16 +502,16 @@ function kn(e, t, n, r = !1) {
|
|
|
497
502
|
label: c ? "bone" : "graphite"
|
|
498
503
|
};
|
|
499
504
|
}
|
|
500
|
-
var
|
|
501
|
-
function
|
|
505
|
+
var Dn = (e) => JSON.parse(j.readFileSync(e, "utf-8")), On = (e, t) => j.writeFileSync(e, `${JSON.stringify(t, null, 2)}\n`);
|
|
506
|
+
function kn(e, t) {
|
|
502
507
|
return [...t, ...Array.isArray(e) ? e.filter((e) => typeof e == "object" && !!e) : []];
|
|
503
508
|
}
|
|
504
|
-
var
|
|
509
|
+
var An = ["blazon-graphite", "blazon-bone"], jn = [...An, "blazon-mark"];
|
|
505
510
|
// src/core/init/shared/hex.ts
|
|
506
|
-
function
|
|
511
|
+
function Mn(e) {
|
|
507
512
|
let t = e.trim();
|
|
508
513
|
if (/^#([0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i.test(t)) return {
|
|
509
|
-
hex:
|
|
514
|
+
hex: Ft(t),
|
|
510
515
|
exact: !0
|
|
511
516
|
};
|
|
512
517
|
let n = t.match(/^rgba?\(\s*([\d.]+)(%?)[\s,]+([\d.]+)%?[\s,]+([\d.]+)%?(?:\s*[,/]\s*([\d.]+)(%?))?\s*\)$/i);
|
|
@@ -522,12 +527,12 @@ function Fn(e) {
|
|
|
522
527
|
};
|
|
523
528
|
}
|
|
524
529
|
// src/core/init/from-site/colors.ts
|
|
525
|
-
var
|
|
526
|
-
function
|
|
530
|
+
var Nn = 40, Pn = /brand|primary|secondary|accent|background|foreground|surface/i;
|
|
531
|
+
function Fn(e) {
|
|
527
532
|
let t = [], n = /* @__PURE__ */ new Set();
|
|
528
533
|
for (let [r, i] of e) {
|
|
529
|
-
if (!
|
|
530
|
-
let e =
|
|
534
|
+
if (!Pn.test(r)) continue;
|
|
535
|
+
let e = Mn(i);
|
|
531
536
|
if (!e || e.hex.length !== 7) continue;
|
|
532
537
|
let a = r.slice(2).toLowerCase().split(/[-_]+/).filter(Boolean);
|
|
533
538
|
a.length > 1 && (a[0] === "color" || a[0] === "colors") && (a = a.slice(1)), a.length > 1 && a.at(-1) === "foreground" || a.length > 1 && a.at(-2) === "on" && /^(dark|light)$/.test(a.at(-1)) || a.length === 0 || n.has(a.join(".")) || (n.add(a.join(".")), t.push({
|
|
@@ -536,20 +541,20 @@ function Rn(e) {
|
|
|
536
541
|
segments: a
|
|
537
542
|
}));
|
|
538
543
|
}
|
|
539
|
-
return t.slice(0,
|
|
544
|
+
return t.slice(0, Nn);
|
|
540
545
|
}
|
|
541
|
-
function
|
|
546
|
+
function In(e, t, n = []) {
|
|
542
547
|
let r = e.filter((e) => e.segments.includes(t)).sort((e, n) => Number(e.segments.at(-1) !== t) - Number(n.segments.at(-1) !== t) || e.segments.length - n.segments.length)[0];
|
|
543
548
|
return r || t !== "secondary" ? r : e.find((e) => !n.includes(e) && e.segments.includes("brand") && !e.segments.some((e) => /light|dark|strong|hero|raised|navy|background|foreground|surface/.test(e)));
|
|
544
549
|
}
|
|
545
550
|
// src/core/init/from-site/context.ts
|
|
546
|
-
var
|
|
551
|
+
var Ln = (...e) => e.join("/");
|
|
547
552
|
// src/core/init/from-site/sections/colors.ts
|
|
548
|
-
function
|
|
549
|
-
let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l =
|
|
553
|
+
function Rn(e, t) {
|
|
554
|
+
let { destDir: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Fn(r).filter((e) => !t?.has(e.cssVar));
|
|
550
555
|
if (l.length === 0) i.missing.push("no brand color: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color");
|
|
551
|
-
else if (c(
|
|
552
|
-
let e =
|
|
556
|
+
else if (c(Ln("tokens", "colors.json"))) {
|
|
557
|
+
let e = A.join(n, "tokens", "colors.json"), t = $t(e), r = t.color ??= {}, c = new Set(nn(r, ["color"])), u = /* @__PURE__ */ new Set(), d = new Set(l.map((e) => e.segments.join(".")));
|
|
553
558
|
for (let e of l) {
|
|
554
559
|
let t = e.segments;
|
|
555
560
|
[...d].some((e) => e.startsWith(`${t.join(".")}.`)) && (t = [...t, "base"]);
|
|
@@ -558,37 +563,37 @@ function Vn(e, t) {
|
|
|
558
563
|
let t = n[r];
|
|
559
564
|
if (t === void 0) {
|
|
560
565
|
let t = {};
|
|
561
|
-
e === 0 && (t.$extensions =
|
|
562
|
-
} else if (
|
|
566
|
+
e === 0 && (t.$extensions = tn({ review: o }), a = !0), n[r] = t, n = t;
|
|
567
|
+
} else if (Qt(t) || typeof t != "object" || !t) {
|
|
563
568
|
c = !1;
|
|
564
569
|
break;
|
|
565
570
|
} else n = t;
|
|
566
571
|
}
|
|
567
572
|
let l = t.at(-1);
|
|
568
|
-
!c || typeof n[l] == "object" && n[l] !== null && !
|
|
573
|
+
!c || typeof n[l] == "object" && n[l] !== null && !Qt(n[l]) ? i.missing.push(`${e.cssVar} was not written: color.${t.join(".")} clashes with a starter token`) : (n[l] = {
|
|
569
574
|
$value: e.hex,
|
|
570
|
-
$extensions:
|
|
575
|
+
$extensions: tn({
|
|
571
576
|
source: s(`:root { ${e.cssVar} }`, e.exact ? e.cssVar : void 0),
|
|
572
577
|
...a ? {} : { review: o }
|
|
573
578
|
})
|
|
574
579
|
}, e.segments = t, u.add(e));
|
|
575
580
|
}
|
|
576
|
-
let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p =
|
|
581
|
+
let f = new Set([...u].map((e) => `color.${e.segments.join(".")}`)), p = In(l, "primary"), m = t.interactive, h = rn(t, "interactive.primary");
|
|
577
582
|
if (!p) i.missing.push("no primary color: interactive.primary keeps the starter's value");
|
|
578
583
|
else if (m && h) {
|
|
579
584
|
let e = `color.${p.segments.join(".")}`;
|
|
580
585
|
m.primary = {
|
|
581
586
|
$value: `{${e}}`,
|
|
582
587
|
...typeof h.$description == "string" && { $description: h.$description },
|
|
583
|
-
$extensions:
|
|
588
|
+
$extensions: tn({
|
|
584
589
|
source: s(`:root { ${p.cssVar} }`, p.exact ? p.cssVar : void 0),
|
|
585
590
|
review: o
|
|
586
591
|
})
|
|
587
592
|
}, i.repointed.push(`interactive.primary to {${e}}`);
|
|
588
|
-
let n =
|
|
593
|
+
let n = En(t, p.hex, `{${e}}`, !0);
|
|
589
594
|
for (let e of n.hints) i.missing.push(e);
|
|
590
595
|
} else i.missing.push("interactive.primary was not found in tokens/colors.json, so the primary color was not set");
|
|
591
|
-
|
|
596
|
+
cn({
|
|
592
597
|
tree: t,
|
|
593
598
|
destDir: n,
|
|
594
599
|
picks: [...u],
|
|
@@ -598,53 +603,53 @@ function Vn(e, t) {
|
|
|
598
603
|
review: o,
|
|
599
604
|
source: s,
|
|
600
605
|
result: i
|
|
601
|
-
}),
|
|
606
|
+
}), en(e, t), i.written.push(Ln("tokens", "colors.json"));
|
|
602
607
|
}
|
|
603
608
|
}
|
|
604
609
|
// src/core/init/from-site/html.ts
|
|
605
|
-
function
|
|
610
|
+
function zn(e) {
|
|
606
611
|
return e.replace(/&/g, "&").replace(/"/g, "\"").replace(/�?39;|'/g, "'").replace(/</g, "<").replace(/>/g, ">").replace(/ /g, " ").replace(/\s+/g, " ").trim().split(/ [|:–—-] /)[0].trim();
|
|
607
612
|
}
|
|
608
|
-
var
|
|
613
|
+
var U = (e, t) => {
|
|
609
614
|
let n = e.match(RegExp(`\\s${t}\\s*=\\s*(?:"([^"]*)"|'([^']*)'|([^\\s>]+))`, "i"));
|
|
610
615
|
return n ? n[1] ?? n[2] ?? n[3] : void 0;
|
|
611
616
|
};
|
|
612
|
-
function
|
|
613
|
-
for (let n of e.match(/<meta\b[^>]*>/gi) ?? []) if ((
|
|
614
|
-
let e =
|
|
617
|
+
function W(e, t) {
|
|
618
|
+
for (let n of e.match(/<meta\b[^>]*>/gi) ?? []) if ((U(n, "property") ?? U(n, "name"))?.toLowerCase() === t) {
|
|
619
|
+
let e = U(n, "content")?.replace(/&/g, "&").trim();
|
|
615
620
|
if (e) return e;
|
|
616
621
|
}
|
|
617
622
|
}
|
|
618
|
-
function
|
|
619
|
-
let t =
|
|
623
|
+
function Bn(e) {
|
|
624
|
+
let t = W(e, "og:site_name") ?? W(e, "application-name");
|
|
620
625
|
if (t) return t;
|
|
621
626
|
let n = e.match(/<title\b[^>]*>([\s\S]*?)<\/title>/i);
|
|
622
|
-
return (n ?
|
|
627
|
+
return (n ? zn(n[1]) : "") || void 0;
|
|
623
628
|
}
|
|
624
|
-
async function
|
|
625
|
-
let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) =>
|
|
629
|
+
async function Vn(e, t) {
|
|
630
|
+
let n = (e.match(/<link\b[^>]*>/gi) ?? []).find((e) => U(e, "rel")?.toLowerCase() === "manifest"), r = n && U(n, "href");
|
|
626
631
|
if (r) try {
|
|
627
632
|
let e = new URL(r, t);
|
|
628
633
|
if (e.protocol !== "http:" && e.protocol !== "https:") return;
|
|
629
|
-
let n = JSON.parse(await
|
|
634
|
+
let n = JSON.parse(await Jt(e.href)), i = typeof n.short_name == "string" ? n.short_name.trim() : "", a = typeof n.name == "string" ? zn(n.name) : "";
|
|
630
635
|
return i || a || void 0;
|
|
631
636
|
} catch {
|
|
632
637
|
return;
|
|
633
638
|
}
|
|
634
639
|
}
|
|
635
640
|
// src/core/init/from-site/sections/config.ts
|
|
636
|
-
async function
|
|
637
|
-
let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u =
|
|
641
|
+
async function Hn(e, t, n) {
|
|
642
|
+
let { destDir: r, url: i, page: a, result: o, mayChange: s } = e, { fontUrls: c } = n, l = "blazon.json", u = W(a.html, "og:site_name") ?? W(a.html, "application-name") ?? await Vn(a.html, i) ?? Bn(a.html), d = W(a.html, "description");
|
|
638
643
|
u || o.missing.push("no <title> on the page: the config title keeps the folder name");
|
|
639
644
|
let f = !1;
|
|
640
645
|
if ((u || d || t.single || t.onLight || c.length > 0) && s(l)) {
|
|
641
|
-
let e =
|
|
646
|
+
let e = A.join(r, l), n = Dn(e);
|
|
642
647
|
u && (n.title = u), d && (n.description = d);
|
|
643
648
|
let i = t.single ?? (t.onLight ? {
|
|
644
649
|
onLight: t.onLight,
|
|
645
650
|
...t.onDark ? { onDark: t.onDark } : {}
|
|
646
651
|
} : void 0);
|
|
647
|
-
i && (n.logo = i), c.length > 0 && (n.fonts =
|
|
652
|
+
i && (n.logo = i), c.length > 0 && (n.fonts = kn(n.fonts, c)), On(e, n), o.written.push(l), f = !!i;
|
|
648
653
|
}
|
|
649
654
|
return {
|
|
650
655
|
title: u,
|
|
@@ -653,23 +658,23 @@ async function Gn(e, t, n) {
|
|
|
653
658
|
};
|
|
654
659
|
}
|
|
655
660
|
// src/core/init/from-site/sections/directives.ts
|
|
656
|
-
var
|
|
657
|
-
function
|
|
658
|
-
let { destDir:
|
|
659
|
-
if (!
|
|
660
|
-
let
|
|
661
|
-
for (let e of
|
|
661
|
+
var Un = /^[ \t]*<!--\s*blazon:tokens\b([^>]*?)-->[ \t]*\r?\n?/gm;
|
|
662
|
+
function Wn(e) {
|
|
663
|
+
let { destDir: n, created: r, result: i } = e, a = A.join(n, "docs");
|
|
664
|
+
if (!j.existsSync(a)) return;
|
|
665
|
+
let o = t(Ne(A.join(n, "tokens"), n), "--").items, s = (e) => o.some((t) => t.path === e || t.path.startsWith(`${e}.`));
|
|
666
|
+
for (let e of j.readdirSync(a).filter((e) => e.endsWith(".md"))) {
|
|
662
667
|
let t = `docs/${e}`;
|
|
663
|
-
if (!
|
|
664
|
-
let
|
|
665
|
-
let n = t.split(/\s+/).filter(Boolean), r = n.filter(
|
|
666
|
-
return c.push(...n.filter((e) => !
|
|
668
|
+
if (!r.has(t)) continue;
|
|
669
|
+
let n = A.join(a, e), o = j.readFileSync(n, "utf-8"), c = [], l = o.replace(Un, (e, t) => {
|
|
670
|
+
let n = t.split(/\s+/).filter(Boolean), r = n.filter(s);
|
|
671
|
+
return c.push(...n.filter((e) => !s(e))), r.length === n.length ? e : r.length === 0 ? "" : `<!-- blazon:tokens ${r.join(" ")} -->\n`;
|
|
667
672
|
}).replace(/\n{3,}/g, "\n\n");
|
|
668
|
-
l !==
|
|
673
|
+
l !== o && (j.writeFileSync(n, l), i.removed.push(`${c.join(", ")} in ${t} (the site has no such token to show)`));
|
|
669
674
|
}
|
|
670
675
|
}
|
|
671
676
|
// src/core/init/shared/google-fonts.ts
|
|
672
|
-
var
|
|
677
|
+
var Gn = [
|
|
673
678
|
"Inter",
|
|
674
679
|
"Roboto",
|
|
675
680
|
"Open Sans",
|
|
@@ -687,12 +692,12 @@ var Jn = [
|
|
|
687
692
|
"Playfair Display",
|
|
688
693
|
"JetBrains Mono"
|
|
689
694
|
];
|
|
690
|
-
function
|
|
691
|
-
let t =
|
|
695
|
+
function Kn(e) {
|
|
696
|
+
let t = Gn.find((t) => t.toLowerCase() === e.toLowerCase());
|
|
692
697
|
return t ? `https://fonts.googleapis.com/css2?family=${t.replace(/ /g, "+")}:wght@400;500;600;700&display=swap` : void 0;
|
|
693
698
|
}
|
|
694
699
|
// src/core/init/from-site/fonts.ts
|
|
695
|
-
var
|
|
700
|
+
var qn = /* @__PURE__ */ new Set([
|
|
696
701
|
"serif",
|
|
697
702
|
"sans-serif",
|
|
698
703
|
"monospace",
|
|
@@ -712,19 +717,19 @@ var Xn = /* @__PURE__ */ new Set([
|
|
|
712
717
|
"-apple-system",
|
|
713
718
|
"blinkmacsystemfont",
|
|
714
719
|
"segoe ui"
|
|
715
|
-
]),
|
|
720
|
+
]), Jn = /* @__PURE__ */ new Set([
|
|
716
721
|
"serif",
|
|
717
722
|
"sans-serif",
|
|
718
723
|
"monospace",
|
|
719
724
|
"cursive",
|
|
720
725
|
"fantasy"
|
|
721
726
|
]);
|
|
722
|
-
function
|
|
727
|
+
function Yn(e) {
|
|
723
728
|
let t = [], n = "", r = "";
|
|
724
729
|
for (let i of e) r ? i === r ? r = "" : n += i : i === "\"" || i === "'" ? r = i : i === "," ? (t.push(n.trim()), n = "") : n += i;
|
|
725
730
|
return t.push(n.trim()), t.filter(Boolean);
|
|
726
731
|
}
|
|
727
|
-
function
|
|
732
|
+
function Xn(e, t, n) {
|
|
728
733
|
let r;
|
|
729
734
|
for (let i of e.replace(/\/\*[\s\S]*?\*\//g, "").matchAll(/([^{}]*)\{([^{}]*)\}/g)) {
|
|
730
735
|
let e = i[1].split(",").map((e) => e.trim().toLowerCase()).find((e) => n.test(e));
|
|
@@ -736,7 +741,7 @@ function $n(e, t, n) {
|
|
|
736
741
|
let e = t.get(c[1]);
|
|
737
742
|
o = e ?? c[2] ?? "", e !== void 0 && (s = c[1]);
|
|
738
743
|
}
|
|
739
|
-
let l =
|
|
744
|
+
let l = Yn(o), u = l.find((e) => !qn.has(e.toLowerCase()) && !e.startsWith("var("));
|
|
740
745
|
u && (r = {
|
|
741
746
|
family: u,
|
|
742
747
|
stack: l,
|
|
@@ -746,21 +751,21 @@ function $n(e, t, n) {
|
|
|
746
751
|
}
|
|
747
752
|
return r;
|
|
748
753
|
}
|
|
749
|
-
function
|
|
750
|
-
let t = e.stack.find((e) =>
|
|
754
|
+
function Zn(e) {
|
|
755
|
+
let t = e.stack.find((e) => Jn.has(e.toLowerCase()));
|
|
751
756
|
return [e.family, (t ?? "sans-serif").toLowerCase()];
|
|
752
757
|
}
|
|
753
758
|
// src/core/init/from-site/sections/fonts.ts
|
|
754
|
-
function
|
|
755
|
-
let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l =
|
|
759
|
+
function Qn(e) {
|
|
760
|
+
let { destDir: t, page: n, vars: r, result: i, note: a, review: o, source: s, mayChange: c } = e, l = Xn(n.css, r, /^(body|html)$/), u = Xn(n.css, r, /^h[1-6]$/), d = [];
|
|
756
761
|
if (!l && !u) i.missing.push("no font: no body or heading rule in the stylesheets names a font-family");
|
|
757
|
-
else if (c(
|
|
758
|
-
let e =
|
|
762
|
+
else if (c(Ln("tokens", "typography.json"))) {
|
|
763
|
+
let e = A.join(t, "tokens", "typography.json"), n = $t(e), r = (n.font ??= {}).family ??= {}, c = l ?? u, f = [["body", c], ["display", u ?? c]];
|
|
759
764
|
for (let [e, t] of f) {
|
|
760
|
-
let n =
|
|
765
|
+
let n = Kn(t.family);
|
|
761
766
|
n ? d.includes(n) || d.push(n) : i.missing.push(`the font ${t.family} is not one blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`), r[e] = {
|
|
762
|
-
$value:
|
|
763
|
-
$extensions:
|
|
767
|
+
$value: Zn(t),
|
|
768
|
+
$extensions: tn({
|
|
764
769
|
source: s(t.cssVar ? `${t.locator}, from ${t.cssVar}` : t.locator),
|
|
765
770
|
review: n ? o : {
|
|
766
771
|
status: "needs-review",
|
|
@@ -770,25 +775,25 @@ function tr(e) {
|
|
|
770
775
|
};
|
|
771
776
|
}
|
|
772
777
|
let p = r.mono;
|
|
773
|
-
p &&
|
|
778
|
+
p && wn(p, `${a} Still blazon's mono font: the site's stylesheets named no monospace font. Set the brand's own.`), en(e, n), i.written.push(Ln("tokens", "typography.json"));
|
|
774
779
|
}
|
|
775
780
|
return { fontUrls: d };
|
|
776
781
|
}
|
|
777
782
|
// src/core/init/from-site/sections/intro.ts
|
|
778
|
-
var
|
|
779
|
-
function
|
|
783
|
+
var $n = (e) => e.length === 1 && e[0] === "logo", er = (e) => e.length < 2 ? e.join("") : `${e.slice(0, -1).join(", ")} and ${e[e.length - 1]}`;
|
|
784
|
+
function tr(e) {
|
|
780
785
|
let { url: t, date: n, result: r } = e, i = {
|
|
781
786
|
colors: r.written.includes("tokens/colors.json"),
|
|
782
787
|
fonts: r.written.includes("tokens/typography.json"),
|
|
783
788
|
logo: r.written.some((e) => e.startsWith("assets/logos/"))
|
|
784
789
|
}, a = Object.entries(i).filter(([, e]) => e).map(([e]) => e), o = Object.entries(i).filter(([, e]) => !e).map(([e]) => e);
|
|
785
790
|
if (a.length === 0) return `Nothing could be read from ${t} on ${n}: it gave no brand colors, no fonts and no logo. This brand book is still blazon's own starter, so replace its colors, fonts and logo with the brand's.`;
|
|
786
|
-
let s = `The ${
|
|
787
|
-
return o.length === 0 ? s : `${s} The ${
|
|
791
|
+
let s = `The ${er(a)} in this brand book ${$n(a) ? "was" : "were"} read from ${t} on ${n}. They are what the site shows today, so the brand owner needs to confirm them before anyone relies on them.`;
|
|
792
|
+
return o.length === 0 ? s : `${s} The ${er(o)} ${$n(o) ? "was" : "were"} not found, so ${$n(o) ? "it is" : "they are"} still blazon's own starter: replace ${$n(o) ? "it" : "them"}.`;
|
|
788
793
|
}
|
|
789
|
-
function
|
|
794
|
+
function nr(e, t, n) {
|
|
790
795
|
let { destDir: r, url: i, created: a, result: o } = e, s = "docs/01-principles.md";
|
|
791
|
-
if (a.has(s) &&
|
|
796
|
+
if (a.has(s) && j.existsSync(A.join(r, s))) {
|
|
792
797
|
let a = t ?? new URL(i).hostname.replace(/^www\./, ""), c = [
|
|
793
798
|
"---",
|
|
794
799
|
"title: Introduction",
|
|
@@ -801,24 +806,24 @@ function ar(e, t, n) {
|
|
|
801
806
|
`# ${a}`,
|
|
802
807
|
"",
|
|
803
808
|
...n ? [n, ""] : [],
|
|
804
|
-
|
|
809
|
+
tr(e),
|
|
805
810
|
""
|
|
806
811
|
];
|
|
807
|
-
|
|
812
|
+
j.writeFileSync(A.join(r, s), c.join("\n")), o.written.push(s);
|
|
808
813
|
}
|
|
809
814
|
}
|
|
810
815
|
// src/core/init/shared/svg.ts
|
|
811
|
-
function
|
|
816
|
+
function rr(e) {
|
|
812
817
|
let t = e.replace(/<script\b[\s\S]*?<\/script>/gi, "").replace(/\son\w+\s*=\s*(?:"[^"]*"|'[^']*')/gi, "").replace(/(href\s*=\s*["'])\s*javascript:[^"']*/gi, "$1#");
|
|
813
818
|
return /<svg\b[^>]*\sxmlns\s*=/i.test(t) || (t = t.replace(/<svg\b/i, "<svg xmlns=\"http://www.w3.org/2000/svg\"")), `${t.trim()}\n`;
|
|
814
819
|
}
|
|
815
820
|
// src/core/init/from-site/logo.ts
|
|
816
|
-
function
|
|
821
|
+
function ir(e, t) {
|
|
817
822
|
let n = e.replace(/<!--[\s\S]*?-->/g, "").match(/<header\b[^>]*>([\s\S]*?)<\/header>/i)?.[1];
|
|
818
823
|
if (!n) return;
|
|
819
824
|
let r = [];
|
|
820
825
|
for (let e of n.matchAll(/<a\b([^>]*)>([\s\S]*?)<\/a>/gi)) {
|
|
821
|
-
let n =
|
|
826
|
+
let n = U(`<a${e[1]}>`, "href");
|
|
822
827
|
if (n !== void 0) try {
|
|
823
828
|
let i = new URL(n.trim(), t);
|
|
824
829
|
i.origin === new URL(t).origin && i.pathname === "/" && r.push(e[2]);
|
|
@@ -826,7 +831,7 @@ function sr(e, t) {
|
|
|
826
831
|
}
|
|
827
832
|
let i = (e) => e.match(/<svg\b[\s\S]*?<\/svg>/i)?.[0], a = (e) => {
|
|
828
833
|
for (let n of e.matchAll(/<img\b[^>]*>/gi)) {
|
|
829
|
-
let e =
|
|
834
|
+
let e = U(n[0], "src");
|
|
830
835
|
if (e && /\.svg(?:[?#]|$)/i.test(e)) try {
|
|
831
836
|
let n = new URL(e.trim(), t);
|
|
832
837
|
if (n.protocol === "http:" || n.protocol === "https:") return n.href;
|
|
@@ -862,16 +867,16 @@ function sr(e, t) {
|
|
|
862
867
|
locator: "header img"
|
|
863
868
|
} : void 0;
|
|
864
869
|
}
|
|
865
|
-
function
|
|
870
|
+
function ar(e, t) {
|
|
866
871
|
let n = [];
|
|
867
872
|
for (let [r] of e.replace(/<!--[\s\S]*?-->/g, "").matchAll(/<link\b[^>]*>/gi)) {
|
|
868
|
-
let e = (
|
|
873
|
+
let e = (U(r, "rel") ?? "").toLowerCase().split(/\s+/), i = e.includes("apple-touch-icon") || e.includes("apple-touch-icon-precomposed");
|
|
869
874
|
if (!i && !e.includes("icon")) continue;
|
|
870
|
-
let a =
|
|
875
|
+
let a = U(r, "href");
|
|
871
876
|
if (a) try {
|
|
872
877
|
let o = new URL(a.trim(), t);
|
|
873
878
|
if (o.protocol !== "http:" && o.protocol !== "https:") continue;
|
|
874
|
-
let s =
|
|
879
|
+
let s = A.extname(o.pathname).toLowerCase() || (U(r, "type") === "image/svg+xml" ? ".svg" : ".png");
|
|
875
880
|
n.push({
|
|
876
881
|
url: o.href,
|
|
877
882
|
svg: s === ".svg",
|
|
@@ -883,14 +888,14 @@ function cr(e, t) {
|
|
|
883
888
|
}
|
|
884
889
|
return n.find((e) => e.svg) ?? n.find((e) => e.apple) ?? n[0];
|
|
885
890
|
}
|
|
886
|
-
function
|
|
891
|
+
function or(e) {
|
|
887
892
|
let t = new URL(e).hostname.replace(/^www\./, "");
|
|
888
893
|
return /^[\d.]+$/.test(t) || t.includes(":") || t.startsWith("[") ? "site" : t.split(".")[0].replace(/[^a-z0-9-]/gi, "-").toLowerCase() || "site";
|
|
889
894
|
}
|
|
890
895
|
// src/core/init/from-site/sections/logo.ts
|
|
891
|
-
async function
|
|
892
|
-
let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l =
|
|
893
|
-
|
|
896
|
+
async function sr(e) {
|
|
897
|
+
let { destDir: t, url: n, date: r, page: i, result: a, note: o, review: s } = e, c = {}, l = or(n), u = (e, i, c) => {
|
|
898
|
+
en(A.join(t, e.replace(/\.[a-z]+$/, ".json")), {
|
|
894
899
|
description: o,
|
|
895
900
|
...c,
|
|
896
901
|
source: {
|
|
@@ -900,26 +905,26 @@ async function ur(e) {
|
|
|
900
905
|
review: s
|
|
901
906
|
}), a.written.push(e.replace(/\.[a-z]+$/, ".json"));
|
|
902
907
|
}, d = (e, n) => {
|
|
903
|
-
let r =
|
|
904
|
-
return i.length > 0 ? (a.missing.push(`${i.join(" and ")} already existed, so ${i.length > 1 ? "they were" : "it was"} kept as ${i.length > 1 ? "they were" : "it was"}, and no logo was written to ${e}`), !1) : (
|
|
905
|
-
}, f =
|
|
908
|
+
let r = A.join(t, e), i = [e, e.replace(/\.[a-z]+$/, ".json")].filter((e) => j.existsSync(A.join(t, e)));
|
|
909
|
+
return i.length > 0 ? (a.missing.push(`${i.join(" and ")} already existed, so ${i.length > 1 ? "they were" : "it was"} kept as ${i.length > 1 ? "they were" : "it was"}, and no logo was written to ${e}`), !1) : (j.mkdirSync(A.dirname(r), { recursive: !0 }), j.writeFileSync(r, n), a.written.push(e), !0);
|
|
910
|
+
}, f = ir(i.html, n), p, m = "";
|
|
906
911
|
if (f?.kind === "inline") p = f.svg, m = f.locator;
|
|
907
912
|
else if (f?.kind === "url") {
|
|
908
913
|
try {
|
|
909
|
-
p = (await
|
|
914
|
+
p = (await qt(f.url)).toString("utf8"), m = `${f.locator} (${f.url})`;
|
|
910
915
|
} catch (e) {
|
|
911
916
|
a.missing.push(`the header logo could not be read: ${e instanceof Error ? e.message : String(e)}`);
|
|
912
917
|
}
|
|
913
918
|
p !== void 0 && !/<svg\b/i.test(p) && (p = void 0, a.missing.push(`${f.url} is not an SVG`));
|
|
914
919
|
}
|
|
915
920
|
let h;
|
|
916
|
-
if (p === void 0 && (h =
|
|
917
|
-
p = (await
|
|
921
|
+
if (p === void 0 && (h = ar(i.html, n), h?.svg)) try {
|
|
922
|
+
p = (await qt(h.url)).toString("utf8"), m = `${h.locator} (${h.url})`, /<svg\b/i.test(p) || (p = void 0);
|
|
918
923
|
} catch (e) {
|
|
919
924
|
a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
|
|
920
925
|
}
|
|
921
926
|
if (p !== void 0) {
|
|
922
|
-
let e =
|
|
927
|
+
let e = rr(p);
|
|
923
928
|
if (/<use\b/i.test(e) && !/<symbol\b/i.test(e) && a.missing.push("the logo uses <use> to point at a sprite elsewhere on the page, so it may draw nothing: check it"), /currentColor/i.test(e)) {
|
|
924
929
|
let t = `assets/logos/${l}.svg`, n = `assets/logos/${l}-white.svg`;
|
|
925
930
|
d(t, e.replace(/currentColor/gi, "#111111")) && (u(t, m, {
|
|
@@ -946,7 +951,7 @@ async function ur(e) {
|
|
|
946
951
|
].includes(h.ext)) a.missing.push(`only a ${h.ext} icon was found (${h.url}), which blazon cannot show: no logo was written`);
|
|
947
952
|
else try {
|
|
948
953
|
let e = `assets/logos/${l}${h.ext === ".jpeg" ? ".jpg" : h.ext}`;
|
|
949
|
-
d(e, await
|
|
954
|
+
d(e, await qt(h.url)) && (u(e, h.locator, { title: "Site icon" }), c.single = `./${e}`, a.missing.push(`no SVG logo was found: ${e} is the site's raster icon (${h.url}), not a logo, so replace it with the real one`));
|
|
950
955
|
} catch (e) {
|
|
951
956
|
a.missing.push(`the icon could not be read: ${e instanceof Error ? e.message : String(e)}`);
|
|
952
957
|
}
|
|
@@ -954,28 +959,28 @@ async function ur(e) {
|
|
|
954
959
|
return c;
|
|
955
960
|
}
|
|
956
961
|
// src/core/init/from-site/sections/placeholder.ts
|
|
957
|
-
function
|
|
962
|
+
function cr(e, t, n) {
|
|
958
963
|
let { destDir: r, created: i, result: a } = e, o = t.single ?? t.onLight;
|
|
959
964
|
if (n && o) {
|
|
960
|
-
let e =
|
|
961
|
-
if (i.has(`assets/logos/${
|
|
962
|
-
let { description: n, background: i, ...a } =
|
|
965
|
+
let e = A.join(r, `assets/logos/${An[0]}.json`), t = A.join(r, o.replace(/^\.\//, "").replace(/\.[a-z]+$/, ".json"));
|
|
966
|
+
if (i.has(`assets/logos/${An[0]}.json`) && j.existsSync(e) && j.existsSync(t)) {
|
|
967
|
+
let { description: n, background: i, ...a } = $t(e), s = $t(t), c = j.readFileSync(A.join(r, o.replace(/^\.\//, "")), "utf-8").match(/<svg\b[^>]*>/i)?.[0] ?? "", l = c.match(/viewBox\s*=\s*["']\s*[-\d.]+[\s,]+[-\d.]+[\s,]+[\d.]+[\s,]+([\d.]+)/i)?.[1] ?? c.match(/\sheight\s*=\s*["']?([\d.]+)/i)?.[1];
|
|
963
968
|
l && Number(l) > 0 && (a.clearSpace = {
|
|
964
969
|
value: Math.max(1, Math.round(Number(l) * .3 * 100) / 100),
|
|
965
970
|
unit: "px"
|
|
966
971
|
});
|
|
967
972
|
for (let [e, t] of Object.entries(a)) s[e] ??= t;
|
|
968
|
-
s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`,
|
|
973
|
+
s.description = `${String(s.description)} Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.`, en(t, s);
|
|
969
974
|
}
|
|
970
|
-
for (let e of
|
|
975
|
+
for (let e of jn) for (let t of ["svg", "json"]) {
|
|
971
976
|
let n = `assets/logos/${e}.${t}`;
|
|
972
|
-
i.has(n) && (
|
|
977
|
+
i.has(n) && (j.rmSync(A.join(r, n), { force: !0 }), a.removed.push(`${n} (blazon's own logo)`));
|
|
973
978
|
}
|
|
974
979
|
}
|
|
975
980
|
}
|
|
976
981
|
// src/core/init/from-site/apply.ts
|
|
977
|
-
async function
|
|
978
|
-
let a = r.toISOString().slice(0, 10), o = i.page ?? await
|
|
982
|
+
async function lr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
|
|
983
|
+
let a = r.toISOString().slice(0, 10), o = i.page ?? await Zt(t), s = {
|
|
979
984
|
written: [],
|
|
980
985
|
missing: [],
|
|
981
986
|
removed: [],
|
|
@@ -986,7 +991,7 @@ async function fr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
|
|
|
986
991
|
date: a,
|
|
987
992
|
created: n,
|
|
988
993
|
page: o,
|
|
989
|
-
vars:
|
|
994
|
+
vars: Ut(o.css),
|
|
990
995
|
result: s,
|
|
991
996
|
note: c,
|
|
992
997
|
review: {
|
|
@@ -1000,27 +1005,27 @@ async function fr(e, t, n, r = /* @__PURE__ */ new Date(), i = {}) {
|
|
|
1000
1005
|
}),
|
|
1001
1006
|
mayChange: (e) => n.has(e) ? !0 : (s.missing.push(`${e} already existed, so it was kept as it was`), !1)
|
|
1002
1007
|
};
|
|
1003
|
-
|
|
1004
|
-
let u =
|
|
1005
|
-
return
|
|
1008
|
+
Rn(l, i.skipVars);
|
|
1009
|
+
let u = Qn(l), d = await sr(l), { title: f, description: p, configLogo: m } = await Hn(l, d, u);
|
|
1010
|
+
return cr(l, d, m), nr(l, f, p), Wn(l), s;
|
|
1006
1011
|
}
|
|
1007
1012
|
// src/core/init/from-site/inspect.ts
|
|
1008
|
-
async function
|
|
1009
|
-
let t = await
|
|
1013
|
+
async function ur(e) {
|
|
1014
|
+
let t = await Zt(e), n = Ut(t.css), r = Fn(n), i = Xn(t.css, n, /^(body|html)$/), a = Xn(t.css, n, /^h[1-6]$/), o = [];
|
|
1010
1015
|
i && o.push({
|
|
1011
1016
|
family: i.family,
|
|
1012
1017
|
role: "body",
|
|
1013
|
-
stylesheet: !!
|
|
1018
|
+
stylesheet: !!Kn(i.family)
|
|
1014
1019
|
}), a && a.family.toLowerCase() !== i?.family.toLowerCase() && o.push({
|
|
1015
1020
|
family: a.family,
|
|
1016
1021
|
role: "headings",
|
|
1017
|
-
stylesheet: !!
|
|
1022
|
+
stylesheet: !!Kn(a.family)
|
|
1018
1023
|
});
|
|
1019
|
-
let s =
|
|
1024
|
+
let s = ir(t.html, e), c = ar(t.html, e), l = s ? `${s.kind === "inline" ? "an inline SVG" : `an SVG image (${s.url})`} in the page header` : c ? `the site icon (${c.url})${c.svg ? "" : `, a ${c.ext} image, not an SVG logo`}` : void 0, u = W(t.html, "og:site_name") ?? W(t.html, "application-name") ?? await Vn(t.html, e) ?? Bn(t.html), d = [];
|
|
1020
1025
|
return r.length === 0 && d.push("no brand colors: no custom property named brand, primary, secondary, accent, background, foreground or surface holds a hex or rgb() color"), o.length === 0 && d.push("no font: no body or heading rule names a font-family"), l || d.push("no logo: no SVG in the header and no icon link on the page"), u || d.push("no site name: the brand name stays as you typed it"), {
|
|
1021
1026
|
page: t,
|
|
1022
1027
|
name: u,
|
|
1023
|
-
description:
|
|
1028
|
+
description: W(t.html, "description"),
|
|
1024
1029
|
colors: r.map((e) => ({
|
|
1025
1030
|
cssVar: e.cssVar,
|
|
1026
1031
|
hex: e.hex
|
|
@@ -1031,92 +1036,92 @@ async function pr(e) {
|
|
|
1031
1036
|
};
|
|
1032
1037
|
}
|
|
1033
1038
|
// src/core/init/answers.ts
|
|
1034
|
-
var
|
|
1039
|
+
var dr = [
|
|
1035
1040
|
".svg",
|
|
1036
1041
|
".png",
|
|
1037
1042
|
".jpg",
|
|
1038
1043
|
".jpeg",
|
|
1039
1044
|
".webp"
|
|
1040
|
-
],
|
|
1041
|
-
function
|
|
1042
|
-
let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ?
|
|
1045
|
+
], fr = (e) => e.trim() ? { value: e.trim() } : { hint: "A name cannot be empty." }, pr = (e) => e.trim().length <= 240 ? { value: e.trim() } : { hint: "Keep the description to one sentence, 240 characters at most." };
|
|
1046
|
+
function mr(e) {
|
|
1047
|
+
let t = e.trim(), n = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.test(t) ? Mn(t.startsWith("#") ? t : `#${t}`) : void 0;
|
|
1043
1048
|
return n ? { value: n.hex } : { hint: "Give the color as hex, for example #2563eb or #26e." };
|
|
1044
1049
|
}
|
|
1045
|
-
var
|
|
1046
|
-
function
|
|
1047
|
-
let n =
|
|
1048
|
-
return
|
|
1050
|
+
var hr = (e) => /^[A-Za-z0-9][A-Za-z0-9 -]{0,60}$/.test(e.trim()) ? { value: e.trim() } : { hint: "Give a font family name, for example Inter or DM Sans." };
|
|
1051
|
+
function gr(e, t = process.cwd()) {
|
|
1052
|
+
let n = A.resolve(t, e.trim());
|
|
1053
|
+
return dr.includes(A.extname(n).toLowerCase()) ? !j.existsSync(n) || !j.statSync(n).isFile() ? { hint: `There is no file at ${n}. Check the path, or press Enter to skip the logo.` } : { value: n } : { hint: "The logo must be an SVG or PNG file (JPG and WebP also work)." };
|
|
1049
1054
|
}
|
|
1050
|
-
function
|
|
1051
|
-
let t =
|
|
1055
|
+
function _r(e) {
|
|
1056
|
+
let t = j.readFileSync(e), n = A.extname(e).toLowerCase() === ".svg";
|
|
1052
1057
|
return {
|
|
1053
1058
|
bytes: t.length,
|
|
1054
1059
|
svg: n,
|
|
1055
1060
|
usesCurrentColor: n && /currentColor/i.test(t.toString("utf8"))
|
|
1056
1061
|
};
|
|
1057
1062
|
}
|
|
1058
|
-
var
|
|
1059
|
-
function
|
|
1063
|
+
var vr = (e) => /^https?:\/\/[^\s/]/i.test(e);
|
|
1064
|
+
function yr(e, t, n) {
|
|
1060
1065
|
let r = {
|
|
1061
1066
|
set: [],
|
|
1062
1067
|
hints: [],
|
|
1063
1068
|
files: []
|
|
1064
|
-
}, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a =
|
|
1069
|
+
}, i = (e) => r.hints.push(`${e} already existed, so it was kept as it was`), a = A.join(e, "blazon.json"), o = n.has("blazon.json") ? Dn(a) : void 0, s = o === void 0 ? void 0 : JSON.stringify(o), c = (e) => (o === void 0 && i(`blazon.json (${e} not set)`), o !== void 0);
|
|
1065
1070
|
if (t.name !== void 0 && c("name") && (o.title = t.name, r.set.push(`name "${t.name}"`)), t.description && c("description") && (o.description = t.description, r.set.push("description")), t.color !== void 0) {
|
|
1066
|
-
let a =
|
|
1071
|
+
let a = A.join(e, "tokens", "colors.json");
|
|
1067
1072
|
if (!n.has("tokens/colors.json")) i("tokens/colors.json");
|
|
1068
1073
|
else {
|
|
1069
|
-
let e = JSON.parse(
|
|
1070
|
-
if (
|
|
1071
|
-
let n =
|
|
1072
|
-
|
|
1074
|
+
let e = JSON.parse(j.readFileSync(a, "utf-8"));
|
|
1075
|
+
if (H(e, "color.signal.orange")) {
|
|
1076
|
+
let n = Tn(e, t.color);
|
|
1077
|
+
j.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/colors.json"), r.set.push(`primary color ${t.color} (color.signal.primary, which interactive.primary uses)`), r.hints.push(...n.hints);
|
|
1073
1078
|
} else r.hints.push("color.signal.orange was not found in tokens/colors.json, so the color was not set");
|
|
1074
1079
|
}
|
|
1075
1080
|
}
|
|
1076
1081
|
if (t.font !== void 0) {
|
|
1077
|
-
let a =
|
|
1082
|
+
let a = A.join(e, "tokens", "typography.json");
|
|
1078
1083
|
if (!n.has("tokens/typography.json")) i("tokens/typography.json");
|
|
1079
1084
|
else {
|
|
1080
|
-
let e = JSON.parse(
|
|
1085
|
+
let e = JSON.parse(j.readFileSync(a, "utf-8")), n = H(e, "font.family.display"), i = H(e, "font.family.body");
|
|
1081
1086
|
if (n && i) {
|
|
1082
1087
|
n.$value = [t.font, "sans-serif"], i.$value = [t.font, "sans-serif"];
|
|
1083
|
-
let s =
|
|
1084
|
-
s &&
|
|
1085
|
-
let l =
|
|
1086
|
-
l && c("font stylesheet") ? (o.fonts =
|
|
1088
|
+
let s = H(e, "font.family.mono");
|
|
1089
|
+
s && wn(s, "Still blazon's mono font: it was not chosen to go with your font. Set the brand's own."), j.writeFileSync(a, `${JSON.stringify(e, null, 2)}\n`), r.files.push("tokens/typography.json");
|
|
1090
|
+
let l = Kn(t.font);
|
|
1091
|
+
l && c("font stylesheet") ? (o.fonts = kn(o.fonts, [l]), r.set.push(`font ${t.font} (font.family.display and font.family.body)`)) : l || (r.set.push(`font ${t.font} (font.family.display and font.family.body)`), r.hints.push(`${t.font} is not a font blazon knows a stylesheet for: add its stylesheet to fonts in blazon.json`)), r.hints.push("font.family.mono and the type scale are still blazon's: set the brand's own");
|
|
1087
1092
|
} else r.hints.push("font.family.display and font.family.body were not found in tokens/typography.json, so the font was not set");
|
|
1088
1093
|
}
|
|
1089
1094
|
}
|
|
1090
1095
|
if (t.logo !== void 0 && c("logo")) {
|
|
1091
|
-
let a =
|
|
1096
|
+
let a = A.basename(t.logo).replace(/[^A-Za-z0-9._-]/g, "-"), s = a.replace(/\.[^.]+$/, ""), c = A.join(e, "assets", "logos"), l = [a, `${s}.json`].filter((e) => !n.has(`assets/logos/${e}`) && j.existsSync(A.join(c, e)));
|
|
1092
1097
|
if (l.length) {
|
|
1093
1098
|
for (let e of l) i(`assets/logos/${e}`);
|
|
1094
1099
|
r.hints.push(`the logo ${t.logo} was not copied: pick another file name, or remove the existing file`);
|
|
1095
1100
|
} else {
|
|
1096
|
-
let e =
|
|
1097
|
-
if (n.has(`assets/logos/${
|
|
1098
|
-
let { description: t, background: n, ...r } = JSON.parse(
|
|
1101
|
+
let e = A.join(c, `${An[0]}.json`), i = {};
|
|
1102
|
+
if (n.has(`assets/logos/${An[0]}.json`) && j.existsSync(e)) {
|
|
1103
|
+
let { description: t, background: n, ...r } = JSON.parse(j.readFileSync(e, "utf-8"));
|
|
1099
1104
|
i = r;
|
|
1100
1105
|
}
|
|
1101
|
-
for (let e of
|
|
1102
|
-
|
|
1103
|
-
let l =
|
|
1104
|
-
|
|
1106
|
+
for (let e of jn) for (let t of ["svg", "json"]) n.has(`assets/logos/${e}.${t}`) && j.rmSync(A.join(c, `${e}.${t}`), { force: !0 });
|
|
1107
|
+
j.mkdirSync(c, { recursive: !0 });
|
|
1108
|
+
let l = j.readFileSync(t.logo);
|
|
1109
|
+
j.writeFileSync(A.join(c, a), a.toLowerCase().endsWith(".svg") ? rr(l.toString("utf8")) : l), j.writeFileSync(A.join(c, `${s}.json`), `${JSON.stringify({
|
|
1105
1110
|
title: "Logo",
|
|
1106
1111
|
description: "The brand's logo. Clear space, minimum size, lockup, placement and partnership are blazon's, not the brand's: set them.",
|
|
1107
1112
|
...i
|
|
1108
1113
|
}, null, 2)}\n`), o.logo = `./assets/logos/${a}`, r.files.push(`assets/logos/${a}`, `assets/logos/${s}.json`), r.set.push(`logo ${a}`);
|
|
1109
1114
|
}
|
|
1110
1115
|
}
|
|
1111
|
-
return o !== void 0 && JSON.stringify(o) !== s && (
|
|
1116
|
+
return o !== void 0 && JSON.stringify(o) !== s && (On(a, o), r.files.push("blazon.json")), r;
|
|
1112
1117
|
}
|
|
1113
1118
|
// src/core/init/prompts.ts
|
|
1114
|
-
var
|
|
1119
|
+
var br = class extends Error {
|
|
1115
1120
|
constructor() {
|
|
1116
1121
|
super("cancelled"), this.name = "PromptCancelled";
|
|
1117
1122
|
}
|
|
1118
1123
|
};
|
|
1119
|
-
function
|
|
1124
|
+
function G(e, t) {
|
|
1120
1125
|
return e.split("\n").map((e) => {
|
|
1121
1126
|
if (e.length <= t || e.includes("\x1B")) return e;
|
|
1122
1127
|
let n = [], r = "";
|
|
@@ -1124,66 +1129,66 @@ function U(e, t) {
|
|
|
1124
1129
|
return n.push(r), n.join("\n");
|
|
1125
1130
|
}).join("\n");
|
|
1126
1131
|
}
|
|
1127
|
-
var
|
|
1128
|
-
function
|
|
1129
|
-
if (
|
|
1132
|
+
var xr = () => Math.max(30, (process.stdout.columns ?? 80) - 6);
|
|
1133
|
+
function Sr(e) {
|
|
1134
|
+
if (M.isCancel(e)) throw new br();
|
|
1130
1135
|
return e;
|
|
1131
1136
|
}
|
|
1132
|
-
function
|
|
1137
|
+
function Cr() {
|
|
1133
1138
|
return {
|
|
1134
|
-
intro: (e) =>
|
|
1135
|
-
outro: (e) =>
|
|
1136
|
-
cancel: (e) =>
|
|
1137
|
-
text: async (e) =>
|
|
1139
|
+
intro: (e) => M.intro(e),
|
|
1140
|
+
outro: (e) => M.outro(e),
|
|
1141
|
+
cancel: (e) => M.cancel(e),
|
|
1142
|
+
text: async (e) => Sr(await M.text({
|
|
1138
1143
|
message: e.message,
|
|
1139
1144
|
placeholder: e.placeholder,
|
|
1140
1145
|
defaultValue: e.defaultValue,
|
|
1141
1146
|
validate: e.validate && ((t) => e.validate(t ?? ""))
|
|
1142
1147
|
})) ?? "",
|
|
1143
|
-
select: async (e) =>
|
|
1148
|
+
select: async (e) => Sr(await M.select({
|
|
1144
1149
|
message: e.message,
|
|
1145
1150
|
options: e.options,
|
|
1146
1151
|
initialValue: e.initialValue
|
|
1147
1152
|
})),
|
|
1148
|
-
multiselect: async (e) =>
|
|
1153
|
+
multiselect: async (e) => Sr(await M.multiselect({
|
|
1149
1154
|
message: e.message,
|
|
1150
1155
|
options: e.options,
|
|
1151
1156
|
initialValues: e.initialValues,
|
|
1152
1157
|
required: !1
|
|
1153
1158
|
})),
|
|
1154
|
-
confirm: async (e) =>
|
|
1159
|
+
confirm: async (e) => Sr(await M.confirm({
|
|
1155
1160
|
message: e.message,
|
|
1156
1161
|
initialValue: e.initialValue
|
|
1157
1162
|
})),
|
|
1158
1163
|
spinner: () => {
|
|
1159
|
-
let e =
|
|
1164
|
+
let e = M.spinner();
|
|
1160
1165
|
return {
|
|
1161
1166
|
start: (t) => e.start(t),
|
|
1162
1167
|
stop: (t) => e.stop(t),
|
|
1163
1168
|
error: (t) => e.error(t)
|
|
1164
1169
|
};
|
|
1165
1170
|
},
|
|
1166
|
-
note: (e, t) =>
|
|
1171
|
+
note: (e, t) => M.note(e, t),
|
|
1167
1172
|
log: {
|
|
1168
|
-
message: (e) =>
|
|
1169
|
-
info: (e) =>
|
|
1170
|
-
success: (e) =>
|
|
1171
|
-
warn: (e) =>
|
|
1172
|
-
error: (e) =>
|
|
1173
|
-
step: (e) =>
|
|
1173
|
+
message: (e) => M.log.message(G(e, xr())),
|
|
1174
|
+
info: (e) => M.log.info(G(e, xr())),
|
|
1175
|
+
success: (e) => M.log.success(G(e, xr())),
|
|
1176
|
+
warn: (e) => M.log.warn(G(e, xr())),
|
|
1177
|
+
error: (e) => M.log.error(G(e, xr())),
|
|
1178
|
+
step: (e) => M.log.step(G(e, xr()))
|
|
1174
1179
|
}
|
|
1175
1180
|
};
|
|
1176
1181
|
}
|
|
1177
1182
|
// src/cli/init-ui.ts
|
|
1178
|
-
function
|
|
1179
|
-
let n =
|
|
1183
|
+
function wr(e = process.env, t = !!process.stdout.isTTY) {
|
|
1184
|
+
let n = b(e, t, []);
|
|
1180
1185
|
return {
|
|
1181
1186
|
color: n,
|
|
1182
1187
|
truecolor: n && /^(truecolor|24bit)$/i.test(e.COLORTERM ?? "")
|
|
1183
1188
|
};
|
|
1184
1189
|
}
|
|
1185
|
-
function
|
|
1186
|
-
let [n, r, i] = (
|
|
1190
|
+
function Tr(e, t) {
|
|
1191
|
+
let [n, r, i] = (dn(e) ?? [
|
|
1187
1192
|
0,
|
|
1188
1193
|
0,
|
|
1189
1194
|
0
|
|
@@ -1192,63 +1197,63 @@ function Dr(e, t) {
|
|
|
1192
1197
|
let a = (e) => Math.round(e / 255 * 5);
|
|
1193
1198
|
return `\x1b[48;5;${16 + 36 * a(n) + 6 * a(r) + a(i)}m`;
|
|
1194
1199
|
}
|
|
1195
|
-
function
|
|
1196
|
-
return t.color ? `${
|
|
1200
|
+
function Er(e, t, n = 2) {
|
|
1201
|
+
return t.color ? `${Tr(e, t)}${" ".repeat(n)}\x1b[0m` : `[${e}]`;
|
|
1197
1202
|
}
|
|
1198
|
-
var
|
|
1203
|
+
var Dr = {
|
|
1199
1204
|
AAA: "AAA",
|
|
1200
1205
|
AA: "AA",
|
|
1201
1206
|
"AA-large": "AA for large text only",
|
|
1202
1207
|
fail: "below AA"
|
|
1203
|
-
},
|
|
1204
|
-
function
|
|
1208
|
+
}, Or = (e) => `${e.toFixed(1)}:1`;
|
|
1209
|
+
function kr(e, t, n = gn(e)) {
|
|
1205
1210
|
let r = (e) => e === "AAA" || e === "AA" ? "yes" : "no";
|
|
1206
1211
|
return [
|
|
1207
|
-
`${
|
|
1208
|
-
`AA for text on white: ${r(n.onWhite.level)} (${
|
|
1209
|
-
`AA for text on near-black: ${r(n.onNearBlack.level)} (${
|
|
1212
|
+
`${Er(e, t, 4)} ${e}`,
|
|
1213
|
+
`AA for text on white: ${r(n.onWhite.level)} (${Or(n.onWhite.ratio)}, ${Dr[n.onWhite.level]})`,
|
|
1214
|
+
`AA for text on near-black: ${r(n.onNearBlack.level)} (${Or(n.onNearBlack.ratio)}, ${Dr[n.onNearBlack.level]})`
|
|
1210
1215
|
];
|
|
1211
1216
|
}
|
|
1212
|
-
function
|
|
1213
|
-
let { ink: t, ratio: n, aa: r } =
|
|
1217
|
+
function Ar(e) {
|
|
1218
|
+
let { ink: t, ratio: n, aa: r } = yn(e);
|
|
1214
1219
|
return r ? `Labels on ${e} will be ${t} (${n.toFixed(1)}:1).` : `Neither graphite nor bone reaches AA (4.5:1) as a label on ${e} (best is ${t} at ${n.toFixed(1)}:1). blazon check will report it; a lighter or darker color fixes that.`;
|
|
1215
1220
|
}
|
|
1216
|
-
var
|
|
1217
|
-
function
|
|
1221
|
+
var jr = (e, t, n) => `${e} of ${t} ${n}`;
|
|
1222
|
+
function Mr(e) {
|
|
1218
1223
|
return e < 1024 ? `${e} bytes` : `${(e / 1024).toFixed(1)} KB`;
|
|
1219
1224
|
}
|
|
1220
1225
|
// src/cli/init-flow.ts
|
|
1221
|
-
var
|
|
1222
|
-
function
|
|
1226
|
+
var Nr = 4;
|
|
1227
|
+
function K(e, t, r, i) {
|
|
1223
1228
|
return e.log.message(i.color ? n.dim(r) : r), t;
|
|
1224
1229
|
}
|
|
1225
|
-
function
|
|
1230
|
+
function Pr(e) {
|
|
1226
1231
|
return (t) => {
|
|
1227
1232
|
if (t.trim() === "") return;
|
|
1228
1233
|
let n = e(t);
|
|
1229
1234
|
return "hint" in n ? n.hint : void 0;
|
|
1230
1235
|
};
|
|
1231
1236
|
}
|
|
1232
|
-
var
|
|
1237
|
+
var Fr = (e, t) => {
|
|
1233
1238
|
let n = t.trim() === "" ? void 0 : e(t);
|
|
1234
1239
|
return n && "value" in n ? n.value : void 0;
|
|
1235
1240
|
};
|
|
1236
|
-
async function
|
|
1241
|
+
async function Ir(e) {
|
|
1237
1242
|
let { prompter: t, look: r } = e, i = {};
|
|
1238
|
-
t.intro(r.color ? n.bold(`blazon init ${n.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(
|
|
1243
|
+
t.intro(r.color ? n.bold(`blazon init ${n.dim(e.dir)}`) : `blazon init ${e.dir}`), e.kept && t.log.warn(`${e.kept} starter ${e.kept === 1 ? "file is" : "files are"} already in this folder and ${e.kept === 1 ? "is" : "are"} kept as ${e.kept === 1 ? "it is" : "they are"}. Only missing files are added.`), t.log.step(jr(1, Nr, "Brand"));
|
|
1239
1244
|
let a = (await t.text({
|
|
1240
|
-
message:
|
|
1245
|
+
message: K(t, "Brand name", "The title of the brand book. Enter keeps the name taken from the folder.", r),
|
|
1241
1246
|
placeholder: "from the folder name",
|
|
1242
1247
|
validate: () => void 0
|
|
1243
1248
|
})).trim();
|
|
1244
1249
|
a && (i.name = a);
|
|
1245
1250
|
let o = (await t.text({
|
|
1246
|
-
message:
|
|
1251
|
+
message: K(t, "One-line description", "What the brand is, in a sentence. It goes in the config and opens the intro page. Enter skips it.", r),
|
|
1247
1252
|
placeholder: "what the brand is, in one sentence",
|
|
1248
|
-
validate: (e) => "hint" in
|
|
1253
|
+
validate: (e) => "hint" in pr(e) ? "Keep it to one sentence, 240 characters at most." : void 0
|
|
1249
1254
|
})).trim();
|
|
1250
1255
|
if (o && (i.description = o), await t.select({
|
|
1251
|
-
message:
|
|
1256
|
+
message: K(t, "Where should the colors, fonts and logo come from?", "Reading a live site fills them in for you to review before anything is written.", r),
|
|
1252
1257
|
options: [{
|
|
1253
1258
|
value: "manual",
|
|
1254
1259
|
label: "I will give them here",
|
|
@@ -1259,36 +1264,36 @@ async function Rr(e) {
|
|
|
1259
1264
|
hint: "you review what was found first"
|
|
1260
1265
|
}]
|
|
1261
1266
|
}) === "site") {
|
|
1262
|
-
let n = await
|
|
1267
|
+
let n = await Lr(e);
|
|
1263
1268
|
if (n) return {
|
|
1264
1269
|
answers: i,
|
|
1265
1270
|
site: n
|
|
1266
1271
|
};
|
|
1267
1272
|
t.log.info("Nothing from a site will be written. Giving the values here instead.");
|
|
1268
1273
|
}
|
|
1269
|
-
t.log.step(
|
|
1270
|
-
let s =
|
|
1271
|
-
message:
|
|
1274
|
+
t.log.step(jr(2, Nr, "Colors"));
|
|
1275
|
+
let s = Fr(mr, (await t.text({
|
|
1276
|
+
message: K(t, "Primary color", "Hex, for example #2563eb. Buttons and links use it. Enter keeps the orange it starts with.", r),
|
|
1272
1277
|
placeholder: "#2563eb",
|
|
1273
|
-
validate:
|
|
1278
|
+
validate: Pr(mr)
|
|
1274
1279
|
})).trim());
|
|
1275
|
-
s && (i.color = s, t.log.info(
|
|
1276
|
-
let c =
|
|
1277
|
-
message:
|
|
1280
|
+
s && (i.color = s, t.log.info(kr(s, r).join("\n")), t.log.info(Ar(s))), t.log.step(jr(3, Nr, "Type"));
|
|
1281
|
+
let c = Fr(hr, (await t.text({
|
|
1282
|
+
message: K(t, "Font family", "A Google Fonts name, for example Inter. Enter keeps the fonts it starts with.", r),
|
|
1278
1283
|
placeholder: "Inter",
|
|
1279
|
-
validate:
|
|
1284
|
+
validate: Pr(hr)
|
|
1280
1285
|
})).trim());
|
|
1281
|
-
c && (i.font = c,
|
|
1282
|
-
let l =
|
|
1283
|
-
message:
|
|
1286
|
+
c && (i.font = c, Kn(c) ? t.log.success(`${c} is on Google Fonts. Its stylesheet will be added to fonts in blazon.json.`) : t.log.warn(`${c} is not in blazon's short list of Google Fonts, so only the font name is written. Add its stylesheet to fonts in blazon.json.`)), t.log.step(jr(4, Nr, "Logo"));
|
|
1287
|
+
let l = Fr((e) => gr(e), (await t.text({
|
|
1288
|
+
message: K(t, "Logo file", "The path to an SVG or PNG. Enter skips it and keeps the logo it starts with.", r),
|
|
1284
1289
|
placeholder: "./logo.svg",
|
|
1285
|
-
validate:
|
|
1290
|
+
validate: Pr((e) => gr(e))
|
|
1286
1291
|
})).trim());
|
|
1287
1292
|
if (l) {
|
|
1288
1293
|
i.logo = l;
|
|
1289
|
-
let e =
|
|
1294
|
+
let e = _r(l), n = A.basename(l);
|
|
1290
1295
|
t.log.info([
|
|
1291
|
-
`${n}: ${e.svg ? "SVG" : "raster image"}, ${
|
|
1296
|
+
`${n}: ${e.svg ? "SVG" : "raster image"}, ${Mr(e.bytes)}.`,
|
|
1292
1297
|
"It will be copied to assets/logos/ and replace the starter's placeholder.",
|
|
1293
1298
|
...e.usesCurrentColor ? ["It draws in currentColor, so it takes the text color of the page it is on."] : [],
|
|
1294
1299
|
...e.svg ? [] : ["A raster logo cannot be recolored; an SVG is better if you have one."]
|
|
@@ -1296,13 +1301,13 @@ async function Rr(e) {
|
|
|
1296
1301
|
}
|
|
1297
1302
|
return { answers: i };
|
|
1298
1303
|
}
|
|
1299
|
-
async function
|
|
1300
|
-
let { prompter: t, look: n } = e, r = e.inspect ??
|
|
1304
|
+
async function Lr(e) {
|
|
1305
|
+
let { prompter: t, look: n } = e, r = e.inspect ?? ur;
|
|
1301
1306
|
for (;;) {
|
|
1302
1307
|
let i = (await t.text({
|
|
1303
|
-
message:
|
|
1308
|
+
message: K(t, "Website address", "Blazon reads its stylesheets and page. It sends no cookies and runs none of the site's scripts.", n),
|
|
1304
1309
|
placeholder: "https://example.com (leave empty to enter the values by hand)",
|
|
1305
|
-
validate: (e) => e.trim() === "" ||
|
|
1310
|
+
validate: (e) => e.trim() === "" || vr(e.trim()) ? void 0 : "Give the full address, starting with http:// or https://, or leave it empty to enter the values by hand."
|
|
1306
1311
|
})).trim();
|
|
1307
1312
|
if (i === "") {
|
|
1308
1313
|
t.log.info("No address given: you can enter the values by hand.");
|
|
@@ -1317,7 +1322,7 @@ async function zr(e) {
|
|
|
1317
1322
|
a.error(`Could not read ${i}`), t.log.error(`${e instanceof Error ? e.message : String(e)}\nCheck the address and your connection. The starter is in place, so nothing is lost.`);
|
|
1318
1323
|
}
|
|
1319
1324
|
if (o) {
|
|
1320
|
-
let t = await
|
|
1325
|
+
let t = await Rr(e, i, o);
|
|
1321
1326
|
return t ? {
|
|
1322
1327
|
url: i,
|
|
1323
1328
|
findings: o,
|
|
@@ -1330,7 +1335,7 @@ async function zr(e) {
|
|
|
1330
1335
|
})) return;
|
|
1331
1336
|
}
|
|
1332
1337
|
}
|
|
1333
|
-
async function
|
|
1338
|
+
async function Rr(e, t, n) {
|
|
1334
1339
|
let { prompter: r, look: i } = e, a = [];
|
|
1335
1340
|
n.name && a.push(`Name: ${n.name}`), n.description && a.push(`Description: ${n.description}`);
|
|
1336
1341
|
for (let e of n.fonts) a.push(`Font (${e.role}): ${e.family}${e.stylesheet ? ", its Google Fonts stylesheet will be added" : ", not in blazon's short list, so add its stylesheet yourself"}`);
|
|
@@ -1339,10 +1344,10 @@ async function Br(e, t, n) {
|
|
|
1339
1344
|
let o = /* @__PURE__ */ new Set();
|
|
1340
1345
|
if (n.colors.length > 0) {
|
|
1341
1346
|
let e = await r.multiselect({
|
|
1342
|
-
message:
|
|
1347
|
+
message: K(r, "Brand colors found", "Untick any you do not want. Everything written is marked needs-review.", i),
|
|
1343
1348
|
options: n.colors.map((e) => ({
|
|
1344
1349
|
value: e.cssVar,
|
|
1345
|
-
label: `${
|
|
1350
|
+
label: `${Er(e.hex, i)} ${e.hex} ${e.cssVar}`
|
|
1346
1351
|
})),
|
|
1347
1352
|
initialValues: n.colors.map((e) => e.cssVar)
|
|
1348
1353
|
});
|
|
@@ -1354,50 +1359,50 @@ async function Br(e, t, n) {
|
|
|
1354
1359
|
}) ? o : void 0;
|
|
1355
1360
|
}
|
|
1356
1361
|
// src/cli/commands/init.ts
|
|
1357
|
-
var
|
|
1358
|
-
function
|
|
1362
|
+
var zr = (e, t, n) => `${e} ${e === 1 ? t : n}`;
|
|
1363
|
+
function Br(e, t) {
|
|
1359
1364
|
let n = t.map((e) => e.split("/").slice(1));
|
|
1360
1365
|
if (n.length === 0) return;
|
|
1361
|
-
if (e === "docs") return `${
|
|
1362
|
-
if (e === "tokens") return `${
|
|
1366
|
+
if (e === "docs") return `${zr(n.length, "page", "pages")}, ${n[0][0]} to ${n[n.length - 1][0]}`;
|
|
1367
|
+
if (e === "tokens") return `${zr(n.length, "file", "files")}: ${n.map((e) => e.join("/")).join(", ")}`;
|
|
1363
1368
|
let r = [...new Set(n.filter((e) => e.length > 1).map((e) => e[0]))];
|
|
1364
|
-
return r.length > 0 ? `${
|
|
1369
|
+
return r.length > 0 ? `${zr(n.length, "file", "files")} in ${zr(r.length, "folder", "folders")}: ${r.join(", ")}` : `${zr(n.length, "file", "files")}: ${n.map((e) => e[0]).join(", ")}`;
|
|
1365
1370
|
}
|
|
1366
|
-
var
|
|
1367
|
-
function
|
|
1368
|
-
let t =
|
|
1369
|
-
for (; t.length > 0 &&
|
|
1371
|
+
var Vr = /^(brand|book|guidelines|guide)$/i;
|
|
1372
|
+
function Hr(e) {
|
|
1373
|
+
let t = A.basename(e).split(/[-_\s]+/).filter(Boolean), n = t.length > 0;
|
|
1374
|
+
for (; t.length > 0 && Vr.test(t[t.length - 1]);) t = t.slice(0, -1);
|
|
1370
1375
|
let r = t.map((e) => e.charAt(0).toUpperCase() + e.slice(1)).join(" ");
|
|
1371
1376
|
return r ? `${r} Brand Book` : n ? "Brand Book" : "Blazon Brand Book";
|
|
1372
1377
|
}
|
|
1373
|
-
var
|
|
1378
|
+
var Ur = [
|
|
1374
1379
|
[
|
|
1375
1380
|
"--name",
|
|
1376
1381
|
"name",
|
|
1377
|
-
|
|
1382
|
+
fr
|
|
1378
1383
|
],
|
|
1379
1384
|
[
|
|
1380
1385
|
"--description",
|
|
1381
1386
|
"description",
|
|
1382
|
-
|
|
1387
|
+
pr
|
|
1383
1388
|
],
|
|
1384
1389
|
[
|
|
1385
1390
|
"--color",
|
|
1386
1391
|
"color",
|
|
1387
|
-
|
|
1392
|
+
mr
|
|
1388
1393
|
],
|
|
1389
1394
|
[
|
|
1390
1395
|
"--font",
|
|
1391
1396
|
"font",
|
|
1392
|
-
|
|
1397
|
+
hr
|
|
1393
1398
|
],
|
|
1394
1399
|
[
|
|
1395
1400
|
"--logo",
|
|
1396
1401
|
"logo",
|
|
1397
|
-
(e) =>
|
|
1402
|
+
(e) => gr(e)
|
|
1398
1403
|
]
|
|
1399
1404
|
];
|
|
1400
|
-
async function
|
|
1405
|
+
async function Wr(e = ".", t = {}) {
|
|
1401
1406
|
if (t.from !== void 0 && !/^https?:\/\/[^\s/]/i.test(t.from)) {
|
|
1402
1407
|
let e = `--from needs an http(s) address, got ${JSON.stringify(t.from)}`;
|
|
1403
1408
|
return console.error(n.red(`blazon init: ${e}`)), t.failure?.({
|
|
@@ -1406,7 +1411,7 @@ async function Kr(e = ".", t = {}) {
|
|
|
1406
1411
|
}), 2;
|
|
1407
1412
|
}
|
|
1408
1413
|
let r = {};
|
|
1409
|
-
for (let [e, i, a] of
|
|
1414
|
+
for (let [e, i, a] of Ur) {
|
|
1410
1415
|
let o = t[i];
|
|
1411
1416
|
if (o === void 0) continue;
|
|
1412
1417
|
let s = a(String(o));
|
|
@@ -1416,8 +1421,8 @@ async function Kr(e = ".", t = {}) {
|
|
|
1416
1421
|
}), 2;
|
|
1417
1422
|
r[i] = s.value;
|
|
1418
1423
|
}
|
|
1419
|
-
let i =
|
|
1420
|
-
if (!
|
|
1424
|
+
let i = A.resolve(process.cwd(), e), a = Ge();
|
|
1425
|
+
if (!j.existsSync(a)) throw Error(`Template directory not found at ${a}`);
|
|
1421
1426
|
let o = t.tty ?? !!(process.stdin.isTTY && process.stdout.isTTY), s = [
|
|
1422
1427
|
t.from,
|
|
1423
1428
|
t.name,
|
|
@@ -1425,16 +1430,16 @@ async function Kr(e = ".", t = {}) {
|
|
|
1425
1430
|
t.color,
|
|
1426
1431
|
t.font,
|
|
1427
1432
|
t.logo
|
|
1428
|
-
].some((e) => e !== void 0), c = o && !s && !t.yes && t.input !== !1, l = c ? t.prompter ??
|
|
1433
|
+
].some((e) => e !== void 0), c = o && !s && !t.yes && t.input !== !1, l = c ? t.prompter ?? Cr() : void 0, u = t.look ?? wr(process.env, o);
|
|
1429
1434
|
c || console.log(n.cyan(`\n✨ Initializing Blazon Brand Book in ${n.bold(i)}...\n`));
|
|
1430
|
-
let d =
|
|
1435
|
+
let d = A.join(i, "blazon.json"), f = j.existsSync(d), p = le(i, a), m = p.kept, h = p.written.map((e) => A.relative(i, e).split(A.sep).join("/")).sort(), g = new Set(h);
|
|
1431
1436
|
t.report?.({
|
|
1432
1437
|
dir: i,
|
|
1433
1438
|
created: h,
|
|
1434
|
-
kept: m.map((e) =>
|
|
1435
|
-
}), !f &&
|
|
1436
|
-
...
|
|
1437
|
-
title:
|
|
1439
|
+
kept: m.map((e) => A.relative(i, e).split(A.sep).join("/")).sort()
|
|
1440
|
+
}), !f && j.existsSync(d) && On(d, {
|
|
1441
|
+
...Dn(d),
|
|
1442
|
+
title: Hr(i),
|
|
1438
1443
|
description: "Brand guidelines, built from design tokens"
|
|
1439
1444
|
});
|
|
1440
1445
|
let _ = [];
|
|
@@ -1443,29 +1448,29 @@ async function Kr(e = ".", t = {}) {
|
|
|
1443
1448
|
"assets",
|
|
1444
1449
|
"docs"
|
|
1445
1450
|
]) {
|
|
1446
|
-
let t =
|
|
1451
|
+
let t = Br(e, h.filter((t) => t.startsWith(`${e}/`)));
|
|
1447
1452
|
t && _.push(`${e}/ (${t})`);
|
|
1448
1453
|
}
|
|
1449
1454
|
h.includes("blazon.json") && _.push("blazon.json"), h.includes("blazon.resolver.json") && _.push("blazon.resolver.json");
|
|
1450
1455
|
let v = { answers: r };
|
|
1451
1456
|
if (l) try {
|
|
1452
|
-
v = await
|
|
1457
|
+
v = await Ir({
|
|
1453
1458
|
prompter: l,
|
|
1454
1459
|
look: u,
|
|
1455
1460
|
dir: i,
|
|
1456
1461
|
kept: m.length
|
|
1457
1462
|
});
|
|
1458
1463
|
} catch (e) {
|
|
1459
|
-
if (e instanceof
|
|
1464
|
+
if (e instanceof br) return l.cancel("Stopped. The starter was copied as it is, and nothing else was changed."), 130;
|
|
1460
1465
|
throw e;
|
|
1461
1466
|
}
|
|
1462
1467
|
else {
|
|
1463
1468
|
for (let e of _) console.log(` ${n.green("✔")} Created ${e}`);
|
|
1464
1469
|
m.length > 0 && console.log(` ${n.yellow("!")} ${m.length} starter files were already here and are kept as they are`), console.log();
|
|
1465
1470
|
}
|
|
1466
|
-
let y = v.site?.url ?? t.from, b = 0, x,
|
|
1467
|
-
if (
|
|
1468
|
-
if (x = await
|
|
1471
|
+
let y = v.site?.url ?? t.from, b = 0, x, S = l?.spinner();
|
|
1472
|
+
if (S?.start("Writing the brand book"), y !== void 0) try {
|
|
1473
|
+
if (x = await lr(i, y, g, /* @__PURE__ */ new Date(), {
|
|
1469
1474
|
page: v.site?.findings.page,
|
|
1470
1475
|
skipVars: v.site?.skipVars
|
|
1471
1476
|
}), !l) {
|
|
@@ -1483,26 +1488,26 @@ async function Kr(e = ".", t = {}) {
|
|
|
1483
1488
|
message: r
|
|
1484
1489
|
}), l ? l.log.error(`Could not read ${y}: ${r}\nThe starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.`) : (console.error(n.red(`blazon init: ${r}`)), console.error(n.dim(" The starter was copied as it is. To start from the site, run blazon init again with --from in a new folder (a folder that already has the starter is kept as it is), or carry on with the starter.\n"))), b = 2;
|
|
1485
1490
|
}
|
|
1486
|
-
let
|
|
1491
|
+
let C;
|
|
1487
1492
|
try {
|
|
1488
|
-
|
|
1493
|
+
C = yr(i, v.answers, g);
|
|
1489
1494
|
} catch (e) {
|
|
1490
|
-
throw
|
|
1491
|
-
}
|
|
1492
|
-
|
|
1493
|
-
let
|
|
1494
|
-
`Run ${
|
|
1495
|
-
`Replace blazon's artwork in ${
|
|
1496
|
-
`Run ${
|
|
1497
|
-
`Point a coding agent at ${
|
|
1495
|
+
throw S?.error("Could not write the brand book"), e;
|
|
1496
|
+
}
|
|
1497
|
+
S?.stop("Wrote the brand book");
|
|
1498
|
+
let w = (e) => u.color ? n.cyan(e) : e, T = L(i), ee = [
|
|
1499
|
+
`Run ${w(z("dev", T))} to see the book`,
|
|
1500
|
+
`Replace blazon's artwork in ${w(R(T, "assets/"))} and the text in ${w(R(T, "docs/"))}`,
|
|
1501
|
+
`Run ${w(z("check", T))} to see what is left`,
|
|
1502
|
+
`Point a coding agent at ${w(R(T, "AGENTS.md"))}: it is the guide for editing this brand`
|
|
1498
1503
|
];
|
|
1499
|
-
x && !x.written.some((e) => e.startsWith("assets/logos/")) &&
|
|
1500
|
-
let
|
|
1504
|
+
x && !x.written.some((e) => e.startsWith("assets/logos/")) && ee.splice(1, 0, `Add your logo: the book still shows blazon's own. Put it in ${w(R(T, "assets/logos/"))} and point ${w("logo")} in ${w(R(T, "blazon.json"))} at it`);
|
|
1505
|
+
let te = w(R(T, "tokens/colors.json")), ne = C.set.some((e) => e.startsWith("primary color")) ? `Finish the palette in ${te}: the primary color is set, the rest is still blazon's` : x?.written.includes("tokens/colors.json") ? `Confirm the colors read from the site in ${te} with the brand owner` : `Edit ${te} with your colors`;
|
|
1501
1506
|
if (l) {
|
|
1502
1507
|
let e = [..._.map((e) => `Created ${e}`)];
|
|
1503
1508
|
x && e.push(`Read from ${y}: ${x.written.length} files written, ${x.removed.length} starter files removed`, ...x.missing.map((e) => `Not found: ${e}`));
|
|
1504
|
-
for (let t of
|
|
1505
|
-
e.push(...
|
|
1509
|
+
for (let t of C.set) e.push(`Set ${t}`);
|
|
1510
|
+
e.push(...C.hints.map((e) => `Note: ${e}`)), l.note(e.join("\n"), "What was written"), b === 0 && l.note(ee.map((e, t) => `${t + 1}. ${e}`).join("\n"), "Next steps");
|
|
1506
1511
|
let n;
|
|
1507
1512
|
try {
|
|
1508
1513
|
n = t.dev ?? await l.confirm({
|
|
@@ -1510,20 +1515,20 @@ async function Kr(e = ".", t = {}) {
|
|
|
1510
1515
|
initialValue: !1
|
|
1511
1516
|
});
|
|
1512
1517
|
} catch (e) {
|
|
1513
|
-
if (!(e instanceof
|
|
1518
|
+
if (!(e instanceof br)) throw e;
|
|
1514
1519
|
return l.cancel("Stopped. Everything above was written."), b === 0 ? 130 : b;
|
|
1515
1520
|
}
|
|
1516
|
-
return l.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${
|
|
1521
|
+
return l.outro(n ? "Starting blazon dev. Press Ctrl-C to stop it." : `Done. Run ${w(z("dev", T))} when you are ready.`), n && await (t.startDev ?? Gr)(i), b;
|
|
1517
1522
|
}
|
|
1518
|
-
for (let e of
|
|
1519
|
-
return
|
|
1523
|
+
for (let e of C.hints) console.log(` ${n.yellow("!")} ${e}`);
|
|
1524
|
+
return C.set.length > 0 && console.log(` ${n.green("✔")} Set ${C.set.join(", ")}\n`), b === 0 && (console.log(n.bold("Next steps:")), console.log(` 1. ${ne}`), ee.forEach((e, t) => console.log(` ${t + 2}. ${e}`))), console.log(), t.dev && await (t.startDev ?? Gr)(i), b;
|
|
1520
1525
|
}
|
|
1521
|
-
async function
|
|
1522
|
-
let { runDev: t } = await Promise.resolve().then(() =>
|
|
1526
|
+
async function Gr(e) {
|
|
1527
|
+
let { runDev: t } = await Promise.resolve().then(() => pt);
|
|
1523
1528
|
await t(e);
|
|
1524
1529
|
}
|
|
1525
1530
|
// src/server/preview-guard.ts
|
|
1526
|
-
function
|
|
1531
|
+
function Kr(e) {
|
|
1527
1532
|
return (t, n, r) => {
|
|
1528
1533
|
let i;
|
|
1529
1534
|
try {
|
|
@@ -1532,26 +1537,26 @@ function Jr(e) {
|
|
|
1532
1537
|
return r();
|
|
1533
1538
|
}
|
|
1534
1539
|
if (i.includes("\0")) return r();
|
|
1535
|
-
let a =
|
|
1536
|
-
if (
|
|
1540
|
+
let a = A.join(e, A.normalize(`/${i}`));
|
|
1541
|
+
if (te(ne(e), ne(a))) return r();
|
|
1537
1542
|
n.statusCode = 403, n.setHeader("Content-Type", "text/plain"), n.end("blazon preview serves only files inside the built site: this path is a link that leaves it");
|
|
1538
1543
|
};
|
|
1539
1544
|
}
|
|
1540
|
-
var
|
|
1545
|
+
var qr = (e) => ({
|
|
1541
1546
|
name: "blazon-site-link-guard",
|
|
1542
1547
|
configurePreviewServer(t) {
|
|
1543
|
-
t.middlewares.use(
|
|
1548
|
+
t.middlewares.use(Kr(e));
|
|
1544
1549
|
}
|
|
1545
1550
|
});
|
|
1546
1551
|
// src/cli/commands/preview.ts
|
|
1547
|
-
async function
|
|
1548
|
-
|
|
1549
|
-
let i = await
|
|
1550
|
-
if (!
|
|
1552
|
+
async function Jr(e = process.cwd(), t, r = {}) {
|
|
1553
|
+
dt(e);
|
|
1554
|
+
let i = await f(e, t ? { port: t } : void 0), a = A.resolve(e, i.outDir);
|
|
1555
|
+
if (!j.existsSync(A.join(a, "index.html"))) throw new P(`no built site at "${a}"`, `Run ${z("build", L(e))} first.`, "no-built-site");
|
|
1551
1556
|
let o;
|
|
1552
1557
|
try {
|
|
1553
|
-
o = await
|
|
1554
|
-
plugins: [
|
|
1558
|
+
o = await Ye({
|
|
1559
|
+
plugins: [oe(), qr(a)],
|
|
1555
1560
|
build: { outDir: a },
|
|
1556
1561
|
preview: {
|
|
1557
1562
|
port: i.port,
|
|
@@ -1561,7 +1566,7 @@ async function Xr(e = process.cwd(), t, r = {}) {
|
|
|
1561
1566
|
}
|
|
1562
1567
|
});
|
|
1563
1568
|
} catch (e) {
|
|
1564
|
-
throw r.strictPort && e instanceof Error && /already in use/.test(e.message) ?
|
|
1569
|
+
throw r.strictPort && e instanceof Error && /already in use/.test(e.message) ? Ze(i.port) : e;
|
|
1565
1570
|
}
|
|
1566
1571
|
let s = o.resolvedUrls, c = s?.local[0] || `http://localhost:${i.port}/`;
|
|
1567
1572
|
console.log(`\n ${n.bold(n.blue("blazon preview"))}`), console.log(` ${n.dim("➜")} ${n.bold("Local:")} ${n.cyan(c)}`);
|
|
@@ -1569,57 +1574,57 @@ async function Xr(e = process.cwd(), t, r = {}) {
|
|
|
1569
1574
|
return console.log(` ${n.dim("➜")} ${n.bold("Dist:")} ${n.dim(a)}\n`), o;
|
|
1570
1575
|
}
|
|
1571
1576
|
// src/plugins/roles/check-cases.ts
|
|
1572
|
-
var
|
|
1573
|
-
function
|
|
1574
|
-
let t =
|
|
1575
|
-
return
|
|
1577
|
+
var Yr = "docs/manual/12-plugins.md (\"What a plugin can look at, and where it writes\")";
|
|
1578
|
+
function Xr(e) {
|
|
1579
|
+
let t = A.basename(e), n = fe(t) ?? t.replace(/^blazon-/, "");
|
|
1580
|
+
return Be(n) ? n : void 0;
|
|
1576
1581
|
}
|
|
1577
|
-
function
|
|
1578
|
-
return
|
|
1582
|
+
function Zr(e, t) {
|
|
1583
|
+
return j.readdirSync(e, { recursive: !0 }).filter((n) => A.join(e, n) !== t && !A.join(e, n).startsWith(t + A.sep)).sort();
|
|
1579
1584
|
}
|
|
1580
|
-
function
|
|
1581
|
-
let t =
|
|
1585
|
+
function Qr(e) {
|
|
1586
|
+
let t = Xr(e);
|
|
1582
1587
|
return async (e, n) => {
|
|
1583
1588
|
let i = r(e), o = i.answers.join(" or "), s = i.stdoutLimit ?? 65536, c = [], l = {
|
|
1584
1589
|
exit: `a valid request is answered with exit ${o}`,
|
|
1585
1590
|
limit: `the answer is at most ${s} bytes`,
|
|
1586
1591
|
shape: `the answer is one the ${e} role accepts: a findings list of at most 500, each with the plugin's code, a severity, a path and a message`,
|
|
1587
1592
|
folder: "the plugin writes into out_dir and nothing beside it"
|
|
1588
|
-
}, u = JSON.parse(a()[e]), d =
|
|
1593
|
+
}, u = JSON.parse(a()[e]), d = j.mkdtempSync(A.join(Je.tmpdir(), "blazon-plugin-check-")), f = A.join(d, "tokens"), p = A.join(f, t ?? "plugin");
|
|
1589
1594
|
try {
|
|
1590
|
-
e === "build" && (
|
|
1591
|
-
site_dir:
|
|
1595
|
+
e === "build" && (j.mkdirSync(A.join(d, "site")), j.mkdirSync(p, { recursive: !0 }), Object.assign(u, {
|
|
1596
|
+
site_dir: A.join(d, "site"),
|
|
1592
1597
|
tokens_dir: f,
|
|
1593
1598
|
out_dir: p
|
|
1594
1599
|
}));
|
|
1595
1600
|
let r = await n(Buffer.from(JSON.stringify(u)), s), a = !r.answered && r.breakReason.startsWith("output over the limit");
|
|
1596
|
-
a ? c.push(
|
|
1601
|
+
a ? c.push(O(6, l.exit, e, {
|
|
1597
1602
|
skipped: !0,
|
|
1598
1603
|
detail: "the output went over the limit before the plugin exited (case 7)"
|
|
1599
|
-
})) : r.answered && i.answers.includes(r.code) ? c.push(
|
|
1604
|
+
})) : r.answered && i.answers.includes(r.code) ? c.push(O(6, l.exit, e, { passed: !0 })) : r.answered && r.code === 1 ? c.push(O(6, l.exit, e, { detail: `got exit 1, and exit 1 is a break in blazon: the ${e} role defines only ${o}, so blazon reports the plugin as failed and counts it toward its breaker. Exit 2 with the reason on the first line when the plugin cannot answer` })) : c.push(O(6, l.exit, e, { detail: r.answered ? `got exit ${r.code}` : `a break: ${r.breakReason}` }));
|
|
1600
1605
|
let m = i.stdoutLimit === void 0 ? "the core's limit, which the role does not raise" : `the ${e} role's limit (stdout_limit_bytes)`;
|
|
1601
|
-
if (c.push(a ?
|
|
1606
|
+
if (c.push(a ? O(7, l.limit, e, { detail: `the plugin printed more than ${s} bytes, ${m}` }) : O(7, l.limit, e, { passed: !0 })), !r.answered || r.code !== 0) c.push(O(8, l.shape, e, {
|
|
1602
1607
|
skipped: !0,
|
|
1603
1608
|
detail: "the plugin did not answer with exit 0"
|
|
1604
1609
|
}));
|
|
1605
|
-
else if (t === void 0) c.push(
|
|
1610
|
+
else if (t === void 0) c.push(O(8, l.shape, e, {
|
|
1606
1611
|
skipped: !0,
|
|
1607
1612
|
detail: "the program's file name is not blazon-<plugin name>, so the check does not know the plugin's code prefix"
|
|
1608
1613
|
}));
|
|
1609
1614
|
else {
|
|
1610
|
-
let n =
|
|
1611
|
-
c.push("problem" in n ?
|
|
1615
|
+
let n = ie(e, t, r.stdout, []);
|
|
1616
|
+
c.push("problem" in n ? O(8, l.shape, e, { detail: n.problem }) : O(8, l.shape, e, { passed: !0 }));
|
|
1612
1617
|
}
|
|
1613
1618
|
if (e === "build") {
|
|
1614
|
-
let t =
|
|
1615
|
-
c.push(t.length === 0 ?
|
|
1619
|
+
let t = Zr(f, p);
|
|
1620
|
+
c.push(t.length === 0 ? O(9, l.folder, e, { passed: !0 }) : O(9, l.folder, e, {
|
|
1616
1621
|
passed: !0,
|
|
1617
1622
|
warning: !0,
|
|
1618
|
-
detail: `it wrote ${t.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${
|
|
1623
|
+
detail: `it wrote ${t.map((e) => `tokens_dir/${e}`).join(", ")}. Blazon empties only out_dir before a build, so a file beside it is never cleaned and can collide with another plugin's. Blazon has no folder for a plugin's own state yet, so this is a warning; see ${Yr}`
|
|
1619
1624
|
}));
|
|
1620
1625
|
}
|
|
1621
1626
|
} finally {
|
|
1622
|
-
|
|
1627
|
+
j.rmSync(d, {
|
|
1623
1628
|
recursive: !0,
|
|
1624
1629
|
force: !0
|
|
1625
1630
|
});
|
|
@@ -1628,28 +1633,28 @@ function ei(e) {
|
|
|
1628
1633
|
};
|
|
1629
1634
|
}
|
|
1630
1635
|
// src/cli/commands/plugin.ts
|
|
1631
|
-
var
|
|
1636
|
+
var $r = {
|
|
1632
1637
|
plugin: "usage: blazon plugin check <program> [--core] | blazon plugin pin <path> [--name <plugin name>] | blazon plugin profile",
|
|
1633
1638
|
check: "usage: blazon plugin check <program> [--core]",
|
|
1634
1639
|
pin: "usage: blazon plugin pin <path> [--name <plugin name> [--digest <digest>] [--entry <path>]]"
|
|
1635
1640
|
};
|
|
1636
|
-
function
|
|
1641
|
+
function ei(e) {
|
|
1637
1642
|
let t = e.warning ? n.yellow("warn") : e.passed ? n.green("ok ") : e.skipped ? n.dim("skip") : n.red("FAIL"), r = e.role ? `${e.role}: ` : "", i = e.detail ? ` (${e.detail})` : "";
|
|
1638
1643
|
return ` ${t} ${e.case} ${r}${e.name}${i}`;
|
|
1639
1644
|
}
|
|
1640
|
-
async function
|
|
1641
|
-
if (!e) throw new
|
|
1645
|
+
async function ti(e, t = {}) {
|
|
1646
|
+
if (!e) throw new P($r.check, void 0, "missing-argument");
|
|
1642
1647
|
let r = t.core === !0;
|
|
1643
1648
|
t.json || (console.log(`${S.host} plugin check: host ${S.host}, adopts: ${S.adopts.length > 0 ? S.adopts.join(", ") : "none"}`), r && console.log("core cases only (1 to 5): no role cases, no layout line"));
|
|
1644
1649
|
let i = await g({
|
|
1645
|
-
...r ? {} : { approvals: await
|
|
1650
|
+
...r ? {} : { approvals: await ni(e) },
|
|
1646
1651
|
host: S.host,
|
|
1647
|
-
profile:
|
|
1652
|
+
profile: He,
|
|
1648
1653
|
program: e,
|
|
1649
1654
|
validate: !1,
|
|
1650
1655
|
requests: a(),
|
|
1651
|
-
...r ? {} : { roleCases:
|
|
1652
|
-
}), o = i.filter((e) => e.warning).length, s = i.filter((e) => !e.passed && !e.skipped), c = r ? void 0 :
|
|
1656
|
+
...r ? {} : { roleCases: Qr(e) }
|
|
1657
|
+
}), o = i.filter((e) => e.warning).length, s = i.filter((e) => !e.passed && !e.skipped), c = r ? void 0 : me(A.resolve(e));
|
|
1653
1658
|
if (t.json) {
|
|
1654
1659
|
let e = (e) => e.warning ? "warn" : e.passed ? "ok" : e.skipped ? "skip" : "fail", t = i.map((t) => ({
|
|
1655
1660
|
case: t.case,
|
|
@@ -1668,89 +1673,89 @@ async function ri(e, t = {}) {
|
|
|
1668
1673
|
...c ? { layout: c } : {}
|
|
1669
1674
|
})}\n`), s.length === 0 && !c ? 0 : 1;
|
|
1670
1675
|
}
|
|
1671
|
-
for (let e of i) console.log(
|
|
1676
|
+
for (let e of i) console.log(ei(e));
|
|
1672
1677
|
return c && console.log(` ${n.red("FAIL")} layout: ${c}`), s.length > 0 ? console.log(n.red(`\n${s.length} case${s.length === 1 ? "" : "s"} failed`)) : console.log(c ? n.red("\nFailed: the file name does not follow the layout of a shipped plugin") : n.green(`\nPassed${o > 0 ? `, with ${o} warning${o === 1 ? "" : "s"}` : ""}`)), s.length === 0 && !c ? 0 : 1;
|
|
1673
1678
|
}
|
|
1674
|
-
async function
|
|
1679
|
+
async function ni(e) {
|
|
1675
1680
|
let t;
|
|
1676
1681
|
try {
|
|
1677
|
-
t = (await
|
|
1682
|
+
t = (await B(process.cwd())).plugins ?? [];
|
|
1678
1683
|
} catch {
|
|
1679
1684
|
return;
|
|
1680
1685
|
}
|
|
1681
|
-
let n =
|
|
1686
|
+
let n = A.basename(e), r = fe(n) ?? n.replace(/^blazon-/, "");
|
|
1682
1687
|
return t.flatMap((e, t) => e.name === r ? [{
|
|
1683
1688
|
key: `plugins[${t}].env`,
|
|
1684
1689
|
approved: e.env ?? []
|
|
1685
1690
|
}] : []);
|
|
1686
1691
|
}
|
|
1687
|
-
function
|
|
1688
|
-
if (!e) throw new
|
|
1689
|
-
if (!t.name && (t.digest || t.entry)) throw new
|
|
1690
|
-
if (!
|
|
1692
|
+
function ri(e, t = {}, n = process.cwd()) {
|
|
1693
|
+
if (!e) throw new P($r.pin, void 0, "missing-argument");
|
|
1694
|
+
if (!t.name && (t.digest || t.entry)) throw new P(`--digest and --entry say what to record, so they need --name; ${$r.pin}`, void 0, "conflicting-options");
|
|
1695
|
+
if (!j.existsSync(e)) return console.error(`blazon plugin pin: there is nothing at ${e}.`), 2;
|
|
1691
1696
|
try {
|
|
1692
1697
|
if (t.name) {
|
|
1693
|
-
let r =
|
|
1698
|
+
let r = u(n, t.name, e, {
|
|
1694
1699
|
digest: t.digest,
|
|
1695
1700
|
entry: t.entry
|
|
1696
1701
|
});
|
|
1697
|
-
return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${
|
|
1702
|
+
return console.log(`pinned ${t.name}: ${r.digest} (${r.source}) in ${o}`), 0;
|
|
1698
1703
|
}
|
|
1699
|
-
let r =
|
|
1700
|
-
return console.log(r.isDirectory() && !r.isSymbolicLink() ? w(e) :
|
|
1704
|
+
let r = j.lstatSync(e);
|
|
1705
|
+
return console.log(r.isDirectory() && !r.isSymbolicLink() ? w(e) : l(e)), 0;
|
|
1701
1706
|
} catch (t) {
|
|
1702
|
-
return console.error(t instanceof
|
|
1707
|
+
return console.error(t instanceof T ? t.message : `cannot read ${e}: ${t instanceof Error ? t.message : String(t)}`), 1;
|
|
1703
1708
|
}
|
|
1704
1709
|
}
|
|
1705
|
-
function
|
|
1710
|
+
function ii() {
|
|
1706
1711
|
return console.log(JSON.stringify(S, null, 2)), 0;
|
|
1707
1712
|
}
|
|
1708
|
-
async function
|
|
1709
|
-
if (e === "check") return
|
|
1713
|
+
async function ai(e, t, n = {}) {
|
|
1714
|
+
if (e === "check") return ti(t, {
|
|
1710
1715
|
json: n.json,
|
|
1711
1716
|
core: n.core
|
|
1712
1717
|
});
|
|
1713
|
-
if (e === "pin") return
|
|
1714
|
-
if (e === "profile") return
|
|
1715
|
-
throw new
|
|
1718
|
+
if (e === "pin") return ri(t, n);
|
|
1719
|
+
if (e === "profile") return ii();
|
|
1720
|
+
throw new P($r.plugin, void 0, "missing-argument");
|
|
1716
1721
|
}
|
|
1717
1722
|
// src/cli/commands/pin.ts
|
|
1718
|
-
function
|
|
1719
|
-
|
|
1723
|
+
function oi(e = process.cwd(), t = {}) {
|
|
1724
|
+
dt(e);
|
|
1720
1725
|
try {
|
|
1721
|
-
let r = t.identity === void 0 ?
|
|
1726
|
+
let r = t.identity === void 0 ? _e(e) : _e(e, t.identity);
|
|
1722
1727
|
return t.json ? process.stdout.write(`${JSON.stringify({
|
|
1723
1728
|
command: "pin",
|
|
1724
1729
|
passed: !0,
|
|
1725
1730
|
commit: r,
|
|
1726
|
-
file:
|
|
1727
|
-
})}\n`) : console.log(`pinned blazon ${n.bold(r)} in ${
|
|
1731
|
+
file: Me
|
|
1732
|
+
})}\n`) : console.log(`pinned blazon ${n.bold(r)} in ${Me}; commit the file with the book`), 0;
|
|
1728
1733
|
} catch (e) {
|
|
1729
1734
|
if (t.json) throw e;
|
|
1730
1735
|
return console.error(e instanceof Error ? e.message : String(e)), 1;
|
|
1731
1736
|
}
|
|
1732
1737
|
}
|
|
1733
1738
|
// src/cli/commands/drift.ts
|
|
1734
|
-
async function
|
|
1735
|
-
let r = (e, r, i) => (console.error(
|
|
1739
|
+
async function si(e, t = {}) {
|
|
1740
|
+
let r = (e, r, i) => (console.error($e("drift", r, i).replace(/^blazon drift:/, (e) => n.red(e))), t.json && console.log(JSON.stringify({
|
|
1736
1741
|
command: "drift",
|
|
1737
1742
|
passed: !1,
|
|
1738
|
-
error: { ...
|
|
1743
|
+
error: { ...it(e, et(r, i), i) }
|
|
1739
1744
|
})), 2);
|
|
1740
1745
|
if (!e) return r("missing-argument", "needs the address of a page or the path of a CSS file", "Run blazon drift <url-or-css-file>.");
|
|
1741
1746
|
let i = t.cwd ?? process.cwd();
|
|
1742
|
-
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(e) && !
|
|
1747
|
+
if (!/^[a-z][a-z0-9+.-]*:\/\//i.test(e) && !j.existsSync(A.resolve(e))) return r("no-file", `there is no file "${e}"`, "Give the path of a CSS file, or the http(s) address of a page.");
|
|
1743
1748
|
let a, o;
|
|
1744
1749
|
try {
|
|
1745
|
-
let n = await
|
|
1750
|
+
let n = await B(i, t.tokens ? { tokensDir: t.tokens } : void 0), r = await D(n, i), s = await Xt(e);
|
|
1746
1751
|
a = s.sources;
|
|
1747
|
-
let c =
|
|
1752
|
+
let c = Ut(s.css);
|
|
1748
1753
|
o = r.tokens.items.flatMap((e) => {
|
|
1749
1754
|
let t = e.blazon.source?.cssVar;
|
|
1750
|
-
return typeof t == "string" ? [
|
|
1755
|
+
return typeof t == "string" ? [Wt(e, t, c)] : [];
|
|
1751
1756
|
});
|
|
1752
1757
|
} catch (e) {
|
|
1753
|
-
return r(e instanceof
|
|
1758
|
+
return r(e instanceof N ? e.code : "error", e instanceof Error ? e.message : String(e), e instanceof N ? e.fix : void 0);
|
|
1754
1759
|
}
|
|
1755
1760
|
if (o.length === 0) return r("error", "no token declares a source.cssVar, so there is nothing to compare", "Name the site's custom property in a token's dev.blazon source.cssVar (manual chapter 2).");
|
|
1756
1761
|
let s = (e) => o.filter((t) => t.status === e).length, c = {
|
|
@@ -1772,10 +1777,10 @@ async function li(e, t = {}) {
|
|
|
1772
1777
|
return console.log(`\n${c.ok} ok, ${c.drift} drifted, ${c.missing} missing`), l;
|
|
1773
1778
|
}
|
|
1774
1779
|
// src/cli/commands/approvals.ts
|
|
1775
|
-
async function
|
|
1776
|
-
let r = await
|
|
1777
|
-
assetsDir:
|
|
1778
|
-
dirs:
|
|
1780
|
+
async function ci(e = process.cwd(), t = {}) {
|
|
1781
|
+
let r = await B(e), i = await D(r, e), a = x(i.tokens, i.assets.all, {
|
|
1782
|
+
assetsDir: A.resolve(e, r.assetsDir),
|
|
1783
|
+
dirs: y(r.assets, e)
|
|
1779
1784
|
}), o = (e) => e.review.value === void 0 ? "not recorded" : e.review.value === e.current ? "recorded" : "stale";
|
|
1780
1785
|
if (t.json) {
|
|
1781
1786
|
let e = a.map((e) => ({
|
|
@@ -1799,50 +1804,50 @@ async function ui(e = process.cwd(), t = {}) {
|
|
|
1799
1804
|
return console.log(), console.log(n.dim(" Set review.value to the fingerprint once a person has confirmed the value.\n")), 0;
|
|
1800
1805
|
}
|
|
1801
1806
|
// src/cli/commands/cwd.ts
|
|
1802
|
-
function
|
|
1807
|
+
function li(e) {
|
|
1803
1808
|
if (e === void 0) return;
|
|
1804
|
-
if (typeof e != "string" || e === "") throw new
|
|
1805
|
-
let t =
|
|
1806
|
-
|
|
1809
|
+
if (typeof e != "string" || e === "") throw new P("--cwd needs a folder", "Give one, such as blazon --cwd ./my-brand check.");
|
|
1810
|
+
let t = A.resolve(process.cwd(), e);
|
|
1811
|
+
dt(t), process.chdir(t);
|
|
1807
1812
|
}
|
|
1808
|
-
function
|
|
1809
|
-
let
|
|
1810
|
-
if (
|
|
1811
|
-
|
|
1813
|
+
function ui(e, t = process.env) {
|
|
1814
|
+
let n = (Array.isArray(e) ? e : e === void 0 ? [] : [e]).map((e) => typeof e == "string" || typeof e == "number" ? String(e) : "");
|
|
1815
|
+
if (n.some((e) => e.trim() === "")) throw new P("--allow-dir needs a folder", "Give one, such as blazon dev --allow-dir ../shared.");
|
|
1816
|
+
v(re(n, t, process.cwd()));
|
|
1812
1817
|
}
|
|
1813
1818
|
// src/core/read/lookup.ts
|
|
1814
|
-
var
|
|
1815
|
-
function
|
|
1816
|
-
let n =
|
|
1819
|
+
var q = class extends Error {}, di = (e) => e.trim().replace(/^\{(.*)\}$/, "$1").trim();
|
|
1820
|
+
function fi(e, t) {
|
|
1821
|
+
let n = di(t), r = e.tokens.byPath.get(n);
|
|
1817
1822
|
if (r) return r;
|
|
1818
|
-
let i =
|
|
1819
|
-
throw new
|
|
1823
|
+
let i = E(n, e.tokens.items.map((e) => e.path));
|
|
1824
|
+
throw new q(e.tokens.items.some((e) => e.path.startsWith(`${n}.`)) ? `"${n}" is a group, not a token; \`blazon rules ${n}\` shows its rules.` : `no token "${n}"${i ? `; did you mean "${i}"?` : "."}`);
|
|
1820
1825
|
}
|
|
1821
1826
|
// src/core/read/rules.ts
|
|
1822
|
-
var
|
|
1823
|
-
function
|
|
1824
|
-
return
|
|
1827
|
+
var pi = (e) => e.extensions?.["dev.blazon"] ?? {};
|
|
1828
|
+
function mi(e, t, n) {
|
|
1829
|
+
return pi(t)[n] === void 0 ? e.tokens.groupMeta.filter((e) => t.path.startsWith(`${e.path}.`) && e.blazon[n] !== void 0).sort((e, t) => t.path.length - e.path.length)[0]?.path : t.path;
|
|
1825
1830
|
}
|
|
1826
|
-
var
|
|
1827
|
-
function
|
|
1828
|
-
let n = t.blazon.usage, r =
|
|
1831
|
+
var J = (e) => Array.isArray(e) ? e.filter((e) => typeof e == "string") : void 0;
|
|
1832
|
+
function hi(e, t) {
|
|
1833
|
+
let n = t.blazon.usage, r = mi(e, t, "usage");
|
|
1829
1834
|
if (!n || typeof n != "object" || r === void 0) return;
|
|
1830
|
-
let i =
|
|
1835
|
+
let i = J(n.allow), a = J(n.deny);
|
|
1831
1836
|
return {
|
|
1832
1837
|
...i && { allow: i },
|
|
1833
1838
|
...a && { deny: a },
|
|
1834
1839
|
from: r
|
|
1835
1840
|
};
|
|
1836
1841
|
}
|
|
1837
|
-
function
|
|
1838
|
-
let n = t.blazon.logo, r =
|
|
1842
|
+
function gi(e, t) {
|
|
1843
|
+
let n = t.blazon.logo, r = mi(e, t, "logo"), i = J(n?.deny);
|
|
1839
1844
|
if (n && i && r !== void 0) return {
|
|
1840
1845
|
deny: i,
|
|
1841
1846
|
...typeof n.reason == "string" && { reason: n.reason },
|
|
1842
1847
|
from: r
|
|
1843
1848
|
};
|
|
1844
1849
|
}
|
|
1845
|
-
function
|
|
1850
|
+
function _i(e) {
|
|
1846
1851
|
return e.tokens.groupMeta.flatMap((e) => (e.blazon.pairs ?? []).map((t) => ({
|
|
1847
1852
|
fg: t.fg,
|
|
1848
1853
|
bg: t.bg,
|
|
@@ -1850,19 +1855,19 @@ function yi(e) {
|
|
|
1850
1855
|
from: e.path
|
|
1851
1856
|
})));
|
|
1852
1857
|
}
|
|
1853
|
-
function
|
|
1858
|
+
function vi(e, t) {
|
|
1854
1859
|
let n = [];
|
|
1855
|
-
for (let r of
|
|
1860
|
+
for (let r of _i(e)) Se(r.fg, e.tokens.items).some((e) => e.path === t.path) && n.push({
|
|
1856
1861
|
...r,
|
|
1857
1862
|
as: "fg"
|
|
1858
|
-
}),
|
|
1863
|
+
}), Se(r.bg, e.tokens.items).some((e) => e.path === t.path) && n.push({
|
|
1859
1864
|
...r,
|
|
1860
1865
|
as: "bg"
|
|
1861
1866
|
});
|
|
1862
1867
|
return n;
|
|
1863
1868
|
}
|
|
1864
|
-
function
|
|
1865
|
-
let n =
|
|
1869
|
+
function yi(e, t) {
|
|
1870
|
+
let n = pi(t).review, r = n ? t.path : mi(e, t, "review"), i = n ?? e.tokens.groupMeta.find((e) => e.path === r)?.blazon.review;
|
|
1866
1871
|
if (i && r !== void 0) return {
|
|
1867
1872
|
status: i.status,
|
|
1868
1873
|
...i.note && { note: i.note },
|
|
@@ -1871,8 +1876,8 @@ function xi(e, t) {
|
|
|
1871
1876
|
from: r
|
|
1872
1877
|
};
|
|
1873
1878
|
}
|
|
1874
|
-
function
|
|
1875
|
-
let n =
|
|
1879
|
+
function bi(e, t) {
|
|
1880
|
+
let n = hi(e, t), r = gi(e, t), i = yi(e, t), a = t.blazon.role === void 0 ? void 0 : mi(e, t, "role");
|
|
1876
1881
|
return {
|
|
1877
1882
|
...t.blazon.role !== void 0 && a !== void 0 && { role: {
|
|
1878
1883
|
value: t.blazon.role,
|
|
@@ -1880,15 +1885,15 @@ function Si(e, t) {
|
|
|
1880
1885
|
} },
|
|
1881
1886
|
...n && { usage: n },
|
|
1882
1887
|
...r && { logo: r },
|
|
1883
|
-
pairs:
|
|
1888
|
+
pairs: vi(e, t),
|
|
1884
1889
|
...i && { review: i }
|
|
1885
1890
|
};
|
|
1886
1891
|
}
|
|
1887
|
-
function
|
|
1892
|
+
function xi(e, t, n) {
|
|
1888
1893
|
let r = n.usage && typeof n.usage == "object" ? {
|
|
1889
|
-
...
|
|
1890
|
-
...
|
|
1891
|
-
} : void 0, i =
|
|
1894
|
+
...J(n.usage.allow) && { allow: J(n.usage.allow) },
|
|
1895
|
+
...J(n.usage.deny) && { deny: J(n.usage.deny) }
|
|
1896
|
+
} : void 0, i = J(n.logo?.deny), a = {
|
|
1892
1897
|
at: e,
|
|
1893
1898
|
kind: t,
|
|
1894
1899
|
...typeof n.role == "string" && { role: n.role },
|
|
@@ -1905,41 +1910,37 @@ function Ci(e, t, n) {
|
|
|
1905
1910
|
};
|
|
1906
1911
|
return Object.keys(a).length > 2 ? a : void 0;
|
|
1907
1912
|
}
|
|
1908
|
-
function
|
|
1909
|
-
let n =
|
|
1913
|
+
function Si(e, t) {
|
|
1914
|
+
let n = di(t), r = (e) => n === "" || e === n || e.startsWith(`${n}.`);
|
|
1910
1915
|
if (!(n === "" || e.tokens.items.some((e) => r(e.path)))) {
|
|
1911
|
-
let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r =
|
|
1912
|
-
throw new
|
|
1916
|
+
let t = [...new Set(e.tokens.items.flatMap((e) => e.path.split(".").slice(0, -1).map((e, t, n) => n.slice(0, t + 1).join("."))))], r = E(n, [...t, ...e.tokens.items.map((e) => e.path)]);
|
|
1917
|
+
throw new q(`no token or group "${n}"${r ? `; did you mean "${r}"?` : "."}`);
|
|
1913
1918
|
}
|
|
1914
1919
|
return [
|
|
1915
|
-
...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) =>
|
|
1920
|
+
...e.tokens.groupMeta.filter((e) => n !== "" && n.startsWith(`${e.path}.`)).map((e) => xi(e.path, "group", {
|
|
1916
1921
|
...e.blazon,
|
|
1917
1922
|
pairs: void 0
|
|
1918
1923
|
})).map((e) => e && {
|
|
1919
1924
|
...e,
|
|
1920
1925
|
inherited: !0
|
|
1921
1926
|
}),
|
|
1922
|
-
...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) =>
|
|
1923
|
-
...e.tokens.items.filter((e) => r(e.path)).map((e) =>
|
|
1927
|
+
...e.tokens.groupMeta.filter((e) => r(e.path)).map((e) => xi(e.path, "group", e.blazon)),
|
|
1928
|
+
...e.tokens.items.filter((e) => r(e.path)).map((e) => xi(e.path, "token", pi(e)))
|
|
1924
1929
|
].filter((e) => e !== void 0);
|
|
1925
1930
|
}
|
|
1926
1931
|
// src/core/read/token.ts
|
|
1927
|
-
function
|
|
1928
|
-
let [n, ...r] =
|
|
1932
|
+
function Ci(e, t) {
|
|
1933
|
+
let [n, ...r] = i(t);
|
|
1929
1934
|
return {
|
|
1930
1935
|
theme: {
|
|
1931
1936
|
variable: n,
|
|
1932
1937
|
...t.parts && { parts: Object.fromEntries(Object.keys(t.parts).map((e, t) => [e, r[t]])) }
|
|
1933
1938
|
},
|
|
1934
|
-
|
|
1935
|
-
variable: i,
|
|
1936
|
-
...a && a.path !== t.path && { shadowedBy: a.path }
|
|
1937
|
-
} : null,
|
|
1938
|
-
...t.type === "typography" && { typographyClass: f(t.path) }
|
|
1939
|
+
...t.type === "typography" && { typographyClass: c(t.path) }
|
|
1939
1940
|
};
|
|
1940
1941
|
}
|
|
1941
|
-
function
|
|
1942
|
-
let n =
|
|
1942
|
+
function wi(e, t) {
|
|
1943
|
+
let n = fi(e, t), r = (e.tokens.contexts ?? []).flatMap((e) => e.tokens.filter((e) => e.path === n.path).map((t) => ({
|
|
1943
1944
|
modifier: e.modifier,
|
|
1944
1945
|
context: e.context,
|
|
1945
1946
|
selector: e.selector,
|
|
@@ -1954,14 +1955,14 @@ function Ei(e, t) {
|
|
|
1954
1955
|
...n.deprecated && { deprecated: n.deprecated },
|
|
1955
1956
|
...n.aliasOf && { aliasOf: n.aliasOf },
|
|
1956
1957
|
...n.blazon.tier && { tier: n.blazon.tier },
|
|
1957
|
-
names:
|
|
1958
|
-
rules:
|
|
1958
|
+
names: Ci(e, n),
|
|
1959
|
+
rules: bi(e, n),
|
|
1959
1960
|
...r.length > 0 && { contexts: r },
|
|
1960
1961
|
sourceFile: n.file.replace(/ \(inline\)$/, "")
|
|
1961
1962
|
};
|
|
1962
1963
|
}
|
|
1963
1964
|
// src/core/read/list.ts
|
|
1964
|
-
function
|
|
1965
|
+
function Ti(e) {
|
|
1965
1966
|
let t = /* @__PURE__ */ new Set();
|
|
1966
1967
|
for (let { path: n } of e.tokens.items) {
|
|
1967
1968
|
let e = n.split(".");
|
|
@@ -1969,20 +1970,20 @@ function Di(e) {
|
|
|
1969
1970
|
}
|
|
1970
1971
|
return t;
|
|
1971
1972
|
}
|
|
1972
|
-
function
|
|
1973
|
-
let n =
|
|
1974
|
-
return !e.tokens.byPath.has(n) &&
|
|
1973
|
+
function Ei(e, t) {
|
|
1974
|
+
let n = di(t);
|
|
1975
|
+
return !e.tokens.byPath.has(n) && Ti(e).has(n);
|
|
1975
1976
|
}
|
|
1976
|
-
function
|
|
1977
|
+
function Di(e, t = {}) {
|
|
1977
1978
|
let n;
|
|
1978
|
-
if (t.type !== void 0 && (n =
|
|
1979
|
+
if (t.type !== void 0 && (n = Ue.find((e) => e === t.type), !n)) throw new q(`no token type "${t.type}"; the types are ${Ue.join(", ")}.`);
|
|
1979
1980
|
let r;
|
|
1980
1981
|
if (t.group !== void 0) {
|
|
1981
|
-
r =
|
|
1982
|
-
let n =
|
|
1982
|
+
r = di(t.group);
|
|
1983
|
+
let n = Ti(e);
|
|
1983
1984
|
if (!n.has(r)) {
|
|
1984
|
-
let e =
|
|
1985
|
-
throw new
|
|
1985
|
+
let e = E(r, [...n]);
|
|
1986
|
+
throw new q(`no group "${r}"${e ? `; did you mean "${e}"?` : "."}`);
|
|
1986
1987
|
}
|
|
1987
1988
|
}
|
|
1988
1989
|
let i = e.tokens.items.filter((e) => (r === void 0 || e.path.startsWith(`${r}.`)) && (n === void 0 || e.type === n)).map((e) => ({
|
|
@@ -1998,24 +1999,24 @@ function ki(e, t = {}) {
|
|
|
1998
1999
|
};
|
|
1999
2000
|
}
|
|
2000
2001
|
// src/core/read/can.ts
|
|
2001
|
-
var
|
|
2002
|
+
var Oi = ["text", "ui"], ki = Ce["AA-large"], Ai = [
|
|
2002
2003
|
"border",
|
|
2003
2004
|
"icon",
|
|
2004
2005
|
"interactive"
|
|
2005
|
-
],
|
|
2006
|
+
], ji = [
|
|
2006
2007
|
"AAA",
|
|
2007
2008
|
"AA",
|
|
2008
2009
|
"AA-large"
|
|
2009
2010
|
];
|
|
2010
|
-
function
|
|
2011
|
+
function Mi(e, t) {
|
|
2011
2012
|
let n = [];
|
|
2012
2013
|
for (let r = t; r && !n.includes(r); r = r.aliasOf ? e.tokens.byPath.get(r.aliasOf) : void 0) n.push(r);
|
|
2013
2014
|
return n;
|
|
2014
2015
|
}
|
|
2015
|
-
function
|
|
2016
|
-
for (let r of
|
|
2017
|
-
if (
|
|
2018
|
-
let t =
|
|
2016
|
+
function Ni(e, t, n) {
|
|
2017
|
+
for (let r of Mi(e, t)) {
|
|
2018
|
+
if (_(r, n)) continue;
|
|
2019
|
+
let t = hi(e, r), i = t.deny?.includes(n) ? `denies "${n}"` : `allows only ${(t.allow ?? []).map((e) => `"${e}"`).join(", ")}, not "${n}"`;
|
|
2019
2020
|
return {
|
|
2020
2021
|
rule: "usage",
|
|
2021
2022
|
ok: !1,
|
|
@@ -2023,15 +2024,15 @@ function Fi(e, t, n) {
|
|
|
2023
2024
|
from: t.from
|
|
2024
2025
|
};
|
|
2025
2026
|
}
|
|
2026
|
-
let r =
|
|
2027
|
+
let r = Mi(e, t).find((t) => hi(e, t));
|
|
2027
2028
|
return {
|
|
2028
2029
|
rule: "usage",
|
|
2029
2030
|
ok: !0,
|
|
2030
2031
|
message: r ? `usage rules on {${r.path}} leave "${n}" open` : `{${t.path}} has no usage rule against "${n}"`
|
|
2031
2032
|
};
|
|
2032
2033
|
}
|
|
2033
|
-
function
|
|
2034
|
-
let n =
|
|
2034
|
+
function Pi(e, t) {
|
|
2035
|
+
let n = Ai.map((n) => Ni(e, t, n)), r = Ai.filter((e, t) => n[t].ok);
|
|
2035
2036
|
return r.length > 0 ? {
|
|
2036
2037
|
rule: "usage",
|
|
2037
2038
|
ok: !0,
|
|
@@ -2043,12 +2044,12 @@ function Ii(e, t) {
|
|
|
2043
2044
|
from: n[0].from
|
|
2044
2045
|
};
|
|
2045
2046
|
}
|
|
2046
|
-
var
|
|
2047
|
-
function
|
|
2048
|
-
let n = e.tokens.modifiers?.find((e) => e.name ===
|
|
2049
|
-
if (!n) throw new
|
|
2050
|
-
if (!n.contexts.includes(t)) throw new
|
|
2051
|
-
let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i =
|
|
2047
|
+
var Fi = "theme";
|
|
2048
|
+
function Ii(e, t) {
|
|
2049
|
+
let n = e.tokens.modifiers?.find((e) => e.name === Fi);
|
|
2050
|
+
if (!n) throw new q(`no theme "${t}": this brand has no resolver "${Fi}" modifier, so it has no themes.`);
|
|
2051
|
+
if (!n.contexts.includes(t)) throw new q(`no theme "${t}". The themes are ${n.contexts.map((e) => `"${e}"`).join(", ")}.`);
|
|
2052
|
+
let r = (e.tokens.contexts ?? []).filter((e) => e.modifier === "theme" && e.context === t), i = ae(e.tokens.items, r);
|
|
2052
2053
|
return {
|
|
2053
2054
|
...e,
|
|
2054
2055
|
tokens: {
|
|
@@ -2058,22 +2059,22 @@ function Ri(e, t) {
|
|
|
2058
2059
|
}
|
|
2059
2060
|
};
|
|
2060
2061
|
}
|
|
2061
|
-
var
|
|
2062
|
-
let n = e.type === "color" ?
|
|
2063
|
-
if (!n) throw new
|
|
2062
|
+
var Li = (e, t) => {
|
|
2063
|
+
let n = e.type === "color" ? h(String(e.value)) : void 0;
|
|
2064
|
+
if (!n) throw new q(`{${e.path}} (${t}) is not a color blazon can read: it is ${e.type ?? "untyped"} with the value ${String(e.value)}.`);
|
|
2064
2065
|
return n;
|
|
2065
2066
|
};
|
|
2066
|
-
function
|
|
2067
|
+
function Ri(t, n, r, i = "text", a) {
|
|
2067
2068
|
if (a !== void 0) return {
|
|
2068
|
-
...
|
|
2069
|
+
...Ri(Ii(t, a), n, r, i),
|
|
2069
2070
|
theme: a
|
|
2070
2071
|
};
|
|
2071
|
-
if (!
|
|
2072
|
-
let o =
|
|
2072
|
+
if (!Oi.includes(i)) throw new q(`"${String(i)}" is not a role blazon can judge. Use ${Oi.map((e) => `"${e}"`).join(" or ")}.`);
|
|
2073
|
+
let o = fi(t, n), s = fi(t, r), c = e(Li(o, "foreground"), Li(s, "background")), l = ji.find((e) => c >= Ce[e]) ?? "fail", u = `${c.toFixed(2)}:1`, d = Math.round(c * 100) / 100;
|
|
2073
2074
|
if (i === "ui") {
|
|
2074
|
-
let
|
|
2075
|
-
|
|
2076
|
-
|
|
2075
|
+
let e = [
|
|
2076
|
+
Pi(t, o),
|
|
2077
|
+
Ni(t, s, "background"),
|
|
2077
2078
|
{
|
|
2078
2079
|
rule: "pairs",
|
|
2079
2080
|
ok: !0,
|
|
@@ -2081,31 +2082,31 @@ function Bi(e, n, r, i = "text", a) {
|
|
|
2081
2082
|
},
|
|
2082
2083
|
{
|
|
2083
2084
|
rule: "contrast",
|
|
2084
|
-
ok: c >=
|
|
2085
|
-
message: `non-text contrast needs ${
|
|
2085
|
+
ok: c >= ki,
|
|
2086
|
+
message: `non-text contrast needs ${ki}:1, this is ${u}`
|
|
2086
2087
|
}
|
|
2087
|
-
], n =
|
|
2088
|
+
], n = e.find((e) => !e.ok), r = n ? n.message : e[e.length - 1].message;
|
|
2088
2089
|
return {
|
|
2089
2090
|
fg: o.path,
|
|
2090
2091
|
bg: s.path,
|
|
2091
2092
|
role: i,
|
|
2092
2093
|
allowed: n === void 0,
|
|
2093
2094
|
reason: r,
|
|
2094
|
-
checks:
|
|
2095
|
+
checks: e,
|
|
2095
2096
|
contrast: {
|
|
2096
2097
|
ratio: d,
|
|
2097
2098
|
level: l,
|
|
2098
|
-
threshold:
|
|
2099
|
+
threshold: ki
|
|
2099
2100
|
}
|
|
2100
2101
|
};
|
|
2101
2102
|
}
|
|
2102
|
-
let f = [
|
|
2103
|
-
if (
|
|
2104
|
-
let
|
|
2103
|
+
let f = [Ni(t, o, "text"), Ni(t, s, "background")], p = _i(t), h = m(t.tokens.items, p, o.path, s.path);
|
|
2104
|
+
if (h.length > 0) for (let e of h) {
|
|
2105
|
+
let t = Ce[e.min];
|
|
2105
2106
|
f.push({
|
|
2106
2107
|
rule: "pairs",
|
|
2107
|
-
ok: c >=
|
|
2108
|
-
message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${
|
|
2108
|
+
ok: c >= t,
|
|
2109
|
+
message: `pairs on ${e.from} list ${e.fg} on ${e.bg}: ${e.min} needs ${t}:1, this is ${u}`,
|
|
2109
2110
|
from: e.from
|
|
2110
2111
|
});
|
|
2111
2112
|
}
|
|
@@ -2138,17 +2139,17 @@ function Bi(e, n, r, i = "text", a) {
|
|
|
2138
2139
|
};
|
|
2139
2140
|
}
|
|
2140
2141
|
// src/core/read/fonts.ts
|
|
2141
|
-
function
|
|
2142
|
-
let r = t.fonts ?? [], i =
|
|
2142
|
+
function zi(e, t, n) {
|
|
2143
|
+
let r = t.fonts ?? [], i = Ie(t.fonts, n), a = /* @__PURE__ */ new Map();
|
|
2143
2144
|
for (let t of e.tokens.items) {
|
|
2144
|
-
let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ?
|
|
2145
|
+
let e = t.resolvedValue, n = t.type === "fontFamily" ? (Array.isArray(e) ? e : [e]).filter((e) => typeof e == "string") : void 0, r = t.type === "fontFamily" ? Pe(e) : t.type === "typography" && typeof e == "object" && e ? Pe(e.fontFamily) : void 0;
|
|
2145
2146
|
if (!r) continue;
|
|
2146
2147
|
let o = r.toLowerCase(), s = a.get(o);
|
|
2147
2148
|
s ? (s.tokens.push(t.path), !s.stack && n && (s.stack = n)) : a.set(o, {
|
|
2148
2149
|
family: r,
|
|
2149
2150
|
tokens: [t.path],
|
|
2150
2151
|
...n && { stack: n },
|
|
2151
|
-
system:
|
|
2152
|
+
system: ke.has(o),
|
|
2152
2153
|
loaded: i.families.has(o) ? !0 : i.opaque ? null : !1,
|
|
2153
2154
|
...t.blazon.webFont !== void 0 && { webFont: t.blazon.webFont },
|
|
2154
2155
|
...t.blazon.font && { font: t.blazon.font }
|
|
@@ -2159,8 +2160,8 @@ function Vi(e, t, n) {
|
|
|
2159
2160
|
value: e.theme[t]
|
|
2160
2161
|
} : void 0;
|
|
2161
2162
|
return {
|
|
2162
|
-
stylesheets: r.filter((e) => !
|
|
2163
|
-
files: r.filter(
|
|
2163
|
+
stylesheets: r.filter((e) => !Ae(e)),
|
|
2164
|
+
files: r.filter(Ae).map((e) => ({
|
|
2164
2165
|
family: e.family,
|
|
2165
2166
|
file: e.file,
|
|
2166
2167
|
...e.weight !== void 0 && { weight: e.weight },
|
|
@@ -2173,22 +2174,22 @@ function Vi(e, t, n) {
|
|
|
2173
2174
|
families: [...a.values()]
|
|
2174
2175
|
};
|
|
2175
2176
|
}
|
|
2176
|
-
function
|
|
2177
|
+
function Bi(e, t) {
|
|
2177
2178
|
let n = e.stylesheets.map((e) => `/* Stylesheet, not fetched by blazon: ${e.replace(/\*\//g, "*%2F")} */`);
|
|
2178
2179
|
for (let r of e.files) {
|
|
2179
|
-
let e =
|
|
2180
|
+
let e = se(r.file);
|
|
2180
2181
|
if (!e) {
|
|
2181
2182
|
n.push(`/* ${r.file.replace(/\*\//g, "*%2F")}: not a font file blazon embeds, so no rule */`);
|
|
2182
2183
|
continue;
|
|
2183
2184
|
}
|
|
2184
2185
|
let i = t === void 0 ? r.file : `${t.endsWith("/") ? t : `${t}/`}${r.file.split("/").pop()}`;
|
|
2185
|
-
n.push(
|
|
2186
|
+
n.push(xe(r, `url("${encodeURI(i).replace(/"/g, "%22")}") format("${e}")`, !0));
|
|
2186
2187
|
}
|
|
2187
2188
|
return n.length === 0 ? "/* The config lists no fonts. */\n" : `${n.join("\n\n")}\n`;
|
|
2188
2189
|
}
|
|
2189
2190
|
// src/core/read/logo.ts
|
|
2190
|
-
function
|
|
2191
|
-
let r =
|
|
2191
|
+
function Vi(e, t, n) {
|
|
2192
|
+
let r = s(t), i = A.resolve(n, t.assetsDir), a = y(t.assets, n), o = (e) => A.relative(n, p(e, i, a)).split(A.sep).join("/"), c = ["onLight", "onDark"].flatMap((t) => {
|
|
2192
2193
|
let n = r[t];
|
|
2193
2194
|
if (!n) return [];
|
|
2194
2195
|
let i = t === "onLight" ? e.logo?.onLightAsset : e.logo?.onDarkAsset, a = t === "onLight" ? e.logo?.onLightInk : e.logo?.onDarkInk;
|
|
@@ -2201,17 +2202,17 @@ function Ui(e, t, n) {
|
|
|
2201
2202
|
}];
|
|
2202
2203
|
});
|
|
2203
2204
|
return {
|
|
2204
|
-
variants:
|
|
2205
|
+
variants: c,
|
|
2205
2206
|
assets: e.assets.logos.map((e) => {
|
|
2206
|
-
let t =
|
|
2207
|
+
let t = p(e, i, a);
|
|
2207
2208
|
return {
|
|
2208
2209
|
id: e.id,
|
|
2209
2210
|
file: o(e),
|
|
2210
|
-
variants:
|
|
2211
|
+
variants: c.filter((e) => r[e.variant] ? d(A.resolve(n, r[e.variant]), t) : !1).map((e) => e.variant),
|
|
2211
2212
|
rules: e.meta ?? {}
|
|
2212
2213
|
};
|
|
2213
2214
|
}),
|
|
2214
|
-
forbidden:
|
|
2215
|
+
forbidden: Si(e, "").flatMap((e) => e.logo ? [{
|
|
2215
2216
|
at: e.at,
|
|
2216
2217
|
deny: e.logo.deny,
|
|
2217
2218
|
...e.logo.reason && { reason: e.logo.reason }
|
|
@@ -2219,33 +2220,33 @@ function Ui(e, t, n) {
|
|
|
2219
2220
|
};
|
|
2220
2221
|
}
|
|
2221
2222
|
// src/cli/read.ts
|
|
2222
|
-
async function
|
|
2223
|
-
let t = await
|
|
2223
|
+
async function Y(e) {
|
|
2224
|
+
let t = await B(e), r = await D(t, e), { errors: i } = k(r.findings);
|
|
2224
2225
|
return i.length > 0 && console.error(n.yellow(`blazon: this brand has ${i.length} error(s), so a value below may be wrong; run blazon check.`)), {
|
|
2225
2226
|
config: t,
|
|
2226
2227
|
data: r
|
|
2227
2228
|
};
|
|
2228
2229
|
}
|
|
2229
|
-
function
|
|
2230
|
+
function Hi(e) {
|
|
2230
2231
|
try {
|
|
2231
2232
|
return e();
|
|
2232
2233
|
} catch (e) {
|
|
2233
|
-
throw e instanceof
|
|
2234
|
+
throw e instanceof q ? new P(e.message, void 0, "unknown-token") : e;
|
|
2234
2235
|
}
|
|
2235
2236
|
}
|
|
2236
|
-
function
|
|
2237
|
+
function Ui(e, t, n) {
|
|
2237
2238
|
process.stdout.write(`${JSON.stringify({
|
|
2238
2239
|
command: e,
|
|
2239
2240
|
passed: t,
|
|
2240
2241
|
...n
|
|
2241
2242
|
}, null, 2)}\n`);
|
|
2242
2243
|
}
|
|
2243
|
-
function
|
|
2244
|
+
function Wi(e, t = " ") {
|
|
2244
2245
|
let r = e.filter((e) => e[1] !== void 0), i = Math.max(0, ...r.map(([e]) => e.length));
|
|
2245
2246
|
for (let [e, a] of r) console.log(`${t}${n.dim(e.padEnd(i))} ${a}`);
|
|
2246
2247
|
}
|
|
2247
2248
|
// src/cli/commands/doctor.ts
|
|
2248
|
-
var
|
|
2249
|
+
var Gi = [
|
|
2249
2250
|
"blazon.brand-deck",
|
|
2250
2251
|
"blazon.favicons",
|
|
2251
2252
|
"blazon.logo-geometry",
|
|
@@ -2253,36 +2254,36 @@ var Ki = [
|
|
|
2253
2254
|
"blazon.press-kit",
|
|
2254
2255
|
"blazon.print-book",
|
|
2255
2256
|
"blazon.social-cards"
|
|
2256
|
-
],
|
|
2257
|
+
], Ki = (e) => {
|
|
2257
2258
|
try {
|
|
2258
|
-
return
|
|
2259
|
+
return j.accessSync(e, j.constants.X_OK), j.statSync(e).isFile();
|
|
2259
2260
|
} catch {
|
|
2260
2261
|
return !1;
|
|
2261
2262
|
}
|
|
2262
2263
|
};
|
|
2263
|
-
function
|
|
2264
|
-
if (e.BLAZON_CHROME) return
|
|
2264
|
+
function qi(e = process.env) {
|
|
2265
|
+
if (e.BLAZON_CHROME) return Ki(e.BLAZON_CHROME);
|
|
2265
2266
|
let t = [];
|
|
2266
2267
|
if (process.platform === "darwin") t.push("/Applications/Google Chrome.app/Contents/MacOS/Google Chrome");
|
|
2267
2268
|
else if (process.platform === "win32") for (let n of [
|
|
2268
2269
|
e.PROGRAMFILES,
|
|
2269
2270
|
e["PROGRAMFILES(X86)"],
|
|
2270
2271
|
e.LOCALAPPDATA
|
|
2271
|
-
]) n && t.push(
|
|
2272
|
-
else t.push("/opt/google/chrome/chrome", ...(e.PATH ?? "").split(
|
|
2273
|
-
return t.some(
|
|
2272
|
+
]) n && t.push(A.join(n, "Google", "Chrome", "Application", "chrome.exe"));
|
|
2273
|
+
else t.push("/opt/google/chrome/chrome", ...(e.PATH ?? "").split(A.delimiter).filter(Boolean).flatMap((e) => ["google-chrome", "google-chrome-stable"].map((t) => A.join(e, t))));
|
|
2274
|
+
return t.some(Ki);
|
|
2274
2275
|
}
|
|
2275
|
-
var
|
|
2276
|
-
let e = JSON.parse(
|
|
2276
|
+
var Ji = () => {
|
|
2277
|
+
let e = JSON.parse(j.readFileSync(A.join(Te(), "package.json"), "utf-8"));
|
|
2277
2278
|
return {
|
|
2278
2279
|
nodeVersion: process.version,
|
|
2279
2280
|
engine: e.engines?.node,
|
|
2280
|
-
hostProblem: (e) =>
|
|
2281
|
-
chrome: () =>
|
|
2282
|
-
identity:
|
|
2281
|
+
hostProblem: (e) => ee(e, { final: "dir" }),
|
|
2282
|
+
chrome: () => qi(),
|
|
2283
|
+
identity: Oe()
|
|
2283
2284
|
};
|
|
2284
2285
|
};
|
|
2285
|
-
function
|
|
2286
|
+
function Yi(e, t) {
|
|
2286
2287
|
let n = /^>=\s*v?(\d+)(?:\.(\d+))?(?:\.(\d+))?$/.exec(t.trim()), r = /^v?(\d+)\.(\d+)\.(\d+)/.exec(e);
|
|
2287
2288
|
if (!n || !r) return;
|
|
2288
2289
|
let i = [
|
|
@@ -2297,14 +2298,14 @@ function Xi(e, t) {
|
|
|
2297
2298
|
for (let e = 0; e < 3; e++) if (a[e] !== i[e]) return a[e] > i[e];
|
|
2298
2299
|
return !0;
|
|
2299
2300
|
}
|
|
2300
|
-
function
|
|
2301
|
+
function Xi(e) {
|
|
2301
2302
|
if (!e.engine) return {
|
|
2302
2303
|
id: "node",
|
|
2303
2304
|
status: "warn",
|
|
2304
2305
|
message: `Node ${e.nodeVersion}; blazon's package.json names no engines range to compare`,
|
|
2305
2306
|
fix: "Reinstall blazon."
|
|
2306
2307
|
};
|
|
2307
|
-
let t =
|
|
2308
|
+
let t = Yi(e.nodeVersion, e.engine);
|
|
2308
2309
|
return t === void 0 ? {
|
|
2309
2310
|
id: "node",
|
|
2310
2311
|
status: "warn",
|
|
@@ -2321,9 +2322,9 @@ function Zi(e) {
|
|
|
2321
2322
|
fix: `Install Node ${e.engine.replace(/^>=\s*/, "")} or newer, such as with nvm install ${e.engine.replace(/^>=\s*v?(\d+).*$/, "$1")}.`
|
|
2322
2323
|
};
|
|
2323
2324
|
}
|
|
2324
|
-
async function
|
|
2325
|
+
async function Zi(e) {
|
|
2325
2326
|
try {
|
|
2326
|
-
let t = await
|
|
2327
|
+
let t = await B(e);
|
|
2327
2328
|
return {
|
|
2328
2329
|
check: {
|
|
2329
2330
|
id: "brand",
|
|
@@ -2337,18 +2338,18 @@ async function Qi(e) {
|
|
|
2337
2338
|
id: "brand",
|
|
2338
2339
|
status: "fail",
|
|
2339
2340
|
message: e instanceof Error ? e.message : String(e),
|
|
2340
|
-
fix: e instanceof
|
|
2341
|
+
fix: e instanceof N && e.fix ? e.fix : "Fix the error in blazon.json, then run blazon doctor again."
|
|
2341
2342
|
} };
|
|
2342
2343
|
}
|
|
2343
2344
|
}
|
|
2344
|
-
function
|
|
2345
|
+
function Qi(e, t, n) {
|
|
2345
2346
|
let r = t.hostProblem(e);
|
|
2346
2347
|
if (!r) return {
|
|
2347
2348
|
id: "plugin-host",
|
|
2348
2349
|
status: "ok",
|
|
2349
2350
|
message: `${e} is a folder blazon will run plugins from`
|
|
2350
2351
|
};
|
|
2351
|
-
let i = /written by group or others/.test(r) ?
|
|
2352
|
+
let i = /written by group or others/.test(r) ? Ve(e) : "Run blazon from a folder under your own home folder that only you can write.";
|
|
2352
2353
|
return {
|
|
2353
2354
|
id: "plugin-host",
|
|
2354
2355
|
status: n > 0 ? "fail" : "warn",
|
|
@@ -2356,8 +2357,8 @@ function $i(e, t, n) {
|
|
|
2356
2357
|
fix: i
|
|
2357
2358
|
};
|
|
2358
2359
|
}
|
|
2359
|
-
function
|
|
2360
|
-
let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) =>
|
|
2360
|
+
function $i(e, t) {
|
|
2361
|
+
let n = [...new Set((t?.plugins ?? []).map((e) => e.name).filter((e) => Gi.includes(e)))];
|
|
2361
2362
|
return n.length === 0 ? {
|
|
2362
2363
|
id: "chrome",
|
|
2363
2364
|
status: "ok",
|
|
@@ -2373,53 +2374,53 @@ function ea(e, t) {
|
|
|
2373
2374
|
fix: "Install Google Chrome, or set BLAZON_CHROME to a Chrome or Chromium program; or take the plugin out of blazon.json."
|
|
2374
2375
|
};
|
|
2375
2376
|
}
|
|
2376
|
-
function
|
|
2377
|
-
if (!
|
|
2377
|
+
function ea(e, t) {
|
|
2378
|
+
if (!j.existsSync(A.join(e, "blazon.lock"))) return {
|
|
2378
2379
|
id: "lock",
|
|
2379
2380
|
status: "ok",
|
|
2380
2381
|
message: "no blazon.lock: this book is not pinned to a blazon build"
|
|
2381
2382
|
};
|
|
2382
|
-
let n =
|
|
2383
|
+
let n = ye(e, t.identity)[0];
|
|
2383
2384
|
return n ? {
|
|
2384
2385
|
id: "lock",
|
|
2385
2386
|
status: "fail",
|
|
2386
2387
|
message: n.message,
|
|
2387
|
-
fix: n.fix ??
|
|
2388
|
+
fix: n.fix ?? De[n.code].fix
|
|
2388
2389
|
} : {
|
|
2389
2390
|
id: "lock",
|
|
2390
2391
|
status: "ok",
|
|
2391
2392
|
message: "blazon.lock matches the blazon that is running"
|
|
2392
2393
|
};
|
|
2393
2394
|
}
|
|
2394
|
-
async function
|
|
2395
|
-
let n = await
|
|
2395
|
+
async function ta(e, t = Ji()) {
|
|
2396
|
+
let n = await Zi(e);
|
|
2396
2397
|
return [
|
|
2397
|
-
|
|
2398
|
+
Xi(t),
|
|
2398
2399
|
n.check,
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2400
|
+
Qi(e, t, n.config?.plugins?.length ?? 0),
|
|
2401
|
+
$i(t, n.config),
|
|
2402
|
+
ea(e, t)
|
|
2402
2403
|
];
|
|
2403
2404
|
}
|
|
2404
|
-
var
|
|
2405
|
+
var na = {
|
|
2405
2406
|
ok: n.green,
|
|
2406
2407
|
warn: n.yellow,
|
|
2407
2408
|
fail: n.red
|
|
2408
2409
|
};
|
|
2409
|
-
async function
|
|
2410
|
-
let r = await
|
|
2411
|
-
if (t.json) return
|
|
2410
|
+
async function ra(e = process.cwd(), t = {}) {
|
|
2411
|
+
let r = await ta(e), i = !r.some((e) => e.status === "fail");
|
|
2412
|
+
if (t.json) return Ui("doctor", i, { checks: r }), +!i;
|
|
2412
2413
|
console.log();
|
|
2413
|
-
for (let e of r) console.log(` ${
|
|
2414
|
+
for (let e of r) console.log(` ${na[e.status](e.status.padEnd(4))} ${e.id.padEnd(11)} ${e.message}`), e.status !== "ok" && e.fix && console.log(n.dim(` fix: ${e.fix}`));
|
|
2414
2415
|
return console.log(), +!i;
|
|
2415
2416
|
}
|
|
2416
2417
|
// src/core/operations/limits.ts
|
|
2417
|
-
var
|
|
2418
|
+
var ia = 4e4, X = {
|
|
2418
2419
|
readOnlyHint: !0,
|
|
2419
2420
|
destructiveHint: !1,
|
|
2420
2421
|
idempotentHint: !0,
|
|
2421
2422
|
openWorldHint: !1
|
|
2422
|
-
},
|
|
2423
|
+
}, aa = {
|
|
2423
2424
|
type: "string",
|
|
2424
2425
|
description: "The brand folder. Default: the current folder"
|
|
2425
2426
|
}, Z = (e, t) => ({
|
|
@@ -2427,7 +2428,7 @@ var aa = 4e4, X = {
|
|
|
2427
2428
|
properties: e,
|
|
2428
2429
|
...t.length > 0 && { required: t },
|
|
2429
2430
|
additionalProperties: !1
|
|
2430
|
-
}),
|
|
2431
|
+
}), oa = {
|
|
2431
2432
|
warnings: {
|
|
2432
2433
|
type: "array",
|
|
2433
2434
|
items: { type: "string" },
|
|
@@ -2448,7 +2449,7 @@ var aa = 4e4, X = {
|
|
|
2448
2449
|
}, Q = (e, t) => ({
|
|
2449
2450
|
type: "object",
|
|
2450
2451
|
properties: {
|
|
2451
|
-
...
|
|
2452
|
+
...oa,
|
|
2452
2453
|
...e
|
|
2453
2454
|
},
|
|
2454
2455
|
required: [
|
|
@@ -2457,7 +2458,7 @@ var aa = 4e4, X = {
|
|
|
2457
2458
|
...t
|
|
2458
2459
|
],
|
|
2459
2460
|
additionalProperties: {}
|
|
2460
|
-
}),
|
|
2461
|
+
}), sa = [
|
|
2461
2462
|
{
|
|
2462
2463
|
name: "check_brand",
|
|
2463
2464
|
title: "Check the brand",
|
|
@@ -2558,7 +2559,7 @@ var aa = 4e4, X = {
|
|
|
2558
2559
|
{
|
|
2559
2560
|
name: "list_tokens",
|
|
2560
2561
|
title: "List the tokens",
|
|
2561
|
-
description: `Lists the design tokens of the brand, or of one group, or of one type, each with its path, type and value, in the order the token files write them. Use it to find a path or to read many values at once. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${
|
|
2562
|
+
description: `Lists the design tokens of the brand, or of one group, or of one type, each with its path, type and value, in the order the token files write them. Use it to find a path or to read many values at once. For a token's CSS variable names and rules use get_token; for the brand's usage rules use get_rules. An answer over ${ia} characters is cut to whole tokens, and \`tokensTotal\` says how many matched: narrow with \`group\` or \`type\`.`,
|
|
2562
2563
|
annotations: X,
|
|
2563
2564
|
inputSchema: Z({
|
|
2564
2565
|
group: {
|
|
@@ -2672,7 +2673,7 @@ var aa = 4e4, X = {
|
|
|
2672
2673
|
command: ["get"],
|
|
2673
2674
|
positional: ["path", "dir"],
|
|
2674
2675
|
cliOnly: ["dir"],
|
|
2675
|
-
summary: "Read one token: its value, type, CSS variable
|
|
2676
|
+
summary: "Read one token: its value, type, CSS variable name in theme.css, its usage, pairs and logo rules, and the file it is in. To find a path, use blazon list",
|
|
2676
2677
|
options: [{
|
|
2677
2678
|
property: "json",
|
|
2678
2679
|
description: "Print the token as JSON on standard output"
|
|
@@ -2682,7 +2683,7 @@ var aa = 4e4, X = {
|
|
|
2682
2683
|
{
|
|
2683
2684
|
name: "get_rules",
|
|
2684
2685
|
title: "Read the brand rules",
|
|
2685
|
-
description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${
|
|
2686
|
+
description: `Lists the brand rules (allowed uses, approved color pairs, logo restrictions) of a token or a group of tokens, or of the whole brand when no path is given. The whole brand can be larger than the size limit (${ia} characters): give a path, or read the resource blazon://rules, which is not cut.`,
|
|
2686
2687
|
annotations: X,
|
|
2687
2688
|
inputSchema: Z({
|
|
2688
2689
|
path: {
|
|
@@ -2920,32 +2921,6 @@ var aa = 4e4, X = {
|
|
|
2920
2921
|
}]
|
|
2921
2922
|
}
|
|
2922
2923
|
},
|
|
2923
|
-
{
|
|
2924
|
-
name: "get_shadcn",
|
|
2925
|
-
title: "Read the shadcn/ui variables",
|
|
2926
|
-
description: "Gets the shadcn/ui variables the brand supplies (theme.shadcn): which token each variable takes, its value, and the variables nothing supplies. Use it when the site uses shadcn/ui. It compiles the brand when called, so it needs no build and is never out of date.",
|
|
2927
|
-
annotations: X,
|
|
2928
|
-
inputSchema: Z({}, []),
|
|
2929
|
-
outputSchema: Q({
|
|
2930
|
-
variables: {
|
|
2931
|
-
description: "Each shadcn variable the brand supplies, by name, with the token it takes, its value and where the pick came from",
|
|
2932
|
-
type: "object",
|
|
2933
|
-
propertyNames: { type: "string" },
|
|
2934
|
-
additionalProperties: {}
|
|
2935
|
-
},
|
|
2936
|
-
unsupplied: {
|
|
2937
|
-
description: "The shadcn variables nothing supplies. They are questions for the brand owner, not for a guess",
|
|
2938
|
-
type: "array",
|
|
2939
|
-
items: {}
|
|
2940
|
-
}
|
|
2941
|
-
}, []),
|
|
2942
|
-
cli: !1,
|
|
2943
|
-
mcp: {
|
|
2944
|
-
command: ["brand"],
|
|
2945
|
-
fixed: ["--key", "theme.shadcn"],
|
|
2946
|
-
json: !1
|
|
2947
|
-
}
|
|
2948
|
-
},
|
|
2949
2924
|
{
|
|
2950
2925
|
name: "get_brand",
|
|
2951
2926
|
title: "Read the whole brand",
|
|
@@ -2954,9 +2929,9 @@ var aa = 4e4, X = {
|
|
|
2954
2929
|
inputSchema: Z({
|
|
2955
2930
|
key: {
|
|
2956
2931
|
type: "string",
|
|
2957
|
-
description: "Only this part of the document, by its dotted path, such as theme.
|
|
2932
|
+
description: "Only this part of the document, by its dotted path, such as theme.roles"
|
|
2958
2933
|
},
|
|
2959
|
-
dir:
|
|
2934
|
+
dir: aa
|
|
2960
2935
|
}, []),
|
|
2961
2936
|
cli: {
|
|
2962
2937
|
rank: 7,
|
|
@@ -2967,14 +2942,14 @@ var aa = 4e4, X = {
|
|
|
2967
2942
|
options: [{
|
|
2968
2943
|
property: "key",
|
|
2969
2944
|
value: "path",
|
|
2970
|
-
description: "Print only this part of the document, by its dotted path, such as theme.
|
|
2945
|
+
description: "Print only this part of the document, by its dotted path, such as theme.roles"
|
|
2971
2946
|
}]
|
|
2972
2947
|
},
|
|
2973
2948
|
mcp: !1
|
|
2974
2949
|
}
|
|
2975
|
-
],
|
|
2950
|
+
], ca = (e) => e.filter((e) => e.mcp !== !1), la = (e) => e.filter((e) => e.cli !== !1).sort((e, t) => e.cli.rank - t.cli.rank);
|
|
2976
2951
|
// src/cli/handlers/rules.ts
|
|
2977
|
-
function
|
|
2952
|
+
function ua(e) {
|
|
2978
2953
|
let t = (e) => n.dim(`(on ${e})`);
|
|
2979
2954
|
return [
|
|
2980
2955
|
...e.role ? [`role ${e.role.value} ${t(e.role.from)}`] : [],
|
|
@@ -2984,7 +2959,7 @@ function da(e) {
|
|
|
2984
2959
|
...e.review ? [`review ${e.review.status}${e.review.by ? ` by ${e.review.by}` : ""}${e.review.at ? ` on ${e.review.at}` : ""} ${t(e.review.from)}`] : []
|
|
2985
2960
|
];
|
|
2986
2961
|
}
|
|
2987
|
-
function
|
|
2962
|
+
function da(e) {
|
|
2988
2963
|
return [
|
|
2989
2964
|
...e.role ? [`role ${e.role}`] : [],
|
|
2990
2965
|
...e.usage ? [`usage ${[e.usage.deny && `deny ${e.usage.deny.join(", ")}`, e.usage.allow && `allow ${e.usage.allow.join(", ")}`].filter(Boolean).join("; ")}`] : [],
|
|
@@ -2992,15 +2967,15 @@ function fa(e) {
|
|
|
2992
2967
|
...e.logo ? [`logo deny ${e.logo.deny.join(", ")}${e.logo.reason ? `: ${e.logo.reason}` : ""}`] : []
|
|
2993
2968
|
];
|
|
2994
2969
|
}
|
|
2995
|
-
var
|
|
2996
|
-
let { data: r } = await
|
|
2970
|
+
var fa = async ({ path: e }, { dir: t }) => {
|
|
2971
|
+
let { data: r } = await Y(t), i = di(e ?? ""), a = i !== "" && r.tokens.byPath.has(i), o = Hi(() => a ? {
|
|
2997
2972
|
path: i,
|
|
2998
2973
|
kind: "token",
|
|
2999
|
-
rules:
|
|
2974
|
+
rules: bi(r, fi(r, i))
|
|
3000
2975
|
} : {
|
|
3001
2976
|
path: i,
|
|
3002
2977
|
kind: i === "" ? "brand" : "group",
|
|
3003
|
-
entries:
|
|
2978
|
+
entries: Si(r, i)
|
|
3004
2979
|
});
|
|
3005
2980
|
return {
|
|
3006
2981
|
command: "rules",
|
|
@@ -3009,53 +2984,52 @@ var pa = async ({ path: e }, { dir: t }) => {
|
|
|
3009
2984
|
body: o,
|
|
3010
2985
|
text: () => {
|
|
3011
2986
|
if (console.log(), o.kind === "token") {
|
|
3012
|
-
let e =
|
|
2987
|
+
let e = ua(o.rules);
|
|
3013
2988
|
console.log(` ${n.bold(o.path)}`), e.length === 0 && console.log(n.dim(" no rules apply to this token"));
|
|
3014
2989
|
for (let t of e) console.log(` ${t}`);
|
|
3015
2990
|
} else {
|
|
3016
2991
|
o.entries.length === 0 && console.log(n.dim(` No rules are written ${i === "" ? "in this brand" : `at or under ${i}`}.`));
|
|
3017
2992
|
for (let e of o.entries) {
|
|
3018
2993
|
console.log(` ${n.bold(e.at)} ${n.dim(e.kind === "group" ? "group" : "token")}${e.inherited ? n.dim(", passes its rules down") : ""}`);
|
|
3019
|
-
for (let t of
|
|
2994
|
+
for (let t of da(e)) console.log(` ${t}`);
|
|
3020
2995
|
}
|
|
3021
2996
|
}
|
|
3022
2997
|
console.log();
|
|
3023
2998
|
}
|
|
3024
2999
|
};
|
|
3025
|
-
},
|
|
3026
|
-
let { data: n } = await
|
|
3027
|
-
if (
|
|
3028
|
-
let r =
|
|
3000
|
+
}, pa = async ({ path: e }, { dir: t }) => {
|
|
3001
|
+
let { data: n } = await Y(t);
|
|
3002
|
+
if (Ei(n, String(e))) throw new P(`"${String(e)}" is a group of tokens, not one token; \`blazon list ${String(e)}\` lists its tokens.`, void 0, "not-a-token");
|
|
3003
|
+
let r = Hi(() => wi(n, String(e)));
|
|
3029
3004
|
return {
|
|
3030
3005
|
command: "get",
|
|
3031
3006
|
passed: !0,
|
|
3032
3007
|
status: 0,
|
|
3033
3008
|
body: { token: r },
|
|
3034
|
-
text: () =>
|
|
3009
|
+
text: () => ma(r)
|
|
3035
3010
|
};
|
|
3036
3011
|
};
|
|
3037
|
-
function
|
|
3012
|
+
function ma(e) {
|
|
3038
3013
|
let { names: t } = e;
|
|
3039
|
-
console.log(`\n ${n.bold(e.path)}${e.deprecated ? n.yellow(" deprecated") : ""}`),
|
|
3014
|
+
console.log(`\n ${n.bold(e.path)}${e.deprecated ? n.yellow(" deprecated") : ""}`), Wi([
|
|
3040
3015
|
["value", String(e.value)],
|
|
3041
3016
|
["type", e.type],
|
|
3042
3017
|
["alias of", e.aliasOf && `{${e.aliasOf}}`],
|
|
3043
3018
|
["tier", e.tier],
|
|
3044
3019
|
["about", e.description],
|
|
3045
3020
|
["theme.css", [t.theme.variable, ...Object.values(t.theme.parts ?? {})].join(", ")],
|
|
3046
|
-
["tailwind.css", t.tailwind ? `${t.tailwind.variable}${t.tailwind.shadowedBy ? ` (taken by {${t.tailwind.shadowedBy}}, which is written first)` : ""}` : "none: no Tailwind namespace for this token"],
|
|
3047
3021
|
["typography.css", t.typographyClass && `.${t.typographyClass}`],
|
|
3048
3022
|
["written in", e.sourceFile]
|
|
3049
3023
|
]);
|
|
3050
3024
|
for (let t of e.contexts ?? []) console.log(` ${n.dim(`${t.modifier}=${t.context}`.padEnd(12))} ${String(t.value)} ${n.dim(t.selector)}`);
|
|
3051
|
-
let r =
|
|
3025
|
+
let r = ua(e.rules);
|
|
3052
3026
|
console.log(`\n ${n.bold("Rules")}`), r.length === 0 && console.log(n.dim(" none written for this token"));
|
|
3053
3027
|
for (let e of r) console.log(` ${e}`);
|
|
3054
3028
|
console.log();
|
|
3055
3029
|
}
|
|
3056
3030
|
// src/cli/handlers/list.ts
|
|
3057
|
-
var
|
|
3058
|
-
let { data: r } = await
|
|
3031
|
+
var ha = async ({ group: e, type: t }, { dir: n }) => {
|
|
3032
|
+
let { data: r } = await Y(n), i = Hi(() => Di(r, {
|
|
3059
3033
|
group: e,
|
|
3060
3034
|
type: t
|
|
3061
3035
|
}));
|
|
@@ -3068,10 +3042,10 @@ var ga = async ({ group: e, type: t }, { dir: n }) => {
|
|
|
3068
3042
|
...i.type && { type: i.type },
|
|
3069
3043
|
tokens: i.tokens
|
|
3070
3044
|
},
|
|
3071
|
-
text: () =>
|
|
3045
|
+
text: () => ga(i)
|
|
3072
3046
|
};
|
|
3073
3047
|
};
|
|
3074
|
-
function
|
|
3048
|
+
function ga(e) {
|
|
3075
3049
|
if (e.tokens.length === 0) return console.log(n.dim(`\n no tokens${e.type ? ` of type ${e.type}` : ""}${e.group ? ` in ${e.group}` : ""}\n`));
|
|
3076
3050
|
let t = Math.max(...e.tokens.map((e) => e.path.length)), r = Math.max(...e.tokens.map((e) => (e.type ?? "").length)), i;
|
|
3077
3051
|
for (let a of e.tokens) {
|
|
@@ -3083,17 +3057,17 @@ function _a(e) {
|
|
|
3083
3057
|
console.log(`\n ${n.dim(`${e.tokens.length} token${e.tokens.length === 1 ? "" : "s"}; blazon get <path> shows one in full`)}\n`);
|
|
3084
3058
|
}
|
|
3085
3059
|
// src/cli/handlers/can.ts
|
|
3086
|
-
var
|
|
3087
|
-
let { data: a } = await
|
|
3060
|
+
var _a = async ({ fg: e, bg: t, role: n, theme: r }, { dir: i }) => {
|
|
3061
|
+
let { data: a } = await Y(i), o = Hi(() => Ri(a, e, t, n ?? "text", r));
|
|
3088
3062
|
return {
|
|
3089
3063
|
command: "can",
|
|
3090
3064
|
passed: o.allowed,
|
|
3091
3065
|
status: +!o.allowed,
|
|
3092
3066
|
body: o,
|
|
3093
|
-
text: () =>
|
|
3067
|
+
text: () => va(o)
|
|
3094
3068
|
};
|
|
3095
3069
|
};
|
|
3096
|
-
function
|
|
3070
|
+
function va(e) {
|
|
3097
3071
|
if (console.log(`\n ${e.allowed ? n.green("allowed") : n.red("denied")} ${e.fg} as ${e.role === "ui" ? "a non-text element (--role ui)" : "text"} on ${e.bg}${e.theme ? ` (theme ${e.theme})` : ""}`), console.log(` ${e.reason}`), e.checks.length > 1) {
|
|
3098
3072
|
console.log();
|
|
3099
3073
|
for (let t of e.checks) console.log(` ${t.rule === "contrast" && e.role === "text" ? n.dim("info") : t.ok ? n.green("ok ") : n.red("no ")} ${t.message}`);
|
|
@@ -3101,11 +3075,11 @@ function ya(e) {
|
|
|
3101
3075
|
console.log();
|
|
3102
3076
|
}
|
|
3103
3077
|
// src/cli/handlers/fonts.ts
|
|
3104
|
-
var
|
|
3105
|
-
let { config: n, data: r } = await
|
|
3078
|
+
var ya = async (e, { dir: t }) => {
|
|
3079
|
+
let { config: n, data: r } = await Y(t), i = zi(r, n, t);
|
|
3106
3080
|
if (e.css === !0 || typeof e.base == "string") {
|
|
3107
|
-
if (e.css !== !0) throw new
|
|
3108
|
-
let t =
|
|
3081
|
+
if (e.css !== !0) throw new P("blazon fonts: --base goes with --css.", "Add --css, or leave --base out.", "conflicting-options");
|
|
3082
|
+
let t = Bi(i, typeof e.base == "string" ? e.base : void 0);
|
|
3109
3083
|
return {
|
|
3110
3084
|
command: "fonts",
|
|
3111
3085
|
passed: !0,
|
|
@@ -3122,10 +3096,10 @@ var ba = async (e, { dir: t }) => {
|
|
|
3122
3096
|
passed: !0,
|
|
3123
3097
|
status: 0,
|
|
3124
3098
|
body: i,
|
|
3125
|
-
text: () =>
|
|
3099
|
+
text: () => ba(i)
|
|
3126
3100
|
};
|
|
3127
3101
|
};
|
|
3128
|
-
function
|
|
3102
|
+
function ba(e) {
|
|
3129
3103
|
console.log(`\n ${n.bold("Loaded")}`), e.stylesheets.length + e.files.length === 0 && console.log(n.dim(" The config lists no fonts."));
|
|
3130
3104
|
for (let t of e.stylesheets) console.log(` stylesheet ${t}`);
|
|
3131
3105
|
for (let t of e.files) console.log(` file ${t.file} ${t.family}${t.weight === void 0 ? "" : `, weight ${t.weight}`}${t.style ? `, ${t.style}` : ""}`);
|
|
@@ -3142,17 +3116,17 @@ var $ = (e) => {
|
|
|
3142
3116
|
if (typeof e != "object" || !e) return String(e);
|
|
3143
3117
|
let t = e;
|
|
3144
3118
|
return t.units === void 0 ? t.value === void 0 ? [t.width !== void 0 && `width ${$(t.width)}`, t.height !== void 0 && `height ${$(t.height)}`].filter(Boolean).join(", ") : `${t.value}${t.unit}` : `${t.units} unit${t.units === 1 ? "" : "s"}`;
|
|
3145
|
-
},
|
|
3146
|
-
let { config: n, data: r } = await
|
|
3119
|
+
}, xa = async (e, { dir: t }) => {
|
|
3120
|
+
let { config: n, data: r } = await Y(t), i = Vi(r, n, t);
|
|
3147
3121
|
return {
|
|
3148
3122
|
command: "logo",
|
|
3149
3123
|
passed: !0,
|
|
3150
3124
|
status: 0,
|
|
3151
3125
|
body: i,
|
|
3152
|
-
text: () =>
|
|
3126
|
+
text: () => Sa(i)
|
|
3153
3127
|
};
|
|
3154
3128
|
};
|
|
3155
|
-
function
|
|
3129
|
+
function Sa(e) {
|
|
3156
3130
|
console.log(`\n ${n.bold("Variants")}`), e.variants.length === 0 && console.log(n.dim(" No logo is configured."));
|
|
3157
3131
|
for (let t of e.variants) console.log(` ${t.variant.padEnd(8)} ${t.file}${t.found ? "" : n.red(" (not found)")}${t.ink ? ` ink ${t.ink}` : ""}${t.asset ? n.dim(` ${t.asset}`) : ""}`);
|
|
3158
3132
|
for (let t of e.assets) {
|
|
@@ -3182,7 +3156,7 @@ function Ca(e) {
|
|
|
3182
3156
|
console.log();
|
|
3183
3157
|
}
|
|
3184
3158
|
// src/cli/handlers/brand.ts
|
|
3185
|
-
function
|
|
3159
|
+
function Ca(e, t) {
|
|
3186
3160
|
let n = e;
|
|
3187
3161
|
for (let e of t.split(".")) {
|
|
3188
3162
|
if (typeof n != "object" || !n || !Object.prototype.hasOwnProperty.call(n, e)) return;
|
|
@@ -3191,16 +3165,16 @@ function wa(e, t) {
|
|
|
3191
3165
|
return n;
|
|
3192
3166
|
}
|
|
3193
3167
|
// src/cli/handlers/index.ts
|
|
3194
|
-
var
|
|
3195
|
-
get_token:
|
|
3196
|
-
list_tokens:
|
|
3197
|
-
get_rules:
|
|
3198
|
-
can_use:
|
|
3199
|
-
get_fonts:
|
|
3200
|
-
get_logo:
|
|
3168
|
+
var wa = {
|
|
3169
|
+
get_token: pa,
|
|
3170
|
+
list_tokens: ha,
|
|
3171
|
+
get_rules: fa,
|
|
3172
|
+
can_use: _a,
|
|
3173
|
+
get_fonts: ya,
|
|
3174
|
+
get_logo: xa,
|
|
3201
3175
|
get_brand: async ({ key: e }, { dir: t }) => {
|
|
3202
|
-
let { config: n, data: r } = await
|
|
3203
|
-
if (a === void 0) throw new
|
|
3176
|
+
let { config: n, data: r } = await Y(t), i = Le(r, n, t), a = e === void 0 ? i : Ca(i, e);
|
|
3177
|
+
if (a === void 0) throw new P(`brand.json has no "${String(e)}". Run blazon brand without --key to see the keys.`, void 0, "unknown-key");
|
|
3204
3178
|
return {
|
|
3205
3179
|
command: "brand",
|
|
3206
3180
|
passed: !0,
|
|
@@ -3209,21 +3183,21 @@ var Ta = {
|
|
|
3209
3183
|
text: () => void process.stdout.write(`${JSON.stringify(a, null, 2)}\n`)
|
|
3210
3184
|
};
|
|
3211
3185
|
}
|
|
3212
|
-
},
|
|
3213
|
-
function
|
|
3214
|
-
let t =
|
|
3186
|
+
}, Ta = (e) => e.cli, Ea = (e) => e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`), Da = la(sa).filter((e) => Ta(e).options.some((e) => e.property === "json")).map((e) => Ta(e).command[0]);
|
|
3187
|
+
function Oa(e) {
|
|
3188
|
+
let t = Ta(e), n = new Set(e.inputSchema.required ?? []);
|
|
3215
3189
|
return [...t.command, ...t.positional.map((e) => n.has(e) ? `<${e}>` : `[${e}]`)].join(" ");
|
|
3216
3190
|
}
|
|
3217
|
-
function
|
|
3218
|
-
return t.property === "json" ? "--json" : e.inputSchema.properties[t.property]?.type === "boolean" ? `--${
|
|
3191
|
+
function ka(e, t) {
|
|
3192
|
+
return t.property === "json" ? "--json" : e.inputSchema.properties[t.property]?.type === "boolean" ? `--${Ea(t.property)}` : `--${Ea(t.property)} <${t.value ?? Ea(t.property)}>`;
|
|
3219
3193
|
}
|
|
3220
|
-
var
|
|
3221
|
-
function
|
|
3222
|
-
for (let n of
|
|
3223
|
-
let r =
|
|
3194
|
+
var Aa = (e) => typeof e == "string" && /^\.|[\\/]/.test(e) && !!j.statSync(e, { throwIfNoEntry: !1 })?.isDirectory();
|
|
3195
|
+
function ja(e, t) {
|
|
3196
|
+
for (let n of la(sa)) {
|
|
3197
|
+
let r = Ta(n), i = wa[n.name];
|
|
3224
3198
|
if (!i) throw Error(`operation ${n.name} has a command and no handler`);
|
|
3225
|
-
let a = e.command(
|
|
3226
|
-
for (let e of r.options) a.option(
|
|
3199
|
+
let a = e.command(Oa(n), r.summary);
|
|
3200
|
+
for (let e of r.options) a.option(ka(n, e), e.description);
|
|
3227
3201
|
a.action(async (...e) => {
|
|
3228
3202
|
let n = e.pop() ?? {};
|
|
3229
3203
|
try {
|
|
@@ -3231,20 +3205,20 @@ function Ma(e, t) {
|
|
|
3231
3205
|
r.positional.forEach((n, r) => t[n] = e[r]);
|
|
3232
3206
|
for (let e of r.options) e.property !== "json" && (t[e.property] = n[e.property]);
|
|
3233
3207
|
let a = t.dir;
|
|
3234
|
-
r.folder !== void 0 && a === void 0 &&
|
|
3208
|
+
r.folder !== void 0 && a === void 0 && Aa(t[r.folder]) && (a = t[r.folder], t[r.folder] = void 0), delete t.dir;
|
|
3235
3209
|
let o = await i(t, { dir: a ? String(a) : process.cwd() });
|
|
3236
|
-
n.json ?
|
|
3210
|
+
n.json ? Ui(o.command, o.passed, o.body) : o.text(), process.exitCode = o.status;
|
|
3237
3211
|
} catch (e) {
|
|
3238
|
-
|
|
3212
|
+
I(r.command.join(" "), e, t);
|
|
3239
3213
|
}
|
|
3240
3214
|
});
|
|
3241
3215
|
}
|
|
3242
3216
|
}
|
|
3243
3217
|
// src/cli/commands/mcp-check.ts
|
|
3244
|
-
var
|
|
3245
|
-
function
|
|
3246
|
-
let t =
|
|
3247
|
-
return
|
|
3218
|
+
var Ma = 3e4, Na = "This check starts blazon-mcp on the brand folder. The server runs blazon with no plugin and a limited environment, and reads the brand files as data. What the brand says reaches your agent as tool results, so check only a brand folder you trust.", Pa = "npm ci && npm run build -w mcp", Fa = () => ca(sa).map((e) => e.name);
|
|
3219
|
+
function Ia(e) {
|
|
3220
|
+
let t = A.join(e, "mcp/dist/index.js");
|
|
3221
|
+
return j.existsSync(t) ? {
|
|
3248
3222
|
name: "built",
|
|
3249
3223
|
passed: !0,
|
|
3250
3224
|
detail: `${t} exists`,
|
|
@@ -3253,26 +3227,26 @@ function La(e) {
|
|
|
3253
3227
|
name: "built",
|
|
3254
3228
|
passed: !1,
|
|
3255
3229
|
detail: `${t} does not exist: blazon-mcp is not built`,
|
|
3256
|
-
fix: `cd ${e} && ${
|
|
3230
|
+
fix: `cd ${e} && ${Pa}`,
|
|
3257
3231
|
entry: t
|
|
3258
3232
|
};
|
|
3259
3233
|
}
|
|
3260
|
-
var
|
|
3234
|
+
var La = (e) => {
|
|
3261
3235
|
try {
|
|
3262
|
-
return
|
|
3236
|
+
return j.statSync(e).isFile() ? (j.accessSync(e, j.constants.X_OK), !0) : !1;
|
|
3263
3237
|
} catch {
|
|
3264
3238
|
return !1;
|
|
3265
3239
|
}
|
|
3266
3240
|
};
|
|
3267
|
-
function
|
|
3268
|
-
let n = (t.PATH ?? "").split(
|
|
3269
|
-
for (let e of n) for (let t of r) if (
|
|
3241
|
+
function Ra(e, t) {
|
|
3242
|
+
let n = (t.PATH ?? "").split(A.delimiter).filter(Boolean), r = process.platform === "win32" ? ["", ...(t.PATHEXT ?? ".EXE;.CMD").split(";")].map((t) => e + t) : [e];
|
|
3243
|
+
for (let e of n) for (let t of r) if (La(A.join(e, t))) return A.join(e, t);
|
|
3270
3244
|
}
|
|
3271
|
-
function
|
|
3272
|
-
let r =
|
|
3245
|
+
function za(e, t, n) {
|
|
3246
|
+
let r = A.join(n, "bin/blazon.js"), i = j.existsSync(r) ? j.existsSync(A.join(n, "dist/cli/index.js")) ? `export BLAZON_BIN=${r}` : `cd ${n} && npm run build && export BLAZON_BIN=${r}` : "put the blazon program on PATH, or export BLAZON_BIN=<path to the blazon executable>", a = e.BLAZON_BIN;
|
|
3273
3247
|
if (a) {
|
|
3274
|
-
let n = a.includes("/") || a.includes(
|
|
3275
|
-
return n &&
|
|
3248
|
+
let n = a.includes("/") || a.includes(A.sep) ? A.resolve(t, a) : Ra(a, e);
|
|
3249
|
+
return n && La(n) ? {
|
|
3276
3250
|
name: "blazon",
|
|
3277
3251
|
passed: !0,
|
|
3278
3252
|
detail: `BLAZON_BIN names ${n}`,
|
|
@@ -3286,7 +3260,7 @@ function Ba(e, t, n) {
|
|
|
3286
3260
|
source: "BLAZON_BIN"
|
|
3287
3261
|
};
|
|
3288
3262
|
}
|
|
3289
|
-
let o =
|
|
3263
|
+
let o = Ra("blazon", e);
|
|
3290
3264
|
return o ? {
|
|
3291
3265
|
name: "blazon",
|
|
3292
3266
|
passed: !0,
|
|
@@ -3301,12 +3275,12 @@ function Ba(e, t, n) {
|
|
|
3301
3275
|
source: "none"
|
|
3302
3276
|
};
|
|
3303
3277
|
}
|
|
3304
|
-
var
|
|
3278
|
+
var Ba = (e, t = 200) => {
|
|
3305
3279
|
let n = e.trim().split("\n").find((e) => e.trim() !== "") ?? "";
|
|
3306
3280
|
return n.length > t ? `${n.slice(0, t)}...` : n;
|
|
3307
3281
|
};
|
|
3308
|
-
async function
|
|
3309
|
-
let { entry: t, brand: n, env: r = process.env, timeoutMs: i =
|
|
3282
|
+
async function Va(e) {
|
|
3283
|
+
let { entry: t, brand: n, env: r = process.env, timeoutMs: i = Ma, expect: a = Fa() } = e, o = process.platform !== "win32", s = qe(process.execPath, [
|
|
3310
3284
|
t,
|
|
3311
3285
|
"--brand",
|
|
3312
3286
|
n
|
|
@@ -3338,7 +3312,7 @@ async function Ha(e) {
|
|
|
3338
3312
|
m = setTimeout(() => {
|
|
3339
3313
|
p = !0, t(/* @__PURE__ */ Error(`no answer within ${i / 1e3} s`));
|
|
3340
3314
|
}, i);
|
|
3341
|
-
}), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${
|
|
3315
|
+
}), g = new Promise((e, t) => s.once("close", (e) => t(/* @__PURE__ */ Error(`the server exited (${e ?? "signal"}) before it answered${c ? `: ${Ba(c)}` : ""}`))));
|
|
3342
3316
|
g.catch(() => void 0), h.catch(() => void 0), u.catch(() => void 0);
|
|
3343
3317
|
let _ = 0, v = (e, t) => {
|
|
3344
3318
|
let n = ++_, r = new Promise((e) => d.set(n, e));
|
|
@@ -3363,7 +3337,7 @@ async function Ha(e) {
|
|
|
3363
3337
|
version: "0"
|
|
3364
3338
|
}
|
|
3365
3339
|
});
|
|
3366
|
-
if (e.error) throw Error(`initialize was refused: ${
|
|
3340
|
+
if (e.error) throw Error(`initialize was refused: ${Ba(e.error.message ?? "")}`);
|
|
3367
3341
|
s.stdin.write(`${JSON.stringify({
|
|
3368
3342
|
jsonrpc: "2.0",
|
|
3369
3343
|
method: "notifications/initialized"
|
|
@@ -3372,8 +3346,8 @@ async function Ha(e) {
|
|
|
3372
3346
|
if (t.error || r.length > 0) return {
|
|
3373
3347
|
name: "handshake",
|
|
3374
3348
|
passed: !1,
|
|
3375
|
-
detail: t.error ? `tools/list failed: ${
|
|
3376
|
-
fix: `cd ${
|
|
3349
|
+
detail: t.error ? `tools/list failed: ${Ba(t.error.message ?? "")}` : `tools/list answered ${n.length} tool(s); missing ${r.join(", ")}`,
|
|
3350
|
+
fix: `cd ${Te()} && ${Pa} (the build is older than this blazon), then run this check again`,
|
|
3377
3351
|
tools: n
|
|
3378
3352
|
};
|
|
3379
3353
|
let i = Date.now(), o = await v("tools/call", {
|
|
@@ -3383,7 +3357,7 @@ async function Ha(e) {
|
|
|
3383
3357
|
if (o.error || o.result?.isError) return {
|
|
3384
3358
|
name: "handshake",
|
|
3385
3359
|
passed: !1,
|
|
3386
|
-
detail: `check_brand failed: ${
|
|
3360
|
+
detail: `check_brand failed: ${Ba(o.error?.message ?? l)}`,
|
|
3387
3361
|
fix: "run blazon check in the brand folder, and make sure the blazon program and the brand folder are the ones the server uses",
|
|
3388
3362
|
tools: n,
|
|
3389
3363
|
ms: c
|
|
@@ -3402,14 +3376,14 @@ async function Ha(e) {
|
|
|
3402
3376
|
name: "handshake",
|
|
3403
3377
|
passed: !1,
|
|
3404
3378
|
detail: `the handshake did not finish: ${e instanceof Error ? e.message : String(e)}${p ? "; the server was killed" : ""}`,
|
|
3405
|
-
fix: `cd ${
|
|
3379
|
+
fix: `cd ${Te()} && ${Pa}, then run this check again; on a hang, run the server by hand: node ${t} --brand ${n}`,
|
|
3406
3380
|
ms: Date.now() - y
|
|
3407
3381
|
};
|
|
3408
3382
|
} finally {
|
|
3409
|
-
clearTimeout(m), await
|
|
3383
|
+
clearTimeout(m), await Ha(s, l, o);
|
|
3410
3384
|
}
|
|
3411
3385
|
}
|
|
3412
|
-
async function
|
|
3386
|
+
async function Ha(e, t, n) {
|
|
3413
3387
|
let r = (t) => {
|
|
3414
3388
|
try {
|
|
3415
3389
|
n && e.pid !== void 0 ? process.kill(-e.pid, t) : e.kill(t);
|
|
@@ -3423,16 +3397,16 @@ async function Ua(e, t, n) {
|
|
|
3423
3397
|
let i;
|
|
3424
3398
|
await Promise.race([t, new Promise((e) => i = setTimeout(e, 2e3))]), clearTimeout(i), e.exitCode === null && e.signalCode === null ? (r("SIGKILL"), await t) : r("SIGKILL");
|
|
3425
3399
|
}
|
|
3426
|
-
function
|
|
3427
|
-
let i =
|
|
3400
|
+
function Ua(e, t, n, r = Je.homedir()) {
|
|
3401
|
+
let i = ze(e, t, r, process.platform, process.env.APPDATA), a = [], o = [], s = [];
|
|
3428
3402
|
for (let e of i) {
|
|
3429
3403
|
let t;
|
|
3430
3404
|
try {
|
|
3431
|
-
t =
|
|
3405
|
+
t = j.readFileSync(e.path, "utf8");
|
|
3432
3406
|
} catch {
|
|
3433
3407
|
continue;
|
|
3434
3408
|
}
|
|
3435
|
-
let n =
|
|
3409
|
+
let n = de(t, e);
|
|
3436
3410
|
n === void 0 ? s.push(e.path) : (o.push(e.path), n.includes("blazon") && a.push(e.path));
|
|
3437
3411
|
}
|
|
3438
3412
|
let c = s.length > 0 ? ` (not valid JSON, skipped: ${s.join(", ")})` : "", l = `blazon mcp --print-config --client ${e} --brand ${n}`;
|
|
@@ -3453,8 +3427,8 @@ function Wa(e, t, n, r = Ze.homedir()) {
|
|
|
3453
3427
|
files: []
|
|
3454
3428
|
};
|
|
3455
3429
|
}
|
|
3456
|
-
async function
|
|
3457
|
-
let { client: t, brand: r, env: i = process.env, cwd: a = process.cwd(), home: o =
|
|
3430
|
+
async function Wa(e) {
|
|
3431
|
+
let { client: t, brand: r, env: i = process.env, cwd: a = process.cwd(), home: o = Je.homedir() } = e, s = Te(), c = Ia(s), l = za(i, r, s), u = c.passed ? await Va({
|
|
3458
3432
|
entry: c.entry,
|
|
3459
3433
|
brand: r,
|
|
3460
3434
|
env: i,
|
|
@@ -3464,22 +3438,22 @@ async function Ga(e) {
|
|
|
3464
3438
|
passed: !1,
|
|
3465
3439
|
detail: "not run: the server is not built",
|
|
3466
3440
|
fix: c.fix
|
|
3467
|
-
}, d =
|
|
3441
|
+
}, d = Ua(t, [.../* @__PURE__ */ new Set([a, r])], r, o), { entry: f, ...p } = c, m = [
|
|
3468
3442
|
p,
|
|
3469
3443
|
l,
|
|
3470
3444
|
u,
|
|
3471
3445
|
d
|
|
3472
3446
|
], h = m.filter((e) => !e.advisory).every((e) => e.passed);
|
|
3473
|
-
if (e.json) return
|
|
3447
|
+
if (e.json) return Ui("mcp", h, {
|
|
3474
3448
|
mode: "check",
|
|
3475
3449
|
client: t,
|
|
3476
3450
|
brand: r,
|
|
3477
3451
|
runsPlugins: !1,
|
|
3478
|
-
trust:
|
|
3452
|
+
trust: Na,
|
|
3479
3453
|
registered: d.passed,
|
|
3480
3454
|
checks: m
|
|
3481
3455
|
}), +!h;
|
|
3482
|
-
console.log(`\n ${n.bold(`blazon-mcp for ${t}, brand ${r}`)}\n ${n.yellow(
|
|
3456
|
+
console.log(`\n ${n.bold(`blazon-mcp for ${t}, brand ${r}`)}\n ${n.yellow(Na)}\n`);
|
|
3483
3457
|
for (let e of m) {
|
|
3484
3458
|
let t = e.passed ? n.green("ok ") : e.advisory ? n.yellow("finding") : n.red("fail ");
|
|
3485
3459
|
console.log(` ${t} ${e.name.padEnd(10)} ${e.detail}`), !e.passed && e.fix && console.log(` ${" ".repeat(7)} ${" ".repeat(10)} ${n.dim("fix:")} ${e.fix}`);
|
|
@@ -3487,23 +3461,23 @@ async function Ga(e) {
|
|
|
3487
3461
|
return console.log(`\n ${h ? n.green("The server is ready.") : n.red("The server is not ready.")}${d.passed ? "" : " It is not registered in this client yet (a finding, not a failure)."}\n`), +!h;
|
|
3488
3462
|
}
|
|
3489
3463
|
// src/cli/commands/mcp.ts
|
|
3490
|
-
async function
|
|
3491
|
-
if (e.printConfig && e.check) throw new
|
|
3492
|
-
if (!e.printConfig && !e.check) throw new
|
|
3464
|
+
async function Ga(e = {}) {
|
|
3465
|
+
if (e.printConfig && e.check) throw new P("give --print-config or --check, not both. See blazon mcp --help.", void 0, "conflicting-options");
|
|
3466
|
+
if (!e.printConfig && !e.check) throw new P("give --print-config to print the config that registers blazon-mcp in a client, or --check to test that it works; neither writes a file. See blazon mcp --help.", void 0, "missing-argument");
|
|
3493
3467
|
let t = e.client === void 0 ? "claude-code" : e.client;
|
|
3494
|
-
if (e.client !== void 0 && !
|
|
3495
|
-
let r = e.brand === void 0 ? void 0 :
|
|
3468
|
+
if (e.client !== void 0 && !we(e.client)) throw new P(`unknown client "${e.client}"; the clients are ${Fe.join(", ")}.`, void 0, "invalid-option-value");
|
|
3469
|
+
let r = e.brand === void 0 ? void 0 : A.resolve(process.cwd(), e.brand);
|
|
3496
3470
|
if (e.check) {
|
|
3497
3471
|
let n = r ?? process.cwd();
|
|
3498
|
-
if (!
|
|
3499
|
-
return
|
|
3472
|
+
if (!j.statSync(n, { throwIfNoEntry: !1 })?.isDirectory()) throw new P(`the brand folder ${n} does not exist.`, void 0, "no-folder");
|
|
3473
|
+
return Wa({
|
|
3500
3474
|
client: t,
|
|
3501
3475
|
brand: n,
|
|
3502
3476
|
...e.json && { json: !0 }
|
|
3503
3477
|
});
|
|
3504
3478
|
}
|
|
3505
|
-
let i =
|
|
3506
|
-
if (e.json) return
|
|
3479
|
+
let i = ue(t, pe(), r);
|
|
3480
|
+
if (e.json) return Ui("mcp", !0, {
|
|
3507
3481
|
client: t,
|
|
3508
3482
|
built: i.built,
|
|
3509
3483
|
...r && { brand: r },
|
|
@@ -3515,8 +3489,8 @@ async function Ka(e = {}) {
|
|
|
3515
3489
|
return i.note && console.log(`\n ${n.yellow(i.note)}`), console.log(""), 0;
|
|
3516
3490
|
}
|
|
3517
3491
|
// src/cli/commands/explain.ts
|
|
3518
|
-
function
|
|
3519
|
-
let t =
|
|
3492
|
+
function Ka(e) {
|
|
3493
|
+
let t = De[e], n = Ee(e);
|
|
3520
3494
|
return {
|
|
3521
3495
|
code: e,
|
|
3522
3496
|
severity: t.severity,
|
|
@@ -3527,27 +3501,27 @@ function qa(e) {
|
|
|
3527
3501
|
manual: t.manual
|
|
3528
3502
|
};
|
|
3529
3503
|
}
|
|
3530
|
-
function
|
|
3504
|
+
function qa(e) {
|
|
3531
3505
|
let [t = "", n] = e.split("#");
|
|
3532
3506
|
return `RFC ${t.padStart(4, "0")}${n ? `, section ${n}` : ""}`;
|
|
3533
3507
|
}
|
|
3534
|
-
function
|
|
3535
|
-
let t = Object.keys(
|
|
3508
|
+
function Ja(e) {
|
|
3509
|
+
let t = Object.keys(De), n = [];
|
|
3536
3510
|
for (let r = 0; r < 3; r++) {
|
|
3537
|
-
let r =
|
|
3511
|
+
let r = E(e, t);
|
|
3538
3512
|
if (r === void 0) break;
|
|
3539
3513
|
n.push(r), t.splice(t.indexOf(r), 1);
|
|
3540
3514
|
}
|
|
3541
3515
|
return n;
|
|
3542
3516
|
}
|
|
3543
|
-
function
|
|
3517
|
+
function Ya(e) {
|
|
3544
3518
|
let t = e.severity === "error" ? n.red : e.severity === "warning" ? n.yellow : n.dim;
|
|
3545
|
-
console.log(`\n ${n.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${n.bold("Fix")} ${e.fix}`), console.log(`\n ${n.bold("Read")} docs/manual/${e.manual}.md, ${
|
|
3519
|
+
console.log(`\n ${n.bold(e.code)} ${t(e.severity)}\n`), console.log(` ${e.summary}`), e.fix !== void 0 && console.log(`\n ${n.bold("Fix")} ${e.fix}`), console.log(`\n ${n.bold("Read")} docs/manual/${e.manual}.md, ${qa(e.rfc)}\n`);
|
|
3546
3520
|
}
|
|
3547
|
-
function
|
|
3521
|
+
function Xa(e, t = {}) {
|
|
3548
3522
|
if (e === void 0) {
|
|
3549
|
-
let e = Object.keys(
|
|
3550
|
-
if (t.json)
|
|
3523
|
+
let e = Object.keys(De).sort().map((e) => Ka(e));
|
|
3524
|
+
if (t.json) Ui("explain", !0, { codes: e });
|
|
3551
3525
|
else {
|
|
3552
3526
|
let t = Math.max(...e.map((e) => e.code.length));
|
|
3553
3527
|
console.log();
|
|
@@ -3556,42 +3530,42 @@ function Za(e, t = {}) {
|
|
|
3556
3530
|
}
|
|
3557
3531
|
return 0;
|
|
3558
3532
|
}
|
|
3559
|
-
if (!Object.hasOwn(
|
|
3560
|
-
let t =
|
|
3561
|
-
throw new
|
|
3533
|
+
if (!Object.hasOwn(De, e)) {
|
|
3534
|
+
let t = Ja(e);
|
|
3535
|
+
throw new P(`unknown code "${e}"`, t.length > 0 ? `Did you mean ${t.map((e) => `"${e}"`).join(", ")}? Run blazon explain to list every code.` : "Run blazon explain to list every code.", "unknown-finding-code");
|
|
3562
3536
|
}
|
|
3563
|
-
let n =
|
|
3564
|
-
return t.json ?
|
|
3537
|
+
let n = Ka(e);
|
|
3538
|
+
return t.json ? Ui("explain", !0, n) : Ya(n), 0;
|
|
3565
3539
|
}
|
|
3566
3540
|
// src/cli/options.ts
|
|
3567
|
-
var
|
|
3541
|
+
var Za = (e) => {
|
|
3568
3542
|
if (e.length === 1) return [`-${e}`];
|
|
3569
3543
|
let t = e.replace(/[A-Z]/g, (e) => `-${e.toLowerCase()}`);
|
|
3570
3544
|
return t === e ? [`--${e}`] : [`--${e}`, `--${t}`];
|
|
3571
3545
|
};
|
|
3572
|
-
function
|
|
3546
|
+
function Qa(e, t) {
|
|
3573
3547
|
let n = e.matchedCommand;
|
|
3574
3548
|
if (!n) return;
|
|
3575
3549
|
let r = [...n.options, ...e.globalCommand.options].filter((e) => e.required);
|
|
3576
3550
|
for (let i of r) {
|
|
3577
3551
|
if (typeof e.options[i.name] == "object") continue;
|
|
3578
|
-
let r = i.names.flatMap(
|
|
3552
|
+
let r = i.names.flatMap(Za);
|
|
3579
3553
|
for (let a = 2; a < t.length; a++) {
|
|
3580
3554
|
let o = t[a], s = r.find((e) => o === e || o.startsWith(`${e}=`));
|
|
3581
3555
|
if (s === void 0) continue;
|
|
3582
3556
|
let c = o === s ? t[a + 1] : o.slice(s.length + 1);
|
|
3583
|
-
if (c !== void 0 && (c === "" &&
|
|
3557
|
+
if (c !== void 0 && (c === "" && F(`blazon ${n.name}: ${s} needs a value, not an empty one.`, "empty-value", { fix: `Give ${s} a value, or leave it out.` }), i.name !== "port")) for (let t of i.names) t in e.options && (e.options[t] = c);
|
|
3584
3558
|
}
|
|
3585
3559
|
}
|
|
3586
3560
|
let i = t.slice(2);
|
|
3587
|
-
i.some((e, t) => e === "" && !(i[t - 1] ?? "").startsWith("-")) &&
|
|
3561
|
+
i.some((e, t) => e === "" && !(i[t - 1] ?? "").startsWith("-")) && F(`blazon ${n.name}: ${n.rawName.includes("[dir]") ? "the folder is an empty name; leave it out to use the current folder" : "an argument is empty"}.`, "empty-value", { fix: "Leave the empty argument out, or give it a value." });
|
|
3588
3562
|
}
|
|
3589
3563
|
// src/cli/json.ts
|
|
3590
|
-
var
|
|
3564
|
+
var $a = [
|
|
3591
3565
|
"error",
|
|
3592
3566
|
"warning",
|
|
3593
3567
|
"info"
|
|
3594
|
-
],
|
|
3568
|
+
], eo = {
|
|
3595
3569
|
error: ["error"],
|
|
3596
3570
|
warning: ["error", "warning"],
|
|
3597
3571
|
info: [
|
|
@@ -3600,19 +3574,19 @@ var eo = [
|
|
|
3600
3574
|
"info"
|
|
3601
3575
|
]
|
|
3602
3576
|
};
|
|
3603
|
-
async function
|
|
3577
|
+
async function to(e, t, n, r = "info") {
|
|
3604
3578
|
let i = console.log;
|
|
3605
3579
|
console.log = (...e) => console.error(...e);
|
|
3606
3580
|
let a;
|
|
3607
3581
|
try {
|
|
3608
3582
|
a = (await n()).findings;
|
|
3609
3583
|
} catch (e) {
|
|
3610
|
-
if (!(e instanceof
|
|
3584
|
+
if (!(e instanceof ht)) throw e;
|
|
3611
3585
|
a = e.findings;
|
|
3612
3586
|
} finally {
|
|
3613
3587
|
console.log = i;
|
|
3614
3588
|
}
|
|
3615
|
-
let o =
|
|
3589
|
+
let o = k(a, { strict: t }), s = {
|
|
3616
3590
|
errors: o.errors.length,
|
|
3617
3591
|
warnings: o.warnings.length,
|
|
3618
3592
|
info: o.infos.length
|
|
@@ -3622,18 +3596,18 @@ async function no(e, t, n, r = "info") {
|
|
|
3622
3596
|
passed: o.passed,
|
|
3623
3597
|
strict: t,
|
|
3624
3598
|
counts: s,
|
|
3625
|
-
findings: o.all.filter((e) =>
|
|
3599
|
+
findings: o.all.filter((e) => eo[r].includes(e.severity)).map((e) => ({
|
|
3626
3600
|
...e,
|
|
3627
|
-
...
|
|
3601
|
+
...ve(e) && { fix: ve(e) }
|
|
3628
3602
|
}))
|
|
3629
3603
|
}, null, 2)}\n`), process.exitCode = +!o.passed;
|
|
3630
3604
|
}
|
|
3631
|
-
async function
|
|
3605
|
+
async function no(e, t) {
|
|
3632
3606
|
let n = console.log;
|
|
3633
3607
|
console.log = (...e) => console.error(...e);
|
|
3634
3608
|
let r, i, a;
|
|
3635
3609
|
try {
|
|
3636
|
-
i = await
|
|
3610
|
+
i = await Wr(e, {
|
|
3637
3611
|
...t,
|
|
3638
3612
|
input: !1,
|
|
3639
3613
|
report: (e) => r = e,
|
|
@@ -3646,18 +3620,18 @@ async function ro(e, t) {
|
|
|
3646
3620
|
command: "init",
|
|
3647
3621
|
passed: i === 0,
|
|
3648
3622
|
...r ?? {},
|
|
3649
|
-
...i !== 0 && { error: a ?
|
|
3623
|
+
...i !== 0 && { error: a ? it(a.code, a.message) : it("error", `init did not finish (exit status ${i}); the reason is on standard error`) }
|
|
3650
3624
|
};
|
|
3651
3625
|
return process.stdout.write(`${JSON.stringify(o)}\n`), i;
|
|
3652
3626
|
}
|
|
3653
3627
|
// src/cli/help.ts
|
|
3654
|
-
var
|
|
3628
|
+
var ro = " 0 it did what it was asked (for check, no errors)\n 1 the check found errors (or warnings, with --strict), `blazon can` denied the combination, `blazon doctor` found a failing check, or the command failed\n 2 it was used wrongly: an unknown command or option, an unknown token, a bad port, no brand book in the folder. It did nothing, except `blazon init --from`, which copies the starter and then exits 2 when the site cannot be read", io = " blazon explain <code> what a finding code means, the fix, and where to read more\n blazon explain list every code", ao = " --cwd <dir> sets the folder every command works from, the same as running blazon there. A folder argument is then relative to it:\n `blazon --cwd ./brands check acme` checks ./brands/acme. A --cwd that is not a folder exits 2.\n `blazon doctor` checks the environment (Node, brand folder, plugin folder safety, Chrome, blazon.lock): one line each, ok, warn or fail, with a fix.", oo = {
|
|
3655
3629
|
check: "blazon plugin check <program> [--core] [--json]\n\nStarts the program the way blazon does and runs the protocol's core cases against it, then blazon's own cases for each role it declares and, for a shipped plugin's layout, the file name rule. Prints one line for each case: ok, skip or FAIL.\nIn a project whose config lists the plugin, case 10 also fails when the entry's env does not approve a variable the manifest lists.\nWith --core, only the core cases (1 to 5) run: no role cases, no case 10 and no layout line. Use it to check a plugin against the protocol alone.\n\nExit status:\n 0 every case passed\n 1 a case failed\n 2 no program was given\n\nExample:\n $ blazon plugin check ./blazon-acme.house-style",
|
|
3656
3630
|
pin: "blazon plugin pin <path> [--name <plugin>] [--digest <digest>] [--entry <path>]\n\nPrints the digest that pins a plugin: sha256: for a file, t1: for a directory.\nWith --name, records the pin in blazon.plugins.lock instead. --digest says what the bytes must be, and the pin is refused when they are not. --entry names the program inside a directory when it is not blazon-<plugin>.\n\nExit status:\n 0 printed, or recorded\n 1 the path is one a host must refuse, or the digest does not match\n 2 no path was given, or --digest or --entry without --name\n\nExample:\n $ blazon plugin pin ./blazon-acme.house-style --name acme.house-style",
|
|
3657
3631
|
profile: "blazon plugin profile\n\nPrints blazon's profile of the plugin protocol as JSON: the roles it defines and its limits. It is the same for every install.\n\nExit status:\n 0 printed"
|
|
3658
3632
|
};
|
|
3659
|
-
function
|
|
3660
|
-
if (t === "plugin" && n !== void 0 && Object.hasOwn(
|
|
3633
|
+
function so(e, t, n) {
|
|
3634
|
+
if (t === "plugin" && n !== void 0 && Object.hasOwn(oo, n)) return [{ body: oo[n] }];
|
|
3661
3635
|
let r = e.map((e) => ({
|
|
3662
3636
|
...e,
|
|
3663
3637
|
body: e.body.replace(/(--no-[a-z-]+[^\n]*?) *\(default: true\)/g, "$1")
|
|
@@ -3666,32 +3640,32 @@ function co(e, t, n) {
|
|
|
3666
3640
|
...r,
|
|
3667
3641
|
{
|
|
3668
3642
|
title: "Finding codes",
|
|
3669
|
-
body:
|
|
3643
|
+
body: io
|
|
3670
3644
|
},
|
|
3671
3645
|
{
|
|
3672
3646
|
title: "Working folder and environment",
|
|
3673
|
-
body:
|
|
3647
|
+
body: ao
|
|
3674
3648
|
},
|
|
3675
3649
|
{
|
|
3676
3650
|
title: "Exit status",
|
|
3677
|
-
body:
|
|
3651
|
+
body: ro
|
|
3678
3652
|
}
|
|
3679
3653
|
] : r;
|
|
3680
3654
|
}
|
|
3681
3655
|
// src/cli/index.ts
|
|
3682
|
-
function
|
|
3656
|
+
function co(e, t) {
|
|
3683
3657
|
if (t === void 0) return;
|
|
3684
3658
|
let n = String(t), r = /^\d+$/.test(n) ? Number(n) : NaN;
|
|
3685
|
-
return r >= 1 && r <= 65535 ||
|
|
3659
|
+
return r >= 1 && r <= 65535 || F(`blazon ${e}: the port must be a whole number from 1 to 65535, not "${n}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), r;
|
|
3686
3660
|
}
|
|
3687
|
-
var
|
|
3688
|
-
function
|
|
3689
|
-
t?.plugins === !1 && t.plugin !== void 0 &&
|
|
3661
|
+
var lo = (e) => typeof e == "number" ? String(e) : e;
|
|
3662
|
+
function uo(e, t) {
|
|
3663
|
+
t?.plugins === !1 && t.plugin !== void 0 && F(`blazon ${e}: --no-plugins runs no plugin, so it cannot be used with --plugin.`, "conflicting-options", { fix: "Leave out --no-plugins, or leave out --plugin." });
|
|
3690
3664
|
}
|
|
3691
|
-
function
|
|
3692
|
-
if (t !== void 0) return n ||
|
|
3665
|
+
function fo(e, t, n) {
|
|
3666
|
+
if (t !== void 0) return n || F(`blazon ${e}: --severity cuts the list that --json prints; add --json, or leave --severity out.`, "conflicting-options", { fix: "Add --json, or leave --severity out." }), $a.includes(t) || F(`blazon ${e}: --severity must be error, warning or info, not "${String(t)}".`, "invalid-option-value", { fix: "Use --severity error, warning or info." }), t;
|
|
3693
3667
|
}
|
|
3694
|
-
var
|
|
3668
|
+
var po = (e) => {
|
|
3695
3669
|
let [t, n] = e.slice(2).filter((e, t, n) => !e.startsWith("-") && n[t - 1] !== "--cwd" && n[t - 1] !== "--allow-dir");
|
|
3696
3670
|
if (e.includes("--json") && t !== void 0) return t === "plugin" ? n === "check" ? "plugin check" : void 0 : [
|
|
3697
3671
|
"check",
|
|
@@ -3703,11 +3677,11 @@ var mo = (e) => {
|
|
|
3703
3677
|
"pin",
|
|
3704
3678
|
"explain",
|
|
3705
3679
|
"doctor",
|
|
3706
|
-
...
|
|
3680
|
+
...Da,
|
|
3707
3681
|
"mcp"
|
|
3708
3682
|
].includes(t) ? t : void 0;
|
|
3709
3683
|
};
|
|
3710
|
-
function
|
|
3684
|
+
function mo(e) {
|
|
3711
3685
|
if (e[2] !== "help") return e;
|
|
3712
3686
|
let t = e[3];
|
|
3713
3687
|
return t !== void 0 && !t.startsWith("-") ? [
|
|
@@ -3717,134 +3691,134 @@ function ho(e) {
|
|
|
3717
3691
|
...e.slice(4)
|
|
3718
3692
|
] : [...e.slice(0, 2), "--help"];
|
|
3719
3693
|
}
|
|
3720
|
-
async function
|
|
3721
|
-
let t =
|
|
3722
|
-
|
|
3723
|
-
let r =
|
|
3694
|
+
async function ho(e = process.argv) {
|
|
3695
|
+
let t = mo(e), n = t.includes("--debug");
|
|
3696
|
+
nt(po(t));
|
|
3697
|
+
let r = Xe("blazon");
|
|
3724
3698
|
if (r.option("--debug", "Show the stack of an error"), r.option("--allow-dir <folder>", "Approve a folder outside the project for an asset category dir (repeat for more; or BLAZON_ALLOW_DIRS)"), r.option("--cwd <dir>", "Work from this folder, as if blazon were run there; a folder argument is then relative to it"), r.command("dev [dir]", "Start interactive Brand Book dev server with HMR").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
|
|
3725
3699
|
try {
|
|
3726
|
-
await
|
|
3700
|
+
await mt(e || process.cwd(), co("dev", t?.port), {
|
|
3727
3701
|
strictPort: t?.strictPort,
|
|
3728
|
-
host:
|
|
3702
|
+
host: lo(t?.host)
|
|
3729
3703
|
});
|
|
3730
3704
|
} catch (e) {
|
|
3731
|
-
|
|
3705
|
+
I("dev", e, n);
|
|
3732
3706
|
}
|
|
3733
3707
|
}), r.command("build [dir]", "Build static brand book site and compiled design tokens").option("-o, --outDir <dir>", "Output directory for static site").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
|
|
3734
3708
|
try {
|
|
3735
|
-
|
|
3736
|
-
let n =
|
|
3737
|
-
t?.json ? await
|
|
3709
|
+
uo("build", t);
|
|
3710
|
+
let n = fo("build", t?.severity, t?.json), r = () => At(e || process.cwd(), t?.outDir === void 0 ? void 0 : A.resolve(process.cwd(), t.outDir), t);
|
|
3711
|
+
t?.json ? await to("build", !1, r, n) : await r();
|
|
3738
3712
|
} catch (e) {
|
|
3739
|
-
|
|
3713
|
+
I("build", e, n);
|
|
3740
3714
|
}
|
|
3741
3715
|
}), r.command("tokens [dir]", "Compile design tokens only (theme.css, tokens.ts, tokens.json)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
|
|
3742
3716
|
try {
|
|
3743
|
-
|
|
3744
|
-
let n =
|
|
3745
|
-
t?.json ? await
|
|
3717
|
+
uo("tokens", t);
|
|
3718
|
+
let n = fo("tokens", t?.severity, t?.json), r = () => jt(e || process.cwd(), t);
|
|
3719
|
+
t?.json ? await to("tokens", !1, r, n) : await r();
|
|
3746
3720
|
} catch (e) {
|
|
3747
|
-
|
|
3721
|
+
I("tokens", e, n);
|
|
3748
3722
|
}
|
|
3749
3723
|
}), r.command("check [dir]", "Check tokens: aliases, types, usage rules, contrast pairs, duplicates and review flags").option("--strict", "Treat warnings as errors (useful for CI/CD pipelines)").option("--plugin <program>", "Run a plugin program that the config does not allow or the lock does not pin, once, with a warning (repeat for more)").option("--no-plugins", "Run no plugin at all, whatever the config lists: the tokens and the book only (no browser needed)").option("--json", "Print the findings as JSON on standard output; everything else goes to standard error").option("--severity <level>", "With --json: list only the findings at this level or worse (error, warning or info); the counts stay whole").action(async (e, t) => {
|
|
3750
3724
|
try {
|
|
3751
|
-
|
|
3752
|
-
let n =
|
|
3753
|
-
t?.json ? await
|
|
3725
|
+
uo("check", t);
|
|
3726
|
+
let n = fo("check", t?.severity, t?.json), r = () => kt(e || process.cwd(), t?.strict, t);
|
|
3727
|
+
t?.json ? await to("check", !!t.strict, r, n) : (await r()).passed || (process.exitCode = 1);
|
|
3754
3728
|
} catch (e) {
|
|
3755
|
-
|
|
3729
|
+
I("check", e, n);
|
|
3756
3730
|
}
|
|
3757
|
-
}),
|
|
3731
|
+
}), ja(r, n), r.command("mcp", "Set up blazon-mcp, the MCP server for coding agents: --print-config prints what registers it in a client, --check tests that it works; neither writes a file").option("--print-config", "Print the config that registers blazon-mcp (stdio) in a client").option("--check", "Test that the server is built, finds blazon, answers a real MCP handshake and is registered in the client; runs no plugin").option("--client <client>", "With --print-config or --check: claude-code (default), claude-desktop, cursor or vscode").option("--brand <dir>", "The brand folder: with --print-config, written into the config as an absolute path; with --check, the folder the server starts on").option("--json", "Print the config or the check as JSON on standard output").action(async (e) => {
|
|
3758
3732
|
try {
|
|
3759
|
-
process.exitCode = await
|
|
3733
|
+
process.exitCode = await Ga(e);
|
|
3760
3734
|
} catch (e) {
|
|
3761
|
-
|
|
3735
|
+
I("mcp", e, n);
|
|
3762
3736
|
}
|
|
3763
3737
|
}), r.command("drift [target]", "Find tokens that have drifted from the live site: compare each token that names a source.cssVar with a page (http or https address) or a CSS file").option("--json", "Print the findings as JSON").option("--tokens <dir>", "Read the tokens from this folder instead of the one the config names").action(async (e, t) => {
|
|
3764
3738
|
try {
|
|
3765
|
-
process.exitCode = await
|
|
3739
|
+
process.exitCode = await si(e, t);
|
|
3766
3740
|
} catch (e) {
|
|
3767
|
-
|
|
3741
|
+
I("drift", e, n);
|
|
3768
3742
|
}
|
|
3769
3743
|
}), r.command("approvals [dir]", "List the tokens and assets marked review ok with the fingerprint of their value today, to record in review.value so `blazon check` sees a later change").option("--json", "Print the list as JSON on standard output").action(async (e, t) => {
|
|
3770
3744
|
try {
|
|
3771
|
-
process.exitCode = await
|
|
3745
|
+
process.exitCode = await ci(e || process.cwd(), { json: t?.json });
|
|
3772
3746
|
} catch (e) {
|
|
3773
|
-
|
|
3747
|
+
I("approvals", e, n);
|
|
3774
3748
|
}
|
|
3775
3749
|
}), r.command("plugin [action] [target]", "Plugins: `check <program>` checks that a program follows the plugin protocol, `pin <path>` prints the digest that pins it, `profile` prints the profile blazon enforces").option("--name <name>", "With `pin`: record the pin in blazon.plugins.lock under this plugin name").option("--digest <digest>", "With `pin --name`: the digest you vouch for; the bytes must be those").option("--entry <path>", "With `pin --name` on a directory: the program inside it, when it is not blazon-<name>").option("--json", "With `check`: print the cases as JSON on standard output").option("--core", "With `check`: run only the core cases of the protocol (1 to 5), not blazon's role cases or the layout of a shipped plugin").action(async (e, t, r) => {
|
|
3776
3750
|
try {
|
|
3777
|
-
if (r?.json && e !== "check" &&
|
|
3751
|
+
if (r?.json && e !== "check" && F("blazon plugin: --json is for `blazon plugin check`; `pin` prints a digest and `profile` prints JSON already.", "conflicting-options", { fix: "Leave out --json, or use it with `blazon plugin check`." }), r?.core && e !== "check" && F("blazon plugin: --core is for `blazon plugin check`; `pin` and `profile` run no cases.", "conflicting-options", { fix: "Leave out --core, or use it with `blazon plugin check`." }), e !== "pin") for (let t of [
|
|
3778
3752
|
"name",
|
|
3779
3753
|
"digest",
|
|
3780
3754
|
"entry"
|
|
3781
|
-
]) r?.[t] !== void 0 &&
|
|
3782
|
-
e === "profile" && t !== void 0 &&
|
|
3755
|
+
]) r?.[t] !== void 0 && F(`blazon plugin: --${t} is for \`blazon plugin pin\`; \`${e ?? "check"}\` does not take it.`, "conflicting-options", { fix: `Leave out --${t}, or use it with \`blazon plugin pin\`.` });
|
|
3756
|
+
e === "profile" && t !== void 0 && F("blazon plugin: `profile` takes no target.", "conflicting-options", { fix: "Run `blazon plugin profile` on its own." }), process.exitCode = await ai(e, t, r);
|
|
3783
3757
|
} catch (e) {
|
|
3784
|
-
|
|
3758
|
+
I("plugin", e, n);
|
|
3785
3759
|
}
|
|
3786
3760
|
}), r.command("explain [code]", "Explain a finding code: its severity, what it means, the fix and where to read more; with no code, list every code").option("--json", "Print the explanation as JSON on standard output").action((e, t) => {
|
|
3787
3761
|
try {
|
|
3788
|
-
process.exitCode =
|
|
3762
|
+
process.exitCode = Xa(e, { json: t?.json });
|
|
3789
3763
|
} catch (e) {
|
|
3790
|
-
|
|
3764
|
+
I("explain", e, n);
|
|
3791
3765
|
}
|
|
3792
3766
|
}), r.command("pin [dir]", "Pin the blazon you build with: write blazon.lock with the commit of the blazon that runs this, so check, tokens and build refuse any other").option("--json", "Print the pinned commit as JSON on standard output").action((e, t) => {
|
|
3793
3767
|
try {
|
|
3794
|
-
process.exitCode =
|
|
3768
|
+
process.exitCode = oi(e || process.cwd(), { json: t?.json });
|
|
3795
3769
|
} catch (e) {
|
|
3796
|
-
|
|
3770
|
+
I("pin", e, n);
|
|
3797
3771
|
}
|
|
3798
3772
|
}), r.command("init [dir]", "Scaffold a new Blazon brand book and design token structure").option("--from <url>", "Start from a live site: read its stylesheets and page for the brand colors, fonts, logo and title (all marked needs-review)").option("--name <text>", "With `init`: the brand book title, as given").option("--description <text>", "With `init`: one sentence on the brand: the config description").option("--color <hex>", "With `init`: the primary color as hex, with or without the #: #2563eb, 2563eb or #26e").option("--font <family>", "With `init`: the font family, a Google Fonts name").option("--logo <file>", "With `init`: an SVG or PNG file to use as the logo").option("--dev", "With `init`: start `blazon dev` when it is done").option("--json", "Print what init made as JSON on standard output; everything else goes to standard error (never asks)").option("--yes", "With `init`: accept every default and never ask").option("--no-input", "With `init`: same as --yes; implied when stdin or stdout is not a terminal").action(async (e, t) => {
|
|
3799
3773
|
try {
|
|
3800
|
-
t?.json ? (t.dev &&
|
|
3774
|
+
t?.json ? (t.dev && F("blazon init: --dev starts a server that never ends, so it cannot be used with --json.", "conflicting-options", { fix: "Leave out --dev, or leave out --json." }), process.exitCode = await no(e || ".", t)) : process.exitCode = await Wr(e || ".", { ...t });
|
|
3801
3775
|
} catch (e) {
|
|
3802
|
-
|
|
3776
|
+
I("init", e, n);
|
|
3803
3777
|
}
|
|
3804
3778
|
}), r.command("preview [dir]", "Preview the static production brand book build").option("-p, --port <port>", "Port number to listen on (default: the port in blazon.json, else 3000)").option("--strict-port", "Exit 2 when the port is in use, instead of taking the next free one").option("--host [address]", "Listen on this address, or on every network interface with no address (default: localhost only)").action(async (e, t) => {
|
|
3805
3779
|
try {
|
|
3806
|
-
await
|
|
3780
|
+
await Jr(e || process.cwd(), co("preview", t?.port), {
|
|
3807
3781
|
strictPort: t?.strictPort,
|
|
3808
|
-
host:
|
|
3782
|
+
host: lo(t?.host)
|
|
3809
3783
|
});
|
|
3810
3784
|
} catch (e) {
|
|
3811
|
-
|
|
3785
|
+
I("preview", e, n);
|
|
3812
3786
|
}
|
|
3813
3787
|
}), r.command("doctor", "Check this machine and folder: Node version, brand folder, plugin folder safety, Chrome (if a plugin needs it) and blazon.lock; writes nothing").option("--json", "Print the checks as JSON on standard output").action(async (e) => {
|
|
3814
3788
|
try {
|
|
3815
|
-
process.exitCode = await
|
|
3789
|
+
process.exitCode = await ra(process.cwd(), { json: e?.json });
|
|
3816
3790
|
} catch (e) {
|
|
3817
|
-
|
|
3791
|
+
I("doctor", e, n);
|
|
3818
3792
|
}
|
|
3819
|
-
}), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) =>
|
|
3793
|
+
}), r.example(" $ blazon init my-brand"), r.example(" $ blazon check my-brand --json"), r.example(" $ blazon build my-brand"), r.example(" $ blazon list ./my-brand --type color"), r.example(" $ blazon get color.brand.primary my-brand --json"), r.example(" $ blazon can text.primary surface.canvas my-brand"), r.help((e) => so(e, r.matchedCommand?.name, r.args[0])), r.version(We), t.slice(2).length === 0) return r.outputHelp();
|
|
3820
3794
|
r.addEventListener("command:*", (e) => {
|
|
3821
3795
|
if (r.options.help || r.options.version) return;
|
|
3822
|
-
let t = String(e.detail), n =
|
|
3823
|
-
|
|
3796
|
+
let t = String(e.detail), n = E(t, r.commands.map((e) => e.name).filter(Boolean));
|
|
3797
|
+
F(`blazon: unknown command "${t}"${n ? `; did you mean "${n}"?` : "."} Run blazon --help for the commands.`, "unknown-command", { fix: n ? `Run blazon ${n}, or blazon --help for the commands.` : "Run blazon --help for the commands." });
|
|
3824
3798
|
});
|
|
3825
3799
|
try {
|
|
3826
|
-
r.parse(t, { run: !1 }),
|
|
3800
|
+
r.parse(t, { run: !1 }), Qa(r, t);
|
|
3827
3801
|
try {
|
|
3828
|
-
|
|
3802
|
+
ui(r.options.allowDir), li(r.options.cwd);
|
|
3829
3803
|
} catch (e) {
|
|
3830
|
-
|
|
3804
|
+
I(r.matchedCommand?.name ?? "", e, n);
|
|
3831
3805
|
}
|
|
3832
3806
|
await r.runMatchedCommand();
|
|
3833
3807
|
} catch (e) {
|
|
3834
|
-
if (!
|
|
3808
|
+
if (!st(e)) return I("", e, n);
|
|
3835
3809
|
let t = r.matchedCommand?.name, i = t ? `blazon ${t}` : "blazon", [, a = "", o] = /^Unknown option `(-{1,2})([^`]+)`$/.exec(e.message) ?? [], s = n ? e.stack : void 0;
|
|
3836
|
-
o !== void 0 && /^\d+$/.test(o) && (t === "dev" || t === "preview") &&
|
|
3810
|
+
o !== void 0 && /^\d+$/.test(o) && (t === "dev" || t === "preview") && F(`blazon ${t}: the port must be a whole number from 1 to 65535, not "-${o}".`, "invalid-port", { fix: "Give a whole number from 1 to 65535." }), t === "get" && /^missing required args/i.test(e.message) && F("blazon get: give a token path, such as blazon get color.brand.primary; blazon list shows the token paths.", "missing-argument", {
|
|
3837
3811
|
stack: s,
|
|
3838
3812
|
fix: "Run blazon list to see the token paths."
|
|
3839
|
-
}), o === void 0 &&
|
|
3813
|
+
}), o === void 0 && F(`${i}: ${ot(e.message)}. Run ${i} --help for the options.`, "missing-argument", {
|
|
3840
3814
|
stack: s,
|
|
3841
3815
|
fix: `Run ${i} --help for the options.`
|
|
3842
3816
|
});
|
|
3843
|
-
let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l =
|
|
3844
|
-
|
|
3817
|
+
let c = [...r.matchedCommand?.options ?? [], ...r.globalCommand.options].map((e) => e.name), l = E(o, c);
|
|
3818
|
+
F(`${i}: unknown option "${a}${o}"${l ? `; did you mean "--${l}"?` : "."} Run ${i} --help for the options.`, "unknown-option", {
|
|
3845
3819
|
stack: s,
|
|
3846
3820
|
fix: l ? `Use --${l}, or run ${i} --help for the options.` : `Run ${i} --help for the options.`
|
|
3847
3821
|
});
|
|
3848
3822
|
}
|
|
3849
3823
|
}
|
|
3850
|
-
export {
|
|
3824
|
+
export { ho as runCli };
|