@marktiderman/genesis-cli 1.24.0 → 1.25.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 +81 -14
- package/dist/cli.js +387 -41
- package/dist/cli.js.map +1 -1
- package/dist/{config-DRHg7V3Z.d.ts → config-CR4kqSCp.d.ts} +48 -6
- package/dist/doctor.d.ts +34 -4
- package/dist/doctor.js +367 -37
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +9 -6
- package/dist/index.d.ts +1 -1
- package/dist/index.js +364 -35
- package/dist/index.js.map +1 -1
- package/dist/vite.js +365 -36
- package/dist/vite.js.map +1 -1
- package/package.json +2 -2
package/dist/vite.js
CHANGED
|
@@ -846,6 +846,7 @@ var KNOWN = /* @__PURE__ */ new Set([
|
|
|
846
846
|
"forbiddenImports",
|
|
847
847
|
"rules",
|
|
848
848
|
"allow",
|
|
849
|
+
"extend",
|
|
849
850
|
"patterns",
|
|
850
851
|
"plugins",
|
|
851
852
|
"packs",
|
|
@@ -860,7 +861,10 @@ var KNOWN = /* @__PURE__ */ new Set([
|
|
|
860
861
|
"$comment"
|
|
861
862
|
]);
|
|
862
863
|
var LEVELS = /* @__PURE__ */ new Set(["error", "warn", "info", "off"]);
|
|
863
|
-
var META_RULES = /* @__PURE__ */ new Set(["allow-grew", "rules-weakened", "ratchet-skipped"]);
|
|
864
|
+
var META_RULES = /* @__PURE__ */ new Set(["allow-grew", "rules-weakened", "ratchet-skipped", "extension-invalid"]);
|
|
865
|
+
var CONFIG_RULES = /* @__PURE__ */ new Set(["stale-exception", "stale-extension", "package-rule-override"]);
|
|
866
|
+
var EXTENSION_KEYS = /* @__PURE__ */ new Set(["rule", "file", "buildsOn", "reason", "upstream"]);
|
|
867
|
+
var EXTENSION_REASON_MIN = { chars: 40, words: 6 };
|
|
864
868
|
var PATTERN_KEYS = /* @__PURE__ */ new Set(["id", "level", "files", "exclude", "forbid", "require", "path", "message", "newOnly"]);
|
|
865
869
|
var PACKAGE_RULE_KEYS = /* @__PURE__ */ new Set(["level", "files", "exclude", "reason"]);
|
|
866
870
|
var CONTRACT_KEYS = /* @__PURE__ */ new Set(["out", "schemas", "databaseEnv"]);
|
|
@@ -1071,6 +1075,30 @@ function validateConfig(raw, source = "config") {
|
|
|
1071
1075
|
}
|
|
1072
1076
|
});
|
|
1073
1077
|
}
|
|
1078
|
+
if (c.extend !== void 0) {
|
|
1079
|
+
if (!Array.isArray(c.extend)) fail(`"extend" must be a list of { rule, file, buildsOn, reason, upstream? }`);
|
|
1080
|
+
const seen = /* @__PURE__ */ new Set();
|
|
1081
|
+
c.extend.forEach((e, i) => {
|
|
1082
|
+
const where2 = `extend[${i}]`;
|
|
1083
|
+
if (!isObject(e)) return fail(`${where2} must be an object`);
|
|
1084
|
+
for (const k of Object.keys(e)) if (!EXTENSION_KEYS.has(k)) fail(`${where2}: unknown key "${k}" (known: ${[...EXTENSION_KEYS].join(", ")})`);
|
|
1085
|
+
for (const k of ["rule", "file", "buildsOn", "reason"]) if (typeof e[k] !== "string" || !e[k].trim()) fail(`${where2} needs "${k}"`);
|
|
1086
|
+
const { rule, file, buildsOn, reason } = e;
|
|
1087
|
+
if (META_RULES.has(rule) || CONFIG_RULES.has(rule)) fail(`${where2} can't extend ${rule}: it is about the config, not the app's code`);
|
|
1088
|
+
if (!rule.includes("/")) fail(`${where2} can't extend ${rule}: only package rules declare extension points (a built-in rule's findings are fixed, or recorded as allow debt)`);
|
|
1089
|
+
if (/[*?[\]{}]/.test(file)) fail(`${where2}.file must be one file, not a glob: each extension is reviewed on its own`);
|
|
1090
|
+
e.file = appPath(file, `${where2}.file`, fail);
|
|
1091
|
+
if (!/^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(buildsOn)) fail(`${where2}.buildsOn must name a Genesis export, or a part of one ("FormBuilder", "ResourceView.slots")`);
|
|
1092
|
+
const text = reason.trim();
|
|
1093
|
+
if (text.length < EXTENSION_REASON_MIN.chars || text.split(/\s+/).length < EXTENSION_REASON_MIN.words) {
|
|
1094
|
+
fail(`${where2} (${rule}) needs a reason of at least ${EXTENSION_REASON_MIN.words} words and ${EXTENSION_REASON_MIN.chars} characters: why the rule's primitive doesn't fit this file`);
|
|
1095
|
+
}
|
|
1096
|
+
if (e.upstream !== void 0 && (typeof e.upstream !== "string" || !e.upstream.trim())) fail(`${where2}.upstream must be a link to the gap's write-up`);
|
|
1097
|
+
const key2 = `${rule}\0${e.file}`;
|
|
1098
|
+
if (seen.has(key2)) fail(`${where2} extends ${rule} in ${e.file} twice`);
|
|
1099
|
+
seen.add(key2);
|
|
1100
|
+
});
|
|
1101
|
+
}
|
|
1074
1102
|
if (c.patterns !== void 0) {
|
|
1075
1103
|
if (!Array.isArray(c.patterns)) fail(`"patterns" must be a list`);
|
|
1076
1104
|
c.patterns.forEach((p, i) => {
|
|
@@ -1764,6 +1792,9 @@ function scanFiles(root, config) {
|
|
|
1764
1792
|
for (const pkg of local) walk3(pkg.dir);
|
|
1765
1793
|
return files;
|
|
1766
1794
|
}
|
|
1795
|
+
function withText(file, text) {
|
|
1796
|
+
return { ...file, text, code: stripBlockComments(text, LINE_COMMENT_EXTS.has(file.ext)) };
|
|
1797
|
+
}
|
|
1767
1798
|
function lineAt(text, index) {
|
|
1768
1799
|
let line = 1;
|
|
1769
1800
|
for (let i = 0; i < index && i < text.length; i++) if (text.charCodeAt(i) === 10) line++;
|
|
@@ -2758,6 +2789,10 @@ var BUILTIN_RULES = [
|
|
|
2758
2789
|
"ratchet-skipped",
|
|
2759
2790
|
"allow-grew",
|
|
2760
2791
|
"rules-weakened",
|
|
2792
|
+
"extension-added",
|
|
2793
|
+
// declared extensions (extensions.ts)
|
|
2794
|
+
"stale-extension",
|
|
2795
|
+
"extension-invalid",
|
|
2761
2796
|
// agent guide (primitives.ts)
|
|
2762
2797
|
"agent-guide-stale",
|
|
2763
2798
|
// supabase pack: contracts (contracts.ts)
|
|
@@ -3046,6 +3081,34 @@ function readSource(abs) {
|
|
|
3046
3081
|
return null;
|
|
3047
3082
|
}
|
|
3048
3083
|
}
|
|
3084
|
+
var lastBlanked = null;
|
|
3085
|
+
function blankStrings(code) {
|
|
3086
|
+
if (lastBlanked?.source === code) return lastBlanked.blanked;
|
|
3087
|
+
const out = code.split("");
|
|
3088
|
+
for (let i = 0; i < code.length; i++) {
|
|
3089
|
+
const ch = code[i];
|
|
3090
|
+
if (ch !== '"' && ch !== "'" && ch !== "`") continue;
|
|
3091
|
+
let j = i - 1;
|
|
3092
|
+
while (j >= 0 && /[ \t]/.test(code[j])) j--;
|
|
3093
|
+
const before = j >= 0 ? code[j] : "\n";
|
|
3094
|
+
const word = /[\w$]/.test(before) ? /(?:^|[^\w$])(return|case|typeof|in|of|yield|await)$/.test(code.slice(Math.max(0, j - 8), j + 1)) : false;
|
|
3095
|
+
if (/[\w$)\]]/.test(before) && !word) continue;
|
|
3096
|
+
let k = i + 1;
|
|
3097
|
+
for (; k < code.length; k++) {
|
|
3098
|
+
const c = code[k];
|
|
3099
|
+
if (c === "\\") {
|
|
3100
|
+
k++;
|
|
3101
|
+
continue;
|
|
3102
|
+
}
|
|
3103
|
+
if (c === ch) break;
|
|
3104
|
+
if (c === "\n" && ch !== "`") break;
|
|
3105
|
+
}
|
|
3106
|
+
for (let x = i + 1; x < k && x < code.length; x++) if (code[x] !== "\n") out[x] = " ";
|
|
3107
|
+
i = k;
|
|
3108
|
+
}
|
|
3109
|
+
lastBlanked = { source: code, blanked: out.join("") };
|
|
3110
|
+
return lastBlanked.blanked;
|
|
3111
|
+
}
|
|
3049
3112
|
function tagEnd(code, start) {
|
|
3050
3113
|
let depth = 0;
|
|
3051
3114
|
let quote2 = null;
|
|
@@ -3067,7 +3130,8 @@ function tagEnd(code, start) {
|
|
|
3067
3130
|
}
|
|
3068
3131
|
return { end: code.length, selfClosing: false };
|
|
3069
3132
|
}
|
|
3070
|
-
function openElementsAt(
|
|
3133
|
+
function openElementsAt(source, index, track) {
|
|
3134
|
+
const code = blankStrings(source);
|
|
3071
3135
|
const open = [];
|
|
3072
3136
|
const re = /<(\/?)([A-Z][\w.]*)(?=[\s>/])/g;
|
|
3073
3137
|
for (let m = re.exec(code); m && m.index < index; m = re.exec(code)) {
|
|
@@ -3919,9 +3983,9 @@ var PackageDeclarationError = class extends Error {
|
|
|
3919
3983
|
var GENESIS = /^@marktiderman\/genesis(?:-([a-z0-9-]+))?$/;
|
|
3920
3984
|
var ID = /^[a-z0-9][a-z0-9-]*$/;
|
|
3921
3985
|
var LEVELS2 = /* @__PURE__ */ new Set(["error", "warn", "info"]);
|
|
3922
|
-
var PREFER_KEYS = /* @__PURE__ */ new Set(["id", "need", "level", "platform", "files", "exclude", "forbid", "unless", "use", "import", "docs", "why", "newOnly"]);
|
|
3986
|
+
var PREFER_KEYS = /* @__PURE__ */ new Set(["id", "need", "level", "platform", "files", "exclude", "forbid", "unless", "use", "import", "docs", "why", "newOnly", "extensible"]);
|
|
3923
3987
|
var FORBID_KEYS = /* @__PURE__ */ new Set(["jsx", "imports", "pattern"]);
|
|
3924
|
-
var UNLESS_KEYS = /* @__PURE__ */ new Set(["renders", "pattern"]);
|
|
3988
|
+
var UNLESS_KEYS = /* @__PURE__ */ new Set(["renders", "inside", "pattern"]);
|
|
3925
3989
|
var PRIMITIVE_KEYS = /* @__PURE__ */ new Set(["need", "use", "import", "docs"]);
|
|
3926
3990
|
var DECLARATION_KEYS = /* @__PURE__ */ new Set(["enforce", "reason", "prefer", "catalog", "primitives", "plugin", "$comment"]);
|
|
3927
3991
|
var SCRIPT_GLOBS = ["**/*.ts", "**/*.tsx", "**/*.js", "**/*.jsx", "**/*.mts", "**/*.cts", "**/*.mjs", "**/*.cjs"];
|
|
@@ -4030,6 +4094,9 @@ function validatePrefer(raw, where2, fail, unknownKey) {
|
|
|
4030
4094
|
if (raw.platform !== void 0 && raw.platform !== "web" && raw.platform !== "native") fail(`${at}.platform must be "web" or "native"`);
|
|
4031
4095
|
if (raw.newOnly !== void 0 && typeof raw.newOnly !== "boolean") fail(`${at}.newOnly must be true or false`);
|
|
4032
4096
|
for (const key2 of ["files", "exclude"]) if (raw[key2] !== void 0 && !isStringList2(raw[key2])) fail(`${at}.${key2} must be a list of globs`);
|
|
4097
|
+
if (raw.extensible !== void 0 && !(isStringList2(raw.extensible) && raw.extensible.every((n) => /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*)*$/.test(n)))) {
|
|
4098
|
+
fail(`${at}.extensible must be a list of export names, or parts of one ("ResourceView.slots")`);
|
|
4099
|
+
}
|
|
4033
4100
|
if (!isObject3(raw.forbid)) fail(`${at} needs "forbid": { jsx?, imports?, pattern? }`);
|
|
4034
4101
|
const forbid = raw.forbid;
|
|
4035
4102
|
for (const key2 of Object.keys(forbid)) if (!FORBID_KEYS.has(key2)) unknownKey(`${at}.forbid`, key2);
|
|
@@ -4042,6 +4109,7 @@ function validatePrefer(raw, where2, fail, unknownKey) {
|
|
|
4042
4109
|
const unless = raw.unless;
|
|
4043
4110
|
for (const key2 of Object.keys(unless)) if (!UNLESS_KEYS.has(key2)) narrowing(`${at}.unless`, key2, UNLESS_KEYS);
|
|
4044
4111
|
if (unless.renders !== void 0 && !isStringList2(unless.renders)) fail(`${at}.unless.renders must be a list of component names`);
|
|
4112
|
+
if (unless.inside !== void 0 && !(isStringList2(unless.inside) && unless.inside.every((n) => /^[A-Z][\w.]*$/.test(n)))) fail(`${at}.unless.inside must be a list of component names`);
|
|
4045
4113
|
if (unless.pattern !== void 0) checkPattern(unless.pattern, `${at}.unless.pattern`, fail);
|
|
4046
4114
|
}
|
|
4047
4115
|
return raw;
|
|
@@ -4156,6 +4224,7 @@ function compile(rule, setting, routes) {
|
|
|
4156
4224
|
imports: (rule.forbid.imports ?? []).map(specMatcher),
|
|
4157
4225
|
...rule.forbid.pattern ? { pattern: toRegExp2(rule.forbid.pattern, "g") } : {},
|
|
4158
4226
|
unlessRenders: new Set(rule.unless?.renders ?? []),
|
|
4227
|
+
unlessInside: new Set(rule.unless?.inside ?? []),
|
|
4159
4228
|
...rule.unless?.pattern ? { unlessPattern: toRegExp2(rule.unless.pattern) } : {}
|
|
4160
4229
|
};
|
|
4161
4230
|
}
|
|
@@ -4167,10 +4236,11 @@ function messageFor(rule, found) {
|
|
|
4167
4236
|
const docs = rule.docs ? ` See ${rule.docs}` : "";
|
|
4168
4237
|
return `${found}; use ${rule.use}${from}. ${rule.why}${docs}`;
|
|
4169
4238
|
}
|
|
4239
|
+
var CHILDREN = /\{\s*(?:props\.)?children\s*\}/g;
|
|
4170
4240
|
var TOP_LEVEL = /^(export\s+(default\s+)?)?(?:async\s+)?(?:function\*?|const|let|var|class)\s+([\w$]+)/gm;
|
|
4171
4241
|
var EXPORT_LIST = /\bexport\s*\{([^}]*)\}(?!\s*from)/g;
|
|
4172
4242
|
var EXPORT_DEFAULT_NAME = /^export\s+default\s+([A-Z][\w$]*)\s*;?\s*$/gm;
|
|
4173
|
-
function wrappersIn(file, elements,
|
|
4243
|
+
function wrappersIn(file, elements, names, accept) {
|
|
4174
4244
|
const out = /* @__PURE__ */ new Map();
|
|
4175
4245
|
const decls = [...file.code.matchAll(TOP_LEVEL)];
|
|
4176
4246
|
const listed = /* @__PURE__ */ new Map();
|
|
@@ -4183,12 +4253,12 @@ function wrappersIn(file, elements, c) {
|
|
|
4183
4253
|
for (const m of file.code.matchAll(EXPORT_DEFAULT_NAME)) listed.set(m[1], [...listed.get(m[1]) ?? [], "default"]);
|
|
4184
4254
|
decls.forEach((d, i) => {
|
|
4185
4255
|
const name = d[3];
|
|
4186
|
-
if (!/^[A-Z]/.test(name) ||
|
|
4256
|
+
if (!/^[A-Z]/.test(name) || names.has(name)) return;
|
|
4187
4257
|
const end = decls[i + 1]?.index ?? file.code.length;
|
|
4188
|
-
const hit = elements.find((m) => m.index > d.index && m.index < end &&
|
|
4189
|
-
if (!hit) return;
|
|
4190
|
-
const
|
|
4191
|
-
for (const n of
|
|
4258
|
+
const hit = elements.find((m) => m.index > d.index && m.index < end && names.has(m[1]));
|
|
4259
|
+
if (!hit || accept && !accept(d.index, end)) return;
|
|
4260
|
+
const exported = [...d[1] ? [d[2] ? "default" : name] : [], ...listed.get(name) ?? []];
|
|
4261
|
+
for (const n of exported) out.set(n, hit[1]);
|
|
4192
4262
|
});
|
|
4193
4263
|
return out;
|
|
4194
4264
|
}
|
|
@@ -4196,6 +4266,32 @@ function runPrefer(ctx, c) {
|
|
|
4196
4266
|
const own = c.rule.packageDir;
|
|
4197
4267
|
const checked = ctx.files.filter((file) => SCRIPT.has(file.ext) && c.includes(file.path) && !c.excludes(file.path) && !inside(own, file.absolutePath));
|
|
4198
4268
|
const exempt = (file, rendered) => rendered.some((n) => c.unlessRenders.has(n)) || (c.unlessPattern?.test(file.code) ?? false);
|
|
4269
|
+
const scanned = new Map(ctx.files.map((f) => [f.absolutePath, f]));
|
|
4270
|
+
const importedBy = /* @__PURE__ */ new Map();
|
|
4271
|
+
const importsOf = (file) => {
|
|
4272
|
+
if (!importedBy.has(file)) importedBy.set(file, localImportedNames(ctx.root, file));
|
|
4273
|
+
return importedBy.get(file);
|
|
4274
|
+
};
|
|
4275
|
+
const builders = /* @__PURE__ */ new Map();
|
|
4276
|
+
const buildersIn = (abs) => {
|
|
4277
|
+
if (!builders.has(abs)) {
|
|
4278
|
+
const target = scanned.get(abs) ?? readSource(abs);
|
|
4279
|
+
const code = target ? "ext" in target ? target.code : stripBlockComments(target.code, true) : "";
|
|
4280
|
+
const childrenInside = (start, end) => [...code.slice(start, end).matchAll(CHILDREN)].some((m) => openElementsAt(code, start + m.index, (n) => c.unlessInside.has(n)).length > 0);
|
|
4281
|
+
builders.set(abs, code ? wrappersIn({ code }, [...code.matchAll(ELEMENT)], c.unlessInside, childrenInside) : /* @__PURE__ */ new Map());
|
|
4282
|
+
}
|
|
4283
|
+
return builders.get(abs);
|
|
4284
|
+
};
|
|
4285
|
+
const nestedInBuilder = (file, index) => {
|
|
4286
|
+
if (!c.unlessInside.size) return false;
|
|
4287
|
+
const imported = importsOf(file);
|
|
4288
|
+
const isBuilder = (name) => {
|
|
4289
|
+
if (c.unlessInside.has(name)) return true;
|
|
4290
|
+
const from = name.includes(".") ? void 0 : imported.get(name);
|
|
4291
|
+
return from !== void 0 && buildersIn(from.file).has(from.name);
|
|
4292
|
+
};
|
|
4293
|
+
return openElementsAt(file.code, index, isBuilder).length > 0;
|
|
4294
|
+
};
|
|
4199
4295
|
const wrappers = /* @__PURE__ */ new Map();
|
|
4200
4296
|
const renderedBy = /* @__PURE__ */ new Map();
|
|
4201
4297
|
for (const file of checked) {
|
|
@@ -4203,16 +4299,17 @@ function runPrefer(ctx, c) {
|
|
|
4203
4299
|
const elements = [...file.code.matchAll(ELEMENT)];
|
|
4204
4300
|
renderedBy.set(file, elements);
|
|
4205
4301
|
if (!c.jsx.size || exempt(file, elements.map((m) => m[1]))) continue;
|
|
4206
|
-
const found = wrappersIn(file, elements, c);
|
|
4302
|
+
const found = wrappersIn(file, elements, c.jsx);
|
|
4207
4303
|
if (found.size) wrappers.set(file.absolutePath, found);
|
|
4208
4304
|
}
|
|
4209
4305
|
for (const file of checked) {
|
|
4210
4306
|
const elements = renderedBy.get(file) ?? [];
|
|
4211
4307
|
if (exempt(file, elements.map((m) => m[1]))) continue;
|
|
4212
4308
|
const report = (line, subject, found) => ctx.report({ rule: c.rule.ruleId, level: c.level, file: file.path, line, subject, message: messageFor(c.rule, found) });
|
|
4213
|
-
const imported = wrappers.size && elements.length ?
|
|
4309
|
+
const imported = wrappers.size && elements.length ? importsOf(file) : null;
|
|
4214
4310
|
for (const m of elements) {
|
|
4215
4311
|
const name = m[1];
|
|
4312
|
+
if (nestedInBuilder(file, m.index)) continue;
|
|
4216
4313
|
if (c.jsx.has(name)) {
|
|
4217
4314
|
report(lineAt(file.code, m.index), name, `renders <${name}>`);
|
|
4218
4315
|
continue;
|
|
@@ -4229,6 +4326,7 @@ function runPrefer(ctx, c) {
|
|
|
4229
4326
|
if (c.pattern) {
|
|
4230
4327
|
c.pattern.lastIndex = 0;
|
|
4231
4328
|
for (const m of file.code.matchAll(c.pattern)) {
|
|
4329
|
+
if (nestedInBuilder(file, m.index)) continue;
|
|
4232
4330
|
const text = m[0].trim().replace(/\s+/g, " ").slice(0, 60);
|
|
4233
4331
|
report(lineAt(file.code, m.index), text, `has ${text}`);
|
|
4234
4332
|
}
|
|
@@ -6024,13 +6122,34 @@ function git3(root, args) {
|
|
|
6024
6122
|
return r.status === 0 ? r.stdout : null;
|
|
6025
6123
|
}
|
|
6026
6124
|
function changedSince(root, base) {
|
|
6027
|
-
const mergeBase =
|
|
6125
|
+
const mergeBase = mergeBaseOf2(root, base);
|
|
6028
6126
|
if (!mergeBase) return null;
|
|
6029
6127
|
const committed = git3(root, ["diff", "-z", "--name-only", "--relative", `${mergeBase}`, "--"]);
|
|
6030
6128
|
const untracked = git3(root, ["ls-files", "-z", "--others", "--exclude-standard"]);
|
|
6031
6129
|
if (committed === null || untracked === null) return null;
|
|
6032
6130
|
return new Set([...committed.split("\0"), ...untracked.split("\0")].filter(Boolean));
|
|
6033
6131
|
}
|
|
6132
|
+
function originsSince(root, base) {
|
|
6133
|
+
const out = /* @__PURE__ */ new Map();
|
|
6134
|
+
const mergeBase = mergeBaseOf2(root, base);
|
|
6135
|
+
if (!mergeBase) return out;
|
|
6136
|
+
const diff = git3(root, ["diff", "-z", "-M", "--name-status", "--relative", mergeBase, "--"]);
|
|
6137
|
+
if (diff === null) return out;
|
|
6138
|
+
const parts = diff.split("\0");
|
|
6139
|
+
for (let i = 0; i < parts.length; ) {
|
|
6140
|
+
const status = parts[i++] ?? "";
|
|
6141
|
+
if (!status) continue;
|
|
6142
|
+
if (status.startsWith("R") || status.startsWith("C")) {
|
|
6143
|
+
const from = parts[i++];
|
|
6144
|
+
const to = parts[i++];
|
|
6145
|
+
if (status.startsWith("R")) out.set(to, from);
|
|
6146
|
+
} else i++;
|
|
6147
|
+
}
|
|
6148
|
+
return out;
|
|
6149
|
+
}
|
|
6150
|
+
function mergeBaseOf2(root, base) {
|
|
6151
|
+
return git3(root, ["merge-base", base, "HEAD"])?.trim() || null;
|
|
6152
|
+
}
|
|
6034
6153
|
var objectOr = (v) => typeof v === "object" && v !== null && !Array.isArray(v) ? v : {};
|
|
6035
6154
|
function showAt(dir, rev, file) {
|
|
6036
6155
|
const at = `${rev}:./${file}`;
|
|
@@ -6038,7 +6157,7 @@ function showAt(dir, rev, file) {
|
|
|
6038
6157
|
return git3(dir, ["show", at]);
|
|
6039
6158
|
}
|
|
6040
6159
|
function configAtBase(root, base, explicitFile) {
|
|
6041
|
-
const mergeBase =
|
|
6160
|
+
const mergeBase = mergeBaseOf2(root, base);
|
|
6042
6161
|
if (!mergeBase) return null;
|
|
6043
6162
|
const candidates = explicitFile ? [{ dir: path21.dirname(explicitFile), file: path21.basename(explicitFile), explicit: true }] : [
|
|
6044
6163
|
{ dir: root, file: "genesis.config.json", explicit: false },
|
|
@@ -6059,7 +6178,12 @@ function configAtBase(root, base, explicitFile) {
|
|
|
6059
6178
|
continue;
|
|
6060
6179
|
}
|
|
6061
6180
|
const b = objectOr(block);
|
|
6062
|
-
return {
|
|
6181
|
+
return {
|
|
6182
|
+
allow: Array.isArray(b.allow) ? b.allow : [],
|
|
6183
|
+
extend: Array.isArray(b.extend) ? b.extend : [],
|
|
6184
|
+
rules: objectOr(b.rules),
|
|
6185
|
+
packageRules: objectOr(b.packageRules)
|
|
6186
|
+
};
|
|
6063
6187
|
}
|
|
6064
6188
|
return "absent";
|
|
6065
6189
|
}
|
|
@@ -6073,6 +6197,16 @@ function allowGrew(allow, before, base) {
|
|
|
6073
6197
|
message: `allow gained an entry for ${a.rule}${a.match ? ` (${a.match})` : ""} since ${base}; the list only shrinks, so fix what it hides instead`
|
|
6074
6198
|
}));
|
|
6075
6199
|
}
|
|
6200
|
+
function extensionsAdded(extend, before, base) {
|
|
6201
|
+
const had = new Set(before.map((e) => `${e.rule}\0${e.file}\0${e.buildsOn}`));
|
|
6202
|
+
return extend.filter((e) => !had.has(`${e.rule}\0${e.file}\0${e.buildsOn}`)).map((e) => ({
|
|
6203
|
+
rule: "extension-added",
|
|
6204
|
+
level: "info",
|
|
6205
|
+
file: e.file,
|
|
6206
|
+
subject: e.rule,
|
|
6207
|
+
message: `extends ${e.rule} since ${base}, building on ${e.buildsOn}: "${e.reason}"${e.upstream ? ` (upstream: ${e.upstream})` : ""}; the pull request's review accepts it, and it covers only the findings the file has now`
|
|
6208
|
+
}));
|
|
6209
|
+
}
|
|
6076
6210
|
var RANK = { off: 0, info: 1, warn: 2, error: 3 };
|
|
6077
6211
|
function rulesWeakened(config, before, base) {
|
|
6078
6212
|
const out = [];
|
|
@@ -6110,14 +6244,169 @@ var NEVER_RATCHETED = /* @__PURE__ */ new Set([
|
|
|
6110
6244
|
"plugin-error",
|
|
6111
6245
|
"build",
|
|
6112
6246
|
"agent-guide-stale",
|
|
6113
|
-
"contracts-stale"
|
|
6247
|
+
"contracts-stale",
|
|
6248
|
+
"stale-extension",
|
|
6249
|
+
"extension-added"
|
|
6114
6250
|
]);
|
|
6251
|
+
function isRatcheted(rule, config, newOnly) {
|
|
6252
|
+
return !NEVER_RATCHETED.has(rule) && (config.ratchet === true || newOnly.has(rule) || Array.isArray(config.ratchet) && config.ratchet.includes(rule));
|
|
6253
|
+
}
|
|
6254
|
+
var countKey = (file, rule) => `${file}\0${rule}`;
|
|
6255
|
+
function countFindings(findings) {
|
|
6256
|
+
const counts = /* @__PURE__ */ new Map();
|
|
6257
|
+
for (const f of findings) counts.set(countKey(f.file, f.rule), (counts.get(countKey(f.file, f.rule)) ?? 0) + 1);
|
|
6258
|
+
return counts;
|
|
6259
|
+
}
|
|
6115
6260
|
function applyRatchet(findings, options) {
|
|
6116
|
-
const { config, newOnly, changed, base, isAppPath } = options;
|
|
6117
|
-
const
|
|
6261
|
+
const { config, newOnly, changed, base, isAppPath, baseCounts, existedAtBase } = options;
|
|
6262
|
+
const originOf = options.originOf ?? ((f) => f);
|
|
6263
|
+
const counts = countFindings(findings.map((f) => ({ file: originOf(f.file), rule: f.rule })));
|
|
6118
6264
|
return findings.map((f) => {
|
|
6119
|
-
if (f.level === "info" || !
|
|
6120
|
-
return { ...f, level: "info", message: `${f.message} (ratcheted: unchanged since ${base})` };
|
|
6265
|
+
if (f.level === "info" || !isRatcheted(f.rule, config, newOnly) || !isAppPath(f.file)) return f;
|
|
6266
|
+
if (!touched(f.file, changed)) return { ...f, level: "info", message: `${f.message} (ratcheted: unchanged since ${base})` };
|
|
6267
|
+
const origin = originOf(f.file);
|
|
6268
|
+
if (!baseCounts || !existedAtBase?.(origin)) return f;
|
|
6269
|
+
const now = counts.get(countKey(origin, f.rule)) ?? 0;
|
|
6270
|
+
const was = baseCounts.get(countKey(origin, f.rule)) ?? 0;
|
|
6271
|
+
const where2 = origin === f.file ? "this file" : `the files from ${origin}`;
|
|
6272
|
+
if (now > was) return { ...f, message: `${f.message} (${now} ${f.rule} findings in ${where2}, ${was} at the merge base with ${base}: don't add to the debt)` };
|
|
6273
|
+
return { ...f, level: "info", message: `${f.message} (ratcheted: ${now} in ${where2}, ${was} at the merge base with ${base})` };
|
|
6274
|
+
});
|
|
6275
|
+
}
|
|
6276
|
+
function snapshotAtBase(root, base, files, changed, originOf = (f) => f) {
|
|
6277
|
+
const mergeBase = mergeBaseOf2(root, base);
|
|
6278
|
+
if (!mergeBase) return null;
|
|
6279
|
+
const out = [];
|
|
6280
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6281
|
+
for (const f of files) {
|
|
6282
|
+
if (!changed.has(f.path)) {
|
|
6283
|
+
if (!seen.has(f.path)) out.push(f);
|
|
6284
|
+
seen.add(f.path);
|
|
6285
|
+
continue;
|
|
6286
|
+
}
|
|
6287
|
+
const origin = originOf(f.path);
|
|
6288
|
+
if (seen.has(origin)) continue;
|
|
6289
|
+
seen.add(origin);
|
|
6290
|
+
const text = showAt(root, mergeBase, origin);
|
|
6291
|
+
if (text === null) return null;
|
|
6292
|
+
if (text !== void 0) out.push(withText({ ...f, path: origin, absolutePath: path21.join(root, origin) }, text));
|
|
6293
|
+
}
|
|
6294
|
+
const cache2 = /* @__PURE__ */ new Map();
|
|
6295
|
+
return {
|
|
6296
|
+
mergeBase,
|
|
6297
|
+
files: out,
|
|
6298
|
+
existed(file) {
|
|
6299
|
+
if (!cache2.has(file)) cache2.set(file, git3(root, ["cat-file", "-e", `${mergeBase}:./${file}`]) !== null);
|
|
6300
|
+
return cache2.get(file);
|
|
6301
|
+
}
|
|
6302
|
+
};
|
|
6303
|
+
}
|
|
6304
|
+
|
|
6305
|
+
// src/doctor/extensions.ts
|
|
6306
|
+
function pointProblem(entry, packages) {
|
|
6307
|
+
const rule = preferRules(packages).find((r) => r.ruleId === entry.rule);
|
|
6308
|
+
if (!rule?.extensible?.length) return `${entry.rule} declares no extension points, so it can't be extended (debt goes in allow, and is fixed)`;
|
|
6309
|
+
if (!rule.extensible.includes(entry.buildsOn)) return `${entry.buildsOn} isn't one of ${entry.rule}'s extension points (${rule.extensible.join(", ")})`;
|
|
6310
|
+
return null;
|
|
6311
|
+
}
|
|
6312
|
+
function extensionProblem(entry, ctx) {
|
|
6313
|
+
const point = pointProblem(entry, ctx.packages);
|
|
6314
|
+
if (point) return point;
|
|
6315
|
+
const name = entry.buildsOn.split(".")[0];
|
|
6316
|
+
const replaces = preferRules(ctx.packages).find((r) => r.forbid.jsx?.includes(name));
|
|
6317
|
+
if (replaces) return `${name} is what ${replaces.ruleId} replaces (use ${replaces.use}); a legacy component can't be built on`;
|
|
6318
|
+
const flagged = ctx.raw.find((f) => f.file === entry.file && f.subject === name);
|
|
6319
|
+
if (flagged) return `${name} is flagged in this file by ${flagged.rule}; build on a current Genesis primitive`;
|
|
6320
|
+
const file = ctx.files.find((f) => f.path === entry.file);
|
|
6321
|
+
if (!file) return `${entry.file} isn't one of the files the doctor scans`;
|
|
6322
|
+
const imported = genesisNamedImports(file.code).some((i) => i.names.includes(name));
|
|
6323
|
+
if (!imported) return `${entry.file} doesn't import ${name} from a Genesis package; buildsOn names the extension point the file uses`;
|
|
6324
|
+
if (!usesPoint(blankStrings(file.code), entry.buildsOn)) {
|
|
6325
|
+
const prop = entry.buildsOn.split(".")[1];
|
|
6326
|
+
return prop ? `${entry.file} doesn't pass ${prop} to <${name}>; an extension point is one the file uses` : `${entry.file} imports ${name} but doesn't render or call it; an extension point is one the file uses`;
|
|
6327
|
+
}
|
|
6328
|
+
return null;
|
|
6329
|
+
}
|
|
6330
|
+
var escape2 = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
6331
|
+
function usesPoint(code, point) {
|
|
6332
|
+
const [name, prop] = point.split(".");
|
|
6333
|
+
const n = escape2(name);
|
|
6334
|
+
if (!prop) return new RegExp(`(?<![\\w$.])<${n}(?=[\\s>/<])|(?<![\\w$.])${n}\\s*(?:<[^>()]*>)?\\s*\\(`).test(code);
|
|
6335
|
+
for (const m of code.matchAll(new RegExp(`(?<![\\w$.])<${n}(?=[\\s>/<])`, "g"))) {
|
|
6336
|
+
const { end } = tagEnd(code, m.index);
|
|
6337
|
+
if (new RegExp(`(?<![\\w$.])${escape2(prop)}\\s*=`).test(code.slice(m.index, end))) return true;
|
|
6338
|
+
}
|
|
6339
|
+
return false;
|
|
6340
|
+
}
|
|
6341
|
+
function applyExtensions(findings, ctx) {
|
|
6342
|
+
const entries = ctx.config.extend ?? [];
|
|
6343
|
+
if (!entries.length) return findings;
|
|
6344
|
+
const staleLevel = ctx.config.rules?.["stale-extension"];
|
|
6345
|
+
const covered = /* @__PURE__ */ new Set();
|
|
6346
|
+
const grew = /* @__PURE__ */ new Map();
|
|
6347
|
+
const out = [];
|
|
6348
|
+
const invalid = (entry, problem) => out.push({ rule: "extension-invalid", level: "error", file: entry.file, line: 0, subject: entry.rule, message: `the extension of ${entry.rule} isn't accepted: ${problem}` });
|
|
6349
|
+
for (const entry of entries) {
|
|
6350
|
+
if (ctx.config.rules?.[entry.rule] === "off" || ctx.config.packageRules?.[entry.rule]?.level === "off") continue;
|
|
6351
|
+
const point = pointProblem(entry, ctx.packages);
|
|
6352
|
+
if (point) {
|
|
6353
|
+
invalid(entry, point);
|
|
6354
|
+
continue;
|
|
6355
|
+
}
|
|
6356
|
+
const hits = findings.filter((f) => f.rule === entry.rule && f.file === entry.file);
|
|
6357
|
+
if (!hits.length) {
|
|
6358
|
+
if (staleLevel === "off") continue;
|
|
6359
|
+
out.push({
|
|
6360
|
+
rule: "stale-extension",
|
|
6361
|
+
level: staleLevel ?? "warn",
|
|
6362
|
+
file: entry.file,
|
|
6363
|
+
line: 0,
|
|
6364
|
+
subject: entry.rule,
|
|
6365
|
+
message: `the extension of ${entry.rule} (building on ${entry.buildsOn}) no longer matches a finding in this file; remove it from doctor.extend`
|
|
6366
|
+
});
|
|
6367
|
+
continue;
|
|
6368
|
+
}
|
|
6369
|
+
const problem = extensionProblem(entry, ctx);
|
|
6370
|
+
if (problem) {
|
|
6371
|
+
invalid(entry, problem);
|
|
6372
|
+
continue;
|
|
6373
|
+
}
|
|
6374
|
+
const limit = ctx.limit?.(entry);
|
|
6375
|
+
if (limit !== void 0 && hits.length > limit) {
|
|
6376
|
+
for (const h of hits) grew.set(h, `${h.message} (the extension of ${entry.rule} here covers the ${limit} at the merge base; this file now has ${hits.length}, so they all count)`);
|
|
6377
|
+
continue;
|
|
6378
|
+
}
|
|
6379
|
+
for (const h of hits) covered.add(h);
|
|
6380
|
+
}
|
|
6381
|
+
const kept = findings.filter((f) => !covered.has(f)).map((f) => grew.has(f) ? { ...f, message: grew.get(f) } : f);
|
|
6382
|
+
return [...kept, ...out].sort(byPlace);
|
|
6383
|
+
}
|
|
6384
|
+
var byPlace = (x, y) => x.file.localeCompare(y.file) || x.line - y.line || x.rule.localeCompare(y.rule);
|
|
6385
|
+
var RANK2 = { info: 0, warn: 1, error: 2 };
|
|
6386
|
+
function dedupeFindings(findings) {
|
|
6387
|
+
const groups = /* @__PURE__ */ new Map();
|
|
6388
|
+
const order = [];
|
|
6389
|
+
for (const f of findings) {
|
|
6390
|
+
if (f.subject === void 0 || !f.line) {
|
|
6391
|
+
order.push([f]);
|
|
6392
|
+
continue;
|
|
6393
|
+
}
|
|
6394
|
+
const key2 = `${f.file}\0${f.line}\0${f.subject}`;
|
|
6395
|
+
const list = groups.get(key2) ?? [];
|
|
6396
|
+
const group = list.find((g) => !g.some((x) => x.rule === f.rule));
|
|
6397
|
+
if (group) group.push(f);
|
|
6398
|
+
else {
|
|
6399
|
+
const fresh = [f];
|
|
6400
|
+
list.push(fresh);
|
|
6401
|
+
groups.set(key2, list);
|
|
6402
|
+
order.push(fresh);
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
return order.map((group) => {
|
|
6406
|
+
if (group.length === 1) return group[0];
|
|
6407
|
+
const primary = group.reduce((a, b) => RANK2[b.level] > RANK2[a.level] ? b : a);
|
|
6408
|
+
const rules = [primary.rule, ...group.filter((g) => g !== primary).map((g) => g.rule)];
|
|
6409
|
+
return { ...primary, rules, message: `${primary.message} (also ${rules.slice(1).join(", ")})` };
|
|
6121
6410
|
});
|
|
6122
6411
|
}
|
|
6123
6412
|
var DEFAULT_CONTRACT_OUT = "resources.genesis.ts";
|
|
@@ -7292,14 +7581,8 @@ async function runDoctor(options = {}) {
|
|
|
7292
7581
|
}
|
|
7293
7582
|
const raw = [];
|
|
7294
7583
|
const ctx = { root, files, genesis, config, packages, ...options.base ? { base: options.base } : {}, ...options.strict ? { strict: true } : {}, report: (f) => raw.push(f) };
|
|
7295
|
-
|
|
7296
|
-
|
|
7297
|
-
await plugin.check(ctx);
|
|
7298
|
-
} catch (err) {
|
|
7299
|
-
if (err instanceof DoctorConfigError) throw err;
|
|
7300
|
-
raw.push({ rule: "plugin-error", file: plugin.name, message: `rule plugin "${plugin.name}" threw: ${err.message}` });
|
|
7301
|
-
}
|
|
7302
|
-
}
|
|
7584
|
+
const appChecks = [...packagePlugins, ...patterns ? [patterns.plugin] : [], ...plugins];
|
|
7585
|
+
await runChecks(ctx, [...builtinChecks(config, { contracts: options.contracts ?? true, figma: options.figma ?? true }), ...appChecks]);
|
|
7303
7586
|
if (options.build) {
|
|
7304
7587
|
const failure = runBuild(root, buildCommands(root, config), options.quietBuild ?? false);
|
|
7305
7588
|
if (failure) raw.push(failure);
|
|
@@ -7309,30 +7592,57 @@ async function runDoctor(options = {}) {
|
|
|
7309
7592
|
let changed = null;
|
|
7310
7593
|
let skipped = false;
|
|
7311
7594
|
const ratchetNeeded = newOnly.size > RATCHETED_BY_DEFAULT.length || raw.some((f) => RATCHETED_BY_DEFAULT.includes(f.rule));
|
|
7312
|
-
if (options.base && (ratchetNeeded || config.ratchet)) {
|
|
7595
|
+
if (options.base && (ratchetNeeded || config.ratchet || config.extend?.length)) {
|
|
7313
7596
|
changed = options.changedFiles ? new Set(options.changedFiles) : changedSince(root, options.base);
|
|
7314
7597
|
skipped ||= !changed;
|
|
7315
7598
|
}
|
|
7316
7599
|
const configFile = "file" in loaded ? loaded.file : null;
|
|
7317
|
-
const guarded = (config.allow?.length ?? 0) + Object.keys(config.rules ?? {}).length + Object.keys(config.packageRules ?? {}).length > 0;
|
|
7600
|
+
const guarded = (config.allow?.length ?? 0) + (config.extend?.length ?? 0) + Object.keys(config.rules ?? {}).length + Object.keys(config.packageRules ?? {}).length > 0;
|
|
7318
7601
|
let configSkipped = false;
|
|
7602
|
+
let baseExtend = [];
|
|
7319
7603
|
if (options.base && configFile) {
|
|
7320
7604
|
const before = configAtBase(root, options.base, options.configPath !== void 0 ? configFile : void 0);
|
|
7605
|
+
if (before && before !== "absent") baseExtend = before.extend;
|
|
7606
|
+
if (before === "absent") raw.push(...extensionsAdded(config.extend ?? [], [], options.base));
|
|
7321
7607
|
if (before && before !== "absent") {
|
|
7322
7608
|
raw.push(...allowGrew(config.allow ?? [], before.allow, options.base));
|
|
7323
7609
|
raw.push(...rulesWeakened(config, before, options.base));
|
|
7610
|
+
raw.push(...extensionsAdded(config.extend ?? [], before.extend, options.base));
|
|
7324
7611
|
}
|
|
7325
7612
|
configSkipped = !before && guarded;
|
|
7326
7613
|
}
|
|
7327
7614
|
if (skipped || configSkipped) {
|
|
7328
7615
|
raw.push(
|
|
7329
|
-
configSkipped ? { rule: "ratchet-skipped", level: "error", file: "genesis config", message: `couldn't compare allow, rules and packageRules against ${options.base} (not a git repository, or the ref isn't fetched; in CI check out with fetch-depth: 0)` } : { rule: "ratchet-skipped", level: "warn", file: "genesis config", message: `couldn't compare against ${options.base} (not a git repository, or the ref isn't fetched); every rule ran at its full level` }
|
|
7616
|
+
configSkipped ? { rule: "ratchet-skipped", level: "error", file: "genesis config", message: `couldn't compare allow, extend, rules and packageRules against ${options.base} (not a git repository, or the ref isn't fetched; in CI check out with fetch-depth: 0)` } : { rule: "ratchet-skipped", level: "warn", file: "genesis config", message: `couldn't compare against ${options.base} (not a git repository, or the ref isn't fetched); every rule ran at its full level` }
|
|
7330
7617
|
);
|
|
7331
7618
|
}
|
|
7332
|
-
|
|
7619
|
+
const packageIds = packageRuleIds(packages);
|
|
7620
|
+
const extensionCtx = { config, files, packages, raw };
|
|
7621
|
+
const configured = applyConfig(raw, config, packageIds);
|
|
7622
|
+
let findings = applyExtensions(configured, extensionCtx);
|
|
7333
7623
|
if (options.base && changed) {
|
|
7334
|
-
|
|
7624
|
+
const isAppPath = (f) => existsSync(path21.join(root, f));
|
|
7625
|
+
const origins = options.changedFiles ? /* @__PURE__ */ new Map() : originsSince(root, options.base);
|
|
7626
|
+
const originOf = (f) => origins.get(f) ?? f;
|
|
7627
|
+
const dueRules = new Set(findings.filter((f) => f.level !== "info" && isRatcheted(f.rule, config, newOnly) && isAppPath(f.file) && touched(f.file, changed)).map((f) => f.rule));
|
|
7628
|
+
const heldExtensions = (config.extend ?? []).filter((e) => touched(e.file, changed) && baseExtend.some((b) => b.rule === e.rule && (b.file === e.file || b.file === originOf(e.file))));
|
|
7629
|
+
for (const e of heldExtensions) dueRules.add(e.rule);
|
|
7630
|
+
const snapshot = dueRules.size ? snapshotAtBase(root, options.base, files, changed, originOf) : null;
|
|
7631
|
+
let baseCounts;
|
|
7632
|
+
if (snapshot) {
|
|
7633
|
+
const before = [];
|
|
7634
|
+
await runChecks({ ...ctx, files: snapshot.files, report: (f) => before.push(f) }, baseChecks(dueRules, packageIds, packagePlugins, () => [...builtinChecks(config, { contracts: false, figma: false }), ...appChecks]));
|
|
7635
|
+
baseCounts = countFindings(applyConfig(before, config, packageIds));
|
|
7636
|
+
if (heldExtensions.length) {
|
|
7637
|
+
const counts = baseCounts;
|
|
7638
|
+
const held = new Set(heldExtensions);
|
|
7639
|
+
findings = applyExtensions(configured, { ...extensionCtx, limit: (e) => held.has(e) ? counts.get(countKey(originOf(e.file), e.rule)) ?? 0 : void 0 });
|
|
7640
|
+
}
|
|
7641
|
+
}
|
|
7642
|
+
findings = applyRatchet(findings, { config, newOnly, changed, base: options.base, isAppPath, originOf, ...snapshot && baseCounts ? { baseCounts, existedAtBase: snapshot.existed } : {} });
|
|
7335
7643
|
}
|
|
7644
|
+
findings = dedupeFindings(findings);
|
|
7645
|
+
const extensionsNew = (config.extend ?? []).filter((e) => findings.some((f) => f.rule === "extension-added" && f.file === e.file && f.subject === e.rule));
|
|
7336
7646
|
const errors = findings.filter((f) => f.level === "error").length;
|
|
7337
7647
|
const warnings = findings.filter((f) => f.level === "warn").length;
|
|
7338
7648
|
const infos = findings.length - errors - warnings;
|
|
@@ -7346,9 +7656,24 @@ async function runDoctor(options = {}) {
|
|
|
7346
7656
|
primitives: primitivesSummary(packages),
|
|
7347
7657
|
errors,
|
|
7348
7658
|
warnings,
|
|
7349
|
-
infos
|
|
7659
|
+
infos,
|
|
7660
|
+
...extensionsNew.length ? { extensionsAdded: extensionsNew } : {}
|
|
7350
7661
|
};
|
|
7351
7662
|
}
|
|
7663
|
+
function baseChecks(rules, preferIds, packagePlugins, all) {
|
|
7664
|
+
if ([...rules].every((r) => preferIds.has(r))) return packagePlugins.filter((p) => p.name === "package-rules");
|
|
7665
|
+
return all();
|
|
7666
|
+
}
|
|
7667
|
+
async function runChecks(ctx, checks) {
|
|
7668
|
+
for (const plugin of checks) {
|
|
7669
|
+
try {
|
|
7670
|
+
await plugin.check(ctx);
|
|
7671
|
+
} catch (err) {
|
|
7672
|
+
if (err instanceof DoctorConfigError) throw err;
|
|
7673
|
+
ctx.report({ rule: "plugin-error", file: plugin.name, message: `rule plugin "${plugin.name}" threw: ${err.message}` });
|
|
7674
|
+
}
|
|
7675
|
+
}
|
|
7676
|
+
}
|
|
7352
7677
|
function builtinChecks(config, options = {}) {
|
|
7353
7678
|
const packs = {
|
|
7354
7679
|
native: { name: "native", check: checkNativePack },
|
|
@@ -7442,17 +7767,21 @@ function formatReport(result, options = {}) {
|
|
|
7442
7767
|
`Genesis doctor: ${g.uiPackage}@${g.uiVersion}, ${g.components.length} components, ${g.tokens.size} tokens, ${result.ruleCount} app rules; raw tags checked: ${[...g.rawTags.keys()].join(", ") || "none"}`
|
|
7443
7768
|
];
|
|
7444
7769
|
for (const f of result.findings) {
|
|
7445
|
-
lines.push(`${f.level.toUpperCase().padEnd(5)} ${f.file}${f.line ? `:${f.line}` : ""} [${f.rule}] ${f.message}`);
|
|
7770
|
+
lines.push(`${f.level.toUpperCase().padEnd(5)} ${f.file}${f.line ? `:${f.line}` : ""} [${(f.rules ?? [f.rule]).join(", ")}] ${f.message}`);
|
|
7446
7771
|
}
|
|
7447
7772
|
lines.push(options.verbose ? `Available but unused (${result.unused.length}): ${result.unused.join(", ") || "none"}` : `Available but unused: ${result.unused.length} (genesis doctor --verbose lists them)`);
|
|
7448
7773
|
lines.push(`Primitives: ${result.primitives.rules} rules from ${result.primitives.packages} packages; see genesis catalog`);
|
|
7774
|
+
if (result.extensionsAdded?.length) {
|
|
7775
|
+
lines.push(`Extensions added on this branch (${result.extensionsAdded.length}); the pull request's review accepts each:`);
|
|
7776
|
+
for (const e of result.extensionsAdded) lines.push(` ${e.file} [${e.rule}] builds on ${e.buildsOn}: ${e.reason}${e.upstream ? ` (upstream: ${e.upstream})` : ""}`);
|
|
7777
|
+
}
|
|
7449
7778
|
const info = result.infos ? `, ${result.infos} info` : "";
|
|
7450
7779
|
lines.push(result.ok ? `PASS (${result.warnings} warnings${info})` : `FAIL (${result.errors} errors, ${result.warnings} warnings${info})`);
|
|
7451
7780
|
return lines.join("\n");
|
|
7452
7781
|
}
|
|
7453
7782
|
|
|
7454
7783
|
// src/vite.ts
|
|
7455
|
-
var formatProblems = (result, withWarnings = false) => result.findings.filter((f) => f.level === "error" || withWarnings && f.level === "warn").map((f) => `${f.file}${f.line ? `:${f.line}` : ""} [${f.rule}] ${f.message}`).join("\n");
|
|
7784
|
+
var formatProblems = (result, withWarnings = false) => result.findings.filter((f) => f.level === "error" || withWarnings && f.level === "warn").map((f) => `${f.file}${f.line ? `:${f.line}` : ""} [${(f.rules ?? [f.rule]).join(", ")}] ${f.message}`).join("\n");
|
|
7456
7785
|
function genesisDoctor(options = {}) {
|
|
7457
7786
|
let root = options.root ?? process.cwd();
|
|
7458
7787
|
return [
|