Permalink
Browse files

Add license banner to JS build output (#2759)

* Include open-source license attribution at the top of all JS files in build
* Also output to notice.txt in bin-release folder
* Cleanup attribution comments in source code
* Import promise-polyfill@v7.1.0 from node_modules

JW8-1235
  • Loading branch information...
robwalch authored and johnBartos committed Mar 6, 2018
1 parent 921fb5f commit 5d3360f56d7f88d104615e2092ba31dbd4d44027
Showing with 183 additions and 251 deletions.
  1. +28 −15 Gruntfile.js
  2. +114 −0 jwplayer.license.notice.js
  3. +6 −0 package-lock.json
  4. +1 −0 package.json
  5. +2 −228 src/js/polyfills/promise.js
  6. +9 −0 src/js/utils/backbone.events.js
  7. +6 −4 src/js/utils/underscore.js
  8. +11 −2 webpack.config.js
  9. +6 −2 yarn.lock
View
@@ -3,26 +3,27 @@
/* eslint-env node */
/* eslint no-process-env: 0 */
var webpack = require('webpack');
var webpackConfigs = require('./webpack.config');
var webpackCompilers = {};
var env = process.env;
var execSync = require('child_process').execSync;
const fs = require('fs');
const webpack = require('webpack');
const webpackConfigs = require('./webpack.config');
const webpackCompilers = {};
const env = process.env;
const execSync = require('child_process').execSync;
function getBuildVersion(packageInfo) {
// Build Version: {major.minor.revision}
var metadata = '';
let metadata = '';
if (env.BUILD_NUMBER) {
var branch = env.GIT_BRANCH;
const branch = env.GIT_BRANCH;
metadata = 'opensource';
if (branch) {
metadata += '_' + branch.replace(/^origin\//, '').replace(/[^0-9A-Za-z-]/g, '-');
}
metadata += '.' + env.BUILD_NUMBER;
} else {
var now = new Date();
const now = new Date();
now.setTime(now.getTime()-now.getTimezoneOffset()*60000);
metadata = 'local.' + now.toISOString().replace(/[\.\-:T]/g, '-').replace(/Z|\.\d/g, '');
metadata = 'local.' + now.toISOString().replace(/[.-:T]/g, '-').replace(/Z|\.\d/g, '');
}
return packageInfo.version +'+'+ metadata;
}
@@ -31,8 +32,8 @@ module.exports = function(grunt) {
require('load-grunt-tasks')(grunt);
var packageInfo = grunt.file.readJSON('package.json');
var buildVersion = getBuildVersion(packageInfo);
const packageInfo = grunt.file.readJSON('package.json');
const buildVersion = getBuildVersion(packageInfo);
console.log('%s v%s', packageInfo.name, buildVersion);
@@ -201,7 +202,7 @@ module.exports = function(grunt) {
if (err) {
throw err;
}
var jsonStats = stats.toJson();
const jsonStats = stats.toJson();
if (jsonStats.errors.length) {
throw jsonStats.errors;
}
@@ -213,15 +214,26 @@ module.exports = function(grunt) {
});
grunt.registerTask('hooks', 'Install Pre Push Hook', function() {
var command = '\\cp .github/hooks/pre-push .git/hooks/pre-push';
const command = '\\cp .github/hooks/pre-push .git/hooks/pre-push';
execSync(command, {
cwd: '.',
stdio: [0, 1, 2]
});
});
grunt.registerTask('notice', 'Create notice.txt file', function() {
const notice = require('./jwplayer.license.notice.js');
const output = './bin-release/notice.txt';
const done = this.async();
fs.writeFile(output, notice, function(err4) {
if (err4) { throw err4; }
console.log('Wrote file', output);
done();
});
});
grunt.registerTask('lint', 'ESLints JavaScript & Stylelints LESS', function(target) {
var command = 'npm run lint';
let command = 'npm run lint';
if (target === 'js') {
command = command + ':js';
}
@@ -235,7 +247,7 @@ module.exports = function(grunt) {
});
grunt.registerTask('docs', 'Generate API documentation', function() {
var command = 'npm run docs';
const command = 'npm run docs';
execSync(command, {
cwd: '.',
stdio: [0, 1, 2]
@@ -260,6 +272,7 @@ module.exports = function(grunt) {
grunt.registerTask('build', [
'clean:dist',
'build-js',
'notice',
'karma:local'
]);
View
@@ -0,0 +1,114 @@
const packageJson = require('./package.json');
const devDeps = packageJson.devDependencies;
const YEAR = new Date().getFullYear();
const versions = {
backbone: '1.1.2',
'can-autoplay': '3.0.0',
'intersection-observer': '' + devDeps['intersection-observer'],
'promise-polyfill': '' + devDeps['promise-polyfill'],
'vtt.js': '0.13.0',
underscore: '1.6.0'
};
const notice = `JW Player version ${packageJson.version}
Copyright (c) ${YEAR}, JW Player, All Rights Reserved
https://github.com/jwplayer/jwplayer/blob/v${packageJson.version}/README.md
This source code and its use and distribution is subject to the terms and conditions of the applicable license agreement.
https://www.jwplayer.com/tos/
This product includes portions of other software. For the full text of licenses, see below:
JW Player Third Party Software Notices and/or Additional Terms and Conditions
**************************************************************************************************
The following software is used under Apache License 2.0
**************************************************************************************************
vtt.js v${versions['vtt.js']}
Copyright (c) ${YEAR} Mozilla (http://mozilla.org)
https://github.com/mozilla/vtt.js/blob/v${versions['vtt.js']}/LICENSE
* * *
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
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and
limitations under the License.
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.
**************************************************************************************************
The following software is used under MIT license
**************************************************************************************************
Underscore.js v${versions.underscore}
Copyright (c) 2009-2014 Jeremy Ashkenas, DocumentCloud and Investigative
https://github.com/jashkenas/underscore/blob/${versions.underscore}/LICENSE
Backbone backbone.events.js v${versions.backbone}
Copyright (c) 2010-2014 Jeremy Ashkenas, DocumentCloud
https://github.com/jashkenas/backbone/blob/${versions.backbone}/LICENSE
Promise Polyfill v${versions['promise-polyfill']}
Copyright (c) 2014 Taylor Hakes and Forbes Lindesay
https://github.com/taylorhakes/promise-polyfill/blob/v${versions['promise-polyfill']}/LICENSE
can-autoplay.js v${versions['can-autoplay']}
Copyright (c) 2017 video-dev
https://github.com/video-dev/can-autoplay/blob/v${versions['can-autoplay']}/LICENSE
* * *
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.
**************************************************************************************************
The following software is used under W3C license
**************************************************************************************************
Intersection Observer v${versions['intersection-observer']}
Copyright (c) 2016 Google Inc. (http://google.com)
https://github.com/w3c/IntersectionObserver/blob/v${versions['intersection-observer']}/LICENSE.md
* * *
W3C SOFTWARE AND DOCUMENT NOTICE AND LICENSE
Status: This license takes effect 13 May, 2015.
This work is being provided by the copyright holders under the following license.
License
By obtaining and/or copying this work, you (the licensee) agree that you have read, understood, and will comply with the following terms and conditions.
Permission to copy, modify, and distribute this work, with or without modification, for any purpose and without fee or royalty is hereby granted, provided that you include the following on ALL copies of the work or portions thereof, including modifications:
The full text of this NOTICE in a location viewable to users of the redistributed or derivative work.
Any pre-existing intellectual property disclaimers, notices, or terms and conditions. If none exist, the W3C Software and Document Short Notice should be included.
Notice of any changes or modifications, through a copyright statement on the new code or document such as "This software or document includes material copied from or derived from [title and URI of the W3C document]. Copyright © [YEAR] W3C® (MIT, ERCIM, Keio, Beihang)."
Disclaimers
THIS WORK IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT THE USE OF THE SOFTWARE OR DOCUMENT WILL NOT INFRINGE ANY THIRD PARTY PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENT.
The name and trademarks of copyright holders may NOT be used in advertising or publicity pertaining to the work without specific, written prior permission. Title to copyright in this work will at all times remain with copyright holders.`;
const invalidResults = (/.*(undefined|vv|\Wv\W|\/\/LICENSE)/g).exec(notice);
if (invalidResults) {
throw new Error(`Found invalid results in notice.txt:
${invalidResults.join('\n')}
${JSON.stringify(versions, null, 4)}`);
}
module.exports = notice;
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -61,6 +61,7 @@
"phantomjs-prebuilt": "2.1.16",
"postcss-loader": "2.0.9",
"postcss-safe-parser": "3.0.1",
"promise-polyfill": "7.1.0",
"raw-loader": "0.5.1",
"requirejs": "2.3.5",
"simple-style-loader": "0.4.3",
Oops, something went wrong.

0 comments on commit 5d3360f

Please sign in to comment.