@gearbox-protocol/deploy-tools 5.49.9 → 5.49.11

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.
Files changed (2) hide show
  1. package/dist/index.mjs +49 -18
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -429514,34 +429514,44 @@ var log_default = logger;
429514
429514
  var log = log_default.child({ name: "git" });
429515
429515
  function getGithubUrl(repo, https = false) {
429516
429516
  const credentials = process.env.GIT_TOKEN ?? process.env.GITHUB_TOKEN ?? process.env.GH_TOKEN;
429517
- log.info({
429518
- GIT_TOKEN: process.env.GIT_TOKEN?.slice(-4) ?? "--",
429519
- GITHUB_TOKEN: process.env.GITHUB_TOKEN?.slice(-4) ?? "--",
429520
- GH_TOKEN: process.env.GH_TOKEN?.slice(-4) ?? "--"
429521
- }, `using git token *****${credentials?.slice(-4)}`);
429517
+ const githubUser = process.env.GITHUB_USER;
429522
429518
  const path12 = repo.replace(/^@/, "").replace(/\/$/, "");
429523
- const cred = credentials ? `${credentials}@` : "";
429524
- return https || credentials ? `https://${cred}github.com/${path12}.git` : `git@github.com:${path12}.git`;
429519
+ let cred = "";
429520
+ if (credentials) {
429521
+ cred = githubUser ? `${githubUser}:${credentials}@` : `${credentials}@`;
429522
+ }
429523
+ const url2 = https || credentials ? `https://${cred}github.com/${path12}.git` : `git@github.com:${path12}.git`;
429524
+ log.info(`github URL: ${url2.replace(/\/\/[^@]+@/, "//***@")}`);
429525
+ return url2;
429525
429526
  }
429526
429527
  async function cloneRepo(opts) {
429527
429528
  const { repo, commit, sandboxDir } = opts;
429528
429529
  const destDir = opts.destDir ?? repo.split("/")[1];
429529
429530
  const repoPath = path.resolve(sandboxDir, destDir);
429531
+ const cloneUrl = getGithubUrl(repo);
429532
+ const clearCreds = ["credential-cache", "exit"];
429533
+ spawnSync("git", clearCreds, { cwd: sandboxDir });
429534
+ const gitConfig = ["config", "--local", "credential.helper", "store"];
429535
+ spawnSync("git", gitConfig, { cwd: sandboxDir });
429530
429536
  if (existsSync(repoPath)) {
429531
429537
  log.trace(`repo ${repoPath} already exists, assuming repo already cloned`);
429532
429538
  if (opts.disablePull) {
429533
429539
  return;
429534
429540
  }
429535
429541
  } else {
429536
- const clone2 = ["clone", getGithubUrl(repo), destDir];
429542
+ const clone2 = ["clone", cloneUrl, destDir];
429537
429543
  log.debug(`cloning ${repo} at ${commit} to ${destDir}`);
429538
- await new Promise((r) => {
429539
- log.flush(r);
429540
- });
429541
429544
  const { stderr, status, error: error46 } = spawnSync("git", clone2, {
429542
- cwd: sandboxDir
429545
+ cwd: sandboxDir,
429546
+ env: {
429547
+ ...process.env,
429548
+ GIT_TERMINAL_PROMPT: "0"
429549
+ // Disable credential prompts
429550
+ }
429543
429551
  });
429544
429552
  if (error46 || status !== 0) {
429553
+ log.error(`Git clone failed with status ${status}: ${stderr?.toString()}`);
429554
+ log.error(`Clone command: git ${clone2.join(" ")}`);
429545
429555
  throw error46 ?? new Error(stderr?.toString());
429546
429556
  }
429547
429557
  log.debug({ clone: clone2 }, "cloned");
@@ -429550,7 +429560,12 @@ async function cloneRepo(opts) {
429550
429560
  const reset2 = ["reset", "--hard", commit, "--"];
429551
429561
  log.trace({ reset: reset2 }, "reset");
429552
429562
  const { stderr, status, error: error46 } = spawnSync("git", reset2, {
429553
- cwd: repoPath
429563
+ cwd: repoPath,
429564
+ env: {
429565
+ ...process.env,
429566
+ GIT_TERMINAL_PROMPT: "0"
429567
+ // Disable credential prompts
429568
+ }
429554
429569
  });
429555
429570
  if (error46 || status !== 0) {
429556
429571
  throw error46 ?? new Error(stderr?.toString());
@@ -429559,13 +429574,23 @@ async function cloneRepo(opts) {
429559
429574
  } else {
429560
429575
  log.trace(`fetching latest from ${repoPath}...`);
429561
429576
  const fetchResult = spawnSync("git", ["fetch", "--all"], {
429562
- cwd: path.resolve(sandboxDir, destDir)
429577
+ cwd: path.resolve(sandboxDir, destDir),
429578
+ env: {
429579
+ ...process.env,
429580
+ GIT_TERMINAL_PROMPT: "0"
429581
+ // Disable credential prompts
429582
+ }
429563
429583
  });
429564
429584
  if (fetchResult.error || fetchResult.status !== 0) {
429565
429585
  throw fetchResult.error ?? new Error(fetchResult.stderr?.toString());
429566
429586
  }
429567
429587
  const currentBranchResult = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
429568
- cwd: path.resolve(sandboxDir, destDir)
429588
+ cwd: path.resolve(sandboxDir, destDir),
429589
+ env: {
429590
+ ...process.env,
429591
+ GIT_TERMINAL_PROMPT: "0"
429592
+ // Disable credential prompts
429593
+ }
429569
429594
  });
429570
429595
  if (currentBranchResult.error || currentBranchResult.status !== 0) {
429571
429596
  throw currentBranchResult.error ?? new Error(currentBranchResult.stderr?.toString());
@@ -429573,7 +429598,12 @@ async function cloneRepo(opts) {
429573
429598
  const currentBranch = currentBranchResult.stdout.toString().trim();
429574
429599
  log.trace(`resetting ${repoPath} to latest commit in origin/${currentBranch}...`);
429575
429600
  const resetResult = spawnSync("git", ["reset", "--hard", `origin/${currentBranch}`], {
429576
- cwd: path.resolve(sandboxDir, destDir)
429601
+ cwd: path.resolve(sandboxDir, destDir),
429602
+ env: {
429603
+ ...process.env,
429604
+ GIT_TERMINAL_PROMPT: "0"
429605
+ // Disable credential prompts
429606
+ }
429577
429607
  });
429578
429608
  if (resetResult.error || resetResult.status !== 0) {
429579
429609
  throw resetResult.error ?? new Error(resetResult.stderr?.toString());
@@ -453189,7 +453219,8 @@ var MetaRepo = class {
453189
453219
  this.#logger.debug({
453190
453220
  GIT_TOKEN: process.env.GIT_TOKEN?.slice(-4) ?? "--",
453191
453221
  GITHUB_TOKEN: process.env.GITHUB_TOKEN?.slice(-4) ?? "--",
453192
- GH_TOKEN: process.env.GH_TOKEN?.slice(-4) ?? "--"
453222
+ GH_TOKEN: process.env.GH_TOKEN?.slice(-4) ?? "--",
453223
+ GITHUB_USER: process.env.GITHUB_USER ?? "--"
453193
453224
  }, "loading metadata from github repo");
453194
453225
  mkdirSync4(this.#dir, { recursive: true });
453195
453226
  await cloneRepo({
@@ -458772,7 +458803,7 @@ function getRenderer(opts) {
458772
458803
  var package_default = {
458773
458804
  name: "@gearbox-protocol/deploy-tools",
458774
458805
  description: "Gearbox deploy tools",
458775
- version: "5.49.9",
458806
+ version: "5.49.11",
458776
458807
  homepage: "https://gearbox.fi",
458777
458808
  keywords: [
458778
458809
  "gearbox"
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "5.49.9",
4
+ "version": "5.49.11",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"