code-squad-cli 2.1.1 → 2.1.2
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 +12 -5
- package/dist/tui/App.d.ts +1 -1
- package/dist/tui/App.js +6 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -266,7 +266,7 @@ function shorten(p) {
|
|
|
266
266
|
const home = os5.homedir();
|
|
267
267
|
return p.startsWith(home) ? "~" + p.slice(home.length) : p;
|
|
268
268
|
}
|
|
269
|
-
function App({ initialWorktrees, root }) {
|
|
269
|
+
function App({ initialWorktrees, root, onSelect }) {
|
|
270
270
|
const { exit } = useApp();
|
|
271
271
|
const [view, setView] = useState("list");
|
|
272
272
|
const [worktrees, setWorktrees] = useState(initialWorktrees);
|
|
@@ -294,7 +294,7 @@ function App({ initialWorktrees, root }) {
|
|
|
294
294
|
} else if (key.downArrow) {
|
|
295
295
|
setCursor((c) => Math.min(worktrees.length - 1, c + 1));
|
|
296
296
|
} else if (key.return && worktrees.length > 0) {
|
|
297
|
-
|
|
297
|
+
onSelect(worktrees[cursor].path);
|
|
298
298
|
exit();
|
|
299
299
|
} else if (ch === "n") {
|
|
300
300
|
setView("create");
|
|
@@ -322,7 +322,7 @@ function App({ initialWorktrees, root }) {
|
|
|
322
322
|
if (patterns.length > 0) {
|
|
323
323
|
await copyFilesWithPatterns(root, wtPath, patterns);
|
|
324
324
|
}
|
|
325
|
-
|
|
325
|
+
onSelect(wtPath);
|
|
326
326
|
exit();
|
|
327
327
|
}).catch((e) => {
|
|
328
328
|
setMsg({ text: e.message, color: "red" });
|
|
@@ -363,12 +363,16 @@ function App({ initialWorktrees, root }) {
|
|
|
363
363
|
}
|
|
364
364
|
async function runTui(workspaceRoot) {
|
|
365
365
|
const worktrees = await git.listWorktrees(workspaceRoot);
|
|
366
|
+
let selectedPath = null;
|
|
366
367
|
const fd = fs11.openSync("/dev/tty", "w");
|
|
367
368
|
const ttyStream = new tty.WriteStream(fd);
|
|
368
|
-
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot
|
|
369
|
+
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => {
|
|
370
|
+
selectedPath = p;
|
|
371
|
+
} }), { stdout: ttyStream });
|
|
369
372
|
await waitUntilExit();
|
|
370
373
|
ttyStream.destroy();
|
|
371
374
|
fs11.closeSync(fd);
|
|
375
|
+
return selectedPath;
|
|
372
376
|
}
|
|
373
377
|
var git;
|
|
374
378
|
var init_App = __esm({
|
|
@@ -2015,7 +2019,10 @@ async function main() {
|
|
|
2015
2019
|
default:
|
|
2016
2020
|
if (process.stdin.isTTY) {
|
|
2017
2021
|
const { runTui: runTui2 } = await Promise.resolve().then(() => (init_App(), App_exports));
|
|
2018
|
-
await runTui2(workspaceRoot);
|
|
2022
|
+
const selectedPath = await runTui2(workspaceRoot);
|
|
2023
|
+
if (selectedPath) {
|
|
2024
|
+
process.stdout.write(selectedPath + "\n");
|
|
2025
|
+
}
|
|
2019
2026
|
} else {
|
|
2020
2027
|
await listWorktrees(workspaceRoot);
|
|
2021
2028
|
}
|
package/dist/tui/App.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare function runTui(workspaceRoot: string): Promise<
|
|
1
|
+
export declare function runTui(workspaceRoot: string): Promise<string | null>;
|
package/dist/tui/App.js
CHANGED
|
@@ -13,7 +13,7 @@ function shorten(p) {
|
|
|
13
13
|
const home = os.homedir();
|
|
14
14
|
return p.startsWith(home) ? '~' + p.slice(home.length) : p;
|
|
15
15
|
}
|
|
16
|
-
function App({ initialWorktrees, root }) {
|
|
16
|
+
function App({ initialWorktrees, root, onSelect }) {
|
|
17
17
|
const { exit } = useApp();
|
|
18
18
|
const [view, setView] = useState('list');
|
|
19
19
|
const [worktrees, setWorktrees] = useState(initialWorktrees);
|
|
@@ -43,7 +43,7 @@ function App({ initialWorktrees, root }) {
|
|
|
43
43
|
setCursor(c => Math.min(worktrees.length - 1, c + 1));
|
|
44
44
|
}
|
|
45
45
|
else if (key.return && worktrees.length > 0) {
|
|
46
|
-
|
|
46
|
+
onSelect(worktrees[cursor].path);
|
|
47
47
|
exit();
|
|
48
48
|
}
|
|
49
49
|
else if (ch === 'n') {
|
|
@@ -75,7 +75,7 @@ function App({ initialWorktrees, root }) {
|
|
|
75
75
|
if (patterns.length > 0) {
|
|
76
76
|
await copyFilesWithPatterns(root, wtPath, patterns);
|
|
77
77
|
}
|
|
78
|
-
|
|
78
|
+
onSelect(wtPath);
|
|
79
79
|
exit();
|
|
80
80
|
})
|
|
81
81
|
.catch((e) => {
|
|
@@ -121,12 +121,14 @@ function App({ initialWorktrees, root }) {
|
|
|
121
121
|
}
|
|
122
122
|
export async function runTui(workspaceRoot) {
|
|
123
123
|
const worktrees = await git.listWorktrees(workspaceRoot);
|
|
124
|
+
let selectedPath = null;
|
|
124
125
|
// Render to /dev/tty directly — bypasses stdout/stderr capture
|
|
125
126
|
// so shell function's `2>&1` doesn't swallow TUI output
|
|
126
127
|
const fd = fs.openSync('/dev/tty', 'w');
|
|
127
128
|
const ttyStream = new tty.WriteStream(fd);
|
|
128
|
-
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot }), { stdout: ttyStream });
|
|
129
|
+
const { waitUntilExit } = render(_jsx(App, { initialWorktrees: worktrees, root: workspaceRoot, onSelect: (p) => { selectedPath = p; } }), { stdout: ttyStream });
|
|
129
130
|
await waitUntilExit();
|
|
130
131
|
ttyStream.destroy();
|
|
131
132
|
fs.closeSync(fd);
|
|
133
|
+
return selectedPath;
|
|
132
134
|
}
|