@marktiderman/genesis-cli 1.17.1 → 1.17.3
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 -2
- package/dist/cli.js +239 -52
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +101 -31
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +9 -9
- package/dist/index.js +101 -31
- package/dist/index.js.map +1 -1
- package/dist/starter/.eas/workflows/e2e.yml +17 -3
- package/dist/starter/.eas/workflows/pr-preview.yml +45 -2
- package/dist/starter/.maestro/README.md +2 -1
- package/dist/starter/README.md +4 -3
- package/dist/templates/eas/workflows/e2e.yml +17 -3
- package/dist/templates/eas/workflows/pr-preview.yml +45 -2
- package/dist/vite.js +101 -31
- package/dist/vite.js.map +1 -1
- package/package.json +3 -3
package/dist/doctor.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ declare function parseRulesMarkdown(markdown: string): PatternRule[];
|
|
|
27
27
|
declare function defineDoctorPlugin(plugin: DoctorPlugin): DoctorPlugin;
|
|
28
28
|
|
|
29
29
|
/** Ids of the built-in rules, for `rules` overrides and `allow` entries. */
|
|
30
|
-
declare const BUILTIN_RULES: readonly ["local-primitives", "starter-leftover", "forbidden-import", "raw-tag", "palette-color", "arbitrary-color", "raw-color", "undefined-token", "shadowed-export", "version-skew", "duplicate-genesis-package", "peer-range-mismatch", "hand-rolled-sub-nav", "local-genesis-copy", "resource-workspace", "page-layout", "iso-date-slice", "resource-view-tree", "studio-server-auth-import", "removed-scope-name", "scope-practice-id", "deprecated-import", "beta-import", "native-raw-primitive", "native-literal-color", "native-custom-header", "native-screen-layout", "store-readiness", "migration-grants", "migration-rls", "migration-definer-search-path", "migration-edited", "migration-testing-kit", "migration-view-rls", "package-app-import", "package-undeclared-dependency", "package-migration-test", "package-migration-number", "package-migration-edited", "package-unregistered", "package-unversioned-change", "package-export-missing", "package-block-invalid", "package-untagged-tests", "package-doctor-declaration", "overlay-unmarked", "overlay-invalid", "overlay-age", "overlay-version", "package-rules-invalid", "package-rule-override", "ratchet-skipped", "allow-grew", "rules-weakened", "agent-guide-stale", "contracts-stale"];
|
|
30
|
+
declare const BUILTIN_RULES: readonly ["local-primitives", "starter-leftover", "forbidden-import", "raw-tag", "palette-color", "arbitrary-color", "raw-color", "undefined-token", "shadowed-export", "version-skew", "duplicate-genesis-package", "peer-range-mismatch", "hand-rolled-sub-nav", "local-genesis-copy", "resource-workspace", "page-layout", "iso-date-slice", "resource-view-tree", "studio-server-auth-import", "removed-scope-name", "scope-practice-id", "deprecated-import", "beta-import", "native-raw-primitive", "native-literal-color", "native-custom-header", "native-screen-layout", "store-readiness", "eas-placeholder", "migration-grants", "migration-rls", "migration-definer-search-path", "migration-edited", "migration-testing-kit", "migration-view-rls", "package-app-import", "package-undeclared-dependency", "package-migration-test", "package-migration-number", "package-migration-edited", "package-unregistered", "package-unversioned-change", "package-export-missing", "package-block-invalid", "package-untagged-tests", "package-doctor-declaration", "overlay-unmarked", "overlay-invalid", "overlay-age", "overlay-version", "package-rules-invalid", "package-rule-override", "ratchet-skipped", "allow-grew", "rules-weakened", "agent-guide-stale", "contracts-stale"];
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Minimal globs for config: `*` matches within a folder, `**` across folders,
|
package/dist/doctor.js
CHANGED
|
@@ -454,14 +454,14 @@ function inherit(own, source) {
|
|
|
454
454
|
}
|
|
455
455
|
function resolveViews(relations) {
|
|
456
456
|
const done = /* @__PURE__ */ new Set();
|
|
457
|
-
const
|
|
457
|
+
const resolve15 = (relation, depth) => {
|
|
458
458
|
if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
|
|
459
459
|
done.add(relation.oid);
|
|
460
460
|
const sources = new Set([...relation.origins.values()].map((o) => o.relation));
|
|
461
461
|
if (sources.size !== 1) return;
|
|
462
462
|
const source = relations.get([...sources][0]);
|
|
463
463
|
if (!source) return;
|
|
464
|
-
|
|
464
|
+
resolve15(source, depth + 1);
|
|
465
465
|
const viewAttnumOf = /* @__PURE__ */ new Map();
|
|
466
466
|
for (const [attnum, origin] of relation.origins) {
|
|
467
467
|
const own = relation.columns.get(attnum);
|
|
@@ -484,7 +484,7 @@ function resolveViews(relations) {
|
|
|
484
484
|
};
|
|
485
485
|
if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
|
|
486
486
|
};
|
|
487
|
-
for (const relation of relations.values())
|
|
487
|
+
for (const relation of relations.values()) resolve15(relation, 0);
|
|
488
488
|
}
|
|
489
489
|
async function introspectPostgres(sql, schemas, options = {}) {
|
|
490
490
|
const relations = /* @__PURE__ */ new Map();
|
|
@@ -2191,6 +2191,7 @@ var BUILTIN_RULES = [
|
|
|
2191
2191
|
"native-custom-header",
|
|
2192
2192
|
"native-screen-layout",
|
|
2193
2193
|
"store-readiness",
|
|
2194
|
+
"eas-placeholder",
|
|
2194
2195
|
// supabase pack
|
|
2195
2196
|
"migration-grants",
|
|
2196
2197
|
"migration-rls",
|
|
@@ -2567,6 +2568,32 @@ function checkNativePack(ctx) {
|
|
|
2567
2568
|
checkCustomHeaders(ctx, pkg);
|
|
2568
2569
|
checkScreenLayouts(ctx, pkg);
|
|
2569
2570
|
checkStoreReadiness(ctx);
|
|
2571
|
+
checkEasPlaceholders(ctx);
|
|
2572
|
+
}
|
|
2573
|
+
var EAS_PLACEHOLDER = /\bREPLACE_WITH_[A-Z0-9_]+/g;
|
|
2574
|
+
function checkEasPlaceholders(ctx) {
|
|
2575
|
+
const files = [];
|
|
2576
|
+
if (existsSync(path19.join(ctx.root, "eas.json"))) files.push("eas.json");
|
|
2577
|
+
const workflows = path19.join(ctx.root, ".eas", "workflows");
|
|
2578
|
+
if (existsSync(workflows)) {
|
|
2579
|
+
for (const name of readdirSync(workflows).sort()) if (/\.ya?ml$/.test(name)) files.push(`.eas/workflows/${name}`);
|
|
2580
|
+
}
|
|
2581
|
+
for (const file of files) {
|
|
2582
|
+
const lines = readFileSync(path19.join(ctx.root, file), "utf8").split("\n");
|
|
2583
|
+
lines.forEach((text, i) => {
|
|
2584
|
+
if (!file.endsWith(".json") && /^\s*#/.test(text)) return;
|
|
2585
|
+
for (const m of text.matchAll(EAS_PLACEHOLDER)) {
|
|
2586
|
+
ctx.report({
|
|
2587
|
+
rule: "eas-placeholder",
|
|
2588
|
+
level: "warn",
|
|
2589
|
+
file,
|
|
2590
|
+
line: i + 1,
|
|
2591
|
+
subject: m[0],
|
|
2592
|
+
message: m[0] === "REPLACE_WITH_APP_FOLDER" ? "still names REPLACE_WITH_APP_FOLDER, so only config changes start a preview; replace it with the app's code folder (src, or apps/<name> in a monorepo)" : `still has the template placeholder ${m[0]}; replace it before the job that reads it runs (see docs/NATIVE-RELEASE.md in the Genesis repository)`
|
|
2593
|
+
});
|
|
2594
|
+
}
|
|
2595
|
+
});
|
|
2596
|
+
}
|
|
2570
2597
|
}
|
|
2571
2598
|
var RN = String.raw`["']react-native["']`;
|
|
2572
2599
|
function checkRawPrimitives(ctx, pkg) {
|
|
@@ -3493,7 +3520,7 @@ function toRegExp2(source, flags = "") {
|
|
|
3493
3520
|
if (source.startsWith("(?i)")) return new RegExp(source.slice(4), flags + "i");
|
|
3494
3521
|
return new RegExp(source, flags);
|
|
3495
3522
|
}
|
|
3496
|
-
function validateDeclaration(raw, packageName3,
|
|
3523
|
+
function validateDeclaration(raw, packageName3, packageDir, ignored) {
|
|
3497
3524
|
const fail = (msg) => {
|
|
3498
3525
|
throw new PackageDeclarationError(`${packageName3}: genesis.doctor ${msg}`);
|
|
3499
3526
|
};
|
|
@@ -3513,9 +3540,9 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
|
|
|
3513
3540
|
}
|
|
3514
3541
|
});
|
|
3515
3542
|
if (typeof raw === "string") {
|
|
3516
|
-
if (!
|
|
3517
|
-
const file = path19.resolve(
|
|
3518
|
-
if (!inside(
|
|
3543
|
+
if (!packageDir) fail(`points at ${raw}, but the package folder is unknown`);
|
|
3544
|
+
const file = path19.resolve(packageDir, raw);
|
|
3545
|
+
if (!inside(packageDir, file)) fail(`points outside the package (${raw})`);
|
|
3519
3546
|
if (!existsSync(file)) fail(`points at ${raw}, which doesn't exist (is it in package.json "files"?)`);
|
|
3520
3547
|
let parsed;
|
|
3521
3548
|
try {
|
|
@@ -3523,7 +3550,7 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
|
|
|
3523
3550
|
} catch (err) {
|
|
3524
3551
|
return fail(`file ${raw} is not valid JSON: ${err.message}`);
|
|
3525
3552
|
}
|
|
3526
|
-
return validateDeclaration(parsed, packageName3,
|
|
3553
|
+
return validateDeclaration(parsed, packageName3, packageDir, ignored);
|
|
3527
3554
|
}
|
|
3528
3555
|
if (raw === false) fail(`is false; say why with { "enforce": false, "reason": "\u2026" }`);
|
|
3529
3556
|
if (!isObject3(raw)) fail(`must be an object (or a path to a JSON file in the package)`);
|
|
@@ -3561,10 +3588,10 @@ function validateDeclaration(raw, packageName3, packageDir2, ignored) {
|
|
|
3561
3588
|
});
|
|
3562
3589
|
let plugin;
|
|
3563
3590
|
if (typeof c.plugin === "string") {
|
|
3564
|
-
if (!
|
|
3591
|
+
if (!packageDir) plugin = c.plugin;
|
|
3565
3592
|
else {
|
|
3566
|
-
plugin = path19.resolve(
|
|
3567
|
-
if (!inside(
|
|
3593
|
+
plugin = path19.resolve(packageDir, c.plugin);
|
|
3594
|
+
if (!inside(packageDir, plugin)) fail(`plugin points outside the package (${c.plugin})`);
|
|
3568
3595
|
}
|
|
3569
3596
|
}
|
|
3570
3597
|
return {
|
|
@@ -4413,6 +4440,23 @@ function checkTestingKit(ctx, migrations) {
|
|
|
4413
4440
|
function granteesOf(s) {
|
|
4414
4441
|
return s.replace(/\s+granted by .*$/, "").replace(/\s+with grant option$/, "").split(/\s*,\s*/).map((r) => r.replace(/^group\s+/, "").trim()).filter(Boolean);
|
|
4415
4442
|
}
|
|
4443
|
+
function dynamicGrants(body) {
|
|
4444
|
+
const out = [];
|
|
4445
|
+
const code = body.replace(/\/\*[\s\S]*?\*\/|--[^\n]*/g, "").replace(/(?<![\w."'$])raise\s+(?:(?:debug|log|info|notice|warning|exception|sqlstate|using)\b|')[^;]*;/g, ";");
|
|
4446
|
+
const strings2 = /(?<![\w$])e'((?:[^'\\]|\\[\s\S]|'')*)(?:'|$)|'((?:[^']|'')*)(?:'|$)|\$(\w*)\$([\s\S]*?)(?:\$\3\$|$)/g;
|
|
4447
|
+
for (const m of code.matchAll(strings2)) {
|
|
4448
|
+
for (const stmt of (m[1] ?? m[2] ?? m[4] ?? "").split(";")) {
|
|
4449
|
+
if (!/^\s*(?:grant|alter default privileges\b.*?\bgrant)\b/.test(stmt)) continue;
|
|
4450
|
+
const to = /\bto(?:\s+|$)([\s\S]*)$/.exec(stmt);
|
|
4451
|
+
if (!to) continue;
|
|
4452
|
+
const roles = to[1].replace(/\s+(?:with grant option|granted by)\b[\s\S]*$/, "").trim();
|
|
4453
|
+
const open = /\b(anon|public)\b/.exec(roles);
|
|
4454
|
+
if (open) out.push(open[1]);
|
|
4455
|
+
else if (!roles || roles.includes("%")) out.push(null);
|
|
4456
|
+
}
|
|
4457
|
+
}
|
|
4458
|
+
return out;
|
|
4459
|
+
}
|
|
4416
4460
|
function checkGrants(ctx, migrations, exposed) {
|
|
4417
4461
|
const fix = "grant by name (grant execute on function schema.fn(args) to role) so an earlier revoke survives";
|
|
4418
4462
|
const open = (roles) => roles.filter((r) => r === "anon" || r === "public");
|
|
@@ -4423,7 +4467,19 @@ function checkGrants(ctx, migrations, exposed) {
|
|
|
4423
4467
|
return null;
|
|
4424
4468
|
};
|
|
4425
4469
|
for (const { file, statements } of migrations) {
|
|
4426
|
-
for (const { sql, line } of statements) {
|
|
4470
|
+
for (const { sql, line, bodies } of statements) {
|
|
4471
|
+
const dynamic = bodies.flatMap(dynamicGrants);
|
|
4472
|
+
if (dynamic.length) {
|
|
4473
|
+
const named = [...new Set(dynamic.filter((r) => r !== null))];
|
|
4474
|
+
ctx.report({
|
|
4475
|
+
rule: "migration-grants",
|
|
4476
|
+
level: "warn",
|
|
4477
|
+
file,
|
|
4478
|
+
line,
|
|
4479
|
+
subject: "dynamic grant",
|
|
4480
|
+
message: named.length ? `builds a grant to ${named.join(" and ")} in dynamic SQL (execute), so the doctor can't check what it grants; name each object and role in a static grant, or make sure every target is in an exposed schema` : "builds a grant to a computed role in dynamic SQL (execute), so the doctor can't check it isn't anon or public; name the role in the grant"
|
|
4481
|
+
});
|
|
4482
|
+
}
|
|
4427
4483
|
const all = /^grant\b.*\bon all (?:functions|routines|procedures) in schema .+? to (.+)$/.exec(sql);
|
|
4428
4484
|
if (all) {
|
|
4429
4485
|
const hit = blanket(granteesOf(all[1]));
|
|
@@ -5361,23 +5417,43 @@ function checkRemovedScopeNames(ctx) {
|
|
|
5361
5417
|
}
|
|
5362
5418
|
var SCRIPT_EXTS6 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
5363
5419
|
var DECLARATION = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\n(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/g;
|
|
5420
|
+
var REEXPORT = /\/\*\*((?:(?!\*\/)[\s\S])*)\*\/\s*\nexport\s+(?:type\s+)?\{([^}]*)\}/g;
|
|
5421
|
+
function specifierParts(spec) {
|
|
5422
|
+
return spec.trim().replace(/^type\s+/, "").split(/\s+as\s+/).map((part) => part.trim());
|
|
5423
|
+
}
|
|
5424
|
+
function tagOf(comment) {
|
|
5425
|
+
const doc = comment.replace(/^[ \t]*\*?[ \t]*/gm, "");
|
|
5426
|
+
const deprecated = /^@deprecated\b[ \t]*([\s\S]*?)(?=^@|(?![\s\S]))/m.exec(doc);
|
|
5427
|
+
const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
|
|
5428
|
+
const note = deprecated?.[1].replace(/\s+/g, " ").trim();
|
|
5429
|
+
if (deprecated) return { stability: "deprecated", ...note ? { note } : {} };
|
|
5430
|
+
return stability ? { stability } : void 0;
|
|
5431
|
+
}
|
|
5364
5432
|
function stabilityTagsIn(dts) {
|
|
5365
5433
|
const tags = /* @__PURE__ */ new Map();
|
|
5366
5434
|
for (const m of dts.matchAll(DECLARATION)) {
|
|
5367
|
-
const
|
|
5368
|
-
|
|
5369
|
-
const stability = /^@stability\s+(Experimental|Beta|Stable|Deprecated)\b/im.exec(doc)?.[1]?.toLowerCase();
|
|
5370
|
-
const note = deprecated?.[1].replace(/\s+/g, " ").trim();
|
|
5371
|
-
if (deprecated) tags.set(m[2], { stability: "deprecated", ...note ? { note } : {} });
|
|
5372
|
-
else if (stability) tags.set(m[2], { stability });
|
|
5435
|
+
const tag = tagOf(m[1]);
|
|
5436
|
+
if (tag) tags.set(m[2], tag);
|
|
5373
5437
|
}
|
|
5438
|
+
for (const [name, tag] of taggedReexports(dts)) tags.set(name, tag);
|
|
5374
5439
|
return tags;
|
|
5375
5440
|
}
|
|
5376
|
-
function
|
|
5441
|
+
function* taggedReexports(dts) {
|
|
5442
|
+
for (const m of dts.matchAll(REEXPORT)) {
|
|
5443
|
+
const tag = tagOf(m[1]);
|
|
5444
|
+
if (!tag) continue;
|
|
5445
|
+
for (const spec of m[2].split(",")) {
|
|
5446
|
+
const name = specifierParts(spec).pop();
|
|
5447
|
+
if (name) yield [name, tag];
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
}
|
|
5451
|
+
function genesisNamedImports(source) {
|
|
5377
5452
|
const out = [];
|
|
5453
|
+
const code = stripForImports(source) ?? source;
|
|
5378
5454
|
const re = /import\s+(?:type\s+)?(?:[\w$]+\s*,\s*)?\{([^}]*)\}\s*from\s*["']((@marktiderman\/genesis[\w-]*)(?:\/[^"']*)?)["']/g;
|
|
5379
5455
|
for (const m of code.matchAll(re)) {
|
|
5380
|
-
const names = m[1].split(",").map((n) => n
|
|
5456
|
+
const names = m[1].split(",").map((n) => specifierParts(n)[0]).filter(Boolean);
|
|
5381
5457
|
out.push({ pkg: m[3], specifier: m[2], names, line: code.slice(0, m.index).split("\n").length });
|
|
5382
5458
|
}
|
|
5383
5459
|
return out;
|
|
@@ -5390,13 +5466,6 @@ function declarationFiles(dir, out = []) {
|
|
|
5390
5466
|
}
|
|
5391
5467
|
return out;
|
|
5392
5468
|
}
|
|
5393
|
-
function packageDir(root, pkg) {
|
|
5394
|
-
for (let dir = path19.resolve(root); ; dir = path19.dirname(dir)) {
|
|
5395
|
-
const candidate = path19.join(dir, "node_modules", ...pkg.split("/"));
|
|
5396
|
-
if (existsSync(path19.join(candidate, "package.json"))) return candidate;
|
|
5397
|
-
if (path19.dirname(dir) === dir) return null;
|
|
5398
|
-
}
|
|
5399
|
-
}
|
|
5400
5469
|
function readPackageTags(dir) {
|
|
5401
5470
|
const pkg = JSON.parse(readFileSync(path19.join(dir, "package.json"), "utf8"));
|
|
5402
5471
|
const tags = { dir, byFile: /* @__PURE__ */ new Map(), declaredIn: /* @__PURE__ */ new Map(), exports: typeof pkg.exports === "object" && pkg.exports ? pkg.exports : {} };
|
|
@@ -5405,11 +5474,12 @@ function readPackageTags(dir) {
|
|
|
5405
5474
|
for (const file of declarationFiles(dist)) {
|
|
5406
5475
|
const text = readFileSync(file, "utf8");
|
|
5407
5476
|
tags.byFile.set(file, stabilityTagsIn(text));
|
|
5477
|
+
const names = /* @__PURE__ */ new Set();
|
|
5408
5478
|
for (const m of text.matchAll(/^(?:export\s+)?(?:declare\s+)?(?:abstract\s+)?(?:function|const|let|class|interface|type|enum|namespace)\s+([A-Za-z_$][\w$]*)/gm)) {
|
|
5409
|
-
|
|
5410
|
-
if (!files.includes(file)) files.push(file);
|
|
5411
|
-
tags.declaredIn.set(m[1], files);
|
|
5479
|
+
names.add(m[1]);
|
|
5412
5480
|
}
|
|
5481
|
+
for (const [name] of taggedReexports(text)) names.add(name);
|
|
5482
|
+
for (const name of names) tags.declaredIn.set(name, [...tags.declaredIn.get(name) ?? [], file]);
|
|
5413
5483
|
}
|
|
5414
5484
|
return tags;
|
|
5415
5485
|
}
|
|
@@ -5429,7 +5499,7 @@ function checkStabilityImports(ctx) {
|
|
|
5429
5499
|
const cache2 = /* @__PURE__ */ new Map();
|
|
5430
5500
|
const tagsOf = (pkg) => {
|
|
5431
5501
|
if (!cache2.has(pkg)) {
|
|
5432
|
-
const dir =
|
|
5502
|
+
const dir = findPackageDir(ctx.root, pkg);
|
|
5433
5503
|
cache2.set(pkg, dir ? readPackageTags(dir) : null);
|
|
5434
5504
|
}
|
|
5435
5505
|
return cache2.get(pkg);
|