@fishawack/lab-env 1.6.3

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 (58) hide show
  1. package/.gitattributes +1 -0
  2. package/CHANGELOG.md +234 -0
  3. package/README.md +197 -0
  4. package/cli.js +71 -0
  5. package/commands/artisan.js +15 -0
  6. package/commands/check.js +16 -0
  7. package/commands/clean.js +16 -0
  8. package/commands/composer.js +15 -0
  9. package/commands/connect.js +15 -0
  10. package/commands/content.js +10 -0
  11. package/commands/create/cmds/delete.js +27 -0
  12. package/commands/create/cmds/diagnose.js +77 -0
  13. package/commands/create/cmds/new.js +48 -0
  14. package/commands/create/libs/prompts.js +60 -0
  15. package/commands/create/libs/utilities.js +50 -0
  16. package/commands/create/libs/vars.js +95 -0
  17. package/commands/create/services/api.js +3 -0
  18. package/commands/create/services/bitbucket.js +92 -0
  19. package/commands/create/services/egnyte.js +31 -0
  20. package/commands/create/services/git.js +31 -0
  21. package/commands/create/services/gitlab.js +30 -0
  22. package/commands/create/services/guide.js +296 -0
  23. package/commands/create/services/test.js +138 -0
  24. package/commands/deploy.js +23 -0
  25. package/commands/docker/build.js +10 -0
  26. package/commands/docker/config.js +10 -0
  27. package/commands/docker/down.js +10 -0
  28. package/commands/docker/mocha.js +10 -0
  29. package/commands/docker/rebuild.js +10 -0
  30. package/commands/docker/up.js +15 -0
  31. package/commands/docker/volumes.js +27 -0
  32. package/commands/execute.js +21 -0
  33. package/commands/install.js +15 -0
  34. package/commands/npm.js +15 -0
  35. package/commands/nuke.js +17 -0
  36. package/commands/origin.js +126 -0
  37. package/commands/php.js +15 -0
  38. package/commands/production.js +10 -0
  39. package/commands/regenerate.js +16 -0
  40. package/commands/reinstall.js +16 -0
  41. package/commands/run.js +25 -0
  42. package/commands/setup.js +27 -0
  43. package/commands/start.js +33 -0
  44. package/commands/test.js +22 -0
  45. package/commands/uninstall.js +15 -0
  46. package/commands/watch.js +20 -0
  47. package/core/0.0.19/Dockerfile +234 -0
  48. package/core/0.0.19/docker-compose.yml +27 -0
  49. package/core/0.0.19/entrypoint.sh +4 -0
  50. package/globals.js +85 -0
  51. package/intercept.sh +37 -0
  52. package/laravel/8/docker-compose.yml +49 -0
  53. package/laravel/8/nginx/nginx.conf +37 -0
  54. package/laravel/8/php/custom.conf +7 -0
  55. package/package.json +33 -0
  56. package/wordpress/5.7.2/apache/.htaccess +25 -0
  57. package/wordpress/5.7.2/apache/uploads.ini +6 -0
  58. package/wordpress/5.7.2/docker-compose.yml +42 -0
@@ -0,0 +1,27 @@
1
+ version: "3.8"
2
+ services:
3
+ core:
4
+ build:
5
+ context: ../../core/${VERSION:-1.0.0}/
6
+ dockerfile: Dockerfile
7
+ image: core:${VERSION:-1.0.0}
8
+ init: true
9
+ tty: true
10
+ volumes:
11
+ - $CWD/:/app
12
+ - $HOME/.gitconfig:/root/.gitconfig
13
+ - $HOME/targets:/root/targets
14
+ - $HOME/.ssh:/root/.ssh
15
+ - node_modules:/app/node_modules
16
+ ports:
17
+ - ${PORT:-3000}:${PORT:-3000}
18
+ - ${PORT_OPT:-3001}:${PORT_OPT:-3001}
19
+ environment:
20
+ - REPO=${REPO:-unknown}
21
+ - PORT=${PORT:-3000}
22
+ - PORT_OPT=${PORT_OPT:-3001}
23
+ - PORT_WEB=${PORT_WEB:-8000}
24
+ - PORT_DB=${PORT_DB:-3306}
25
+ volumes:
26
+ node_modules:
27
+ driver: "local"
@@ -0,0 +1,4 @@
1
+ #!/bin/sh
2
+ chmod 600 /root/.ssh/id_rsa
3
+
4
+ exec "$@"
package/globals.js ADDED
@@ -0,0 +1,85 @@
1
+ const execSync = require('child_process').execSync;
2
+ const path = require('path');
3
+ const { lstatSync, readdirSync, copyFileSync, existsSync } = require('fs');
4
+ const semver = require('semver');
5
+
6
+ const isDirectory = source => lstatSync(source).isDirectory();
7
+ const getDirectories = source => readdirSync(source).map(name => path.join(source, name)).filter(isDirectory);
8
+
9
+ var repo;
10
+ var platform;
11
+ var pkg;
12
+ var composer;
13
+ var docker;
14
+ var method;
15
+ var run;
16
+ var exec;
17
+ var opts = {encoding: 'utf8', stdio: 'inherit', shell: '/bin/bash'};
18
+
19
+ try{
20
+ repo = execSync('basename "$(git rev-parse --show-toplevel)"', {encoding: 'utf8', stdio: 'pipe'}).trim() || path.basename(process.cwd());
21
+ } catch(e){
22
+ repo = path.basename(process.cwd());
23
+ }
24
+
25
+ try{ pkg = require(path.join(process.cwd(), 'package.json')); } catch(e){}
26
+
27
+ try{ composer = require(path.join(process.cwd(), 'composer.json')); } catch(e){}
28
+
29
+ try{ wordpress = existsSync(path.join(process.cwd(), 'themes/')); } catch(e){}
30
+
31
+ if(composer && composer.require && composer.require['laravel/framework']){
32
+ platform = 'laravel';
33
+ } else if(wordpress) {
34
+ platform = 'wordpress';
35
+ } else {
36
+ platform = 'core';
37
+ }
38
+
39
+ const versions = getDirectories(path.resolve(__dirname, './core')).map(d => path.basename(d)).sort((a, b) => semver.lt(a, b));
40
+ const version = pkg && pkg.devDependencies && (pkg.devDependencies['@fishawack/core'] || pkg.devDependencies['@fishawack/config-grunt']);
41
+
42
+ // if(semver.satisfies(version, '<6')){
43
+ // process.env.VERSION = '1.0.0';
44
+ // } else {
45
+ process.env.VERSION = versions[0];
46
+ // }
47
+
48
+ if(platform === 'laravel'){
49
+ if(!existsSync(path.join(process.cwd(), '.env'))){
50
+ copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
51
+ }
52
+
53
+ docker = `docker-compose --env-file ${path.join(process.cwd(), '.env')} -f ${__dirname}/laravel/8/docker-compose.yml -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
54
+ } else if(platform === 'wordpress'){
55
+ if(!existsSync(path.join(process.cwd(), '.env'))){
56
+ copyFileSync(path.join(process.cwd(), '.env.example'), path.join(process.cwd(), '.env'));
57
+ }
58
+
59
+ 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}`;
60
+ } else {
61
+ docker = `docker-compose -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
62
+ }
63
+
64
+ exec = `exec ${process.env.CI_BUILD_ID ? '-T' : ''}`;
65
+ method = execSync(`${docker} ps --services --filter "status=running"`, {encoding: 'utf8'}).trim().length ? exec : 'run --rm --service-ports';
66
+ run = `${method} core bash -l`;
67
+
68
+ module.exports = {
69
+ platform,
70
+ repo,
71
+ repo_safe: repo.replace(/\./g, ''),
72
+ pkg,
73
+ docker,
74
+ method,
75
+ run,
76
+ exec,
77
+ opts,
78
+ ports(){
79
+ console.table({
80
+ core: {port: +process.env.PORT},
81
+ web: {port: +process.env.PORT_WEB},
82
+ mysql: {port: +process.env.PORT_DB}
83
+ });
84
+ }
85
+ };
package/intercept.sh ADDED
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+
3
+ npm(){
4
+ command lab-env npm "$@"
5
+ }
6
+
7
+ composer(){
8
+ command lab-env composer "$@"
9
+ }
10
+
11
+ artisan(){
12
+ command lab-env artisan "$@"
13
+ }
14
+
15
+ php(){
16
+ command lab-env php "$@"
17
+ }
18
+
19
+ chmod(){
20
+ command lab-env exec "chmod $@"
21
+ }
22
+
23
+ chown(){
24
+ command lab-env exec "chown $@"
25
+ }
26
+
27
+ sed(){
28
+ command lab-env exec "sed $@"
29
+ }
30
+
31
+ export -f npm;
32
+ export -f composer;
33
+ export -f artisan;
34
+ export -f php;
35
+ export -f chown;
36
+ export -f chmod;
37
+ export -f sed;
@@ -0,0 +1,49 @@
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
+ ports:
23
+ - "${PORT_WEB:-8000}:80"
24
+ php:
25
+ image: chialab/php:7.3-fpm
26
+ init: true
27
+ working_dir: /app
28
+ networks:
29
+ - default
30
+ volumes:
31
+ - $CWD/:/app
32
+ - ./php/custom.conf:/opt/bitnami/php/etc/custom.conf
33
+ - vendor:/app/vendor
34
+ redis:
35
+ image: redis:alpine
36
+ networks:
37
+ - default
38
+ volumes:
39
+ - redis:/data
40
+ networks:
41
+ default:
42
+ driver: "bridge"
43
+ volumes:
44
+ vendor:
45
+ driver: "local"
46
+ mysql:
47
+ driver: "local"
48
+ redis:
49
+ driver: "local"
@@ -0,0 +1,37 @@
1
+ server {
2
+ listen 80 default_server;
3
+ listen [::]:80 default_server;
4
+ root /app/public;
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,7 @@
1
+ [www]
2
+ user = www-data
3
+ group = www-data
4
+
5
+ listen.owner = www-data
6
+ listen.group = www-data
7
+ listen.mode = 0660
package/package.json ADDED
@@ -0,0 +1,33 @@
1
+ {
2
+ "name": "@fishawack/lab-env",
3
+ "version": "1.6.3",
4
+ "description": "Docker manager for FW",
5
+ "main": "cli.js",
6
+ "scripts": {
7
+ "test": "echo \"Error: no test specified\" && exit 0",
8
+ "preversion": "npm test",
9
+ "postversion": "git push && git push --tags && npm publish",
10
+ "postpublish": "git checkout development && git merge master && git push"
11
+ },
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+ssh://git@bitbucket.org/fishawackdigital/lab-env.git"
15
+ },
16
+ "author": "",
17
+ "license": "ISC",
18
+ "homepage": "https://bitbucket.org/fishawackdigital/lab-env#readme",
19
+ "bin": {
20
+ "lab-env": "./cli.js",
21
+ "fw": "./cli.js"
22
+ },
23
+ "dependencies": {
24
+ "axios": "0.21.1",
25
+ "chalk": "4.1.0",
26
+ "get-port": "5.1.1",
27
+ "inquirer": "8.1.2",
28
+ "ora": "5.4.1",
29
+ "semver": "7.3.4",
30
+ "update-notifier": "5.1.0",
31
+ "yargs": "16.2.0"
32
+ }
33
+ }
@@ -0,0 +1,25 @@
1
+ RewriteEngine on
2
+ RewriteCond %{HTTP:Authorization} ^(.*)
3
+ RewriteRule ^(.*) - [E=HTTP_AUTHORIZATION:%1]
4
+
5
+ RewriteBase /
6
+ RewriteRule ^index\.php$ - [L]
7
+ RewriteCond %{REQUEST_FILENAME} !-f
8
+ RewriteCond %{REQUEST_FILENAME} !-d
9
+ RewriteRule . /index.php [L]
10
+
11
+ # BEGIN WordPress
12
+ # The directives (lines) between "BEGIN WordPress" and "END WordPress" are
13
+ # dynamically generated, and should only be modified via WordPress filters.
14
+ # Any changes to the directives between these markers will be overwritten.
15
+ <IfModule mod_rewrite.c>
16
+ RewriteEngine On
17
+ RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
18
+ RewriteBase /
19
+ RewriteRule ^index\.php$ - [L]
20
+ RewriteCond %{REQUEST_FILENAME} !-f
21
+ RewriteCond %{REQUEST_FILENAME} !-d
22
+ RewriteRule . /index.php [L]
23
+ </IfModule>
24
+
25
+ # END WordPress
@@ -0,0 +1,6 @@
1
+ file_uploads = On
2
+ memory_limit = 500M
3
+ upload_max_filesize = 500M
4
+ post_max_size = 500M
5
+ max_execution_time = 600
6
+
@@ -0,0 +1,42 @@
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
+ wordpress:
16
+ image: wordpress:5.7.2
17
+ networks:
18
+ - default
19
+ environment:
20
+ WORDPRESS_DB_HOST: mysql
21
+ WORDPRESS_DB_USER: ${DB_USERNAME}
22
+ WORDPRESS_DB_PASSWORD: ${DB_PASSWORD}
23
+ WORDPRESS_DB_NAME: ${DB_DATABASE}
24
+ WORDPRESS_CONFIG_EXTRA: |
25
+ define('JWT_AUTH_SECRET_KEY', '${JWT_SECRET}');
26
+ define('JWT_AUTH_CORS_ENABLE',true);
27
+ define('WP_DEBUG',true);
28
+ volumes:
29
+ - $CWD/themes:/var/www/html/wp-content/themes
30
+ - $CWD/plugins:/var/www/html/wp-content/plugins
31
+ - $CWD/uploads:/var/www/html/wp-content/uploads
32
+ - ./apache/uploads.ini:/usr/local/etc/php/conf.d/uploads.ini
33
+ - ./apache/.htaccess:/var/www/html/.htaccess
34
+ ports:
35
+ - "${PORT_WEB:-8000}:80"
36
+
37
+ networks:
38
+ default:
39
+ driver: "bridge"
40
+ volumes:
41
+ mysql:
42
+ driver: "local"