Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies to enable Greenkeeper 🌴 #278

Merged
merged 5 commits into from
Jun 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
148 changes: 112 additions & 36 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,44 +1,120 @@
version: 2

node-image: &node-image
image: circleci/node:6

set-npm-global: &set-npm-global
run:
name: set-npm-global
command: |
mkdir -p ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export NPM_CONFIG_PREFIX=~/.npm-global' >> $BASH_ENV
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV
source $BASH_ENV

save: &save
save_cache:
key: code-{{ .Revision }}
paths:
- .
- ".git"
- "~/.npm-global"

restore: &restore
restore_cache:
key: code-{{ .Revision }}

jobs:
build:
docker:
- image: circleci/node:6
environment:
- NODE_ENV=test
- DATABASE_URL_POSTGRES=postgres://ubuntu@localhost:5432/circle_test
- DATABASE_URL_COCKROACH=postgresql://root@localhost:26257/circle_test
- image: postgres:10.4-alpine
environment:
- POSTGRES_USER=ubuntu
- POSTGRES_DB=circle_test
- image: cockroachdb/cockroach:v1.1.8
command: ['start', '--insecure', '--host=localhost']
steps:
- checkout
- run:
name: update-npm
command: |
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export NPM_CONFIG_PREFIX=~/.npm-global' >> $BASH_ENV
echo 'export PATH=~/.npm-global/bin:$PATH' >> $BASH_ENV
source $BASH_ENV
npm install -g [email protected]
- restore_cache:
install:
docker:
- <<: *node-image
steps:
- checkout
- <<: *set-npm-global
- run: npm install -g [email protected]
- restore_cache:
key: dependency-cache-{{ checksum "package.json" }}
- run:
name: install-npm
command: npm ci
- save_cache:
- run:
name: install-greenkeeper
command: |
npm install -g greenkeeper-lockfile
greenkeeper-lockfile-update
- run: npm i
- save_cache:
key: dependency-cache-{{ checksum "package.json" }}
paths:
- ./node_modules
- run:
name: lint
command: npm run lint
- run:
- <<: *save
lint:
docker:
- <<: *node-image
steps:
- <<: *restore
- run: npm run lint
test:
docker:
- <<: *node-image
steps:
- <<: *restore
- run: npm test
test-pg:
docker:
- <<: *node-image
environment:
- DATABASE_URL=postgres://ubuntu@localhost:5432/circle_test
- image: postgres:10.4-alpine
environment:
- POSTGRES_USER=ubuntu
- POSTGRES_DB=circle_test
steps:
- <<: *restore
- run:
name: test
command: npm run migrate up -- -m test/migrations && npm run migrate down 0 -- -m test/migrations --timestamps
test-cocroach:
docker:
- <<: *node-image
environment:
- DATABASE_URL=postgresql://root@localhost:26257/circle_test
- image: cockroachdb/cockroach:v1.1.8
command: ['start', '--insecure', '--host=localhost']
steps:
- <<: *restore
- run:
name: create-cockroach-db
command: node -e '(new require("pg").Pool({connectionString:process.env.DATABASE_URL_COCKROACH})).query("CREATE DATABASE circle_test").then(function(){process.exit(0)})'
- run:
command: node -e '(new require("pg").Pool({connectionString:process.env.DATABASE_URL})).query("CREATE DATABASE circle_test").then(function(){process.exit(0)})'
- run:
name: test
command: npm test
command: npm run migrate up -- -m test/cockroach -s '' --migrations-schema circle_test --no-lock && npm run migrate down 0 -- -m test/cockroach -s '' --migrations-schema circle_test --no-lock --timestamps
finish:
docker:
- <<: *node-image
steps:
- <<: *restore
- <<: *set-npm-global
- run: greenkeeper-lockfile-upload

workflows:
version: 2
main_workflow:
jobs:
- install
- lint:
requires:
- install
- test:
requires:
- install
- test-pg:
requires:
- install
- test-cocroach:
requires:
- install
- finish:
requires:
- lint
- test
- test-pg
- test-cocroach
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
[![NPM version](https://img.shields.io/npm/v/node-pg-migrate.svg)](https://www.npmjs.com/package/node-pg-migrate)
![Downloads](https://img.shields.io/npm/dm/node-pg-migrate.svg?style=flat)
![Licence](https://img.shields.io/npm/l/node-pg-migrate.svg?style=flat)
[![Known Vulnerabilities](https://snyk.io/test/github/salsita/node-pg-migrate/badge.svg)](https://snyk.io/test/github/salsita/node-pg-migrate)
[![Known Vulnerabilities](https://snyk.io/test/github/salsita/node-pg-migrate/badge.svg)](https://snyk.io/test/github/salsita/node-pg-migrate) [![Greenkeeper badge](https://badges.greenkeeper.io/salsita/node-pg-migrate.svg)](https://greenkeeper.io/)

Node.js database migration management built exclusively for postgres. (But can also be used for other DBs conforming to SQL standard - e.g. [CockroachDB](https://github.com/cockroachdb/cockroach).)
Started by [Theo Ephraim](https://github.com/theoephraim/), now maintained by [Salsita Software](https://www.salsitasoft.com/).
Expand Down
4 changes: 3 additions & 1 deletion lib/migration.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ class Migration {
return Promise.reject(
new Error(`User has disabled down migration on file: ${this.name}`)
);
} else if (this.down === undefined) {
}

if (this.down === undefined) {
// automatically infer the down migration by running the up migration in reverse mode...
pgm.enableReverseMode();
this.down = this.up;
Expand Down
5 changes: 4 additions & 1 deletion lib/operations/operators.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,10 +86,13 @@ const operatorMap = typeShorthands => ({
params.length > 0 ? formatParams(params, typeShorthands) : "";

return `OPERATOR ${number} ${nameStr}${paramsStr}`;
} else if (String(type).toLowerCase() === "operator") {
}

if (String(type).toLowerCase() === "operator") {
const paramsStr = formatParams(params, typeShorthands);
return `FUNCTION ${number} ${schemalize(name)}${paramsStr}`;
}

throw new Error('Operator "type" must be either "function" or "operator"');
};

Expand Down
16 changes: 3 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"cross-env": "^5.0.0",
"dotenv": ">=1.0.0",
"eslint": "^4.8.0",
"eslint-config-airbnb-base": "^12.1.0",
"eslint-config-airbnb-base": "^13.0.0",
"eslint-config-prettier": "^2.9.0",
"eslint-plugin-import": "^2.7.0",
"eslint-plugin-prettier": "^2.6.0",
Expand All @@ -69,7 +69,7 @@
"mocha": "^5.0.0",
"pg": "^7.3.0",
"prettier": "^1.11.1",
"sinon": "^5.0.0",
"sinon": "^6.0.0",
"sinon-chai": "^3.0.0"
},
"peerDependencies": {
Expand All @@ -82,18 +82,8 @@
"scripts": {
"precommit": "lint-staged",
"compile": "babel lib/ -d dist/ && cp lib/migration-template.* dist/",
"test:mocha": "cross-env NODE_ENV=test mocha --opts ./mocha.opts test",
"test": "cross-env NODE_ENV=test mocha --opts ./mocha.opts test",
"migrate": "babel-node bin/node-pg-migrate",
"migrate:postgres":
"DATABASE_URL=$DATABASE_URL_POSTGRES npm run migrate -- -m test/migrations",
"migrate:cockroach":
"DATABASE_URL=$DATABASE_URL_COCKROACH npm run migrate -- -m test/cockroach -s '' --migrations-schema circle_test --no-lock",
"test:postgres":
"npm run migrate:postgres up && npm run migrate:postgres down 0 -- --timestamps",
"test:cockroach":
"npm run migrate:cockroach up && npm run migrate:cockroach down 0 -- --timestamp",
"test":
"npm run test:mocha && npm run test:postgres && npm run test:cockroach",
"lint": "eslint -c eslintrc.js . bin/*",
"lintfix":
"npm run lint -- --fix && prettier --write *.json *.md docs/*.md",
Expand Down