staklink 0.3.15 → 0.3.17
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/proxy-server.cjs +55 -25
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -33610,11 +33610,15 @@ var Repo = class {
|
|
|
33610
33610
|
}
|
|
33611
33611
|
async branchExists(branch) {
|
|
33612
33612
|
try {
|
|
33613
|
-
const localCheck = await this.execCommand(
|
|
33613
|
+
const localCheck = await this.execCommand(
|
|
33614
|
+
`git show-ref --verify --quiet refs/heads/${branch}`
|
|
33615
|
+
).catch(() => null);
|
|
33614
33616
|
if (localCheck !== null) {
|
|
33615
33617
|
return true;
|
|
33616
33618
|
}
|
|
33617
|
-
const remoteCheck = await this.execCommand(
|
|
33619
|
+
const remoteCheck = await this.execCommand(
|
|
33620
|
+
`git ls-remote --heads origin ${branch}`
|
|
33621
|
+
).catch(() => "");
|
|
33618
33622
|
return remoteCheck.trim().length > 0;
|
|
33619
33623
|
} catch (e) {
|
|
33620
33624
|
return false;
|
|
@@ -33635,6 +33639,9 @@ var Repo = class {
|
|
|
33635
33639
|
}
|
|
33636
33640
|
return branchName;
|
|
33637
33641
|
}
|
|
33642
|
+
async checkout(branch) {
|
|
33643
|
+
return this.execCommand(`git checkout ${branch}`);
|
|
33644
|
+
}
|
|
33638
33645
|
async checkoutNew(branch) {
|
|
33639
33646
|
return this.execCommand(`git checkout -b ${branch}`);
|
|
33640
33647
|
}
|
|
@@ -33928,7 +33935,7 @@ var SSEManager = class {
|
|
|
33928
33935
|
var sseManager = new SSEManager();
|
|
33929
33936
|
|
|
33930
33937
|
// src/proxy/version.ts
|
|
33931
|
-
var VERSION = "0.3.
|
|
33938
|
+
var VERSION = "0.3.17";
|
|
33932
33939
|
|
|
33933
33940
|
// node_modules/uuid/dist/esm/stringify.js
|
|
33934
33941
|
var byteToHex = [];
|
|
@@ -80323,6 +80330,7 @@ async function startProxyServer() {
|
|
|
80323
80330
|
const shouldCommit = req.query.commit === "true";
|
|
80324
80331
|
const commits = [];
|
|
80325
80332
|
const prs = {};
|
|
80333
|
+
const branches = {};
|
|
80326
80334
|
console.log(`=> Commit requested: ${shouldCommit}`);
|
|
80327
80335
|
console.log(`=> PR creation requested: ${createPR}`);
|
|
80328
80336
|
console.log(
|
|
@@ -80332,28 +80340,50 @@ async function startProxyServer() {
|
|
|
80332
80340
|
const repo = await NewRepo(r.url);
|
|
80333
80341
|
const repoName = getRepoNameFromUrl(r.url);
|
|
80334
80342
|
const stashCreated = await repo.stashDevcontainer();
|
|
80343
|
+
const requestedBranch = await repo.generateUniqueBranchName(r.branch_name);
|
|
80344
|
+
let currentBranch = (await repo.printCurrentBranch()).trim();
|
|
80345
|
+
console.log(`=> Current branch: ${currentBranch}`);
|
|
80346
|
+
console.log(`=> Requested branch: ${requestedBranch}`);
|
|
80347
|
+
if (currentBranch !== requestedBranch) {
|
|
80348
|
+
const branchExists = await repo.branchExists(requestedBranch);
|
|
80349
|
+
if (branchExists) {
|
|
80350
|
+
console.log(`=> Switching to existing branch: ${requestedBranch}`);
|
|
80351
|
+
await repo.checkout(requestedBranch);
|
|
80352
|
+
} else {
|
|
80353
|
+
console.log(`=> Creating new branch from current position: ${requestedBranch}`);
|
|
80354
|
+
await repo.checkoutNew(requestedBranch);
|
|
80355
|
+
}
|
|
80356
|
+
} else {
|
|
80357
|
+
console.log(`=> Already on correct branch: ${requestedBranch}`);
|
|
80358
|
+
}
|
|
80335
80359
|
if (shouldCommit) {
|
|
80336
80360
|
console.log(`=> COMMIT to ${r.url}`);
|
|
80337
80361
|
console.log(`=> COMMIT in ${repo.printcwd()}`);
|
|
80338
|
-
const
|
|
80339
|
-
|
|
80340
|
-
|
|
80341
|
-
|
|
80342
|
-
|
|
80343
|
-
|
|
80344
|
-
|
|
80345
|
-
|
|
80346
|
-
|
|
80362
|
+
const status = await repo.execCommand("git status --porcelain");
|
|
80363
|
+
if (status.trim()) {
|
|
80364
|
+
console.log(`=> Found uncommitted changes, committing...`);
|
|
80365
|
+
await repo.addAll();
|
|
80366
|
+
currentBranch = (await repo.printCurrentBranch()).trim();
|
|
80367
|
+
console.log(`=> COMMIT to ${r.url} on branch: ${currentBranch}`);
|
|
80368
|
+
await repo.commitWithCredentials(
|
|
80369
|
+
r.commit_name,
|
|
80370
|
+
code.git_credentials
|
|
80371
|
+
);
|
|
80372
|
+
console.log(`=> Commit successful`);
|
|
80373
|
+
} else {
|
|
80374
|
+
console.log(
|
|
80375
|
+
`=> No uncommitted changes, skipping commit (may have been committed by agent)`
|
|
80376
|
+
);
|
|
80347
80377
|
}
|
|
80348
|
-
await repo.addAll();
|
|
80349
|
-
const currentBranch = (await repo.printCurrentBranch()).trim();
|
|
80350
|
-
console.log(`=> COMMIT to ${r.url} on branch: ${currentBranch}`);
|
|
80351
|
-
await repo.commitWithCredentials(r.commit_name, code.git_credentials);
|
|
80352
80378
|
}
|
|
80353
80379
|
console.log(`=> PUSH to ${r.url}`);
|
|
80354
80380
|
await repo.pushCurrentBranchWithCredentials(code.git_credentials);
|
|
80381
|
+
console.log(`=> Push successful`);
|
|
80355
80382
|
const link = await repo.getLatestCommitLink();
|
|
80356
80383
|
commits.push(link);
|
|
80384
|
+
currentBranch = (await repo.printCurrentBranch()).trim();
|
|
80385
|
+
branches[repoName] = currentBranch;
|
|
80386
|
+
console.log(`=> Branch for ${repoName}: ${currentBranch}`);
|
|
80357
80387
|
if (stashCreated) {
|
|
80358
80388
|
await repo.popDevcontainerStash();
|
|
80359
80389
|
}
|
|
@@ -80372,10 +80402,10 @@ async function startProxyServer() {
|
|
|
80372
80402
|
const currentBranchRaw = await repo.execCommand(
|
|
80373
80403
|
"git rev-parse --abbrev-ref HEAD"
|
|
80374
80404
|
);
|
|
80375
|
-
const
|
|
80376
|
-
console.log(`=> Current branch: ${
|
|
80405
|
+
const currentBranch2 = currentBranchRaw.trim();
|
|
80406
|
+
console.log(`=> Current branch: ${currentBranch2}`);
|
|
80377
80407
|
const baseBranch = r.base_branch || "main";
|
|
80378
|
-
if (
|
|
80408
|
+
if (currentBranch2 === baseBranch) {
|
|
80379
80409
|
console.log(
|
|
80380
80410
|
`=> Cannot create PR: currently on base branch (${baseBranch})`
|
|
80381
80411
|
);
|
|
@@ -80388,9 +80418,9 @@ async function startProxyServer() {
|
|
|
80388
80418
|
);
|
|
80389
80419
|
if (!diff.trim()) {
|
|
80390
80420
|
console.log(
|
|
80391
|
-
`=> No commits between ${baseBranch} and ${
|
|
80421
|
+
`=> No commits between ${baseBranch} and ${currentBranch2}`
|
|
80392
80422
|
);
|
|
80393
|
-
prs[repoName] = `Error: No commits to create PR - ${
|
|
80423
|
+
prs[repoName] = `Error: No commits to create PR - ${currentBranch2} is up to date with ${baseBranch}`;
|
|
80394
80424
|
continue;
|
|
80395
80425
|
}
|
|
80396
80426
|
console.log(`=> Commits to include in PR:
|
|
@@ -80402,7 +80432,7 @@ ${diff.trim()}`);
|
|
|
80402
80432
|
await new Promise((resolve3) => setTimeout(resolve3, 2e3));
|
|
80403
80433
|
const gh = new GitHubCLI(
|
|
80404
80434
|
code.git_credentials.auth_data.token,
|
|
80405
|
-
|
|
80435
|
+
currentBranch2,
|
|
80406
80436
|
repoLocation
|
|
80407
80437
|
);
|
|
80408
80438
|
await gh.init();
|
|
@@ -80412,8 +80442,8 @@ ${diff.trim()}`);
|
|
|
80412
80442
|
prs[repoName] = existingPR.url;
|
|
80413
80443
|
} else {
|
|
80414
80444
|
const pr = await gh.createPR({
|
|
80415
|
-
title: r.commit_name || `Changes from ${
|
|
80416
|
-
body: `Automated PR from branch ${
|
|
80445
|
+
title: r.commit_name || `Changes from ${currentBranch2}`,
|
|
80446
|
+
body: `Automated PR from branch ${currentBranch2}`,
|
|
80417
80447
|
base: baseBranch,
|
|
80418
80448
|
draft: false
|
|
80419
80449
|
});
|
|
@@ -80427,7 +80457,7 @@ ${diff.trim()}`);
|
|
|
80427
80457
|
}
|
|
80428
80458
|
}
|
|
80429
80459
|
}
|
|
80430
|
-
const response = { success: true, commits };
|
|
80460
|
+
const response = { success: true, commits, branches };
|
|
80431
80461
|
if (createPR) {
|
|
80432
80462
|
response.prs = prs;
|
|
80433
80463
|
}
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10905,7 +10905,7 @@ var glob = Object.assign(glob_, {
|
|
|
10905
10905
|
glob.glob = glob;
|
|
10906
10906
|
|
|
10907
10907
|
// src/proxy/version.ts
|
|
10908
|
-
var VERSION = "0.3.
|
|
10908
|
+
var VERSION = "0.3.17";
|
|
10909
10909
|
|
|
10910
10910
|
// src/cli.ts
|
|
10911
10911
|
var STAKLINK_PROXY = "staklink-proxy";
|