@marktiderman/genesis-cli 1.3.0 → 1.4.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/dist/expo.d.ts ADDED
@@ -0,0 +1,59 @@
1
+ import { ConfigPlugin } from '@expo/config-plugins';
2
+ import { ExpoConfig } from '@expo/config-types';
3
+ import { G as GenesisLinks } from './config-Ci-_Ue-1.js';
4
+ export { a as GenesisConfigError, r as readGenesisConfig, v as validateLinks } from './config-Ci-_Ue-1.js';
5
+
6
+ declare const APP_VARIANTS: readonly ["development", "preview", "production"];
7
+ type AppVariant = (typeof APP_VARIANTS)[number];
8
+ interface VariantSuffix {
9
+ /** Appended to `ios.bundleIdentifier` and `android.package`, e.g. `.dev`. */
10
+ id: string;
11
+ /** Appended to `name`, e.g. ` (Dev)`. */
12
+ name: string;
13
+ }
14
+ /** A required-reason API category and the reasons for it, as in PrivacyInfo.xcprivacy. */
15
+ interface PrivacyApi {
16
+ NSPrivacyAccessedAPIType: string;
17
+ NSPrivacyAccessedAPITypeReasons: string[];
18
+ }
19
+ interface WithGenesisOptions {
20
+ /**
21
+ * The variant, overriding `APP_VARIANT`. Tests and scripts pass it; an app
22
+ * leaves it out and sets `APP_VARIANT` per build profile in eas.json.
23
+ */
24
+ variant?: AppVariant;
25
+ /** Suffixes per non-production variant. Default `.dev` / ` (Dev)` and `.preview` / ` (Preview)`. */
26
+ variants?: Partial<Record<Exclude<AppVariant, "production">, Partial<VariantSuffix>>>;
27
+ /** Where genesis.config.json and package.json live. Default: the Expo project root. */
28
+ projectRoot?: string;
29
+ /** Turn single steps off. Every step is on by default. */
30
+ links?: boolean;
31
+ privacyManifest?: boolean;
32
+ exportCompliance?: boolean;
33
+ fingerprint?: boolean;
34
+ }
35
+ declare const DEFAULT_VARIANT_SUFFIXES: Record<Exclude<AppVariant, "production">, VariantSuffix>;
36
+ /**
37
+ * The required-reason APIs each package needs the app to declare, copied from
38
+ * the package's own PrivacyInfo.xcprivacy. A package is matched when the
39
+ * app's package.json lists it in `dependencies`.
40
+ *
41
+ * - async-storage (2.2.0 `ios/PrivacyInfo.xcprivacy`): FileTimestamp, C617.1.
42
+ *
43
+ * expo-secure-store is not listed: the Keychain is not a required-reason API.
44
+ */
45
+ declare const PRIVACY_APIS: Record<string, PrivacyApi[]>;
46
+ /** The variant from options, else `APP_VARIANT`, else production. An unknown value throws. */
47
+ declare function resolveVariant(given?: string): AppVariant;
48
+ declare function applyVariant(config: ExpoConfig, variant: AppVariant, options?: WithGenesisOptions["variants"]): ExpoConfig;
49
+ declare function applyLinks(config: ExpoConfig, links: GenesisLinks | undefined): ExpoConfig;
50
+ /** The required-reason APIs for the packages listed in package.json `dependencies`. */
51
+ declare function privacyApisFor(dependencies: Record<string, unknown>): PrivacyApi[];
52
+ /** Merge required-reason APIs into `ios.privacyManifests`, keeping every entry and reason the app declares. */
53
+ declare function applyPrivacyApis(config: ExpoConfig, apis: PrivacyApi[]): ExpoConfig;
54
+ declare function applyExportCompliance(config: ExpoConfig): ExpoConfig;
55
+ declare function applyFingerprint(config: ExpoConfig): ExpoConfig;
56
+ /** The Genesis config plugin. Use it in `plugins` or call it directly in app.config.ts. */
57
+ declare const withGenesis: ConfigPlugin<WithGenesisOptions | void>;
58
+
59
+ export { APP_VARIANTS, type AppVariant, DEFAULT_VARIANT_SUFFIXES, GenesisLinks, PRIVACY_APIS, type PrivacyApi, type VariantSuffix, type WithGenesisOptions, applyExportCompliance, applyFingerprint, applyLinks, applyPrivacyApis, applyVariant, withGenesis as default, privacyApisFor, resolveVariant, withGenesis };
package/dist/expo.js ADDED
@@ -0,0 +1,157 @@
1
+ import { existsSync, readFileSync } from 'fs';
2
+ import * as path from 'path';
3
+
4
+ // src/expo.ts
5
+ var GenesisConfigError = class extends Error {
6
+ name = "GenesisConfigError";
7
+ };
8
+ var DoctorConfigError = class extends GenesisConfigError {
9
+ name = "DoctorConfigError";
10
+ };
11
+ function readJson(file) {
12
+ try {
13
+ return JSON.parse(readFileSync(file, "utf8"));
14
+ } catch (err) {
15
+ throw new DoctorConfigError(`${file} is not valid JSON: ${err.message}`);
16
+ }
17
+ }
18
+ function readGenesisConfig(root) {
19
+ const file = path.join(root, "genesis.config.json");
20
+ if (!existsSync(file)) return null;
21
+ const raw = readJson(file);
22
+ if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
23
+ const links = raw.links === void 0 ? void 0 : validateLinks(raw.links, file);
24
+ return links ? { raw, links } : { raw };
25
+ }
26
+ var LINK_KEYS = /* @__PURE__ */ new Set(["hosts", "paths", "webcredentials"]);
27
+ var HOST = /^(?=.{1,253}$)(\*\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
28
+ function validateLinks(raw, source = "config") {
29
+ const fail = (msg) => {
30
+ throw new GenesisConfigError(`${source}: ${msg}`);
31
+ };
32
+ if (!isObject(raw)) fail(`"links" must be an object`);
33
+ const c = raw;
34
+ for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting "${key}"`);
35
+ if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);
36
+ for (const host of c.hosts) {
37
+ if (!HOST.test(host)) {
38
+ fail(`links.hosts: "${host}" is not a bare lower-case host name (no scheme, path or port), e.g. "example.com"`);
39
+ }
40
+ }
41
+ if (c.paths !== void 0) {
42
+ if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);
43
+ for (const p of c.paths) {
44
+ if (!p.startsWith("/") || /[\s?#*]/.test(p)) {
45
+ fail(`links.paths: "${p}" must start with "/" and hold no spaces, "?", "#" or "*"`);
46
+ }
47
+ }
48
+ }
49
+ if (c.webcredentials !== void 0 && typeof c.webcredentials !== "boolean") fail(`links.webcredentials must be true or false`);
50
+ const links = { hosts: [...new Set(c.hosts)] };
51
+ if (c.paths !== void 0) links.paths = [...new Set(c.paths)];
52
+ if (c.webcredentials !== void 0) links.webcredentials = c.webcredentials;
53
+ return links;
54
+ }
55
+ function isObject(v) {
56
+ return typeof v === "object" && v !== null && !Array.isArray(v);
57
+ }
58
+ function isStringList(v) {
59
+ return Array.isArray(v) && v.every((x) => typeof x === "string");
60
+ }
61
+
62
+ // src/expo.ts
63
+ var APP_VARIANTS = ["development", "preview", "production"];
64
+ var DEFAULT_VARIANT_SUFFIXES = {
65
+ development: { id: ".dev", name: " (Dev)" },
66
+ preview: { id: ".preview", name: " (Preview)" }
67
+ };
68
+ var PRIVACY_APIS = {
69
+ "@react-native-async-storage/async-storage": [
70
+ { NSPrivacyAccessedAPIType: "NSPrivacyAccessedAPICategoryFileTimestamp", NSPrivacyAccessedAPITypeReasons: ["C617.1"] }
71
+ ]
72
+ };
73
+ function resolveVariant(given) {
74
+ const value = given ?? process.env.APP_VARIANT ?? "production";
75
+ if (!APP_VARIANTS.includes(value)) {
76
+ throw new GenesisConfigError(`APP_VARIANT is "${value}"; expected one of ${APP_VARIANTS.join(", ")}`);
77
+ }
78
+ return value;
79
+ }
80
+ function applyVariant(config, variant, options = {}) {
81
+ if (variant === "production") return config;
82
+ const suffix = { ...DEFAULT_VARIANT_SUFFIXES[variant], ...options[variant] };
83
+ const add = (value, end) => end && value.endsWith(end) ? value : value + end;
84
+ const next = { ...config, name: add(config.name, suffix.name) };
85
+ if (config.ios?.bundleIdentifier) next.ios = { ...config.ios, bundleIdentifier: add(config.ios.bundleIdentifier, suffix.id) };
86
+ if (config.android?.package) next.android = { ...config.android, package: add(config.android.package, suffix.id) };
87
+ return next;
88
+ }
89
+ function applyLinks(config, links) {
90
+ if (!links) return config;
91
+ const services = links.webcredentials === false ? ["applinks"] : ["applinks", "webcredentials"];
92
+ const domains = links.hosts.flatMap((host) => services.map((service) => `${service}:${host}`));
93
+ const associatedDomains = union(config.ios?.associatedDomains ?? [], domains);
94
+ const data = links.hosts.flatMap(
95
+ (host) => links.paths?.length ? links.paths.map((pathPrefix) => ({ scheme: "https", host, pathPrefix })) : [{ scheme: "https", host }]
96
+ );
97
+ const filter = { action: "VIEW", autoVerify: true, data, category: ["BROWSABLE", "DEFAULT"] };
98
+ const existing = config.android?.intentFilters ?? [];
99
+ const intentFilters = existing.some((f) => JSON.stringify(f) === JSON.stringify(filter)) ? existing : [...existing, filter];
100
+ return {
101
+ ...config,
102
+ ios: { ...config.ios, associatedDomains },
103
+ android: { ...config.android, intentFilters }
104
+ };
105
+ }
106
+ function privacyApisFor(dependencies) {
107
+ return Object.keys(PRIVACY_APIS).filter((pkg) => pkg in dependencies).flatMap((pkg) => PRIVACY_APIS[pkg]);
108
+ }
109
+ function applyPrivacyApis(config, apis) {
110
+ if (apis.length === 0) return config;
111
+ const manifests = config.ios?.privacyManifests ?? {};
112
+ const types = (manifests.NSPrivacyAccessedAPITypes ?? []).map((t) => ({ ...t, NSPrivacyAccessedAPITypeReasons: [...t.NSPrivacyAccessedAPITypeReasons] }));
113
+ for (const api of apis) {
114
+ const found = types.find((t) => t.NSPrivacyAccessedAPIType === api.NSPrivacyAccessedAPIType);
115
+ if (found) found.NSPrivacyAccessedAPITypeReasons = union(found.NSPrivacyAccessedAPITypeReasons, api.NSPrivacyAccessedAPITypeReasons);
116
+ else types.push({ ...api, NSPrivacyAccessedAPITypeReasons: [...api.NSPrivacyAccessedAPITypeReasons] });
117
+ }
118
+ return { ...config, ios: { ...config.ios, privacyManifests: { ...manifests, NSPrivacyAccessedAPITypes: types } } };
119
+ }
120
+ function applyExportCompliance(config) {
121
+ if (config.ios?.config?.usesNonExemptEncryption !== void 0) return config;
122
+ return { ...config, ios: { ...config.ios, config: { ...config.ios?.config, usesNonExemptEncryption: false } } };
123
+ }
124
+ function applyFingerprint(config) {
125
+ if (config.runtimeVersion !== void 0 || config.ios?.runtimeVersion !== void 0 || config.android?.runtimeVersion !== void 0) {
126
+ return config;
127
+ }
128
+ return { ...config, runtimeVersion: { policy: "fingerprint" } };
129
+ }
130
+ var withGenesis = (config, props) => {
131
+ const options = props ?? {};
132
+ const root = options.projectRoot ?? config._internal?.projectRoot ?? process.cwd();
133
+ let next = applyVariant(config, resolveVariant(options.variant), options.variants);
134
+ if (options.links !== false) next = applyLinks(next, readGenesisConfig(root)?.links);
135
+ if (options.privacyManifest !== false) next = applyPrivacyApis(next, privacyApisFor(readDependencies(root)));
136
+ if (options.exportCompliance !== false) next = applyExportCompliance(next);
137
+ if (options.fingerprint !== false) next = applyFingerprint(next);
138
+ return next;
139
+ };
140
+ var expo_default = withGenesis;
141
+ function readDependencies(root) {
142
+ const file = path.join(root, "package.json");
143
+ if (!existsSync(file)) return {};
144
+ try {
145
+ const deps = JSON.parse(readFileSync(file, "utf8"))?.dependencies;
146
+ return deps && typeof deps === "object" ? deps : {};
147
+ } catch (err) {
148
+ throw new GenesisConfigError(`${file} is not valid JSON: ${err.message}`);
149
+ }
150
+ }
151
+ function union(a, b) {
152
+ return [.../* @__PURE__ */ new Set([...a, ...b])];
153
+ }
154
+
155
+ export { APP_VARIANTS, DEFAULT_VARIANT_SUFFIXES, GenesisConfigError, PRIVACY_APIS, applyExportCompliance, applyFingerprint, applyLinks, applyPrivacyApis, applyVariant, expo_default as default, privacyApisFor, readGenesisConfig, resolveVariant, validateLinks, withGenesis };
156
+ //# sourceMappingURL=expo.js.map
157
+ //# sourceMappingURL=expo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/doctor/config.ts","../src/expo.ts"],"names":["path2","existsSync","readFileSync"],"mappings":";;;;AAcO,IAAM,kBAAA,GAAN,cAAiC,KAAA,CAAM;AAAA,EACnC,IAAA,GAAO,oBAAA;AAClB;AAEO,IAAM,iBAAA,GAAN,cAAgC,kBAAA,CAAmB;AAAA,EAC/C,IAAA,GAAO,mBAAA;AAClB,CAAA;AAoEA,SAAS,SAAS,IAAA,EAAc;AAC9B,EAAA,IAAI;AACF,IAAA,OAAO,IAAA,CAAK,KAAA,CAAM,YAAA,CAAa,IAAA,EAAM,MAAM,CAAC,CAAA;AAAA,EAC9C,SAAS,GAAA,EAAK;AACZ,IAAA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,CAAW,IAAI,CAAA,SAAU,EAAC;AAC/B,EAAA,IAAI;AACF,IAAA,MAAM,OAAO,IAAA,CAAK,KAAA,CAAMC,aAAa,IAAA,EAAM,MAAM,CAAC,CAAA,EAAG,YAAA;AACrD,IAAA,OAAO,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,GAAW,OAAO,EAAC;AAAA,EACpD,SAAS,GAAA,EAAK;AACZ,IAAA,MAAM,IAAI,kBAAA,CAAmB,CAAA,EAAG,IAAI,CAAA,oBAAA,EAAwB,GAAA,CAAc,OAAO,CAAA,CAAE,CAAA;AAAA,EACrF;AACF;AAEA,SAAS,KAAA,CAAM,GAAa,CAAA,EAAuB;AACjD,EAAA,OAAO,CAAC,mBAAG,IAAI,GAAA,CAAI,CAAC,GAAG,CAAA,EAAG,GAAG,CAAC,CAAC,CAAC,CAAA;AAClC","file":"expo.js","sourcesContent":["/**\n * Finds and validates the app's genesis.config.json.\n *\n * The doctor's lookup order: `--config <path>`, then `genesis.config.json`\n * in the app root, then the `genesis` key of package.json. Either file holds\n * the settings under `doctor`, beside other blocks: `features` (read by\n * `genesis features`) and `links` (validated here, read by the Expo config\n * plugin).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { DoctorConfig } from \"./types.js\";\n\n/** A genesis.config.json that can't be read or has a block of the wrong shape. */\nexport class GenesisConfigError extends Error {\n override name = \"GenesisConfigError\";\n}\n\nexport class DoctorConfigError extends GenesisConfigError {\n override name = \"DoctorConfigError\";\n}\n\n/** The `links` block: the web hosts (and optional path prefixes) the app opens as universal / app links. */\nexport interface GenesisLinks {\n /** Bare host names, such as `example.com` or `app.example.com`: no scheme, path or port. */\n hosts: string[];\n /** Path prefixes the app handles, each starting with `/`. Default: every path. */\n paths?: string[];\n /** Also add `webcredentials:` domains (password autofill). Default true. */\n webcredentials?: boolean;\n}\n\n/** genesis.config.json, parsed, with its shared blocks validated. */\nexport interface GenesisConfigFile {\n /** The whole parsed file, for blocks other readers own (`doctor`, `features`). */\n raw: Record<string, unknown>;\n links?: GenesisLinks;\n}\n\nexport interface LoadedConfig {\n config: DoctorConfig;\n /** The file it came from, or null when no config exists (defaults apply). */\n file: string | null;\n /** Folder that relative plugin paths resolve against. */\n dir: string;\n}\n\nconst STRING_LISTS = [\"src\", \"extensions\", \"ignore\", \"tokenFiles\", \"ignoreTokenPrefixes\", \"localPrimitiveDirs\", \"build\"] as const;\nconst STRINGS = [\"uiPackage\", \"rulesDoc\"] as const;\nconst KNOWN = new Set<string>([\n ...STRING_LISTS,\n ...STRINGS,\n \"themeCss\",\n \"rawTags\",\n \"forbiddenImports\",\n \"rules\",\n \"allow\",\n \"patterns\",\n \"plugins\",\n \"$schema\",\n \"$comment\",\n]);\nconst LEVELS = new Set([\"error\", \"warn\", \"off\"]);\nconst PATTERN_KEYS = new Set([\"id\", \"level\", \"files\", \"exclude\", \"forbid\", \"require\", \"path\", \"message\"]);\n\nexport function loadConfig(root: string, configPath?: string): LoadedConfig {\n if (configPath) {\n const file = path.resolve(root, configPath);\n if (!existsSync(file)) throw new DoctorConfigError(`Config file not found: ${configPath}`);\n const json = readJson(file);\n // An explicit file may hold the block at the top level or under `doctor`\n // (or, for a package.json, under `genesis.doctor`).\n const block = path.basename(file) === \"package.json\" ? json?.genesis?.doctor : json?.doctor ?? json;\n return { config: validateConfig(block ?? {}, file), file, dir: path.dirname(file) };\n }\n const own = path.join(root, \"genesis.config.json\");\n if (existsSync(own)) {\n const block = readGenesisConfig(root)?.raw.doctor;\n return { config: validateConfig(block ?? {}, own), file: own, dir: root };\n }\n const pkg = path.join(root, \"package.json\");\n if (existsSync(pkg)) {\n const block = readJson(pkg)?.genesis?.doctor;\n if (block !== undefined) return { config: validateConfig(block, pkg), file: pkg, dir: root };\n }\n return { config: {}, file: null, dir: root };\n}\n\nfunction readJson(file: string) {\n try {\n return JSON.parse(readFileSync(file, \"utf8\"));\n } catch (err) {\n throw new DoctorConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\n/**\n * Reads `<root>/genesis.config.json` and validates its shared blocks (today:\n * `links`). Returns null when the file doesn't exist; throws a\n * GenesisConfigError naming the file when it isn't valid.\n */\nexport function readGenesisConfig(root: string): GenesisConfigFile | null {\n const file = path.join(root, \"genesis.config.json\");\n if (!existsSync(file)) return null;\n const raw: unknown = readJson(file);\n if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);\n const links = raw.links === undefined ? undefined : validateLinks(raw.links, file);\n return links ? { raw, links } : { raw };\n}\n\nconst LINK_KEYS = new Set([\"hosts\", \"paths\", \"webcredentials\"]);\nconst HOST = /^(?=.{1,253}$)(\\*\\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\\.)+[a-z]{2,63}$/;\n\n/** Check the `links` block, so a typo'd host fails the build instead of shipping links that never open. */\nexport function validateLinks(raw: unknown, source = \"config\"): GenesisLinks {\n const fail = (msg: string): never => {\n throw new GenesisConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(`\"links\" must be an object`);\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting \"${key}\"`);\n if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);\n for (const host of c.hosts as string[]) {\n if (!HOST.test(host)) {\n fail(`links.hosts: \"${host}\" is not a bare lower-case host name (no scheme, path or port), e.g. \"example.com\"`);\n }\n }\n if (c.paths !== undefined) {\n if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);\n for (const p of c.paths as string[]) {\n if (!p.startsWith(\"/\") || /[\\s?#*]/.test(p)) {\n fail(`links.paths: \"${p}\" must start with \"/\" and hold no spaces, \"?\", \"#\" or \"*\"`);\n }\n }\n }\n if (c.webcredentials !== undefined && typeof c.webcredentials !== \"boolean\") fail(`links.webcredentials must be true or false`);\n const links: GenesisLinks = { hosts: [...new Set(c.hosts as string[])] };\n if (c.paths !== undefined) links.paths = [...new Set(c.paths as string[])];\n if (c.webcredentials !== undefined) links.webcredentials = c.webcredentials as boolean;\n return links;\n}\n\n/** Check the shape, so a typo fails loudly instead of silently disabling a check. */\nexport function validateConfig(raw: unknown, source = \"config\"): DoctorConfig {\n const fail = (msg: string): never => {\n throw new DoctorConfigError(`${source}: ${msg}`);\n };\n if (!isObject(raw)) fail(\"the doctor settings must be an object\");\n const c = raw as Record<string, unknown>;\n for (const key of Object.keys(c)) if (!KNOWN.has(key)) fail(`unknown setting \"${key}\"`);\n // themeCss takes one stylesheet or several; normalize to a list.\n if (typeof c.themeCss === \"string\") c.themeCss = [c.themeCss];\n if (c.themeCss !== undefined && !isStringList(c.themeCss)) fail(`\"themeCss\" must be a path or a list of paths`);\n for (const key of STRING_LISTS) {\n if (c[key] !== undefined && !isStringList(c[key])) fail(`\"${key}\" must be a list of strings`);\n }\n for (const key of STRINGS) {\n if (c[key] !== undefined && typeof c[key] !== \"string\") fail(`\"${key}\" must be a string`);\n }\n if (c.rawTags !== undefined) {\n if (!isObject(c.rawTags)) fail(`\"rawTags\" must be an object`);\n for (const [tag, v] of Object.entries(c.rawTags as object)) {\n if (!/^[a-z][a-z0-9-]*$/.test(tag)) fail(`rawTags: \"${tag}\" is not an HTML tag name`);\n if (v !== false && typeof v !== \"string\") fail(`rawTags.${tag} must be a component name or false`);\n }\n }\n if (c.forbiddenImports !== undefined) {\n if (!isObject(c.forbiddenImports)) fail(`\"forbiddenImports\" must be an object of pattern → message`);\n for (const [re, msg] of Object.entries(c.forbiddenImports as object)) {\n if (typeof msg !== \"string\") fail(`forbiddenImports[\"${re}\"] must be a message string`);\n checkRegExp(re, `forbiddenImports[\"${re}\"]`, fail);\n }\n }\n if (c.rules !== undefined) {\n if (!isObject(c.rules)) fail(`\"rules\" must be an object of rule → level`);\n for (const [rule, level] of Object.entries(c.rules as object)) {\n if (!LEVELS.has(level as string)) fail(`rules.${rule} must be \"error\", \"warn\" or \"off\"`);\n }\n }\n if (c.allow !== undefined) {\n if (!Array.isArray(c.allow)) fail(`\"allow\" must be a list`);\n (c.allow as unknown[]).forEach((e, i) => {\n if (!isObject(e)) return fail(`allow[${i}] must be an object`);\n const entry = e as Record<string, unknown>;\n if (typeof entry.rule !== \"string\" || !entry.rule) fail(`allow[${i}] needs a \"rule\"`);\n if (typeof entry.reason !== \"string\" || !entry.reason.trim()) fail(`allow[${i}] (${entry.rule}) needs a \"reason\"`);\n for (const k of [\"file\", \"match\"]) {\n if (entry[k] !== undefined && typeof entry[k] !== \"string\") fail(`allow[${i}].${k} must be a string`);\n }\n });\n }\n if (c.patterns !== undefined) {\n if (!Array.isArray(c.patterns)) fail(`\"patterns\" must be a list`);\n (c.patterns as unknown[]).forEach((p, i) => {\n if (!isObject(p)) return fail(`patterns[${i}] must be an object`);\n const rule = p as Record<string, unknown>;\n for (const k of Object.keys(rule)) if (!PATTERN_KEYS.has(k)) fail(`patterns[${i}]: unknown key \"${k}\"`);\n if (typeof rule.id !== \"string\" || !rule.id) fail(`patterns[${i}] needs an \"id\"`);\n for (const k of [\"files\", \"exclude\"]) {\n if (rule[k] !== undefined && !isStringList(rule[k])) fail(`patterns[${i}].${k} must be a list of globs`);\n }\n });\n }\n if (c.plugins !== undefined) {\n const ok =\n Array.isArray(c.plugins) &&\n c.plugins.every((p) => typeof p === \"string\" || (Array.isArray(p) && p.length === 2 && typeof p[0] === \"string\"));\n if (!ok) fail(`\"plugins\" must be a list of module paths or [path, options] pairs`);\n }\n return c as DoctorConfig;\n}\n\nexport function checkRegExp(source: string, where: string, fail: (msg: string) => never): void {\n try {\n new RegExp(source);\n } catch (err) {\n fail(`${where} is not a valid regular expression: ${(err as Error).message}`);\n }\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === \"object\" && v !== null && !Array.isArray(v);\n}\n\nfunction isStringList(v: unknown): v is string[] {\n return Array.isArray(v) && v.every((x) => typeof x === \"string\");\n}\n","/**\n * `withGenesis()` — the Genesis Expo config plugin.\n *\n * Keeps an app's `app.config.ts` to a name, ids and plugins. It sets:\n *\n * 1. App variants: `APP_VARIANT` (`development` | `preview` | `production`,\n * default `production`) suffixes the bundle id, Android package and name,\n * so the three builds install side by side.\n * 2. Universal / app links from genesis.config.json `links`:\n * `ios.associatedDomains` (`applinks:` and `webcredentials:`) and one\n * Android `intentFilters` entry with `autoVerify`.\n * 3. The iOS privacy manifest's required-reason APIs for the packages the\n * app's package.json lists, merged into what the app declares.\n * 4. Export compliance: `ios.config.usesNonExemptEncryption = false`.\n * 5. `runtimeVersion: { policy: \"fingerprint\" }`.\n *\n * Anything the app already sets wins: the plugin fills gaps and appends to\n * lists, never overwrites or removes a value, and running it twice changes\n * nothing.\n *\n * Determinism: the plugin reads two committed files in the project root,\n * genesis.config.json and package.json, and one environment variable,\n * APP_VARIANT. No network, no clock, no other environment. The same commit\n * and variant always give the same config; the EAS fingerprint is stable only\n * if APP_VARIANT is set the same way for builds, `eas update` and fingerprint\n * checks (an EAS environment variable, not a build profile's `env`).\n */\nimport { existsSync, readFileSync } from \"node:fs\";\nimport * as path from \"node:path\";\nimport type { ConfigPlugin } from \"@expo/config-plugins\";\nimport type { ExpoConfig } from \"@expo/config-types\";\nimport { GenesisConfigError, readGenesisConfig, type GenesisLinks } from \"./doctor/config.js\";\n\nexport { GenesisConfigError, validateLinks, readGenesisConfig, type GenesisLinks } from \"./doctor/config.js\";\n\nexport const APP_VARIANTS = [\"development\", \"preview\", \"production\"] as const;\nexport type AppVariant = (typeof APP_VARIANTS)[number];\n\nexport interface VariantSuffix {\n /** Appended to `ios.bundleIdentifier` and `android.package`, e.g. `.dev`. */\n id: string;\n /** Appended to `name`, e.g. ` (Dev)`. */\n name: string;\n}\n\n/** A required-reason API category and the reasons for it, as in PrivacyInfo.xcprivacy. */\nexport interface PrivacyApi {\n NSPrivacyAccessedAPIType: string;\n NSPrivacyAccessedAPITypeReasons: string[];\n}\n\nexport interface WithGenesisOptions {\n /**\n * The variant, overriding `APP_VARIANT`. Tests and scripts pass it; an app\n * leaves it out and sets `APP_VARIANT` per build profile in eas.json.\n */\n variant?: AppVariant;\n /** Suffixes per non-production variant. Default `.dev` / ` (Dev)` and `.preview` / ` (Preview)`. */\n variants?: Partial<Record<Exclude<AppVariant, \"production\">, Partial<VariantSuffix>>>;\n /** Where genesis.config.json and package.json live. Default: the Expo project root. */\n projectRoot?: string;\n /** Turn single steps off. Every step is on by default. */\n links?: boolean;\n privacyManifest?: boolean;\n exportCompliance?: boolean;\n fingerprint?: boolean;\n}\n\nexport const DEFAULT_VARIANT_SUFFIXES: Record<Exclude<AppVariant, \"production\">, VariantSuffix> = {\n development: { id: \".dev\", name: \" (Dev)\" },\n preview: { id: \".preview\", name: \" (Preview)\" },\n};\n\n/**\n * The required-reason APIs each package needs the app to declare, copied from\n * the package's own PrivacyInfo.xcprivacy. A package is matched when the\n * app's package.json lists it in `dependencies`.\n *\n * - async-storage (2.2.0 `ios/PrivacyInfo.xcprivacy`): FileTimestamp, C617.1.\n *\n * expo-secure-store is not listed: the Keychain is not a required-reason API.\n */\nexport const PRIVACY_APIS: Record<string, PrivacyApi[]> = {\n \"@react-native-async-storage/async-storage\": [\n { NSPrivacyAccessedAPIType: \"NSPrivacyAccessedAPICategoryFileTimestamp\", NSPrivacyAccessedAPITypeReasons: [\"C617.1\"] },\n ],\n};\n\n/** The variant from options, else `APP_VARIANT`, else production. An unknown value throws. */\nexport function resolveVariant(given?: string): AppVariant {\n const value = given ?? process.env.APP_VARIANT ?? \"production\";\n if (!(APP_VARIANTS as readonly string[]).includes(value)) {\n throw new GenesisConfigError(`APP_VARIANT is \"${value}\"; expected one of ${APP_VARIANTS.join(\", \")}`);\n }\n return value as AppVariant;\n}\n\nexport function applyVariant(config: ExpoConfig, variant: AppVariant, options: WithGenesisOptions[\"variants\"] = {}): ExpoConfig {\n if (variant === \"production\") return config;\n const suffix = { ...DEFAULT_VARIANT_SUFFIXES[variant], ...options[variant] };\n // A value that already ends in the suffix was suffixed by an earlier run: leave it.\n const add = (value: string, end: string) => (end && value.endsWith(end) ? value : value + end);\n const next: ExpoConfig = { ...config, name: add(config.name, suffix.name) };\n if (config.ios?.bundleIdentifier) next.ios = { ...config.ios, bundleIdentifier: add(config.ios.bundleIdentifier, suffix.id) };\n if (config.android?.package) next.android = { ...config.android, package: add(config.android.package, suffix.id) };\n return next;\n}\n\nexport function applyLinks(config: ExpoConfig, links: GenesisLinks | undefined): ExpoConfig {\n if (!links) return config;\n const services = links.webcredentials === false ? [\"applinks\"] : [\"applinks\", \"webcredentials\"];\n const domains = links.hosts.flatMap((host) => services.map((service) => `${service}:${host}`));\n const associatedDomains = union(config.ios?.associatedDomains ?? [], domains);\n\n const data = links.hosts.flatMap((host) =>\n links.paths?.length ? links.paths.map((pathPrefix) => ({ scheme: \"https\", host, pathPrefix })) : [{ scheme: \"https\", host }],\n );\n const filter = { action: \"VIEW\", autoVerify: true, data, category: [\"BROWSABLE\", \"DEFAULT\"] };\n const existing = config.android?.intentFilters ?? [];\n const intentFilters = existing.some((f) => JSON.stringify(f) === JSON.stringify(filter)) ? existing : [...existing, filter];\n\n return {\n ...config,\n ios: { ...config.ios, associatedDomains },\n android: { ...config.android, intentFilters },\n };\n}\n\n/** The required-reason APIs for the packages listed in package.json `dependencies`. */\nexport function privacyApisFor(dependencies: Record<string, unknown>): PrivacyApi[] {\n return Object.keys(PRIVACY_APIS)\n .filter((pkg) => pkg in dependencies)\n .flatMap((pkg) => PRIVACY_APIS[pkg]!);\n}\n\n/** Merge required-reason APIs into `ios.privacyManifests`, keeping every entry and reason the app declares. */\nexport function applyPrivacyApis(config: ExpoConfig, apis: PrivacyApi[]): ExpoConfig {\n if (apis.length === 0) return config;\n const manifests = config.ios?.privacyManifests ?? {};\n const types = (manifests.NSPrivacyAccessedAPITypes ?? []).map((t) => ({ ...t, NSPrivacyAccessedAPITypeReasons: [...t.NSPrivacyAccessedAPITypeReasons] }));\n for (const api of apis) {\n const found = types.find((t) => t.NSPrivacyAccessedAPIType === api.NSPrivacyAccessedAPIType);\n if (found) found.NSPrivacyAccessedAPITypeReasons = union(found.NSPrivacyAccessedAPITypeReasons, api.NSPrivacyAccessedAPITypeReasons);\n else types.push({ ...api, NSPrivacyAccessedAPITypeReasons: [...api.NSPrivacyAccessedAPITypeReasons] });\n }\n return { ...config, ios: { ...config.ios, privacyManifests: { ...manifests, NSPrivacyAccessedAPITypes: types } } };\n}\n\nexport function applyExportCompliance(config: ExpoConfig): ExpoConfig {\n if (config.ios?.config?.usesNonExemptEncryption !== undefined) return config;\n return { ...config, ios: { ...config.ios, config: { ...config.ios?.config, usesNonExemptEncryption: false } } };\n}\n\nexport function applyFingerprint(config: ExpoConfig): ExpoConfig {\n if (config.runtimeVersion !== undefined || config.ios?.runtimeVersion !== undefined || config.android?.runtimeVersion !== undefined) {\n return config;\n }\n return { ...config, runtimeVersion: { policy: \"fingerprint\" } };\n}\n\n/** The Genesis config plugin. Use it in `plugins` or call it directly in app.config.ts. */\nexport const withGenesis: ConfigPlugin<WithGenesisOptions | void> = (config, props) => {\n const options = props ?? {};\n const root = options.projectRoot ?? (config as { _internal?: { projectRoot?: string } })._internal?.projectRoot ?? process.cwd();\n let next = applyVariant(config, resolveVariant(options.variant), options.variants);\n if (options.links !== false) next = applyLinks(next, readGenesisConfig(root)?.links);\n if (options.privacyManifest !== false) next = applyPrivacyApis(next, privacyApisFor(readDependencies(root)));\n if (options.exportCompliance !== false) next = applyExportCompliance(next);\n if (options.fingerprint !== false) next = applyFingerprint(next);\n return next;\n};\n\nexport default withGenesis;\n\nfunction readDependencies(root: string): Record<string, unknown> {\n const file = path.join(root, \"package.json\");\n if (!existsSync(file)) return {};\n try {\n const deps = JSON.parse(readFileSync(file, \"utf8\"))?.dependencies;\n return deps && typeof deps === \"object\" ? deps : {};\n } catch (err) {\n throw new GenesisConfigError(`${file} is not valid JSON: ${(err as Error).message}`);\n }\n}\n\nfunction union(a: string[], b: string[]): string[] {\n return [...new Set([...a, ...b])];\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export { FileSystem, ScaffoldLogger, ScaffoldOptions, ScaffoldResult, planScaffold, runScaffold, validateConsumerName } from './scaffolder.js';
2
2
  import postgres from 'postgres';
3
- export { DoctorConfig, DoctorConfigError, DoctorContext, DoctorPlugin, DoctorResult, Finding, RunDoctorOptions, defineDoctorPlugin, formatReport, runDoctor } from './doctor.js';
3
+ export { RunDoctorOptions, defineDoctorPlugin, formatReport, runDoctor } from './doctor.js';
4
+ export { D as DoctorConfig, b as DoctorConfigError, c as DoctorContext, d as DoctorPlugin, e as DoctorResult, F as Finding, a as GenesisConfigError, f as GenesisConfigFile, G as GenesisLinks, r as readGenesisConfig, v as validateLinks } from './config-Ci-_Ue-1.js';
4
5
 
5
6
  type StorageType = "string" | "number" | "boolean" | "datetime" | "json";
6
7
  interface IntrospectedColumn {
package/dist/index.js CHANGED
@@ -46,16 +46,12 @@ export type { Brand } from "./brand";
46
46
  },
47
47
  {
48
48
  path: `tailwind.config.ts`,
49
- content: tailwindConfig(consumer)
49
+ content: tailwindConfig(consumer, opts.native ?? false)
50
50
  },
51
51
  {
52
52
  path: `app/global.css`,
53
53
  content: globalCss()
54
54
  },
55
- {
56
- path: `.genesis/cli.yml`,
57
- content: genesisConfig(consumer)
58
- },
59
55
  {
60
56
  path: `CLAUDE.md`,
61
57
  content: claudeMd(consumer)
@@ -105,9 +101,9 @@ async function runScaffold(opts, fs) {
105
101
  function joinPath(...parts) {
106
102
  return parts.filter(Boolean).join("/").replace(/\/+/g, "/");
107
103
  }
108
- function dirname(path9) {
109
- const idx = path9.lastIndexOf("/");
110
- return idx === -1 ? "." : path9.slice(0, idx);
104
+ function dirname(path10) {
105
+ const idx = path10.lastIndexOf("/");
106
+ return idx === -1 ? "." : path10.slice(0, idx);
111
107
  }
112
108
  function brandPackageJson(consumer, genesisVersion) {
113
109
  return JSON.stringify(
@@ -237,8 +233,11 @@ export const brand: Brand = {
237
233
  };
238
234
  `;
239
235
  }
240
- function tailwindConfig(consumer) {
236
+ function tailwindConfig(consumer, native) {
241
237
  return `import type { Config } from "tailwindcss";
238
+ import { genesisPreset } from "@marktiderman/genesis-design-system/presets/tailwind";${native ? `
239
+ // NativeWind v4 needs its preset; Genesis's goes after it.
240
+ import nativewindPreset from "nativewind/preset";` : ""}
242
241
  import { brand } from "@${consumer}/brand";
243
242
 
244
243
  /**
@@ -254,9 +253,9 @@ const config: Config = {
254
253
  content: [
255
254
  "./app/**/*.{ts,tsx}",
256
255
  "./components/**/*.{ts,tsx}",
257
- "./node_modules/@marktiderman/genesis-ui-native/**/*.{js,ts,tsx}",
258
- ],
259
- presets: [require("@marktiderman/genesis-design-system/tailwind-preset")],
256
+ ${native ? ` "./node_modules/@marktiderman/genesis-ui-native/**/*.{js,ts,tsx}",
257
+ ` : ""} ],
258
+ presets: [${native ? "nativewindPreset, " : ""}genesisPreset],
260
259
  theme: {
261
260
  extend: {
262
261
  colors: {
@@ -278,47 +277,16 @@ export default config;
278
277
  }
279
278
  function globalCss() {
280
279
  return `/**
281
- * Genesis global stylesheet entry. Imports the canonical token sheet
282
- * + the consumer's tailwind layers. The token sheet wires CSS variables
283
- * (--color-primary, --color-foreground, etc.) used by every Genesis
284
- * primitive's tailwind classes.
280
+ * Genesis global stylesheet entry. Imports the Genesis theme (the CSS
281
+ * variables every Genesis primitive's classes read: --background,
282
+ * --foreground, --primary, \u2026) and the consumer's tailwind layers.
285
283
  */
286
- @import "@marktiderman/genesis-design-system/tokens.css";
284
+ @import "@marktiderman/genesis-design-system/themes/genesis.css";
287
285
  @tailwind base;
288
286
  @tailwind components;
289
287
  @tailwind utilities;
290
288
  `;
291
289
  }
292
- function genesisConfig(consumer) {
293
- return `# Genesis DESIGN-SYSTEM consumer pin \u2014 read by the genesis CLI + .claude/hooks/*
294
- # NOT the harness config: the schema-validated harness/root config lives at
295
- # genesis.config.yml (see genesis.config.example.yml). This file only pins the
296
- # @marktiderman/genesis-* version + design-system rules for this consumer.
297
- #
298
- # version pin: which @marktiderman/genesis-* major are we on. The genesis CLI
299
- # uses this to validate that an upgrade hasn't drifted past breaking-change
300
- # boundaries.
301
- version: "1"
302
- consumer: "${consumer}"
303
-
304
- rules:
305
- # Block raw hex in consumer code \u2014 must use brand tokens.
306
- no-raw-hex: error
307
- # Block StyleSheet.create() in NativeWind-first projects.
308
- no-stylesheet-create: error
309
- # Block fork-and-modify of Genesis primitives.
310
- no-genesis-fork: error
311
- # Layouts must compose Genesis primitives, not rebuild them.
312
- prefer-genesis-layout: warn
313
-
314
- # Path map \u2014 where consumer composites + brand live. Default values match
315
- # the scaffolder's output; adjust if your layout differs.
316
- paths:
317
- brand: "packages/${consumer}-brand"
318
- composites: "components"
319
- app: "app"
320
- `;
321
- }
322
290
  function claudeMd(consumer) {
323
291
  return `# CLAUDE.md \u2014 ${consumer}
324
292
 
@@ -326,8 +294,9 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
326
294
 
327
295
  ## Workflow
328
296
 
329
- - **Reuse before extend, extend before create.** See the Genesis usage
330
- doctrine: \`docs/prds/PRD-07-genesis-consumption-architecture/standards/usage-doctrine.md\`
297
+ - **Reuse before extend, extend before create.** Before building anything,
298
+ run \`npx @marktiderman/genesis-cli features find <term>\` and read
299
+ https://github.com/marktiderman/genesis/blob/main/docs/FRAMEWORK.md
331
300
  - **Brand changes live in \`packages/${consumer}-brand\`.** Don't fork Genesis
332
301
  primitives \u2014 edit your brand schema instead (Layer 1).
333
302
  - **Layout customization has 4 layers.** Default \u2192 named props \u2192
@@ -335,9 +304,9 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
335
304
 
336
305
  ## Critical rules
337
306
 
338
- - \`.genesis/cli.yml\` design-system rules are enforced via Claude Code hooks. Don't
339
- bypass with \`StyleSheet.create()\` or raw hex; use brand tokens.
340
- - Run \`pnpm test\` before every commit.
307
+ - \`genesis doctor\` enforces the design-system rules. Don't bypass them with
308
+ \`StyleSheet.create()\` or raw hex; use brand tokens and theme roles.
309
+ - Run your test script before every commit.
341
310
  - Open RFCs in the genesis repo for missing primitives \u2014 don't fork
342
311
  locally and forget.
343
312
 
@@ -1025,7 +994,10 @@ ${String(r.stderr ?? "").trim().split("\n").slice(-20).join("\n")}` : "";
1025
994
  }
1026
995
  return null;
1027
996
  }
1028
- var DoctorConfigError = class extends Error {
997
+ var GenesisConfigError = class extends Error {
998
+ name = "GenesisConfigError";
999
+ };
1000
+ var DoctorConfigError = class extends GenesisConfigError {
1029
1001
  name = "DoctorConfigError";
1030
1002
  };
1031
1003
  var STRING_LISTS = ["src", "extensions", "ignore", "tokenFiles", "ignoreTokenPrefixes", "localPrimitiveDirs", "build"];
@@ -1055,7 +1027,8 @@ function loadConfig(root, configPath) {
1055
1027
  }
1056
1028
  const own = path3.join(root, "genesis.config.json");
1057
1029
  if (existsSync(own)) {
1058
- return { config: validateConfig(readJson(own)?.doctor ?? {}, own), file: own, dir: root };
1030
+ const block = readGenesisConfig(root)?.raw.doctor;
1031
+ return { config: validateConfig(block ?? {}, own), file: own, dir: root };
1059
1032
  }
1060
1033
  const pkg = path3.join(root, "package.json");
1061
1034
  if (existsSync(pkg)) {
@@ -1071,6 +1044,43 @@ function readJson(file) {
1071
1044
  throw new DoctorConfigError(`${file} is not valid JSON: ${err.message}`);
1072
1045
  }
1073
1046
  }
1047
+ function readGenesisConfig(root) {
1048
+ const file = path3.join(root, "genesis.config.json");
1049
+ if (!existsSync(file)) return null;
1050
+ const raw = readJson(file);
1051
+ if (!isObject(raw)) throw new GenesisConfigError(`${file}: the config must be a JSON object`);
1052
+ const links = raw.links === void 0 ? void 0 : validateLinks(raw.links, file);
1053
+ return links ? { raw, links } : { raw };
1054
+ }
1055
+ var LINK_KEYS = /* @__PURE__ */ new Set(["hosts", "paths", "webcredentials"]);
1056
+ var HOST = /^(?=.{1,253}$)(\*\.)?([a-z0-9]([a-z0-9-]{0,61}[a-z0-9])?\.)+[a-z]{2,63}$/;
1057
+ function validateLinks(raw, source = "config") {
1058
+ const fail = (msg) => {
1059
+ throw new GenesisConfigError(`${source}: ${msg}`);
1060
+ };
1061
+ if (!isObject(raw)) fail(`"links" must be an object`);
1062
+ const c = raw;
1063
+ for (const key of Object.keys(c)) if (!LINK_KEYS.has(key)) fail(`links: unknown setting "${key}"`);
1064
+ if (!isStringList(c.hosts) || c.hosts.length === 0) fail(`links.hosts must be a non-empty list of host names`);
1065
+ for (const host of c.hosts) {
1066
+ if (!HOST.test(host)) {
1067
+ fail(`links.hosts: "${host}" is not a bare lower-case host name (no scheme, path or port), e.g. "example.com"`);
1068
+ }
1069
+ }
1070
+ if (c.paths !== void 0) {
1071
+ if (!isStringList(c.paths)) fail(`links.paths must be a list of path prefixes`);
1072
+ for (const p of c.paths) {
1073
+ if (!p.startsWith("/") || /[\s?#*]/.test(p)) {
1074
+ fail(`links.paths: "${p}" must start with "/" and hold no spaces, "?", "#" or "*"`);
1075
+ }
1076
+ }
1077
+ }
1078
+ if (c.webcredentials !== void 0 && typeof c.webcredentials !== "boolean") fail(`links.webcredentials must be true or false`);
1079
+ const links = { hosts: [...new Set(c.hosts)] };
1080
+ if (c.paths !== void 0) links.paths = [...new Set(c.paths)];
1081
+ if (c.webcredentials !== void 0) links.webcredentials = c.webcredentials;
1082
+ return links;
1083
+ }
1074
1084
  function validateConfig(raw, source = "config") {
1075
1085
  const fail = (msg) => {
1076
1086
  throw new DoctorConfigError(`${source}: ${msg}`);
@@ -1175,7 +1185,7 @@ function globToRegExp(glob) {
1175
1185
  }
1176
1186
  function globMatcher(globs) {
1177
1187
  const res = (globs ?? []).filter((g) => g.trim()).map(globToRegExp);
1178
- return (path9) => res.some((re) => re.test(path9));
1188
+ return (path10) => res.some((re) => re.test(path10));
1179
1189
  }
1180
1190
  var DEFAULT_UI_PACKAGE = "@marktiderman/genesis-ui";
1181
1191
  var DESIGN_SYSTEM_PACKAGE = "@marktiderman/genesis-design-system";
@@ -1731,7 +1741,8 @@ var BUILTIN_RULES = [
1731
1741
  "arbitrary-color",
1732
1742
  "raw-color",
1733
1743
  "undefined-token",
1734
- "shadowed-export"
1744
+ "shadowed-export",
1745
+ "version-skew"
1735
1746
  ];
1736
1747
  var DEFAULT_LOCAL_PRIMITIVE_DIRS = ["src/components/ui"];
1737
1748
  var STARTER_LEFTOVERS = ["components.json", "src/lib/utils.ts"];
@@ -1877,6 +1888,30 @@ function unusedComponents(ctx) {
1877
1888
  }
1878
1889
  return ctx.genesis.components.filter((c) => !used.has(c));
1879
1890
  }
1891
+ var UMBRELLA_PACKAGE = "@marktiderman/genesis";
1892
+ function readReleaseManifest(root) {
1893
+ const dir = findPackageDir(root, UMBRELLA_PACKAGE);
1894
+ const file = dir && path3.join(dir, "dist", "versions.json");
1895
+ if (!file || !existsSync(file)) return null;
1896
+ return JSON.parse(readFileSync(file, "utf8"));
1897
+ }
1898
+ function checkVersionSkew(ctx) {
1899
+ const manifest = readReleaseManifest(ctx.root);
1900
+ if (!manifest) return;
1901
+ for (const [name, want] of Object.entries(manifest.packages)) {
1902
+ const dir = findPackageDir(ctx.root, name);
1903
+ if (!dir) continue;
1904
+ const have = JSON.parse(readFileSync(path3.join(dir, "package.json"), "utf8")).version;
1905
+ if (have === want) continue;
1906
+ ctx.report({
1907
+ rule: "version-skew",
1908
+ level: "warn",
1909
+ file: "package.json",
1910
+ subject: name,
1911
+ message: `${name} is ${have}, but ${UMBRELLA_PACKAGE} ${manifest.version} was released with ${want}. Install ${name}@${want}, or move every Genesis package to one release.`
1912
+ });
1913
+ }
1914
+ }
1880
1915
 
1881
1916
  // src/doctor/index.ts
1882
1917
  async function runDoctor(options = {}) {
@@ -1899,7 +1934,8 @@ async function runDoctor(options = {}) {
1899
1934
  { name: "raw-tags", check: checkRawTags },
1900
1935
  { name: "colors", check: checkColors },
1901
1936
  { name: "tokens", check: checkTokens },
1902
- { name: "shadowed-exports", check: checkShadowedExports }
1937
+ { name: "shadowed-exports", check: checkShadowedExports },
1938
+ { name: "version-skew", check: checkVersionSkew }
1903
1939
  ];
1904
1940
  for (const plugin of [...builtins, ...patterns ? [patterns.plugin] : [], ...plugins]) {
1905
1941
  try {
@@ -1977,6 +2013,6 @@ function formatReport(result) {
1977
2013
  return lines.join("\n");
1978
2014
  }
1979
2015
 
1980
- export { CommentSettingsError, DoctorConfigError, defineDoctorPlugin, detectHost, emitContracts, formatReport, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planScaffold, planStudioInit, runDoctor, runScaffold, validateConsumerName };
2016
+ export { CommentSettingsError, DoctorConfigError, GenesisConfigError, defineDoctorPlugin, detectHost, emitContracts, formatReport, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planScaffold, planStudioInit, readGenesisConfig, runDoctor, runScaffold, validateConsumerName, validateLinks };
1981
2017
  //# sourceMappingURL=index.js.map
1982
2018
  //# sourceMappingURL=index.js.map