@fishawack/lab-env 1.6.3 → 1.7.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,8 @@
1
1
  ## Changelog
2
2
 
3
+ ### 1.7.0 (2021-10-13)
4
+ * [Feature] Can now detect and process drupal 9 builds
5
+
3
6
  ### 1.6.3 (2021-09-16)
4
7
  * [Bug] Fixed mySql volume path now syntax has been deprecated
5
8
 
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `lab-env_boilerplate-drupal`;
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('deploy', () => {
10
+ before(function(){
11
+ this.timeout(60000 * 10);
12
+
13
+ execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-drupal _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
+
15
+ execSync('fw setup', opts);
16
+
17
+ execSync('fw prod', opts);
18
+ });
19
+
20
+ it('All boilerplate-drupal tests should pass', async () => {
21
+ expect(execSync('fw test', opts)).to.not.equal(Error);
22
+ });
23
+
24
+ after(() => {
25
+ execSync('fw nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `lab-env_boilerplate-laravel`;
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('deploy', () => {
10
+ before(function(){
11
+ this.timeout(60000 * 10);
12
+
13
+ execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-laravel _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
+
15
+ execSync('fw setup', opts);
16
+
17
+ execSync('fw prod', opts);
18
+ });
19
+
20
+ it('All boilerplate-laravel tests should pass', async () => {
21
+ expect(execSync('fw test', opts)).to.not.equal(Error);
22
+ });
23
+
24
+ after(() => {
25
+ execSync('fw nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `lab-env_boilerplate-wordpress`;
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('deploy', () => {
10
+ before(function(){
11
+ this.timeout(60000 * 10);
12
+
13
+ execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate-wordpress _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
+
15
+ execSync('fw setup', opts);
16
+
17
+ execSync('fw prod', opts);
18
+ });
19
+
20
+ it('All boilerplate-wordpress tests should pass', async () => {
21
+ expect(execSync('fw test', opts)).to.not.equal(Error);
22
+ });
23
+
24
+ after(() => {
25
+ execSync('fw nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
@@ -0,0 +1,29 @@
1
+ 'use strict';
2
+
3
+ const repo = `lab-env_boilerplate`;
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('deploy', () => {
10
+ before(function(){
11
+ this.timeout(60000 * 10);
12
+
13
+ execSync(`git clone git@bitbucket.org:fishawackdigital/boilerplate _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
14
+
15
+ execSync('fw setup', opts);
16
+
17
+ execSync('fw prod', opts);
18
+ });
19
+
20
+ it('All boilerplate tests should pass', async () => {
21
+ expect(execSync('fw test', opts)).to.not.equal(Error);
22
+ });
23
+
24
+ after(() => {
25
+ execSync('fw nuke', opts)
26
+
27
+ execSync(`rm -rf _Test/_fixtures/${repo}`, {encoding: 'utf8', stdio: 'inherit'});
28
+ });
29
+ });
package/cli.js CHANGED
@@ -1,5 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
+ process.env.CWD = process.cwd();
4
+
3
5
  const _ = require('./globals.js');
4
6
 
5
7
  const updateNotifier = require('update-notifier');
@@ -19,9 +21,8 @@ const args = hideBin(process.argv);
19
21
  process.env.PORT = await getPort({port: getPort.makeRange(3000, 3100)});
20
22
  process.env.PORT_OPT = +process.env.PORT + 1;
21
23
  process.env.REPO = _.repo;
22
- process.env.CWD = process.cwd();
23
24
 
24
- if(_.platform === "laravel" || _.platform === "wordpress"){
25
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
25
26
  process.env.PORT_WEB = await getPort({port: getPort.makeRange(8000, 8100)});
26
27
  process.env.PORT_DB = await getPort({port: getPort.makeRange(3306, 3406)});
27
28
  }
@@ -37,7 +38,15 @@ const args = hideBin(process.argv);
37
38
  let commands = ['start', 'watch', 'setup', 'content', 'production', 'test', 'deploy', 'reinstall', 'install', 'uninstall', 'run', 'check', 'clean', 'nuke', 'regenerate', 'connect', 'execute', 'origin', 'npm'];
38
39
 
39
40
  if(_.platform === "laravel"){
40
- commands.push('artisan', 'composer', 'php');
41
+ commands.push('artisan');
42
+ }
43
+
44
+ if(_.platform === "drupal"){
45
+ commands.push('drush');
46
+ }
47
+
48
+ if(_.platform === "laravel" || _.platform === "drupal"){
49
+ commands.push('composer', 'php');
41
50
  }
42
51
 
43
52
  commands.forEach(d => cli.command(...require(`./commands/${d}.js`)));
package/commands/clean.js CHANGED
@@ -9,7 +9,7 @@ module.exports = [
9
9
  argv => {
10
10
  execSync(`${_.docker} ${_.run}c "git clean -xfd node_modules/ 2>/dev/null || true"`, _.opts);
11
11
 
12
- if(_.platform === "laravel"){
12
+ if(_.platform === "laravel" || _.platform === "drupal"){
13
13
  execSync(`${_.docker} ${_.method} php bash -lc "git clean -xfd vendor/ 2>/dev/null || true"`, _.opts);
14
14
  }
15
15
  }
@@ -62,6 +62,10 @@ module.exports.templates = [
62
62
  "name": "boilerplate-laravel",
63
63
  "type": "boilerplate"
64
64
  },
65
+ {
66
+ "name": "boilerplate-drupal",
67
+ "type": "boilerplate"
68
+ },
65
69
  {
66
70
  "name": "sprinkle-base",
67
71
  "type": "framework",
@@ -7,7 +7,7 @@ module.exports = [
7
7
  'deploys the repo',
8
8
  yargs => {},
9
9
  argv => {
10
- if(_.platform === "laravel" || _.platform === "wordpress"){
10
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
11
11
  execSync(`lab-env up -d`, _.opts);
12
12
 
13
13
  // Run deploy.sh directly as other containers need to run not just node/core
@@ -9,19 +9,30 @@ module.exports = [
9
9
  'node_modules'
10
10
  ];
11
11
 
12
- if(_.platform === "laravel" || _.platform === "wordpress"){
12
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
13
13
  volumes.push(
14
14
  'mysql'
15
15
  );
16
16
  }
17
+
18
+ if(_.platform === "drupal"){
19
+ volumes.push(
20
+ 'drupal'
21
+ );
22
+ }
17
23
 
18
24
  if(_.platform === "laravel"){
19
25
  volumes.push(
20
- 'vendor',
21
26
  'redis'
22
27
  );
23
28
  }
24
29
 
30
+ if(_.platform === "laravel" || _.platform === "drupal"){
31
+ volumes.push(
32
+ 'vendor'
33
+ );
34
+ }
35
+
25
36
  console.log(`${volumes.map(d => `${_.repo_safe}_${d}`).join('\n')}`);
26
37
  }
27
38
  ];
@@ -0,0 +1,15 @@
1
+ const _ = require('../globals.js');
2
+
3
+ const execSync = require('child_process').execSync;
4
+
5
+ module.exports = [
6
+ 'drush [command...]',
7
+ 'run drush command',
8
+ yargs => {
9
+ yargs.positional('command', {
10
+ describe: 'command to run',
11
+ default: ''
12
+ });
13
+ },
14
+ argv => execSync(`${_.docker} ${_.method} php bash -lc "vendor/bin/drush ${argv.command.join(' ')}"`, _.opts)
15
+ ];
@@ -9,7 +9,7 @@ module.exports = [
9
9
  argv => {
10
10
  execSync(`${_.docker} ${_.run}c "rm package-lock.json; git clean -xfd node_modules/ 2>/dev/null || true; npm install"`, _.opts);
11
11
 
12
- if(_.platform === "laravel"){
12
+ if(_.platform === "laravel" || _.platform === "drupal"){
13
13
  execSync(`${_.docker} ${_.method} php bash -lc "rm composer.lock; git clean -xfd vendor/ 2>/dev/null || true; composer install"`, _.opts)
14
14
  }
15
15
  }
@@ -9,7 +9,7 @@ module.exports = [
9
9
  argv => {
10
10
  execSync(`${_.docker} ${_.run}c "npm ci || npm i"`, _.opts);
11
11
 
12
- if(_.platform === "laravel"){
12
+ if(_.platform === "laravel" || _.platform === "drupal"){
13
13
  execSync(`${_.docker} ${_.method} php bash -lc "composer install"`, _.opts);
14
14
  }
15
15
  }
package/commands/setup.js CHANGED
@@ -7,7 +7,7 @@ module.exports = [
7
7
  'runs the initial setup',
8
8
  yargs => {},
9
9
  argv => {
10
- if(_.platform === "laravel" || _.platform === "wordpress"){
10
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
11
11
  execSync(`lab-env up -d`, _.opts);
12
12
 
13
13
  // Run setup.sh directly as other containers need to run not just node/core
package/commands/start.js CHANGED
@@ -12,7 +12,7 @@ module.exports = [
12
12
  });
13
13
  },
14
14
  argv => {
15
- if(_.platform === "laravel" || _.platform === "wordpress"){
15
+ if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
16
16
  _.ports();
17
17
 
18
18
  execSync(`lab-env up -d`, _.opts);
@@ -0,0 +1,59 @@
1
+ services:
2
+ mysql:
3
+ image: mysql:5.7
4
+ networks:
5
+ - default
6
+ environment:
7
+ - MYSQL_ROOT_PASSWORD=password
8
+ - MYSQL_DATABASE=${DB_DATABASE}
9
+ - MYSQL_USER=${DB_USERNAME}
10
+ - MYSQL_PASSWORD=${DB_PASSWORD}
11
+ ports:
12
+ - "${PORT_DB:-3306}:3306"
13
+ volumes:
14
+ - mysql:/var/lib/mysql
15
+ nginx:
16
+ image: nginx:1.19
17
+ networks:
18
+ - default
19
+ volumes:
20
+ - $CWD/:/app
21
+ - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
22
+ - $CWD/themes:/app/web/themes
23
+ - $CWD/modules:/app/web/modules
24
+ - $CWD/sites:/app/web/sites
25
+ - $CWD/profiles:/app/web/profiles
26
+ - drupal:/app/web
27
+ ports:
28
+ - "${PORT_WEB:-8000}:80"
29
+ php:
30
+ image: chialab/php:7.3-fpm
31
+ init: true
32
+ working_dir: /app
33
+ networks:
34
+ - default
35
+ env_file:
36
+ - $CWD/.env
37
+ volumes:
38
+ - $CWD/:/app
39
+ - ./php/custom.ini:/usr/local/etc/php/conf.d/custom.ini
40
+ - $CWD/themes:/app/web/themes
41
+ - $CWD/modules:/app/web/modules
42
+ - $CWD/sites:/app/web/sites
43
+ - $CWD/profiles:/app/web/profiles
44
+ - vendor:/app/vendor
45
+ - drupal:/app/web
46
+ core:
47
+ volumes:
48
+ - drupal:/app/web
49
+
50
+ networks:
51
+ default:
52
+ driver: "bridge"
53
+ volumes:
54
+ vendor:
55
+ driver: "local"
56
+ mysql:
57
+ driver: "local"
58
+ drupal:
59
+ driver: "local"
@@ -0,0 +1,37 @@
1
+ server {
2
+ listen 80 default_server;
3
+ listen [::]:80 default_server;
4
+ root /app/web;
5
+
6
+ add_header X-Frame-Options "SAMEORIGIN";
7
+ add_header X-XSS-Protection "1; mode=block";
8
+ add_header X-Content-Type-Options "nosniff";
9
+
10
+ index index.php;
11
+
12
+ charset utf-8;
13
+
14
+ location / {
15
+ try_files $uri $uri/ /index.php?$query_string;
16
+ }
17
+
18
+ location = /favicon.ico { access_log off; log_not_found off; }
19
+ location = /robots.txt { access_log off; log_not_found off; }
20
+
21
+ error_page 404 /index.php;
22
+
23
+ location ~ \.php$ {
24
+ fastcgi_pass php:9000;
25
+ include fastcgi_params;
26
+ fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
27
+ fastcgi_param SCRIPT_NAME $fastcgi_script_name;
28
+ }
29
+
30
+ location ~ \.(bmp|cur|gif|ico|jpe?g|png|svgz?|webp|pdf|dzi)$ {
31
+ add_header Access-Control-Allow-Origin *;
32
+ }
33
+
34
+ location ~ /\.(?!well-known).* {
35
+ deny all;
36
+ }
37
+ }
@@ -0,0 +1 @@
1
+ memory_limit = -1
package/globals.js CHANGED
@@ -30,6 +30,8 @@ try{ wordpress = existsSync(path.join(process.cwd(), 'themes/')); } catch(e){}
30
30
 
31
31
  if(composer && composer.require && composer.require['laravel/framework']){
32
32
  platform = 'laravel';
33
+ } else if(composer && composer.require && composer.require['drupal/core-recommended']){
34
+ platform = 'drupal';
33
35
  } else if(wordpress) {
34
36
  platform = 'wordpress';
35
37
  } else {
@@ -57,6 +59,12 @@ if(platform === 'laravel'){
57
59
  }
58
60
 
59
61
  docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/wordpress/5.7.2/docker-compose.yml -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
62
+ } else if(platform === "drupal"){
63
+ if(!existsSync(path.join(process.cwd(), '.env'))){
64
+ copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
65
+ }
66
+
67
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/drupal/9/docker-compose.yml -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
60
68
  } else {
61
69
  docker = `docker-compose -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
62
70
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@fishawack/lab-env",
3
- "version": "1.6.3",
3
+ "version": "1.7.0",
4
4
  "description": "Docker manager for FW",
5
5
  "main": "cli.js",
6
6
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 0",
7
+ "test": "mocha _Test/*.js --timeout 120s --bail",
8
8
  "preversion": "npm test",
9
9
  "postversion": "git push && git push --tags && npm publish",
10
10
  "postpublish": "git checkout development && git merge master && git push"
@@ -29,5 +29,9 @@
29
29
  "semver": "7.3.4",
30
30
  "update-notifier": "5.1.0",
31
31
  "yargs": "16.2.0"
32
+ },
33
+ "devDependencies": {
34
+ "chai": "4.3.4",
35
+ "mocha": "9.1.2"
32
36
  }
33
37
  }