@@ -19,6 +19,7 @@ import { config } from '@/lib/conf.js';
1919import { debug } from '@/lib/debug.js' ;
2020import { type Target , repos } from '@/lib/repos.js' ;
2121import { spinner } from '@/lib/spinner.js' ;
22+ import { match } from 'ts-pattern' ;
2223
2324const parsedCliArgs = program . parse ( process . argv ) ;
2425const outDirPath = Option . fromNullable ( parsedCliArgs . args [ 0 ] ) ;
@@ -30,6 +31,7 @@ if (outDirPath.isNone()) {
3031const options = parsedCliArgs . opts ( ) ;
3132const type = Option . fromNullable ( options . type ) . getOr ( 'web' ) as Target ;
3233
34+ // [NOTE]
3335// We make this option available in the global scope,
3436// so debug() function can access it without the need to pass it
3537// as a parameter everytime we want to use it
@@ -77,21 +79,6 @@ await temporaryDirectoryTask(async (tmpDir) => {
7779spinner . succeed ( ) ;
7880process . chdir ( outDirPath . value ) ;
7981
80- // Init git repository and add first commit
81- if ( ! options . skipGitInit ) {
82- spinner . start ( 'Initializing repository...' ) ;
83-
84- try {
85- await $ `git init` ;
86- await $ `git add .` ;
87- await $ `git commit -m "${ 'feat: initial commit' } "` ;
88- spinner . succeed ( ) ;
89- } catch ( error ) {
90- debug ( 'Failed to initialize git repository' , error ) ;
91- spinner . warn ( 'Unable to run git init, skipping' ) ;
92- }
93- }
94-
9582if ( ! options . skipInstall ) {
9683 spinner . start ( 'Installing dependencies with pnpm...' ) ;
9784
@@ -113,11 +100,30 @@ if (!options.skipInstall) {
113100 } ) ;
114101}
115102
103+ // Init git repository and add first commit
104+ if ( ! options . skipGitInit ) {
105+ spinner . start ( 'Initializing repository...' ) ;
106+
107+ try {
108+ await $ `git init` ;
109+ await $ `git add .` ;
110+ await $ `git commit -m "${ 'feat: initial commit' } "` ;
111+ spinner . succeed ( ) ;
112+ } catch ( error ) {
113+ debug ( 'Failed to initialize git repository' , error ) ;
114+ spinner . warn ( 'Unable to run git init, skipping' ) ;
115+ }
116+ }
117+
116118console . log ( '' ) ;
117119console . log ( chalk . green ( '✅ Project created!' ) ) ;
118120console . log (
119121 `➡️ Run \`${ chalk . grey ( `cd ${ outDirPath . value } ` ) } \` and follow getting started instructions in the README.md` ,
120122) ;
121- if ( type === 'web' ) {
122- console . log ( 'ℹ️ Check https://docs.web.start-ui.com/ for additional guides or details about 🚀 Start UI [web]' ) ;
123- }
123+
124+ // Once the repo template has been copied into
125+ // the disired folder, run target specific scripts
126+ match ( type )
127+ . with ( 'web' , ( ) => import ( '@/target/web/index.js' ) )
128+ . with ( 'native' , ( ) => import ( '@/target/native/index.js' ) )
129+ . exhaustive ( ) ;
0 commit comments