@paleo/worktree-env 0.3.0 → 0.4.0

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/cli.d.ts CHANGED
@@ -2,11 +2,11 @@ export interface SetupArgs {
2
2
  help?: boolean;
3
3
  use?: string;
4
4
  create?: string;
5
- self?: boolean;
5
+ here?: boolean;
6
6
  owner?: string;
7
7
  "set-owner"?: string;
8
8
  remove?: string;
9
- "remove-self"?: boolean;
9
+ "remove-here"?: boolean;
10
10
  "no-remote-check"?: boolean;
11
11
  slot?: string;
12
12
  force?: boolean;
package/dist/cli.js CHANGED
@@ -12,7 +12,7 @@ const SETUP_OPTIONS = {
12
12
  arg: "branch",
13
13
  description: "Create a new branch + worktree, then set up the local environment. If the branch already exists, appends a numeric suffix (-2, -3, ...)",
14
14
  },
15
- self: {
15
+ here: {
16
16
  type: "boolean",
17
17
  description: "Set up the local environment in the current linked worktree",
18
18
  },
@@ -31,13 +31,13 @@ const SETUP_OPTIONS = {
31
31
  arg: "branch",
32
32
  description: "Remove a worktree by branch name (stop dev server, free slot, delete directory)",
33
33
  },
34
- "remove-self": {
34
+ "remove-here": {
35
35
  type: "boolean",
36
36
  description: "Remove the current linked worktree (same as --remove, but for the worktree you are in)",
37
37
  },
38
38
  "no-remote-check": {
39
39
  type: "boolean",
40
- description: "Skip remote branch verification when removing (use with --remove or --remove-self)",
40
+ description: "Skip remote branch verification when removing (use with --remove or --remove-here)",
41
41
  },
42
42
  slot: {
43
43
  type: "string",
@@ -87,10 +87,10 @@ export function printDevServerHelp() {
87
87
  console.log(formatHelp("dev-server [options]", "Start, stop, or list background dev-server processes.", DEV_SERVER_OPTIONS));
88
88
  }
89
89
  export function isSetupMode(args) {
90
- return args.use !== undefined || args.create !== undefined || Boolean(args.self);
90
+ return args.use !== undefined || args.create !== undefined || Boolean(args.here);
91
91
  }
92
92
  export function isRemoveMode(args) {
93
- return args.remove !== undefined || Boolean(args["remove-self"]);
93
+ return args.remove !== undefined || Boolean(args["remove-here"]);
94
94
  }
95
95
  export function isSetOwnerMode(args) {
96
96
  return args["set-owner"] !== undefined;
@@ -99,24 +99,24 @@ export function validateSetupFlags(args) {
99
99
  const modeFlags = [
100
100
  args.use,
101
101
  args.create,
102
- args.self,
102
+ args.here,
103
103
  isRemoveMode(args),
104
104
  isSetOwnerMode(args),
105
105
  ].filter(Boolean);
106
106
  if (modeFlags.length > 1) {
107
- throw new ConfigError("Error: --use, --create, --self, --remove, --remove-self, and --set-owner are mutually exclusive.");
107
+ throw new ConfigError("Error: --use, --create, --here, --remove, --remove-here, and --set-owner are mutually exclusive.");
108
108
  }
109
- if (args.remove !== undefined && args["remove-self"]) {
110
- throw new ConfigError("Error: --remove and --remove-self are mutually exclusive.");
109
+ if (args.remove !== undefined && args["remove-here"]) {
110
+ throw new ConfigError("Error: --remove and --remove-here are mutually exclusive.");
111
111
  }
112
112
  if ((args.slot !== undefined || args.force) && !isSetupMode(args)) {
113
- throw new ConfigError("Error: --slot and --force can only be used with --use, --create, or --self.");
113
+ throw new ConfigError("Error: --slot and --force can only be used with --use, --create, or --here.");
114
114
  }
115
115
  if (args.owner !== undefined && !isSetupMode(args)) {
116
- throw new ConfigError("Error: --owner is only valid with --use, --create, or --self.");
116
+ throw new ConfigError("Error: --owner is only valid with --use, --create, or --here.");
117
117
  }
118
118
  if (args["no-remote-check"] && !isRemoveMode(args)) {
119
- throw new ConfigError("Error: --no-remote-check is only valid with --remove or --remove-self.");
119
+ throw new ConfigError("Error: --no-remote-check is only valid with --remove or --remove-here.");
120
120
  }
121
121
  }
122
122
  export function validateDevServerFlags(args) {
@@ -147,8 +147,8 @@ function generateConfigFiles(ctx, entries, slot, ports, force, log) {
147
147
  }), entry.path, force, entry.required ?? false);
148
148
  }
149
149
  }
150
- function resolveRemoveTarget(args, ctx, registry, removeSelf) {
151
- if (removeSelf) {
150
+ function resolveRemoveTarget(args, ctx, registry, removeHere) {
151
+ if (removeHere) {
152
152
  if (ctx.isMainWorktree) {
153
153
  console.error("Error: Cannot remove the main worktree.");
154
154
  process.exit(1);
@@ -174,7 +174,7 @@ function resolveRemoveTarget(args, ctx, registry, removeSelf) {
174
174
  }
175
175
  const worktreePath = entry[1].worktree;
176
176
  if (resolve(ctx.currentWorktree) === resolve(worktreePath)) {
177
- console.error("Error: You are currently in this worktree. Use --remove-self instead.");
177
+ console.error("Error: You are currently in this worktree. Use --remove-here instead.");
178
178
  process.exit(1);
179
179
  }
180
180
  return { slotPort: entry[0], branch, worktreePath, owner: entry[1].owner };
@@ -208,9 +208,9 @@ async function stopDevServerByPidFiles(worktreePath, pidFiles, log) {
208
208
  }
209
209
  async function handleRemove(args, ctx, run, config) {
210
210
  const log = makeLog(run.verbose);
211
- const removeSelf = Boolean(args["remove-self"]);
211
+ const removeHere = Boolean(args["remove-here"]);
212
212
  const registry = readSlots(ctx.mainWorktree);
213
- const target = resolveRemoveTarget(args, ctx, registry, removeSelf);
213
+ const target = resolveRemoveTarget(args, ctx, registry, removeHere);
214
214
  if (!args["no-remote-check"]) {
215
215
  verifyBranchAbsentFromRemote(target.branch, run);
216
216
  }
@@ -233,12 +233,12 @@ async function handleRemove(args, ctx, run, config) {
233
233
  delete registry.slots[target.slotPort];
234
234
  writeSlots(ctx.mainWorktree, registry);
235
235
  removeDevServerEntryByWorktree(ctx.mainWorktree, target.worktreePath);
236
- if (removeSelf) {
236
+ if (removeHere) {
237
237
  process.chdir(ctx.mainWorktree);
238
238
  }
239
239
  removeWorktree(target.worktreePath, run);
240
240
  console.log(`Removed worktree for branch "${target.branch}" (slot ${target.slotPort}${ownerSuffix}).`);
241
- if (removeSelf) {
241
+ if (removeHere) {
242
242
  console.log(`Now run: cd ${ctx.mainWorktree}`);
243
243
  }
244
244
  }
@@ -16,6 +16,6 @@ export declare function getCurrentBranch(worktreePath: string): string;
16
16
  export declare function enforceWorktreeMode(args: {
17
17
  use?: string;
18
18
  create?: string;
19
- self?: boolean;
19
+ here?: boolean;
20
20
  }, ctx: WorktreeContext): void;
21
21
  export declare function removeWorktree(worktreePath: string, run: RunCtx): void;
package/dist/worktree.js CHANGED
@@ -80,9 +80,9 @@ export function enforceWorktreeMode(args, ctx) {
80
80
  process.exit(1);
81
81
  }
82
82
  }
83
- else if (args.self) {
83
+ else if (args.here) {
84
84
  if (ctx.isMainWorktree) {
85
- console.error("Error: --self must be run from a linked worktree, not from the main worktree.");
85
+ console.error("Error: --here must be run from a linked worktree, not from the main worktree.");
86
86
  process.exit(1);
87
87
  }
88
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/worktree-env",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Worktree-based concurrent local environment kernel.",
5
5
  "keywords": [
6
6
  "worktree",