-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8213 from tylersmalley/4.6-node6
- Loading branch information
Showing
9 changed files
with
161 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
4.4.7 | ||
6.4.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/` | ||
}] | ||
} | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); | ||
}; |
Oops, something went wrong.