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