pi-straw-boss 0.80.1 → 0.80.3

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.
@@ -4393,7 +4393,7 @@ function checkStages(stages) {
4393
4393
 
4394
4394
  // src/train/appsconfig.ts
4395
4395
  import { existsSync as existsSync8, readFileSync as readFileSync12, realpathSync as realpathSync2, statSync as statSync7 } from "node:fs";
4396
- import { basename as basename2, dirname as dirname6, join as join12, resolve as resolve2, sep as sep2 } from "node:path";
4396
+ import { basename as basename2, dirname as dirname6, join as join12, relative as relative2, resolve as resolve2, sep as sep2 } from "node:path";
4397
4397
  var MIGRATION = "see docs/how-it-works.md, Moving a project to 0.65.0";
4398
4398
  function gitRoot(dir) {
4399
4399
  for (let d = dir; ; d = dirname6(d)) {
@@ -4479,28 +4479,60 @@ function repoRoot(dir) {
4479
4479
  return real2(root);
4480
4480
  }
4481
4481
  }
4482
- function carRepos(dir, app, fallback = dir) {
4482
+ function gitDirs(root) {
4483
+ try {
4484
+ const dot = join12(root, ".git"), named2 = statSync7(dot).isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))[1].trim() : dot, gitdir = realpathSync2(resolve2(root, named2));
4485
+ return [gitdir, commonOf(gitdir)];
4486
+ } catch {
4487
+ return [];
4488
+ }
4489
+ }
4490
+ function commonOf(gitdir) {
4491
+ const file = join12(gitdir, "commondir");
4492
+ return existsSync8(file) ? realpathSync2(resolve2(gitdir, readFileSync12(file, "utf8").trim())) : gitdir;
4493
+ }
4494
+ function appRepos(dir, app) {
4483
4495
  const read = readApps(dir), at2 = read.ok ? read.apps.find((a) => a.name === app)?.dir : void 0;
4484
- if (typeof at2 !== "string") return [fallback];
4485
- const home = repoRoot(dir);
4496
+ if (typeof at2 !== "string") return [];
4497
+ const top = resolve2(gitRoot(dir)), home = repoRoot(dir);
4486
4498
  const inside2 = (path, root) => path.startsWith(root + sep2);
4487
- const ownGitDir = (folder) => {
4488
- const dot = join12(folder, ".git");
4489
- if (statSync7(dot).isDirectory()) return true;
4490
- const named2 = /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))?.[1]?.trim();
4491
- return named2 !== void 0 && inside2(realpathSync2(resolve2(folder, named2)), home);
4492
- };
4493
4499
  const own2 = (root) => {
4494
4500
  const folder = resolve2(root, at2);
4495
- if (!inside2(folder, root) || !existsSync8(join12(folder, ".git"))) return [];
4501
+ if (!inside2(folder, root)) return [];
4496
4502
  try {
4497
- const real2 = realpathSync2(folder);
4498
- return inside2(real2, realpathSync2(root)) && ownGitDir(real2) ? [real2] : [];
4503
+ const real2 = realpathSync2(root), mine = gitDirs(top), allowed = [real2, home, ...mine], within2 = (path) => allowed.some((a) => path === a || inside2(path, a));
4504
+ for (let d = realpathSync2(folder); inside2(d, real2); d = dirname6(d)) {
4505
+ const dot = join12(d, ".git"), stat = statSync7(dot, { throwIfNoEntry: false });
4506
+ if (!stat) continue;
4507
+ const named2 = stat.isDirectory() ? dot : stat.isFile() ? /^gitdir:\s*(.+)$/m.exec(readFileSync12(dot, "utf8"))?.[1]?.trim() : void 0;
4508
+ if (named2 === void 0) return [];
4509
+ const gitdir = realpathSync2(resolve2(d, named2)), common = commonOf(gitdir);
4510
+ if (common === mine[1] || !existsSync8(join12(gitdir, "HEAD"))) return [];
4511
+ return within2(gitdir) && within2(common) ? [d] : [];
4512
+ }
4499
4513
  } catch {
4500
- return [];
4501
4514
  }
4515
+ return [];
4502
4516
  };
4503
- const found = [.../* @__PURE__ */ new Set([...own2(resolve2(gitRoot(dir))), ...own2(home)])];
4517
+ return [.../* @__PURE__ */ new Set([...own2(top), ...own2(home)])];
4518
+ }
4519
+ function appLinkPaths(dir, app) {
4520
+ const read = readApps(dir), at2 = read.ok ? read.apps.find((a) => a.name === app)?.dir : void 0, root = resolve2(gitRoot(dir)), paths = [];
4521
+ if (typeof at2 !== "string") return { root, paths };
4522
+ for (let d = resolve2(root, at2); d.startsWith(root + sep2); d = dirname6(d)) paths.push(relative2(root, d).split(sep2).join("/"));
4523
+ return { root, paths };
4524
+ }
4525
+ function gitmodulesPaths(root) {
4526
+ let text4;
4527
+ try {
4528
+ text4 = readFileSync12(join12(root, ".gitmodules"), "utf8");
4529
+ } catch {
4530
+ return [];
4531
+ }
4532
+ return [...text4.matchAll(/^[ \t]*path[ \t]*=[ \t]*(.*?)[ \t]*$/gm)].map((m) => m[1].replace(/^"(.*)"$/, "$1").replace(/\/+$/, "")).filter(Boolean);
4533
+ }
4534
+ function carRepos(dir, app, fallback = dir) {
4535
+ const found = appRepos(dir, app);
4504
4536
  return found.length ? found : [fallback];
4505
4537
  }
4506
4538
  function checkoutProject(dir) {
@@ -6758,6 +6790,9 @@ export {
6758
6790
  openRefusal,
6759
6791
  projectAppsDir,
6760
6792
  repoRoot,
6793
+ appRepos,
6794
+ appLinkPaths,
6795
+ gitmodulesPaths,
6761
6796
  carRepos,
6762
6797
  checkoutProject,
6763
6798
  TRAIN,
@@ -89,7 +89,7 @@ import {
89
89
  writeBoard,
90
90
  writeJson,
91
91
  writerAlive
92
- } from "./chunk-S2XBGLRM.mjs";
92
+ } from "./chunk-576U3FLU.mjs";
93
93
 
94
94
  // src/server/cli.ts
95
95
  import { existsSync as existsSync2, realpathSync as realpathSync3 } from "node:fs";
@@ -225,7 +225,7 @@ async function runProcs(ctx, flags, { out, err }) {
225
225
 
226
226
  // src/server/traincmds.ts
227
227
  import { existsSync, lstatSync, readdirSync, readFileSync, realpathSync as realpathSync2 } from "node:fs";
228
- import { availableParallelism, loadavg, userInfo } from "node:os";
228
+ import { availableParallelism, devNull, loadavg, userInfo } from "node:os";
229
229
  import { dirname as dirname2, join, resolve as resolve3 } from "node:path";
230
230
  var MAX_INPUT = 256 * 1024;
231
231
  var usage = (io, text) => (io.err(`${text}
@@ -302,7 +302,7 @@ function check(flags, io) {
302
302
  const exists = io.exists ?? ((path) => existsSync(resolve3(cwd, path)));
303
303
  const isAncestor = io.isAncestor ?? ((older, newer2) => repos.some((at) => {
304
304
  try {
305
- execFileSyncExe("git", ["merge-base", "--is-ancestor", older, newer2], { cwd: at, stdio: "ignore", timeout: 15e3, killSignal: "SIGKILL" });
305
+ execFileSyncExe("git", ["--no-replace-objects", "-c", "core.commitGraph=false", "merge-base", "--is-ancestor", older, newer2], { cwd: at, stdio: "ignore", timeout: 15e3, killSignal: "SIGKILL", env: { ...process.env, GIT_GRAFT_FILE: devNull } });
306
306
  return true;
307
307
  } catch {
308
308
  return false;