liferay-npm-bundler-plugin-replace-browser-modules
Advanced tools
Comparing version 2.13.2 to 2.13.3-alpha.6
188
lib/index.js
@@ -1,40 +0,38 @@ | ||
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = function (_ref, _ref2) { | ||
var log = _ref.log, | ||
pkg = _ref.pkg; | ||
var pkgJson = _ref2.pkgJson; | ||
var browser = pkgJson.browser || pkgJson.unpkg || pkgJson.jsdelivr; | ||
if (typeof browser === 'string') { | ||
replaceMainModule(pkg.dir, browser, pkgJson, log); | ||
} else if (browser) { | ||
replaceModules(pkg.dir, browser, pkgJson, log); | ||
} else { | ||
log.info('replace-browser-modules', 'No browser modules found'); | ||
} | ||
"use strict"; | ||
/** | ||
* © 2017 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
var _fsExtra = require('fs-extra'); | ||
var _fsExtra2 = _interopRequireDefault(_fsExtra); | ||
var _packages = require('liferay-npm-build-tools-common/lib/packages'); | ||
var pkgs = _interopRequireWildcard(_packages); | ||
var _path = require('path'); | ||
var _path2 = _interopRequireDefault(_path); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var __importStar = (this && this.__importStar) || function (mod) { | ||
if (mod && mod.__esModule) return mod; | ||
var result = {}; | ||
if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k]; | ||
result["default"] = mod; | ||
return result; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const fs_extra_1 = __importDefault(require("fs-extra")); | ||
const pkgs = __importStar(require("liferay-npm-build-tools-common/lib/packages")); | ||
const path_1 = __importDefault(require("path")); | ||
/** | ||
* @return {void} | ||
*/ | ||
function default_1({ log, pkg }, { pkgJson }) { | ||
const browser = pkgJson.browser || pkgJson.unpkg || pkgJson.jsdelivr; | ||
if (typeof browser === 'string') { | ||
replaceMainModule(pkg.dir, browser, pkgJson, log); | ||
} | ||
else if (browser) { | ||
replaceModules(pkg.dir, browser, pkgJson, log); | ||
} | ||
else { | ||
log.info('replace-browser-modules', 'No browser modules found'); | ||
} | ||
} | ||
exports.default = default_1; | ||
/** | ||
* Copy "browser"/"module" module file on top of "main" module file. | ||
@@ -47,19 +45,10 @@ * @param {FilePath} pkgDir directory where package is placed | ||
*/ | ||
/** | ||
* © 2017 Liferay, Inc. <https://liferay.com> | ||
* | ||
* SPDX-License-Identifier: LGPL-3.0-or-later | ||
*/ | ||
function replaceMainModule(pkgDir, browser, pkgJson, log) { | ||
var pkgId = pkgJson.name + '@' + pkgJson.version; | ||
var main = pkgJson.main || 'index.js'; | ||
var srcPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, browser)).asNative; | ||
var destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, main)).asNative; | ||
replaceFile(pkgId, srcPath, browser, destPath, main, log); | ||
const pkgId = `${pkgJson.name}@${pkgJson.version}`; | ||
const main = pkgJson.main || 'index.js'; | ||
const srcPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, browser)).asNative; | ||
const destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, main)) | ||
.asNative; | ||
replaceFile(pkgId, srcPath, browser, destPath, main, log); | ||
} | ||
/** | ||
@@ -73,25 +62,16 @@ * Copy "browser"/"module" module files on top of their server versions. | ||
*/ | ||
/** | ||
* @return {void} | ||
*/ | ||
function replaceModules(pkgDir, browser, pkgJson, log) { | ||
var pkgId = pkgJson.name + '@' + pkgJson.version; | ||
Object.keys(browser).forEach(function (fromModuleName) { | ||
var toModuleName = browser[fromModuleName]; | ||
var destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, fromModuleName)).asNative; | ||
if (toModuleName == false) { | ||
ignoreFile(destPath, fromModuleName, log); | ||
} else { | ||
var srcPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, toModuleName)).asNative; | ||
replaceFile(pkgId, srcPath, toModuleName, destPath, fromModuleName, log); | ||
} | ||
}); | ||
const pkgId = `${pkgJson.name}@${pkgJson.version}`; | ||
Object.keys(browser).forEach(fromModuleName => { | ||
const toModuleName = browser[fromModuleName]; | ||
const destPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, fromModuleName)).asNative; | ||
if (toModuleName == false) { | ||
ignoreFile(destPath, fromModuleName, log); | ||
} | ||
else { | ||
const srcPath = pkgDir.join(pkgs.resolveModuleFile(pkgDir.asNative, toModuleName)).asNative; | ||
replaceFile(pkgId, srcPath, toModuleName, destPath, fromModuleName, log); | ||
} | ||
}); | ||
} | ||
/** | ||
@@ -108,30 +88,28 @@ * Replace one package file with another. | ||
function replaceFile(pkgId, srcPath, srcName, destPath, destName, log) { | ||
var srcModuleName = srcName.replace('.js', ''); | ||
var destModuleName = destName.replace('.js', ''); | ||
log.info('replace-browser-modules', 'Replacing module ' + destName + ' with module ' + srcName); | ||
try { | ||
var contents = ''; | ||
try { | ||
contents = _fsExtra2.default.readFileSync(srcPath).toString(); | ||
} catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
contents = contents.replace('\'' + pkgId + '/' + srcModuleName + '\'', '\'' + pkgId + '/' + destModuleName + '\''); | ||
_fsExtra2.default.mkdirsSync(_path2.default.dirname(destPath)); | ||
_fsExtra2.default.writeFileSync(destPath, '/* Module replaced with ' + srcName + ' by liferay-npm-bundler-plugin-replace-browser-modules */\n' + contents); | ||
} catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
const srcModuleName = srcName.replace('.js', ''); | ||
const destModuleName = destName.replace('.js', ''); | ||
log.info('replace-browser-modules', `Replacing module ${destName} with module ${srcName}`); | ||
try { | ||
let contents = ''; | ||
try { | ||
contents = fs_extra_1.default.readFileSync(srcPath).toString(); | ||
} | ||
catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
contents = contents.replace(`'${pkgId}/${srcModuleName}'`, `'${pkgId}/${destModuleName}'`); | ||
fs_extra_1.default.mkdirsSync(path_1.default.dirname(destPath)); | ||
fs_extra_1.default.writeFileSync(destPath, '/* Module replaced with ' + | ||
srcName + | ||
' by liferay-npm-bundler-plugin-replace-browser-modules */\n' + | ||
contents); | ||
} | ||
catch (err) { | ||
if (err.code !== 'ENOENT') { | ||
throw err; | ||
} | ||
} | ||
} | ||
/** | ||
@@ -145,8 +123,6 @@ * Ignores one package | ||
function ignoreFile(filePath, moduleName, log) { | ||
log.info('replace-browser-modules', 'Emptying module ' + moduleName + ' because it is server-only'); | ||
_fsExtra2.default.mkdirsSync(_path2.default.dirname(filePath)); | ||
_fsExtra2.default.writeFileSync(filePath, '/* Module ignored by ' + 'liferay-npm-bundler-plugin-replace-browser-modules */\n'); | ||
log.info('replace-browser-modules', `Emptying module ${moduleName} because it is server-only`); | ||
fs_extra_1.default.mkdirsSync(path_1.default.dirname(filePath)); | ||
fs_extra_1.default.writeFileSync(filePath, '/* Module ignored by ' + | ||
'liferay-npm-bundler-plugin-replace-browser-modules */\n'); | ||
} | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "liferay-npm-bundler-plugin-replace-browser-modules", | ||
"version": "2.13.2", | ||
"version": "2.13.3-alpha.6+ae09044", | ||
"description": "A liferay-npm-bundler plugin to replace files listed under the browser/module entry of package.json files.", | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"build": "babel --source-maps -D -d lib src --ignore '**/__tests__/**'", | ||
"prepublish": "npm run build" | ||
"copyfiles": "node ../../scripts/copyfiles.js", | ||
"build": "tsc && yarn copyfiles", | ||
"prepublish": "yarn build" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.24.1", | ||
"babel-preset-es2015": "^6.24.1", | ||
"recursive-copy": "^2.0.9" | ||
}, | ||
"dependencies": { | ||
"fs-extra": "^7.0.1", | ||
"liferay-npm-build-tools-common": "2.13.2" | ||
} | ||
"fs-extra": "^8.1.0", | ||
"liferay-npm-build-tools-common": "2.13.3-alpha.6+ae09044" | ||
}, | ||
"gitHead": "ae09044beb216743cb2f1e2273aa6e055716ce64" | ||
} |
@@ -29,3 +29,3 @@ /** | ||
overwrite: true, | ||
}).then(done); | ||
}).then(() => done()); | ||
}); | ||
@@ -32,0 +32,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Manifest confusion
Supply chain riskThis package has inconsistent metadata. This could be malicious or caused by an error when publishing the package.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
Mixed license
License(Experimental) Package contains multiple licenses.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Copyleft License
License(Experimental) Copyleft license information was found.
Found 1 instance in 1 package
Non-permissive License
License(Experimental) A license not known to be considered permissive was found.
Found 1 instance in 1 package
27681
1
505
3
2
1
+ Addedfs-extra@8.1.0(transitive)
- Removed@mrmlnc/readdir-enhanced@2.2.1(transitive)
- Removed@nodelib/fs.stat@1.1.3(transitive)
- Removedansi-regex@2.1.1(transitive)
- Removedansi-styles@2.2.13.2.1(transitive)
- Removedarr-diff@4.0.0(transitive)
- Removedarr-flatten@1.1.0(transitive)
- Removedarr-union@3.1.0(transitive)
- Removedarray-union@1.0.2(transitive)
- Removedarray-uniq@1.0.3(transitive)
- Removedarray-unique@0.3.2(transitive)
- Removedarrify@1.0.1(transitive)
- Removedassign-symbols@1.0.0(transitive)
- Removedatob@2.1.2(transitive)
- Removedbabel-code-frame@6.26.0(transitive)
- Removedbabel-helper-evaluate-path@0.5.0(transitive)
- Removedbabel-helper-mark-eval-scopes@0.4.3(transitive)
- Removedbabel-helper-remove-or-void@0.4.3(transitive)
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-plugin-add-module-metadata@2.13.2(transitive)
- Removedbabel-plugin-minify-dead-code-elimination@0.5.0(transitive)
- Removedbabel-plugin-name-amd-modules@2.13.2(transitive)
- Removedbabel-plugin-namespace-amd-define@2.13.2(transitive)
- Removedbabel-plugin-namespace-modules@2.13.2(transitive)
- Removedbabel-plugin-normalize-requires@2.13.2(transitive)
- Removedbabel-plugin-transform-node-env-inline@0.2.0(transitive)
- Removedbabel-plugin-wrap-modules-amd@2.13.2(transitive)
- Removedbabel-preset-liferay-standard@2.13.2(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-template@6.26.0(transitive)
- Removedbabel-traverse@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedbabylon@6.18.0(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbase@0.11.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@2.3.2(transitive)
- Removedcache-base@1.0.1(transitive)
- Removedcall-me-maybe@1.0.2(transitive)
- Removedchalk@1.1.32.4.2(transitive)
- Removedclass-utils@0.3.6(transitive)
- Removedcollection-visit@1.0.0(transitive)
- Removedcolor-convert@1.9.3(transitive)
- Removedcolor-name@1.1.3(transitive)
- Removedcomponent-emitter@1.3.1(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removedcopy-descriptor@0.1.1(transitive)
- Removedcore-js@2.6.12(transitive)
- Removeddebug@2.6.9(transitive)
- Removeddecode-uri-component@0.2.2(transitive)
- Removeddefine-property@0.2.51.0.02.0.2(transitive)
- Removeddir-glob@2.0.0(transitive)
- Removeddot-prop@5.3.0(transitive)
- Removedescape-string-regexp@1.0.5(transitive)
- Removedesutils@2.0.3(transitive)
- Removedexpand-brackets@2.1.4(transitive)
- Removedextend-shallow@2.0.13.0.2(transitive)
- Removedextglob@2.0.4(transitive)
- Removedfast-glob@2.2.7(transitive)
- Removedfill-range@4.0.0(transitive)
- Removedfor-in@1.0.2(transitive)
- Removedfragment-cache@0.2.1(transitive)
- Removedfs-extra@7.0.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedfunction-bind@1.1.2(transitive)
- Removedget-value@2.0.6(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@3.1.0(transitive)
- Removedglob-to-regexp@0.3.0(transitive)
- Removedglobals@9.18.0(transitive)
- Removedglobby@8.0.2(transitive)
- Removedhas-ansi@2.0.0(transitive)
- Removedhas-flag@3.0.0(transitive)
- Removedhas-value@0.3.11.0.0(transitive)
- Removedhas-values@0.1.41.0.0(transitive)
- Removedhasown@2.0.2(transitive)
- Removedignore@3.3.10(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedinvariant@2.2.4(transitive)
- Removedis-accessor-descriptor@1.0.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-core-module@2.15.1(transitive)
- Removedis-data-descriptor@1.0.1(transitive)
- Removedis-descriptor@0.1.71.0.3(transitive)
- Removedis-extendable@0.1.11.0.1(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@3.1.04.0.3(transitive)
- Removedis-number@3.0.0(transitive)
- Removedis-obj@2.0.0(transitive)
- Removedis-plain-object@2.0.4(transitive)
- Removedis-windows@1.0.2(transitive)
- Removedisarray@1.0.0(transitive)
- Removedisobject@2.1.03.0.1(transitive)
- Removedjs-tokens@3.0.2(transitive)
- Removedkind-of@3.2.24.0.06.0.3(transitive)
- Removedliferay-npm-build-tools-common@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-exclude-imports@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-imports-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-inject-peer-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-namespace-packages@2.13.2(transitive)
- Removedliferay-npm-bundler-plugin-resolve-linked-dependencies@2.13.2(transitive)
- Removedliferay-npm-bundler-preset-standard@2.13.2(transitive)
- Removedlodash@4.17.21(transitive)
- Removedlodash.some@4.6.0(transitive)
- Removedloose-envify@1.4.0(transitive)
- Removedmap-cache@0.2.2(transitive)
- Removedmap-visit@1.0.0(transitive)
- Removedmerge@1.2.1(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@3.1.10(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedmixin-deep@1.3.2(transitive)
- Removedms@2.0.0(transitive)
- Removednanomatch@1.2.13(transitive)
- Removedobject-copy@0.1.0(transitive)
- Removedobject-visit@1.0.1(transitive)
- Removedobject.pick@1.3.0(transitive)
- Removedonce@1.4.0(transitive)
- Removedpascalcase@0.1.1(transitive)
- Removedpath-dirname@1.0.2(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-parse@1.0.7(transitive)
- Removedpath-type@3.0.0(transitive)
- Removedpify@3.0.0(transitive)
- Removedposix-character-classes@0.1.1(transitive)
- Removedproperties@1.2.1(transitive)
- Removedread-json-sync@1.1.12.0.1(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
- Removedregex-not@1.0.2(transitive)
- Removedrepeat-element@1.1.4(transitive)
- Removedrepeat-string@1.6.1(transitive)
- Removedresolve@1.22.8(transitive)
- Removedresolve-url@0.2.1(transitive)
- Removedret@0.1.15(transitive)
- Removedsafe-regex@1.1.0(transitive)
- Removedsemver@5.7.2(transitive)
- Removedset-value@2.0.1(transitive)
- Removedslash@1.0.0(transitive)
- Removedsnapdragon@0.8.2(transitive)
- Removedsnapdragon-node@2.1.1(transitive)
- Removedsnapdragon-util@3.0.1(transitive)
- Removedsource-map@0.5.7(transitive)
- Removedsource-map-resolve@0.5.3(transitive)
- Removedsource-map-url@0.4.1(transitive)
- Removedsplit-string@3.1.0(transitive)
- Removedstatic-extend@0.1.2(transitive)
- Removedstrip-ansi@3.0.1(transitive)
- Removedsupports-color@2.0.05.5.0(transitive)
- Removedsupports-preserve-symlinks-flag@1.0.0(transitive)
- Removedto-fast-properties@1.0.3(transitive)
- Removedto-object-path@0.3.0(transitive)
- Removedto-regex@3.0.2(transitive)
- Removedto-regex-range@2.1.1(transitive)
- Removedunion-value@1.0.1(transitive)
- Removedunset-value@1.0.0(transitive)
- Removedurix@0.1.0(transitive)
- Removeduse@3.1.1(transitive)
- Removedwrappy@1.0.2(transitive)
Updatedfs-extra@^8.1.0
Updatedliferay-npm-build-tools-common@2.13.3-alpha.6+ae09044