@desplega.ai/wts 0.1.4 → 0.1.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.
Files changed (2) hide show
  1. package/dist/index.js +29 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1877,7 +1877,7 @@ var {
1877
1877
  // package.json
1878
1878
  var package_default = {
1879
1879
  name: "@desplega.ai/wts",
1880
- version: "0.1.4",
1880
+ version: "0.1.6",
1881
1881
  description: "Git worktree manager with tmux integration",
1882
1882
  type: "module",
1883
1883
  bin: {
@@ -2098,6 +2098,10 @@ async function removeWorktree(path, force = false, cwd) {
2098
2098
  async function pruneWorktrees(cwd) {
2099
2099
  await Bun.$`git worktree prune`.cwd(cwd ?? process.cwd());
2100
2100
  }
2101
+ async function deleteBranch(branch, force = false, cwd) {
2102
+ const flag = force ? "-D" : "-d";
2103
+ await Bun.$`git branch ${flag} ${branch}`.cwd(cwd ?? process.cwd());
2104
+ }
2101
2105
  function generateWorktreePath(baseDir, alias) {
2102
2106
  const dirName = generateWorktreeDirName(alias);
2103
2107
  return join(baseDir, dirName);
@@ -2799,7 +2803,7 @@ async function categorizeWorktrees(worktrees, gitRoot, options) {
2799
2803
  }
2800
2804
  return { merged, unmerged, stale, active };
2801
2805
  }
2802
- var cleanupCommand = new Command2("cleanup").description("Remove merged or stale worktrees").option("--dry-run", "Show what would be removed without removing").option("-f, --force", "Force removal without confirmation").option("--older-than <days>", "Include worktrees older than N days").option("--unmerged", "Include all unmerged worktrees").action(async (options) => {
2806
+ var cleanupCommand = new Command2("cleanup").description("Remove merged or stale worktrees").option("--dry-run", "Show what would be removed without removing").option("-f, --force", "Force removal without confirmation").option("--older-than <days>", "Include worktrees older than N days").option("--unmerged", "Include all unmerged worktrees").option("--delete-branches", "Also delete the associated branches").action(async (options) => {
2803
2807
  const gitRoot = await getGitRoot();
2804
2808
  if (!gitRoot) {
2805
2809
  console.error(source_default.red("Error: Not in a git repository"));
@@ -2851,24 +2855,38 @@ var cleanupCommand = new Command2("cleanup").description("Remove merged or stale
2851
2855
  }
2852
2856
  console.log();
2853
2857
  }
2858
+ if (options.deleteBranches) {
2859
+ console.log(source_default.dim("(branches will also be deleted)"));
2860
+ }
2854
2861
  if (options.dryRun) {
2855
2862
  console.log(source_default.dim("(dry run - no changes made)"));
2856
2863
  return;
2857
2864
  }
2858
2865
  if (!options.force) {
2859
- const shouldProceed = await confirm(`Remove ${toRemove.length} worktree(s)?`, false);
2866
+ const message = options.deleteBranches ? `Remove ${toRemove.length} worktree(s) and their branches?` : `Remove ${toRemove.length} worktree(s)?`;
2867
+ const shouldProceed = await confirm(message, false);
2860
2868
  if (!shouldProceed) {
2861
2869
  console.log(source_default.dim("Cancelled"));
2862
2870
  return;
2863
2871
  }
2864
2872
  }
2865
- let removed = 0;
2873
+ let removedWorktrees = 0;
2874
+ let removedBranches = 0;
2866
2875
  let failed = 0;
2867
2876
  for (const wt of toRemove) {
2868
2877
  try {
2869
2878
  console.log(source_default.dim(`Removing ${wt.alias ?? wt.branch}...`));
2870
2879
  await removeWorktree(wt.path, true, gitRoot);
2871
- removed++;
2880
+ removedWorktrees++;
2881
+ if (options.deleteBranches && wt.branch && wt.branch !== "detached") {
2882
+ try {
2883
+ await deleteBranch(wt.branch, true, gitRoot);
2884
+ removedBranches++;
2885
+ } catch (error) {
2886
+ console.error(source_default.yellow(` Warning: Could not delete branch ${wt.branch}:`));
2887
+ console.error(source_default.dim(` ${error instanceof Error ? error.message : String(error)}`));
2888
+ }
2889
+ }
2872
2890
  } catch (error) {
2873
2891
  console.error(source_default.red(` Failed to remove ${wt.alias ?? wt.branch}:`));
2874
2892
  console.error(source_default.dim(` ${error instanceof Error ? error.message : String(error)}`));
@@ -2876,8 +2894,11 @@ var cleanupCommand = new Command2("cleanup").description("Remove merged or stale
2876
2894
  }
2877
2895
  }
2878
2896
  console.log();
2879
- if (removed > 0) {
2880
- console.log(source_default.green(`Removed ${removed} worktree(s)`));
2897
+ if (removedWorktrees > 0) {
2898
+ console.log(source_default.green(`Removed ${removedWorktrees} worktree(s)`));
2899
+ }
2900
+ if (removedBranches > 0) {
2901
+ console.log(source_default.green(`Deleted ${removedBranches} branch(es)`));
2881
2902
  }
2882
2903
  if (failed > 0) {
2883
2904
  console.log(source_default.red(`Failed to remove ${failed} worktree(s)`));
@@ -3292,7 +3313,7 @@ async function listAllProjects(jsonOutput) {
3292
3313
  }
3293
3314
  function printWorktreeTable(worktrees, projectName) {
3294
3315
  console.log(source_default.bold.blue(`${projectName}`));
3295
- console.log(source_default.dim("".repeat(60)));
3316
+ console.log(source_default.dim("-".repeat(60)));
3296
3317
  if (worktrees.length === 0) {
3297
3318
  console.log(source_default.dim(" No worktrees"));
3298
3319
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@desplega.ai/wts",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Git worktree manager with tmux integration",
5
5
  "type": "module",
6
6
  "bin": {