Skip to content

Commit 1da7c41

Browse files
Merge pull request #35 from antstackio/dev
Dev
2 parents 8a03085 + ceae0f2 commit 1da7c41

File tree

7 files changed

+164
-157
lines changed

7 files changed

+164
-157
lines changed

.github/workflows/main.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: Publish Package to NPM
2+
on:
3+
release:
4+
types: [created]
5+
jobs:
6+
build:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Check out code
10+
uses: actions/checkout@v3
11+
# Setup .npmrc file to publish to npm
12+
13+
- name: Setup Node.js environment
14+
uses: actions/setup-node@v3
15+
with:
16+
node-version: '16.x'
17+
registry-url: 'https://registry.npmjs.org'
18+
19+
- name: Install Dependicies
20+
run : npm install
21+
22+
- name: Build
23+
run: npm run build
24+
25+
- name: Publish
26+
run: npm publish
27+
env:
28+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

README.md

Lines changed: 23 additions & 94 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
# ![img](https://lh5.googleusercontent.com/KTsxxY4oI66ejQrBgqLfzHK9eJY4lpZNm8XzyAiPR2WGFoL8hc9hENMT0QyQTzNaNpwgyKdRahFUeGw2HB6wEGMehP8kzY8OW9bLylcKCbxpI_Oev6qmidivhNU_ui8wLEM84-iHigas5nuEu0OxLjU)Overview
1+
# ![Create a sample project](./assets/roverForBright.png)Overview
22

3-
Rover is a backend automation package that generates SAM projects based on user requirements. And deploys SAM project both through CLI and Pipeline. It has a set of predefined modules and components like Auth, CRUD, etc which are commonly used by the system.
3+
Rover is a npm package or CLI-based that generates or updates SAM projects based on predefined modules and components. it also helps in deployment by generating CI/CD pipeline or deploy through CLI in few clicks.
44

5-
Modules are the small functional unit of the project like Email Authentication. Components combine AWS services like Lambda with S3 as Trigger.
5+
Modules are the small functional unit of the project like Email Authentication. Components are combination of AWS services like Lambda with S3 as Trigger.
66

7-
It is designed using typescript and is a CLI-based library that supports Node and Python with a limited set of AWS Services.
7+
It is a CLI-based library that supports Node and Python with a some AWS Services.
88

9-
To Install:
9+
#### To Install:
1010

1111
npm install @rover-tools/cli -g
1212

@@ -17,113 +17,42 @@ To Install:
1717
* Python 3
1818
* AWS SAM CLI
1919

20-
# Features of Rover
2120

22-
In Rover, we have predefined modules, we can select them and create our project or we have options to create custom modules by selecting the components in that module.
2321

24-
### Create New SAM Projects Based on Modules
22+
In Rover, we have predefined modules, we can select them and create our project or we have options to create custom modules by selecting the components in that module.
2523

26-
Rover is a package or CLI-based library that generates SAM projects based on user input. It takes three inputs from the user:
24+
# Usage
2725

28-
* App Name which is of User’s choice.
29-
* App Language is Node and Python
30-
* App Type is a list of predefined modules.
26+
#### Create or Update
3127

3228
```sh
3329
$ rover init
34-
1)Create new SAM project
35-
2)add component to existing SAM
36-
3)add modules to existing SAMAnswer: Create a new SAM projectApp
37-
Name: dgb
38-
Choose your language: Node
39-
Type:1. Email Auth Module: Authentication module using Cognito
40-
2. Customizable:Create your own module
41-
Answer:Email Auth Module: Authentication module using CognitoStack
42-
Name: email
43-
Do you want to add one or more components to module: No
30+
1) create new SAM project
31+
2) add components to existing SAM
32+
3) add modules to existing SAM
4433
```
45-
46-
### Create Custom Modules based on Components
47-
48-
In Rover, we will be defining a module configuration template which is a standard template where the template resources are defined. It will have details of the module:
49-
50-
* The number of stacks.
51-
* Resources in the stack.
52-
* Stack configuration - Policies and Environment variables in JSON.
53-
34+
#### Deploy
5435
```sh
55-
$ rover init
56-
1)Create new SAM project
57-
2)add component to existing SAM
58-
3)add modules to existing SAM
59-
App Name: dgb
60-
Choose your language: Node
61-
Type:Customizable: Create your own moduleStrack
62-
Name: custom
63-
Please select your component: S3_lambda
64-
Do you want to add one or more components to module: No
36+
$ rover deploy
37+
1) generate pipeline
38+
2) cli
39+
3) repository and pipeline
40+
6541
```
42+
**Note**: update and deploy should be done within the SAM project
6643

67-
### Add Components and Modules to Existing SAM
6844

69-
Modules are a small functional unit of the project like Email Authentication. Components combine AWS services like Lambda with S3 as Trigger.
70-
71-
```sh
72-
$ rover init
73-
1)Create new SAM project
74-
2)add component to existing SAM
75-
3)add modules to existing SAMAnswer:add component to existing SAM
76-
App Name: dgb
77-
Choose your language: Node
78-
Select the module to which you want to add the component:emailEmailAuthModule
79-
80-
Please select your components: S3_lambda
81-
Do you want to add one or more components to module: No
82-
```
45+
# Features of Rover
46+
###### Creates new SAM project with predefined Modules and Components
8347

84-
### Deploy SAM projects through CLI and CI/CD Pipeline
48+
###### Adds Components and Modules to Existing SAM
8549

86-
Deploying SAM projects to AWS through CLI and CI/CD Pipeline.
8750

88-
```sh
89-
$  rover deploy
90-
1)repository and pipeline
91-
2)cli
92-
```
51+
###### Generates CI/CD Pipeline in SAM projects
9352

94-
#### Deploying SAM project through CI/CD Pipeline
9553

96-
```sh
97-
Deploy through:repository and pipeline
98-
Name:dgb
99-
App Name:dgbRepo Type:public
100-
Tools:git
101-
Language:js
102-
Framework:sam
103-
Accesskey:[hidden}
104-
Secretkey:[hidden]
105-
Please enter the required number of Environments(dev,test) you want:1
106-
Environment 1:dev
107-
Please select your components:
108-
build,
109-
deploy
110-
Stack Name —> dev:rovertest
111-
Deployment Bucket —>devDeployment Region:ap-south-1
112-
Deployment Parameter —> dev
113-
```
114-
115-
#### Deploying SAM project through CLI
54+
###### Deploys SAM project through CLI
11655

117-
```sh
118-
| $ rover deploy
119-
1)repository and pipeline
120-
2)cli
121-
Deploy through:cli
122-
Stack Name —> rovertest
123-
Deployment Bucket —>devDeployment
124-
Region:ap-south-1
125-
Deployment Parameter —> dev
126-
```
12756

12857
# Keywords
12958

assets/roverForBright.png

37 KB
Loading

bin/index.ts

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
const rover_utilities= require("@rover-tools/engine").rover_utilities;
2-
2+
const rover_config= require("@rover-tools/engine").rover_config;
3+
let fs = require("fs");
34
import * as cliConfig from "../cli-main/cliConfig";
45
import * as util from "../cli-main/util";
56
const deployment= require("@rover-tools/engine").rover_deployment;
@@ -19,7 +20,7 @@ async function run(argv:AnyObject) {
1920
if (argv[0] === "init") {
2021
let editedSam = await util.confirmation();
2122
if (editedSam === "create new SAM project") {
22-
let app_name:object = await util.inputString("app_name","", "App Name:");
23+
let app_name:object = await util.inputString("app_name","",false, "App Name:");
2324
await rover_utilities.checkFile(app_name["app_name"],"no")
2425
let language = await util.languageChoice();
2526
let stack_names: any = {};
@@ -36,11 +37,11 @@ async function run(argv:AnyObject) {
3637
let app_Types: any = [];
3738
let AppType:string = await util.appType("Module Type :");
3839

39-
4040
if (AppType !== "Customizable") {
41-
stackname[`stackName${i}`]=await util.makeid()
41+
stackname[`stackName${i}`]= "rover"+rover_utilities.NumtoAlpabet(i)
4242
let stack_name = stackname
4343
let stackName:string = stack_name[`stackName${i}`];
44+
4445
if (AppType === "CRUD") {
4546
let crud:AnyObject={} ;
4647
let tempObj = {};
@@ -70,7 +71,7 @@ async function run(argv:AnyObject) {
7071
let choice = cliConfig.customizable.choice;
7172
let customstack_name = await util.inputString(
7273
`customStackName${i}`,
73-
"",
74+
"",false,
7475
`Stack ${i} Name: `
7576
);
7677
let CustomStacks = await util.multichoice("app_type", choice);
@@ -88,7 +89,7 @@ async function run(argv:AnyObject) {
8889

8990
} else if (editedSam === "add components to existing SAM") {
9091

91-
let app_name = await util.inputString("app_name","", "App Name");
92+
let app_name = await util.inputString("app_name","",false, "App Name");
9293
await rover_utilities.checkFile(app_name["app_name"],"yes")
9394

9495
let language = await util.languageChoice();
@@ -103,12 +104,10 @@ async function run(argv:AnyObject) {
103104
if (nested) {
104105
let chooseStack = await util.inputType("Select the module to which you want to add the components ", choice);
105106
let selectedchoice = choice.filter((ele) => Object.values(chooseStack).includes(ele));
106-
choice = choice.filter((ele) => ele !== selectedchoice[0]);
107107
let componentChoice = cliConfig.customizable.choice;
108108
let components = await util.multichoice("type", componentChoice);
109109
let path = CompStacks["CompStacks"][selectedchoice[0]];
110110
nestedComponents[selectedchoice[0]] = { ...components, path: path };
111-
112111
template = {
113112
...app_name,
114113
language,
@@ -127,12 +126,10 @@ async function run(argv:AnyObject) {
127126
...Compnents
128127
};
129128
}
130-
if(choiceLength===1 || !nested){
131-
break;
132-
}else{
129+
133130
moreStack = await util.moreStack("Do you want to add one more components to modules ?")
131+
console.log(moreStack)
134132
i++;
135-
}
136133

137134
} while (moreStack !== "No"|| choiceLength===0)
138135

@@ -159,10 +156,14 @@ async function run(argv:AnyObject) {
159156
}
160157
else {
161158
await util.samValidate()
159+
if(fs.existsSync("samconfig.toml")) {
160+
exec("rm -rf samconfig.toml")
161+
162+
}
162163
let filenamearray=(exec("pwd").toString()).split("/")
163164
let file_name = filenamearray[filenamearray.length-1].replace("\n","");
164-
let stack_name = await util.inputString("stack_name","","Stack Name(optional) :")
165-
let bucketName = await util.inputString("name","","Bucket Name(optional) :");
165+
let stack_name = await util.inputString("stack_name","",true,"Stack Name(optional) :")
166+
let bucketName = await util.inputString("name","",true,"Bucket Name(optional) :");
166167
let choice = buildConfig.samConfig.choices.deploymentregion;
167168
let deploymentregion = await util.inputType("Deployment region",choice);
168169
if (bucketName["name"]=="") {
@@ -173,7 +174,7 @@ async function run(argv:AnyObject) {
173174
if (stack_name["stack_name"]=="") {stack_name=file_name+"roverTest"}else{stack_name=stack_name["stack_name"]}
174175
let region=deploymentregion["Deployment region"]
175176

176-
exec("sh " + rover_utilities.npmroot +"/@rover-tools/cli/cli-main/exec.sh "+file_name+" "+stack_name+" "+region+" "+bucketName);
177+
exec("sh " + rover_config.npmroot +"/@rover-tools/cli/cli-main/exec.sh "+file_name+" "+stack_name+" "+region+" "+bucketName);
177178

178179
}
179180
} else {
@@ -187,7 +188,7 @@ async function run(argv:AnyObject) {
187188
console.log("Note: install @rover-tools/cli globally (install @rover-tools/cli -g)")
188189
}
189190
}catch (error) {
190-
console.log("Error: ",error)
191+
console.log("Error: ",error.message)
191192

192193
}
193194
}

0 commit comments

Comments
 (0)