bosun 0.34.2 → 0.34.4

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.
@@ -22,10 +22,19 @@
22
22
 
23
23
  import { existsSync, mkdirSync, readFileSync, writeFileSync, rmSync, readdirSync, statSync } from "node:fs";
24
24
  import { resolve, basename, join } from "node:path";
25
- import { execSync, spawnSync } from "node:child_process";
25
+ import { createRequire } from "node:module";
26
26
 
27
27
  const TAG = "[workspace-manager]";
28
28
 
29
+ const _childProcessRequire = createRequire(import.meta.url);
30
+ let _childProcessModule = null;
31
+ function getChildProcess() {
32
+ if (!_childProcessModule) {
33
+ _childProcessModule = _childProcessRequire("node:child_process");
34
+ }
35
+ return _childProcessModule;
36
+ }
37
+
29
38
  // Lazy-loaded reference to repo-config.mjs (resolved on first use)
30
39
  let _repoConfigModule = null;
31
40
 
@@ -345,6 +354,7 @@ export function addRepoToWorkspace(configDir, workspaceId, { url, name, branch,
345
354
 
346
355
  const wsPath = getWorkspacePath(configDir, wsId);
347
356
  const repoPath = resolve(wsPath, repoName);
357
+ const childProcess = getChildProcess();
348
358
  let cloned = false;
349
359
 
350
360
  if (!existsSync(repoPath)) {
@@ -354,7 +364,7 @@ export function addRepoToWorkspace(configDir, workspaceId, { url, name, branch,
354
364
  if (branch) cloneArgs.push("--branch", branch);
355
365
  cloneArgs.push(url, repoPath);
356
366
 
357
- const result = spawnSync("git", cloneArgs, {
367
+ const result = childProcess.spawnSync("git", cloneArgs, {
358
368
  encoding: "utf8",
359
369
  timeout: 300000, // 5 minutes
360
370
  stdio: ["pipe", "pipe", "pipe"],
@@ -463,6 +473,7 @@ export function setActiveRepo(configDir, workspaceId, repoName) {
463
473
  export function pullWorkspaceRepos(configDir, workspaceId) {
464
474
  const ws = getWorkspace(configDir, workspaceId);
465
475
  if (!ws) throw new Error(`Workspace "${workspaceId}" not found`);
476
+ const childProcess = getChildProcess();
466
477
 
467
478
  const results = [];
468
479
  for (const repo of ws.repos || []) {
@@ -482,7 +493,7 @@ export function pullWorkspaceRepos(configDir, workspaceId) {
482
493
  try {
483
494
  mkdirSync(ws.path, { recursive: true });
484
495
  console.log(TAG, `Cloning ${repoUrl} into ${repoPath}...`);
485
- const clone = spawnSync("git", ["clone", repoUrl, repoPath], {
496
+ const clone = childProcess.spawnSync("git", ["clone", repoUrl, repoPath], {
486
497
  encoding: "utf8",
487
498
  timeout: 300000,
488
499
  stdio: ["pipe", "pipe", "pipe"],
@@ -529,7 +540,7 @@ export function pullWorkspaceRepos(configDir, workspaceId) {
529
540
  (repo.slug ? `https://github.com/${repo.slug.replace(/\.git$/i, "")}.git` : "");
530
541
  if (isEmpty && repoUrl) {
531
542
  console.log(TAG, `Cloning ${repoUrl} into existing empty directory ${repoPath}...`);
532
- const clone = spawnSync("git", ["clone", repoUrl, "."], {
543
+ const clone = childProcess.spawnSync("git", ["clone", repoUrl, "."], {
533
544
  encoding: "utf8",
534
545
  timeout: 300000,
535
546
  stdio: ["pipe", "pipe", "pipe"],
@@ -562,7 +573,7 @@ export function pullWorkspaceRepos(configDir, workspaceId) {
562
573
  }
563
574
  }
564
575
  try {
565
- execSync("git pull --rebase", {
576
+ childProcess.execSync("git pull --rebase", {
566
577
  cwd: repoPath,
567
578
  encoding: "utf8",
568
579
  timeout: 120000,
@@ -697,6 +708,7 @@ export function detectWorkspaces(configDir) {
697
708
  if (!existsSync(wsDir)) return [];
698
709
 
699
710
  const detected = [];
711
+ const childProcess = getChildProcess();
700
712
  for (const entry of readdirSync(wsDir)) {
701
713
  const entryPath = resolve(wsDir, entry);
702
714
  if (!statSync(entryPath).isDirectory()) continue;
@@ -708,7 +720,7 @@ export function detectWorkspaces(configDir) {
708
720
  if (existsSync(resolve(subPath, ".git"))) {
709
721
  let slug = "";
710
722
  try {
711
- const remote = execSync("git remote get-url origin", {
723
+ const remote = childProcess.execSync("git remote get-url origin", {
712
724
  cwd: subPath,
713
725
  encoding: "utf8",
714
726
  stdio: ["pipe", "pipe", "ignore"],