1+ import type { TOptionsConfig , TOptionsDebugger } from "@/helpers" ;
12import { optionDebugger } from "@/helpers" ;
23import * as prompter from "@clack/prompts" ;
34import { program } from "commander" ;
@@ -10,11 +11,23 @@ import { copyFile, existsSync } from "node:fs";
1011import { fileURLToPath } from "node:url" ;
1112import path , { dirname } from "node:path" ;
1213
14+ //----------------------
15+ // Types
16+ //----------------------
17+ /** @internal @dontexport */
18+ type TOptions = TOptionsConfig & TOptionsDebugger ;
19+
20+ //----------------------
21+ // CLI APP
22+ //----------------------
1323program
1424 . command ( "init" )
25+ . addOption ( optionDebugger ) //TODO: Fix to make it work (Only work in one command at time rn)
1526 . description ( "Init configuration file" )
16- . addOption ( optionDebugger )
17- . action ( async ( ) => {
27+ . action ( async ( options : TOptions ) => {
28+ process . env . DEBUG = options . debugger ? "TRUE" : "FALSE" ;
29+ logging . debug ( "Test debug message" ) ;
30+ logging . debug ( options ) ;
1831 const test = await new StageRunner ( )
1932 . addStep ( {
2033 intro : ( ) => {
@@ -104,9 +117,14 @@ program
104117 const destination = `${ process . cwd ( ) } /${ finalname } ` ;
105118 const templatePath = path . resolve (
106119 dirname ( fileURLToPath ( import . meta. url ) ) ,
107- `./templates/configs/config.${ ext } .hbs`
120+ `.. /templates/configs/config.${ ext } .hbs`
108121 ) ;
109122
123+ logging . debug ( `Template Path: ${ templatePath } ` ) ;
124+
125+ //TODO: Error if it do not exist
126+ logging . debug ( `Template Path Exist: ${ existsSync ( templatePath ) } ` ) ;
127+
110128 if ( existsSync ( destination ) ) {
111129 logging . warn ( "File already exists!" ) ;
112130 const overwrite = await prompter . confirm ( { message : "Overwrite file?" , initialValue : false } ) ;
@@ -119,6 +137,7 @@ program
119137 copyFile ( templatePath , destination , ( err : unknown ) : void => {
120138 if ( err ) logging . error ( err ) ;
121139 } ) ;
140+
122141 prompter . outro ( chalk . bgGreen ( "File created successfully!" ) ) ;
123142 }
124143 } )
@@ -132,3 +151,5 @@ program
132151
133152 process . exit ( 0 ) ;
134153 } ) ;
154+
155+ // program.parse(process.argv);
0 commit comments