@fishawack/lab-env 1.10.1 → 1.13.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 +19 -0
- package/cli.js +3 -10
- package/commands/create/cmds/diagnose.js +4 -0
- package/commands/create/services/guide.js +16 -0
- package/commands/create/services/test.js +25 -4
- package/commands/docker/compose.js +15 -0
- package/commands/docker/up.js +11 -1
- package/commands/setup.js +1 -8
- package/commands/start.js +3 -10
- package/core/0.0.19/Dockerfile +8 -0
- package/core/0.0.19/docker-compose.yml +1 -0
- package/drupal/9/docker-compose.yml +1 -1
- package/globals.js +42 -8
- package/package.json +2 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,24 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
+
### 1.13.0 (2021-12-03)
|
|
4
|
+
* [Feature] Installed elastic beanstalk cli into the core image
|
|
5
|
+
* [Feature] Core image now mounts the .aws folder
|
|
6
|
+
* [Change] Switched mysql to 8.0.23 for Drupal builds
|
|
7
|
+
|
|
8
|
+
### 1.12.1 (2021-11-26)
|
|
9
|
+
* [Bug] Pass along errors thrown in new _.up function so commands correctly come to a stop when errors are thrown
|
|
10
|
+
|
|
11
|
+
### 1.12.0 (2021-11-17)
|
|
12
|
+
* [Feature] Test for watertight-node-auto access
|
|
13
|
+
* [Feature] Test for multiple ssh keys
|
|
14
|
+
|
|
15
|
+
### 1.11.0 (2021-10-26)
|
|
16
|
+
* [Feature] Show ports on up command if -v flag given
|
|
17
|
+
* [Feature] Added compose command
|
|
18
|
+
* [Change] If ports are already running then grab what they are from docker ps
|
|
19
|
+
* [Change] Show ports on all projects when fw start called
|
|
20
|
+
* [Bug] Fixed typo throwing r is not defined warning
|
|
21
|
+
|
|
3
22
|
### 1.10.1 (2021-10-26)
|
|
4
23
|
* [Feature] Added a script command
|
|
5
24
|
|
package/cli.js
CHANGED
|
@@ -10,22 +10,15 @@ updateNotifier({pkg, updateCheckInterval: 0}).notify();
|
|
|
10
10
|
|
|
11
11
|
const execSync = require('child_process').execSync;
|
|
12
12
|
|
|
13
|
-
const getPort = require('get-port');
|
|
14
|
-
|
|
15
13
|
const yargs = require('yargs/yargs');
|
|
16
14
|
const { hideBin } = require('yargs/helpers');
|
|
17
15
|
|
|
18
16
|
const args = hideBin(process.argv);
|
|
19
17
|
|
|
20
18
|
(async () => {
|
|
21
|
-
process.env.PORT = await getPort({port: getPort.makeRange(3000, 3100)});
|
|
22
|
-
process.env.PORT_OPT = +process.env.PORT + 1;
|
|
23
19
|
process.env.REPO = _.repo;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
process.env.PORT_WEB = await getPort({port: getPort.makeRange(8000, 8100)});
|
|
27
|
-
process.env.PORT_DB = await getPort({port: getPort.makeRange(3306, 3406)});
|
|
28
|
-
}
|
|
20
|
+
|
|
21
|
+
await _.ports.set();
|
|
29
22
|
|
|
30
23
|
try{
|
|
31
24
|
let cli = yargs(args)
|
|
@@ -52,7 +45,7 @@ const args = hideBin(process.argv);
|
|
|
52
45
|
commands.forEach(d => cli.command(...require(`./commands/${d}.js`)));
|
|
53
46
|
|
|
54
47
|
// Docker commands
|
|
55
|
-
['build', 'config', 'down', 'mocha', 'rebuild', 'up', 'volumes'].forEach(d => cli.command(...require(`./commands/docker/${d}.js`)));
|
|
48
|
+
['build', 'config', 'down', 'mocha', 'rebuild', 'up', 'volumes', 'compose'].forEach(d => cli.command(...require(`./commands/docker/${d}.js`)));
|
|
56
49
|
|
|
57
50
|
// Create commands
|
|
58
51
|
['new', 'diagnose', 'delete'].forEach(d => cli.command(...require(`./commands/create/cmds/${d}.js`)));
|
|
@@ -293,4 +293,20 @@ module.exports.key = async () => {
|
|
|
293
293
|
} else {
|
|
294
294
|
throw('');
|
|
295
295
|
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
module.exports.watertight = async () => {
|
|
299
|
+
let inputs = await inquirer.prompt([
|
|
300
|
+
{
|
|
301
|
+
type: 'confirm',
|
|
302
|
+
name: 'confirm',
|
|
303
|
+
message: 'Re-run watertight check? (ensure your ssh key is uploaded to bitbucket)',
|
|
304
|
+
default: true
|
|
305
|
+
}
|
|
306
|
+
]);
|
|
307
|
+
|
|
308
|
+
if(inputs.confirm){
|
|
309
|
+
} else {
|
|
310
|
+
throw('');
|
|
311
|
+
}
|
|
296
312
|
}
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
const os = require('os');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
+
const glob = require("glob");
|
|
3
4
|
|
|
4
5
|
const utils = require('../libs/utilities');
|
|
5
6
|
const vars = require('../libs/vars');
|
|
7
|
+
const { execSync, exec } = require('child_process');
|
|
6
8
|
|
|
7
9
|
module.exports.targets = async () => {
|
|
8
10
|
// Check targets folder exists
|
|
@@ -127,12 +129,31 @@ module.exports.ssh = async () => {
|
|
|
127
129
|
|
|
128
130
|
module.exports.key = async () => {
|
|
129
131
|
// Check misc.json exists
|
|
130
|
-
let spinner = new utils.Spinner('Looking for id_rsa
|
|
131
|
-
|
|
132
|
+
let spinner = new utils.Spinner('Looking for id_rsa key in .ssh');
|
|
133
|
+
|
|
132
134
|
if (fs.existsSync(`${os.homedir()}/.ssh/id_rsa`)) {
|
|
133
|
-
spinner.update('Found \'id_rsa\'
|
|
135
|
+
spinner.update('Found \'id_rsa\' key');
|
|
136
|
+
return true;
|
|
137
|
+
} else if (glob.sync(`${os.homedir()}/.ssh/**/*.pub`).length) {
|
|
138
|
+
spinner.update('Found multiple ssh keys');
|
|
134
139
|
return true;
|
|
135
140
|
} else {
|
|
136
|
-
spinner.update('Could not find \'id_rsa\'
|
|
141
|
+
spinner.update('Could not find \'id_rsa\' key', 'fail');
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
module.exports.watertight = async () => {
|
|
146
|
+
// Check misc.json exists
|
|
147
|
+
let spinner = new utils.Spinner('Testing access to watertight-node-auto repository');
|
|
148
|
+
|
|
149
|
+
try{
|
|
150
|
+
!await new Promise((resolve, reject) => exec('git clone --bare git@bitbucket.org:fishawackdigital/watertight-node-auto ./.tmp/watertight-node-auto', (error, stdout, stderr) => (error) ? reject(error) : resolve()));
|
|
151
|
+
|
|
152
|
+
spinner.update('Successfully accessed watertight-node-auto repository');
|
|
153
|
+
return true;
|
|
154
|
+
} catch(e){
|
|
155
|
+
spinner.update('Could not access watertight-node-auto repository', 'fail');
|
|
156
|
+
} finally{
|
|
157
|
+
execSync('rm -rf ./.tmp/watertight-node-auto', {stdio: 'pipe'});
|
|
137
158
|
}
|
|
138
159
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const _ = require('../../globals.js');
|
|
2
|
+
|
|
3
|
+
const execSync = require('child_process').execSync;
|
|
4
|
+
|
|
5
|
+
module.exports = [
|
|
6
|
+
'compose [command...]',
|
|
7
|
+
false,
|
|
8
|
+
yargs => {
|
|
9
|
+
yargs.positional('command', {
|
|
10
|
+
describe: 'command to run',
|
|
11
|
+
default: ''
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
argv => execSync(`${_.docker} ${argv.command.join(' ')}`, _.opts)
|
|
15
|
+
];
|
package/commands/docker/up.js
CHANGED
|
@@ -10,6 +10,16 @@ module.exports = [
|
|
|
10
10
|
describe: 'flags to pass',
|
|
11
11
|
default: ''
|
|
12
12
|
});
|
|
13
|
+
|
|
14
|
+
yargs.option('verbose', {
|
|
15
|
+
alias: 'v',
|
|
16
|
+
describe: 'Show breakdown of packages',
|
|
17
|
+
type: 'boolean'
|
|
18
|
+
});
|
|
13
19
|
},
|
|
14
|
-
argv =>
|
|
20
|
+
argv => {
|
|
21
|
+
if(argv.v) _.ports.get();
|
|
22
|
+
|
|
23
|
+
execSync(`${_.docker} up ${argv.flags.join(' ')}`, _.opts);
|
|
24
|
+
}
|
|
15
25
|
];
|
package/commands/setup.js
CHANGED
|
@@ -8,14 +8,7 @@ module.exports = [
|
|
|
8
8
|
yargs => {},
|
|
9
9
|
argv => {
|
|
10
10
|
if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
|
|
11
|
-
_.up(
|
|
12
|
-
() => execSync(`source ${__dirname}/../intercept.sh && /bin/bash ./_Scripts/setup.sh`, _.opts),
|
|
13
|
-
e => {
|
|
14
|
-
if(e.status !== 130 && e.status !== 131 && e.status !== 1){
|
|
15
|
-
console.log(e.message);
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
);
|
|
11
|
+
_.up(() => execSync(`source ${__dirname}/../intercept.sh && /bin/bash ./_Scripts/setup.sh`, _.opts));
|
|
19
12
|
} else {
|
|
20
13
|
execSync(`${_.docker} ${_.run}c "npm run setup"`, _.opts);
|
|
21
14
|
}
|
package/commands/start.js
CHANGED
|
@@ -12,17 +12,10 @@ module.exports = [
|
|
|
12
12
|
});
|
|
13
13
|
},
|
|
14
14
|
argv => {
|
|
15
|
+
_.ports.get();
|
|
16
|
+
|
|
15
17
|
if(_.platform === "laravel" || _.platform === "wordpress" || _.platform === "drupal"){
|
|
16
|
-
_.
|
|
17
|
-
|
|
18
|
-
_.up(
|
|
19
|
-
() => execSync(`${_.docker} ${_.exec} core bash -lc "npm start -- -- ${argv.flags.join(' ')}" 2>/dev/null`, _.opts),
|
|
20
|
-
e => {
|
|
21
|
-
if(e.status !== 130 && e.status !== 131 && e.status !== 1){
|
|
22
|
-
console.log(e);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
);
|
|
18
|
+
_.up(() => execSync(`${_.docker} ${_.exec} core bash -lc "npm start -- -- ${argv.flags.join(' ')}" 2>/dev/null`, _.opts));
|
|
26
19
|
} else {
|
|
27
20
|
execSync(`${_.docker} ${_.run}c "npm start -- -- ${argv.flags.join(' ')}" 2>/dev/null`, _.opts);
|
|
28
21
|
}
|
package/core/0.0.19/Dockerfile
CHANGED
|
@@ -129,6 +129,13 @@ RUN apt-get install -y dos2unix
|
|
|
129
129
|
|
|
130
130
|
RUN apt-get install -y locales
|
|
131
131
|
|
|
132
|
+
# Install AWS Elastic Beanstalk cli
|
|
133
|
+
RUN apt-get install -y zlib1g-dev libssl-dev libncurses-dev libffi-dev libsqlite3-dev libreadline-dev libbz2-dev
|
|
134
|
+
|
|
135
|
+
RUN git clone https://github.com/aws/aws-elastic-beanstalk-cli-setup.git
|
|
136
|
+
RUN ./aws-elastic-beanstalk-cli-setup/scripts/bundled_installer
|
|
137
|
+
RUN rm -rf ./aws-elastic-beanstalk-cli-setup
|
|
138
|
+
|
|
132
139
|
RUN sed -i '/en_US.UTF-8/s/^# //g' /etc/locale.gen && \
|
|
133
140
|
locale-gen
|
|
134
141
|
|
|
@@ -198,6 +205,7 @@ export gal="31.170.122.20"\n\
|
|
|
198
205
|
export grunt="grunt --gruntfile node_modules/@fishawack/core/Gruntfile.js"\n\
|
|
199
206
|
export gruntOld="grunt --gruntfile node_modules/@fishawack/config-grunt/Gruntfile.js"\n\
|
|
200
207
|
export PS1="\[\033[36m\]\u\[\033[m\]@\[\033[32m\]\h:\[\033[33;1m\]\w\[\033[m\]\[\033[31m\]\$(parse_git_branch)\[\033[00m\]\$ "\n\
|
|
208
|
+
export PATH="/root/.ebcli-virtual-env/executables:$PATH"\n\
|
|
201
209
|
alias ls="ls -l -GFh"\n\
|
|
202
210
|
# Load in enviroment variables if they exist in the root of the project\n\
|
|
203
211
|
if [ -f ./env.sh ]; then . ./env.sh; fi\n\
|
package/globals.js
CHANGED
|
@@ -2,6 +2,7 @@ const execSync = require('child_process').execSync;
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const { lstatSync, readdirSync, copyFileSync, existsSync } = require('fs');
|
|
4
4
|
const semver = require('semver');
|
|
5
|
+
const getPort = require('get-port');
|
|
5
6
|
|
|
6
7
|
const isDirectory = source => lstatSync(source).isDirectory();
|
|
7
8
|
const getDirectories = source => readdirSync(source).map(name => path.join(source, name)).filter(isDirectory);
|
|
@@ -15,6 +16,7 @@ var method;
|
|
|
15
16
|
var run;
|
|
16
17
|
var exec;
|
|
17
18
|
var running;
|
|
19
|
+
var services;
|
|
18
20
|
var opts = {encoding: 'utf8', stdio: 'inherit', shell: '/bin/bash'};
|
|
19
21
|
|
|
20
22
|
try{
|
|
@@ -70,7 +72,8 @@ if(platform === 'laravel'){
|
|
|
70
72
|
docker = `docker-compose -f ${__dirname}/core/${process.env.VERSION}/docker-compose.yml -p ${repo}`;
|
|
71
73
|
}
|
|
72
74
|
|
|
73
|
-
|
|
75
|
+
services = execSync(`${docker} ps --services --filter "status=running"`, {encoding: 'utf8'});
|
|
76
|
+
running = services.trim().length;
|
|
74
77
|
exec = `exec ${process.env.CI_BUILD_ID ? '-T' : ''}`;
|
|
75
78
|
method = running ? exec : 'run --rm --service-ports';
|
|
76
79
|
run = `${method} core bash -l`;
|
|
@@ -86,12 +89,43 @@ module.exports = {
|
|
|
86
89
|
exec,
|
|
87
90
|
running,
|
|
88
91
|
opts,
|
|
89
|
-
ports
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
ports: {
|
|
93
|
+
async set(){
|
|
94
|
+
if(!running){
|
|
95
|
+
process.env.PORT = await getPort({port: getPort.makeRange(3000, 3100)});
|
|
96
|
+
process.env.PORT_OPT = +process.env.PORT + 1;
|
|
97
|
+
|
|
98
|
+
if(platform === "laravel" || platform === "wordpress" || platform === "drupal"){
|
|
99
|
+
process.env.PORT_WEB = await getPort({port: getPort.makeRange(8000, 8100)});
|
|
100
|
+
process.env.PORT_DB = await getPort({port: getPort.makeRange(3306, 3406)});
|
|
101
|
+
}
|
|
102
|
+
} else {
|
|
103
|
+
try{
|
|
104
|
+
let env = execSync(`${docker} exec -T core env`, {encoding: 'utf8'});
|
|
105
|
+
let ports = env.split('\n').reduce((obj, d) => { obj[d.split('=')[0]] = d.split('=')[1]; return obj; }, {});
|
|
106
|
+
|
|
107
|
+
process.env.PORT = ports.PORT;
|
|
108
|
+
process.env.PORT_OPT = ports.PORT_OPT;
|
|
109
|
+
|
|
110
|
+
if(platform === "laravel" || platform === "wordpress" || platform === "drupal"){
|
|
111
|
+
process.env.PORT_WEB = ports.PORT_WEB;
|
|
112
|
+
process.env.PORT_DB = ports.PORT_DB;
|
|
113
|
+
}
|
|
114
|
+
} catch(e){
|
|
115
|
+
console.log(e.message);
|
|
116
|
+
|
|
117
|
+
process.exit(1);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
},
|
|
121
|
+
get(){
|
|
122
|
+
let ports = { core: {port: +process.env.PORT} };
|
|
123
|
+
|
|
124
|
+
if(+process.env.PORT_WEB) ports.web = {port: +process.env.PORT_WEB};
|
|
125
|
+
if(+process.env.PORT_DB) ports.db = {port: +process.env.PORT_DB};
|
|
126
|
+
|
|
127
|
+
console.table(ports);
|
|
128
|
+
}
|
|
95
129
|
},
|
|
96
130
|
up(cb, err){
|
|
97
131
|
if(!running) execSync(`lab-env up -d`, opts);
|
|
@@ -99,7 +133,7 @@ module.exports = {
|
|
|
99
133
|
try{
|
|
100
134
|
cb();
|
|
101
135
|
} catch(e){
|
|
102
|
-
|
|
136
|
+
throw(e);
|
|
103
137
|
} finally{
|
|
104
138
|
if(!running) execSync(`lab-env down`, opts);
|
|
105
139
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fishawack/lab-env",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.13.0",
|
|
4
4
|
"description": "Docker manager for FW",
|
|
5
5
|
"main": "cli.js",
|
|
6
6
|
"scripts": {
|
|
@@ -24,6 +24,7 @@
|
|
|
24
24
|
"axios": "0.21.1",
|
|
25
25
|
"chalk": "4.1.0",
|
|
26
26
|
"get-port": "5.1.1",
|
|
27
|
+
"glob": "7.1.7",
|
|
27
28
|
"inquirer": "8.1.2",
|
|
28
29
|
"ora": "5.4.1",
|
|
29
30
|
"semver": "7.3.4",
|