@@ -2,7 +2,7 @@ import inquirer from 'inquirer';
22import chalk from 'chalk' ;
33import fs from 'fs/promises' ;
44import path from 'path' ;
5- import { scaffoldProject , setupHusky , generateReadmeContent , generateGitignoreContent , runCommand , } from '@stackcode/core' ;
5+ import { scaffoldProject , setupHusky , generateReadmeContent , generateGitignoreContent , runCommand } from '@stackcode/core' ;
66import { t } from '@stackcode/i18n' ;
77export const getInitCommand = ( ) => ( {
88 command : 'init' ,
@@ -14,7 +14,7 @@ export const getInitCommand = () => ({
1414 const answers = await inquirer . prompt ( [
1515 {
1616 type : 'input' , name : 'projectName' , message : t ( 'init.prompt.project_name' ) ,
17- validate : ( input ) => input ? true : t ( 'init.prompt.project_name_error' ) ,
17+ validate : ( input ) => ! ! input || t ( 'init.prompt.project_name_error' ) ,
1818 } ,
1919 {
2020 type : 'input' , name : 'description' , message : t ( 'init.prompt.description' ) ,
@@ -58,37 +58,40 @@ export const getInitCommand = () => ({
5858 description : answers . description ,
5959 authorName : answers . authorName ,
6060 } ;
61- console . log ( chalk . blue ( ` ${ t ( 'init.step.scaffold' ) } ` ) ) ;
62- scaffoldProject ( {
61+ const projectOptions = {
6362 projectPath,
6463 stack : answers . stack ,
6564 features : answers . features ,
6665 replacements,
67- } ) ;
66+ } ;
67+ console . log ( chalk . blue ( ` ${ t ( 'init.step.scaffold' ) } ` ) ) ;
68+ await scaffoldProject ( projectOptions ) ;
6869 if ( answers . features . includes ( 'husky' ) && answers . commitValidation !== undefined ) {
69- const config = { features : { commitValidation : answers . commitValidation } } ;
70+ const config = {
71+ stack : answers . stack ,
72+ features : { commitValidation : answers . commitValidation }
73+ } ;
7074 await fs . writeFile ( path . join ( projectPath , '.stackcoderc.json' ) , JSON . stringify ( config , null , 2 ) ) ;
7175 }
72- console . log ( chalk . blue ( ` ${ t ( 'init.step.readme' ) } ` ) ) ;
76+ console . log ( chalk . blue ( ` ${ t ( 'init.step.readme' ) } ` ) ) ;
7377 const readmeContent = await generateReadmeContent ( ) ;
7478 await fs . writeFile ( path . join ( projectPath , 'README.md' ) , readmeContent ) ;
75- console . log ( chalk . blue ( ` ${ t ( 'init.step.gitignore' ) } ` ) ) ;
76- // CORREÇÃO: Passando a 'stack' selecionada pelo usuário para a função.
77- const gitignoreContent = await generateGitignoreContent ( answers . stack ) ;
79+ console . log ( chalk . blue ( ` ${ t ( 'init.step.gitignore' ) } ` ) ) ;
80+ const gitignoreContent = await generateGitignoreContent ( [ answers . stack ] ) ;
7881 await fs . writeFile ( path . join ( projectPath , '.gitignore' ) , gitignoreContent ) ;
7982 if ( answers . features . includes ( 'husky' ) ) {
80- console . log ( chalk . blue ( ` ${ t ( 'init.step.husky' ) } ` ) ) ;
81- setupHusky ( projectPath ) ;
83+ console . log ( chalk . blue ( ` ${ t ( 'init.step.husky' ) } ` ) ) ;
84+ await setupHusky ( projectPath ) ;
8285 }
83- console . log ( chalk . blue ( ` ${ t ( 'init.step.git' ) } ` ) ) ;
86+ console . log ( chalk . blue ( ` ${ t ( 'init.step.git' ) } ` ) ) ;
8487 await runCommand ( 'git' , [ 'init' ] , { cwd : projectPath } ) ;
85- console . log ( chalk . blue ( ` ${ t ( 'init.step.deps' ) } ` ) ) ;
88+ console . log ( chalk . blue ( ` ${ t ( 'init.step.deps' ) } ` ) ) ;
8689 await runCommand ( 'npm' , [ 'install' ] , { cwd : projectPath } ) ;
8790 console . log ( chalk . gray ( '----------------------------------------------------' ) ) ;
8891 console . log ( chalk . green . bold ( t ( 'init.success.ready' ) ) ) ;
8992 console . log ( chalk . cyan ( `\n${ t ( 'init.success.next_steps' ) } ` ) ) ;
90- console . log ( ` 1. cd ${ answers . projectName } ` ) ;
91- console . log ( ' 2. Open the project in your favorite editor.' ) ;
92- console . log ( ' 3. Start coding! 🎉' ) ;
93+ console . log ( ` 1. cd ${ answers . projectName } ` ) ;
94+ console . log ( ' 2. Open the project in your favorite editor.' ) ;
95+ console . log ( ' 3. Start coding! 🎉' ) ;
9396 } ,
9497} ) ;
0 commit comments