@marktiderman/genesis-cli 1.19.0 → 1.21.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 +98 -1
- package/dist/cli.js +682 -74
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +1 -1
- package/dist/doctor.js +270 -8
- package/dist/doctor.js.map +1 -1
- package/dist/eslint.cjs +99 -0
- package/dist/eslint.cjs.map +1 -0
- package/dist/eslint.d.cts +68 -0
- package/dist/eslint.d.ts +68 -0
- package/dist/eslint.js +72 -0
- package/dist/eslint.js.map +1 -0
- package/dist/genesis-catalog.json +86 -14
- package/dist/index.js +278 -16
- package/dist/index.js.map +1 -1
- package/dist/starter/README.md +17 -5
- package/dist/starter/__tests__/components/setup.ts +11 -0
- package/dist/starter/__tests__/starter.test.ts +19 -0
- package/dist/starter/eslint.config.js +8 -1
- package/dist/starter/nativewind-env.d.ts +1 -0
- package/dist/starter/package.json +5 -3
- package/dist/starter/src/lib/app.ts +13 -5
- package/dist/starter/src/lib/define-starter.ts +1 -1
- package/dist/starter/src/lib/devtools-overlay.ts +3 -4
- package/dist/starter/src/lib/native-modules.ts +5 -1
- package/dist/starter/src/lib/offline.ts +14 -0
- package/dist/starter/supabase/migrations/20261024000750_support_default_tenant.sql +18 -0
- package/dist/starter/supabase/migrations/20261024000800_genesis_support_tickets.sql +800 -0
- package/dist/starter/supabase/migrations/20261025000070_starter_tenancy.sql +26 -0
- package/dist/starter/supabase/migrations/20261025000080_genesis_chat_tenants.sql +716 -0
- package/dist/starter/supabase/tests/database/chat_people.test.sql +1 -1
- package/dist/starter/supabase/tests/database/genesis_chat.test.sql +10 -2
- package/dist/starter/supabase/tests/database/genesis_chat_coaching.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_search_threads.test.sql +8 -0
- package/dist/starter/supabase/tests/database/genesis_chat_tenants.test.sql +259 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +15 -3
- package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +10 -0
- package/dist/starter/supabase/tests/database/genesis_support_tickets.test.sql +327 -0
- package/dist/starter/supabase/tests/database/starter_tenancy.test.sql +19 -0
- package/dist/vite.js +270 -8
- package/dist/vite.js.map +1 -1
- package/package.json +18 -4
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", "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", "overlay-behind", "package-rules-invalid", "package-rule-override", "ratchet-skipped", "allow-grew", "rules-weakened", "agent-guide-stale", "contracts-stale", "lock-files", "database-elsewhere"];
|
|
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", "overlay-behind", "package-rules-invalid", "package-rule-override", "ratchet-skipped", "allow-grew", "rules-weakened", "agent-guide-stale", "contracts-stale", "lock-files", "database-elsewhere", "genesis-eslint-config"];
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* Minimal globs for config: `*` matches within a folder, `**` across folders,
|
package/dist/doctor.js
CHANGED
|
@@ -455,14 +455,14 @@ function inherit(own, source) {
|
|
|
455
455
|
}
|
|
456
456
|
function resolveViews(relations) {
|
|
457
457
|
const done = /* @__PURE__ */ new Set();
|
|
458
|
-
const
|
|
458
|
+
const resolve17 = (relation, depth) => {
|
|
459
459
|
if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
|
|
460
460
|
done.add(relation.oid);
|
|
461
461
|
const sources = new Set([...relation.origins.values()].map((o) => o.relation));
|
|
462
462
|
if (sources.size !== 1) return;
|
|
463
463
|
const source = relations.get([...sources][0]);
|
|
464
464
|
if (!source) return;
|
|
465
|
-
|
|
465
|
+
resolve17(source, depth + 1);
|
|
466
466
|
const viewAttnumOf = /* @__PURE__ */ new Map();
|
|
467
467
|
for (const [attnum, origin] of relation.origins) {
|
|
468
468
|
const own = relation.columns.get(attnum);
|
|
@@ -485,7 +485,7 @@ function resolveViews(relations) {
|
|
|
485
485
|
};
|
|
486
486
|
if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
|
|
487
487
|
};
|
|
488
|
-
for (const relation of relations.values())
|
|
488
|
+
for (const relation of relations.values()) resolve17(relation, 0);
|
|
489
489
|
}
|
|
490
490
|
async function introspectPostgres(sql, schemas, options = {}) {
|
|
491
491
|
const relations = /* @__PURE__ */ new Map();
|
|
@@ -1143,7 +1143,7 @@ function globToRegExp(glob) {
|
|
|
1143
1143
|
}
|
|
1144
1144
|
function globMatcher(globs) {
|
|
1145
1145
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1146
|
-
return (
|
|
1146
|
+
return (path43) => res.some((re) => re.test(path43));
|
|
1147
1147
|
}
|
|
1148
1148
|
var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
|
|
1149
1149
|
var NATIVE_UI_PACKAGE = "@marktiderman/genesis-ui-native";
|
|
@@ -1455,6 +1455,7 @@ var FUNCTION_NAME = /^[a-z0-9][a-z0-9_-]*$/;
|
|
|
1455
1455
|
var ROUTE = /^\/(?:[A-Za-z0-9_\-[\]().]+\/?)*$/;
|
|
1456
1456
|
var INSTALL_SPEC = /^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(@[A-Za-z0-9.^~<>=|* -]+)?$/;
|
|
1457
1457
|
var SECRET = /^[A-Z][A-Z0-9_]*$/;
|
|
1458
|
+
var SQL_FUNCTION = /^[a-z_][a-z0-9_]*\.[a-z_][a-z0-9_]*$/;
|
|
1458
1459
|
var ManifestError = class extends Error {
|
|
1459
1460
|
constructor(problems) {
|
|
1460
1461
|
super(`Invalid block manifest:
|
|
@@ -1549,6 +1550,39 @@ function parseManifest(home, id, raw, version, options = {}) {
|
|
|
1549
1550
|
});
|
|
1550
1551
|
}
|
|
1551
1552
|
}
|
|
1553
|
+
if (m["needs"] !== void 0) {
|
|
1554
|
+
if (!Array.isArray(m["needs"])) problems.push(`${where2}.needs: must be a list of { function, how }`);
|
|
1555
|
+
else {
|
|
1556
|
+
out.needs = m["needs"].flatMap((n, j) => {
|
|
1557
|
+
const at2 = `${where2}.needs[${j}]`;
|
|
1558
|
+
if (!isObject2(n) || typeof n["function"] !== "string" || typeof n["how"] !== "string" || !n["how"].trim()) {
|
|
1559
|
+
problems.push(`${at2}: must be { function: "schema.name", how: "what to add" }`);
|
|
1560
|
+
return [];
|
|
1561
|
+
}
|
|
1562
|
+
if (!SQL_FUNCTION.test(n["function"])) {
|
|
1563
|
+
problems.push(`${at2}.function: "${n["function"]}" must be a schema-qualified function name, like private.genesis_viewer_people`);
|
|
1564
|
+
return [];
|
|
1565
|
+
}
|
|
1566
|
+
return [{ function: n["function"], how: n["how"].trim() }];
|
|
1567
|
+
});
|
|
1568
|
+
}
|
|
1569
|
+
}
|
|
1570
|
+
if (m["runsBefore"] !== void 0) {
|
|
1571
|
+
if (!Array.isArray(m["runsBefore"])) problems.push(`${where2}.runsBefore: must be a list of { package, file }`);
|
|
1572
|
+
else {
|
|
1573
|
+
out.runsBefore = m["runsBefore"].map((r, j) => {
|
|
1574
|
+
const at2 = `${where2}.runsBefore[${j}]`;
|
|
1575
|
+
if (!isObject2(r)) {
|
|
1576
|
+
problems.push(`${at2}: must be an object`);
|
|
1577
|
+
return { package: home, file: "" };
|
|
1578
|
+
}
|
|
1579
|
+
const before = { package: pkgOf(r["package"], at2), file: pathOf(r["file"], `${at2}.file`) };
|
|
1580
|
+
if (before.file && !MIGRATION_FILE.test(before.file.split("/").pop())) problems.push(`${at2}.file: "${before.file}" must be named NNNN_name.sql`);
|
|
1581
|
+
if (before.package === out.package && before.file === file) problems.push(`${at2}: a migration can't run before itself`);
|
|
1582
|
+
return before;
|
|
1583
|
+
});
|
|
1584
|
+
}
|
|
1585
|
+
}
|
|
1552
1586
|
if (m["test"] !== void 0) {
|
|
1553
1587
|
out.test = pathOf(m["test"], `${where2}.test`);
|
|
1554
1588
|
if (out.test && !/^[a-z0-9_]+\.test\.sql$/.test(out.test.split("/").pop().replace(/^\d{4}_/, ""))) problems.push(`${where2}.test: "${out.test}" must be named [NNNN_]name.test.sql`);
|
|
@@ -2359,8 +2393,8 @@ function pinnedVersion(root, name, manifests = ["package.json"]) {
|
|
|
2359
2393
|
} catch {
|
|
2360
2394
|
continue;
|
|
2361
2395
|
}
|
|
2362
|
-
for (const
|
|
2363
|
-
const spec = json[
|
|
2396
|
+
for (const section2 of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
2397
|
+
const spec = json[section2]?.[name];
|
|
2364
2398
|
const v = typeof spec === "string" ? /^[\^~=]?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/.exec(spec)?.[1] : void 0;
|
|
2365
2399
|
const parsed = v && parseVersion(v);
|
|
2366
2400
|
if (parsed && (!best || compareVersions(parsed, parseVersion(best)) > 0)) best = v;
|
|
@@ -2513,7 +2547,9 @@ var BUILTIN_RULES = [
|
|
|
2513
2547
|
// genesis.lock.json against the files (lock-files.ts)
|
|
2514
2548
|
"lock-files",
|
|
2515
2549
|
// an app whose database files live in another app (database.ts)
|
|
2516
|
-
"database-elsewhere"
|
|
2550
|
+
"database-elsewhere",
|
|
2551
|
+
// the app's eslint config loads Genesis's lint rules (eslint-config.ts)
|
|
2552
|
+
"genesis-eslint-config"
|
|
2517
2553
|
];
|
|
2518
2554
|
var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
2519
2555
|
var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -5568,6 +5604,31 @@ function readsPracticeId(text) {
|
|
|
5568
5604
|
var augmentsResourceScope = (text) => /\binterface\s+ResourceScope\b/.test(text);
|
|
5569
5605
|
var PRACTICE_ID_AUGMENTATION = 'declare module "@marktiderman/genesis-core" { interface ResourceScope { practiceId?: string } }';
|
|
5570
5606
|
|
|
5607
|
+
// src/upgrade/eslint-config.ts
|
|
5608
|
+
var ESLINT_EXPORT = "@marktiderman/genesis-cli/eslint";
|
|
5609
|
+
var TESTING_LIBRARY = "eslint-plugin-testing-library";
|
|
5610
|
+
var FLAT_CONFIG_FILES = ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "eslint.config.mts", "eslint.config.cts"];
|
|
5611
|
+
function findEslintConfig(root) {
|
|
5612
|
+
return FLAT_CONFIG_FILES.find((name) => existsSync(path20.join(root, name))) ?? null;
|
|
5613
|
+
}
|
|
5614
|
+
function readPackageJson(root) {
|
|
5615
|
+
try {
|
|
5616
|
+
return JSON.parse(readFileSync(path20.join(root, "package.json"), "utf8"));
|
|
5617
|
+
} catch {
|
|
5618
|
+
return null;
|
|
5619
|
+
}
|
|
5620
|
+
}
|
|
5621
|
+
var declares = (pkg, name) => Boolean(pkg?.dependencies?.[name] ?? pkg?.devDependencies?.[name] ?? pkg?.peerDependencies?.[name]);
|
|
5622
|
+
function appPlatform(pkg) {
|
|
5623
|
+
return declares(pkg, "expo") || declares(pkg, "react-native") ? "native" : "web";
|
|
5624
|
+
}
|
|
5625
|
+
function hasTestingLibrary(pkg) {
|
|
5626
|
+
return declares(pkg, TESTING_LIBRARY);
|
|
5627
|
+
}
|
|
5628
|
+
function usesGenesisLint(text) {
|
|
5629
|
+
return text.includes(ESLINT_EXPORT);
|
|
5630
|
+
}
|
|
5631
|
+
|
|
5571
5632
|
// src/upgrade/codemods.ts
|
|
5572
5633
|
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", ".expo", "coverage", "ios", "android"]);
|
|
5573
5634
|
var SCRIPT2 = /\.(?:[cm]?[jt]sx?)$/;
|
|
@@ -6348,9 +6409,179 @@ function blockOfSource(source, manifests) {
|
|
|
6348
6409
|
}
|
|
6349
6410
|
return null;
|
|
6350
6411
|
}
|
|
6412
|
+
var BUN_LOCK = "bun.lock";
|
|
6413
|
+
var GENESIS_TAIL = /(?:^|\/)(@marktiderman\/genesis(?:-[a-z0-9-]+)?)$/;
|
|
6414
|
+
var PLAIN_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/;
|
|
6415
|
+
function skipSpace(text, i) {
|
|
6416
|
+
for (; ; ) {
|
|
6417
|
+
while (i < text.length && /\s/.test(text[i])) i++;
|
|
6418
|
+
if (text.startsWith("//", i)) {
|
|
6419
|
+
const nl = text.indexOf("\n", i);
|
|
6420
|
+
i = nl === -1 ? text.length : nl + 1;
|
|
6421
|
+
} else if (text.startsWith("/*", i)) {
|
|
6422
|
+
const close = text.indexOf("*/", i + 2);
|
|
6423
|
+
i = close === -1 ? text.length : close + 2;
|
|
6424
|
+
} else return i;
|
|
6425
|
+
}
|
|
6426
|
+
}
|
|
6427
|
+
function skipString(text, i) {
|
|
6428
|
+
for (let j = i + 1; j < text.length; j++) {
|
|
6429
|
+
if (text[j] === "\\") j++;
|
|
6430
|
+
else if (text[j] === '"') return j + 1;
|
|
6431
|
+
}
|
|
6432
|
+
throw new Error("an unterminated string");
|
|
6433
|
+
}
|
|
6434
|
+
function skipValue(text, i) {
|
|
6435
|
+
const c = text[i];
|
|
6436
|
+
if (c === '"') return skipString(text, i);
|
|
6437
|
+
if (c === "{" || c === "[") {
|
|
6438
|
+
let depth = 0;
|
|
6439
|
+
for (let j2 = i; j2 < text.length; ) {
|
|
6440
|
+
const d = text[j2];
|
|
6441
|
+
if (d === '"') {
|
|
6442
|
+
j2 = skipString(text, j2);
|
|
6443
|
+
continue;
|
|
6444
|
+
}
|
|
6445
|
+
if (text.startsWith("//", j2) || text.startsWith("/*", j2)) {
|
|
6446
|
+
j2 = skipSpace(text, j2);
|
|
6447
|
+
continue;
|
|
6448
|
+
}
|
|
6449
|
+
if (d === "{" || d === "[") depth++;
|
|
6450
|
+
else if (d === "}" || d === "]") {
|
|
6451
|
+
depth--;
|
|
6452
|
+
if (depth === 0) return j2 + 1;
|
|
6453
|
+
}
|
|
6454
|
+
j2++;
|
|
6455
|
+
}
|
|
6456
|
+
throw new Error("an unclosed object or array");
|
|
6457
|
+
}
|
|
6458
|
+
let j = i;
|
|
6459
|
+
while (j < text.length && !/[\s,}\]]/.test(text[j])) j++;
|
|
6460
|
+
if (j === i) throw new Error(`an unexpected ${JSON.stringify(c ?? "end")} at ${i}`);
|
|
6461
|
+
return j;
|
|
6462
|
+
}
|
|
6463
|
+
function members(text, open) {
|
|
6464
|
+
const out = [];
|
|
6465
|
+
let i = skipSpace(text, open + 1);
|
|
6466
|
+
while (text[i] !== "}") {
|
|
6467
|
+
if (text[i] !== '"') throw new Error(`a key expected at ${i}`);
|
|
6468
|
+
const keyEnd = skipString(text, i);
|
|
6469
|
+
const key2 = JSON.parse(text.slice(i, keyEnd));
|
|
6470
|
+
let j = skipSpace(text, keyEnd);
|
|
6471
|
+
if (text[j] !== ":") throw new Error(`":" expected at ${j}`);
|
|
6472
|
+
const value = skipSpace(text, j + 1);
|
|
6473
|
+
const end = skipValue(text, value);
|
|
6474
|
+
out.push({ key: key2, start: i, end, value });
|
|
6475
|
+
j = skipSpace(text, end);
|
|
6476
|
+
if (text[j] === ",") j = skipSpace(text, j + 1);
|
|
6477
|
+
i = j;
|
|
6478
|
+
if (i >= text.length) throw new Error("an unclosed object");
|
|
6479
|
+
}
|
|
6480
|
+
return out;
|
|
6481
|
+
}
|
|
6482
|
+
function section(text, name) {
|
|
6483
|
+
const open = skipSpace(text, 0);
|
|
6484
|
+
if (text[open] !== "{") throw new Error("not an object");
|
|
6485
|
+
const m = members(text, open).find((x) => x.key === name);
|
|
6486
|
+
return m && text[m.value] === "{" ? m : null;
|
|
6487
|
+
}
|
|
6488
|
+
function parseLoose(fragment) {
|
|
6489
|
+
let out = "";
|
|
6490
|
+
for (let i = 0; i < fragment.length; ) {
|
|
6491
|
+
const c = fragment[i];
|
|
6492
|
+
if (c === '"') {
|
|
6493
|
+
const end = skipString(fragment, i);
|
|
6494
|
+
out += fragment.slice(i, end);
|
|
6495
|
+
i = end;
|
|
6496
|
+
} else if (c === ",") {
|
|
6497
|
+
const next = skipSpace(fragment, i + 1);
|
|
6498
|
+
if (fragment[next] !== "}" && fragment[next] !== "]") out += c;
|
|
6499
|
+
i++;
|
|
6500
|
+
} else if (fragment.startsWith("//", i) || fragment.startsWith("/*", i)) {
|
|
6501
|
+
i = skipSpace(fragment, i);
|
|
6502
|
+
} else {
|
|
6503
|
+
out += c;
|
|
6504
|
+
i++;
|
|
6505
|
+
}
|
|
6506
|
+
}
|
|
6507
|
+
return JSON.parse(out);
|
|
6508
|
+
}
|
|
6509
|
+
function resolution(value) {
|
|
6510
|
+
const first = Array.isArray(value) ? value[0] : null;
|
|
6511
|
+
if (typeof first !== "string") return null;
|
|
6512
|
+
const at = first.lastIndexOf("@");
|
|
6513
|
+
if (at <= 0) return null;
|
|
6514
|
+
return { name: first.slice(0, at), spec: first.slice(at + 1) };
|
|
6515
|
+
}
|
|
6516
|
+
function staleNestedEntries(text, want = () => null) {
|
|
6517
|
+
const packages = section(text, "packages");
|
|
6518
|
+
if (!packages) return [];
|
|
6519
|
+
const list = members(text, packages.value);
|
|
6520
|
+
const value = (m) => parseLoose(text.slice(m.value, m.end));
|
|
6521
|
+
const byKey = new Map(list.map((m) => [m.key, m]));
|
|
6522
|
+
const out = [];
|
|
6523
|
+
for (const m of list) {
|
|
6524
|
+
const tail = GENESIS_TAIL.exec(m.key);
|
|
6525
|
+
if (!tail || tail[1] === m.key) continue;
|
|
6526
|
+
const name = tail[1];
|
|
6527
|
+
const nested = resolution(value(m));
|
|
6528
|
+
if (!nested || nested.name !== name || !PLAIN_VERSION.test(nested.spec)) continue;
|
|
6529
|
+
const rootEntry = byKey.get(name);
|
|
6530
|
+
const rootRes = rootEntry ? resolution(value(rootEntry)) : null;
|
|
6531
|
+
const target = want(name) ?? (rootRes && PLAIN_VERSION.test(rootRes.spec) ? rootRes.spec : null);
|
|
6532
|
+
if (!rootEntry || !target || target === nested.spec) continue;
|
|
6533
|
+
const parent = m.key.slice(0, m.key.length - name.length - 1);
|
|
6534
|
+
const parentEntry = byKey.get(parent);
|
|
6535
|
+
const meta = parentEntry ? value(parentEntry)[2] : void 0;
|
|
6536
|
+
const declared = meta && typeof meta === "object" ? meta : {};
|
|
6537
|
+
const range = ["dependencies", "peerDependencies", "optionalDependencies"].map((s) => declared[s]?.[name]).find((r) => typeof r === "string");
|
|
6538
|
+
if (!range || satisfies(target, range) !== true) continue;
|
|
6539
|
+
out.push({ key: m.key, name, parent, version: nested.spec, root: target, range });
|
|
6540
|
+
}
|
|
6541
|
+
return out;
|
|
6542
|
+
}
|
|
6543
|
+
function readBunLock(dir) {
|
|
6544
|
+
const file = path20.join(dir, BUN_LOCK);
|
|
6545
|
+
return existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
6546
|
+
}
|
|
6547
|
+
function findLockfile(root) {
|
|
6548
|
+
let dir = path20.resolve(root);
|
|
6549
|
+
for (; ; ) {
|
|
6550
|
+
if (existsSync(path20.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
|
|
6551
|
+
if (existsSync(path20.join(dir, "bun.lock")) || existsSync(path20.join(dir, "bun.lockb"))) return { pm: "bun", dir };
|
|
6552
|
+
if (existsSync(path20.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
|
|
6553
|
+
if (existsSync(path20.join(dir, "package-lock.json"))) return { pm: "npm", dir };
|
|
6554
|
+
const parent = path20.dirname(dir);
|
|
6555
|
+
if (parent === dir) return null;
|
|
6556
|
+
dir = parent;
|
|
6557
|
+
}
|
|
6558
|
+
}
|
|
6351
6559
|
|
|
6352
6560
|
// src/doctor/lock-files.ts
|
|
6561
|
+
function checkBunLock(ctx) {
|
|
6562
|
+
const found = findLockfile(ctx.root);
|
|
6563
|
+
if (found?.pm !== "bun") return;
|
|
6564
|
+
const text = readBunLock(found.dir);
|
|
6565
|
+
if (text === null) return;
|
|
6566
|
+
const file = path20.relative(ctx.root, path20.join(found.dir, BUN_LOCK)).split(path20.sep).join("/");
|
|
6567
|
+
let stale;
|
|
6568
|
+
try {
|
|
6569
|
+
stale = staleNestedEntries(text);
|
|
6570
|
+
} catch {
|
|
6571
|
+
return;
|
|
6572
|
+
}
|
|
6573
|
+
for (const s of stale) {
|
|
6574
|
+
ctx.report({
|
|
6575
|
+
rule: "lock-files",
|
|
6576
|
+
level: "warn",
|
|
6577
|
+
file,
|
|
6578
|
+
subject: s.key,
|
|
6579
|
+
message: `keeps a nested copy of ${s.name}@${s.version} under ${s.parent} beside the root's ${s.root}, which satisfies its ${s.range}: Bun keeps it across installs, so the app runs two copies (a provider from one is invisible to hooks from the other). Delete the "${s.key}" entry from ${file}'s packages, then reinstall (bun install); genesis upgrade does both`
|
|
6580
|
+
});
|
|
6581
|
+
}
|
|
6582
|
+
}
|
|
6353
6583
|
async function checkLockFiles(ctx) {
|
|
6584
|
+
checkBunLock(ctx);
|
|
6354
6585
|
if (!existsSync(path20.join(ctx.root, LOCK_FILE))) return;
|
|
6355
6586
|
let lock;
|
|
6356
6587
|
try {
|
|
@@ -6463,7 +6694,37 @@ function checkDatabaseHome(ctx) {
|
|
|
6463
6694
|
});
|
|
6464
6695
|
}
|
|
6465
6696
|
}
|
|
6466
|
-
|
|
6697
|
+
function checkEslintConfig(ctx) {
|
|
6698
|
+
const pkg = readPackageJson(ctx.root);
|
|
6699
|
+
const native = appPlatform(pkg) === "native" || (ctx.config.packs?.includes("native") ?? false);
|
|
6700
|
+
if (!native) return;
|
|
6701
|
+
const file = findEslintConfig(ctx.root);
|
|
6702
|
+
if (!file) return;
|
|
6703
|
+
let text;
|
|
6704
|
+
try {
|
|
6705
|
+
text = readFileSync(path20.join(ctx.root, file), "utf8");
|
|
6706
|
+
} catch {
|
|
6707
|
+
return;
|
|
6708
|
+
}
|
|
6709
|
+
if (!usesGenesisLint(text)) {
|
|
6710
|
+
ctx.report({
|
|
6711
|
+
rule: "genesis-eslint-config",
|
|
6712
|
+
level: "warn",
|
|
6713
|
+
file,
|
|
6714
|
+
subject: "@marktiderman/genesis-cli/eslint",
|
|
6715
|
+
message: `doesn't load Genesis's lint rules, so genesis upgrade can't bring new ones (React Native Testing Library 14's await rules today). Run genesis codemod genesis-cli-eslint-config, or add const { genesis } = require("@marktiderman/genesis-cli/eslint") (import { genesis } from \u2026 in an ES module) and ...genesis("native") last in the array the config exports, with ${TESTING_LIBRARY} in devDependencies`
|
|
6716
|
+
});
|
|
6717
|
+
} else if (!hasTestingLibrary(pkg)) {
|
|
6718
|
+
ctx.report({
|
|
6719
|
+
rule: "genesis-eslint-config",
|
|
6720
|
+
level: "warn",
|
|
6721
|
+
file: "package.json",
|
|
6722
|
+
subject: TESTING_LIBRARY,
|
|
6723
|
+
message: `${file} loads Genesis's native lint rules, which need ${TESTING_LIBRARY}: add it to devDependencies (pnpm add -D ${TESTING_LIBRARY}), or the lint can't load its config`
|
|
6724
|
+
});
|
|
6725
|
+
}
|
|
6726
|
+
}
|
|
6727
|
+
var RATCHETED_BY_DEFAULT = ["deprecated-import", "genesis-eslint-config"];
|
|
6467
6728
|
async function runDoctor(options = {}) {
|
|
6468
6729
|
const root = path20.resolve(options.root ?? process.cwd());
|
|
6469
6730
|
const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);
|
|
@@ -6566,6 +6827,7 @@ function builtinChecks(config, options = {}) {
|
|
|
6566
6827
|
{ name: "overlays", check: (ctx) => checkOverlays(ctx) },
|
|
6567
6828
|
{ name: "lock-files", check: checkLockFiles },
|
|
6568
6829
|
{ name: "database-elsewhere", check: checkDatabaseHome },
|
|
6830
|
+
{ name: "eslint-config", check: checkEslintConfig },
|
|
6569
6831
|
...(config.packs ?? []).map((p) => packs[p]),
|
|
6570
6832
|
...config.packs?.includes("supabase") && config.contracts && options.contracts !== false ? [{ name: "contracts", check: (ctx) => checkContracts(ctx) }] : []
|
|
6571
6833
|
];
|