lunel-cli 0.1.2 → 0.1.4
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/index.js +23 -5
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import * as os from "os";
|
|
|
9
9
|
import { spawn, execSync } from "child_process";
|
|
10
10
|
import { createServer } from "net";
|
|
11
11
|
const PROXY_URL = process.env.LUNEL_PROXY_URL || "https://gateway.lunel.dev";
|
|
12
|
-
const VERSION = "1.
|
|
12
|
+
const VERSION = "0.1.3";
|
|
13
13
|
// Root directory - sandbox all file operations to this
|
|
14
14
|
const ROOT_DIR = process.cwd();
|
|
15
15
|
// Terminal sessions
|
|
@@ -290,7 +290,17 @@ async function handleGitStatus() {
|
|
|
290
290
|
for (const line of lines) {
|
|
291
291
|
const index = line[0];
|
|
292
292
|
const worktree = line[1];
|
|
293
|
-
|
|
293
|
+
// Git porcelain format: XY path (where X=index status, Y=worktree status)
|
|
294
|
+
// For renamed files: XY old -> new
|
|
295
|
+
let filepath = line.substring(3).trim();
|
|
296
|
+
// Handle quoted paths (git quotes paths with special chars)
|
|
297
|
+
if (filepath.startsWith('"') && filepath.endsWith('"')) {
|
|
298
|
+
filepath = filepath.slice(1, -1);
|
|
299
|
+
}
|
|
300
|
+
// For renamed files, extract just the new name
|
|
301
|
+
if (filepath.includes(' -> ')) {
|
|
302
|
+
filepath = filepath.split(' -> ')[1];
|
|
303
|
+
}
|
|
294
304
|
if (index === "?" && worktree === "?") {
|
|
295
305
|
untracked.push(filepath);
|
|
296
306
|
}
|
|
@@ -318,7 +328,7 @@ async function handleGitStage(payload) {
|
|
|
318
328
|
const paths = payload.paths;
|
|
319
329
|
if (!paths || !paths.length)
|
|
320
330
|
throw Object.assign(new Error("paths is required"), { code: "EINVAL" });
|
|
321
|
-
const result = await runGit(["add", ...paths]);
|
|
331
|
+
const result = await runGit(["add", "--", ...paths]);
|
|
322
332
|
if (result.code !== 0) {
|
|
323
333
|
throw Object.assign(new Error(result.stderr || "git add failed"), { code: "EGIT" });
|
|
324
334
|
}
|
|
@@ -328,9 +338,15 @@ async function handleGitUnstage(payload) {
|
|
|
328
338
|
const paths = payload.paths;
|
|
329
339
|
if (!paths || !paths.length)
|
|
330
340
|
throw Object.assign(new Error("paths is required"), { code: "EINVAL" });
|
|
331
|
-
|
|
341
|
+
// Use git restore --staged (Git 2.23+) which is more reliable
|
|
342
|
+
// Falls back to git reset HEAD for older versions
|
|
343
|
+
let result = await runGit(["restore", "--staged", "--", ...paths]);
|
|
332
344
|
if (result.code !== 0) {
|
|
333
|
-
|
|
345
|
+
// Fallback to reset for older git versions
|
|
346
|
+
result = await runGit(["reset", "HEAD", "--", ...paths]);
|
|
347
|
+
if (result.code !== 0) {
|
|
348
|
+
throw Object.assign(new Error(result.stderr || "git unstage failed"), { code: "EGIT" });
|
|
349
|
+
}
|
|
334
350
|
}
|
|
335
351
|
return {};
|
|
336
352
|
}
|
|
@@ -574,6 +590,7 @@ function handleProcessesList() {
|
|
|
574
590
|
startTime: proc.startTime,
|
|
575
591
|
status: proc.proc.killed ? "stopped" : "running",
|
|
576
592
|
channel: proc.channel,
|
|
593
|
+
cwd: proc.cwd,
|
|
577
594
|
});
|
|
578
595
|
}
|
|
579
596
|
return { processes: result };
|
|
@@ -599,6 +616,7 @@ function handleProcessesSpawn(payload) {
|
|
|
599
616
|
proc,
|
|
600
617
|
command,
|
|
601
618
|
args,
|
|
619
|
+
cwd: workDir,
|
|
602
620
|
startTime: Date.now(),
|
|
603
621
|
output: [],
|
|
604
622
|
channel,
|