@marktiderman/genesis-cli 1.4.0 → 1.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  import { ConfigPlugin } from '@expo/config-plugins';
2
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';
3
+ import { G as GenesisLinks } from './config-CUdwT-nY.js';
4
+ export { a as GenesisConfigError, r as readGenesisConfig, v as validateLinks } from './config-CUdwT-nY.js';
5
5
 
6
6
  declare const APP_VARIANTS: readonly ["development", "preview", "production"];
7
7
  type AppVariant = (typeof APP_VARIANTS)[number];
package/dist/expo.js.map CHANGED
@@ -1 +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,MAAM,IAAI,iBAAA,CAAkB,CAAA,EAAG,IAAI,CAAA,oBAAA,EAAwB,GAAA,CAAc,OAAO,CAAA,CAAE,CAAA;AAAA,EACpF;AACF;AAOO,SAAS,kBAAkB,IAAA,EAAwC;AACxE,EAAA,MAAM,IAAA,GAAY,IAAA,CAAA,IAAA,CAAK,IAAA,EAAM,qBAAqB,CAAA;AAClD,EAAA,IAAI,CAAC,U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AA,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"]}
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;AAsFA,SAAS,SAAS,IAAA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AAQ;AAEf,SAAS,iBAAiB,IAAA,EAAuC;AAC/D,EAAA,MAAM,IAAA,GAAYA,IAAA,CAAA,IAAA,CAAK,IAAA,EAAM,cAAc,CAAA;AAC3C,EAAA,IAAI,CAACC,UAAAA,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 \"packs\",\n \"native\",\n \"supabase\",\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\"]);\nconst PACKS = new Set([\"native\", \"supabase\"]);\n/** Each pack's settings: key → \"string\", \"path\" (app-relative folder, normalized) or \"list\". */\nconst PACK_KEYS: Record<string, Record<string, \"string\" | \"path\" | \"list\">> = {\n native: { routerRoot: \"path\" },\n supabase: { migrations: \"path\", base: \"string\", exposedSchemas: \"list\", since: \"string\" },\n};\n\n/** An app-relative folder in POSIX form (`./app/` → `app`); absolute paths and paths leaving the app are rejected. */\nfunction appPath(v: unknown, where: string, fail: (msg: string) => never): string {\n if (typeof v !== \"string\" || !v.trim()) return fail(`${where} must be a non-empty path`);\n if (path.isAbsolute(v) || /^[A-Za-z]:[\\\\/]/.test(v)) fail(`${where} must be relative to the app, not absolute (\"${v}\")`);\n const norm = path.posix.normalize(v.replace(/\\\\/g, \"/\")).replace(/\\/+$/, \"\");\n if (norm === \".\" || norm === \"..\" || norm.startsWith(\"../\")) fail(`${where} must be a folder inside the app (\"${v}\")`);\n return norm;\n}\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.packs !== undefined) {\n if (!isStringList(c.packs)) fail(`\"packs\" must be a list, e.g. [\"native\", \"supabase\"]`);\n for (const p of c.packs as string[]) if (!PACKS.has(p)) fail(`packs: unknown pack \"${p}\" (known: ${[...PACKS].join(\", \")})`);\n if (new Set(c.packs as string[]).size !== (c.packs as string[]).length) fail(`packs: lists a pack twice`);\n }\n for (const [pack, keys] of Object.entries(PACK_KEYS)) {\n const block = c[pack];\n if (block === undefined) continue;\n if (!isObject(block)) fail(`\"${pack}\" must be an object`);\n if (!((c.packs as string[] | undefined) ?? []).includes(pack)) fail(`\"${pack}\" settings are set but the ${pack} pack is not in \"packs\"`);\n for (const [k, v] of Object.entries(block as object)) {\n const want = keys[k];\n if (!want) fail(`${pack}: unknown setting \"${k}\"`);\n if (want === \"string\" && typeof v !== \"string\") fail(`${pack}.${k} must be a string`);\n if (want === \"list\" && !isStringList(v)) fail(`${pack}.${k} must be a list of strings`);\n if (want === \"string\" && !(v as string).trim()) fail(`${pack}.${k} must not be empty`);\n if (want === \"path\") (block as Record<string, unknown>)[k] = appPath(v, `${pack}.${k}`, fail);\n }\n }\n // Schema names compare lowercased, like the SQL they're matched against.\n const supa = c.supabase as Record<string, unknown> | undefined;\n if (Array.isArray(supa?.exposedSchemas)) supa.exposedSchemas = (supa.exposedSchemas as string[]).map((s) => s.toLowerCase());\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,7 +1,7 @@
1
1
  export { FileSystem, ScaffoldLogger, ScaffoldOptions, ScaffoldResult, planScaffold, runScaffold, validateConsumerName } from './scaffolder.js';
2
2
  import postgres from 'postgres';
3
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
+ 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-CUdwT-nY.js';
5
5
 
6
6
  type StorageType = "string" | "number" | "boolean" | "datetime" | "json";
7
7
  interface IntrospectedColumn {