Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,11 @@
"scripts": {
"preprocess": "node tasks/preprocess.js",
"bundle": "node tasks/bundle.js",
"header": "node tasks/header.js",
"header-dist": "node tasks/header_dist.js",
"header-src": "node tasks/header_src.js",
"stats": "node tasks/stats.js",
"find-strings": "node tasks/find_locale_strings.js",
"build": "npm run preprocess && npm run find-strings && npm run bundle && npm run header && npm run stats",
"build": "npm run preprocess && npm run find-strings && npm run bundle && npm run header-dist && npm run stats",
"cibuild": "npm run preprocess && node tasks/cibundle.js",
"watch": "node tasks/watch.js",
"lint": "eslint --version && eslint .",
Expand All @@ -46,7 +47,7 @@
"start": "npm run start-test_dashboard",
"baseline": "node tasks/baseline.js",
"preversion": "check-node-version --node 12 --npm 6.14 && npm-link-check && npm ls --prod",
"version": "npm run build && npm run no-bad-char && git add -A dist src build",
"version": "npm run build && npm run no-bad-char && git add -A dist build src/version.js",
"postversion": "node -e \"console.log('Version bumped and committed. If ok, run: git push && git push --tags')\"",
"postpublish": "node tasks/sync_packages.js",
"postshrinkwrap": "chttps ."
Expand Down
31 changes: 31 additions & 0 deletions tasks/header_dist.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
var prependFile = require('prepend-file');
var constants = require('./util/constants');
var common = require('./util/common');

(function addHeadersInDistFiles() {
function _prepend(path, header) {
prependFile(path, header + '\n', common.throwOnError);
}

// add header to main dist bundles
var pathsDist = [
constants.pathToPlotlyDistMin,
constants.pathToPlotlyDist,
constants.pathToPlotlyDistWithMeta,
constants.pathToPlotlyGeoAssetsDist
];
pathsDist.forEach(function(path) {
_prepend(path, constants.licenseDist);
});

// add header and bundle name to partial bundle
constants.partialBundlePaths.forEach(function(pathObj) {
var headerDist = constants.licenseDist
.replace('plotly.js', 'plotly.js (' + pathObj.name + ')');
_prepend(pathObj.dist, headerDist);

var headerDistMin = constants.licenseDist
.replace('plotly.js', 'plotly.js (' + pathObj.name + ' - minified)');
_prepend(pathObj.distMin, headerDistMin);
});
})();
40 changes: 2 additions & 38 deletions tasks/header.js → tasks/header_src.js
Original file line number Diff line number Diff line change
@@ -1,48 +1,12 @@
var path = require('path');
var fs = require('fs');

var prependFile = require('prepend-file');
var falafel = require('falafel');
var glob = require('glob');

var constants = require('./util/constants');
var common = require('./util/common');

// main
addHeadersInDistFiles();
updateHeadersInSrcFiles();

// add headers to dist files
function addHeadersInDistFiles() {
function _prepend(path, header) {
prependFile(path, header + '\n', common.throwOnError);
}

// add header to main dist bundles
var pathsDist = [
constants.pathToPlotlyDistMin,
constants.pathToPlotlyDist,
constants.pathToPlotlyDistWithMeta,
constants.pathToPlotlyGeoAssetsDist
];
pathsDist.forEach(function(path) {
_prepend(path, constants.licenseDist);
});

// add header and bundle name to partial bundle
constants.partialBundlePaths.forEach(function(pathObj) {
var headerDist = constants.licenseDist
.replace('plotly.js', 'plotly.js (' + pathObj.name + ')');
_prepend(pathObj.dist, headerDist);

var headerDistMin = constants.licenseDist
.replace('plotly.js', 'plotly.js (' + pathObj.name + ' - minified)');
_prepend(pathObj.distMin, headerDistMin);
});
}

// add or update header to src/ lib/ files
function updateHeadersInSrcFiles() {
(function updateHeadersInSrcAndLibFiles() {
var srcGlob = path.join(constants.pathToSrc, '**/*.js');
var libGlob = path.join(constants.pathToLib, '**/*.js');

Expand Down Expand Up @@ -96,4 +60,4 @@ function updateHeadersInSrcFiles() {

return (header.value.replace(regex, '') === licenseStr.replace(regex, ''));
}
}
})();