@@ -84,6 +84,22 @@ export async function inputString(
8484
8585 return { ...takeInput }
8686}
87+ export async function inputDescription (
88+ name : string ,
89+ defaults : string ,
90+ optional : boolean ,
91+ message = ""
92+ ) {
93+ const takeInput = await inquirer . prompt ( [
94+ {
95+ type : "input" ,
96+ name,
97+ message,
98+ } ,
99+ ] )
100+
101+ return { ...takeInput }
102+ }
87103
88104export const languageChoice = async function ( ) {
89105 const lang = await inquirer . prompt ( [
@@ -101,14 +117,14 @@ export const languageChoice = async function () {
101117}
102118
103119export const inputType = async function (
104- userName : string ,
120+ name : string ,
105121 choices : Array < string > | string ,
106122 message = ""
107123) {
108124 const takeInput = await inquirer . prompt ( [
109125 {
110126 type : "rawlist" ,
111- name : `${ userName } ` ,
127+ name : `${ name } ` ,
112128 message : message ,
113129 choices :
114130 typeof choices === "string" ? cliConfig . app . choices [ choices ] : choices ,
@@ -118,14 +134,15 @@ export const inputType = async function (
118134 return takeInput
119135}
120136
121- export const confirmation = async function ( ) : Promise < string > {
137+ export const confirmation = async function ( ) {
122138 const r = await inquirer . prompt ( [
123139 {
124140 type : "rawlist" ,
125141 name : "choice" ,
126142 message : `Hey, what do you want ?` ,
127143 choices : [
128144 "create new SAM project" ,
145+ "create custom SAM project" ,
129146 "add components to existing SAM" ,
130147 "add modules to existing SAM" ,
131148 ] ,
@@ -135,16 +152,16 @@ export const confirmation = async function ():Promise<string> {
135152 return r . choice
136153}
137154
138- export const inputNumber = async function ( userName : string , message : string ) {
139- let displayname = userName
155+ export const inputNumber = async function ( name : string , message : string ) {
156+ let displayname = name
140157 if ( message !== undefined ) {
141158 displayname = message
142159 }
143160 const takeInput = await inquirer . prompt ( [
144161 {
145162 type : "input" ,
146163 message : `Please enter the required number of ${ displayname } you want ?` ,
147- name : `${ userName } ` ,
164+ name : `${ name } ` ,
148165 validate : function ( value ) {
149166 const pass = ! isNaN ( value ) && value > 0
150167 if ( pass ) {
@@ -155,7 +172,7 @@ export const inputNumber = async function (userName: string, message: string) {
155172 } ,
156173 ] )
157174
158- return parseInt ( takeInput [ `${ userName } ` ] , 10 )
175+ return parseInt ( takeInput [ `${ name } ` ] , 10 )
159176}
160177
161178export const inputCli = async function (
@@ -184,130 +201,17 @@ export const inputCli = async function (
184201 }
185202 return res
186203}
187- export const password = async function ( userName : string , message = "" ) {
204+ export const password = async function ( name : string , message = "" ) {
188205 const r = await inquirer . prompt ( [
189206 {
190207 type : "password" ,
191208 message : message ,
192- name : userName ,
209+ name : name ,
193210 } ,
194211 ] )
195212 return r
196213}
197214
198- export const samBuilds = async function ( lang : string ) {
199- try {
200- const obj = buildConfig . samConfig
201- const choices = < Record < string , Array < string > > > buildConfig . samConfig . choices
202- const subObj = < Array < Record < string , string > > > buildConfig . samConfig . samBuild
203- let sam : Record < string , Record < string , string > > = await inputCli (
204- obj ,
205- subObj ,
206- ""
207- )
208- const temp : Record < string , Record < string , string > > = { }
209- Object . values ( sam ) . forEach ( ( ele ) => {
210- Object . assign ( temp , ele )
211- } )
212- sam = temp
213- const langs = { language : lang }
214- const no_of_env = await inputNumber ( "no_of_env" , "environments" )
215- const envs : string [ ] = [ ]
216- let steps : Record < string , Array < string > > = { }
217- let stacknames : Record < string , string > = { }
218- const deploymentregion : Record < string , string > = { }
219- let deploymentparameters : Record < string , string > = { }
220- let depBucketNames : Record < string , string > = { }
221-
222- const branches = { branches : [ "main" ] }
223- for ( let i = 1 ; i <= no_of_env ; i ++ ) {
224- const env = await inputString ( `env${ i } ` , "" , false , `Envrionment ${ i } :` )
225- const envName = env [ `env${ i } ` ]
226- envs . push ( envName )
227-
228- const stepsChoice = choices . dev
229- let step = await multichoice (
230- `steps required for ${ envName } environment ` ,
231- stepsChoice ,
232- ""
233- )
234- const steps1 : Record < string , Array < string > > = { }
235- step = Object . keys ( step ) . map ( ( ele ) => {
236- let name : string = ele . replace ( "steps required for " , "" )
237- name = name . replace ( " environment " , "" )
238- steps1 [ name ] = step [ ele ]
239- } )
240-
241- const stackname = await inputString (
242- `${ envName } ` ,
243- "" ,
244- true ,
245-
246- `Stack Name(optional) --> ${ envName } :`
247- )
248- const deploymentbucket = await inputString (
249- `${ envName } ` ,
250- "" ,
251- true ,
252- `Deployment Bucket(optional) --> ${ envName } :`
253- )
254- const regionChoice = choices . deploymentregion
255- const deployment_region = await inputType (
256- `${ envName } ` ,
257- regionChoice ,
258- "Deployment Region"
259- )
260- const deployment_parameter = await inputString (
261- `${ envName } ` ,
262- "" ,
263- true ,
264- `Deployment Parameter(optional) --> ${ envName } :`
265- )
266- steps = { ...steps , ...steps1 }
267-
268- stacknames = { ...stacknames , ...stackname }
269-
270- depBucketNames = {
271- ...depBucketNames ,
272- ...deploymentbucket ,
273- }
274- deploymentregion [ `${ envName } ` ] = deployment_region [ `${ envName } ` ]
275- deploymentparameters = {
276- ...deploymentparameters ,
277- ...deployment_parameter ,
278- }
279- }
280-
281- const deployment_choice = choices . deployment
282- const deploymentEvent = await multichoice (
283- `deploymentevents` ,
284- deployment_choice ,
285- ""
286- )
287- const framework = { framework : "sam" }
288-
289- const result : IroverDeploymentObject = {
290- ...sam ,
291- ...langs ,
292- no_of_env,
293- envs,
294- ...branches ,
295- ...framework ,
296- steps,
297- stackname : { ...stacknames } ,
298- deploymentbucket : {
299- ...depBucketNames ,
300- } ,
301- deploymentregion,
302- deploymentparameters,
303- ...deploymentEvent ,
304- }
305- return result
306- } catch ( error ) {
307- console . log ( error )
308- }
309- }
310-
311215export const samBuild = async ( lang : string ) => {
312216 try {
313217 const { samConfig } = buildConfig
0 commit comments