Skip to content

Commit 32ed8ba

Browse files
committed
fix: crash-safe version restore and explicit git pull branch
- Wrap npm pack calls in try/finally so package.json versions are always restored even if packing fails - Use git pull origin main instead of bare git pull
1 parent 1055ac4 commit 32ed8ba

1 file changed

Lines changed: 13 additions & 7 deletions

File tree

scripts/bundle.mjs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ function resolveCdkPath() {
6666

6767
if (fs.existsSync(cloneDir)) {
6868
log('Pulling latest changes...');
69-
run('git pull', { cwd: cloneDir });
69+
run('git pull origin main', { cwd: cloneDir });
7070
} else {
7171
run(`git clone --depth 1 ${CDK_REPO_URL} ${cloneDir}`);
7272
}
@@ -113,9 +113,12 @@ run('npm run build', { cwd: cdkPath });
113113

114114
// Step 2: Bump CDK version and pack into a tarball
115115
const cdkVersionInfo = bumpVersion(cdkPath);
116-
log('Packing CDK constructs...');
117-
run('npm pack', { cwd: cdkPath });
118-
restoreVersion(cdkVersionInfo);
116+
try {
117+
log('Packing CDK constructs...');
118+
run('npm pack', { cwd: cdkPath });
119+
} finally {
120+
restoreVersion(cdkVersionInfo);
121+
}
119122

120123
const cdkTarballName = `aws-agentcore-cdk-${cdkVersionInfo.bumpedVersion}.tgz`;
121124
const cdkTarballSrc = path.join(cdkPath, cdkTarballName);
@@ -139,9 +142,12 @@ log(`Placed CDK tarball at ${bundledTarballDest}`);
139142

140143
// Step 5: Bump CLI version and pack into final tarball (includes the bundled CDK tarball)
141144
const cliVersionInfo = bumpVersion(cliRoot);
142-
log('Packing CLI tarball...');
143-
run('npm pack', { cwd: cliRoot });
144-
restoreVersion(cliVersionInfo);
145+
try {
146+
log('Packing CLI tarball...');
147+
run('npm pack', { cwd: cliRoot });
148+
} finally {
149+
restoreVersion(cliVersionInfo);
150+
}
145151

146152
const cliTarballName = `aws-agentcore-${cliVersionInfo.bumpedVersion}.tgz`;
147153
const cliTarballPath = path.join(cliRoot, cliTarballName);

0 commit comments

Comments
 (0)