totopo 0.6.0 → 0.6.1-rc-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/package.json +1 -1
- package/src/core/commands/dev.ts +19 -25
package/package.json
CHANGED
package/src/core/commands/dev.ts
CHANGED
|
@@ -7,8 +7,8 @@
|
|
|
7
7
|
import { spawnSync } from "node:child_process";
|
|
8
8
|
import { existsSync, readdirSync, readFileSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
9
9
|
import { tmpdir } from "node:os";
|
|
10
|
-
import { basename, join } from "node:path";
|
|
11
|
-
import { cancel, groupMultiselect, isCancel, log, multiselect, note, outro,
|
|
10
|
+
import { basename, join, relative } from "node:path";
|
|
11
|
+
import { cancel, groupMultiselect, isCancel, log, multiselect, note, outro, path, select } from "@clack/prompts";
|
|
12
12
|
|
|
13
13
|
// biome-ignore lint/style/noNonNullAssertion: guarded immediately below; non-null assertion needed for closure type inference
|
|
14
14
|
const workspaceDir = process.env.TOTOPO_REPO_ROOT!;
|
|
@@ -127,40 +127,34 @@ async function promptDeeperPaths(style: "only" | "except"): Promise<string[]> {
|
|
|
127
127
|
const verb = style === "only" ? "include" : "exclude";
|
|
128
128
|
const accumulated: string[] = [];
|
|
129
129
|
|
|
130
|
-
// Build a concrete example from actual cwd contents
|
|
131
|
-
const exampleDir = readdirSync(cwd).find((e) => {
|
|
132
|
-
try {
|
|
133
|
-
return statSync(join(cwd, e)).isDirectory() && join(cwd, e) !== totopoDir;
|
|
134
|
-
} catch {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
const exampleSub = exampleDir ? readdirSync(join(cwd, exampleDir))[0] : undefined;
|
|
139
|
-
const example = exampleDir ? (exampleSub ? `${exampleDir}/ or ${exampleDir}/${exampleSub}` : `${exampleDir}/`) : "some-dir/";
|
|
140
|
-
|
|
141
130
|
while (true) {
|
|
142
|
-
const
|
|
143
|
-
message: `Add a nested path to ${verb}
|
|
144
|
-
|
|
131
|
+
const selectedAbs = await path({
|
|
132
|
+
message: `Add a nested path to ${verb} — browse or type, blank Enter to finish:`,
|
|
133
|
+
root: cwd,
|
|
134
|
+
validate: (v) => {
|
|
135
|
+
// Allow empty to signal "done"
|
|
136
|
+
if (!v) return undefined;
|
|
137
|
+
if (!existsSync(v)) return `Path not found: ${v}`;
|
|
138
|
+
return undefined;
|
|
139
|
+
},
|
|
140
|
+
directory: false, // Set to true to only show directories
|
|
145
141
|
});
|
|
146
142
|
|
|
147
|
-
if (isCancel(
|
|
143
|
+
if (isCancel(selectedAbs)) {
|
|
148
144
|
cancel("Cancelled.");
|
|
149
145
|
process.exit(0);
|
|
150
146
|
}
|
|
151
147
|
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
148
|
+
const absPath = (selectedAbs as string).trim();
|
|
149
|
+
if (!absPath) break;
|
|
154
150
|
|
|
155
|
-
const
|
|
151
|
+
const prefix = relative(cwd, absPath);
|
|
152
|
+
if (!prefix) break; // selected cwd root itself — treat as done
|
|
156
153
|
|
|
157
|
-
|
|
158
|
-
log.warn(`Path not found: ${prefix}`);
|
|
159
|
-
continue;
|
|
160
|
-
}
|
|
154
|
+
const targetDir = absPath;
|
|
161
155
|
|
|
162
156
|
if (!statSync(targetDir).isDirectory()) {
|
|
163
|
-
//
|
|
157
|
+
// selected a direct file
|
|
164
158
|
accumulated.push(prefix);
|
|
165
159
|
log.success(`Added: ${prefix}`);
|
|
166
160
|
continue;
|