@marktiderman/genesis-cli 1.18.0 → 1.19.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 +78 -2
- package/dist/cli.js +789 -403
- package/dist/cli.js.map +1 -1
- package/dist/{config-1jP8eCZy.d.ts → config-Dj_f9T7J.d.ts} +14 -1
- package/dist/doctor.d.ts +3 -3
- package/dist/doctor.js +171 -37
- package/dist/doctor.js.map +1 -1
- package/dist/expo.d.ts +2 -2
- package/dist/expo.js +18 -0
- package/dist/expo.js.map +1 -1
- package/dist/genesis-catalog.json +26 -13
- package/dist/index.d.ts +1 -1
- package/dist/index.js +174 -40
- package/dist/index.js.map +1 -1
- package/dist/starter/README.md +9 -0
- package/dist/starter/__tests__/components/gestures.test.tsx +64 -0
- package/dist/starter/__tests__/components/resolver.js +14 -2
- package/dist/starter/__tests__/components/setup.ts +5 -0
- package/dist/starter/__tests__/starter.test.ts +27 -7
- package/dist/starter/jest.config.js +3 -0
- package/dist/starter/package.json +2 -0
- package/dist/starter/src/lib/link-hosts.ts +7 -3
- package/dist/starter/supabase/functions/genesis-apple-revoke/apple.ts +7 -2
- package/dist/starter/supabase/migrations/20261024000700_genesis_support_findings.sql +339 -0
- package/dist/starter/supabase/tests/database/genesis_support.test.sql +1 -1
- package/dist/starter/supabase/tests/database/genesis_support_findings.test.sql +219 -0
- package/dist/templates/ci/genesis-upgrade.yml +1 -0
- package/dist/vite.js +171 -37
- package/dist/vite.js.map +1 -1
- package/package.json +2 -2
|
@@ -391,12 +391,25 @@ interface GenesisPrivacy {
|
|
|
391
391
|
/** `NSPrivacyTracking`. Default false; true needs `NSPrivacyTrackingDomains` in app.config. */
|
|
392
392
|
tracking?: boolean;
|
|
393
393
|
}
|
|
394
|
+
/**
|
|
395
|
+
* The top-level `supabase` setting: where this app's database files (migrations, pgTAP tests,
|
|
396
|
+
* Edge Functions, config.toml) live. Left out (or `true`), they are this app's own `supabase/`.
|
|
397
|
+
* `false`: this app has none. `{ app }`: another Genesis app's folder, relative to this one
|
|
398
|
+
* (`"../app"`), whose `supabase/` holds them; a phone app beside a web app shares its database.
|
|
399
|
+
* Either way `genesis add`, `migrate`, `upgrade` and `init` never write or plan Supabase files
|
|
400
|
+
* here, and the doctor's supabase pack doesn't run.
|
|
401
|
+
*/
|
|
402
|
+
type GenesisSupabase = false | {
|
|
403
|
+
app: string;
|
|
404
|
+
};
|
|
394
405
|
/** genesis.config.json, parsed, with its shared blocks validated. */
|
|
395
406
|
interface GenesisConfigFile {
|
|
396
407
|
/** The whole parsed file, for blocks other readers own (`doctor`, `features`). */
|
|
397
408
|
raw: Record<string, unknown>;
|
|
398
409
|
links?: GenesisLinks;
|
|
399
410
|
privacy?: GenesisPrivacy;
|
|
411
|
+
/** Set only when the database files live elsewhere (see {@link GenesisSupabase}). */
|
|
412
|
+
supabase?: GenesisSupabase;
|
|
400
413
|
}
|
|
401
414
|
interface LoadedConfig {
|
|
402
415
|
config: DoctorConfig;
|
|
@@ -423,4 +436,4 @@ declare function validateLinks(raw: unknown, source?: string): GenesisLinks;
|
|
|
423
436
|
/** Check the shape, so a typo fails loudly instead of silently disabling a check. */
|
|
424
437
|
declare function validateConfig(raw: unknown, source?: string): DoctorConfig;
|
|
425
438
|
|
|
426
|
-
export { type AllowEntry as A,
|
|
439
|
+
export { type AllowEntry as A, type SupabasePackConfig as B, type CompanionPackage as C, type DoctorConfig as D, loadConfig as E, type Finding as F, type GenesisDataUse as G, validateConfig as H, type Level as L, type NativePackConfig as N, PRIVACY_DATA_TYPES as P, type RuleSetting as R, type SourceFile as S, type GenesisPrivacy as a, type GenesisLinks as b, GenesisConfigError as c, PRIVACY_PURPOSES as d, validatePrivacy as e, DoctorConfigError as f, type DoctorContext as g, type DoctorPlugin as h, type DoctorResult as i, type GenesisConfigFile as j, type GenesisSupabase as k, type GenesisFacts as l, type PatternRule as m, type PreferRule as n, type DeclaringPackage as o, privacyDataType as p, type PackageDeclaration as q, readGenesisConfig as r, type ContractsConfig as s, type DoctorPack as t, type FindingInput as u, validateLinks as v, type PackageRuleSetting as w, type PackagesPackConfig as x, type PluginSpec as y, type PrimitiveEntry as z };
|
package/dist/doctor.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as DoctorConfig,
|
|
2
|
-
export { A as AllowEntry, C as CompanionPackage,
|
|
1
|
+
import { D as DoctorConfig, l as GenesisFacts, m as PatternRule, h as DoctorPlugin, S as SourceFile, g as DoctorContext, n as PreferRule, o as DeclaringPackage, q as PackageDeclaration, i as DoctorResult, F as Finding } from './config-Dj_f9T7J.js';
|
|
2
|
+
export { A as AllowEntry, C as CompanionPackage, s as ContractsConfig, f as DoctorConfigError, t as DoctorPack, u as FindingInput, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, k as GenesisSupabase, L as Level, N as NativePackConfig, w as PackageRuleSetting, x as PackagesPackConfig, y as PluginSpec, z as PrimitiveEntry, R as RuleSetting, B as SupabasePackConfig, E as loadConfig, r as readGenesisConfig, H as validateConfig, v as validateLinks } from './config-Dj_f9T7J.js';
|
|
3
3
|
import '@marktiderman/genesis-features';
|
|
4
4
|
|
|
5
5
|
/** The installed folder of `name`, looking in node_modules from `from` upward (works with hoisting and pnpm). */
|
|
@@ -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"];
|
|
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"];
|
|
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 resolve16 = (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
|
+
resolve16(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()) resolve16(relation, 0);
|
|
489
489
|
}
|
|
490
490
|
async function introspectPostgres(sql, schemas, options = {}) {
|
|
491
491
|
const relations = /* @__PURE__ */ new Map();
|
|
@@ -899,8 +899,26 @@ function readGenesisConfig(root) {
|
|
|
899
899
|
const out = { raw };
|
|
900
900
|
if (raw.links !== void 0) out.links = validateLinks(raw.links, file);
|
|
901
901
|
if (raw.privacy !== void 0) out.privacy = validatePrivacy(raw.privacy, file);
|
|
902
|
+
if (raw.supabase !== void 0) {
|
|
903
|
+
const supabase = validateSupabase(raw.supabase, file);
|
|
904
|
+
if (supabase !== true) out.supabase = supabase;
|
|
905
|
+
}
|
|
902
906
|
return out;
|
|
903
907
|
}
|
|
908
|
+
function validateSupabase(raw, source = "config") {
|
|
909
|
+
const fail = (msg) => {
|
|
910
|
+
throw new GenesisConfigError(`${source}: ${msg}`);
|
|
911
|
+
};
|
|
912
|
+
if (typeof raw === "boolean") return raw ? true : false;
|
|
913
|
+
if (!isObject(raw)) return fail(`"supabase" must be false or { "app": "<the folder of the app that holds supabase/>" }`);
|
|
914
|
+
for (const key2 of Object.keys(raw)) if (key2 !== "app" && key2 !== "$comment") fail(`supabase: unknown setting "${key2}" (known: app)`);
|
|
915
|
+
const app = raw.app;
|
|
916
|
+
if (typeof app !== "string" || !app.trim()) return fail(`supabase.app must be the folder of the app that holds supabase/, relative to this one (e.g. "../app")`);
|
|
917
|
+
if (path20.isAbsolute(app) || /^[A-Za-z]:[\\/]/.test(app) || app.includes("\\")) fail(`supabase.app must be relative to this app, with forward slashes ("${app}")`);
|
|
918
|
+
const norm = path20.posix.normalize(app).replace(/\/+$/, "");
|
|
919
|
+
if (norm === "." || norm === "") fail(`supabase.app names this app itself; leave "supabase" out instead`);
|
|
920
|
+
return { app: norm };
|
|
921
|
+
}
|
|
904
922
|
var PRIVACY_KEYS = /* @__PURE__ */ new Set(["blocks", "collects", "tracking"]);
|
|
905
923
|
var DATA_USE_KEYS = /* @__PURE__ */ new Set(["type", "purposes", "linked", "tracking"]);
|
|
906
924
|
function validatePrivacy(raw, source = "config") {
|
|
@@ -1125,7 +1143,7 @@ function globToRegExp(glob) {
|
|
|
1125
1143
|
}
|
|
1126
1144
|
function globMatcher(globs) {
|
|
1127
1145
|
const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
|
|
1128
|
-
return (
|
|
1146
|
+
return (path39) => res.some((re) => re.test(path39));
|
|
1129
1147
|
}
|
|
1130
1148
|
var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
|
|
1131
1149
|
var NATIVE_UI_PACKAGE = "@marktiderman/genesis-ui-native";
|
|
@@ -1511,6 +1529,26 @@ function parseManifest(home, id, raw, version, options = {}) {
|
|
|
1511
1529
|
const file = pathOf(m["file"], `${where2}.file`);
|
|
1512
1530
|
if (file && !MIGRATION_FILE.test(file.split("/").pop())) problems.push(`${where2}.file: "${file}" must be named NNNN_name.sql (lowercase letters, digits, _)`);
|
|
1513
1531
|
const out = { package: pkgOf(m["package"], where2), file };
|
|
1532
|
+
if (m["provides"] !== void 0) {
|
|
1533
|
+
if (!Array.isArray(m["provides"])) problems.push(`${where2}.provides: must be a list of { package, file }`);
|
|
1534
|
+
else {
|
|
1535
|
+
out.provides = m["provides"].map((p, j) => {
|
|
1536
|
+
const at2 = `${where2}.provides[${j}]`;
|
|
1537
|
+
if (!isObject2(p)) {
|
|
1538
|
+
problems.push(`${at2}: must be an object`);
|
|
1539
|
+
return { package: home, file: "" };
|
|
1540
|
+
}
|
|
1541
|
+
const provided = { package: pkgOf(p["package"], at2), file: pathOf(p["file"], `${at2}.file`) };
|
|
1542
|
+
if (p["functions"] !== void 0) {
|
|
1543
|
+
if (!Array.isArray(p["functions"])) problems.push(`${at2}.functions: must be a list of function folders`);
|
|
1544
|
+
else provided.functions = p["functions"].map((f, k) => pathOf(f, `${at2}.functions[${k}]`));
|
|
1545
|
+
}
|
|
1546
|
+
if (provided.file && !MIGRATION_FILE.test(provided.file.split("/").pop())) problems.push(`${at2}.file: "${provided.file}" must be named NNNN_name.sql`);
|
|
1547
|
+
if (provided.package === out.package && provided.file === file) problems.push(`${at2}: a migration can't provide itself`);
|
|
1548
|
+
return provided;
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
}
|
|
1514
1552
|
if (m["test"] !== void 0) {
|
|
1515
1553
|
out.test = pathOf(m["test"], `${where2}.test`);
|
|
1516
1554
|
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`);
|
|
@@ -1654,10 +1692,6 @@ function appPath2(root, rel) {
|
|
|
1654
1692
|
if (there(target) && lstatSync(target).isSymbolicLink()) throw new Error(`${rel} is a symlink; left alone`);
|
|
1655
1693
|
return target;
|
|
1656
1694
|
}
|
|
1657
|
-
function readApp(root, rel) {
|
|
1658
|
-
const file = appPath2(root, rel);
|
|
1659
|
-
return existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
1660
|
-
}
|
|
1661
1695
|
|
|
1662
1696
|
// src/blocks/local.ts
|
|
1663
1697
|
var LOCAL_PACKAGES_KEY = "localPackages";
|
|
@@ -2477,7 +2511,9 @@ var BUILTIN_RULES = [
|
|
|
2477
2511
|
// supabase pack: contracts (contracts.ts)
|
|
2478
2512
|
"contracts-stale",
|
|
2479
2513
|
// genesis.lock.json against the files (lock-files.ts)
|
|
2480
|
-
"lock-files"
|
|
2514
|
+
"lock-files",
|
|
2515
|
+
// an app whose database files live in another app (database.ts)
|
|
2516
|
+
"database-elsewhere"
|
|
2481
2517
|
];
|
|
2482
2518
|
var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
|
|
2483
2519
|
var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
|
|
@@ -2700,7 +2736,7 @@ function privacyApisFor(dependencies2) {
|
|
|
2700
2736
|
var EAS_PLACEHOLDERS = {
|
|
2701
2737
|
REPLACE_WITH_APP_STORE_CONNECT_APP_ID: "the app's Apple ID from App Store Connect (create the app there, then App Information \u2192 General Information \u2192 Apple ID, a number)",
|
|
2702
2738
|
REPLACE_WITH_APPLE_TEAM_ID: "your Apple Developer Team ID (developer.apple.com \u2192 Account \u2192 Membership details, 10 characters)",
|
|
2703
|
-
REPLACE_WITH_PATH_TO_GOOGLE_SERVICE_ACCOUNT_JSON: "the
|
|
2739
|
+
REPLACE_WITH_PATH_TO_GOOGLE_SERVICE_ACCOUNT_JSON: "the Google Play service account key uploaded to EAS, not a local path (deploy-production.yml submits on EAS, where a local file isn't there): create a Google Cloud service account and its JSON key, invite it in Play Console \u2192 Users and permissions, upload the key with `eas credentials` (Android \u2192 Google Service Account), then remove only this serviceAccountKeyPath line (https://docs.expo.dev/submit/android/). Until you ship to Google Play, remove the submit_android job from deploy-production.yml instead, and keep submit.production.android as it is (the internal track, as a draft)",
|
|
2704
2740
|
REPLACE_WITH_APP_FOLDER: "the app's code folder (src, or apps/<name> in a monorepo)"
|
|
2705
2741
|
};
|
|
2706
2742
|
function placeholderKey(line, placeholder) {
|
|
@@ -3609,11 +3645,21 @@ async function blocksOfInstalled(dir, warnings = [], options = {}) {
|
|
|
3609
3645
|
const out = [];
|
|
3610
3646
|
for (const id of [...ids].sort()) {
|
|
3611
3647
|
const fromJson = raw[id] ?? {};
|
|
3612
|
-
const
|
|
3648
|
+
const merged = { ...fromJson, ...declared[id] };
|
|
3649
|
+
if (declared[id]?.["migrations"] && Array.isArray(fromJson["migrations"])) merged["migrations"] = withProvides(declared[id]["migrations"], fromJson["migrations"]);
|
|
3650
|
+
const manifest = tryParse(() => parseManifest(pkg.name, id, merged, pkg.version, options), warnings);
|
|
3613
3651
|
if (manifest) out.push(manifest);
|
|
3614
3652
|
}
|
|
3615
3653
|
return out;
|
|
3616
3654
|
}
|
|
3655
|
+
function withProvides(declared, json) {
|
|
3656
|
+
if (!Array.isArray(declared)) return declared;
|
|
3657
|
+
const fileOf = (m) => m && typeof m === "object" ? m["file"] : void 0;
|
|
3658
|
+
return declared.map((m) => {
|
|
3659
|
+
const same = json.find((j) => fileOf(j) === fileOf(m));
|
|
3660
|
+
return same?.["provides"] !== void 0 && m && typeof m === "object" && !("provides" in m) ? { ...m, provides: same["provides"] } : m;
|
|
3661
|
+
});
|
|
3662
|
+
}
|
|
3617
3663
|
async function allBlocks(root, warnings = []) {
|
|
3618
3664
|
const out = [];
|
|
3619
3665
|
for (const local of localPackages(root)) {
|
|
@@ -4475,6 +4521,45 @@ function checkPackagesPack(ctx) {
|
|
|
4475
4521
|
if (base && "sha" in merge && !overlay) checkChanges(ctx, pkg, json, base, merge.sha);
|
|
4476
4522
|
}
|
|
4477
4523
|
}
|
|
4524
|
+
var LOCK_FILE = "genesis.lock.json";
|
|
4525
|
+
function emptyLock() {
|
|
4526
|
+
return { version: 1, blocks: {}, files: {} };
|
|
4527
|
+
}
|
|
4528
|
+
function readLock(root) {
|
|
4529
|
+
const file = path20.join(root, LOCK_FILE);
|
|
4530
|
+
if (!existsSync(file)) return emptyLock();
|
|
4531
|
+
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
4532
|
+
if (raw.version !== 1) throw new Error(`${LOCK_FILE} has version ${String(raw.version)}; this CLI reads version 1.`);
|
|
4533
|
+
return {
|
|
4534
|
+
version: 1,
|
|
4535
|
+
...raw.substitutions ? { substitutions: raw.substitutions } : {},
|
|
4536
|
+
blocks: raw.blocks ?? {},
|
|
4537
|
+
files: raw.files ?? {},
|
|
4538
|
+
...raw.migrations ? { migrations: raw.migrations } : {}
|
|
4539
|
+
};
|
|
4540
|
+
}
|
|
4541
|
+
function parseSource(source) {
|
|
4542
|
+
const at = source.indexOf(":");
|
|
4543
|
+
if (at < 1) throw new Error(`${LOCK_FILE}: "${source}" is not <package>:<path>`);
|
|
4544
|
+
return { package: source.slice(0, at), path: source.slice(at + 1) };
|
|
4545
|
+
}
|
|
4546
|
+
|
|
4547
|
+
// src/blocks/database.ts
|
|
4548
|
+
function databaseElsewhere(root) {
|
|
4549
|
+
const setting = readGenesisConfig(root)?.supabase;
|
|
4550
|
+
if (setting === void 0) return null;
|
|
4551
|
+
if (setting === false) return { app: null, dir: null, hasSupabase: false };
|
|
4552
|
+
const resolved = path20.resolve(root, setting.app);
|
|
4553
|
+
const real2 = (p) => existsSync(p) ? realpathSync(p) : p;
|
|
4554
|
+
const dir = real2(resolved);
|
|
4555
|
+
if (dir === real2(path20.resolve(root))) throw new GenesisConfigError(`${path20.join(root, "genesis.config.json")}: supabase.app "${setting.app}" is this app itself; leave "supabase" out instead`);
|
|
4556
|
+
return { app: setting.app, dir, hasSupabase: existsSync(path20.join(dir, "supabase")) };
|
|
4557
|
+
}
|
|
4558
|
+
function isSupabasePath(rel) {
|
|
4559
|
+
return rel === "supabase" || rel.startsWith("supabase/");
|
|
4560
|
+
}
|
|
4561
|
+
|
|
4562
|
+
// src/doctor/supabase.ts
|
|
4478
4563
|
var DEFAULT_MIGRATIONS = "supabase/migrations";
|
|
4479
4564
|
var DEFAULT_BASE = "origin/main";
|
|
4480
4565
|
var DEFAULT_EXPOSED = ["public"];
|
|
@@ -4655,6 +4740,7 @@ function gitView(root, dir, base) {
|
|
|
4655
4740
|
return { touched: touched2, edited };
|
|
4656
4741
|
}
|
|
4657
4742
|
function checkSupabasePack(ctx) {
|
|
4743
|
+
if (databaseElsewhere(ctx.root)) return;
|
|
4658
4744
|
const settings = ctx.config.supabase ?? {};
|
|
4659
4745
|
const dir = settings.migrations ?? DEFAULT_MIGRATIONS;
|
|
4660
4746
|
const abs = path20.join(ctx.root, dir);
|
|
@@ -6112,28 +6198,6 @@ function checkAgentGuide(ctx) {
|
|
|
6112
6198
|
ctx.report({ rule: "agent-guide-stale", level: "warn", file: "AGENTS.md", message });
|
|
6113
6199
|
}
|
|
6114
6200
|
}
|
|
6115
|
-
var LOCK_FILE = "genesis.lock.json";
|
|
6116
|
-
function emptyLock() {
|
|
6117
|
-
return { version: 1, blocks: {}, files: {} };
|
|
6118
|
-
}
|
|
6119
|
-
function readLock(root) {
|
|
6120
|
-
const file = path20.join(root, LOCK_FILE);
|
|
6121
|
-
if (!existsSync(file)) return emptyLock();
|
|
6122
|
-
const raw = JSON.parse(readFileSync(file, "utf8"));
|
|
6123
|
-
if (raw.version !== 1) throw new Error(`${LOCK_FILE} has version ${String(raw.version)}; this CLI reads version 1.`);
|
|
6124
|
-
return {
|
|
6125
|
-
version: 1,
|
|
6126
|
-
...raw.substitutions ? { substitutions: raw.substitutions } : {},
|
|
6127
|
-
blocks: raw.blocks ?? {},
|
|
6128
|
-
files: raw.files ?? {},
|
|
6129
|
-
...raw.migrations ? { migrations: raw.migrations } : {}
|
|
6130
|
-
};
|
|
6131
|
-
}
|
|
6132
|
-
function parseSource(source) {
|
|
6133
|
-
const at = source.indexOf(":");
|
|
6134
|
-
if (at < 1) throw new Error(`${LOCK_FILE}: "${source}" is not <package>:<path>`);
|
|
6135
|
-
return { package: source.slice(0, at), path: source.slice(at + 1) };
|
|
6136
|
-
}
|
|
6137
6201
|
var CLI = "@marktiderman/genesis-cli";
|
|
6138
6202
|
function ownedKeyProblem(key2, source, localNames = /* @__PURE__ */ new Set()) {
|
|
6139
6203
|
let parsed;
|
|
@@ -6176,8 +6240,25 @@ function featuresBody(text) {
|
|
|
6176
6240
|
const m = /\bfeatures:\s*\{/.exec(text);
|
|
6177
6241
|
if (!m) return null;
|
|
6178
6242
|
const start = m.index + m[0].length;
|
|
6179
|
-
|
|
6180
|
-
|
|
6243
|
+
let depth = 1;
|
|
6244
|
+
for (let i = start; i < text.length; i++) {
|
|
6245
|
+
const c = text[i];
|
|
6246
|
+
if (c === "/" && text[i + 1] === "/") {
|
|
6247
|
+
const nl = text.indexOf("\n", i);
|
|
6248
|
+
if (nl < 0) return null;
|
|
6249
|
+
i = nl;
|
|
6250
|
+
} else if (c === "/" && text[i + 1] === "*") {
|
|
6251
|
+
const close = text.indexOf("*/", i + 2);
|
|
6252
|
+
if (close < 0) return null;
|
|
6253
|
+
i = close + 1;
|
|
6254
|
+
} else if (c === '"' || c === "'" || c === "`") {
|
|
6255
|
+
let j = i + 1;
|
|
6256
|
+
while (j < text.length && text[j] !== c) j += text[j] === "\\" ? 2 : 1;
|
|
6257
|
+
i = j;
|
|
6258
|
+
} else if (c === "{") depth++;
|
|
6259
|
+
else if (c === "}" && --depth === 0) return { start, body: text.slice(start, i) };
|
|
6260
|
+
}
|
|
6261
|
+
return null;
|
|
6181
6262
|
}
|
|
6182
6263
|
function parseStarterFeatures(text) {
|
|
6183
6264
|
const found = featuresBody(text);
|
|
@@ -6199,6 +6280,7 @@ function parseStarterBlocks(json, source = GENESIS_CONFIG) {
|
|
|
6199
6280
|
const starter = raw?.starter;
|
|
6200
6281
|
if (starter === void 0) return null;
|
|
6201
6282
|
const blocks = starter?.blocks;
|
|
6283
|
+
if (blocks === void 0 && typeof starter === "object" && starter !== null && !Array.isArray(starter)) return null;
|
|
6202
6284
|
if (typeof blocks !== "object" || blocks === null || Array.isArray(blocks)) throw new Error(`${source}: starter.blocks must map each feature switch to a list of block ids`);
|
|
6203
6285
|
const out = {};
|
|
6204
6286
|
for (const [name, ids] of Object.entries(blocks)) {
|
|
@@ -6297,15 +6379,44 @@ async function checkLockFiles(ctx) {
|
|
|
6297
6379
|
});
|
|
6298
6380
|
}
|
|
6299
6381
|
const local = localPackageNames(ctx.root);
|
|
6382
|
+
let home = null;
|
|
6383
|
+
try {
|
|
6384
|
+
home = databaseElsewhere(ctx.root);
|
|
6385
|
+
} catch {
|
|
6386
|
+
}
|
|
6387
|
+
const elsewhere = home ? Object.keys(lock.files).filter(isSupabasePath) : [];
|
|
6388
|
+
if (home && elsewhere.length) {
|
|
6389
|
+
ctx.report({
|
|
6390
|
+
rule: "lock-files",
|
|
6391
|
+
level: "info",
|
|
6392
|
+
file: LOCK_FILE,
|
|
6393
|
+
subject: "supabase/",
|
|
6394
|
+
message: `lists ${elsewhere.length} file${elsewhere.length === 1 ? "" : "s"} under supabase/, but this app's database files live ${home.app ? `in ${home.app}` : "nowhere"} (genesis.config.json supabase): genesis upgrade leaves them alone, so delete those entries`
|
|
6395
|
+
});
|
|
6396
|
+
}
|
|
6300
6397
|
for (const [rel, entry] of Object.entries(lock.files)) {
|
|
6398
|
+
if (home && isSupabasePath(rel)) continue;
|
|
6301
6399
|
if (ownedKeyProblem(rel, entry.source, local)) continue;
|
|
6302
6400
|
if (offManifests.length && blockOfSource(entry.source, offManifests)) continue;
|
|
6303
|
-
let
|
|
6401
|
+
let file;
|
|
6304
6402
|
try {
|
|
6305
|
-
|
|
6403
|
+
file = appPath2(ctx.root, rel);
|
|
6306
6404
|
} catch {
|
|
6307
6405
|
continue;
|
|
6308
6406
|
}
|
|
6407
|
+
let text;
|
|
6408
|
+
try {
|
|
6409
|
+
text = existsSync(file) ? readFileSync(file, "utf8") : null;
|
|
6410
|
+
} catch (err) {
|
|
6411
|
+
ctx.report({
|
|
6412
|
+
rule: "lock-files",
|
|
6413
|
+
level: "warn",
|
|
6414
|
+
file: rel,
|
|
6415
|
+
subject: rel,
|
|
6416
|
+
message: `is in ${LOCK_FILE} (from ${entry.source}) but can't be read (${err instanceof Error ? err.message : String(err)}), so genesis upgrade can't refresh it. Make it a file again, or remove its entry from ${LOCK_FILE}`
|
|
6417
|
+
});
|
|
6418
|
+
continue;
|
|
6419
|
+
}
|
|
6309
6420
|
if (text === null) {
|
|
6310
6421
|
if (entry.deleted) continue;
|
|
6311
6422
|
ctx.report({
|
|
@@ -6330,6 +6441,28 @@ async function checkLockFiles(ctx) {
|
|
|
6330
6441
|
});
|
|
6331
6442
|
}
|
|
6332
6443
|
}
|
|
6444
|
+
function checkDatabaseHome(ctx) {
|
|
6445
|
+
const home = databaseElsewhere(ctx.root);
|
|
6446
|
+
if (!home) return;
|
|
6447
|
+
if (home.app && !home.hasSupabase) {
|
|
6448
|
+
ctx.report({
|
|
6449
|
+
rule: "database-elsewhere",
|
|
6450
|
+
level: "warn",
|
|
6451
|
+
file: "genesis.config.json",
|
|
6452
|
+
subject: home.app,
|
|
6453
|
+
message: `supabase.app is ${home.app}, which has no supabase folder; name the app that holds this app's database (its migrations, tests and Edge Functions)`
|
|
6454
|
+
});
|
|
6455
|
+
}
|
|
6456
|
+
if (existsSync(path20.join(ctx.root, "supabase"))) {
|
|
6457
|
+
ctx.report({
|
|
6458
|
+
rule: "database-elsewhere",
|
|
6459
|
+
level: "warn",
|
|
6460
|
+
file: "supabase",
|
|
6461
|
+
subject: "supabase/",
|
|
6462
|
+
message: `is here, but genesis.config.json says this app's database files live ${home.app ? `in ${home.app}/supabase` : "nowhere"}: genesis add, migrate and upgrade never plan it, so it is a second, unused copy. Delete it`
|
|
6463
|
+
});
|
|
6464
|
+
}
|
|
6465
|
+
}
|
|
6333
6466
|
var RATCHETED_BY_DEFAULT = ["deprecated-import"];
|
|
6334
6467
|
async function runDoctor(options = {}) {
|
|
6335
6468
|
const root = path20.resolve(options.root ?? process.cwd());
|
|
@@ -6432,6 +6565,7 @@ function builtinChecks(config, options = {}) {
|
|
|
6432
6565
|
{ name: "agent-guide", check: checkAgentGuide },
|
|
6433
6566
|
{ name: "overlays", check: (ctx) => checkOverlays(ctx) },
|
|
6434
6567
|
{ name: "lock-files", check: checkLockFiles },
|
|
6568
|
+
{ name: "database-elsewhere", check: checkDatabaseHome },
|
|
6435
6569
|
...(config.packs ?? []).map((p) => packs[p]),
|
|
6436
6570
|
...config.packs?.includes("supabase") && config.contracts && options.contracts !== false ? [{ name: "contracts", check: (ctx) => checkContracts(ctx) }] : []
|
|
6437
6571
|
];
|