@@ -21,7 +21,12 @@ const getDirectories = async source =>
2121 . map ( dirent => dirent . name ) ;
2222
2323const createIndexFileText = name => {
24- return [ `export * from './${ name } ';` , `export { default } from './${ name } ';` , `` ] . join ( '\n' ) ;
24+ return [
25+ `// === Automatically generated file. Don't edit it. ===` ,
26+ `export * from './${ name } ';` ,
27+ `export { default } from './${ name } ';` ,
28+ `` ,
29+ ] . join ( '\n' ) ;
2530} ;
2631
2732const createComponentFileText = name => {
@@ -99,7 +104,7 @@ const editParentComponentExportFile = async parentComponentName => {
99104 const subComponentNames = await getDirectories ( parentComponentDir ) ;
100105
101106 let texts = [
102- `// 자동으로 생성된 파일입니다. 수정하지 마세요. ` ,
107+ `// === Automatically generated file. Don't edit it. === ` ,
103108 `import _${ parentComponentName } from './${ parentComponentName } ';` ,
104109 ] ;
105110
@@ -159,24 +164,26 @@ const start = async () => {
159164
160165 switch ( type ) {
161166 case 'feature' : {
162- const { pageName , componentName } = await inquirer . prompt ( [
163- createPromptInput ( { name : 'pageName ' , label : 'Page name (camelCase)' } ) ,
167+ const { featureName , componentName } = await inquirer . prompt ( [
168+ createPromptInput ( { name : 'featureName ' , label : 'Feature name (camelCase)' } ) ,
164169 createPromptInput ( {
165170 name : 'componentName' ,
166171 label : 'Component name (PascalCase)' ,
167172 } ) ,
168173 ] ) ;
169174
170- const pageDir = `${ FEATURES_DIR } /${ pageName } ` ;
171- const componentDir = `${ pageDir } /${ componentName } ` ;
175+ const featureDir = `${ FEATURES_DIR } /${ featureName } ` ;
176+ const componentDir = `${ featureDir } /${ componentName } ` ;
172177
178+ // check component dir already exists
173179 if ( fs . existsSync ( componentDir ) ) {
174180 console . log ( `🛑 Component [${ componentName } ] already exists` ) ;
175181 process . exit ( 0 ) ;
176182 }
177183
178- if ( ! fs . existsSync ( pageDir ) ) {
179- fs . mkdirSync ( pageDir , { recursive : true } ) ;
184+ // not found feature dir -> create dir
185+ if ( ! fs . existsSync ( featureDir ) ) {
186+ fs . mkdirSync ( featureDir , { recursive : true } ) ;
180187 }
181188
182189 createComponentAndFileOpen ( componentDir , componentName ) ;
@@ -193,6 +200,7 @@ const start = async () => {
193200
194201 const componentDir = `${ COMPONENT_DIR } /${ componentName } ` ;
195202
203+ // check component dir already exists
196204 if ( fs . existsSync ( componentDir ) ) {
197205 console . log ( `🛑 Component [${ componentName } ] already exists` ) ;
198206 process . exit ( 0 ) ;
@@ -228,6 +236,7 @@ const start = async () => {
228236
229237 const componentDir = `${ COMPONENT_DIR } /${ parentComponentName } /${ componentName } ` ;
230238
239+ // check component dir already exists
231240 if ( fs . existsSync ( componentDir ) ) {
232241 console . log ( `🛑 Component [${ componentName } ] already exists` ) ;
233242 process . exit ( 0 ) ;
@@ -253,7 +262,7 @@ const start = async () => {
253262 const dir = pagePath . split ( '/' ) . slice ( 0 , - 1 ) . join ( '/' ) ;
254263 const nameArray = pagePathInput . split ( '/' ) ;
255264
256- // camelCase 처리
265+ // processing camelCase
257266 let name = nameArray
258267 . reduce ( ( acc , item , i ) => {
259268 if ( i === 0 ) return [ item ] ;
@@ -270,35 +279,33 @@ const start = async () => {
270279 } , [ ] )
271280 . join ( '' ) ;
272281
273- // 페이지 파일 중복 체크
282+ // check page file already exists
274283 if ( fs . existsSync ( pagePath ) ) {
275284 console . log ( `🛑 [${ pagePath } ] already exists` ) ;
276285 process . exit ( 0 ) ;
277286 }
278287
279- // 페이지 스타일 파일 중복 체크
288+ // check page styled file already exists
280289 if ( fs . existsSync ( `${ PAGE_STYLED_DIR } /${ name } PageStyled.ts` ) ) {
281290 console . log ( `🛑 [${ PAGE_STYLED_DIR } /${ name } PageStyled.ts] already exists` ) ;
282291 process . exit ( 0 ) ;
283292 }
284293
285- // 페이지 dir이 없다면 생성
294+ // not found page dir -> create dir
286295 if ( ! fs . existsSync ( dir ) ) {
287296 fs . mkdirSync ( dir , { recursive : true } ) ;
288297 }
289298
290- // 페이지 스타일 dir이 없다면 생성
299+ // not found styled dir -> create dir
291300 if ( ! fs . existsSync ( PAGE_STYLED_DIR ) ) {
292301 fs . mkdirSync ( PAGE_STYLED_DIR , { recursive : true } ) ;
293302 }
294303
295- // 페이지 스타일 파일 생성
296304 fs . writeFileSync (
297305 `${ PAGE_STYLED_DIR } /${ name } PageStyled.ts` ,
298306 createStyledFileText ( capitalize ( name ) + 'Page' ) ,
299307 ) ;
300308
301- // 페이지 파일 생성
302309 fs . writeFileSync ( pagePath , createPageFileText ( name ) ) ;
303310
304311 console . log ( `🎉 Page [${ name } ] created` ) ;
0 commit comments