@fishawack/lab-env 2.1.0 → 3.1.0

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.
Files changed (38) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/_Test/_fixtures/.gitkeep +0 -0
  3. package/_Test/_helpers/globals.js +10 -0
  4. package/_Test/boilerplate-craftcms.js +4 -4
  5. package/_Test/boilerplate-drupal.js +4 -4
  6. package/_Test/boilerplate-laravel.js +4 -4
  7. package/_Test/boilerplate-wordpress.js +4 -4
  8. package/_Test/boilerplate.js +4 -4
  9. package/_Test/check.js +29 -0
  10. package/_Test/key.js +33 -0
  11. package/_Test/provision.js +33 -0
  12. package/cli.js +6 -6
  13. package/commands/check.js +1 -1
  14. package/commands/create/cmds/dekey.js +72 -0
  15. package/commands/create/cmds/deprovision.js +54 -0
  16. package/commands/create/cmds/diagnose.js +15 -3
  17. package/commands/create/cmds/key.js +96 -0
  18. package/commands/create/cmds/provision.js +120 -0
  19. package/commands/create/libs/aws-cloudfront-auth.js +77 -0
  20. package/commands/create/libs/aws-cloudfront-simple.js +51 -0
  21. package/commands/create/libs/utilities.js +51 -2
  22. package/commands/create/services/aws/cloudfront.js +295 -0
  23. package/commands/create/services/aws/iam.js +170 -0
  24. package/commands/create/services/aws/index.js +25 -0
  25. package/commands/create/services/aws/misc.js +9 -0
  26. package/commands/create/services/aws/s3.js +109 -0
  27. package/commands/create/services/guide.js +13 -0
  28. package/commands/docker/rebuild.js +1 -1
  29. package/commands/execute.js +10 -1
  30. package/core/{0.1.0 → 0.2.0}/Dockerfile +8 -4
  31. package/core/{0.1.0 → 0.2.0}/entrypoint.sh +0 -0
  32. package/core/CHANGELOG.md +4 -0
  33. package/core/package.json +3 -2
  34. package/drupal/9/apache/apache.conf +1 -0
  35. package/drupal/9/docker-compose.yml +1 -1
  36. package/drupal/9/php/Dockerfile +1 -1
  37. package/globals.js +31 -1
  38. package/package.json +16 -5
package/CHANGELOG.md CHANGED
@@ -1,5 +1,30 @@
1
1
  ## Changelog
2
2
 
3
+ ### 3.1.0 (2022-09-08)
4
+ * [Feature] exec command now has the -g flag to prepend the full grunt path
5
+ * [Feature] Diagnosis now has a version number that will prompt for re-run when needed
6
+ * [Change] Bumped core `0.1.0` to `0.2.0`
7
+ * [Bug] rebuild now passes flags after the service
8
+ * [Bug] Specify platform in core build command
9
+ * [Bug] Login to docker during docker before versioning and building images
10
+ * [Misc] Tests now use cli path
11
+
12
+ ### 3.0.0 (2022-09-05)
13
+ * [Feature] Added newly setup AWS accounts to the client prompts on `fw provision`
14
+ * [Feature] Added key/dekey commands
15
+ * [Change] Provisioned environment variables now append client to uniqueify the services created
16
+ * [Change] `fw provision` no longer does two polls to cloudfront to speed up the process
17
+ * [Change] Drupal now defaults to 8.1 php
18
+ * [Bug] Added protocol to www in cloudfront function to ensure redirect works correctly
19
+ * [Bug] Added posiexem to fix M1 chip issue on drupal
20
+
21
+ ### 2.2.0 (2022-08-10)
22
+ * [Feature] Can now skip diagnose in `fw diagnose`
23
+ * [Feature] Can now provision AWS environments using `fw provision`
24
+ * [Change] Now requires node > 16
25
+ * [Change] Auditted npm dependencies
26
+ * [Misc] Added test coverage for new AWS service
27
+
3
28
  ### 2.1.0 (2022-05-27)
4
29
  * [Change] Bumped core `0.0.21` to `0.1.0`
5
30
 
File without changes
@@ -0,0 +1,10 @@
1
+ const fs = require('fs');
2
+ const os = require('os');
3
+ const host = "ftp-fishawack.egnyte.com";
4
+ const creds = JSON.parse(fs.readFileSync(`${os.homedir()}/targets/.ftppass`))[host];
5
+
6
+ module.exports = {
7
+ opts: {encoding: 'utf8', stdio: process.argv.includes('--publish') ? 'pipe' : 'inherit'},
8
+ host,
9
+ creds
10
+ };
@@ -12,17 +12,17 @@ describe('deploy', () => {
12
12
 
13
13
  execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
- execSync('fw setup', opts);
15
+ execSync('node ../../../cli.js setup', opts);
16
16
 
17
- execSync('fw prod', opts);
17
+ execSync('node ../../../cli.js prod', opts);
18
18
  });
19
19
 
20
20
  it(`All ${repo} tests should pass`, async () => {
21
- expect(execSync('fw test', opts)).to.not.equal(Error);
21
+ expect(execSync('node ../../../cli.js test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
24
24
  after(() => {
25
- execSync('fw nuke', opts)
25
+ execSync('node ../../../cli.js nuke', opts)
26
26
 
27
27
  execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
28
  });
@@ -12,17 +12,17 @@ describe('deploy', () => {
12
12
 
13
13
  execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
- execSync('fw setup', opts);
15
+ execSync('node ../../../cli.js setup', opts);
16
16
 
17
- execSync('fw prod', opts);
17
+ execSync('node ../../../cli.js prod', opts);
18
18
  });
19
19
 
20
20
  it(`All ${repo} tests should pass`, async () => {
21
- expect(execSync('fw test', opts)).to.not.equal(Error);
21
+ expect(execSync('node ../../../cli.js test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
24
24
  after(() => {
25
- execSync('fw nuke', opts)
25
+ execSync('node ../../../cli.js nuke', opts)
26
26
 
27
27
  execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
28
  });
@@ -12,17 +12,17 @@ describe('deploy', () => {
12
12
 
13
13
  execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
- execSync('fw setup', opts);
15
+ execSync('node ../../../cli.js setup', opts);
16
16
 
17
- execSync('fw prod', opts);
17
+ execSync('node ../../../cli.js prod', opts);
18
18
  });
19
19
 
20
20
  it(`All ${repo} tests should pass`, async () => {
21
- expect(execSync('fw test', opts)).to.not.equal(Error);
21
+ expect(execSync('node ../../../cli.js test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
24
24
  after(() => {
25
- execSync('fw nuke', opts)
25
+ execSync('node ../../../cli.js nuke', opts)
26
26
 
27
27
  execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
28
  });
@@ -12,17 +12,17 @@ describe('deploy', () => {
12
12
 
13
13
  execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
- execSync('fw setup', opts);
15
+ execSync('node ../../../cli.js setup', opts);
16
16
 
17
- execSync('fw prod', opts);
17
+ execSync('node ../../../cli.js prod', opts);
18
18
  });
19
19
 
20
20
  it(`All ${repo} tests should pass`, async () => {
21
- expect(execSync('fw test', opts)).to.not.equal(Error);
21
+ expect(execSync('node ../../../cli.js test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
24
24
  after(() => {
25
- execSync('fw nuke', opts)
25
+ execSync('node ../../../cli.js nuke', opts)
26
26
 
27
27
  execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
28
  });
@@ -12,17 +12,17 @@ describe('deploy', () => {
12
12
 
13
13
  execSync(`git -C _Test/_fixtures clone git@bitbucket.org:fishawackdigital/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
14
 
15
- execSync('fw setup', opts);
15
+ execSync('node ../../../cli.js setup', opts);
16
16
 
17
- execSync('fw prod', opts);
17
+ execSync('node ../../../cli.js prod', opts);
18
18
  });
19
19
 
20
20
  it(`All ${repo} tests should pass`, async () => {
21
- expect(execSync('fw test', opts)).to.not.equal(Error);
21
+ expect(execSync('node ../../../cli.js test', opts)).to.not.equal(Error);
22
22
  });
23
23
 
24
24
  after(() => {
25
- execSync('fw nuke', opts)
25
+ execSync('node ../../../cli.js nuke', opts)
26
26
 
27
27
  execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
28
  });
package/_Test/check.js ADDED
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `newrepo`;
4
+ const opts = {encoding: 'utf8', stdio: 'inherit', cwd: `_Test/_fixtures/${repo}`};
5
+
6
+ const expect = require('chai').expect;
7
+ const execSync = require('child_process').execSync;
8
+
9
+ describe('check', () => {
10
+ before(function(){
11
+ execSync(`mkdir _Test/_fixtures/${repo} && cd _Test/_fixtures/${repo} && npm init -y`, {encoding: 'utf8', stdio: 'inherit'});
12
+
13
+ execSync('node ../../../cli.js install lodash@4.17.15 query-string@7.1.1', opts);
14
+ });
15
+
16
+ it(`Should flag query-string as non es5 dependency`, () => {
17
+ expect(execSync('node ../../../cli.js check', {cwd: `_Test/_fixtures/${repo}`}).toString()).to.contain('query-string');
18
+ });
19
+
20
+ it(`Should not flag lodash as es5 dependency`, () => {
21
+ expect(execSync('node ../../../cli.js check', {cwd: `_Test/_fixtures/${repo}`}).toString()).to.not.contain('lodash');
22
+ });
23
+
24
+ after(() => {
25
+ execSync('node ../../../cli.js nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
package/_Test/key.js ADDED
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const expect = require('chai').expect;
4
+ const aws = require("../commands/create/services/aws/index.js");
5
+
6
+ describe('key', async () => {
7
+ let account = 'fishawack';
8
+
9
+ before(async () => {
10
+ let res = await aws.iam.createFWIAMUser('fw-test-user', account);
11
+
12
+ // Wait for key as AWS doesn't provide a way to wait for it to becom eactive
13
+ await new Promise(resolve => setTimeout(() => resolve(), 10000));
14
+
15
+ process.env.AWS_ACCESS_KEY_ID = res.AccessKey.AccessKeyId;
16
+ process.env.AWS_SECRET_ACCESS_KEY = res.AccessKey.SecretAccessKey;
17
+ });
18
+
19
+ it('Should be able to access AWS service', async () => {
20
+ let res;
21
+
22
+ try{ res = await aws.s3.listS3Buckets(); } catch(e){ console.log(e.message); }
23
+
24
+ expect(res).to.not.be.undefined;
25
+ });
26
+
27
+ after(async () => {
28
+ delete process.env.AWS_ACCESS_KEY_ID;
29
+ delete process.env.AWS_SECRET_ACCESS_KEY;
30
+
31
+ await aws.iam.removeIAMUser('fw-test-user', account);
32
+ });
33
+ });
@@ -0,0 +1,33 @@
1
+ 'use strict';
2
+
3
+ const expect = require('chai').expect;
4
+ const aws = require("../commands/create/services/aws/index.js");
5
+ var fetch;
6
+
7
+ describe('provision', async () => {
8
+ let config;
9
+ let repo = 'lab-env-test-suite';
10
+ let account = 'fishawack';
11
+
12
+ before(async () => {
13
+ fetch = (await import('node-fetch')).default;
14
+
15
+ config = await aws.static(repo, account);
16
+
17
+ await aws.s3.addFileToS3Bucket(repo, account, 'index.html', new TextEncoder().encode("test"));
18
+ });
19
+
20
+ it('Should provision s3 bucket', async () => {
21
+ expect((await fetch(config.url)).status).to.be.equal(200);
22
+ });
23
+
24
+ after(async () => {
25
+ await aws.s3.removeFileToS3Bucket(repo, account, 'index.html');
26
+
27
+ await aws.s3.removeS3Bucket(repo, account);
28
+
29
+ await aws.cloudfront.removeCloudFrontDistribution(config.cloudfront, account);
30
+
31
+ await aws.cloudfront.removeCloudFrontFunction(repo, account);
32
+ });
33
+ });
package/cli.js CHANGED
@@ -4,10 +4,6 @@ process.env.CWD = process.cwd();
4
4
 
5
5
  const _ = require('./globals.js');
6
6
 
7
- const updateNotifier = require('update-notifier');
8
- const pkg = require('./package.json');
9
- updateNotifier({pkg, updateCheckInterval: 0}).notify();
10
-
11
7
  const execSync = require('child_process').execSync;
12
8
 
13
9
  const yargs = require('yargs/yargs');
@@ -16,9 +12,13 @@ const { hideBin } = require('yargs/helpers');
16
12
  const args = hideBin(process.argv);
17
13
 
18
14
  // Stop here if docker process not running and command isn't version or origin which don't require docker
19
- if(!_.services && !(args[0] === 'origin' || args[0] === '--version')) return;
15
+ if(!_.services && !(args[0] === 'origin' || args[0] === '--version')) process.exit();
20
16
 
21
17
  (async () => {
18
+ const updateNotifier = (await import('update-notifier')).default;
19
+ const pkg = require('./package.json');
20
+ updateNotifier({pkg, updateCheckInterval: 0}).notify();
21
+
22
22
  process.env.REPO = _.repo;
23
23
 
24
24
  await _.ports.set();
@@ -59,7 +59,7 @@ if(!_.services && !(args[0] === 'origin' || args[0] === '--version')) return;
59
59
  ['build', 'config', 'down', 'mocha', 'rebuild', 'up', 'volumes', 'compose'].forEach(d => cli.command(...require(`./commands/docker/${d}.js`)));
60
60
 
61
61
  // Create commands
62
- ['new', 'diagnose', 'delete'].forEach(d => cli.command(...require(`./commands/create/cmds/${d}.js`)));
62
+ ['new', 'provision', 'deprovision', 'diagnose', 'delete', 'key', 'dekey'].forEach(d => cli.command(...require(`./commands/create/cmds/${d}.js`)));
63
63
 
64
64
  cli.demandCommand(1, '')
65
65
  .wrap(null)
package/commands/check.js CHANGED
@@ -13,7 +13,7 @@ module.exports = [
13
13
  });
14
14
  },
15
15
  argv => {
16
- execSync(`${_.docker} ${_.run}c "check-dependencies ${argv.v ? '' : '&>/dev/null'} && echo -e '\\033[0;32mNpm deps OK\\033[0m' || { echo -e '\\033[0;31mNpm deps missing or outdated\\033[0m'; }"`, _.opts);
16
+ execSync(`${_.docker} ${_.run}c "check-dependencies ${argv.v ? '' : '&>/dev/null'} && echo -e '\\033[0;32mNpm deps OK\\033[0m' || { echo -e '\\033[0;31mNpm deps missing or outdated\\033[0m'; } && are-you-es5 check . && echo -e '\\033[0;32mNpm-ES5 compatibility OK\\033[0m' || { echo -e '\\033[0;31mNpm-ES5 incompatibilities detected\\033[0m'; }"`, _.opts);
17
17
 
18
18
  if(_.platform === "laravel" || _.platform === "drupal" || _.platform === "craftcms"){
19
19
  execSync(`${_.docker} ${_.method} php bash -lc "composer install --dry-run ${argv.v ? '' : '2>&1'} | grep -q 'Nothing to install, update or remove' && echo -e '\\033[0;32mComposer deps OK\\033[0m' || echo -e '\\033[0;31mComposer deps missing or outdated\\033[0m'"`, _.opts);
@@ -0,0 +1,72 @@
1
+ const _ = require('../../../globals.js');
2
+ const utilities = require('../libs/utilities');
3
+ const inquirer = require('inquirer');
4
+ const aws = require('../services/aws/index.js');
5
+
6
+ module.exports = [
7
+ 'dekey',
8
+ false,
9
+ yargs => {},
10
+ async argv => {
11
+ let users = [];
12
+ let clients = [];
13
+
14
+ let answer = await inquirer.prompt([
15
+ {
16
+ type: 'confirm',
17
+ name: 'check',
18
+ message: `Remove keys for all users`,
19
+ default: 'Y'
20
+ }
21
+ ]);
22
+
23
+ if(answer.check){
24
+ users = _.config.users.map(d => d.username);
25
+ } else {
26
+ answer = await inquirer.prompt([
27
+ {
28
+ type: 'checkbox',
29
+ name: 'users',
30
+ message: 'Select users',
31
+ choices: _.config.users.map(d => d.username)
32
+ }
33
+ ]);
34
+
35
+ users = answer.users;
36
+ }
37
+
38
+ answer = await inquirer.prompt([
39
+ {
40
+ type: 'confirm',
41
+ name: 'check',
42
+ message: `Remove keys for all clients`,
43
+ default: 'Y'
44
+ }
45
+ ]);
46
+
47
+ if(answer.check){
48
+ clients = aws.clients;
49
+ } else {
50
+ answer = await inquirer.prompt([
51
+ {
52
+ type: 'checkbox',
53
+ name: 'clients',
54
+ message: 'Select clients',
55
+ choices: aws.clients
56
+ }
57
+ ]);
58
+
59
+ clients = answer.clients;
60
+ }
61
+
62
+ for(let i = 0; i < clients.length; i++){
63
+ let client = clients[i];
64
+
65
+ for(let j = 0; j < users.length; j++){
66
+ let user = users[j];
67
+
68
+ await aws.iam.removeIAMUser(`fw-automation-${user}`, client);
69
+ }
70
+ }
71
+ }
72
+ ];
@@ -0,0 +1,54 @@
1
+ const _ = require('../../../globals.js');
2
+ const inquirer = require('inquirer');
3
+ const aws = require('../services/aws/index.js');
4
+ const utilities = require('../libs/utilities');
5
+
6
+ module.exports = [
7
+ ['deprovision', 'deprov'],
8
+ false,
9
+ yargs => {
10
+ yargs.option('branch', {
11
+ alias: 'b',
12
+ describe: 'Branch to configure',
13
+ type: 'string'
14
+ });
15
+ },
16
+ async argv => {
17
+ let branch = argv.branch || _.branch;
18
+
19
+ const answers = await inquirer.prompt([
20
+ {
21
+ type: 'input',
22
+ name: 'id',
23
+ message: 'What is the Id of the CloudFront distribution?',
24
+ validate: (input) => !!input.length
25
+ },
26
+ {
27
+ type: 'list',
28
+ name: 'client',
29
+ message: 'Which AWS account is this deployed too?',
30
+ choices: aws.clients,
31
+ default: 'fishawack'
32
+ }
33
+ ]);
34
+
35
+ let answer = await inquirer.prompt([
36
+ {
37
+ type: 'confirm',
38
+ name: 'check',
39
+ message: `Deprovisioning ${utilities.colorize(aws.slug(_.repo, answers.client, branch), 'error')} from ${utilities.colorize(answers.client, 'error')} AWS account, are you sure you want to continue?`,
40
+ default: false
41
+ }
42
+ ]);
43
+
44
+ if(!answer.check){
45
+ process.exit(1);
46
+ }
47
+
48
+ try { await aws.s3.removeS3Bucket(aws.slug(_.repo, answers.client, branch), answers.client); } catch(e) {}
49
+
50
+ try { await aws.cloudfront.removeCloudFrontDistribution(answers.id, answers.client); } catch(e) {}
51
+
52
+ try { await aws.cloudfront.removeCloudFrontFunction(aws.slug(_.repo, answers.client, branch), answers.client); } catch(e) {}
53
+ }
54
+ ];
@@ -4,6 +4,10 @@ const egnyte = require("../services/egnyte");
4
4
  const gitlab = require("../services/gitlab");
5
5
  const guide = require("../services/guide");
6
6
  const test = require("../services/test");
7
+ const _ = require('../../../globals.js');
8
+ const path = require('path');
9
+ const {writeFileSync} = require('fs');
10
+ const os = require('os');
7
11
 
8
12
  module.exports = [
9
13
  ['diagnose', 'diag'],
@@ -57,9 +61,11 @@ module.exports = [
57
61
  while(!await test.bitbucket() || !await bitbucket.check()){
58
62
  await guide.bitbucket();
59
63
  }
60
-
61
- while(!await test.gitlab() || !await gitlab.check()){
62
- await guide.gitlab();
64
+
65
+ if(!await guide.gitlabSkip()) {
66
+ while(!await test.gitlab() || !await gitlab.check()){
67
+ await guide.gitlab();
68
+ }
63
69
  }
64
70
 
65
71
  const userRepoName = vars.misc.bitbucket.username.split('@')[0].replace(/\./, '-');
@@ -71,6 +77,12 @@ module.exports = [
71
77
 
72
78
  await bitbucket.remove(userRepoName);
73
79
  }
80
+
81
+ // Update diagnosis version in ~/.lab-env config file
82
+ if(_.config.diagnosis !== _.diagnosis){
83
+ _.config.diagnosis = _.diagnosis;
84
+ writeFileSync(path.join(os.homedir(), '', '.lab-env'), JSON.stringify(_.config, null, 4));
85
+ }
74
86
  } catch(e){
75
87
  if(e.message){
76
88
  console.log(`\nError: ${e.message}`);
@@ -0,0 +1,96 @@
1
+ const _ = require('../../../globals.js');
2
+ const utilities = require('../libs/utilities');
3
+ const inquirer = require('inquirer');
4
+ const aws = require('../services/aws/index.js');
5
+
6
+ module.exports = [
7
+ 'key',
8
+ false,
9
+ yargs => {},
10
+ async argv => {
11
+ let users = [];
12
+ let clients = [];
13
+
14
+ let answer = await inquirer.prompt([
15
+ {
16
+ type: 'confirm',
17
+ name: 'check',
18
+ message: `Set keys for all users`,
19
+ default: 'Y'
20
+ }
21
+ ]);
22
+
23
+ if(answer.check){
24
+ users = _.config.users.map(d => d.username);
25
+ } else {
26
+ answer = await inquirer.prompt([
27
+ {
28
+ type: 'checkbox',
29
+ name: 'users',
30
+ message: 'Select users',
31
+ choices: _.config.users.map(d => d.username)
32
+ }
33
+ ]);
34
+
35
+ users = answer.users;
36
+ }
37
+
38
+ answer = await inquirer.prompt([
39
+ {
40
+ type: 'confirm',
41
+ name: 'check',
42
+ message: `Set keys for all clients`,
43
+ default: 'Y'
44
+ }
45
+ ]);
46
+
47
+ if(answer.check){
48
+ clients = aws.clients;
49
+ } else {
50
+ answer = await inquirer.prompt([
51
+ {
52
+ type: 'checkbox',
53
+ name: 'clients',
54
+ message: 'Select clients',
55
+ choices: aws.clients
56
+ }
57
+ ]);
58
+
59
+ clients = answer.clients;
60
+ }
61
+
62
+ let credentials = {};
63
+
64
+ for(let i = 0; i < clients.length; i++){
65
+ let client = clients[i];
66
+
67
+ for(let j = 0; j < users.length; j++){
68
+ let user = users[j];
69
+
70
+ if(!credentials[user]){
71
+ credentials[user] = {};
72
+ }
73
+
74
+ let res = await aws.iam.createFWIAMUser(`fw-automation-${user}`, client);
75
+
76
+ credentials[user][client] = {
77
+ key: res.AccessKey && res.AccessKey.AccessKeyId || res.AccessKeyMetadata[0].AccessKeyId,
78
+ secret: res.AccessKey && res.AccessKey.SecretAccessKey || '** secret **'
79
+ }
80
+ }
81
+ }
82
+
83
+ let output = '';
84
+
85
+ for(var user in credentials){
86
+ output += utilities.colorize(`\n${user}\n`, 'title');
87
+ for(var client in credentials[user]){
88
+ output += `\n[${client}]\n`;
89
+ output += `aws_access_key_id = ${credentials[user][client].key}\n`;
90
+ output += `aws_secret_access_key = ${credentials[user][client].secret}\n`;
91
+ }
92
+ }
93
+
94
+ console.log(output);
95
+ }
96
+ ];