@hienlh/ppm 0.2.4 → 0.2.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hienlh/ppm",
3
- "version": "0.2.4",
3
+ "version": "0.2.5",
4
4
  "description": "Personal Project Manager — mobile-first web IDE with AI assistance",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -155,17 +155,12 @@ export async function startServer(options: {
155
155
  const { ensureCloudflared } = await import("../services/cloudflared.service.ts");
156
156
  const bin = await ensureCloudflared();
157
157
 
158
- // Check if tunnel already running (reuse from previous server crash)
158
+ // Kill any leftover tunnel from previous run
159
159
  if (existsSync(statusFile)) {
160
160
  try {
161
161
  const prev = JSON.parse(readFileSync(statusFile, "utf-8"));
162
- if (prev.tunnelPid && prev.shareUrl) {
163
- try {
164
- process.kill(prev.tunnelPid, 0); // Check alive
165
- console.log(` Reusing existing tunnel (PID: ${prev.tunnelPid})`);
166
- shareUrl = prev.shareUrl;
167
- tunnelPid = prev.tunnelPid;
168
- } catch { /* tunnel dead, spawn new one */ }
162
+ if (prev.tunnelPid) {
163
+ try { process.kill(prev.tunnelPid); } catch { /* already dead */ }
169
164
  }
170
165
  } catch {}
171
166
  }
@@ -173,8 +168,10 @@ export async function startServer(options: {
173
168
  // Spawn new tunnel if no existing one
174
169
  if (!shareUrl) {
175
170
  console.log(" Starting share tunnel...");
176
- const { openSync: openFd } = await import("node:fs");
171
+ const { openSync: openFd, writeFileSync: writeFs } = await import("node:fs");
177
172
  const tunnelLog = resolve(ppmDir, "tunnel.log");
173
+ // Truncate old log so we only match the new tunnel URL
174
+ writeFs(tunnelLog, "");
178
175
  const tfd = openFd(tunnelLog, "a");
179
176
  const tunnelProc = Bun.spawn({
180
177
  cmd: [bin, "tunnel", "--url", `http://localhost:${port}`],