Upgrade to Node 6.4.0

* Updated dependencies to include graceful-fs ~4.0
* Replaced deprecated grunt-s3 package with suggested grunt-aws-s3
* Update licenses task to better support npm 3

Signed-off-by: Tyler Smalley <tyler.smalley@elastic.co>
This commit is contained in:
Tyler Smalley 2016-07-20 15:00:30 -07:00
parent bfb81efb15
commit ad97552c03
7 changed files with 153 additions and 190 deletions

View file

@ -1 +1 @@
4.4.7
6.4.0

View file

@ -68,7 +68,7 @@
"url": "https://github.com/elastic/kibana.git"
},
"dependencies": {
"@bigfunger/decompress-zip": "0.2.0-stripfix2",
"@bigfunger/decompress-zip": "0.2.0-stripfix3",
"@bigfunger/jsondiffpatch": "0.1.38-webpack",
"@elastic/datemath": "2.3.0",
"@spalger/filesaver": "1.1.2",
@ -84,7 +84,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.38",
"babel-core": "5.8.38",
@ -125,8 +125,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.0",
"less-loader": "2.2.3",
"lodash": "3.10.1",
"marked": "0.3.5",
"minimatch": "2.0.10",
@ -159,7 +159,7 @@
"angular-mocks": "1.4.7",
"auto-release-sinon": "1.0.3",
"babel-eslint": "4.1.8",
"chokidar": "1.4.3",
"chokidar": "1.6.0",
"chromedriver": "2.22.1",
"elasticdump": "2.1.1",
"eslint": "1.10.3",
@ -167,15 +167,15 @@
"event-stream": "3.3.2",
"expect.js": "0.3.1",
"faker": "1.1.0",
"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.1",
"grunt-karma": "0.12.0",
"grunt-run": "0.5.0",
"grunt-s3": "0.2.0-alpha.3",
"grunt-esvm": "3.2.4",
"grunt-karma": "2.0.0",
"grunt-run": "0.6.0",
"grunt-simple-mocha": "0.4.0",
"gruntify-eslint": "1.0.1",
"handlebars": "4.0.5",
@ -183,29 +183,31 @@
"image-diff": "1.6.0",
"intern": "3.2.3",
"istanbul-instrumenter-loader": "0.1.3",
"karma": "0.13.9",
"karma": "1.2.0",
"karma-chrome-launcher": "0.2.0",
"karma-coverage": "0.5.1",
"karma-firefox-launcher": "0.1.6",
"karma-ie-launcher": "0.2.0",
"karma-mocha": "0.2.0",
"karma-safari-launcher": "0.1.1",
"license-checker": "3.1.0",
"load-grunt-config": "0.19.1",
"license-checker": "5.1.2",
"load-grunt-config": "0.19.2",
"makelogs": "3.0.2",
"mocha": "2.3.0",
"marked-text-renderer": "0.1.0",
"mocha": "2.5.3",
"ncp": "2.0.0",
"nock": "2.10.0",
"npm": "2.15.8",
"npm": "3.10.3",
"portscanner": "1.0.0",
"simple-git": "1.37.0",
"sinon": "1.17.2",
"source-map": "0.4.4",
"source-map-support": "0.4.0",
"source-map": "0.5.6",
"source-map-support": "0.2.10",
"supertest": "1.2.0",
"supertest-as-promised": "2.0.2"
},
"engines": {
"node": "4.4.7",
"npm": "2.15.8"
"node": "6.4.0",
"npm": "3.10.3"
}
}

View file

@ -1,5 +1,5 @@
import _ from 'lodash';
import { SourceMapConsumer } from 'source-map/lib/source-map/source-map-consumer';
import { SourceMapConsumer } from 'source-map/lib/source-map-consumer';
import { parse } from 'url';
function SourceMapReader(url, map) {

21
tasks/config/aws_s3.js Normal file
View file

@ -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/`
}]
}
};
};

View file

@ -2,62 +2,44 @@ module.exports = function (grunt) {
return {
options: {
licenses: [
'MIT',
'MIT*',
'MIT License',
'MIT/X11',
'OFL-1.1 AND MIT',
'new BSD, and MIT',
'(MIT OR Apache-2.0)',
'BSD',
'BSD*',
'BSD New',
'BSD-like',
'BSD-2-Clause',
'(BSD-2-Clause OR MIT OR Apache-2.0)',
'(BSD-2-Clause OR MIT)',
'(MIT AND CC-BY-3.0)',
'(MIT OR Apache-2.0)',
'AFLv2.1',
'Apache',
'Apache 2.0',
'Apache License, v2.0',
'Apache*',
'Apache, Version 2.0',
'Apache-2.0',
'BSD',
'BSD New',
'BSD*',
'BSD-2-Clause',
'BSD-3-Clause',
'BSD-3-Clause AND MIT',
'BSD-like',
'CC-BY',
'CC-BY-4.0',
'Apache',
'Apache*',
'Apache v2',
'Apache 2.0',
'Apache2',
'Apache-2.0',
'Apache, Version 2.0',
'Apache License, v2.0',
'ISC',
'WTFPL',
'Public-Domain',
'MIT',
'MIT*',
'MIT/X11',
'OFL-1.1 AND MIT',
'Public domain',
'UNLICENSE'
'WTFPL',
'new BSD, and MIT'
],
overrides: {
'amdefine@1.0.0': ['BSD-3-Clause', 'MIT'],
'@spalger/angular-bootstrap@0.12.1': ['MIT'],
'angular-ui-ace@0.2.3': ['MIT'],
'assert-plus@0.1.5': ['MIT'],
'buffers@0.1.1': ['MIT/X11'],
'color-name@1.0.0': ['UNLICENSE'],
'commander@2.2.0': ['MIT'],
'css-color-names@0.0.1': ['MIT'],
'css-parse@1.0.4': ['MIT'],
'css-stringify@1.0.5': ['MIT'],
'css@1.0.8': ['MIT'],
'cycle@1.0.3': ['Public-Domain'],
'delegate@3.0.1': ['MIT'],
'FileSaver@1.1.0': ['MIT'],
'flatten@0.0.1': ['MIT'],
'indexof@0.0.1': ['MIT'],
'inherits@1.0.0': ['ISC'],
'is-buffer@1.1.2': ['MIT'],
'jsonpointer@1.1.0': ['MIT'],
'lazy-cache@1.0.3': ['MIT'],
'leaflet@0.7.2': ['BSD-2-Clause'],
'Nonsense@0.1.2': ['Public-Domain'],
'pkginfo@0.2.3': ['MIT'],
'readable-stream@2.0.5': ['MIT'],
'repeat-string@1.5.2': ['MIT'],
'ripemd160@0.2.0': ['MIT'],
'select@1.0.6': ['MIT'],
'uglify-js@2.2.5': ['BSD'],

View file

@ -1,7 +1,5 @@
import _ from 'lodash';
import {
fromNode,
} from 'bluebird';
import { fromNode } from 'bluebird';
import npm from 'npm';
import npmLicense from 'license-checker';
@ -10,82 +8,67 @@ export default function licenses(grunt) {
const config = this.options();
const done = this.async();
const result = {};
const options = { start: process.cwd(), json: true };
const checkQueueLength = 2;
const result = [];
const options = {
start: process.cwd(),
production: true,
json: true
};
function getLicenses(dependency) {
if (config.overrides[dependency.name]) {
return config.overrides[dependency.name];
}
if (dependency && dependency.licenses) {
return _.flatten([dependency.licenses]);
}
}
function processPackage(dependency) {
const pkgInfo = Object.assign({}, dependency);
pkgInfo.licenses = getLicenses(dependency);
pkgInfo.valid = (function () {
if (_.intersection(pkgInfo.licenses, config.licenses).length > 0) {
return true;
}
return false;
}());
return pkgInfo;
}
const allDependencies = await fromNode(cb => {
npmLicense.init(options, result => {
const packages = await fromNode(cb => {
npmLicense.init(options, (result, error) => {
cb(undefined, result);
});
});
// Only check production NPM dependencies, not dev
await fromNode(cb => npm.load({production: true}, cb));
/**
* Licenses for a package by name with overrides
*
* @param {String} name
* @return {Array}
*/
const npmList = await fromNode(cb => {
npm.commands.list([], true, (a, b, npmList) => cb(undefined, npmList));
});
function licensesForPackage(name) {
let licenses = packages[name].licenses;
// Recurse npm --production --json ls output, create array of dependency
// objects, each with a name prop formatted as 'package@version' and a
// path prop leading back to the root dependency.
function getDependencies(dependencies, path, list = []) {
Object.keys(dependencies).forEach(name => {
const dependency = dependencies[name];
const newPath = path ? `${path} -> ${dependency.from}` : dependency.from;
list.push({
path: newPath,
name: name + '@' + dependency.version
});
if (config.overrides.hasOwnProperty(name)) {
licenses = config.overrides[name];
}
if (dependency.dependencies) {
getDependencies(dependency.dependencies, newPath, list);
}
});
return list;
};
const productionDependencies = {};
getDependencies(npmList.dependencies).forEach(dependency => {
productionDependencies[dependency.name] =
Object.assign({}, allDependencies[dependency.name], dependency);
});
const licenseStats = _.map(productionDependencies, processPackage);
const invalidLicenses = licenseStats.filter(pkg => !pkg.valid);
if (!grunt.option('only-invalid')) {
grunt.log.debug(JSON.stringify(licenseStats, null, 2));
return typeof licenses === 'string' ? [licenses] : licenses;
}
if (invalidLicenses.length) {
grunt.log.debug(JSON.stringify(invalidLicenses, null, 2));
/**
* Determine if a package has a valid license
*
* @param {String} name
* @return {Boolean}
*/
function isInvalidLicense(name) {
let licenses = licensesForPackage(name);
// 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 (Object.keys(invalidPackages).length) {
const util = require('util');
const execSync = require('child_process').execSync;
const names = Object.keys(invalidPackages);
// 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 ${_.pluck(invalidLicenses, 'path').join('\n')}`,
invalidLicenses.length
`Non-confirming licenses:\n ${names.join('\n ')}\n\n${tree}`,
invalidPackages.length
);
}

View file

@ -1,88 +1,63 @@
module.exports = function (grunt) {
var readline = require('readline');
var url = require('url');
var fs = require('fs');
var _ = require('lodash');
const readline = require('readline');
const url = require('url');
const fs = require('fs');
const path = require('path');
const _ = require('lodash');
// build, then zip and upload to s3
grunt.registerTask('release', [
'_release:confirmUpload',
'_release:loadS3Config',
'build',
'_release:setS3Uploads',
's3:release',
'_release:loadS3Config',
'aws_s3:staging',
'_release:complete'
]);
grunt.registerTask('_release:confirmUpload', function () {
var rl = readline.createInterface({
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout
});
rl.on('close', this.async());
rl.question('Do you want to actually upload the files to s3 after building?, [N/y] ', function (resp) {
var debug = resp.toLowerCase().trim()[0] !== 'y';
grunt.config.set('s3.release.debug', debug);
const debug = resp.toLowerCase().trim()[0] !== 'y';
grunt.config.set('aws_s3.staging.options.debug', debug);
rl.close();
});
});
// collect the key and secret from the .aws-config.json file, finish configuring the s3 task
grunt.registerTask('_release:loadS3Config', function () {
var config = grunt.file.readJSON('.aws-config.json');
grunt.config('s3.options', {
key: config.key,
secret: config.secret
const config = grunt.file.readJSON('.aws-config.json');
grunt.config('aws_s3.options', {
accessKeyId: config.key,
secretAccessKey: config.secret,
bucket: config.bucket || grunt.config.get('aws_s3.config.bucket'),
region: config.region
});
});
grunt.registerTask('_release:setS3Uploads', function () {
const { sha, version } = grunt.config.get('build');
var uploads = grunt.config.get('platforms')
.reduce(function (files, platform) {
return files.concat(
platform.tarName,
platform.tarName + '.sha1.txt',
platform.zipName,
platform.zipName + '.sha1.txt',
platform.rpmName,
platform.rpmName && platform.rpmName + '.sha1.txt',
platform.debName,
platform.debName && platform.debName + '.sha1.txt'
);
}, [])
.filter(function (filename) {
if (_.isUndefined(filename)) return false;
try {
fs.accessSync('target/' + filename, fs.F_OK);
return true;
} catch (e) {
return false;
}
})
.map(function (filename) {
const src = `target/${filename}`;
const shortSha = sha.substr(0, 7);
const dest = `kibana/staging/${version}-${shortSha}/kibana/${filename}`;
return { src, dest };
});
grunt.config.set('s3.release.upload', uploads);
});
grunt.registerTask('_release:complete', function () {
grunt.log.ok('Builds released');
var links = grunt.config.get('s3.release.upload').reduce((t, {dest}) => {
var link = url.format({
protocol: 'https',
hostname: 'download.elastic.co',
pathname: dest
});
return `${t}${link}\n`;
}, '');
grunt.log.write(links);
const { sha, version } = grunt.config.get('build');
const config = grunt.config.get('aws_s3.staging.files');
grunt.log.ok('Builds uploaded');
fs.readdirSync('./target').forEach((file) => {
if (path.extname(file) !== '.txt') {
let link = url.format({
protocol: 'https',
hostname: 'download.elastic.co',
pathname: config[0].dest + file
});
grunt.log.writeln(link);
}
});
});
};