11import { existsSync } from "node:fs" ;
22import { mkdir } from "node:fs/promises" ;
3- import { Cancel , Exit , args , color , confirm , group , note , positionals , text } from "@r5n/cli-core" ;
3+ import { args , Cancel , color , confirm , Exit , group , note , positionals , text } from "@r5n/cli-core" ;
44import { BaseCommand , type Ctx } from "../base-command" ;
55import { CLI_BIN , DEFAULT_PROFILE , RUNNERS_DIR , SHARED_DIR } from "../constants" ;
66import type { Profile } from "../types" ;
77
8- const initPositionals = positionals ( {
9- url : { description : "GitHub repository or organization URL" } ,
10- } ) ;
8+ const initPositionals = positionals ( { url : { description : "GitHub repository or organization URL" } } ) ;
119
1210const initArgs = args ( {
1311 force : { alias : "f" , default : false , description : "Overwrite existing config" , type : "boolean" } ,
@@ -27,9 +25,7 @@ export class InitCommand extends BaseCommand {
2725 prompts = true ;
2826
2927 async execute ( ctx : InitCtx ) {
30- const profileName = ctx . interactive
31- ? await this . promptProfileName ( ctx )
32- : ( ctx . args . profile ?? DEFAULT_PROFILE ) ;
28+ const profileName = ctx . interactive ? await this . promptProfileName ( ctx ) : ( ctx . args . profile ?? DEFAULT_PROFILE ) ;
3329
3430 const isNewInit = ! ctx . config . exists ( ) ;
3531
@@ -38,7 +34,10 @@ export class InitCommand extends BaseCommand {
3834 if ( ! ctx . interactive ) {
3935 throw new Exit ( `Profile "${ profileName } " already exists. Use --force to overwrite.` ) ;
4036 }
41- const overwrite = await confirm ( { initialValue : false , message : `Profile "${ profileName } " already exists. Overwrite?` } ) ;
37+ const overwrite = await confirm ( {
38+ initialValue : false ,
39+ message : `Profile "${ profileName } " already exists. Overwrite?` ,
40+ } ) ;
4241 if ( ! overwrite ) return ;
4342 }
4443
@@ -70,10 +69,7 @@ export class InitCommand extends BaseCommand {
7069 }
7170
7271 private async promptProfileName ( ctx : InitCtx ) : Promise < string > {
73- return text ( {
74- initialValue : ctx . args . profile ?? DEFAULT_PROFILE ,
75- message : "Profile name" ,
76- } ) ;
72+ return text ( { initialValue : ctx . args . profile ?? DEFAULT_PROFILE , message : "Profile name" } ) ;
7773 }
7874
7975 private async ensureDirectories ( ) {
@@ -102,12 +98,7 @@ export class InitCommand extends BaseCommand {
10298 return undefined ;
10399 } ,
104100 } ) ,
105- name : ( ) =>
106- text ( {
107- initialValue : "runner" ,
108- message : "Base name for runners" ,
109- placeholder : "runner" ,
110- } ) ,
101+ name : ( ) => text ( { initialValue : "runner" , message : "Base name for runners" , placeholder : "runner" } ) ,
111102 runners : ( ) =>
112103 text ( {
113104 initialValue : "1" ,
@@ -121,12 +112,13 @@ export class InitCommand extends BaseCommand {
121112 } ,
122113 } ) ,
123114 labels : ( ) =>
124- text ( {
125- message : "Additional labels (comma-separated, optional)" ,
126- placeholder : "self-hosted,macOS,ARM64" ,
127- } ) ,
115+ text ( { message : "Additional labels (comma-separated, optional)" , placeholder : "self-hosted,macOS,ARM64" } ) ,
116+ } ,
117+ {
118+ onCancel : ( ) => {
119+ throw new Cancel ( ) ;
120+ } ,
128121 } ,
129- { onCancel : ( ) => { throw new Cancel ( ) ; } } ,
130122 ) ;
131123
132124 return {
0 commit comments