@@ -8,17 +8,11 @@ import * as cliConfig from "../src/cliConfig"
88import * as util from "../src/util"
99const deployment = rover . deployment
1010import * as buildConfig from "../src/buildConfig"
11-
11+ import { createModules , roverADD , listProfiles } from "../src/helper"
1212import {
1313 IroverInput ,
1414 IroveraddComponentInput ,
1515 IroveraddModule ,
16- TroverCLIStackParams ,
17- TroverCLIcurd ,
18- IroverCLIparamModule ,
19- IstackDetails ,
20- IstackDetailsObject ,
21- IroverCLIcurdObject ,
2216 TnestedComponentsObject ,
2317 IroverDeploymentConfig ,
2418 IroverDeploymentObject ,
@@ -27,120 +21,9 @@ import * as child from "child_process"
2721const exec = child . execSync
2822
2923import { version } from "../package.json"
30- async function roverADD ( ) {
31- const app_name = await util . inputString ( "app_name" , "" , false , "App Name" )
32- await rover_helpers . samValidate ( app_name [ "app_name" ] )
33- await rover_helpers . checkFile ( app_name [ "app_name" ] , "yes" )
34- const language = await util . languageChoice ( )
35- const file_name = await exec ( `ls ${ app_name [ "app_name" ] } /*.yaml ` ) . toString ( )
36- const CompStacks = await rover_helpers . checkNested ( file_name )
37- return {
38- appname : app_name ,
39- language : language ,
40- filename : file_name ,
41- compstack : CompStacks ,
42- }
43- }
44- async function CRUDObject ( stackName : string , AppType : string ) {
45- const crud : TroverCLIcurd = { }
46- let StackParams : TroverCLIStackParams = { }
47- let paramModule : IroverCLIparamModule = < IroverCLIparamModule > { }
48- const obj : TroverCLIStackParams = { }
49- let tempObj = { }
5024
51- do {
52- paramModule = < IroverCLIparamModule > ( < unknown > await util . params ( AppType ) )
53- paramModule [ "res" ] [ "resourcetype" ] = "lambda"
54- paramModule [ "res" ] [ "methods" ] . push ( "options" )
55- crud [ paramModule . name ] = paramModule . res
56-
57- obj [ stackName ] = crud
58- tempObj = { ...tempObj , crud }
59- moreStack = await util . moreStack ( "Do you want to add another API ?" )
60- } while ( moreStack !== "No" )
61- StackParams = { ...obj }
62- return StackParams
63- }
64- async function CustomObject ( i : number ) {
65- const customStacks : Record < string , Array < string > > = { }
66- const choice = cliConfig . customizable . components
67- const customstack_name = await util . inputString (
68- `customStackName${ i } ` ,
69- "" ,
70- false ,
71- `Stack ${ i } Name: `
72- )
73- const CustomStacks = await util . multichoice ( "app_type" , choice )
74- customStacks [ customstack_name [ `customStackName${ i } ` ] ] = CustomStacks . app_type
75- return customStacks
76- }
77- async function createModules (
78- app_name : Record < string , string > ,
79- language : string
80- ) {
81- const stack_names : Record < string , string > = { }
82- let customStacks : Record < string , Array < string > > = { }
83- const basecrud = { }
84- let StackParams : TroverCLIStackParams = { }
85- let moreStack : string
86- const stackDetails : IstackDetails = { }
87- const stackname : Record < string , string > = { }
88- let i = 1
89- const obj : TroverCLIStackParams = { }
90- do {
91- const AppType : string = < string > await util . appType ( "Module Type :" )
92- if ( AppType !== "CustomizableModule" ) {
93- stackname [ `stackName${ i } ` ] = `${ AppType } ${ rover_helpers . makeid ( 5 ) } `
94- const stack_name = stackname
95- const stackName : string = stack_name [ `stackName${ i } ` ]
96- if ( AppType === "CRUDModule" ) {
97- StackParams = {
98- ...StackParams ,
99- ...( await CRUDObject ( stackName , AppType ) ) ,
100- }
101- } else {
102- obj [ stackName ] = < Record < string , IroverCLIcurdObject > > basecrud
103- StackParams = { ...obj , ...StackParams }
104- }
105- stack_names [ stack_name [ `stackName${ i } ` ] ] = AppType
106- } else {
107- customStacks = { ...customStacks , ...( await CustomObject ( i ) ) }
108- }
109- moreStack = await util . moreStack ( "Do you want to add one more modules ? " )
110- i ++
111- } while ( moreStack !== "No" )
112- if ( stack_names !== null ) {
113- Object . keys ( stack_names ) . forEach ( ( element ) => {
114- stackDetails [ element ] = < IstackDetailsObject > { }
115- stackDetails [ element ] [ "type" ] = stack_names [ element ]
116- stackDetails [ element ] [ "params" ] = StackParams [ element ]
117- stackDetails [ element ] [ "componentlist" ] = [ ]
118- } )
119- }
120- if ( customStacks !== null ) {
121- Object . keys ( customStacks ) . forEach ( ( element ) => {
122- stackDetails [ element ] = < IstackDetailsObject > { }
123- stackDetails [ element ] [ "type" ] = "Custom"
124- stackDetails [ element ] [ "params" ] = { }
125- stackDetails [ element ] [ "componentlist" ] = customStacks [ element ]
126- } )
127- }
128- const template : IroverInput = {
129- app_name : app_name [ "app_name" ] ,
130- language,
131- stack_details : stackDetails ,
132- }
133- return template
134- }
135- async function listProfiles ( ) {
136- const profiles = exec ( "aws configure list-profiles" ) . toString ( ) . split ( "\n" )
137- if ( profiles [ profiles . length - 1 ] == "" )
138- profiles . splice ( profiles . length - 1 , 1 )
139- return profiles
140- }
14125async function run ( argv : Array < string > ) {
14226 try {
143- //rover_generateSAM.generateSAM(testinput)
14427 if ( rover_helpers . npmrootTest ( ) ) {
14528 const commandError = `rover ${ argv . join (
14629 " "
@@ -245,7 +128,13 @@ async function run(argv: Array<string>) {
245128 const app_name = res [ "appname" ]
246129 const language = res [ "language" ]
247130 const file_name = res [ "filename" ]
248-
131+ const addToExisting = await util . inputString (
132+ "addToExisting" ,
133+ "" ,
134+ false ,
135+ "Add to Existing Module: "
136+ )
137+ console . log ( addToExisting )
249138 const template = < IroveraddModule > (
250139 await createModules ( app_name , language )
251140 )
0 commit comments