@marktiderman/genesis-cli 1.11.0 → 1.11.1

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
@@ -2195,6 +2195,11 @@ var real = (p) => {
2195
2195
  return p;
2196
2196
  }
2197
2197
  };
2198
+ var LOCKFILES = ["bun.lock", "bun.lockb", "package-lock.json", "npm-shrinkwrap.json", "yarn.lock", "pnpm-lock.yaml"];
2199
+ function nodeModulesOf(dir) {
2200
+ const parent = path14.dirname(dir);
2201
+ return path14.basename(parent).startsWith("@") ? path14.dirname(parent) : parent;
2202
+ }
2198
2203
  function packagesIn(nodeModules) {
2199
2204
  if (!existsSync(nodeModules)) return [];
2200
2205
  const out = [];
@@ -2243,18 +2248,33 @@ function genesisInstalls(root) {
2243
2248
  for (const r of roots) visit(r.dir, r.by, r.range);
2244
2249
  while (queue.length) {
2245
2250
  const { real: from, manifest, label } = queue.shift();
2246
- const deps = { ...manifest.peerDependencies, ...manifest.optionalDependencies, ...manifest.dependencies };
2251
+ const deps = { ...manifest.optionalDependencies, ...manifest.dependencies };
2247
2252
  for (const [name, range] of Object.entries(deps)) {
2248
2253
  const dir = findPackageDir(from, name);
2249
2254
  if (dir) visit(dir, label, range);
2250
2255
  }
2256
+ for (const [name, range] of Object.entries(manifest.peerDependencies ?? {})) {
2257
+ if (name in deps) continue;
2258
+ const dir = peerOf(from, name);
2259
+ if (dir) visit(dir, label, range);
2260
+ }
2251
2261
  }
2252
2262
  };
2263
+ const peerOf = (from, name) => {
2264
+ const dir = findPackageDir(from, name);
2265
+ if (!dir) return null;
2266
+ if (!ownInstall || name in declared) return dir;
2267
+ const realDir = real(dir);
2268
+ if (realDir.startsWith(realRoot + path14.sep)) return dir;
2269
+ return nodeModulesOf(realDir) === nodeModulesOf(from) ? dir : null;
2270
+ };
2253
2271
  const rootsOf = (deps, by) => Object.entries(deps).flatMap(([name, range]) => {
2254
2272
  const dir = findPackageDir(root, name);
2255
2273
  return dir ? [{ dir, by, ...range ? { range } : {} }] : [];
2256
2274
  });
2257
2275
  const app = readManifest(root);
2276
+ const ownInstall = LOCKFILES.some((f) => existsSync(path14.join(root, f)));
2277
+ const declared = { ...app?.devDependencies, ...app?.peerDependencies, ...app?.optionalDependencies, ...app?.dependencies };
2258
2278
  const declaredDev = Object.entries(app?.devDependencies ?? {});
2259
2279
  const runtimeDeps = {
2260
2280
  ...Object.fromEntries(declaredDev.filter(([n]) => !NON_SHIPPING.test(n))),
@@ -2273,7 +2293,7 @@ function genesisInstalls(root) {
2273
2293
  }).map((dir) => ({ dir, by: "hoisted, not a direct dependency" }))
2274
2294
  );
2275
2295
  const devRoots = { ...devDeps };
2276
- for (const tool of DEV_TOOLS) if (!(tool in devRoots)) devRoots[tool] = runtimeDeps[tool];
2296
+ for (const tool of DEV_TOOLS) if (!(tool in devRoots) && tool in runtimeDeps) devRoots[tool] = runtimeDeps[tool];
2277
2297
  walk("dev", rootsOf(devRoots, "the app (dev)"));
2278
2298
  for (const [key2, copy] of copies) {
2279
2299
  const kinds = via.get(key2);