cloudmason 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,6 +9,11 @@ Can be used as a command line tool, or in a CI/CD pipeline.
9
9
  - [Important Notes](##important)
10
10
  - [Commands](##commands)
11
11
 
12
+ ## Installation
13
+
14
+ Be sure to use the -g flag to install globally.
15
+
16
+ ``npm install -g cloudmason``
12
17
 
13
18
 
14
19
  ## Quick Start
@@ -18,12 +23,15 @@ Get an Ec2 nodejs app up and running in 4 commands.
18
23
  1. **Prereqs**
19
24
  1. Open an AWS account
20
25
  2. Download and set up the AWS CLI (or just set your AWS credentials with enviroment variables)
21
- 3. Buy a domain to deploy apps to
22
- 4. Run the following command to set up your org:
23
- - `init-org -name MyOrg -region us-east-1`
26
+ 3. Ensure you have a domain to deploy apps to
27
+ 4. Make sure you have nodejs version 18+ installed
28
+ 5. Install the cloudmason CLI
29
+ - `npm install -g cloudmason`
30
+ 6. Run the following command to set up your org:
31
+ - `mason init-org -name MyOrg -region us-east-1`
24
32
  2. **Set up a Local App Template**
25
33
  1. Get a sample nodejs app template:
26
- - `mason starter -p ./myDesktop/MyFirstApp -type asg`
34
+ - `mason starter -p ./myDesktop/MyFirstApp -type asg -l node`
27
35
  3. **Add an App**
28
36
  ```
29
37
  mason new-app -name MyFirstApp -type asg
@@ -31,12 +39,12 @@ mason new-instance -app MyFirstApp -domain myfirstapp.com -region us-east-2 -adm
31
39
  mason update-app -app MyFirstApp -v 1.0 -path ./myDesktop/HelloWorld
32
40
  mason list-apps
33
41
  ```
34
- 4. **Launch it**
42
+ 1. **Launch it**
35
43
  ```
36
44
  mason launch -app MyFirstApp -v 1.0 -domain myfirstapp.com
37
45
  mason inspect -app MyFirstApp -domain myfirstapp.com -boot
38
46
  ```
39
- 5. **Review It**
47
+ 1. **Review It**
40
48
  1. Visit the domain you specified. You'll see a login page.
41
49
  2. Check the email address you specified for a temp password. Use it to log in.
42
50
  3. After logging in, you'll see a "Hello World" page.
@@ -44,8 +52,9 @@ mason inspect -app MyFirstApp -domain myfirstapp.com -boot
44
52
  #### All Together
45
53
 
46
54
  ```
47
- init-org -name MyOrg -region us-east-1
48
- mason starter -p ./myDesktop/MyFirstApp -type asg
55
+ npm install -g cloudmason
56
+ mason init-org -name MyOrg -region us-east-1
57
+ mason starter -p ./myDesktop/MyFirstApp -type asg -l node
49
58
  mason new-app -name MyFirstApp -type asg
50
59
  mason new-instance -app MyFirstApp -domain myfirstapp.com -region us-east-2 -admin me@gmail.com
51
60
  mason update-app -app MyFirstApp -v 1.0 -path ./myDesktop/MyFirstApp
@@ -32,7 +32,6 @@ exports.deployOrgStack = async function(region,params){
32
32
  return result.StackId;
33
33
  } catch (e){
34
34
  if (/AlreadyExistsException/.test(e)){
35
- console.log('Stack exists ' + stackName);
36
35
  return false;
37
36
  } else {
38
37
  throw new Error(e.message)
@@ -28,21 +28,20 @@ exports.main = async function(args){
28
28
  return true;
29
29
  }
30
30
 
31
+ exports.setOrg = async function(args){
32
+ // Set org.txt
33
+ const orgPath = path.resolve(__dirname,'..','org.txt');
34
+ const orgData = `${args.name},${args.region}`;
35
+ fs.writeFileSync(orgPath,orgData,'utf-8')
36
+ console.log('Set org:',orgData)
37
+ return true;
38
+ }
39
+
31
40
 
32
41
  /////////////////////////////////////////
33
42
  ////////////// FUNCS ////////////////////
34
43
  ////////////////////////////////////////
35
44
 
36
- async function bucketExists(bucketName,region){
37
- const client = new S3Client({region});
38
- try {
39
- await client.send(new HeadBucketCommand({ Bucket: bucketName }));
40
- return true;
41
- } catch (e){
42
- return false;
43
- }
44
- }
45
-
46
45
  async function getDefaultVPC(region){
47
46
  const ec2Client = new EC2Client({ region });
48
47
  const response = await ec2Client.send(new DescribeVpcsCommand({ Filters: [{ Name: "isDefault", Values: ["true"] }] }));
@@ -9,7 +9,9 @@ exports.main = function(args){
9
9
 
10
10
  // Resolve Output Path
11
11
  const outputPath = path.resolve(args.p);
12
- const starterPath = `./commands/starters/${args.type}${args.l ? `_${args.l}` : ''}`;
12
+ const starterRelPath = `starters/${args.type}${args.l ? `_${args.l}` : ''}`;
13
+ const starterPath = path.join(__dirname, starterRelPath);
14
+
13
15
 
14
16
  // Copy Directory
15
17
  console.log(`Creating dir ${outputPath}`);
package/main.js CHANGED
@@ -14,6 +14,14 @@ const Commands = {
14
14
  {n: 'region', desc: 'AWS Region for Core Assets. Default us-east-1', r: false}
15
15
  ]
16
16
  },
17
+ 'set-org': {
18
+ desc: "Set an exsiting organization",
19
+ exec: require('./commands/init_org').setOrg,
20
+ args: [
21
+ {n: 'name', desc: 'Unique org Name. Letters only', r: true, pattern: `[A-Za-z]{2,20}`},
22
+ {n: 'region', desc: 'AWS Region for Core Assets. Default us-east-1', r: false}
23
+ ]
24
+ },
17
25
  'new-app': {
18
26
  desc: 'Add a new application',
19
27
  exec: require('./commands/new_app').main,
@@ -128,6 +136,8 @@ const Commands = {
128
136
  }
129
137
 
130
138
  async function main(){
139
+ const nodeVersion = checkNodeVersion();
140
+
131
141
  const orgExists = await readOrgInfo();
132
142
  if (orgExists){
133
143
  console.log(`>>>> ${process.env.orgName} <<<<`);
@@ -186,6 +196,14 @@ async function main(){
186
196
  /////////////////////////////////
187
197
  ////////////////////////////////
188
198
 
199
+ function checkNodeVersion() {
200
+ const requiredVersion = 16;
201
+ const currentVersion = process.version.split('.')[0].replace('v', '');
202
+
203
+ if (parseInt(currentVersion) < requiredVersion) {
204
+ throw new Error(`Node.js version is less than ${requiredVersion}. Current version: ${process.version}`);
205
+ }
206
+ }
189
207
 
190
208
  async function readOrgInfo(){
191
209
  const orgPath = path.resolve(__dirname,'org.txt');
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"cloudmason","version":"1.0.3","description":"","main":"main.js","scripts":{"build":"node build.js"},"bin":{"mason":"./main.js"},"repository":{"type":"git","url":"https://github.com/kai-harvey/secure-saas.git"},"author":"Kai Harvey","license":"ISC","dependencies":{"@aws-sdk/client-acm":"^3.418.0","@aws-sdk/client-auto-scaling":"^3.470.0","@aws-sdk/client-cloudformation":"^3.418.0","@aws-sdk/client-ec2":"^3.416.0","@aws-sdk/client-iam":"^3.418.0","@aws-sdk/client-route-53":"^3.425.0","@aws-sdk/client-s3":"^3.418.0","@aws-sdk/client-ssm":"^3.421.0","adm-zip":"^0.5.10"}}
1
+ {"name":"cloudmason","version":"1.0.5","description":"","main":"main.js","scripts":{"build":"node build.js"},"bin":{"mason":"./main.js"},"repository":{"type":"git","url":"https://github.com/kai-harvey/secure-saas.git"},"author":"Kai Harvey","license":"ISC","dependencies":{"@aws-sdk/client-acm":"^3.418.0","@aws-sdk/client-auto-scaling":"^3.470.0","@aws-sdk/client-cloudformation":"^3.418.0","@aws-sdk/client-ec2":"^3.416.0","@aws-sdk/client-iam":"^3.418.0","@aws-sdk/client-route-53":"^3.425.0","@aws-sdk/client-s3":"^3.418.0","@aws-sdk/client-ssm":"^3.421.0","adm-zip":"^0.5.10"}}