staklink 0.4.5 → 0.4.6
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 +80 -16
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
package/dist/proxy-server.cjs
CHANGED
|
@@ -60411,6 +60411,23 @@ var Repo = class {
|
|
|
60411
60411
|
log("nowBranch:", nowBranch);
|
|
60412
60412
|
return nowBranch.includes(`* ${base_branch}`);
|
|
60413
60413
|
}
|
|
60414
|
+
async getDefaultBranch() {
|
|
60415
|
+
try {
|
|
60416
|
+
const result = await this.execCommand(
|
|
60417
|
+
`git remote show origin | sed -n '/HEAD branch/s/.*: //p'`
|
|
60418
|
+
);
|
|
60419
|
+
return result.trim();
|
|
60420
|
+
} catch {
|
|
60421
|
+
try {
|
|
60422
|
+
await this.execCommand(
|
|
60423
|
+
"git show-ref --verify --quiet refs/heads/main"
|
|
60424
|
+
);
|
|
60425
|
+
return "main";
|
|
60426
|
+
} catch {
|
|
60427
|
+
return "master";
|
|
60428
|
+
}
|
|
60429
|
+
}
|
|
60430
|
+
}
|
|
60414
60431
|
async checkoutMainBranchOrBaseBranch(base_branch) {
|
|
60415
60432
|
if (base_branch) {
|
|
60416
60433
|
return this.execCommand(`git checkout -f ${base_branch}`);
|
|
@@ -60777,7 +60794,7 @@ var SSEManager = class {
|
|
|
60777
60794
|
var sseManager = new SSEManager();
|
|
60778
60795
|
|
|
60779
60796
|
// src/proxy/version.ts
|
|
60780
|
-
var VERSION = "0.4.
|
|
60797
|
+
var VERSION = "0.4.6";
|
|
60781
60798
|
|
|
60782
60799
|
// node_modules/uuid/dist/esm/stringify.js
|
|
60783
60800
|
var byteToHex = [];
|
|
@@ -141205,37 +141222,42 @@ async function handleBranchDiff(req, res) {
|
|
|
141205
141222
|
try {
|
|
141206
141223
|
const results = [];
|
|
141207
141224
|
const repos = await getReposMaybe();
|
|
141208
|
-
const baseBranch = req.query.base || "main";
|
|
141209
141225
|
for (const r of repos) {
|
|
141210
141226
|
const repo = await NewRepo(r);
|
|
141211
141227
|
const repoName = getRepoNameFromUrl(r);
|
|
141212
141228
|
const currentBranch = (await repo.printCurrentBranch()).trim();
|
|
141213
|
-
|
|
141214
|
-
|
|
141215
|
-
|
|
141216
|
-
|
|
141217
|
-
|
|
141218
|
-
|
|
141219
|
-
} catch {
|
|
141229
|
+
const baseBranch = req.query.base || await repo.getDefaultBranch();
|
|
141230
|
+
const onBaseBranch = currentBranch === baseBranch;
|
|
141231
|
+
let diffBase;
|
|
141232
|
+
if (onBaseBranch) {
|
|
141233
|
+
diffBase = "HEAD";
|
|
141234
|
+
} else {
|
|
141220
141235
|
try {
|
|
141221
|
-
|
|
141236
|
+
diffBase = (await repo.execCommand(`git merge-base ${baseBranch} HEAD`)).trim();
|
|
141222
141237
|
} catch {
|
|
141223
|
-
|
|
141224
|
-
|
|
141225
|
-
|
|
141226
|
-
|
|
141238
|
+
try {
|
|
141239
|
+
diffBase = (await repo.execCommand(
|
|
141240
|
+
`git merge-base origin/${baseBranch} HEAD`
|
|
141241
|
+
)).trim();
|
|
141242
|
+
} catch {
|
|
141243
|
+
warn(
|
|
141244
|
+
`Could not find merge base for ${repoName}, skipping...`
|
|
141245
|
+
);
|
|
141246
|
+
continue;
|
|
141247
|
+
}
|
|
141227
141248
|
}
|
|
141228
141249
|
}
|
|
141229
141250
|
let diffOutput = "";
|
|
141230
141251
|
try {
|
|
141231
141252
|
diffOutput = await repo.execCommand(
|
|
141232
|
-
`git diff --name-status ${
|
|
141253
|
+
`git diff --name-status ${diffBase}`
|
|
141233
141254
|
);
|
|
141234
141255
|
} catch (error88) {
|
|
141235
141256
|
warn(`Error getting branch diff for repo ${repoName}:`, error88);
|
|
141236
141257
|
continue;
|
|
141237
141258
|
}
|
|
141238
141259
|
const lines = diffOutput.trim().split("\n").filter((line) => line);
|
|
141260
|
+
const trackedFiles = /* @__PURE__ */ new Set();
|
|
141239
141261
|
for (const line of lines) {
|
|
141240
141262
|
const parts = line.split(" ");
|
|
141241
141263
|
if (parts.length < 2) {
|
|
@@ -141243,6 +141265,7 @@ async function handleBranchDiff(req, res) {
|
|
|
141243
141265
|
}
|
|
141244
141266
|
const status = parts[0];
|
|
141245
141267
|
const filePath = parts[1];
|
|
141268
|
+
trackedFiles.add(filePath);
|
|
141246
141269
|
let action;
|
|
141247
141270
|
if (status.startsWith("A")) {
|
|
141248
141271
|
action = "create";
|
|
@@ -141258,7 +141281,7 @@ async function handleBranchDiff(req, res) {
|
|
|
141258
141281
|
} else {
|
|
141259
141282
|
try {
|
|
141260
141283
|
content = await repo.execCommand(
|
|
141261
|
-
`git diff ${
|
|
141284
|
+
`git diff ${diffBase} -- "${filePath}"`
|
|
141262
141285
|
);
|
|
141263
141286
|
} catch (error88) {
|
|
141264
141287
|
warn(`Error getting branch diff for ${filePath}:`, error88);
|
|
@@ -141272,6 +141295,47 @@ async function handleBranchDiff(req, res) {
|
|
|
141272
141295
|
errors: []
|
|
141273
141296
|
});
|
|
141274
141297
|
}
|
|
141298
|
+
let untrackedOutput = "";
|
|
141299
|
+
try {
|
|
141300
|
+
untrackedOutput = await repo.execCommand(
|
|
141301
|
+
"git ls-files --others --exclude-standard"
|
|
141302
|
+
);
|
|
141303
|
+
} catch (error88) {
|
|
141304
|
+
warn(
|
|
141305
|
+
`Error getting untracked files for repo ${repoName}:`,
|
|
141306
|
+
error88
|
|
141307
|
+
);
|
|
141308
|
+
}
|
|
141309
|
+
const untrackedLines = untrackedOutput.trim().split("\n").filter((line) => line && !trackedFiles.has(line));
|
|
141310
|
+
for (const filePath of untrackedLines) {
|
|
141311
|
+
let content = "";
|
|
141312
|
+
const binaryContent = await binaryDiffContent(
|
|
141313
|
+
repo,
|
|
141314
|
+
filePath,
|
|
141315
|
+
"create"
|
|
141316
|
+
);
|
|
141317
|
+
if (binaryContent !== null) {
|
|
141318
|
+
content = binaryContent;
|
|
141319
|
+
} else {
|
|
141320
|
+
try {
|
|
141321
|
+
const fileContent = await repo.execCommand(`cat "${filePath}"`);
|
|
141322
|
+
const fileLines = fileContent.split("\n");
|
|
141323
|
+
content = `--- /dev/null
|
|
141324
|
+
+++ b/${filePath}
|
|
141325
|
+
@@ -0,0 +1,${fileLines.length} @@
|
|
141326
|
+
${fileLines.map((line) => "+" + line).join("\n")}`;
|
|
141327
|
+
} catch (error88) {
|
|
141328
|
+
warn(`Error reading untracked file ${filePath}:`, error88);
|
|
141329
|
+
}
|
|
141330
|
+
}
|
|
141331
|
+
results.push({
|
|
141332
|
+
file: `${repoName}/${filePath}`,
|
|
141333
|
+
action: "create",
|
|
141334
|
+
content,
|
|
141335
|
+
repoName,
|
|
141336
|
+
errors: []
|
|
141337
|
+
});
|
|
141338
|
+
}
|
|
141275
141339
|
}
|
|
141276
141340
|
res.status(200).json(results);
|
|
141277
141341
|
} catch (error88) {
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10967,7 +10967,7 @@ var glob = Object.assign(glob_, {
|
|
|
10967
10967
|
glob.glob = glob;
|
|
10968
10968
|
|
|
10969
10969
|
// src/proxy/version.ts
|
|
10970
|
-
var VERSION = "0.4.
|
|
10970
|
+
var VERSION = "0.4.6";
|
|
10971
10971
|
|
|
10972
10972
|
// src/deps.ts
|
|
10973
10973
|
var import_child_process = require("child_process");
|