File tree Expand file tree Collapse file tree 6 files changed +31
-17
lines changed
Expand file tree Collapse file tree 6 files changed +31
-17
lines changed Original file line number Diff line number Diff line change 11import { defineCommand } from "citty" ;
22import { createVanilla } from "./create-vanilla" ;
33import * as p from "@clack/prompts" ;
4- import { cancelable , spinnerify } from ". /utils/ui" ;
4+ import { cancelable , spinnerify } from "@solid-cli /utils/ui" ;
55import { createStart } from "./create-start" ;
66import { getTemplatesList , StartTemplate , VanillaTemplate } from "./utils/constants" ;
77import { detectPackageManager } from "@solid-cli/utils/package-manager" ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import { createRoute } from "@solid-cli/utils";
22import { defineCommand } from "citty" ;
33import * as p from "@clack/prompts" ;
44import { green } from "picocolors" ;
5+ import { cancelable } from "@solid-cli/utils/ui"
56export const startCommands = defineCommand ( {
67 meta : { description : "Start-specific commands" } , subCommands : {
78 route : defineCommand ( {
@@ -13,6 +14,11 @@ export const startCommands = defineCommand({
1314 } ,
1415 } ,
1516 async run ( { args : { path } } ) {
17+ path ||= await cancelable ( p . text ( {
18+ message : "Route name" , validate ( value ) {
19+ if ( value . length === 0 ) return "A route name is required"
20+ } ,
21+ } ) )
1622 await createRoute ( path as string ) ;
1723 p . log . success ( `Route ${ green ( path as string ) } successfully created!` )
1824 } ,
Original file line number Diff line number Diff line change 5555 "types" : " ./types/package-manager/index.d.ts" ,
5656 "import" : " ./dist/package-manager/index.mjs" ,
5757 "require" : " ./dist/package-manager/index.mjs"
58+ },
59+ "./ui" : {
60+ "types" : " ./types/ui/index.d.ts" ,
61+ "import" : " ./dist/ui/index.mjs" ,
62+ "require" : " ./dist/ui/index.mjs"
5863 }
5964 },
6065 "scripts" : {
Original file line number Diff line number Diff line change 1+ import { log } from "@clack/prompts" ;
2+ export const cancelable = async < T = unknown > (
3+ prompt : Promise < T | symbol > ,
4+ cancelMessage : string = "Canceled" ,
5+ ) : Promise < T > => {
6+ const value = await prompt ;
7+
8+ if ( typeof value === "symbol" ) {
9+ log . warn ( cancelMessage ) ;
10+ process . exit ( 0 ) ;
11+ }
12+
13+ return value ;
14+ } ;
Original file line number Diff line number Diff line change 1+ import { cancelable } from "./cancelable" ;
2+ import { spinnerify } from "./spinnerify" ;
3+ export { cancelable , spinnerify }
Original file line number Diff line number Diff line change 1- import { log , spinner } from "@clack/prompts" ;
1+ import { spinner } from "@clack/prompts" ;
22type SpinnerItem < T > = {
33 startText : string ;
44 finishText : string ;
@@ -16,18 +16,4 @@ export async function spinnerify<T>(spinners: SpinnerItem<any>[] | SpinnerItem<T
1616 s . stop ( finishText ) ;
1717 }
1818 return results . length === 1 ? results [ 0 ] : results ;
19- }
20-
21- export const cancelable = async < T = unknown > (
22- prompt : Promise < T | symbol > ,
23- cancelMessage : string = "Canceled" ,
24- ) : Promise < T > => {
25- const value = await prompt ;
26-
27- if ( typeof value === "symbol" ) {
28- log . warn ( cancelMessage ) ;
29- process . exit ( 0 ) ;
30- }
31-
32- return value ;
33- } ;
19+ }
You can’t perform that action at this time.
0 commit comments