staklink 0.3.21 → 0.3.22

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/README.md CHANGED
@@ -8,6 +8,16 @@ VSCode extension for automating development and debugging in Codespaces.
8
8
 
9
9
  npx -y staklink@latest start
10
10
 
11
+ ### local cli testing
12
+
13
+ pm2 stop all
14
+ pm2 delete all
15
+
16
+ yarn build:cli
17
+ yarn build:proxy
18
+
19
+ node bin/staklink.cjs start
20
+
11
21
  ## processes
12
22
 
13
23
  There are 2 ways to configure your dev processes (like your backend, frontend, db, etc)
@@ -26614,8 +26614,25 @@ async function dirExists(dirPath) {
26614
26614
  }
26615
26615
  async function getReposMaybe() {
26616
26616
  const root = await workspaceRoot();
26617
+ const rootGitPath = path3.join(root, ".git");
26618
+ const isRootGitRepo = await dirExists(rootGitPath);
26619
+ if (isRootGitRepo) {
26620
+ return [root];
26621
+ }
26617
26622
  const children = await getChildDirectories(root);
26618
- return children.filter((dir) => !dir.startsWith("."));
26623
+ const gitRepos = [];
26624
+ for (const child of children) {
26625
+ if (child.startsWith(".")) {
26626
+ continue;
26627
+ }
26628
+ const childPath = path3.join(root, child);
26629
+ const childGitPath = path3.join(childPath, ".git");
26630
+ const isGitRepo = await dirExists(childGitPath);
26631
+ if (isGitRepo) {
26632
+ gitRepos.push(child);
26633
+ }
26634
+ }
26635
+ return gitRepos;
26619
26636
  }
26620
26637
  async function getAppsPortAndLabel() {
26621
26638
  const root = await workspaceRoot();
@@ -26648,6 +26665,9 @@ async function getChildDirectories(dirPath) {
26648
26665
  // src/proxy/utils.ts
26649
26666
  async function findRepoLocation(repoFullName) {
26650
26667
  try {
26668
+ if (repoFullName.startsWith("/") && await dirExists(repoFullName)) {
26669
+ return repoFullName;
26670
+ }
26651
26671
  const repoName = repoFullName.split("/").pop() || "";
26652
26672
  const repodir1 = `/workspaces/${repoName}`;
26653
26673
  if (await dirExists(repodir1)) {
@@ -33882,6 +33902,13 @@ var Repo = class {
33882
33902
  }
33883
33903
  };
33884
33904
  async function NewRepo(url3) {
33905
+ if (url3.startsWith("/")) {
33906
+ const repoLocation2 = await findRepoLocation(url3);
33907
+ if (!repoLocation2) {
33908
+ throw new Error(`Repository not found for ${url3}`);
33909
+ }
33910
+ return new Repo(repoLocation2);
33911
+ }
33885
33912
  const repoName = getRepoNameFromUrl(url3);
33886
33913
  const repoLocation = await findRepoLocation(repoName);
33887
33914
  if (!repoLocation) {
@@ -33935,7 +33962,7 @@ var SSEManager = class {
33935
33962
  var sseManager = new SSEManager();
33936
33963
 
33937
33964
  // src/proxy/version.ts
33938
- var VERSION = "0.3.21";
33965
+ var VERSION = "0.3.22";
33939
33966
 
33940
33967
  // node_modules/uuid/dist/esm/stringify.js
33941
33968
  var byteToHex = [];
@@ -80249,6 +80276,7 @@ async function startProxyServer() {
80249
80276
  for (const r of repos) {
80250
80277
  const repo = await NewRepo(r);
80251
80278
  const repoName = getRepoNameFromUrl(r);
80279
+ const stashCreated = await repo.stashDevcontainer();
80252
80280
  const diffOutput = await repo.execCommand(
80253
80281
  "git diff --name-status HEAD"
80254
80282
  );
@@ -80315,6 +80343,9 @@ ${lines2.map((line) => "+" + line).join("\n")}`;
80315
80343
  errors: []
80316
80344
  });
80317
80345
  }
80346
+ if (stashCreated) {
80347
+ await repo.popDevcontainerStash();
80348
+ }
80318
80349
  }
80319
80350
  res.status(200).json(results);
80320
80351
  } catch (error82) {
@@ -80369,6 +80400,7 @@ ${lines2.map((line) => "+" + line).join("\n")}`;
80369
80400
  const createPR = req.query.pr === "true";
80370
80401
  const shouldCommit = req.query.commit === "true";
80371
80402
  const autoMerge = req.query.automerge === "true";
80403
+ const stayOnCurrentBranch = req.query.stayOnCurrentBranch === "true";
80372
80404
  const commits = [];
80373
80405
  const prs = {};
80374
80406
  const branches = {};
@@ -80382,17 +80414,22 @@ ${lines2.map((line) => "+" + line).join("\n")}`;
80382
80414
  const repo = await NewRepo(r.url);
80383
80415
  const repoName = getRepoNameFromUrl(r.url);
80384
80416
  const stashCreated = await repo.stashDevcontainer();
80385
- const requestedBranch = await repo.generateUniqueBranchName(r.branch_name);
80386
80417
  let currentBranch = (await repo.printCurrentBranch()).trim();
80418
+ const requestedBranch = stayOnCurrentBranch ? currentBranch : await repo.generateUniqueBranchName(r.branch_name);
80387
80419
  console.log(`=> Current branch: ${currentBranch}`);
80388
80420
  console.log(`=> Requested branch: ${requestedBranch}`);
80389
- if (currentBranch !== requestedBranch) {
80421
+ const protectedBranches = ["main", "master"];
80422
+ const isOnProtectedBranch = protectedBranches.includes(currentBranch);
80423
+ const shouldSwitchBranch = (!stayOnCurrentBranch || isOnProtectedBranch) && currentBranch !== requestedBranch;
80424
+ if (shouldSwitchBranch) {
80390
80425
  const branchExists = await repo.branchExists(requestedBranch);
80391
80426
  if (branchExists) {
80392
80427
  console.log(`=> Switching to existing branch: ${requestedBranch}`);
80393
80428
  await repo.checkout(requestedBranch);
80394
80429
  } else {
80395
- console.log(`=> Creating new branch from current position: ${requestedBranch}`);
80430
+ console.log(
80431
+ `=> Creating new branch from current position: ${requestedBranch}`
80432
+ );
80396
80433
  await repo.checkoutNew(requestedBranch);
80397
80434
  }
80398
80435
  } else {
@@ -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.21";
10908
+ var VERSION = "0.3.22";
10909
10909
 
10910
10910
  // src/cli.ts
10911
10911
  var STAKLINK_PROXY = "staklink-proxy";
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "staklink",
3
3
  "displayName": "staklink",
4
4
  "description": "staklink process manager",
5
- "version": "0.3.21",
5
+ "version": "0.3.22",
6
6
  "type": "module",
7
7
  "publisher": "stakwork",
8
8
  "engines": {