@marktiderman/genesis-cli 1.11.0 → 1.11.2

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/doctor.js CHANGED
@@ -1130,7 +1130,7 @@ function unusedComponents(ctx) {
1130
1130
  // ../../scripts/lib/native-primitives.mjs
1131
1131
  var NATIVE_WRAPPED_PRIMITIVES = Object.freeze({
1132
1132
  Modal: Object.freeze(["NativeDialog", "NativeSheet", "NativeDrawer"]),
1133
- ActivityIndicator: Object.freeze(["NativeSkeleton", "NativeProgress"])
1133
+ ActivityIndicator: Object.freeze(["NativeLoadingState", "NativeSkeleton", "NativeProgress"])
1134
1134
  });
1135
1135
  function wrappedPrimitivesIn(namedImports) {
1136
1136
  return namedImports.split(",").map((n) => n.trim()).filter((n) => n && !/^type\s/.test(n)).map((n) => n.split(/\s+as\s+/)[0].trim()).filter((n) => n && Object.hasOwn(NATIVE_WRAPPED_PRIMITIVES, n));
@@ -1398,6 +1398,13 @@ function checkCustomHeaders(ctx, pkg) {
1398
1398
  });
1399
1399
  }
1400
1400
  }
1401
+ var LOADING_ROUTE_COMPANIONS = /* @__PURE__ */ new Set(["NativeLoadingState", "Stack.Screen", "Fragment", "React.Fragment"]);
1402
+ function isLoadingOnlyRoute(code) {
1403
+ const loading = [...code.matchAll(/<NativeLoadingState\b([^>]*)>/g)];
1404
+ if (loading.length === 0 || loading.some((m) => /\bfullScreen\s*=\s*\{\s*false\s*\}/.test(m[1] ?? ""))) return false;
1405
+ const tags = [...code.matchAll(/<([A-Z][\w.]*)/g)].map((m) => m[1] ?? "");
1406
+ return tags.every((t) => LOADING_ROUTE_COMPANIONS.has(t));
1407
+ }
1401
1408
  function routerRoot(ctx) {
1402
1409
  if (ctx.config.native?.routerRoot) return ctx.config.native.routerRoot.replace(/\/+$/, "");
1403
1410
  return existsSync(path14.join(ctx.root, "src", "app")) ? "src/app" : "app";
@@ -1420,12 +1427,13 @@ function checkScreenLayouts(ctx, pkg) {
1420
1427
  });
1421
1428
  return;
1422
1429
  }
1423
- const renders2 = new RegExp(`<(?:${layouts.join("|")}|Redirect)\\b`);
1430
+ const renders2 = new RegExp(`<(?:${[...layouts, "Redirect"].join("|")})\\b`);
1431
+ const loadingOnly = pkg.values.has("NativeLoadingState") ? isLoadingOnlyRoute : () => false;
1424
1432
  const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
1425
1433
  for (const file of routes) {
1426
1434
  if (!JSX_EXTS3.has(file.ext) || NON_SCREEN_ROUTE.test(file.path)) continue;
1427
1435
  if (!/\bexport\s+default\b/.test(file.code) || !/<[A-Za-z]/.test(file.code)) continue;
1428
- if (renders2.test(file.code)) continue;
1436
+ if (renders2.test(file.code) || loadingOnly(file.code)) continue;
1429
1437
  const viaImport = localImports(ctx.root, file).some((abs) => {
1430
1438
  const target = byPath.get(abs) ?? readSource(abs);
1431
1439
  return target !== null && renders2.test(target.code);
@@ -2195,6 +2203,11 @@ var real = (p) => {
2195
2203
  return p;
2196
2204
  }
2197
2205
  };
2206
+ var LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"];
2207
+ function nodeModulesOf(dir) {
2208
+ const parent = path14.dirname(dir);
2209
+ return path14.basename(parent).startsWith("@") ? path14.dirname(parent) : parent;
2210
+ }
2198
2211
  function packagesIn(nodeModules) {
2199
2212
  if (!existsSync(nodeModules)) return [];
2200
2213
  const out = [];
@@ -2243,18 +2256,33 @@ function genesisInstalls(root) {
2243
2256
  for (const r of roots) visit(r.dir, r.by, r.range);
2244
2257
  while (queue.length) {
2245
2258
  const { real: from, manifest, label } = queue.shift();
2246
- const deps = { ...manifest.peerDependencies, ...manifest.optionalDependencies, ...manifest.dependencies };
2259
+ const deps = { ...manifest.optionalDependencies, ...manifest.dependencies };
2247
2260
  for (const [name, range] of Object.entries(deps)) {
2248
2261
  const dir = findPackageDir(from, name);
2249
2262
  if (dir) visit(dir, label, range);
2250
2263
  }
2264
+ for (const [name, range] of Object.entries(manifest.peerDependencies ?? {})) {
2265
+ if (name in deps) continue;
2266
+ const dir = peerOf(from, name);
2267
+ if (dir) visit(dir, label, range);
2268
+ }
2251
2269
  }
2252
2270
  };
2271
+ const peerOf = (from, name) => {
2272
+ const dir = findPackageDir(from, name);
2273
+ if (!dir) return null;
2274
+ if (!ownInstall || name in declared) return dir;
2275
+ const realDir = real(dir);
2276
+ if (realDir.startsWith(realRoot + path14.sep)) return dir;
2277
+ return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
2278
+ };
2253
2279
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
2254
2280
  const dir = findPackageDir(root, name);
2255
2281
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
2256
2282
  });
2257
2283
  const app = readManifest(root);
2284
+ const ownInstall = LOCKFILES.some((f) => existsSync(path14.join(root, f)));
2285
+ const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
2258
2286
  const declaredDev = Object.entries(app?.devDependencies ?? {});
2259
2287
  const runtimeDeps = {
2260
2288
  ...Object.fromEntries(declaredDev.filter(([n]) => !NON_SHIPPING.test(n))),
@@ -2273,7 +2301,7 @@ function genesisInstalls(root) {
2273
2301
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
2274
2302
  );
2275
2303
  const devRoots = { ...devDeps };
2276
- for (const tool of DEV_TOOLS) if (!(tool in devRoots)) devRoots[tool] = runtimeDeps[tool];
2304
+ for (const tool of DEV_TOOLS) if (!(tool in devRoots) && tool in runtimeDeps) devRoots[tool] = runtimeDeps[tool];
2277
2305
  walk("dev", rootsOf(devRoots, "the app (dev)"));
2278
2306
  for (const [key2, copy] of copies) {
2279
2307
  const kinds = via.get(key2);