Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Takeoff config to be more like a plugin
- Loading branch information
Showing
1 changed file
with
40 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,43 @@ | ||
|
||
let sleep = 'sleep 5'; | ||
if (process.platform === 'win32') sleep = 'sleep -s 5'; | ||
|
||
module.exports = environment => [ | ||
{ cmd: `git submodule init`, message: `Initialising submodules`, cwd: `envs/${environment}` }, | ||
{ cmd: `git submodule update`, message: `Cloning submodules`, cwd: `envs/${environment}` }, | ||
{ cmd: `npm install`, message: 'Installing blueprint dependencies', cwd: `envs/${environment}` }, | ||
{ cmd: `node_modules/.bin/lerna bootstrap`, message: 'Bootstrapping environments', cwd: `envs/${environment}` }, | ||
{ | ||
cmd: `docker-compose -f docker/docker-compose.yml build --no-cache`, | ||
message: 'Running Docker Compose Build', | ||
cwd: `envs/${environment}`, | ||
}, | ||
{ | ||
cmd: `docker-compose -f docker/docker-compose.yml up -d db`, | ||
message: 'Triggering database creation', | ||
cwd: `envs/${environment}`, | ||
}, | ||
{ cmd: `${sleep}`, message: 'Waiting for database' }, | ||
{ | ||
cmd: `docker-compose -f docker/docker-compose.yml stop db`, | ||
message: 'Shutting down database', | ||
cwd: `envs/${environment}`, | ||
}, | ||
]; | ||
module.exports = ({ command, shell, args, opts, workingDir, ProgressBar }) => { | ||
const bar = new ProgressBar({ | ||
schema: ' :title (:current/:total :elapseds) [:bar]', | ||
total: 4 | ||
}); | ||
|
||
bar.tick(0, { title: 'Doing NPM Install' }); | ||
|
||
const submoduleInit = shell.exec(`npm install`, { cwd: __dirname, silent: opts.v ? false : true }); | ||
if (submoduleInit.code !== 0) return false; | ||
|
||
bar.tick(1, { title: 'Bootstrap Environment' }); | ||
|
||
const bootstrap = shell.exec(`node_modules/.bin/lerna bootstrap`, { | ||
cwd: __dirname, | ||
silent: opts.v ? false : true | ||
}); | ||
if (bootstrap.code !== 0) return false; | ||
|
||
bar.tick(1, { title: 'Running Docker Build' }); | ||
|
||
const build = shell.exec(`docker-compose -f docker/docker-compose.yml build --no-cache`, { | ||
cwd: __dirname, | ||
silent: opts.v ? false : true | ||
}); | ||
if (build.code !== 0) return false; | ||
|
||
bar.tick(1, { title: 'Initilising Database' }); | ||
|
||
const dbinit = shell.exec( | ||
`docker-compose -f docker/docker-compose.yml build --no-cache \ | ||
&& ${sleep} && docker-compose -f docker/docker-compose.yml stop db`, | ||
{ cwd: __dirname, silent: opts.v ? false : true } | ||
); | ||
if (dbinit.code !== 0) return false; | ||
|
||
bar.tick(1, { title: 'Done' }); | ||
|
||
return true; | ||
}; |