1- import React , { useReducer , useRef } from 'react' ;
1+ import React , { useReducer } from 'react' ;
22import { Box , Text , Newline } from 'ink' ;
33import {
44 InitialProjectConfiguration ,
55 ProjectConfiguration ,
66} from './ProjectState.js' ;
7- import { generateProject } from './generateProject.js' ;
87import { StepDataProvider } from './StepDataProvider.js' ;
98import { StepAuthProvider } from './StepAuthProvider.js' ;
109import { StepResources } from './StepResources.js' ;
1110import { StepInstall } from './StepInstall.js' ;
12- import { useInstallDeps } from './useInstallDeps.js' ;
1311import { StepName } from './StepName.js' ;
12+ import { StepGenerate } from './StepGenerate' ;
13+ import { StepRunInstall } from './StepRunInstall' ;
1414
1515type Props = {
1616 name : string | undefined ;
@@ -61,6 +61,7 @@ const stepReducer = (
6161 case 'generate' :
6262 return {
6363 ...state ,
64+ messages : action . value . messages ,
6465 step : state . installer ? 'run-install' : 'finish' ,
6566 } ;
6667 case 'run-install' :
@@ -80,8 +81,7 @@ export default function App({ name = 'my-admin' }: Props) {
8081 name : sanitizedName ,
8182 step : sanitizedName === name ? 'data-provider' : 'name' ,
8283 } ) ;
83- const helpMessages = useRef ( [ ] ) ;
84- const installDeps = useInstallDeps ( ) ;
84+
8585 const handleSubmit = ( value : any ) => {
8686 dispatch ( { value } ) ;
8787 } ;
@@ -102,17 +102,10 @@ export default function App({ name = 'my-admin' }: Props) {
102102 return < StepInstall onSubmit = { handleSubmit } /> ;
103103 }
104104 if ( state . step === 'generate' ) {
105- generateProject ( state ) . then ( messages => {
106- helpMessages . current = messages ;
107- dispatch ( { } ) ;
108- } ) ;
109- return < Text > Generating your application...</ Text > ;
105+ return < StepGenerate config = { state } onCompleted = { handleSubmit } /> ;
110106 }
111107 if ( state . step === 'run-install' ) {
112- installDeps ( state ) . then ( ( ) => {
113- dispatch ( { } ) ;
114- } ) ;
115- return < Text > Installing dependencies...</ Text > ;
108+ return < StepRunInstall config = { state } onCompleted = { handleSubmit } /> ;
116109 }
117110 return (
118111 < >
@@ -144,7 +137,7 @@ export default function App({ name = 'my-admin' }: Props) {
144137 </ Box >
145138 ) }
146139 < Box marginBottom = { 1 } >
147- { helpMessages . current . map ( ( line , index ) => (
140+ { state . messages . map ( ( line , index ) => (
148141 < Text key = { index } > { line } </ Text >
149142 ) ) }
150143 </ Box >
0 commit comments