mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[build] Add notice file (#10344)
* [build] Add notice file * [build] Include license text if available * [build] Look for both license and notice files * [build] Add node license to notice * [build] Add a base notice file including info on committed dependencies * Bump license copyright year * [build] Kibana at top of notice
This commit is contained in:
parent
9bc4d9158b
commit
e1b677ac9f
4 changed files with 147 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
Copyright 2012–2016 Elasticsearch BV
|
||||
Copyright 2012–2017 Elasticsearch BV
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ module.exports = function (grunt) {
|
|||
'_build:readme',
|
||||
'_build:babelCache',
|
||||
'_build:installNpmDeps',
|
||||
'_build:notice',
|
||||
'_build:removePkgJsonDeps',
|
||||
'clean:testsFromModules',
|
||||
'run:optimizeBuild',
|
||||
|
|
86
tasks/build/notice.js
Normal file
86
tasks/build/notice.js
Normal file
|
@ -0,0 +1,86 @@
|
|||
import _ from 'lodash';
|
||||
import npm from 'npm';
|
||||
import npmLicense from 'license-checker';
|
||||
import glob from 'glob';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { execSync } from 'child_process';
|
||||
|
||||
export default function licenses(grunt) {
|
||||
grunt.registerTask('_build:notice', 'Adds a notice', function () {
|
||||
const done = this.async();
|
||||
const buildPath = path.join(grunt.config.get('buildDir'), 'kibana');
|
||||
|
||||
function getPackagePaths() {
|
||||
const packagePaths = {};
|
||||
const installedPackages = execSync(`npm ls --parseable --long`, {
|
||||
cwd: buildPath
|
||||
});
|
||||
installedPackages.toString().trim().split('\n').forEach(pkg => {
|
||||
const packageDetails = pkg.split(':');
|
||||
const [modulePath, packageName] = packageDetails;
|
||||
const licenses = glob.sync(path.join(modulePath, '*LICENSE*'));
|
||||
const notices = glob.sync(path.join(modulePath, '*NOTICE*'));
|
||||
packagePaths[packageName] = {
|
||||
relative: modulePath.replace(/.*\/kibana\//, ''),
|
||||
licenses,
|
||||
notices
|
||||
};
|
||||
});
|
||||
return packagePaths;
|
||||
}
|
||||
|
||||
function combineFiles(filePaths) {
|
||||
let content = '';
|
||||
filePaths.forEach(filePath => {
|
||||
content += fs.readFileSync(filePath) + '\n';
|
||||
});
|
||||
return content;
|
||||
}
|
||||
|
||||
function getNodeInfo() {
|
||||
const nodeVersion = grunt.config.get('nodeVersion');
|
||||
const nodeDir = path.join(grunt.config.get('root'), '.node_binaries', nodeVersion);
|
||||
const licensePath = path.join(nodeDir, 'linux-x64', 'LICENSE');
|
||||
const license = fs.readFileSync(licensePath);
|
||||
return `This product bundles Node.js.\n\n${license}`;
|
||||
}
|
||||
|
||||
function getPackageInfo(packages) {
|
||||
const packagePaths = getPackagePaths();
|
||||
const overrides = grunt.config.get('licenses.options.overrides');
|
||||
let content = '';
|
||||
_.forOwn(packages, (value, key) => {
|
||||
const licenses = [].concat(overrides.hasOwnProperty(key) ? overrides[key] : value.licenses);
|
||||
if (!licenses.length || licenses.includes('UNKNOWN')) return grunt.fail.fatal(`Unknown license for ${key}`);
|
||||
const packagePath = packagePaths[key];
|
||||
const readLicenseAndNotice = combineFiles([].concat(packagePath.licenses, packagePath.notices));
|
||||
const licenseOverview = licenses.length > 1 ? `the\n"${licenses.join('", ')} licenses` : `a\n"${licenses[0]}" license`;
|
||||
const licenseAndNotice = readLicenseAndNotice ? `\n${readLicenseAndNotice}` : ` For details, see ${packagePath.relative}/.`;
|
||||
const combinedText = `This product bundles ${key} which is available under ${licenseOverview}.${licenseAndNotice}\n---\n`;
|
||||
|
||||
content += combinedText;
|
||||
});
|
||||
return content;
|
||||
}
|
||||
|
||||
function getBaseNotice() {
|
||||
return fs.readFileSync(path.join(__dirname, 'notice', 'base_notice.txt'));
|
||||
}
|
||||
|
||||
npmLicense.init({
|
||||
start: buildPath,
|
||||
production: true,
|
||||
json: true
|
||||
}, (result, error) => {
|
||||
if (error) return grunt.fail.fatal(error);
|
||||
const noticePath = path.join(buildPath, 'NOTICE.txt');
|
||||
const fd = fs.openSync(noticePath, 'w');
|
||||
fs.appendFileSync(fd, getBaseNotice());
|
||||
fs.appendFileSync(fd, getPackageInfo(result));
|
||||
fs.appendFileSync(fd, getNodeInfo());
|
||||
fs.closeSync(fd);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}
|
59
tasks/build/notice/base_notice.txt
Normal file
59
tasks/build/notice/base_notice.txt
Normal file
|
@ -0,0 +1,59 @@
|
|||
Kibana
|
||||
Copyright 2012-2017 Elasticsearch
|
||||
|
||||
---
|
||||
This product bundles angular-ui-bootstrap@0.12.1 which is available under a
|
||||
"MIT" license.
|
||||
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2012-2014 the AngularUI Team, https://github.com/organizations/angular-ui/teams/291112
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
---
|
||||
This product bundles bootstrap@3.3.6 which is available under a
|
||||
"MIT" license.
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2011-2015 Twitter, Inc
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
|
||||
---
|
||||
This product bundles geohash.js which is available under a
|
||||
"MIT" license. For details, see src/ui/public/utils/decode_geo_hash.js.
|
||||
---
|
Loading…
Add table
Add a link
Reference in a new issue