()
| 420 | } |
| 421 | |
| 422 | async function promptCustomPath(): Promise<string> { |
| 423 | if (!isInteractiveTTY()) { |
| 424 | throw new Error('Cannot prompt for custom path in non-interactive mode. Use --dest instead.'); |
| 425 | } |
| 426 | |
| 427 | const result = await clack.text({ |
| 428 | message: 'Enter the destination directory path:', |
| 429 | validate: (value: string | undefined) => { |
| 430 | if (!value?.trim()) return 'Path cannot be empty.'; |
| 431 | const resolved = resolvePathFromCwd(value); |
| 432 | if (resolved === path.parse(resolved).root) { |
| 433 | return 'Refusing to use filesystem root. Use a dedicated directory.'; |
| 434 | } |
| 435 | return undefined; |
| 436 | }, |
| 437 | }); |
| 438 | |
| 439 | if (clack.isCancel(result)) { |
| 440 | clack.cancel('Operation cancelled.'); |
| 441 | throw new Error('Operation cancelled.'); |
| 442 | } |
| 443 | |
| 444 | return resolvePathFromCwd(result as string); |
| 445 | } |
| 446 | |
| 447 | export function registerInitCommand(app: Argv, ctx?: { workspaceRoot: string }): void { |
| 448 | app.command( |
no test coverage detected