@paleo/worktree-env 0.6.0 → 0.6.1

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
@@ -37,9 +37,12 @@ npm run setup-worktree -- --remove feat/42 # full teardown
37
37
  ## API
38
38
 
39
39
  ```ts
40
+ import { fileURLToPath } from "node:url";
40
41
  import { runSetupWorktree, helpers } from "@paleo/worktree-env";
41
42
 
42
43
  await runSetupWorktree({
44
+ scriptPath: fileURLToPath(import.meta.url),
45
+ devServerScript: fileURLToPath(new URL("./dev-server.mjs", import.meta.url)),
43
46
  basePort: 8100,
44
47
  portNames: ["server", "frontend", "db"],
45
48
  sharedDirs: [".local", ".plans"],
@@ -77,6 +80,7 @@ await runDevServer({
77
80
  devLimit: 5,
78
81
  servers: [
79
82
  {
83
+ kind: "spawn",
80
84
  name: "dev",
81
85
  exec: { command: "npm", args: ["run", "dev"] },
82
86
  port: helpers.readPortFromEnvFile(".env", "PORT"),
@@ -60,8 +60,8 @@ function callbackServersOf(config) {
60
60
  async function start(config, mainWorktree, { evict }) {
61
61
  const ctx = { cwd: process.cwd() };
62
62
  await enforceCap(config, mainWorktree, evict);
63
- await checkPortsFree(config.servers);
64
63
  checkNoLocalRegistryConflict(config, mainWorktree, ctx.cwd);
64
+ await checkPortsFree(config.servers);
65
65
  const spawnPids = {};
66
66
  const startedCallbacks = [];
67
67
  try {
@@ -126,6 +126,7 @@ async function rollbackStart(spawnPids, startedCallbacks, ctx) {
126
126
  }
127
127
  }
128
128
  for (const server of [...startedCallbacks].reverse()) {
129
+ console.log(`Stopping ${server.name}...`);
129
130
  try {
130
131
  await server.stop(ctx);
131
132
  }
@@ -205,6 +206,7 @@ async function stopLocal(config, mainWorktree) {
205
206
  }
206
207
  const callbacks = callbackServersOf(config);
207
208
  for (const server of [...callbacks].reverse()) {
209
+ console.log(`Stopping ${server.name}...`);
208
210
  try {
209
211
  await server.stop(ctx);
210
212
  }
@@ -59,6 +59,7 @@ export async function evictOldest(input) {
59
59
  }
60
60
  async function stopCallbacksForVictim(callbackServers, worktree) {
61
61
  for (const server of [...callbackServers].reverse()) {
62
+ console.log(` ${server.name} (callback)`);
62
63
  try {
63
64
  await server.stop({ cwd: worktree });
64
65
  }
@@ -2,7 +2,7 @@ import { spawn, spawnSync } from "node:child_process";
2
2
  import { appendFileSync, closeSync, existsSync, mkdirSync, openSync, readFileSync, symlinkSync, writeFileSync, } from "node:fs";
3
3
  import { dirname, join, relative, resolve } from "node:path";
4
4
  import { isFinalizeMode, isInfoMode, isRemoveMode, isSetOwnerMode, isSetupMode, isWaitMode, parseSetupArgs, printSetupHelp, validateSetupFlags, } from "./cli.js";
5
- import { removeDevServerEntryByWorktree } from "./dev-servers-registry.js";
5
+ import { findOwnEntry, removeDevServerEntryByWorktree } from "./dev-servers-registry.js";
6
6
  import { ConfigError } from "./errors.js";
7
7
  import { copyAndPatchFile } from "./helpers.js";
8
8
  import { defaultComputePorts, isValidPort, resolvePortScheme } from "./ports.js";
@@ -287,7 +287,13 @@ async function handleRemove(args, ctx, run, config) {
287
287
  console.log(`Removed registry entry for branch "${target.branch}" (slot ${target.slotPort}${ownerSuffix}).`);
288
288
  return;
289
289
  }
290
- stopTargetDevServer(config.devServerScript, target.worktreePath, verboseLog);
290
+ const targetEntry = findOwnEntry(ctx.mainWorktree, config.registryDir, target.worktreePath);
291
+ if (targetEntry) {
292
+ stopTargetDevServer(config.devServerScript, target.worktreePath, verboseLog);
293
+ }
294
+ else {
295
+ verboseLog(`No dev-server running in ${target.worktreePath}; skipping --stop.`);
296
+ }
291
297
  if (config.purgeInfrastructure) {
292
298
  await config.purgeInfrastructure({
293
299
  worktree: target.worktreePath,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paleo/worktree-env",
3
- "version": "0.6.0",
3
+ "version": "0.6.1",
4
4
  "description": "Worktree-based concurrent local environment kernel.",
5
5
  "keywords": [
6
6
  "worktree",