Skip to content

Commit

Permalink
Merge pull request #8213 from tylersmalley/4.6-node6
Browse files Browse the repository at this point in the history
[backport] PR #7920,#8313 to 4.6 - Upgrade to Node 6.4.0
  • Loading branch information
tylersmalley authored Oct 11, 2016
2 parents 89044b0 + f1263fe commit 332abe8
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 145 deletions.
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.4.7
6.4.0
33 changes: 18 additions & 15 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"url": "https://github.com/elastic/kibana.git"
},
"dependencies": {
"@bigfunger/decompress-zip": "0.2.0-stripfix2",
"@bigfunger/decompress-zip": "0.2.0-stripfix3",
"@spalger/angular-bootstrap": "0.12.1",
"@spalger/filesaver": "1.1.2",
"@spalger/leaflet-draw": "0.2.3",
Expand All @@ -77,7 +77,7 @@
"angular-route": "1.4.7",
"angular-sanitize": "1.5.7",
"ansicolors": "0.3.2",
"autoprefixer": "5.1.1",
"autoprefixer": "6.3.7",
"autoprefixer-loader": "2.0.0",
"babel": "5.8.23",
"babel-core": "5.8.23",
Expand All @@ -103,8 +103,11 @@
"good": "6.3.0",
"good-squeeze": "2.1.0",
"gridster": "0.5.6",
"hapi": "8.8.1",
"grunt-run": "0.6.0",
"h2o2": "5.1.1",
"hapi": "14.2.0",
"imports-loader": "0.6.4",
"inert": "4.0.2",
"jade": "1.11.0",
"jade-loader": "0.7.1",
"joi": "6.6.1",
Expand All @@ -114,8 +117,8 @@
"json-stringify-safe": "5.0.1",
"jstimezonedetect": "1.0.5",
"leaflet": "0.7.5",
"less": "2.5.1",
"less-loader": "2.2.0",
"less": "2.7.1",
"less-loader": "2.2.3",
"loader-utils": "0.2.11",
"lodash": "3.10.1",
"marked": "0.3.6",
Expand All @@ -133,6 +136,7 @@
"style-loader": "0.12.3",
"tar": "2.2.0",
"url-loader": "0.5.6",
"vision": "4.1.0",
"webpack": "1.12.15",
"webpack-directory-name-as-main": "1.0.0",
"whatwg-fetch": "0.9.0",
Expand All @@ -143,28 +147,27 @@
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
"babel-eslint": "4.1.7",
"chokidar": "1.0.5",
"chokidar": "1.6.0",
"chromedriver": "2.22.1",
"eslint": "1.5.1",
"eslint-plugin-mocha": "1.0.0",
"expect.js": "0.3.1",
"faker": "1.1.0",
"glob": "4.5.3",
"grunt": "0.4.5",
"grunt": "1.0.1",
"grunt-aws-s3": "0.14.5",
"grunt-babel": "5.0.1",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.6.0",
"grunt-contrib-clean": "1.0.0",
"grunt-contrib-copy": "0.8.1",
"grunt-esvm": "3.2.6",
"grunt-karma": "0.12.0",
"grunt-run": "0.5.0",
"grunt-s3": "0.2.0-alpha.3",
"grunt-karma": "0.12.2",
"grunt-simple-mocha": "0.4.0",
"gruntify-eslint": "1.0.1",
"husky": "0.8.1",
"intern": "3.2.3",
"istanbul-instrumenter-loader": "0.1.3",
"karma": "0.13.22",
"karma": "1.2.0",
"karma-chrome-launcher": "0.2.0",
"karma-coverage": "0.5.1",
"karma-firefox-launcher": "0.1.6",
Expand All @@ -177,14 +180,14 @@
"makelogs": "2.0.0",
"mocha": "2.3.4",
"nock": "8.0.0",
"npm": "2.15.8",
"npm": "3.10.3",
"portscanner": "1.0.0",
"simple-git": "1.8.0",
"sinon": "1.17.2",
"source-map": "0.4.4"
},
"engines": {
"node": "4.4.7",
"npm": "2.15.8"
"node": "6.4.0",
"npm": "3.10.3"
}
}
5 changes: 4 additions & 1 deletion src/optimize/lazy/LazyServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@
let { Server } = require('hapi');
let { fromNode } = require('bluebird');
let Boom = require('boom');

let registerHapiPlugins = require('../../server/http/register_hapi_plugins');

module.exports = class LazyServer {
constructor(host, port, optimizer) {
this.optimizer = optimizer;
this.server = new Server();

registerHapiPlugins(null, this.server);

this.server.connection({
host: host,
port: port
Expand Down
23 changes: 9 additions & 14 deletions src/plugins/elasticsearch/lib/__tests__/routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ describe('plugins/elasticsearch', function () {
});


function testRoute(options) {
function testRoute(options, statusCode = 200) {
if (typeof options.payload === 'object') {
options.payload = JSON.stringify(options.payload);
}

const statusCode = options.statusCode || 200;
describe(format('%s %s', options.method, options.url), function () {
it('should should return ' + statusCode, function (done) {
kbnTestServer.makeRequest(kbnServer, options, function (res) {
Expand Down Expand Up @@ -61,21 +60,18 @@ describe('plugins/elasticsearch', function () {

testRoute({
method: 'POST',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'PUT',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'DELETE',
url: '/elasticsearch/.kibana',
statusCode: 405
});
url: '/elasticsearch/.kibana'
}, 405);

testRoute({
method: 'GET',
Expand All @@ -85,9 +81,8 @@ describe('plugins/elasticsearch', function () {
testRoute({
method: 'POST',
url: '/elasticsearch/.kibana/_bulk',
payload: '{}',
statusCode: 400
});
payload: '{}'
}, 400);

testRoute({
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions src/server/http/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = function (kbnServer, server, config) {
server = kbnServer.server = new Hapi.Server();

const shortUrlLookup = require('./short_url_lookup')(server);
kbnServer.mixin(require('./register_hapi_plugins'));

// Create a new connection
let connectionOptions = {
Expand Down
16 changes: 16 additions & 0 deletions src/server/http/register_hapi_plugins.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import HapiTemplates from 'vision';
import HapiStaticFiles from 'inert';
import HapiProxy from 'h2o2';
import { fromNode } from 'bluebird';

const plugins = [HapiTemplates, HapiStaticFiles, HapiProxy];

async function registerPlugins(server) {
await fromNode(cb => {
server.register(plugins, cb);
});
}

export default function (kbnServer, server, config) {
registerPlugins(server);
}
21 changes: 21 additions & 0 deletions tasks/config/aws_s3.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default function (grunt) {
const { config } = grunt;
const { sha, version } = grunt.config.get('build');

return {
options: {
bucket: 'download.elasticsearch.org',
access: 'private',
uploadConcurrency: 10
},

staging: {
files: [{
expand: true,
cwd: 'target',
src: ['**'],
dest: `kibana/staging/${version}-${sha.substr(0, 7)}/kibana/`
}]
}
};
};
118 changes: 60 additions & 58 deletions tasks/licenses.js
Original file line number Diff line number Diff line change
@@ -1,75 +1,77 @@
var _ = require('lodash');
var npm = require('npm');
var npmLicense = require('license-checker');
import _ from 'lodash';
import { fromNode } from 'bluebird';
import npm from 'npm';
import npmLicense from 'license-checker';

module.exports = function (grunt) {
grunt.registerTask('licenses', 'Checks dependency licenses', function () {
export default function licenses(grunt) {
grunt.registerTask('licenses', 'Checks dependency licenses', async function () {
const config = this.options();
const done = this.async();

var config = this.options();
const result = [];
const options = {
start: process.cwd(),
production: true,
json: true
};

var done = this.async();
const packages = await fromNode(cb => {
npmLicense.init(options, (result, error) => {
cb(undefined, result);
});
});

var result = {};
var options = { start: process.cwd(), json: true };
var checkQueueLength = 2;
/**
* Licenses for a package by name with overrides
*
* @param {String} name
* @return {Array}
*/

function processPackage(info, dependency) {
var pkgInfo = {};
pkgInfo.name = dependency;
pkgInfo.licenses = config.overrides[dependency] || (info && info.licenses);
pkgInfo.licenses = _.isArray(pkgInfo.licenses) ? pkgInfo.licenses : [pkgInfo.licenses];
pkgInfo.valid = (function () {
if (_.intersection(pkgInfo.licenses, config.licenses).length > 0) {
return true;
}
return false;
}());
return pkgInfo;
}
function licensesForPackage(name) {
let licenses = packages[name].licenses;

npmLicense.init(options, function (allDependencies) {
// Only check production NPM dependencies, not dev
npm.load({production: true}, function () {
npm.commands.list([], true, function (a, b, npmList) {
if (config.overrides.hasOwnProperty(name)) {
licenses = config.overrides[name];
}

// Recurse npm --production --json ls output, create array of package@version
var getDependencies = function (dependencies, list) {
list = list || [];
_.each(dependencies, function (info, dependency) {
list.push(dependency + '@' + info.version);
if (info.dependencies) {
getDependencies(info.dependencies, list);
}
});
return list;
};
return typeof licenses === 'string' ? [licenses] : licenses;
}

var productionDependencies = {};
_.each(getDependencies(npmList.dependencies), function (packageAndVersion) {
productionDependencies[packageAndVersion] = allDependencies[packageAndVersion];
});
/**
* Determine if a package has a valid license
*
* @param {String} name
* @return {Boolean}
*/

var licenseStats = _.map(productionDependencies, processPackage);
var invalidLicenses = _.filter(licenseStats, function (pkg) { return !pkg.valid; });
function isInvalidLicense(name) {
let licenses = licensesForPackage(name);

if (!grunt.option('only-invalid')) {
grunt.log.debug(JSON.stringify(licenseStats, null, 2));
}
// verify all licenses for the package are in the config
return _.intersection(licenses, config.licenses).length < licenses.length;
}

// Build object containing only invalid packages
const invalidPackages = _.pick(packages, (pkg, name) => {
return isInvalidLicense(name);
});

if (invalidLicenses.length) {
grunt.log.debug(JSON.stringify(invalidLicenses, null, 2));
grunt.fail.warn(
'Non-confirming licenses: ' + _.pluck(invalidLicenses, 'name').join(', '),
invalidLicenses.length
);
}
if (Object.keys(invalidPackages).length) {
const util = require('util');
const execSync = require('child_process').execSync;
const names = Object.keys(invalidPackages);

done();
});
});
});
// Uses npm ls to create tree for package locations
const tree = execSync(`npm ls ${names.join(' ')}`);

grunt.log.debug(JSON.stringify(invalidPackages, null, 2));
grunt.fail.warn(
`Non-confirming licenses:\n ${names.join('\n ')}\n\n${tree}`,
invalidPackages.length
);
}

done();
});
};
Loading

0 comments on commit 332abe8

Please sign in to comment.