@fishawack/lab-env 4.2.1 → 4.3.1

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,25 @@
1
1
  ## Changelog
2
2
 
3
+ ### 4.3.1 (2022-11-14)
4
+ * [Bug] key and dekey can now be run outside of repos
5
+ * [Bug] Use repo_safe for all compose commands
6
+
7
+ ### 4.3.0 (2022-11-09)
8
+ * [Feature] Added newly setup AWS accounts to the client prompts on `fw provision`
9
+ * [Feature] Laravels php and nginx images are now versioned
10
+ * [Feature] Laravel php image now installs composer deps and copys the source code when building the production image
11
+ * [Feature] Laravel nginx image now copys the source code when building the production image
12
+ * [Feature] `fw diagnose` now additionally checks for the presence of `~/.gitconfig`
13
+ * [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
14
+ * [Feature] `fw key` now has instructions in the generated emails
15
+ * [Feature] `fw key` now has its email separated out into a html file for easier coding
16
+ * [Change] Laravels php and nginx images are no longer built but pulled from docker.hub
17
+ * [Change] Laravels php and nginx images contain docker multi step builds to separate out the development from production
18
+ * [Change] Laravel compose file now defines development as the multi step to build
19
+ * [Change] Bumped diagnose version
20
+ * [Bug] Fixed the version expansion on the automatic versioning of images
21
+ * [Bug] Automatic versioning now usess conventional commits
22
+
3
23
  ### 4.2.1 (2022-10-21)
4
24
  * [Bug] `fw new` should pass through docker running check
5
25
 
@@ -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{
@@ -46,6 +46,8 @@ try{
46
46
  repo = path.basename(process.cwd());
47
47
  }
48
48
 
49
+ const repo_safe = repo.replace(/\./g, '');
50
+
49
51
  try{ pkg = require(path.join(process.cwd(), 'package.json')); } catch(e){}
50
52
 
51
53
  try{ composer = require(path.join(process.cwd(), 'composer.json')); } catch(e){}
@@ -81,40 +83,50 @@ const version = pkg && pkg.devDependencies && (pkg.devDependencies['@fishawack/c
81
83
  process.env.VERSION = versions[0];
82
84
  // }
83
85
 
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
+ let linked = false;
88
+ try { require('mocha'); linked = true; } catch(e) {}
89
+
84
90
  var core = `-f ${__dirname}/core/docker-compose.yml`;
85
91
 
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');
92
+ // If locally linked then use locally built compose files to test before publishing onto docker hub
93
+ if(linked){
89
94
  core = `-f ${__dirname}/core/docker-compose-dev.yml ${core}`;
90
- } catch(e) {}
95
+ }
91
96
 
92
97
  if(platform === 'laravel'){
93
98
  if(!existsSync(path.join(process.cwd(), '.env'))){
94
99
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
95
100
  }
96
101
 
97
- docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/laravel/8/docker-compose.yml ${core} -p ${repo}`;
102
+ let container = `-f ${__dirname}/laravel/8/docker-compose.yml`;
103
+
104
+ // If linked locally then use locally built php image
105
+ if(linked){
106
+ container = `-f ${__dirname}/laravel/8/docker-compose-dev.yml ${container}`;
107
+ }
108
+
109
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} ${container} ${core} -p ${repo_safe}`;
98
110
  } else if(platform === 'wordpress'){
99
111
  if(!existsSync(path.join(process.cwd(), '.env'))){
100
112
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
101
113
  }
102
114
 
103
- docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/wordpress/5.7.2/docker-compose.yml ${core} -p ${repo}`;
115
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/wordpress/5.7.2/docker-compose.yml ${core} -p ${repo_safe}`;
104
116
  } else if(platform === "drupal"){
105
117
  if(!existsSync(path.join(process.cwd(), '.env'))){
106
118
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
107
119
  }
108
120
 
109
- docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/drupal/9/docker-compose.yml ${core} -p ${repo}`;
121
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/drupal/9/docker-compose.yml ${core} -p ${repo_safe}`;
110
122
  } else if(platform === "craftcms"){
111
123
  if(!existsSync(path.join(process.cwd(), '.env'))){
112
124
  copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
113
125
  }
114
126
 
115
- docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/craftcms/3/docker-compose.yml ${core} -p ${repo}`;
127
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/craftcms/3/docker-compose.yml ${core} -p ${repo_safe}`;
116
128
  } else {
117
- docker = `docker-compose ${core} -p ${repo}`;
129
+ docker = `docker-compose ${core} -p ${repo_safe}`;
118
130
  }
119
131
 
120
132
  try{
@@ -125,8 +137,8 @@ try{
125
137
  run = `${method} core bash -l`;
126
138
  } catch(e){}
127
139
 
128
- // Always allow diagnose, diag, version, help and origin through
129
- if(args[0] !== 'diag' && args[0] !== 'diagnose' && args[0] !== 'origin' && args[0] !== '--version' && args[0] !== '--help' && args[0] !== 'new'){
140
+ // Always allow commands that don't require a repository through
141
+ if(args[0] !== 'diag' && args[0] !== 'diagnose' && args[0] !== 'origin' && args[0] !== '--version' && args[0] !== '--help' && args[0] !== 'new' && args[0] !== 'key' && args[0] !== 'dekey'){
130
142
  // Stop here if diagnosis either unset or outdated
131
143
  if(!config.diagnosis || semver.diff(config.diagnosis, diagnosis) === 'major'){
132
144
  console.log(`${utilities.colorize(`@fishawack/lab-env`, 'title')} diagnosis is ${utilities.colorize(`outdated`, 'error')}.\n\nRun ${utilities.colorize(`fw diagnose`, 'success')} to reconfigure.`);
@@ -148,7 +160,7 @@ module.exports = {
148
160
  platform,
149
161
  repo,
150
162
  branch,
151
- repo_safe: repo.replace(/\./g, ''),
163
+ repo_safe,
152
164
  pkg,
153
165
  docker,
154
166
  method,
@@ -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.1",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {