Skip to content

Commit

Permalink
melhorias de build, script de build com commander para melhor automat…
Browse files Browse the repository at this point in the history
…ização
  • Loading branch information
joaopaulogse committed Sep 26, 2017
1 parent 9967bdf commit d4916d4
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 19 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
NODE_ENV=development
PORT=3000
PORT=3003

DB_HOST=localhost
DB_VENDOR=postgres
DB_SCHEMA=API
DB_NAME=mydb
DB_USER=joaopaulo
DB_USER=jpts
DB_PASS=postgres
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
node_modules
coverage
# variaveis de produção
.env
*.log
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ before_install:
install: yarn install

script:
- yarn run test-integration-jest
- yarn run production
- ./build -t
- ./build -p

services:
- mongodb
52 changes: 52 additions & 0 deletions build
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/usr/bin/env node
const { exec } = require('child_process')
const program = require("commander");
program
.version(require('./package.json').version)
.option('-p, --production', 'Build de produção')
.option('-d, --development', 'Build de desenvolvimento')
.option('-t, --test', 'Roda os testes')
.parse(process.argv);

if(program.production){
exec('cp .env.example .env')
const npm = exec('yarn run production')
npm.stdout.on('data', data=>{
console.log(data.toString())
})
npm.stderr.on('data', data=>{
console.log(data.toString())
})
npm.on('close', code=>{
console.log(code.toString())
})

}
if(program.development){
exec('cp .env.example .env')
const npm = exec('yarn run dev')
npm.stdout.on('data', data=>{
console.log(data.toString())
})
npm.stderr.on('data', data=>{
console.log(data.toString())
})
npm.on('close', code=>{
console.log(code.toString())
})
}
if(program.test){
//copia as varias que voce quer para serem executadas
exec('cp .env.example .env')
const npm = exec('yarn run test-integration-jest')
npm.stdout.on('data', data=>{
console.log(data.toString())
})
npm.stderr.on('data', data=>{
console.log(data.toString())
})
npm.on('close', code=>{
console.log(code.toString())
})

}
17 changes: 4 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"lint": "eslint **/**/*.js ",
"lint:fix": "eslint **/**/*.js --fix --ignore-path .gitignore",
"test": "cross-env NODE_ENV=test jest",
"test-integration-jest": "cross-env NODE_ENV=test jest",
"test-integration-jest": "cross-env NODE_ENV=test jest --forceExit",
"test-coverage": "cross-env NODE_ENV=test istanbul cover jest",
"test-integration:mocha": "cross-env NODE_ENV=test mocha --opts ./src/api/tests/integration/mocha.opts ./src/api/tests/integration/**/*.js"
},
Expand Down Expand Up @@ -46,6 +46,7 @@
},
"devDependencies": {
"chai": "^4.1.1",
"commander": "^2.11.0",
"eslint": "^4.3.0",
"eslint-config-airbnb": "^15.1.0",
"eslint-plugin-chai-expect": "^1.1.1",
Expand Down
2 changes: 1 addition & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,7 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
dependencies:
delayed-stream "~1.0.0"

[email protected], commander@^2.9.0:
[email protected], commander@^2.11.0, commander@^2.9.0:
version "2.11.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.11.0.tgz#157152fd1e7a6c8d98a5b715cf376df928004563"

Expand Down

0 comments on commit d4916d4

Please sign in to comment.