Merge pull request #540 from CartoDB/nodejs-10

Support Node.js 10 LTS
This commit is contained in:
Daniel G. Aubert 2018-11-22 14:48:55 +01:00 committed by GitHub
commit 5f5b516721
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 4728 additions and 55 deletions

View File

@ -5,7 +5,13 @@ jobs:
- docker - docker
language: generic language: generic
before_install: docker pull carto/nodejs6-xenial-pg101 before_install: docker pull carto/nodejs6-xenial-pg101
script: npm run docker-test script: npm run docker-test -- nodejs6
- sudo: required
services:
- docker
language: generic
before_install: docker pull carto/nodejs10-xenial-pg101:postgis-2.4.4.5
script: npm run docker-test -- nodejs10
- dist: precise - dist: precise
addons: addons:
apt: apt:

10
NEWS.md
View File

@ -1,10 +1,16 @@
# Changelog # Changelog
## 2.2.2 ## 2.3.0
Released 2018-mm-dd Released 2018-mm-dd
Announcements:
* Support Node.js 10
* Add package-lock.json
* Configure Travis CI to run docker tests against Node.js 6 & 10 versions
Bug fixes: Bug fixes:
* Make all modules to use strict mode semantics. * Do not use `assert` to throw erros as in Node.js > 6 wraps the original error, the keyword 'throw' does the trick and it's backwards compatible
* Make all modules to use strict mode semantics.
## 2.2.1 ## 2.2.1

View File

@ -4,7 +4,6 @@
var _ = require('underscore'); var _ = require('underscore');
var OAuthUtil = require('oauth-client'); var OAuthUtil = require('oauth-client');
var step = require('step'); var step = require('step');
var assert = require('assert');
var CdbRequest = require('../models/cartodb_request'); var CdbRequest = require('../models/cartodb_request');
var cdbReq = new CdbRequest(); var cdbReq = new CdbRequest();
@ -90,7 +89,9 @@ var oAuth = (function(){
return oAuth.parseTokens(req); return oAuth.parseTokens(req);
}, },
function getOAuthHash(err, _requestTokens) { function getOAuthHash(err, _requestTokens) {
assert.ifError(err); if (err) {
throw err;
}
// this is oauth request only if oauth headers are present // this is oauth request only if oauth headers are present
this.is_oauth_request = !_.isEmpty(_requestTokens); this.is_oauth_request = !_.isEmpty(_requestTokens);
@ -103,7 +104,9 @@ var oAuth = (function(){
} }
}, },
function regenerateSignature(err, oAuthHash){ function regenerateSignature(err, oAuthHash){
assert.ifError(err); if (err) {
throw err;
}
if (!this.is_oauth_request) { if (!this.is_oauth_request) {
return null; return null;
} }

View File

@ -2,7 +2,6 @@
var _ = require('underscore'); var _ = require('underscore');
var step = require('step'); var step = require('step');
var assert = require('assert');
var PSQL = require('cartodb-psql'); var PSQL = require('cartodb-psql');
var CachedQueryTables = require('../services/cached-query-tables'); var CachedQueryTables = require('../services/cached-query-tables');
const pgEntitiesAccessValidator = require('../services/pg-entities-access-validator'); const pgEntitiesAccessValidator = require('../services/pg-entities-access-validator');
@ -158,7 +157,9 @@ QueryController.prototype.handleQuery = function (req, res, next) {
}); });
}, },
function setHeaders(err, affectedTables) { function setHeaders(err, affectedTables) {
assert.ifError(err); if (err) {
throw err;
}
var mayWrite = queryMayWrite(sql); var mayWrite = queryMayWrite(sql);
if ( req.profiler ) { if ( req.profiler ) {
@ -206,7 +207,9 @@ QueryController.prototype.handleQuery = function (req, res, next) {
return null; return null;
}, },
function generateFormat(err){ function generateFormat(err){
assert.ifError(err); if (err) {
throw err;
}
checkAborted('generateFormat'); checkAborted('generateFormat');
// TODO: drop this, fix UI! // TODO: drop this, fix UI!

View File

@ -6,7 +6,6 @@ var fs = require('fs');
var _ = require('underscore'); var _ = require('underscore');
var PSQL = require('cartodb-psql'); var PSQL = require('cartodb-psql');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var assert = require('assert');
// Keeps track of what's waiting baking for export // Keeps track of what's waiting baking for export
var bakingExports = {}; var bakingExports = {};
@ -95,7 +94,9 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback
pg.query(colsql, this); pg.query(colsql, this);
}, },
function findSRS(err, result) { function findSRS(err, result) {
assert.ifError(err); if (err) {
throw err;
}
var needSRS = that._needSRS; var needSRS = that._needSRS;
@ -139,7 +140,9 @@ OgrFormat.prototype.toOGR = function(options, out_format, out_filename, callback
}); });
}, },
function spawnDumper(err, srid, type) { function spawnDumper(err, srid, type) {
assert.ifError(err); if (err) {
throw err;
}
var next = this; var next = this;

View File

@ -3,7 +3,6 @@
var step = require('step'); var step = require('step');
var fs = require('fs'); var fs = require('fs');
var spawn = require('child_process').spawn; var spawn = require('child_process').spawn;
var assert = require('assert');
var ogr = require('./../ogr'); var ogr = require('./../ogr');
@ -51,12 +50,16 @@ ShpFormat.prototype.toSHP = function (options, callback) {
fs.mkdir(outdirpath, 0o777, this); fs.mkdir(outdirpath, 0o777, this);
}, },
function spawnDumper(err) { function spawnDumper(err) {
assert.ifError(err); if (err) {
throw err;
}
fmtObj.toOGR(options, 'ESRI Shapefile', shapefile, this); fmtObj.toOGR(options, 'ESRI Shapefile', shapefile, this);
}, },
function doZip(err) { function doZip(err) {
assert.ifError(err); if (err) {
throw err;
}
var next = this; var next = this;

View File

@ -2,7 +2,6 @@
var step = require('step'); var step = require('step');
var PSQL = require('cartodb-psql'); var PSQL = require('cartodb-psql');
var assert = require('assert');
function PostgresFormat(id) { function PostgresFormat(id) {
this.id = id; this.id = id;
@ -82,8 +81,9 @@ PostgresFormat.prototype.handleQueryEnd = function(result) {
that.transform(result, that.opts, this); that.transform(result, that.opts, this);
}, },
function sendResults(err, out){ function sendResults(err, out){
if (err) {
assert.ifError(err); throw err;
}
// return to browser // return to browser
if ( out ) { if ( out ) {

3
docker-bash.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
docker run -it -v `pwd`:/srv carto/${1:-nodejs10-xenial-pg101:postgis-2.4.4.5} bash

23
docker-test.sh Executable file
View File

@ -0,0 +1,23 @@
#!/bin/bash
usage() {
echo "Usage: $0 [nodejs6|nodejs10]"
exit 1
}
echo "$0 $1"
NODEJS_VERSION=${1-nodejs10}
if [ "$NODEJS_VERSION" = "nodejs10" ];
then
DOCKER='nodejs10-xenial-pg101:postgis-2.4.4.5'
elif [ "$NODEJS_VERSION" = "nodejs6" ];
then
DOCKER='nodejs6-xenial-pg101'
else
usage
fi
docker run -v `pwd`:/srv carto/${DOCKER} bash test/run_tests_docker.sh ${NODEJS_VERSION} && \
docker ps --filter status=dead --filter status=exited -aq | xargs docker rm -v

54
npm-shrinkwrap.json generated
View File

@ -1,6 +1,6 @@
{ {
"name": "cartodb_sql_api", "name": "cartodb_sql_api",
"version": "2.2.2", "version": "2.3.0",
"dependencies": { "dependencies": {
"@carto/fqdn-sync": { "@carto/fqdn-sync": {
"version": "0.2.2", "version": "0.2.2",
@ -110,9 +110,9 @@
} }
}, },
"bluebird": { "bluebird": {
"version": "3.5.2", "version": "3.5.3",
"from": "bluebird@>=3.3.3 <4.0.0", "from": "bluebird@>=3.3.3 <4.0.0",
"resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.2.tgz" "resolved": "https://registry.npmjs.org/bluebird/-/bluebird-3.5.3.tgz"
}, },
"boom": { "boom": {
"version": "2.10.1", "version": "2.10.1",
@ -162,9 +162,9 @@
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz" "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-3.0.0.tgz"
}, },
"cartodb-psql": { "cartodb-psql": {
"version": "0.12.0", "version": "0.13.0",
"from": "cartodb-psql@0.12.0", "from": "cartodb-psql@0.13.0",
"resolved": "https://registry.npmjs.org/cartodb-psql/-/cartodb-psql-0.12.0.tgz", "resolved": "https://registry.npmjs.org/cartodb-psql/-/cartodb-psql-0.13.0.tgz",
"dependencies": { "dependencies": {
"debug": { "debug": {
"version": "3.2.6", "version": "3.2.6",
@ -174,14 +174,14 @@
} }
}, },
"cartodb-query-tables": { "cartodb-query-tables": {
"version": "0.2.0", "version": "0.4.0",
"from": "cartodb-query-tables@0.2.0", "from": "cartodb-query-tables@0.4.0",
"resolved": "https://registry.npmjs.org/cartodb-query-tables/-/cartodb-query-tables-0.2.0.tgz" "resolved": "https://registry.npmjs.org/cartodb-query-tables/-/cartodb-query-tables-0.4.0.tgz"
}, },
"cartodb-redis": { "cartodb-redis": {
"version": "2.0.2", "version": "2.1.0",
"from": "cartodb-redis@2.0.2", "from": "cartodb-redis@2.1.0",
"resolved": "https://registry.npmjs.org/cartodb-redis/-/cartodb-redis-2.0.2.tgz" "resolved": "https://registry.npmjs.org/cartodb-redis/-/cartodb-redis-2.1.0.tgz"
}, },
"caseless": { "caseless": {
"version": "0.11.0", "version": "0.11.0",
@ -463,9 +463,9 @@
"optional": true "optional": true
}, },
"graceful-fs": { "graceful-fs": {
"version": "4.1.11", "version": "4.1.15",
"from": "graceful-fs@>=4.1.2 <5.0.0", "from": "graceful-fs@>=4.1.2 <5.0.0",
"resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.11.tgz" "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.1.15.tgz"
}, },
"har-validator": { "har-validator": {
"version": "2.0.6", "version": "2.0.6",
@ -839,9 +839,9 @@
"resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz" "resolved": "https://registry.npmjs.org/path-type/-/path-type-1.1.0.tgz"
}, },
"pg": { "pg": {
"version": "6.4.2", "version": "6.4.2-cdb2",
"from": "cartodb/node-postgres#6.4.2-cdb1", "from": "cartodb/node-postgres#6.4.2-cdb2",
"resolved": "git://github.com/cartodb/node-postgres.git#449fac1d6da711ffcc6694ae3c89f85244f48bdc" "resolved": "git://github.com/cartodb/node-postgres.git#5417d7b29b7272ca2e71bb396899ab3f177a9ae6"
}, },
"pg-connection-string": { "pg-connection-string": {
"version": "0.1.3", "version": "0.1.3",
@ -849,9 +849,9 @@
"resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz" "resolved": "https://registry.npmjs.org/pg-connection-string/-/pg-connection-string-0.1.3.tgz"
}, },
"pg-copy-streams": { "pg-copy-streams": {
"version": "1.2.0-carto.2", "version": "1.2.0-carto.3",
"from": "cartodb/node-pg-copy-streams#v1.2.0-carto.2", "from": "cartodb/node-pg-copy-streams#v1.2.0-carto.3",
"resolved": "git://github.com/cartodb/node-pg-copy-streams.git#6f1d5cb4a54be07cf2ca076563142737e44eaf5c" "resolved": "git://github.com/cartodb/node-pg-copy-streams.git#94c8d89abaea54bd4e6f61f63f47ef81cdc44253"
}, },
"pg-int8": { "pg-int8": {
"version": "1.0.1", "version": "1.0.1",
@ -964,9 +964,9 @@
"resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz" "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.4.0.tgz"
}, },
"redis-mpool": { "redis-mpool": {
"version": "0.5.0", "version": "0.7.0",
"from": "redis-mpool@0.5.0", "from": "redis-mpool@0.7.0",
"resolved": "https://registry.npmjs.org/redis-mpool/-/redis-mpool-0.5.0.tgz", "resolved": "https://registry.npmjs.org/redis-mpool/-/redis-mpool-0.7.0.tgz",
"dependencies": { "dependencies": {
"generic-pool": { "generic-pool": {
"version": "2.1.1", "version": "2.1.1",
@ -1082,9 +1082,9 @@
"resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz" "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz"
}, },
"spdx-license-ids": { "spdx-license-ids": {
"version": "3.0.1", "version": "3.0.2",
"from": "spdx-license-ids@>=3.0.0 <4.0.0", "from": "spdx-license-ids@>=3.0.0 <4.0.0",
"resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.1.tgz" "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.2.tgz"
}, },
"split": { "split": {
"version": "1.0.1", "version": "1.0.1",
@ -1092,9 +1092,9 @@
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz" "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz"
}, },
"sshpk": { "sshpk": {
"version": "1.15.1", "version": "1.15.2",
"from": "sshpk@>=1.7.0 <2.0.0", "from": "sshpk@>=1.7.0 <2.0.0",
"resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.1.tgz", "resolved": "https://registry.npmjs.org/sshpk/-/sshpk-1.15.2.tgz",
"dependencies": { "dependencies": {
"assert-plus": { "assert-plus": {
"version": "1.0.0", "version": "1.0.0",

4587
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -5,7 +5,7 @@
"keywords": [ "keywords": [
"cartodb" "cartodb"
], ],
"version": "2.2.2", "version": "2.3.0",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/CartoDB/CartoDB-SQL-API.git" "url": "git://github.com/CartoDB/CartoDB-SQL-API.git"
@ -21,9 +21,9 @@
"basic-auth": "^2.0.0", "basic-auth": "^2.0.0",
"bintrees": "1.0.1", "bintrees": "1.0.1",
"bunyan": "1.8.1", "bunyan": "1.8.1",
"cartodb-psql": "0.12.0", "cartodb-psql": "0.13.0",
"cartodb-query-tables": "0.2.0", "cartodb-query-tables": "0.4.0",
"cartodb-redis": "2.0.2", "cartodb-redis": "2.1.0",
"debug": "2.2.0", "debug": "2.2.0",
"express": "~4.13.3", "express": "~4.13.3",
"log4js": "cartodb/log4js-node#cdb", "log4js": "cartodb/log4js-node#cdb",
@ -33,10 +33,10 @@
"node-statsd": "~0.0.7", "node-statsd": "~0.0.7",
"node-uuid": "^1.4.7", "node-uuid": "^1.4.7",
"oauth-client": "0.3.0", "oauth-client": "0.3.0",
"pg-copy-streams": "github:cartodb/node-pg-copy-streams#v1.2.0-carto.2", "pg-copy-streams": "github:cartodb/node-pg-copy-streams#v1.2.0-carto.3",
"qs": "~6.2.1", "qs": "~6.2.1",
"queue-async": "~1.0.7", "queue-async": "~1.0.7",
"redis-mpool": "0.5.0", "redis-mpool": "0.7.0",
"redlock": "2.0.1", "redlock": "2.0.1",
"request": "~2.75.0", "request": "~2.75.0",
"step": "~0.0.5", "step": "~0.0.5",
@ -48,7 +48,7 @@
"devDependencies": { "devDependencies": {
"istanbul": "0.4.5", "istanbul": "0.4.5",
"jshint": "~2.6.0", "jshint": "~2.6.0",
"libxmljs": "0.18.0", "libxmljs": "0.19.5",
"mocha": "3.2.0", "mocha": "3.2.0",
"shapefile": "0.3.0", "shapefile": "0.3.0",
"sqlite3": "4.0.0", "sqlite3": "4.0.0",
@ -58,8 +58,8 @@
"test": "make test-all", "test": "make test-all",
"test:unit": "mocha test/unit/**/*.js", "test:unit": "mocha test/unit/**/*.js",
"test:unit:watch": "npm run test:unit -- -w", "test:unit:watch": "npm run test:unit -- -w",
"docker-test": "docker run -v `pwd`:/srv carto/nodejs6-xenial-pg101 bash test/run_tests_docker.sh && docker ps --filter status=dead --filter status=exited -aq | xargs -r docker rm -v", "docker-test": "./docker-test.sh",
"docker-bash": "docker run -it -v `pwd`:/srv carto/nodejs6-xenial-pg101 bash" "docker-bash": "./docker-bash.sh"
}, },
"engines": { "engines": {
"node": ">= 4.5.0", "node": ">= 4.5.0",

View File

@ -1,11 +1,47 @@
#!/bin/bash
usage() {
/etc/init.d/postgresql stop
echo "Usage: $0 [nodejs10|nodejs6]"
exit 1
}
echo "$0 $1"
# start PostgreSQL # start PostgreSQL
/etc/init.d/postgresql start /etc/init.d/postgresql start
# Configure # Configure
./configure ./configure
echo "Node.js version:"
node -v
# install dependencies # install dependencies
npm i NODEJS_VERSION=${1-nodejs10}
if [ "$NODEJS_VERSION" = "nodejs10" ];
then
echo "npm version on install:"
npm -v
mv npm-shrinkwrap.json npm-shrinkwrap.json.backup
npm ci
npm ls
mv npm-shrinkwrap.json.backup npm-shrinkwrap.json
elif [ "$NODEJS_VERSION" = "nodejs6" ];
then
echo "npm version on install:"
npm -v
mv package-lock.json package-lock.json.backup
npm i
npm ls
mv package-lock.json.backup package-lock.json
else
usage
fi
# run tests # run tests
echo "npm version on tests:"
npm -v
npm test npm test