@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/index.js
CHANGED
|
@@ -456,14 +456,14 @@ function inherit(own, source) {
|
|
|
456
456
|
}
|
|
457
457
|
function resolveViews(relations) {
|
|
458
458
|
const done = /* @__PURE__ */ new Set();
|
|
459
|
-
const
|
|
459
|
+
const resolve17 = (relation, depth) => {
|
|
460
460
|
if (done.has(relation.oid) || !relation.origins || depth > MAX_VIEW_DEPTH) return;
|
|
461
461
|
done.add(relation.oid);
|
|
462
462
|
const sources = new Set([...relation.origins.values()].map((o) => o.relation));
|
|
463
463
|
if (sources.size !== 1) return;
|
|
464
464
|
const source = relations.get([...sources][0]);
|
|
465
465
|
if (!source) return;
|
|
466
|
-
|
|
466
|
+
resolve17(source, depth + 1);
|
|
467
467
|
const viewAttnumOf = /* @__PURE__ */ new Map();
|
|
468
468
|
for (const [attnum, origin] of relation.origins) {
|
|
469
469
|
const own = relation.columns.get(attnum);
|
|
@@ -486,7 +486,7 @@ function resolveViews(relations) {
|
|
|
486
486
|
};
|
|
487
487
|
if (Object.keys(inherited).length) relation.table.settings = { ...inherited, ...relation.table.settings };
|
|
488
488
|
};
|
|
489
|
-
for (const relation of relations.values())
|
|
489
|
+
for (const relation of relations.values()) resolve17(relation, 0);
|
|
490
490
|
}
|
|
491
491
|
async function introspectPostgres(sql, schemas, options = {}) {
|
|
492
492
|
const relations = /* @__PURE__ */ new Map();
|
|
@@ -816,9 +816,9 @@ async function runScaffold(opts, fs) {
|
|
|
816
816
|
function joinPath(...parts) {
|
|
817
817
|
return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
|
|
818
818
|
}
|
|
819
|
-
function dirname(
|
|
820
|
-
const idx =
|
|
821
|
-
return idx === -1 ? "." :
|
|
819
|
+
function dirname(path43) {
|
|
820
|
+
const idx = path43.lastIndexOf("/");
|
|
821
|
+
return idx === -1 ? "." : path43.slice(0, idx);
|
|
822
822
|
}
|
|
823
823
|
function brandPackageJson(consumer, genesisVersion) {
|
|
824
824
|
return JSON.stringify(
|
|
@@ -1076,8 +1076,8 @@ function routeTags(source) {
|
|
|
1076
1076
|
var GUARD = /<((?:[A-Z]\w*)?(?:Admin|Staff)\w*(?:Guard|Route|Only)|RequireAdmin|RequireStaff)>/;
|
|
1077
1077
|
function wireStudioRoute(source, route, pageImportPath) {
|
|
1078
1078
|
const tags = routeTags(source);
|
|
1079
|
-
const
|
|
1080
|
-
const existing = tags.find((t) => new RegExp(`path=["'](/?${
|
|
1079
|
+
const relative11 = route.replace(/^\//, "");
|
|
1080
|
+
const existing = tags.find((t) => new RegExp(`path=["'](/?${relative11.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")})["']`).test(t.text));
|
|
1081
1081
|
if (existing) {
|
|
1082
1082
|
return { skipped: `Your router already has a page at ${route}. Replace its element with <DataStudioPage /> to use the studio there.` };
|
|
1083
1083
|
}
|
|
@@ -1085,17 +1085,17 @@ function wireStudioRoute(source, route, pageImportPath) {
|
|
|
1085
1085
|
const roots = layouts.length ? layouts : tags.filter((t) => !t.selfClosing && t.close !== void 0 && /path=["']\/["']/.test(t.text));
|
|
1086
1086
|
if (roots.length !== 1) {
|
|
1087
1087
|
return {
|
|
1088
|
-
skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${
|
|
1088
|
+
skipped: roots.length === 0 ? `No layout route found to put the page under. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.` : `More than one layout route; add <Route path="${relative11}" element={<DataStudioPage />} /> inside the one your other admin pages use.`
|
|
1089
1089
|
};
|
|
1090
1090
|
}
|
|
1091
1091
|
const layout = roots[0];
|
|
1092
1092
|
const base = (/\bpath=["']([^"']*)["']/.exec(layout.text)?.[1] ?? "").replace(/^\/+|\/+$/g, "");
|
|
1093
|
-
if (base && !
|
|
1093
|
+
if (base && !relative11.startsWith(`${base}/`)) {
|
|
1094
1094
|
return {
|
|
1095
1095
|
skipped: `Your layout route lives at /${base}, outside ${route}. Add <Route path="${route}" element={<DataStudioPage />} /> where your app's other pages are.`
|
|
1096
1096
|
};
|
|
1097
1097
|
}
|
|
1098
|
-
const childPath = base ?
|
|
1098
|
+
const childPath = base ? relative11.slice(base.length + 1) : relative11;
|
|
1099
1099
|
const guard = GUARD.exec(source)?.[1];
|
|
1100
1100
|
const element = guard ? `<${guard}><DataStudioPage /></${guard}>` : "<DataStudioPage />";
|
|
1101
1101
|
const before = source.slice(0, layout.close);
|
|
@@ -1831,7 +1831,7 @@ function globToRegExp(glob) {
|
|
|
1831
1831
|
}
|
|
1832
1832
|
function globMatcher(globs) {
|
|
1833
1833
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1834
|
-
return (
|
|
1834
|
+
return (path43) => res.some((re) => re.test(path43));
|
|
1835
1835
|
}
|
|
1836
1836
|
var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
|
|
1837
1837
|
var NATIVE_UI_PACKAGE = "@marktiderman/genesis-ui-native";
|
|
@@ -2143,6 +2143,7 @@ var FUNCTION_NAME = /^[a-z0-9][a-z0-9_-]*$/;
|
|
|
2143
2143
|
var ROUTE = /^\/(?:[A-Za-z0-9_\-[\]().]+\/?)*$/;
|
|
2144
2144
|
var INSTALL_SPEC = /^(@[a-z0-9][a-z0-9._-]*\/)?[a-z0-9][a-z0-9._-]*(@[A-Za-z0-9.^~<>=|* -]+)?$/;
|
|
2145
2145
|
var SECRET = /^[A-Z][A-Z0-9_]*$/;
|
|
2146
|
+
var SQL_FUNCTION = /^[a-z_][a-z0-9_]*\.[a-z_][a-z0-9_]*$/;
|
|
2146
2147
|
var ManifestError = class extends Error {
|
|
2147
2148
|
constructor(problems) {
|
|
2148
2149
|
super(`Invalid block manifest:
|
|
@@ -2237,6 +2238,39 @@ function parseManifest(home, id, raw, version, options = {}) {
|
|
|
2237
2238
|
});
|
|
2238
2239
|
}
|
|
2239
2240
|
}
|
|
2241
|
+
if (m["needs"] !== void 0) {
|
|
2242
|
+
if (!Array.isArray(m["needs"])) problems.push(`${where2}.needs: must be a list of { function, how }`);
|
|
2243
|
+
else {
|
|
2244
|
+
out.needs = m["needs"].flatMap((n, j) => {
|
|
2245
|
+
const at2 = `${where2}.needs[${j}]`;
|
|
2246
|
+
if (!isObject2(n) || typeof n["function"] !== "string" || typeof n["how"] !== "string" || !n["how"].trim()) {
|
|
2247
|
+
problems.push(`${at2}: must be { function: "schema.name", how: "what to add" }`);
|
|
2248
|
+
return [];
|
|
2249
|
+
}
|
|
2250
|
+
if (!SQL_FUNCTION.test(n["function"])) {
|
|
2251
|
+
problems.push(`${at2}.function: "${n["function"]}" must be a schema-qualified function name, like private.genesis_viewer_people`);
|
|
2252
|
+
return [];
|
|
2253
|
+
}
|
|
2254
|
+
return [{ function: n["function"], how: n["how"].trim() }];
|
|
2255
|
+
});
|
|
2256
|
+
}
|
|
2257
|
+
}
|
|
2258
|
+
if (m["runsBefore"] !== void 0) {
|
|
2259
|
+
if (!Array.isArray(m["runsBefore"])) problems.push(`${where2}.runsBefore: must be a list of { package, file }`);
|
|
2260
|
+
else {
|
|
2261
|
+
out.runsBefore = m["runsBefore"].map((r, j) => {
|
|
2262
|
+
const at2 = `${where2}.runsBefore[${j}]`;
|
|
2263
|
+
if (!isObject2(r)) {
|
|
2264
|
+
problems.push(`${at2}: must be an object`);
|
|
2265
|
+
return { package: home, file: "" };
|
|
2266
|
+
}
|
|
2267
|
+
const before = { package: pkgOf(r["package"], at2), file: pathOf(r["file"], `${at2}.file`) };
|
|
2268
|
+
if (before.file && !MIGRATION_FILE.test(before.file.split("/").pop())) problems.push(`${at2}.file: "${before.file}" must be named NNNN_name.sql`);
|
|
2269
|
+
if (before.package === out.package && before.file === file) problems.push(`${at2}: a migration can't run before itself`);
|
|
2270
|
+
return before;
|
|
2271
|
+
});
|
|
2272
|
+
}
|
|
2273
|
+
}
|
|
2240
2274
|
if (m["test"] !== void 0) {
|
|
2241
2275
|
out.test = pathOf(m["test"], `${where2}.test`);
|
|
2242
2276
|
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`);
|
|
@@ -3047,8 +3081,8 @@ function pinnedVersion(root, name, manifests = ["package.json"]) {
|
|
|
3047
3081
|
} catch {
|
|
3048
3082
|
continue;
|
|
3049
3083
|
}
|
|
3050
|
-
for (const
|
|
3051
|
-
const spec = json[
|
|
3084
|
+
for (const section2 of ["dependencies", "devDependencies", "optionalDependencies"]) {
|
|
3085
|
+
const spec = json[section2]?.[name];
|
|
3052
3086
|
const v = typeof spec === "string" ? /^[\^~=]?(\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?)$/.exec(spec)?.[1] : void 0;
|
|
3053
3087
|
const parsed = v && parseVersion(v);
|
|
3054
3088
|
if (parsed && (!best || compareVersions(parsed, parseVersion(best)) > 0)) best = v;
|
|
@@ -3201,7 +3235,9 @@ var BUILTIN_RULES = [
|
|
|
3201
3235
|
// genesis.lock.json against the files (lock-files.ts)
|
|
3202
3236
|
"lock-files",
|
|
3203
3237
|
// an app whose database files live in another app (database.ts)
|
|
3204
|
-
"database-elsewhere"
|
|
3238
|
+
"database-elsewhere",
|
|
3239
|
+
// the app's eslint config loads Genesis's lint rules (eslint-config.ts)
|
|
3240
|
+
"genesis-eslint-config"
|
|
3205
3241
|
];
|
|
3206
3242
|
var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
3207
3243
|
var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -6253,6 +6289,31 @@ function readsPracticeId(text) {
|
|
|
6253
6289
|
var augmentsResourceScope = (text) => /\binterface\s+ResourceScope\b/.test(text);
|
|
6254
6290
|
var PRACTICE_ID_AUGMENTATION = 'declare module "@marktiderman/genesis-core" { interface ResourceScope { practiceId?: string } }';
|
|
6255
6291
|
|
|
6292
|
+
// src/upgrade/eslint-config.ts
|
|
6293
|
+
var ESLINT_EXPORT = "@marktiderman/genesis-cli/eslint";
|
|
6294
|
+
var TESTING_LIBRARY = "eslint-plugin-testing-library";
|
|
6295
|
+
var FLAT_CONFIG_FILES = ["eslint.config.js", "eslint.config.mjs", "eslint.config.cjs", "eslint.config.ts", "eslint.config.mts", "eslint.config.cts"];
|
|
6296
|
+
function findEslintConfig(root) {
|
|
6297
|
+
return FLAT_CONFIG_FILES.find((name) => existsSync(path20.join(root, name))) ?? null;
|
|
6298
|
+
}
|
|
6299
|
+
function readPackageJson(root) {
|
|
6300
|
+
try {
|
|
6301
|
+
return JSON.parse(readFileSync(path20.join(root, "package.json"), "utf8"));
|
|
6302
|
+
} catch {
|
|
6303
|
+
return null;
|
|
6304
|
+
}
|
|
6305
|
+
}
|
|
6306
|
+
var declares = (pkg, name) => Boolean(pkg?.dependencies?.[name] ?? pkg?.devDependencies?.[name] ?? pkg?.peerDependencies?.[name]);
|
|
6307
|
+
function appPlatform(pkg) {
|
|
6308
|
+
return declares(pkg, "expo") || declares(pkg, "react-native") ? "native" : "web";
|
|
6309
|
+
}
|
|
6310
|
+
function hasTestingLibrary(pkg) {
|
|
6311
|
+
return declares(pkg, TESTING_LIBRARY);
|
|
6312
|
+
}
|
|
6313
|
+
function usesGenesisLint(text) {
|
|
6314
|
+
return text.includes(ESLINT_EXPORT);
|
|
6315
|
+
}
|
|
6316
|
+
|
|
6256
6317
|
// src/upgrade/codemods.ts
|
|
6257
6318
|
var SKIP_DIRS3 = /* @__PURE__ */ new Set(["node_modules", "dist", "build", ".git", ".next", ".output", ".turbo", ".expo", "coverage", "ios", "android"]);
|
|
6258
6319
|
var SCRIPT2 = /\.(?:[cm]?[jt]sx?)$/;
|
|
@@ -6995,9 +7056,179 @@ function blockOfSource(source, manifests) {
|
|
|
6995
7056
|
}
|
|
6996
7057
|
return null;
|
|
6997
7058
|
}
|
|
7059
|
+
var BUN_LOCK = "bun.lock";
|
|
7060
|
+
var GENESIS_TAIL = /(?:^|\/)(@marktiderman\/genesis(?:-[a-z0-9-]+)?)$/;
|
|
7061
|
+
var PLAIN_VERSION = /^\d+\.\d+\.\d+(?:[-+][0-9A-Za-z.+-]+)?$/;
|
|
7062
|
+
function skipSpace(text, i) {
|
|
7063
|
+
for (; ; ) {
|
|
7064
|
+
while (i < text.length && /\s/.test(text[i])) i++;
|
|
7065
|
+
if (text.startsWith("//", i)) {
|
|
7066
|
+
const nl = text.indexOf("\n", i);
|
|
7067
|
+
i = nl === -1 ? text.length : nl + 1;
|
|
7068
|
+
} else if (text.startsWith("/*", i)) {
|
|
7069
|
+
const close = text.indexOf("*/", i + 2);
|
|
7070
|
+
i = close === -1 ? text.length : close + 2;
|
|
7071
|
+
} else return i;
|
|
7072
|
+
}
|
|
7073
|
+
}
|
|
7074
|
+
function skipString(text, i) {
|
|
7075
|
+
for (let j = i + 1; j < text.length; j++) {
|
|
7076
|
+
if (text[j] === "\\") j++;
|
|
7077
|
+
else if (text[j] === '"') return j + 1;
|
|
7078
|
+
}
|
|
7079
|
+
throw new Error("an unterminated string");
|
|
7080
|
+
}
|
|
7081
|
+
function skipValue(text, i) {
|
|
7082
|
+
const c = text[i];
|
|
7083
|
+
if (c === '"') return skipString(text, i);
|
|
7084
|
+
if (c === "{" || c === "[") {
|
|
7085
|
+
let depth = 0;
|
|
7086
|
+
for (let j2 = i; j2 < text.length; ) {
|
|
7087
|
+
const d = text[j2];
|
|
7088
|
+
if (d === '"') {
|
|
7089
|
+
j2 = skipString(text, j2);
|
|
7090
|
+
continue;
|
|
7091
|
+
}
|
|
7092
|
+
if (text.startsWith("//", j2) || text.startsWith("/*", j2)) {
|
|
7093
|
+
j2 = skipSpace(text, j2);
|
|
7094
|
+
continue;
|
|
7095
|
+
}
|
|
7096
|
+
if (d === "{" || d === "[") depth++;
|
|
7097
|
+
else if (d === "}" || d === "]") {
|
|
7098
|
+
depth--;
|
|
7099
|
+
if (depth === 0) return j2 + 1;
|
|
7100
|
+
}
|
|
7101
|
+
j2++;
|
|
7102
|
+
}
|
|
7103
|
+
throw new Error("an unclosed object or array");
|
|
7104
|
+
}
|
|
7105
|
+
let j = i;
|
|
7106
|
+
while (j < text.length && !/[\s,}\]]/.test(text[j])) j++;
|
|
7107
|
+
if (j === i) throw new Error(`an unexpected ${JSON.stringify(c ?? "end")} at ${i}`);
|
|
7108
|
+
return j;
|
|
7109
|
+
}
|
|
7110
|
+
function members(text, open) {
|
|
7111
|
+
const out = [];
|
|
7112
|
+
let i = skipSpace(text, open + 1);
|
|
7113
|
+
while (text[i] !== "}") {
|
|
7114
|
+
if (text[i] !== '"') throw new Error(`a key expected at ${i}`);
|
|
7115
|
+
const keyEnd = skipString(text, i);
|
|
7116
|
+
const key2 = JSON.parse(text.slice(i, keyEnd));
|
|
7117
|
+
let j = skipSpace(text, keyEnd);
|
|
7118
|
+
if (text[j] !== ":") throw new Error(`":" expected at ${j}`);
|
|
7119
|
+
const value = skipSpace(text, j + 1);
|
|
7120
|
+
const end = skipValue(text, value);
|
|
7121
|
+
out.push({ key: key2, start: i, end, value });
|
|
7122
|
+
j = skipSpace(text, end);
|
|
7123
|
+
if (text[j] === ",") j = skipSpace(text, j + 1);
|
|
7124
|
+
i = j;
|
|
7125
|
+
if (i >= text.length) throw new Error("an unclosed object");
|
|
7126
|
+
}
|
|
7127
|
+
return out;
|
|
7128
|
+
}
|
|
7129
|
+
function section(text, name) {
|
|
7130
|
+
const open = skipSpace(text, 0);
|
|
7131
|
+
if (text[open] !== "{") throw new Error("not an object");
|
|
7132
|
+
const m = members(text, open).find((x) => x.key === name);
|
|
7133
|
+
return m && text[m.value] === "{" ? m : null;
|
|
7134
|
+
}
|
|
7135
|
+
function parseLoose(fragment) {
|
|
7136
|
+
let out = "";
|
|
7137
|
+
for (let i = 0; i < fragment.length; ) {
|
|
7138
|
+
const c = fragment[i];
|
|
7139
|
+
if (c === '"') {
|
|
7140
|
+
const end = skipString(fragment, i);
|
|
7141
|
+
out += fragment.slice(i, end);
|
|
7142
|
+
i = end;
|
|
7143
|
+
} else if (c === ",") {
|
|
7144
|
+
const next = skipSpace(fragment, i + 1);
|
|
7145
|
+
if (fragment[next] !== "}" && fragment[next] !== "]") out += c;
|
|
7146
|
+
i++;
|
|
7147
|
+
} else if (fragment.startsWith("//", i) || fragment.startsWith("/*", i)) {
|
|
7148
|
+
i = skipSpace(fragment, i);
|
|
7149
|
+
} else {
|
|
7150
|
+
out += c;
|
|
7151
|
+
i++;
|
|
7152
|
+
}
|
|
7153
|
+
}
|
|
7154
|
+
return JSON.parse(out);
|
|
7155
|
+
}
|
|
7156
|
+
function resolution(value) {
|
|
7157
|
+
const first = Array.isArray(value) ? value[0] : null;
|
|
7158
|
+
if (typeof first !== "string") return null;
|
|
7159
|
+
const at = first.lastIndexOf("@");
|
|
7160
|
+
if (at <= 0) return null;
|
|
7161
|
+
return { name: first.slice(0, at), spec: first.slice(at + 1) };
|
|
7162
|
+
}
|
|
7163
|
+
function staleNestedEntries(text, want = () => null) {
|
|
7164
|
+
const packages = section(text, "packages");
|
|
7165
|
+
if (!packages) return [];
|
|
7166
|
+
const list = members(text, packages.value);
|
|
7167
|
+
const value = (m) => parseLoose(text.slice(m.value, m.end));
|
|
7168
|
+
const byKey = new Map(list.map((m) => [m.key, m]));
|
|
7169
|
+
const out = [];
|
|
7170
|
+
for (const m of list) {
|
|
7171
|
+
const tail = GENESIS_TAIL.exec(m.key);
|
|
7172
|
+
if (!tail || tail[1] === m.key) continue;
|
|
7173
|
+
const name = tail[1];
|
|
7174
|
+
const nested = resolution(value(m));
|
|
7175
|
+
if (!nested || nested.name !== name || !PLAIN_VERSION.test(nested.spec)) continue;
|
|
7176
|
+
const rootEntry = byKey.get(name);
|
|
7177
|
+
const rootRes = rootEntry ? resolution(value(rootEntry)) : null;
|
|
7178
|
+
const target = want(name) ?? (rootRes && PLAIN_VERSION.test(rootRes.spec) ? rootRes.spec : null);
|
|
7179
|
+
if (!rootEntry || !target || target === nested.spec) continue;
|
|
7180
|
+
const parent = m.key.slice(0, m.key.length - name.length - 1);
|
|
7181
|
+
const parentEntry = byKey.get(parent);
|
|
7182
|
+
const meta = parentEntry ? value(parentEntry)[2] : void 0;
|
|
7183
|
+
const declared = meta && typeof meta === "object" ? meta : {};
|
|
7184
|
+
const range = ["dependencies", "peerDependencies", "optionalDependencies"].map((s) => declared[s]?.[name]).find((r) => typeof r === "string");
|
|
7185
|
+
if (!range || satisfies(target, range) !== true) continue;
|
|
7186
|
+
out.push({ key: m.key, name, parent, version: nested.spec, root: target, range });
|
|
7187
|
+
}
|
|
7188
|
+
return out;
|
|
7189
|
+
}
|
|
7190
|
+
function readBunLock(dir) {
|
|
7191
|
+
const file = path20.join(dir, BUN_LOCK);
|
|
7192
|
+
return existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
7193
|
+
}
|
|
7194
|
+
function findLockfile(root) {
|
|
7195
|
+
let dir = path20.resolve(root);
|
|
7196
|
+
for (; ; ) {
|
|
7197
|
+
if (existsSync(path20.join(dir, "pnpm-lock.yaml"))) return { pm: "pnpm", dir };
|
|
7198
|
+
if (existsSync(path20.join(dir, "bun.lock")) || existsSync(path20.join(dir, "bun.lockb"))) return { pm: "bun", dir };
|
|
7199
|
+
if (existsSync(path20.join(dir, "yarn.lock"))) return { pm: "yarn", dir };
|
|
7200
|
+
if (existsSync(path20.join(dir, "package-lock.json"))) return { pm: "npm", dir };
|
|
7201
|
+
const parent = path20.dirname(dir);
|
|
7202
|
+
if (parent === dir) return null;
|
|
7203
|
+
dir = parent;
|
|
7204
|
+
}
|
|
7205
|
+
}
|
|
6998
7206
|
|
|
6999
7207
|
// src/doctor/lock-files.ts
|
|
7208
|
+
function checkBunLock(ctx) {
|
|
7209
|
+
const found = findLockfile(ctx.root);
|
|
7210
|
+
if (found?.pm !== "bun") return;
|
|
7211
|
+
const text = readBunLock(found.dir);
|
|
7212
|
+
if (text === null) return;
|
|
7213
|
+
const file = path20.relative(ctx.root, path20.join(found.dir, BUN_LOCK)).split(path20.sep).join("/");
|
|
7214
|
+
let stale;
|
|
7215
|
+
try {
|
|
7216
|
+
stale = staleNestedEntries(text);
|
|
7217
|
+
} catch {
|
|
7218
|
+
return;
|
|
7219
|
+
}
|
|
7220
|
+
for (const s of stale) {
|
|
7221
|
+
ctx.report({
|
|
7222
|
+
rule: "lock-files",
|
|
7223
|
+
level: "warn",
|
|
7224
|
+
file,
|
|
7225
|
+
subject: s.key,
|
|
7226
|
+
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`
|
|
7227
|
+
});
|
|
7228
|
+
}
|
|
7229
|
+
}
|
|
7000
7230
|
async function checkLockFiles(ctx) {
|
|
7231
|
+
checkBunLock(ctx);
|
|
7001
7232
|
if (!existsSync(path20.join(ctx.root, LOCK_FILE))) return;
|
|
7002
7233
|
let lock;
|
|
7003
7234
|
try {
|
|
@@ -7110,7 +7341,37 @@ function checkDatabaseHome(ctx) {
|
|
|
7110
7341
|
});
|
|
7111
7342
|
}
|
|
7112
7343
|
}
|
|
7113
|
-
|
|
7344
|
+
function checkEslintConfig(ctx) {
|
|
7345
|
+
const pkg = readPackageJson(ctx.root);
|
|
7346
|
+
const native = appPlatform(pkg) === "native" || (ctx.config.packs?.includes("native") ?? false);
|
|
7347
|
+
if (!native) return;
|
|
7348
|
+
const file = findEslintConfig(ctx.root);
|
|
7349
|
+
if (!file) return;
|
|
7350
|
+
let text;
|
|
7351
|
+
try {
|
|
7352
|
+
text = readFileSync(path20.join(ctx.root, file), "utf8");
|
|
7353
|
+
} catch {
|
|
7354
|
+
return;
|
|
7355
|
+
}
|
|
7356
|
+
if (!usesGenesisLint(text)) {
|
|
7357
|
+
ctx.report({
|
|
7358
|
+
rule: "genesis-eslint-config",
|
|
7359
|
+
level: "warn",
|
|
7360
|
+
file,
|
|
7361
|
+
subject: "@marktiderman/genesis-cli/eslint",
|
|
7362
|
+
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`
|
|
7363
|
+
});
|
|
7364
|
+
} else if (!hasTestingLibrary(pkg)) {
|
|
7365
|
+
ctx.report({
|
|
7366
|
+
rule: "genesis-eslint-config",
|
|
7367
|
+
level: "warn",
|
|
7368
|
+
file: "package.json",
|
|
7369
|
+
subject: TESTING_LIBRARY,
|
|
7370
|
+
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`
|
|
7371
|
+
});
|
|
7372
|
+
}
|
|
7373
|
+
}
|
|
7374
|
+
var RATCHETED_BY_DEFAULT = ["deprecated-import", "genesis-eslint-config"];
|
|
7114
7375
|
async function runDoctor(options = {}) {
|
|
7115
7376
|
const root = path20.resolve(options.root ?? process.cwd());
|
|
7116
7377
|
const loaded = options.config ? { config: options.config, dir: root } : loadConfig(root, options.configPath);
|
|
@@ -7213,6 +7474,7 @@ function builtinChecks(config, options = {}) {
|
|
|
7213
7474
|
{ name: "overlays", check: (ctx) => checkOverlays(ctx) },
|
|
7214
7475
|
{ name: "lock-files", check: checkLockFiles },
|
|
7215
7476
|
{ name: "database-elsewhere", check: checkDatabaseHome },
|
|
7477
|
+
{ name: "eslint-config", check: checkEslintConfig },
|
|
7216
7478
|
...(config.packs ?? []).map((p) => packs[p]),
|
|
7217
7479
|
...config.packs?.includes("supabase") && config.contracts && options.contracts !== false ? [{ name: "contracts", check: (ctx) => checkContracts(ctx) }] : []
|
|
7218
7480
|
];
|