filemanager-webpack-plugin
Advanced tools
Comparing version 3.0.0-alpha.1 to 3.0.0-alpha.2
@@ -5,2 +5,19 @@ # Changelog | ||
## v3.0.0-alpha.2 (2020-10-22) | ||
#### Features | ||
- support webpack 5 | ||
#### Enhancements | ||
- removed dependency `mv` and `mkdir`, use `fs-extra` instead | ||
- run tests in `ubuntu`, `windows` and `mac` | ||
- added more tests for all actions | ||
#### Breaking Changes | ||
- requires node 10.13 or above | ||
- removed verbose option, will be added in upcoming releases | ||
## v3.0.0-alpha.1 (2020-10-04) | ||
@@ -7,0 +24,0 @@ |
707
lib/index.js
'use strict'; | ||
var validateOptions = require('schema-utils'); | ||
var fs$1 = require('fs'); | ||
var path$1 = require('path'); | ||
var makeDir = require('make-dir'); | ||
var path = require('path'); | ||
var schemaUtils = require('schema-utils'); | ||
var fs = require('fs'); | ||
var fsExtra = require('fs-extra'); | ||
var cpy = require('cpy'); | ||
var cpFile = require('cp-file'); | ||
var del = require('del'); | ||
var archiver = require('archiver'); | ||
@@ -13,357 +13,186 @@ | ||
var validateOptions__default = /*#__PURE__*/_interopDefaultLegacy(validateOptions); | ||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1); | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$1); | ||
var makeDir__default = /*#__PURE__*/_interopDefaultLegacy(makeDir); | ||
var path__default = /*#__PURE__*/_interopDefaultLegacy(path); | ||
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs); | ||
var fsExtra__default = /*#__PURE__*/_interopDefaultLegacy(fsExtra); | ||
var cpy__default = /*#__PURE__*/_interopDefaultLegacy(cpy); | ||
var cpFile__default = /*#__PURE__*/_interopDefaultLegacy(cpFile); | ||
var del__default = /*#__PURE__*/_interopDefaultLegacy(del); | ||
var archiver__default = /*#__PURE__*/_interopDefaultLegacy(archiver); | ||
function _classCallCheck(instance, Constructor) { | ||
if (!(instance instanceof Constructor)) { | ||
throw new TypeError("Cannot call a class as a function"); | ||
/*! | ||
* is-extglob <https://github.com/jonschlinkert/is-extglob> | ||
* | ||
* Copyright (c) 2014-2016, Jon Schlinkert. | ||
* Licensed under the MIT License. | ||
*/ | ||
var isExtglob = function isExtglob(str) { | ||
if (typeof str !== 'string' || str === '') { | ||
return false; | ||
} | ||
} | ||
function _defineProperties(target, props) { | ||
for (var i = 0; i < props.length; i++) { | ||
var descriptor = props[i]; | ||
descriptor.enumerable = descriptor.enumerable || false; | ||
descriptor.configurable = true; | ||
if ("value" in descriptor) descriptor.writable = true; | ||
Object.defineProperty(target, descriptor.key, descriptor); | ||
var match; | ||
while (match = /(\\).|([@?!+*]\(.*\))/g.exec(str)) { | ||
if (match[2]) return true; | ||
str = str.slice(match.index + match[0].length); | ||
} | ||
} | ||
function _createClass(Constructor, protoProps, staticProps) { | ||
if (protoProps) _defineProperties(Constructor.prototype, protoProps); | ||
if (staticProps) _defineProperties(Constructor, staticProps); | ||
return Constructor; | ||
} | ||
return false; | ||
}; | ||
function _defineProperty(obj, key, value) { | ||
if (key in obj) { | ||
Object.defineProperty(obj, key, { | ||
value: value, | ||
enumerable: true, | ||
configurable: true, | ||
writable: true | ||
}); | ||
} else { | ||
obj[key] = value; | ||
} | ||
/*! | ||
* is-glob <https://github.com/jonschlinkert/is-glob> | ||
* | ||
* Copyright (c) 2014-2017, Jon Schlinkert. | ||
* Released under the MIT License. | ||
*/ | ||
return obj; | ||
} | ||
var chars = { | ||
'{': '}', | ||
'(': ')', | ||
'[': ']' | ||
}; | ||
var strictRegex = /\\(.)|(^!|\*|[\].+)]\?|\[[^\\\]]+\]|\{[^\\}]+\}|\(\?[:!=][^\\)]+\)|\([^|]+\|[^\\)]+\))/; | ||
var relaxedRegex = /\\(.)|(^!|[*?{}()[\]]|\(\?)/; | ||
function ownKeys(object, enumerableOnly) { | ||
var keys = Object.keys(object); | ||
var isGlob = function isGlob(str, options) { | ||
if (typeof str !== 'string' || str === '') { | ||
return false; | ||
} | ||
if (Object.getOwnPropertySymbols) { | ||
var symbols = Object.getOwnPropertySymbols(object); | ||
if (enumerableOnly) symbols = symbols.filter(function (sym) { | ||
return Object.getOwnPropertyDescriptor(object, sym).enumerable; | ||
}); | ||
keys.push.apply(keys, symbols); | ||
if (isExtglob(str)) { | ||
return true; | ||
} | ||
return keys; | ||
} | ||
var regex = strictRegex; | ||
var match; // optionally relax regex | ||
function _objectSpread2(target) { | ||
for (var i = 1; i < arguments.length; i++) { | ||
var source = arguments[i] != null ? arguments[i] : {}; | ||
if (i % 2) { | ||
ownKeys(Object(source), true).forEach(function (key) { | ||
_defineProperty(target, key, source[key]); | ||
}); | ||
} else if (Object.getOwnPropertyDescriptors) { | ||
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); | ||
} else { | ||
ownKeys(Object(source)).forEach(function (key) { | ||
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); | ||
}); | ||
} | ||
if (options && options.strict === false) { | ||
regex = relaxedRegex; | ||
} | ||
return target; | ||
} | ||
while (match = regex.exec(str)) { | ||
if (match[2]) return true; | ||
var idx = match.index + match[0].length; // if an open bracket/brace/paren is escaped, | ||
// set the index to the next closing character | ||
function _toConsumableArray(arr) { | ||
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); | ||
} | ||
var open = match[1]; | ||
var close = open ? chars[open] : null; | ||
function _arrayWithoutHoles(arr) { | ||
if (Array.isArray(arr)) return _arrayLikeToArray(arr); | ||
} | ||
if (open && close) { | ||
var n = str.indexOf(close, idx); | ||
function _iterableToArray(iter) { | ||
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); | ||
} | ||
if (n !== -1) { | ||
idx = n + 1; | ||
} | ||
} | ||
function _unsupportedIterableToArray(o, minLen) { | ||
if (!o) return; | ||
if (typeof o === "string") return _arrayLikeToArray(o, minLen); | ||
var n = Object.prototype.toString.call(o).slice(8, -1); | ||
if (n === "Object" && o.constructor) n = o.constructor.name; | ||
if (n === "Map" || n === "Set") return Array.from(o); | ||
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); | ||
} | ||
str = str.slice(idx); | ||
} | ||
function _arrayLikeToArray(arr, len) { | ||
if (len == null || len > arr.length) len = arr.length; | ||
return false; | ||
}; | ||
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; | ||
const copyAction = async tasks => { | ||
const taskMap = tasks.map(copy); | ||
await Promise.all(taskMap); | ||
}; | ||
return arr2; | ||
} | ||
const copy = async task => { | ||
const { | ||
source, | ||
absSource, | ||
absDestination, | ||
context | ||
} = task; | ||
function _nonIterableSpread() { | ||
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); | ||
} | ||
try { | ||
if (isGlob(source)) { | ||
const src = path__default['default'].posix.join(context, source); | ||
await cpy__default['default'](src, absDestination); | ||
} else { | ||
const isFolderTarget = /(?:\\|\/)$/.test(absDestination); | ||
const isSourceFile = fs__default['default'].lstatSync(absSource).isFile(); // if source is a file and target is a directory | ||
// create the directory and copy the file into that directory | ||
/** | ||
* Execute copy action | ||
* | ||
* @param {Object} command - Command data for given action | ||
* @return {Function|null} - Function that returns a promise or null | ||
*/ | ||
function copyAction(command, options) { | ||
var verbose = options.verbose, | ||
context = options.context; | ||
return function () { | ||
return new Promise(function (resolve, reject) { | ||
// if source is a file, just copyFile() | ||
// if source is a NOT a glob pattern, simply append **/* | ||
var fileRegex = /(\*|\{+|\}+)/g; | ||
var matches = fileRegex.exec(command.source); | ||
if (matches === null) { | ||
var source = path__default['default'].resolve(context, command.source); | ||
fs__default['default'].lstat(source, function (sErr, sStats) { | ||
if (sErr) return reject(sErr); | ||
fs__default['default'].lstat(command.destination, function (dErr, dStats) { | ||
if (sStats.isFile()) { | ||
var destination = dStats && dStats.isDirectory() ? path__default['default'].resolve(context, command.destination + '/' + path__default['default'].basename(command.source)) : path__default['default'].resolve(context, command.destination); | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Start copy source: ".concat(command.source, " to destination: ").concat(destination)); | ||
} | ||
var pathInfo = path__default['default'].parse(destination); | ||
if (pathInfo.ext === '') { | ||
makeDir__default['default'](destination).then(function () { | ||
cpFile__default['default'](source, path__default['default'].resolve(destination, path__default['default'].basename(source))).then(resolve).catch(reject); | ||
}); | ||
} else { | ||
cpFile__default['default'](source, destination).then(resolve).catch(reject); | ||
} | ||
} else { | ||
var sourceDir = command.source + (command.source.substr(-1) !== '/' ? '/' : '') + '**/*'; | ||
copy(sourceDir, command.destination, resolve, reject, options); | ||
} | ||
}); | ||
}); | ||
} else { | ||
copy(command.source, command.destination, resolve, reject, options); | ||
if (isSourceFile && isFolderTarget) { | ||
await fsExtra__default['default'].ensureDir(absDestination); | ||
const sourceFileName = path__default['default'].basename(absSource); | ||
const filePath = path__default['default'].resolve(absDestination, sourceFileName); | ||
await fsExtra__default['default'].copy(absSource, filePath); | ||
return; | ||
} | ||
}); | ||
}; | ||
} | ||
/** | ||
* Execute copy directory | ||
* | ||
* @param {string} source - source file path | ||
* @param {string} destination - destination file path | ||
* @param {Function} resolve - function used to resolve a Promise | ||
* @param {Function} reject - function used to reject a Promise | ||
* @return {void} | ||
*/ | ||
await fsExtra__default['default'].copy(absSource, absDestination); | ||
} | ||
} catch (err) {} | ||
}; | ||
function copy(source, destination, resolve, reject, options) { | ||
var verbose = options.verbose, | ||
context = options.context; | ||
/* cpy options */ | ||
const moveAction = async input => { | ||
for (const task of input) { | ||
await fsExtra__default['default'].move(task.absSource, task.absDestination); | ||
} | ||
}; | ||
var cpyOptions = { | ||
cwd: context | ||
}; | ||
const deleteAction = async tasks => { | ||
for (const task of tasks) { | ||
await del__default['default'](task.absSource); | ||
} | ||
}; | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Start copy source file: ".concat(source, " to destination file: ").concat(destination)); | ||
const mkdirAction = async tasks => { | ||
for (const task of tasks) { | ||
await fsExtra__default['default'].ensureDir(task.absSource); | ||
} | ||
}; | ||
cpy__default['default'](source, destination, cpyOptions).then(function () { | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Finished copy source: ".concat(source, " to destination: ").concat(destination)); | ||
} | ||
const archiveAction = async tasks => { | ||
const actionMap = tasks.map(archive); | ||
await Promise.all(actionMap); | ||
}; | ||
resolve(); | ||
}).catch(function (err) { | ||
if (err && options.verbose) { | ||
console.log(' - FileManagerPlugin: Error - copy failed', err); | ||
return reject(err); | ||
} | ||
}); | ||
} | ||
const archive = async task => { | ||
const { | ||
source, | ||
absSource, | ||
absDestination, | ||
options = {}, | ||
context | ||
} = task; | ||
const format = task.format || path__default['default'].extname(absDestination).replace('.', ''); // Exclude destination file from archive | ||
var fs = require('fs'); | ||
const destFile = path__default['default'].basename(absDestination); | ||
const destDir = path__default['default'].dirname(absDestination); | ||
const globOptions = Object.assign({ | ||
ignore: destFile | ||
}, options.globOptions || {}); | ||
await fsExtra__default['default'].ensureDir(destDir); | ||
const output = fs__default['default'].createWriteStream(absDestination); | ||
const archive = archiver__default['default'](format, options); | ||
archive.pipe(output); | ||
var mv = require('mv'); | ||
/** | ||
* Execute move action | ||
* | ||
* @param {Object} command - Command data for given action | ||
* @return {Function|null} - Function that returns a promise or null | ||
*/ | ||
function moveAction(command, options) { | ||
var verbose = options.verbose; | ||
if (fs.existsSync(command.source)) { | ||
return function () { | ||
return new Promise(function (resolve, reject) { | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Start move source: ".concat(command.source, " to destination: ").concat(command.destination)); | ||
} | ||
mv(command.source, command.destination, { | ||
mkdirp: false | ||
}, function (err) { | ||
if (err) { | ||
if (verbose) { | ||
console.log(' - FileManagerPlugin: Error - move failed', err); | ||
} | ||
reject(err); | ||
} | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Finished move source: ".concat(command.source, " to destination: ").concat(command.destination)); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
if (isGlob(source)) { | ||
const gOptions = { ...globOptions, | ||
cwd: context | ||
}; | ||
await archive.glob(source, gOptions).finalize(); | ||
} else { | ||
process.emitWarning(' - FileManagerPlugin: Could not move ' + command.source + ': path does not exist'); | ||
return null; | ||
} | ||
} | ||
const sStat = fs__default['default'].lstatSync(absSource); | ||
var path = require('path'); | ||
if (sStat.isDirectory()) { | ||
const gOptions = { ...globOptions, | ||
cwd: absSource | ||
}; | ||
await archive.glob('**/*', gOptions).finalize(); | ||
} | ||
var rimraf = require('rimraf'); | ||
/** | ||
* Execute delete action | ||
* | ||
* @param {Object} command - Command data for given action | ||
* @return {Function|null} - Function that returns a promise or null | ||
*/ | ||
function deleteAction(command, options) { | ||
var verbose = options.verbose, | ||
context = options.context; | ||
return function () { | ||
return new Promise(function (resolve, reject) { | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Starting delete path ".concat(command.source)); | ||
} | ||
var source = path.resolve(context, command.source); | ||
rimraf(source, {}, function (response) { | ||
if (verbose && response === null) { | ||
console.log(" - FileManagerPlugin: Finished delete path ".concat(command.source)); | ||
} | ||
resolve(); | ||
}); | ||
}); | ||
}; | ||
} | ||
/** | ||
* Execute mkdir action | ||
* | ||
* @param {Object} command - Command data for given action | ||
* @return {Function|null} - Function that returns a promise or null | ||
*/ | ||
function mkdirAction(command, options) { | ||
var verbose = options.verbose, | ||
context = options.context; | ||
return function () { | ||
if (verbose) { | ||
console.log(" - FileManagerPlugin: Creating path ".concat(command.source)); | ||
if (sStat.isFile()) { | ||
const options = { | ||
name: path__default['default'].basename(source) | ||
}; | ||
await archive.file(absSource, options).finalize(); | ||
} | ||
} // output.close() | ||
var source = path__default['default'].resolve(context, command.source); | ||
return makeDir__default['default'](source); | ||
}; | ||
} | ||
}; | ||
/** | ||
* Execute mkdir action | ||
* | ||
* @param {Object} command - Command data for given action | ||
* @return {Function|null} - Function that returns a promise or null | ||
*/ | ||
function archiveAction(command, options) { | ||
var context = options.context; | ||
var source = path__default['default'].resolve(context, command.source); | ||
var destination = path__default['default'].resolve(context, command.destination); | ||
return function () { | ||
return new Promise(function (resolve, reject) { | ||
var fileRegex = /(\*|\{+|\}+)/g; | ||
var matches = fileRegex.exec(command.source); | ||
var isGlob = matches !== null; | ||
fs__default['default'].lstat(source, function (sErr, sStats) { | ||
if (!fs__default['default'].existsSync(path__default['default'].dirname(destination))) { | ||
fs__default['default'].mkdirSync(path__default['default'].dirname(destination), { | ||
recursive: true | ||
}); | ||
} | ||
var output = fs__default['default'].createWriteStream(destination); | ||
var archive = archiver__default['default'](command.format, command.options); | ||
archive.on('error', function (err) { | ||
return reject(err); | ||
}); | ||
archive.pipe(output); // Exclude destination file from archive | ||
var destFile = path__default['default'].basename(destination); | ||
var globOptions = Object.assign({ | ||
ignore: destFile | ||
}, command.options.globOptions || {}); | ||
if (isGlob) { | ||
archive.glob(command.source, _objectSpread2(_objectSpread2({}, globOptions), {}, { | ||
cwd: context | ||
})); | ||
} else if (sStats.isFile()) { | ||
archive.file(source, { | ||
name: path__default['default'].basename(command.source), | ||
cwd: context | ||
}); | ||
} else if (sStats.isDirectory()) { | ||
archive.glob('**/*', { | ||
cwd: source, | ||
ignore: destFile | ||
}); | ||
} | ||
archive.finalize().then(resolve); | ||
}); | ||
}); | ||
}; | ||
} | ||
var schema = { | ||
@@ -497,191 +326,99 @@ title: 'FileManagerPluginOptions', | ||
var PLUGIN_NAME = 'FileManagerPlugin'; | ||
const PLUGIN_NAME = 'FileManagerPlugin'; | ||
var FileManagerPlugin = /*#__PURE__*/function () { | ||
function FileManagerPlugin(options) { | ||
_classCallCheck(this, FileManagerPlugin); | ||
const resolvePaths = (stages, context) => { | ||
Object.keys(stages).forEach(stage => { | ||
Object.keys(stages[stage]).forEach(action => { | ||
stages[stage][action] = stages[stage][action].map(task => { | ||
const source = typeof task === 'string' ? task : task.source; | ||
validateOptions__default['default'](schema, options, { | ||
if (typeof task === 'string') { | ||
return { | ||
source, | ||
absSource: path__default['default'].isAbsolute(source) ? source : path__default['default'].join(context, source) | ||
}; | ||
} | ||
const { | ||
destination | ||
} = task; | ||
return { ...task, | ||
source: source, | ||
absSource: path__default['default'].isAbsolute(source) ? source : path__default['default'].join(context, source), | ||
destination: destination, | ||
absDestination: path__default['default'].isAbsolute(destination) ? destination : path__default['default'].join(context, destination), | ||
context | ||
}; | ||
}); | ||
}); | ||
}); | ||
return stages; | ||
}; | ||
class FileManagerPlugin { | ||
constructor(actions) { | ||
schemaUtils.validate(schema, actions, { | ||
name: PLUGIN_NAME, | ||
baseDataPath: 'options' | ||
baseDataPath: 'actions' | ||
}); | ||
this.options = this.setOptions(options); | ||
this.actions = actions; | ||
} | ||
_createClass(FileManagerPlugin, [{ | ||
key: "setOptions", | ||
value: function setOptions(userOptions) { | ||
var defaultOptions = { | ||
verbose: false, | ||
moveWithMkdirp: false, | ||
onStart: {}, | ||
onEnd: {} | ||
}; | ||
async processAction(action, actionParams) { | ||
const options = { | ||
context: this.context | ||
}; | ||
await action(actionParams, options); | ||
} | ||
for (var key in defaultOptions) { | ||
if (userOptions.hasOwnProperty(key)) { | ||
defaultOptions[key] = userOptions[key]; | ||
} | ||
} | ||
return defaultOptions; | ||
async execute(stage) { | ||
if (!this.actions[stage]) { | ||
return; | ||
} | ||
}, { | ||
key: "checkOptions", | ||
value: function checkOptions(stage) { | ||
var _this = this; | ||
if (this.options.verbose && Object.keys(this.options[stage]).length) { | ||
console.log("FileManagerPlugin: processing ".concat(stage, " event")); | ||
} | ||
const stages = Object.keys(this.actions[stage]); | ||
const executionPromises = stages.map(async actionType => { | ||
const actionParams = this.actions[stage][actionType]; | ||
var operationList = []; | ||
switch (actionType) { | ||
case 'delete': | ||
return this.processAction(deleteAction, actionParams); | ||
if (this.options[stage] && Array.isArray(this.options[stage])) { | ||
this.options[stage].map(function (opts) { | ||
return operationList.push.apply(operationList, _toConsumableArray(_this.parseFileOptions(opts, true))); | ||
}); | ||
} else { | ||
operationList.push.apply(operationList, _toConsumableArray(this.parseFileOptions(this.options[stage]))); | ||
} | ||
case 'mkdir': | ||
return this.processAction(mkdirAction, actionParams); | ||
if (operationList.length) { | ||
operationList.reduce(function (previous, fn) { | ||
return previous.then(function (retVal) { | ||
return fn(retVal); | ||
}).catch(function (err) { | ||
return console.log(err); | ||
}); | ||
}, Promise.resolve()); | ||
} | ||
} | ||
}, { | ||
key: "replaceHash", | ||
value: function replaceHash(filename) { | ||
return filename.replace('[hash]', this.fileHash); | ||
} | ||
}, { | ||
key: "processAction", | ||
value: function processAction(action, params, commandOrder) { | ||
var options = _objectSpread2(_objectSpread2({}, this.options), {}, { | ||
context: this.context | ||
}); | ||
case 'copy': | ||
return this.processAction(copyAction, actionParams); | ||
var result = action(params, options); | ||
case 'move': | ||
return this.processAction(moveAction, actionParams); | ||
if (result !== null) { | ||
commandOrder.push(result); | ||
case 'archive': | ||
return this.processAction(archiveAction, actionParams); | ||
default: | ||
return; | ||
} | ||
} | ||
}, { | ||
key: "parseFileOptions", | ||
value: function parseFileOptions(options) { | ||
var _this2 = this; | ||
}); | ||
} | ||
var commandOrder = []; | ||
Object.keys(options).forEach(function (actionType) { | ||
var actionOptions = options[actionType]; | ||
var actionParams = null; | ||
actionOptions.forEach(function (actionItem) { | ||
switch (actionType) { | ||
case 'copy': | ||
actionParams = Object.assign({ | ||
source: _this2.replaceHash(actionItem.source) | ||
}, actionItem.destination && { | ||
destination: actionItem.destination | ||
}); | ||
apply(compiler) { | ||
this.context = compiler.options.context; | ||
this.actions = resolvePaths(this.actions, this.context); | ||
_this2.processAction(copyAction, actionParams, commandOrder); | ||
const onStart = async () => { | ||
await this.execute('onStart'); | ||
}; | ||
break; | ||
const onEnd = async () => { | ||
await this.execute('onEnd'); | ||
}; | ||
case 'move': | ||
actionParams = Object.assign({ | ||
source: _this2.replaceHash(actionItem.source) | ||
}, actionItem.destination && { | ||
destination: actionItem.destination | ||
}); | ||
compiler.hooks.beforeRun.tapPromise(PLUGIN_NAME, onStart); | ||
compiler.hooks.afterEmit.tapPromise(PLUGIN_NAME, onEnd); | ||
} | ||
_this2.processAction(moveAction, actionParams, commandOrder); | ||
} | ||
break; | ||
case 'delete': | ||
if (!Array.isArray(actionOptions) || typeof actionItem !== 'string') { | ||
throw Error(" - FileManagerPlugin: Fail - delete parameters has to be an array of strings"); | ||
} | ||
actionParams = Object.assign({ | ||
source: _this2.replaceHash(actionItem) | ||
}); | ||
_this2.processAction(deleteAction, actionParams, commandOrder); | ||
break; | ||
case 'mkdir': | ||
actionParams = { | ||
source: _this2.replaceHash(actionItem) | ||
}; | ||
_this2.processAction(mkdirAction, actionParams, commandOrder); | ||
break; | ||
case 'archive': | ||
actionParams = { | ||
source: _this2.replaceHash(actionItem.source), | ||
destination: actionItem.destination, | ||
format: actionItem.format ? actionItem.format : 'zip', | ||
options: actionItem.options ? actionItem.options : { | ||
zlib: { | ||
level: 9 | ||
} | ||
} | ||
}; | ||
_this2.processAction(archiveAction, actionParams, commandOrder); | ||
break; | ||
} | ||
}); | ||
}); | ||
return commandOrder; | ||
} | ||
}, { | ||
key: "apply", | ||
value: function apply(compiler) { | ||
var _this3 = this; | ||
this.context = compiler.options.context; | ||
var comp = function comp(compilation) { | ||
try { | ||
_this3.checkOptions('onStart'); | ||
} catch (error) { | ||
compilation.errors.push(error); | ||
} | ||
}; | ||
var afterEmit = function afterEmit(compilation, cb) { | ||
_this3.fileHash = compilation.hash; | ||
try { | ||
_this3.checkOptions('onEnd'); | ||
} catch (error) { | ||
compilation.errors.push(error); | ||
} | ||
cb(); | ||
}; | ||
compiler.hooks.thisCompilation.tap(PLUGIN_NAME, comp); | ||
compiler.hooks.afterEmit.tapAsync(PLUGIN_NAME, afterEmit); | ||
} | ||
}]); | ||
return FileManagerPlugin; | ||
}(); | ||
module.exports = FileManagerPlugin; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "filemanager-webpack-plugin", | ||
"version": "3.0.0-alpha.1", | ||
"version": "3.0.0-alpha.2", | ||
"description": "This Webpack plugin allows you to copy, archive (.zip), move, delete files and directories before and after builds", | ||
@@ -30,19 +30,22 @@ "author": "gregnb", | ||
"build": "rollup -c", | ||
"test": "rimraf tests/fixtures/testing && ava", | ||
"test": "ava", | ||
"prettier": "prettier . --write", | ||
"prepublishOnly": "npm run build && npm run test" | ||
}, | ||
"peerDependencies": { | ||
"webpack": "^4 || ^5" | ||
}, | ||
"dependencies": { | ||
"archiver": "^5.0.2", | ||
"cpy": "^8.1.1", | ||
"make-dir": "^3.1.0", | ||
"mv": "^2.1.1", | ||
"rimraf": "^3.0.2", | ||
"schema-utils": "^2.7.1" | ||
"del": "^6.0.0", | ||
"fs-extra": "^9.0.1", | ||
"is-glob": "^4.0.1", | ||
"schema-utils": "^3.0.0" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@babel/core": "^7.11.6", | ||
"@babel/preset-env": "^7.11.5", | ||
"@babel/register": "^7.11.5", | ||
"@babel/core": "^7.12.3", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/register": "^7.12.1", | ||
"@rollup/plugin-babel": "^5.2.1", | ||
@@ -53,13 +56,12 @@ "@rollup/plugin-commonjs": "^15.1.0", | ||
"ava": "^3.13.0", | ||
"glob": "^7.1.6", | ||
"fast-glob": "^3.2.4", | ||
"html-webpack-plugin": "^4.5.0", | ||
"husky": "^4.3.0", | ||
"jszip": "^3.5.0", | ||
"prettier": "^2.1.2", | ||
"pretty-quick": "^3.0.2", | ||
"pretty-quick": "^3.1.0", | ||
"regenerator-runtime": "^0.13.7", | ||
"rollup": "^2.28.2", | ||
"webpack": "^4.44.2", | ||
"webpack-cli": "3.3.12", | ||
"webpack-dev-server": "^3.11.0" | ||
"rollup": "^2.32.1", | ||
"webpack": "^5.1.3" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
18
43973
7
367
+ Addeddel@^6.0.0
+ Addedfs-extra@^9.0.1
+ Addedis-glob@^4.0.1
+ Added@jridgewell/gen-mapping@0.3.8(transitive)
+ Added@jridgewell/resolve-uri@3.1.2(transitive)
+ Added@jridgewell/set-array@1.2.1(transitive)
+ Added@jridgewell/source-map@0.3.6(transitive)
+ Added@jridgewell/sourcemap-codec@1.5.0(transitive)
+ Added@jridgewell/trace-mapping@0.3.25(transitive)
+ Added@nodelib/fs.scandir@2.1.5(transitive)
+ Added@nodelib/fs.stat@2.0.5(transitive)
+ Added@nodelib/fs.walk@1.2.8(transitive)
+ Added@types/eslint@9.6.1(transitive)
+ Added@types/eslint-scope@3.7.7(transitive)
+ Added@types/estree@1.0.6(transitive)
+ Added@webassemblyjs/ast@1.14.1(transitive)
+ Added@webassemblyjs/floating-point-hex-parser@1.13.2(transitive)
+ Added@webassemblyjs/helper-api-error@1.13.2(transitive)
+ Added@webassemblyjs/helper-buffer@1.14.1(transitive)
+ Added@webassemblyjs/helper-numbers@1.13.2(transitive)
+ Added@webassemblyjs/helper-wasm-bytecode@1.13.2(transitive)
+ Added@webassemblyjs/helper-wasm-section@1.14.1(transitive)
+ Added@webassemblyjs/ieee754@1.13.2(transitive)
+ Added@webassemblyjs/leb128@1.13.2(transitive)
+ Added@webassemblyjs/utf8@1.13.2(transitive)
+ Added@webassemblyjs/wasm-edit@1.14.1(transitive)
+ Added@webassemblyjs/wasm-gen@1.14.1(transitive)
+ Added@webassemblyjs/wasm-opt@1.14.1(transitive)
+ Added@webassemblyjs/wasm-parser@1.14.1(transitive)
+ Added@webassemblyjs/wast-printer@1.14.1(transitive)
+ Added@xtuc/ieee754@1.2.0(transitive)
+ Added@xtuc/long@4.2.2(transitive)
+ Addedacorn@8.14.0(transitive)
+ Addedajv@8.17.1(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedajv-keywords@5.1.0(transitive)
+ Addedarray-union@2.1.0(transitive)
+ Addedat-least-node@1.0.0(transitive)
+ Addedbraces@3.0.3(transitive)
+ Addedbrowserslist@4.24.4(transitive)
+ Addedbuffer-from@1.1.2(transitive)
+ Addedcaniuse-lite@1.0.30001700(transitive)
+ Addedchrome-trace-event@1.0.4(transitive)
+ Addedcommander@2.20.3(transitive)
+ Addeddel@6.1.1(transitive)
+ Addeddir-glob@3.0.1(transitive)
+ Addedelectron-to-chromium@1.5.101(transitive)
+ Addedenhanced-resolve@5.18.1(transitive)
+ Addedes-module-lexer@1.6.0(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedeslint-scope@5.1.1(transitive)
+ Addedesrecurse@4.3.0(transitive)
+ Addedestraverse@4.3.05.3.0(transitive)
+ Addedevents@3.3.0(transitive)
+ Addedfast-glob@3.3.3(transitive)
+ Addedfast-uri@3.0.6(transitive)
+ Addedfastq@1.19.0(transitive)
+ Addedfill-range@7.1.1(transitive)
+ Addedfs-extra@9.1.0(transitive)
+ Addedglob-parent@5.1.2(transitive)
+ Addedglob-to-regexp@0.4.1(transitive)
+ Addedglobby@11.1.0(transitive)
+ Addedhas-flag@4.0.0(transitive)
+ Addedignore@5.3.2(transitive)
+ Addedis-number@7.0.0(transitive)
+ Addedis-path-cwd@2.2.0(transitive)
+ Addedis-path-inside@3.0.3(transitive)
+ Addedjest-worker@27.5.1(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedloader-runner@4.3.0(transitive)
+ Addedmerge-stream@2.0.0(transitive)
+ Addedmicromatch@4.0.8(transitive)
+ Addedmime-db@1.52.0(transitive)
+ Addedmime-types@2.1.35(transitive)
+ Addedneo-async@2.6.2(transitive)
+ Addednode-releases@2.0.19(transitive)
+ Addedp-map@4.0.0(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedpicomatch@2.3.1(transitive)
+ Addedqueue-microtask@1.2.3(transitive)
+ Addedrandombytes@2.1.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedreusify@1.0.4(transitive)
+ Addedrun-parallel@1.2.0(transitive)
+ Addedschema-utils@3.3.04.3.0(transitive)
+ Addedserialize-javascript@6.0.2(transitive)
+ Addedslash@3.0.0(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsource-map-support@0.5.21(transitive)
+ Addedsupports-color@8.1.1(transitive)
+ Addedtapable@2.2.1(transitive)
+ Addedterser@5.39.0(transitive)
+ Addedterser-webpack-plugin@5.3.11(transitive)
+ Addedto-regex-range@5.0.1(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedupdate-browserslist-db@1.1.2(transitive)
+ Addedwatchpack@2.4.2(transitive)
+ Addedwebpack@5.98.0(transitive)
+ Addedwebpack-sources@3.2.3(transitive)
- Removedmake-dir@^3.1.0
- Removedmv@^2.1.1
- Removedrimraf@^3.0.2
- Removedglob@6.0.4(transitive)
- Removedminimist@1.2.8(transitive)
- Removedmkdirp@0.5.6(transitive)
- Removedmv@2.1.1(transitive)
- Removedncp@2.0.0(transitive)
- Removedpify@4.0.1(transitive)
- Removedrimraf@2.4.5(transitive)
- Removedschema-utils@2.7.1(transitive)
Updatedschema-utils@^3.0.0