import { SelectArchetypeStep } from "./SelectArchetypeStep" ; import { SpecifyArchetypeVersionStep } from "./SpecifyArchetypeVersionStep" ; import { SpecifyArtifactIdStep } from "./SpecifyArtifactIdStep" ; import { SpecifyGroupIdStep } from "./SpecifyGroupIdStep" ; import { SpecifyTargetFolderStep } from "./SpecifyTargetFolderStep" ; import { IProjectCreationMetadata , IProjectCreationStep , StepResult } from "./types" ; export const selectArchetypeStep = new SelectArchetypeStep ( ) ; export const specifyArchetypeVersionStep = new SpecifyArchetypeVersionStep ( ) ; export const specifyGroupIdStep = new SpecifyGroupIdStep ( ) ; export const specifyArtifactIdStep = new SpecifyArtifactIdStep ( ) ; export const specifyTargetFolderStep = new SpecifyTargetFolderStep ( ) ; param steps param metadata returns export const runSteps = async ( steps , metadata ) : Promise < boolean > => { for ( let i = 0 ; i < steps . length ; i += 1 ) { steps [ i ] . nextStep = steps [ i + 1 ] ; steps [ i ] . previousStep = steps [ i - 1 ] ; } let step = steps [ 0 ] ; while ( step !== undefined ) { const result = await step . run ( metadata ) ; switch ( result ) { case StepResult . NEXT : step = step . nextStep ; break ; case StepResult . PREVIOUS : step = step . previousStep ; break ; case StepResult . STOP : return false ; default : throw new Error ( "invalid StepResult returned." ) ; } } return true ; } ;