liferay-npm-bundler
Advanced tools
Comparing version 1.6.0 to 1.6.1
142
lib/index.js
@@ -8,4 +8,2 @@ 'use strict'; | ||
exports.default = function (args) { | ||
var promises = []; | ||
var versionsInfo = config.getVersionsInfo(); | ||
@@ -16,56 +14,7 @@ | ||
return; | ||
} | ||
_report2.default.versionsInfo(versionsInfo); | ||
var outputDir = _path2.default.resolve(config.getOutputDir()); | ||
// Create work directories | ||
_fsExtra2.default.mkdirsSync(_path2.default.join(outputDir, 'node_modules')); | ||
// Copy project's package.json | ||
promises.push(copyRootPackageJson(outputDir)); | ||
// Grab NPM dependencies | ||
var pkgs = (0, _dependencies.getPackageDependencies)('.', config.getIncludeDependencies()); | ||
pkgs = Object.keys(pkgs).map(function (id) { | ||
return pkgs[id]; | ||
}); | ||
pkgs = pkgs.filter(function (pkg) { | ||
return pkg.dir != '.'; | ||
}); | ||
_report2.default.dependencies(pkgs); | ||
// Process NPM dependencies | ||
var start = process.hrtime(); | ||
log.info('Bundling ' + pkgs.length + ' dependencies...'); | ||
if (config.isProcessSerially()) { | ||
_report2.default.warn('Option process-serially is on: this may degrade build performance.'); | ||
promises.push(iterateSerially(pkgs, function (pkg) { | ||
return bundlePackage(pkg, outputDir); | ||
})); | ||
} else { | ||
promises.push.apply(promises, _toConsumableArray(pkgs.map(function (pkg) { | ||
return bundlePackage(pkg, outputDir); | ||
}))); | ||
_report2.default.versionsInfo(versionsInfo); | ||
} | ||
Promise.all(promises).then(function () { | ||
var hrtime = process.hrtime(start); | ||
log.info('Bundling took ' + (0, _prettyTime2.default)(hrtime)); | ||
_report2.default.executionTime(hrtime); | ||
if (config.isDumpReport()) { | ||
_fsExtra2.default.writeFileSync(config.getReportFilePath(), _report2.default.toHtml()); | ||
log.info('Report written to ' + config.getReportFilePath()); | ||
} | ||
}).catch(function (err) { | ||
log.error(err); | ||
process.exit(1); | ||
}); | ||
insight.init().then(run); | ||
}; | ||
@@ -111,2 +60,6 @@ | ||
var _insight = require('./insight'); | ||
var insight = _interopRequireWildcard(_insight); | ||
var _dependencies = require('./dependencies'); | ||
@@ -136,2 +89,65 @@ | ||
/** | ||
* Real tool execution | ||
* @return {void} | ||
*/ | ||
function run() { | ||
// Create work directories | ||
var outputDir = _path2.default.resolve(config.getOutputDir()); | ||
_fsExtra2.default.mkdirsSync(_path2.default.join(outputDir, 'node_modules')); | ||
var promises = []; | ||
// Copy project's package.json | ||
promises.push(copyRootPackageJson(outputDir)); | ||
// Grab NPM dependencies | ||
var pkgs = (0, _dependencies.getPackageDependencies)('.', config.getIncludeDependencies()); | ||
pkgs = Object.keys(pkgs).map(function (id) { | ||
return pkgs[id]; | ||
}); | ||
pkgs = pkgs.filter(function (pkg) { | ||
return pkg.dir != '.'; | ||
}); | ||
_report2.default.dependencies(pkgs); | ||
// Process NPM dependencies | ||
var start = process.hrtime(); | ||
log.info('Bundling ' + pkgs.length + ' dependencies...'); | ||
if (config.isProcessSerially()) { | ||
_report2.default.warn('Option process-serially is on: this may degrade build performance.'); | ||
promises.push(iterateSerially(pkgs, function (pkg) { | ||
return bundlePackage(pkg, outputDir); | ||
})); | ||
} else { | ||
promises.push.apply(promises, _toConsumableArray(pkgs.map(function (pkg) { | ||
return bundlePackage(pkg, outputDir); | ||
}))); | ||
} | ||
Promise.all(promises).then(function () { | ||
var hrtime = process.hrtime(start); | ||
_report2.default.executionTime(hrtime); | ||
log.info('Bundling took ' + (0, _prettyTime2.default)(hrtime)); | ||
// Send report analytics data | ||
_report2.default.sendAnalytics(); | ||
// Write report if requested | ||
if (config.isDumpReport()) { | ||
_fsExtra2.default.writeFileSync(config.getReportFilePath(), _report2.default.toHtml()); | ||
log.info('Report written to ' + config.getReportFilePath()); | ||
} | ||
}).catch(function (err) { | ||
log.error(err); | ||
process.exit(1); | ||
}); | ||
} | ||
/** | ||
* Copy project root package.json file to output directory. | ||
@@ -145,15 +161,17 @@ * @param {String} outputDir the output directory path | ||
['dependencies', 'devDependencies'].forEach(function (scope) { | ||
Object.keys(pkgJson[scope]).forEach(function (depName) { | ||
var depVersion = pkgJson[scope][depName]; | ||
if (pkgJson[scope] != null) { | ||
Object.keys(pkgJson[scope]).forEach(function (depName) { | ||
var depVersion = pkgJson[scope][depName]; | ||
if (_semver2.default.validRange(depVersion) == null) { | ||
var depPkgJsonPath = _path2.default.join(depVersion.substring(5), 'package.json'); | ||
if (_semver2.default.validRange(depVersion) == null) { | ||
var depPkgJsonPath = _path2.default.join(depVersion.substring(5), 'package.json'); | ||
var depPkgJson = (0, _readJsonSync2.default)(depPkgJsonPath); | ||
var depPkgJson = (0, _readJsonSync2.default)(depPkgJsonPath); | ||
pkgJson[scope][depName] = depPkgJson.version; | ||
pkgJson[scope][depName] = depPkgJson.version; | ||
_report2.default.linkedDependency(depName, depVersion, depPkgJson.version); | ||
} | ||
}); | ||
_report2.default.linkedDependency(depName, depVersion, depPkgJson.version); | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -160,0 +178,0 @@ |
@@ -12,2 +12,4 @@ 'use strict'; | ||
var _analytics = require('./analytics'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -46,2 +48,14 @@ | ||
/** | ||
* Dump report information to insight package so that it gets exported to | ||
* our Google Analytics account. | ||
* @return {void} | ||
*/ | ||
}, { | ||
key: 'sendAnalytics', | ||
value: function sendAnalytics() { | ||
return (0, _analytics.analyticsDump)(this); | ||
} | ||
/** | ||
* Register execution time. | ||
@@ -48,0 +62,0 @@ * @param {Array} hrtime the time it took to execute |
{ | ||
"name": "liferay-npm-bundler", | ||
"version": "1.6.0", | ||
"version": "1.6.1", | ||
"description": "A CLI utility to bundle NPM dependencies of a Liferay OSGi bundle.", | ||
@@ -21,3 +21,4 @@ "main": "lib/index.js", | ||
"globby": "^6.1.0", | ||
"liferay-npm-build-tools-common": "1.6.0", | ||
"insight": "0.10.0", | ||
"liferay-npm-build-tools-common": "1.6.1", | ||
"pretty-time": "^0.2.0", | ||
@@ -24,0 +25,0 @@ "read-json-sync": "^1.1.1", |
@@ -164,2 +164,3 @@ # liferay-npm-bundler | ||
"process-serially": <true|false>, | ||
"dump-report": <true|false>, | ||
"verbose": <true|false> | ||
@@ -206,3 +207,6 @@ "*" : { | ||
same time. | ||
* **"verbose"**: dump detailed information about what the tool is doing. | ||
* **"dump-report"**: write a report HTML file in the project directory with | ||
details about how each package is transformed and what has been done. | ||
* **"verbose"**: dump detailed information about what the tool is doing to the | ||
console. | ||
* **(list of plugins)**: is a comma separated list of strings defining the | ||
@@ -209,0 +213,0 @@ `liferay-npm-bundler` plugins to call (note that the |
@@ -12,2 +12,3 @@ import * as babel from 'babel-core'; | ||
import * as config from './config'; | ||
import * as insight from './insight'; | ||
import {getPackageDependencies} from './dependencies'; | ||
@@ -23,4 +24,2 @@ import * as log from './log'; | ||
export default function(args) { | ||
let promises = []; | ||
const versionsInfo = config.getVersionsInfo(); | ||
@@ -31,11 +30,20 @@ | ||
return; | ||
} else { | ||
report.versionsInfo(versionsInfo); | ||
} | ||
report.versionsInfo(versionsInfo); | ||
insight.init().then(run); | ||
} | ||
/** | ||
* Real tool execution | ||
* @return {void} | ||
*/ | ||
function run() { | ||
// Create work directories | ||
const outputDir = path.resolve(config.getOutputDir()); | ||
// Create work directories | ||
fs.mkdirsSync(path.join(outputDir, 'node_modules')); | ||
let promises = []; | ||
// Copy project's package.json | ||
@@ -72,5 +80,10 @@ promises.push(copyRootPackageJson(outputDir)); | ||
log.info(`Bundling took ${pretty(hrtime)}`); | ||
report.executionTime(hrtime); | ||
log.info(`Bundling took ${pretty(hrtime)}`); | ||
// Send report analytics data | ||
report.sendAnalytics(); | ||
// Write report if requested | ||
if (config.isDumpReport()) { | ||
@@ -96,22 +109,24 @@ fs.writeFileSync(config.getReportFilePath(), report.toHtml()); | ||
['dependencies', 'devDependencies'].forEach(scope => { | ||
Object.keys(pkgJson[scope]).forEach(depName => { | ||
const depVersion = pkgJson[scope][depName]; | ||
if (pkgJson[scope] != null) { | ||
Object.keys(pkgJson[scope]).forEach(depName => { | ||
const depVersion = pkgJson[scope][depName]; | ||
if (semver.validRange(depVersion) == null) { | ||
const depPkgJsonPath = path.join( | ||
depVersion.substring(5), | ||
'package.json' | ||
); | ||
if (semver.validRange(depVersion) == null) { | ||
const depPkgJsonPath = path.join( | ||
depVersion.substring(5), | ||
'package.json' | ||
); | ||
const depPkgJson = readJsonSync(depPkgJsonPath); | ||
const depPkgJson = readJsonSync(depPkgJsonPath); | ||
pkgJson[scope][depName] = depPkgJson.version; | ||
pkgJson[scope][depName] = depPkgJson.version; | ||
report.linkedDependency( | ||
depName, | ||
depVersion, | ||
depPkgJson.version | ||
); | ||
} | ||
}); | ||
report.linkedDependency( | ||
depName, | ||
depVersion, | ||
depPkgJson.version | ||
); | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -118,0 +133,0 @@ |
import {htmlDump} from './html'; | ||
import {analyticsDump} from './analytics'; | ||
@@ -28,2 +29,11 @@ /** | ||
/** | ||
* Dump report information to insight package so that it gets exported to | ||
* our Google Analytics account. | ||
* @return {void} | ||
*/ | ||
sendAnalytics() { | ||
return analyticsDump(this); | ||
} | ||
/** | ||
* Register execution time. | ||
@@ -30,0 +40,0 @@ * @param {Array} hrtime the time it took to execute |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
255087
92
3549
229
9
+ Addedinsight@0.10.0
+ Addedajv@6.12.6(transitive)
+ Addedansi-escapes@3.2.0(transitive)
+ Addedansi-regex@3.0.1(transitive)
+ Addedansi-styles@3.2.1(transitive)
+ Addedasn1@0.2.6(transitive)
+ Addedassert-plus@1.0.0(transitive)
+ Addedasync@2.6.4(transitive)
+ Addedasynckit@0.4.0(transitive)
+ Addedaws-sign2@0.7.0(transitive)
+ Addedaws4@1.13.2(transitive)
+ Addedbcrypt-pbkdf@1.0.2(transitive)
+ Addedcaseless@0.12.0(transitive)
+ Addedchalk@2.4.2(transitive)
+ Addedchardet@0.4.2(transitive)
+ Addedcli-cursor@2.1.0(transitive)
+ Addedcli-width@2.2.1(transitive)
+ Addedcolor-convert@1.9.3(transitive)
+ Addedcolor-name@1.1.3(transitive)
+ Addedcombined-stream@1.0.8(transitive)
+ Addedconf@1.4.0(transitive)
+ Addedcore-util-is@1.0.2(transitive)
+ Addeddashdash@1.14.1(transitive)
+ Addeddelayed-stream@1.0.0(transitive)
+ Addeddot-prop@4.2.1(transitive)
+ Addedecc-jsbn@0.1.2(transitive)
+ Addedenv-paths@1.0.0(transitive)
+ Addedextend@3.0.2(transitive)
+ Addedexternal-editor@2.2.0(transitive)
+ Addedextsprintf@1.3.0(transitive)
+ Addedfast-deep-equal@3.1.3(transitive)
+ Addedfast-json-stable-stringify@2.1.0(transitive)
+ Addedfigures@2.0.0(transitive)
+ Addedfind-up@2.1.0(transitive)
+ Addedforever-agent@0.6.1(transitive)
+ Addedform-data@2.3.3(transitive)
+ Addedgetpass@0.1.7(transitive)
+ Addedhar-schema@2.0.0(transitive)
+ Addedhar-validator@5.1.5(transitive)
+ Addedhas-flag@3.0.0(transitive)
+ Addedhttp-signature@1.2.0(transitive)
+ Addediconv-lite@0.4.24(transitive)
+ Addedimurmurhash@0.1.4(transitive)
+ Addedinquirer@5.2.0(transitive)
+ Addedinsight@0.10.0(transitive)
+ Addedis-fullwidth-code-point@2.0.0(transitive)
+ Addedis-obj@1.0.1(transitive)
+ Addedis-typedarray@1.0.0(transitive)
+ Addedisstream@0.1.2(transitive)
+ Addedjsbn@0.1.1(transitive)
+ Addedjson-schema@0.4.0(transitive)
+ Addedjson-schema-traverse@0.4.1(transitive)
+ Addedjson-stringify-safe@5.0.1(transitive)
+ Addedjsprim@1.4.2(transitive)
+ Addedliferay-npm-build-tools-common@1.6.1(transitive)
+ Addedlocate-path@2.0.0(transitive)
+ Addedlodash.debounce@4.0.8(transitive)
+ Addedmacos-release@1.1.0(transitive)
+ Addedmake-dir@1.3.0(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedmimic-fn@1.2.0(transitive)
+ Addedmute-stream@0.0.7(transitive)
+ Addedoauth-sign@0.9.0(transitive)
+ Addedonetime@2.0.1(transitive)
+ Addedos-name@2.0.1(transitive)
+ Addedp-limit@1.3.0(transitive)
+ Addedp-locate@2.0.0(transitive)
+ Addedp-try@1.0.0(transitive)
+ Addedpath-exists@3.0.0(transitive)
+ Addedperformance-now@2.1.0(transitive)
+ Addedpify@3.0.0(transitive)
+ Addedpkg-up@2.0.0(transitive)
+ Addedpsl@1.13.0(transitive)
+ Addedpunycode@2.3.1(transitive)
+ Addedqs@6.5.3(transitive)
+ Addedrequest@2.88.2(transitive)
+ Addedrestore-cursor@2.0.0(transitive)
+ Addedrun-async@2.4.1(transitive)
+ Addedrxjs@5.5.12(transitive)
+ Addedsafe-buffer@5.2.1(transitive)
+ Addedsafer-buffer@2.1.2(transitive)
+ Addedsignal-exit@3.0.7(transitive)
+ Addedsshpk@1.18.0(transitive)
+ Addedstring-width@2.1.1(transitive)
+ Addedstrip-ansi@4.0.0(transitive)
+ Addedsupports-color@5.5.0(transitive)
+ Addedsymbol-observable@1.0.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtmp@0.0.33(transitive)
+ Addedtough-cookie@2.5.0(transitive)
+ Addedtunnel-agent@0.6.0(transitive)
+ Addedtweetnacl@0.14.5(transitive)
+ Addeduri-js@4.4.1(transitive)
+ Addeduuid@3.4.0(transitive)
+ Addedverror@1.10.0(transitive)
+ Addedwin-release@1.1.1(transitive)
+ Addedwrite-file-atomic@2.4.3(transitive)
- Removedliferay-npm-build-tools-common@1.6.0(transitive)