@fishawack/lab-env 4.2.1 → 4.3.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  ## Changelog
2
2
 
3
+ ### 4.3.0 (2022-11-09)
4
+ * [Feature] Added newly setup AWS accounts to the client prompts on `fw provision`
5
+ * [Feature] Laravels php and nginx images are now versioned
6
+ * [Feature] Laravel php image now installs composer deps and copys the source code when building the production image
7
+ * [Feature] Laravel nginx image now copys the source code when building the production image
8
+ * [Feature] `fw diagnose` now additionally checks for the presence of `~/.gitconfig`
9
+ * [Feature] `fw new` will now check for the existence of a prefix in the name before applying it automatically to prevent duplicate framework names in repos
10
+ * [Feature] `fw key` now has instructions in the generated emails
11
+ * [Feature] `fw key` now has its email separated out into a html file for easier coding
12
+ * [Change] Laravels php and nginx images are no longer built but pulled from docker.hub
13
+ * [Change] Laravels php and nginx images contain docker multi step builds to separate out the development from production
14
+ * [Change] Laravel compose file now defines development as the multi step to build
15
+ * [Change] Bumped diagnose version
16
+ * [Bug] Fixed the version expansion on the automatic versioning of images
17
+ * [Bug] Automatic versioning now usess conventional commits
18
+
3
19
  ### 4.2.1 (2022-10-21)
4
20
  * [Bug] `fw new` should pass through docker running check
5
21
 
@@ -16,6 +16,10 @@ module.exports = [
16
16
  async argv => {
17
17
  try{
18
18
  let preset = await guide.preset();
19
+
20
+ while(!await test.gitconfig()){
21
+ await guide.gitconfig();
22
+ };
19
23
 
20
24
  while(!await test.ssh()){
21
25
  await guide.ssh();
@@ -90,4 +94,4 @@ module.exports = [
90
94
  }
91
95
  }
92
96
  }
93
- ];
97
+ ];
@@ -3,6 +3,7 @@ const utilities = require('../libs/utilities');
3
3
  const inquirer = require('inquirer');
4
4
  const aws = require('../services/aws/index.js');
5
5
  const email = require('../services/email.js');
6
+ const htmlEmail = require('fs').readFileSync(`${__dirname}/../templates/credentials.html`, {encoding: 'utf8'});
6
7
 
7
8
  module.exports = [
8
9
  'key',
@@ -107,7 +108,7 @@ module.exports = [
107
108
  output += outputUser;
108
109
 
109
110
  if(sendEmail){
110
- await email.send(_.config.users.find(d => d.username === user).email, 'New AWS Keys', null, outputUser);
111
+ await email.send(_.config.users.find(d => d.username === user).email, 'New AWS Keys', `${htmlEmail}<pre><code>${outputUser.replace(/\n/g, '<br>')}</code></pre>`);
111
112
  }
112
113
  }
113
114
 
@@ -27,8 +27,13 @@ module.exports = [
27
27
  console.log(utilities.colorize(`Template ${answers.template} not a valid template type`, 'error'));
28
28
  return;
29
29
  }
30
-
31
- let name = `${template.prefix ? `${template.prefix}-` : ''}${answers.name}`;
30
+
31
+ let name = answers.name;
32
+
33
+ if(template.prefix && !name.startsWith(template.prefix + '-'))
34
+ {
35
+ name = `${template.prefix}-${name}`;
36
+ }
32
37
 
33
38
  if(/^[a-zA-Z0-9-_.]+$/.test(name)){
34
39
  // Create Remote Repositories
@@ -45,4 +50,4 @@ module.exports = [
45
50
  console.log(utilities.colorize(`Repo name can contain only letters, digits, '_', '-' and '.'`, 'helper'));
46
51
  }
47
52
  }
48
- ];
53
+ ];
@@ -6,7 +6,7 @@ module.exports.iam = require("./iam.js");
6
6
 
7
7
  module.exports.slug = (repo, client, branch) => s3Safe(`${branch}-${repo}-${client}`);
8
8
 
9
- module.exports.clients = ['fishawack', 'abbvie', 'sanofigenzyme', 'gsk', 'janssen', 'astrazeneca', 'ptc', 'jazz', 'pfizer', 'heron', 'novartis', 'training', 'merck', 'acadia', 'travere', 'roche', 'utc', 'bayer', 'alcon', 'uhc'];
9
+ module.exports.clients = ['fishawack', 'abbvie', 'sanofigenzyme', 'gsk', 'janssen', 'astrazeneca', 'ptc', 'jazz', 'pfizer', 'heron', 'novartis', 'training', 'merck', 'acadia', 'travere', 'roche', 'utc', 'bayer', 'alcon', 'uhc', 'chiesi', '3m', 'sarepta', 'ipsen'];
10
10
 
11
11
  module.exports.static = async (name, account, tags = [], credentials = []) => {
12
12
  let s3 = await module.exports.s3.createS3Bucket(name, account, tags);
@@ -322,4 +322,21 @@ module.exports.watertight = async () => {
322
322
  } else {
323
323
  throw('');
324
324
  }
325
- }
325
+ }
326
+
327
+ module.exports.gitconfig = async () => {
328
+ let inputs = await inquirer.prompt([
329
+ {
330
+ type: 'confirm',
331
+ name: 'confirm',
332
+ message: 'Generate git config file?',
333
+ default: true
334
+ }
335
+ ]);
336
+
337
+ if(inputs.confirm){
338
+ writeFileSync(`${homedir()}/.gitconfig`, '');
339
+ } else {
340
+ throw('');
341
+ }
342
+ }
@@ -156,4 +156,16 @@ module.exports.watertight = async () => {
156
156
  } finally{
157
157
  execSync('rm -rf ./.tmp/watertight-node-auto', {stdio: 'pipe'});
158
158
  }
159
- }
159
+ }
160
+
161
+ module.exports.gitconfig = async () => {
162
+ // Check ssh config exists
163
+ let spinner = new utils.Spinner('Looking for .gitconfig file');
164
+
165
+ if (fs.existsSync(`${os.homedir()}/.gitconfig`)) {
166
+ spinner.update('Found \'.gitconfig\' file');
167
+ return true;
168
+ } else {
169
+ spinner.update('Could not find \'.gitconfig\' file', 'fail');
170
+ }
171
+ }
@@ -0,0 +1,23 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>Credentials</title>
8
+ </head>
9
+ <body>
10
+ <h3>Instructions</h3>
11
+
12
+ <p>These keys should be appended to a file called <strong>credentials</strong> found at:</p>
13
+
14
+ <pre><code>~/.aws/credentials</code></pre></p>
15
+
16
+ <p>If this file doesn't exist you can create it with the command:</p>
17
+
18
+ <pre><code>mkdir -p ~/.aws && touch ~/.aws/credentials</code></pre>
19
+
20
+ <h3>Keys</h3>
21
+ <!-- Keys are inserted here in the import script -->
22
+ </body>
23
+ </html>
package/core/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "description": "lab-env docker config for the @fishawack/core npm module",
5
5
  "scripts": {
6
6
  "preversion": "docker login",
7
- "postversion": "mv ./*/ ./$npm_package_version && docker build ./*/ -t fishawack/core:$npm_package_version --platform linux/amd64 -t fishawack/core:latest && docker push fishawack/core:$npm_package_version && docker push fishawack/core:latest && git add . && git commit -m 'Bumped core to $npm_package_version'"
7
+ "postversion": "mv ./*/ ./$npm_package_version && docker build ./*/ -t fishawack/core:$npm_package_version --platform linux/amd64 -t fishawack/core:latest && docker push fishawack/core:$npm_package_version && docker push fishawack/core:latest && git add . && git commit -m \"build: Bumped core to $npm_package_version\""
8
8
  },
9
9
  "author": "Mike Mellor",
10
10
  "license": "ISC"
package/globals.js CHANGED
@@ -25,7 +25,7 @@ var exec;
25
25
  var running;
26
26
  var services;
27
27
  var branch;
28
- var diagnosis = '1.0.0';
28
+ var diagnosis = '1.0.1';
29
29
  var opts = {encoding: 'utf8', stdio: 'inherit', shell: '/bin/bash'};
30
30
 
31
31
  try{
@@ -81,20 +81,30 @@ const version = pkg && pkg.devDependencies && (pkg.devDependencies['@fishawack/c
81
81
  process.env.VERSION = versions[0];
82
82
  // }
83
83
 
84
+ // If dev dep installed, then assume running from npm linked local dev version of lab-env and point to build context rather than docker hub
85
+ let linked = false;
86
+ try { require('mocha'); linked = true; } catch(e) {}
87
+
84
88
  var core = `-f ${__dirname}/core/docker-compose.yml`;
85
89
 
86
- // If dev dep installed, then assume running from npm linked local dev version of lab-env and point to build context rather than docker hub
87
- try {
88
- require('mocha');
90
+ // If locally linked then use locally built compose files to test before publishing onto docker hub
91
+ if(linked){
89
92
  core = `-f ${__dirname}/core/docker-compose-dev.yml ${core}`;
90
- } catch(e) {}
93
+ }
91
94
 
92
95
  if(platform === 'laravel'){
93
96
  if(!existsSync(path.join(process.cwd(), '.env'))){
94
97
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
95
98
  }
96
99
 
97
- docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/laravel/8/docker-compose.yml ${core} -p ${repo}`;
100
+ let container = `-f ${__dirname}/laravel/8/docker-compose.yml`;
101
+
102
+ // If linked locally then use locally built php image
103
+ if(linked){
104
+ container = `-f ${__dirname}/laravel/8/docker-compose-dev.yml ${container}`;
105
+ }
106
+
107
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} ${container} ${core} -p ${repo}`;
98
108
  } else if(platform === 'wordpress'){
99
109
  if(!existsSync(path.join(process.cwd(), '.env'))){
100
110
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
@@ -0,0 +1,11 @@
1
+ services:
2
+ nginx:
3
+ build:
4
+ context: ./nginx/
5
+ dockerfile: Dockerfile
6
+ target: development
7
+ php:
8
+ build:
9
+ context: ./php/
10
+ dockerfile: Dockerfile
11
+ target: development
@@ -15,28 +15,22 @@ services:
15
15
  - mysql:/var/lib/mysql
16
16
  nginx:
17
17
  platform: linux/amd64
18
- image: nginx:1.19
18
+ image: fishawack/lab-env-laravel-8-nginx:latest
19
19
  networks:
20
20
  - default
21
21
  volumes:
22
22
  - $CWD/:/app
23
- - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
24
23
  ports:
25
24
  - "${PORT_WEB:-8000}:80"
26
25
  php:
27
26
  platform: linux/amd64
28
- build:
29
- context: ./php/
30
- dockerfile: Dockerfile
31
- image: lab-env/laravel/8/php:0.0.2
27
+ image: fishawack/lab-env-laravel-8-php:latest
32
28
  init: true
33
29
  working_dir: /app
34
30
  networks:
35
31
  - default
36
32
  volumes:
37
33
  - $CWD/:/app
38
- - ./php/custom.conf:/opt/bitnami/php/etc/custom.conf
39
- - ./php/policy.xml:/etc/ImageMagick-6/policy.xml
40
34
  - vendor:/app/vendor
41
35
  redis:
42
36
  platform: linux/amd64
@@ -0,0 +1,11 @@
1
+ FROM nginx:1.19 AS development
2
+
3
+ MAINTAINER Mike Mellor
4
+
5
+ # Copy nginx conf
6
+ COPY ./nginx.conf /etc/nginx/conf.d/default.conf
7
+
8
+ FROM fishawack/lab-env-laravel-8-nginx:latest AS production
9
+
10
+ # Copy source code into container
11
+ COPY . /app
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "nginx",
3
+ "version": "0.1.0",
4
+ "description": "lab-env docker config for the nginx module",
5
+ "scripts": {
6
+ "preversion": "docker login",
7
+ "postversion": "docker build -t fishawack/lab-env-laravel-8-nginx:$npm_package_version --target development --platform linux/amd64 -t fishawack/lab-env-laravel-8-nginx:latest . && docker push fishawack/lab-env-laravel-8-nginx:$npm_package_version && docker push fishawack/lab-env-laravel-8-nginx:latest && git add . && git commit -m \"build: Bumped fishawack/lab-env-laravel-8-nginx to $npm_package_version\""
8
+ },
9
+ "author": "Mike Mellor",
10
+ "license": "ISC"
11
+ }
@@ -1,4 +1,4 @@
1
- FROM chialab/php:7.4-fpm
1
+ FROM chialab/php:7.4-fpm AS development
2
2
 
3
3
  MAINTAINER Mike Mellor
4
4
 
@@ -6,6 +6,23 @@ MAINTAINER Mike Mellor
6
6
  RUN apt-get update && \
7
7
  apt-get install -y ghostscript
8
8
 
9
+ # Copy php conf
10
+ COPY ./custom.conf /opt/bitnami/php/etc/custom.conf
11
+
12
+ # Copy ImageMagick policy
13
+ COPY ./policy.xml /etc/ImageMagick-6/policy.xml
14
+
9
15
  # Cleanup apt-get install folders
10
16
  RUN apt-get clean && \
11
- rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
17
+ rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
18
+
19
+ FROM fishawack/lab-env-laravel-8-php:latest AS production
20
+
21
+ # Copy source code into container
22
+ COPY . /app
23
+
24
+ # Install composer dependencies
25
+ RUN TEMPFILE=$(mktemp) && \
26
+ curl -o "$TEMPFILE" "https://getcomposer.org/installer" && \
27
+ php <"$TEMPFILE" && \
28
+ ./composer.phar install -d /app --no-dev --no-interaction --no-ansi --optimize-autoloader
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "php",
3
+ "version": "0.3.0",
4
+ "description": "lab-env docker config for the php module",
5
+ "scripts": {
6
+ "preversion": "docker login",
7
+ "postversion": "docker build -t fishawack/lab-env-laravel-8-php:$npm_package_version --target development --platform linux/amd64 -t fishawack/lab-env-laravel-8-php:latest . && docker push fishawack/lab-env-laravel-8-php:$npm_package_version && docker push fishawack/lab-env-laravel-8-php:latest && git add . && git commit -m \"build: Bumped fishawack/lab-env-laravel-8-php to $npm_package_version\""
8
+ },
9
+ "author": "Mike Mellor",
10
+ "license": "ISC"
11
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "4.2.1",
3
+ "version": "4.3.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {