@gearbox-protocol/deploy-tools 5.49.10 → 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.
- package/dist/index.mjs +39 -16
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -429515,40 +429515,43 @@ 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
429517
|
const githubUser = process.env.GITHUB_USER;
|
|
429518
|
-
log.info({
|
|
429519
|
-
GIT_TOKEN: process.env.GIT_TOKEN?.slice(-4) ?? "--",
|
|
429520
|
-
GITHUB_TOKEN: process.env.GITHUB_TOKEN?.slice(-4) ?? "--",
|
|
429521
|
-
GH_TOKEN: process.env.GH_TOKEN?.slice(-4) ?? "--",
|
|
429522
|
-
GITHUB_USER: githubUser ?? "--"
|
|
429523
|
-
}, `using git token *****${credentials?.slice(-4)}`);
|
|
429524
429518
|
const path12 = repo.replace(/^@/, "").replace(/\/$/, "");
|
|
429525
429519
|
let cred = "";
|
|
429526
429520
|
if (credentials) {
|
|
429527
429521
|
cred = githubUser ? `${githubUser}:${credentials}@` : `${credentials}@`;
|
|
429528
429522
|
}
|
|
429529
429523
|
const url2 = https || credentials ? `https://${cred}github.com/${path12}.git` : `git@github.com:${path12}.git`;
|
|
429524
|
+
log.info(`github URL: ${url2.replace(/\/\/[^@]+@/, "//***@")}`);
|
|
429530
429525
|
return url2;
|
|
429531
429526
|
}
|
|
429532
429527
|
async function cloneRepo(opts) {
|
|
429533
429528
|
const { repo, commit, sandboxDir } = opts;
|
|
429534
429529
|
const destDir = opts.destDir ?? repo.split("/")[1];
|
|
429535
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 });
|
|
429536
429536
|
if (existsSync(repoPath)) {
|
|
429537
429537
|
log.trace(`repo ${repoPath} already exists, assuming repo already cloned`);
|
|
429538
429538
|
if (opts.disablePull) {
|
|
429539
429539
|
return;
|
|
429540
429540
|
}
|
|
429541
429541
|
} else {
|
|
429542
|
-
const clone2 = ["clone",
|
|
429542
|
+
const clone2 = ["clone", cloneUrl, destDir];
|
|
429543
429543
|
log.debug(`cloning ${repo} at ${commit} to ${destDir}`);
|
|
429544
|
-
await new Promise((r) => {
|
|
429545
|
-
log.flush(r);
|
|
429546
|
-
});
|
|
429547
429544
|
const { stderr, status, error: error46 } = spawnSync("git", clone2, {
|
|
429548
|
-
cwd: sandboxDir
|
|
429545
|
+
cwd: sandboxDir,
|
|
429546
|
+
env: {
|
|
429547
|
+
...process.env,
|
|
429548
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
429549
|
+
// Disable credential prompts
|
|
429550
|
+
}
|
|
429549
429551
|
});
|
|
429550
429552
|
if (error46 || status !== 0) {
|
|
429551
429553
|
log.error(`Git clone failed with status ${status}: ${stderr?.toString()}`);
|
|
429554
|
+
log.error(`Clone command: git ${clone2.join(" ")}`);
|
|
429552
429555
|
throw error46 ?? new Error(stderr?.toString());
|
|
429553
429556
|
}
|
|
429554
429557
|
log.debug({ clone: clone2 }, "cloned");
|
|
@@ -429557,7 +429560,12 @@ async function cloneRepo(opts) {
|
|
|
429557
429560
|
const reset2 = ["reset", "--hard", commit, "--"];
|
|
429558
429561
|
log.trace({ reset: reset2 }, "reset");
|
|
429559
429562
|
const { stderr, status, error: error46 } = spawnSync("git", reset2, {
|
|
429560
|
-
cwd: repoPath
|
|
429563
|
+
cwd: repoPath,
|
|
429564
|
+
env: {
|
|
429565
|
+
...process.env,
|
|
429566
|
+
GIT_TERMINAL_PROMPT: "0"
|
|
429567
|
+
// Disable credential prompts
|
|
429568
|
+
}
|
|
429561
429569
|
});
|
|
429562
429570
|
if (error46 || status !== 0) {
|
|
429563
429571
|
throw error46 ?? new Error(stderr?.toString());
|
|
@@ -429566,13 +429574,23 @@ async function cloneRepo(opts) {
|
|
|
429566
429574
|
} else {
|
|
429567
429575
|
log.trace(`fetching latest from ${repoPath}...`);
|
|
429568
429576
|
const fetchResult = spawnSync("git", ["fetch", "--all"], {
|
|
429569
|
-
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
|
+
}
|
|
429570
429583
|
});
|
|
429571
429584
|
if (fetchResult.error || fetchResult.status !== 0) {
|
|
429572
429585
|
throw fetchResult.error ?? new Error(fetchResult.stderr?.toString());
|
|
429573
429586
|
}
|
|
429574
429587
|
const currentBranchResult = spawnSync("git", ["rev-parse", "--abbrev-ref", "HEAD"], {
|
|
429575
|
-
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
|
+
}
|
|
429576
429594
|
});
|
|
429577
429595
|
if (currentBranchResult.error || currentBranchResult.status !== 0) {
|
|
429578
429596
|
throw currentBranchResult.error ?? new Error(currentBranchResult.stderr?.toString());
|
|
@@ -429580,7 +429598,12 @@ async function cloneRepo(opts) {
|
|
|
429580
429598
|
const currentBranch = currentBranchResult.stdout.toString().trim();
|
|
429581
429599
|
log.trace(`resetting ${repoPath} to latest commit in origin/${currentBranch}...`);
|
|
429582
429600
|
const resetResult = spawnSync("git", ["reset", "--hard", `origin/${currentBranch}`], {
|
|
429583
|
-
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
|
+
}
|
|
429584
429607
|
});
|
|
429585
429608
|
if (resetResult.error || resetResult.status !== 0) {
|
|
429586
429609
|
throw resetResult.error ?? new Error(resetResult.stderr?.toString());
|
|
@@ -458780,7 +458803,7 @@ function getRenderer(opts) {
|
|
|
458780
458803
|
var package_default = {
|
|
458781
458804
|
name: "@gearbox-protocol/deploy-tools",
|
|
458782
458805
|
description: "Gearbox deploy tools",
|
|
458783
|
-
version: "5.49.
|
|
458806
|
+
version: "5.49.11",
|
|
458784
458807
|
homepage: "https://gearbox.fi",
|
|
458785
458808
|
keywords: [
|
|
458786
458809
|
"gearbox"
|