@paleo/worktree-env 0.1.0 → 0.2.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.
@@ -8,8 +8,8 @@ export type PortConfig = {
8
8
  };
9
9
  export interface DevServerConfig {
10
10
  basePort: number;
11
- devLimitEnvVar: string;
12
- defaultLimit?: number;
11
+ /** Maximum concurrent dev-servers across all worktrees. `0` means unlimited. */
12
+ devLimit: number;
13
13
  servers: ServerDescriptor[];
14
14
  ensureInfrastructure?: () => Promise<void> | void;
15
15
  printSummary?: (ctx: DevServerSummaryContext) => string;
@@ -3,7 +3,6 @@ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, writeFileSync
3
3
  import { createConnection } from "node:net";
4
4
  import { dirname, join } from "node:path";
5
5
  import { parseDevServerArgs, printDevServerHelp, validateDevServerFlags, } from "./cli.js";
6
- import { readDevLimit } from "./dev-limit.js";
7
6
  import { listDevServers, printActiveServers, pruneAndPersist, registerDevServer, stopAllRegistered, unregisterDevServer, } from "./dev-servers-registry.js";
8
7
  import { ConfigError, StartupError } from "./errors.js";
9
8
  import { awaitAllReady, handleStartupFailure } from "./log-polling.js";
@@ -129,10 +128,7 @@ export async function runDevServer(config) {
129
128
  await start(config, mainWorktree);
130
129
  }
131
130
  async function start(config, mainWorktree) {
132
- const limit = readDevLimit({
133
- projectVar: config.devLimitEnvVar,
134
- defaultLimit: config.defaultLimit,
135
- });
131
+ const limit = config.devLimit;
136
132
  const active = pruneAndPersist(mainWorktree).servers;
137
133
  if (limit > 0 && active.length >= limit) {
138
134
  console.error(`Error: dev-server cap reached (${active.length}/${limit}). Active dev-servers:`);
@@ -41,7 +41,6 @@ export interface SetupWorktreeConfig {
41
41
  perWorktreeDirs?: string[];
42
42
  sharedDirs?: string[];
43
43
  devServerPidFiles: string[];
44
- devLimitEnvVar?: string;
45
44
  configFiles: ConfigFileEntry[];
46
45
  provisionDatabase: (ctx: SetupContext) => Promise<void> | void;
47
46
  teardownInfrastructure?: (ctx: TeardownContext) => Promise<void> | void;
@@ -166,7 +166,12 @@ function resolveRemoveTarget(args, ctx, registry, removeSelf) {
166
166
  console.error("Error: No slot found for this worktree in the registry.");
167
167
  process.exit(1);
168
168
  }
169
- return { slotPort: entry[0], branch: entry[1].branch, worktreePath: ctx.currentWorktree };
169
+ return {
170
+ slotPort: entry[0],
171
+ branch: entry[1].branch,
172
+ worktreePath: ctx.currentWorktree,
173
+ owner: entry[1].owner ?? "default",
174
+ };
170
175
  }
171
176
  const branch = args.remove ?? "";
172
177
  const entry = Object.entries(registry.slots).find(([, v]) => v.branch === branch);
@@ -179,7 +184,7 @@ function resolveRemoveTarget(args, ctx, registry, removeSelf) {
179
184
  console.error("Error: You are currently in this worktree. Use --remove-self instead.");
180
185
  process.exit(1);
181
186
  }
182
- return { slotPort: entry[0], branch, worktreePath };
187
+ return { slotPort: entry[0], branch, worktreePath, owner: entry[1].owner ?? "default" };
183
188
  }
184
189
  async function stopDevServerByPidFiles(worktreePath, pidFiles, log) {
185
190
  for (const pidFileRel of pidFiles) {
@@ -216,11 +221,12 @@ async function handleRemove(args, ctx, run, config) {
216
221
  if (!args["no-remote-check"]) {
217
222
  verifyBranchAbsentFromRemote(target.branch, run);
218
223
  }
224
+ const ownerSuffix = target.owner !== "default" ? `, owner ${target.owner}` : "";
219
225
  if (!existsSync(target.worktreePath)) {
220
226
  console.warn(`Warning: Worktree directory ${target.worktreePath} not found. Cleaning up registry only.`);
221
227
  delete registry.slots[target.slotPort];
222
228
  writeSlots(ctx.mainWorktree, registry);
223
- console.log(`Removed registry entry for branch "${target.branch}" (slot ${target.slotPort}).`);
229
+ console.log(`Removed registry entry for branch "${target.branch}" (slot ${target.slotPort}${ownerSuffix}).`);
224
230
  return;
225
231
  }
226
232
  await stopDevServerByPidFiles(target.worktreePath, config.devServerPidFiles, log);
@@ -238,7 +244,7 @@ async function handleRemove(args, ctx, run, config) {
238
244
  process.chdir(ctx.mainWorktree);
239
245
  }
240
246
  removeWorktree(target.worktreePath, run);
241
- console.log(`Removed worktree for branch "${target.branch}" (slot ${target.slotPort}).`);
247
+ console.log(`Removed worktree for branch "${target.branch}" (slot ${target.slotPort}${ownerSuffix}).`);
242
248
  if (removeSelf) {
243
249
  console.log(`Now run: cd ${ctx.mainWorktree}`);
244
250
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/worktree-env",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Worktree-based concurrent local environment kernel.",
5
5
  "keywords": [
6
6
  "worktree",
@@ -1,6 +0,0 @@
1
- export interface ReadDevLimitOptions {
2
- projectVar: string;
3
- defaultLimit?: number;
4
- env?: NodeJS.ProcessEnv;
5
- }
6
- export declare function readDevLimit(opts: ReadDevLimitOptions): number;
package/dist/dev-limit.js DELETED
@@ -1,13 +0,0 @@
1
- export function readDevLimit(opts) {
2
- const env = opts.env ?? process.env;
3
- const defaultLimit = opts.defaultLimit ?? 5;
4
- const candidates = [env[opts.projectVar], env.PROJECT_DEV_LIMIT];
5
- for (const raw of candidates) {
6
- if (raw === undefined || raw === "")
7
- continue;
8
- const parsed = Number(raw);
9
- if (Number.isInteger(parsed) && parsed >= 0)
10
- return parsed;
11
- }
12
- return defaultLimit;
13
- }