@fishawack/lab-env 3.0.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.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  ## Changelog
2
2
 
3
- ### 3.0.0 (2022-08-17)
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)
4
13
  * [Feature] Added newly setup AWS accounts to the client prompts on `fw provision`
5
14
  * [Feature] Added key/dekey commands
6
15
  * [Change] Provisioned environment variables now append client to uniqueify the services created
@@ -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/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);
@@ -2,15 +2,12 @@ const _ = require('../../../globals.js');
2
2
  const utilities = require('../libs/utilities');
3
3
  const inquirer = require('inquirer');
4
4
  const aws = require('../services/aws/index.js');
5
- const fs = require('fs');
6
- const os = require('os');
7
5
 
8
6
  module.exports = [
9
7
  'dekey',
10
8
  false,
11
9
  yargs => {},
12
10
  async argv => {
13
- let config = JSON.parse(fs.readFileSync(`${os.homedir()}/.lab-env`, {encoding: 'utf8'}));
14
11
  let users = [];
15
12
  let clients = [];
16
13
 
@@ -24,14 +21,14 @@ module.exports = [
24
21
  ]);
25
22
 
26
23
  if(answer.check){
27
- users = config.users.map(d => d.username);
24
+ users = _.config.users.map(d => d.username);
28
25
  } else {
29
26
  answer = await inquirer.prompt([
30
27
  {
31
28
  type: 'checkbox',
32
29
  name: 'users',
33
30
  message: 'Select users',
34
- choices: config.users.map(d => d.username)
31
+ choices: _.config.users.map(d => d.username)
35
32
  }
36
33
  ]);
37
34
 
@@ -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'],
@@ -73,6 +77,12 @@ module.exports = [
73
77
 
74
78
  await bitbucket.remove(userRepoName);
75
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
+ }
76
86
  } catch(e){
77
87
  if(e.message){
78
88
  console.log(`\nError: ${e.message}`);
@@ -2,15 +2,12 @@ const _ = require('../../../globals.js');
2
2
  const utilities = require('../libs/utilities');
3
3
  const inquirer = require('inquirer');
4
4
  const aws = require('../services/aws/index.js');
5
- const fs = require('fs');
6
- const os = require('os');
7
5
 
8
6
  module.exports = [
9
7
  'key',
10
8
  false,
11
9
  yargs => {},
12
10
  async argv => {
13
- let config = JSON.parse(fs.readFileSync(`${os.homedir()}/.lab-env`, {encoding: 'utf8'}));
14
11
  let users = [];
15
12
  let clients = [];
16
13
 
@@ -24,14 +21,14 @@ module.exports = [
24
21
  ]);
25
22
 
26
23
  if(answer.check){
27
- users = config.users.map(d => d.username);
24
+ users = _.config.users.map(d => d.username);
28
25
  } else {
29
26
  answer = await inquirer.prompt([
30
27
  {
31
28
  type: 'checkbox',
32
29
  name: 'users',
33
30
  message: 'Select users',
34
- choices: config.users.map(d => d.username)
31
+ choices: _.config.users.map(d => d.username)
35
32
  }
36
33
  ]);
37
34
 
@@ -8,6 +8,8 @@ const colorize = module.exports.colorize = (str, type) => {
8
8
  switch (type) {
9
9
  case 'success':
10
10
  return chalk.green(str);
11
+ case 'warning':
12
+ return chalk.yellow(str);
11
13
  case 'error':
12
14
  return chalk.red(str);
13
15
  case 'title':
@@ -11,5 +11,5 @@ module.exports = [
11
11
  default: ''
12
12
  });
13
13
  },
14
- argv => execSync(`${_.docker} build ${argv.image} --no-cache`, _.opts)
14
+ argv => execSync(`${_.docker} build --no-cache ${argv.image}`, _.opts)
15
15
  ];
@@ -16,6 +16,15 @@ module.exports = [
16
16
  describe: 'Run with a virtual display',
17
17
  type: 'boolean'
18
18
  });
19
+
20
+ yargs.option('grunt', {
21
+ alias: 'g',
22
+ describe: 'Execute a grunt command',
23
+ type: 'boolean'
24
+ });
19
25
  },
20
- argv => execSync(`${_.docker} ${_.run}c "${argv.d ? 'xvfb-run ' : ''}${argv.command.join(' ')}"`, _.opts)
26
+ argv => {
27
+ const prep = argv.g ? '$grunt ' : ' ';
28
+ execSync(`${_.docker} ${_.run}c "${argv.d ? 'xvfb-run ' : ''}${prep}${argv.command.join(prep)}"`, _.opts)
29
+ }
21
30
  ];
@@ -37,6 +37,9 @@ RUN npm install grunt-cli -g
37
37
  # Install package.json checker
38
38
  RUN npm install check-dependencies -g
39
39
 
40
+ # Install node_modules checker
41
+ RUN npm install are-you-es5 -g
42
+
40
43
  # Install imagemagick
41
44
  RUN apt-get update && apt-get install -y imagemagick
42
45
 
@@ -105,7 +108,7 @@ RUN apt-get update
105
108
 
106
109
  # Specific chrome version
107
110
  # Check available versions here: https://www.ubuntuupdates.org/package/google_chrome/stable/main/base/google-chrome-stable
108
- ARG CHROME_VERSION="87.0.4280.141-1"
111
+ ARG CHROME_VERSION="105.0.5195.102-1"
109
112
  RUN wget --no-verbose -O /tmp/chrome.deb http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_${CHROME_VERSION}_amd64.deb
110
113
  RUN apt install -y /tmp/chrome.deb
111
114
 
@@ -185,10 +188,11 @@ npm(){(\n\
185
188
  sed -i \'s/watchTask: true,/watchTask: true,watchOptions: { usePolling: true },port: process.env.PORT || 3000, ui: {port: +process.env.PORT_OPT || 3001},/g\' $PWD/node_modules/@fishawack/core/_Tasks/options/browserSync.js 2>/dev/null || true\n\
186
189
  sed -i \'s/watchTask: true,/watchTask: true,watchOptions: { usePolling: true },port: process.env.PORT || 3000, ui: {port: +process.env.PORT_OPT || 3001},/g\' $PWD/node_modules/@fishawack/config-grunt/_Tasks/options/browserSync.js 2>/dev/null || true\n\
187
190
  echo "Overwrite webdriver browsers to fix them to specific browser versions"\n\
188
- sed -i \'s/exports.config = {.*/exports.config = { seleniumArgs: { drivers: {chrome: { version: "87.0.4280.88" },firefox: { version: "0.28.0" }} },/\' $PWD/node_modules/@fishawack/core/wdio.conf.js 2>/dev/null || true\n\
189
- sed -i \'s/exports.config = {.*/exports.config = { seleniumArgs: { drivers: {chrome: { version: "87.0.4280.88" },firefox: { version: "0.28.0" }} },/\' $PWD/node_modules/@fishawack/config-grunt/wdio.conf.js 2>/dev/null || true\n\
191
+ sed -i \'s/exports.config = {.*/exports.config = { seleniumArgs: { drivers: {chrome: { version: "105.0.5195.52" },firefox: { version: "0.28.0" }} },/\' $PWD/node_modules/@fishawack/core/wdio.conf.js 2>/dev/null || true\n\
192
+ sed -i \'s/exports.config = {.*/exports.config = { seleniumArgs: { drivers: {chrome: { version: "105.0.5195.52" },firefox: { version: "0.28.0" }} },/\' $PWD/node_modules/@fishawack/config-grunt/wdio.conf.js 2>/dev/null || true\n\
193
+ sed -i \'s/87.0.4280.88/105.0.5195.52/\' $PWD/node_modules/@fishawack/core/wdio.conf.js 2>/dev/null || true\n\
190
194
  sed -i \'s/puppeteer.launch({headless: true}).*/puppeteer.launch({headless: true, args: [ "--no-sandbox", "--disable-setuid-sandbox", "--disable-dev-shm-usage" ]}).then(async browser => {/\' $PWD/node_modules/sprinkle/bin/commands/screenshots.js 2>/dev/null || true\n\
191
- npx --no-install selenium-standalone --singleDriverInstall=chrome install --drivers.chrome.version=87.0.4280.88 2>/dev/null || true\n\
195
+ npx --no-install selenium-standalone --singleDriverInstall=chrome install --drivers.chrome.version=105.0.5195.52 2>/dev/null || true\n\
192
196
  npx --no-install selenium-standalone --singleDriverInstall=firefox install --drivers.firefox.version=0.28.0 2>/dev/null || true\n\
193
197
  export OVERRIDE=true\n\
194
198
  else\n\
File without changes
package/core/CHANGELOG.md CHANGED
@@ -1,4 +1,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 0.2.0 (2022-09-08)
4
+ * [Feature] are-you-es5 dependency now globally installed with npm
5
+ * [Fix] core now points to google-chrome 105 now that 87 is no longer available to download through the image
6
+
3
7
  ### 0.1.0 (2022-05-27)
4
8
  * [Feature] Added aws-cli@2 to core container
package/core/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "core",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "lab-env docker config for the @fishawack/core npm module",
5
5
  "scripts": {
6
- "postversion": "mv ./*/ ./$npm_package_version && docker build ./*/ -t fishawack/core:$npm_package_version -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'"
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
8
  },
8
9
  "author": "Mike Mellor",
9
10
  "license": "ISC"
package/globals.js CHANGED
@@ -1,15 +1,19 @@
1
1
  const execSync = require('child_process').execSync;
2
2
  const path = require('path');
3
- const { lstatSync, readdirSync, copyFileSync, existsSync } = require('fs');
3
+ const { lstatSync, readdirSync, copyFileSync, existsSync, readFileSync } = require('fs');
4
4
  const semver = require('semver');
5
5
  const getPort = require('get-port');
6
6
  const utilities = require('./commands/create/libs/utilities');
7
+ const os = require('os');
8
+ const { hideBin } = require('yargs/helpers');
9
+ const args = hideBin(process.argv);
7
10
 
8
11
  process.env.DIRNAME = __dirname;
9
12
 
10
13
  const isDirectory = source => lstatSync(source).isDirectory();
11
14
  const getDirectories = source => readdirSync(source).map(name => path.join(source, name)).filter(isDirectory);
12
15
 
16
+ var config;
13
17
  var repo;
14
18
  var platform;
15
19
  var pkg;
@@ -21,8 +25,24 @@ var exec;
21
25
  var running;
22
26
  var services;
23
27
  var branch;
28
+ var diagnosis = '1.0.0';
24
29
  var opts = {encoding: 'utf8', stdio: 'inherit', shell: '/bin/bash'};
25
30
 
31
+ try{
32
+ config = JSON.parse(readFileSync(`${os.homedir()}/.lab-env`, {encoding: 'utf8'}));
33
+ } catch(e){
34
+ config = {};
35
+ }
36
+
37
+ if(args[0] !== 'diag' && args[0] !== 'diagnose'){
38
+ if(!config.diagnosis || semver.diff(config.diagnosis, diagnosis) === 'major'){
39
+ console.log(`${utilities.colorize(`@fishawack/lab-env`, 'title')} diagnosis is ${utilities.colorize(`outdated`, 'error')}.\n\nRun ${utilities.colorize(`fw diagnose`, 'success')} to reconfigure.`);
40
+ process.exit(1);
41
+ } else if(semver.diff(config.diagnosis, diagnosis) !== null){
42
+ console.log(`${utilities.colorize(`@fishawack/lab-env`, 'title')} diagnosis is ${utilities.colorize(`outdated`, 'warning')}.\n\nRun ${utilities.colorize(`fw diagnose`, 'success')} to reconfigure.`);
43
+ }
44
+ }
45
+
26
46
  try{
27
47
  branch = process.env.BRANCH || process.env.CI_COMMIT_REF_NAME || require('git-branch').sync();
28
48
  } catch(e){
@@ -117,6 +137,8 @@ try{
117
137
  }
118
138
 
119
139
  module.exports = {
140
+ config,
141
+ diagnosis,
120
142
  services,
121
143
  platform,
122
144
  repo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "3.0.0",
3
+ "version": "3.1.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {