Update with working working version (#12)
* Fix workflow * Trigger * [auto] Update compiled version * [auto] Commit modules * Push Windows changes * Fix * [auto] Update compiled version * Try removing cwd * [auto] Update compiled version * Try with path module * [auto] Update compiled version * Fix path * [auto] Update compiled version * Use raw path * [auto] Update compiled version * Other path * [auto] Update compiled version * Avoid @action/exec * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * test * [auto] Update compiled version * Try with shelljs * [auto] Update compiled version * Fix my stupidity * Copy scripts to local dir * [auto] Update compiled version * Still use path * [auto] Update compiled version * Delete entrypoint.sh * [auto] Update compiled version * Make file executable * [auto] Update compiled version * Try using bash * [auto] Update compiled version
This commit is contained in:
178
node_modules/@node-minify/core/lib/compress.js
generated
vendored
Normal file
178
node_modules/@node-minify/core/lib/compress.js
generated
vendored
Normal file
@@ -0,0 +1,178 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.compress = void 0;
|
||||
|
||||
var _fs = _interopRequireDefault(require("fs"));
|
||||
|
||||
var _mkdirp = _interopRequireDefault(require("mkdirp"));
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*!
|
||||
* node-minify
|
||||
* Copyright(c) 2011-2019 Rodolphe Stoclin
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Run compressor.
|
||||
*
|
||||
* @param {Object} settings
|
||||
*/
|
||||
const compress = settings => {
|
||||
if (typeof settings.compressor !== 'function') {
|
||||
throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);
|
||||
}
|
||||
|
||||
createDirectory(settings.output);
|
||||
|
||||
if (Array.isArray(settings.output)) {
|
||||
return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
|
||||
} else {
|
||||
return compressSingleFile(settings);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Compress an array of files in sync.
|
||||
*
|
||||
* @param {Object} settings
|
||||
*/
|
||||
|
||||
|
||||
exports.compress = compress;
|
||||
|
||||
const compressArrayOfFilesSync = settings => {
|
||||
return settings.input.forEach((input, index) => {
|
||||
const content = getContentFromFiles(input);
|
||||
return runSync({
|
||||
settings,
|
||||
content,
|
||||
index
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Compress an array of files in async.
|
||||
*
|
||||
* @param {Object} settings
|
||||
*/
|
||||
|
||||
|
||||
const compressArrayOfFilesAsync = settings => {
|
||||
let sequence = Promise.resolve();
|
||||
settings.input.forEach((input, index) => {
|
||||
const content = getContentFromFiles(input);
|
||||
sequence = sequence.then(() => runAsync({
|
||||
settings,
|
||||
content,
|
||||
index
|
||||
}));
|
||||
});
|
||||
return sequence;
|
||||
};
|
||||
/**
|
||||
* Compress a single file.
|
||||
*
|
||||
* @param {Object} settings
|
||||
*/
|
||||
|
||||
|
||||
const compressSingleFile = settings => {
|
||||
const content = getContentFromFiles(settings.input);
|
||||
return settings.sync ? runSync({
|
||||
settings,
|
||||
content
|
||||
}) : runAsync({
|
||||
settings,
|
||||
content
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Run compressor in sync.
|
||||
*
|
||||
* @param {Object} settings
|
||||
* @param {String} content
|
||||
* @param {Number} index - index of the file being processed
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
|
||||
const runSync = ({
|
||||
settings,
|
||||
content,
|
||||
index
|
||||
}) => settings.compressor({
|
||||
settings,
|
||||
content,
|
||||
callback: null,
|
||||
index
|
||||
});
|
||||
/**
|
||||
* Run compressor in async.
|
||||
*
|
||||
* @param {Object} settings
|
||||
* @param {String} content
|
||||
* @param {Number} index - index of the file being processed
|
||||
* @return {Promise}
|
||||
*/
|
||||
|
||||
|
||||
const runAsync = ({
|
||||
settings,
|
||||
content,
|
||||
index
|
||||
}) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
settings.compressor({
|
||||
settings,
|
||||
content,
|
||||
callback: (err, min) => {
|
||||
if (err) {
|
||||
return reject(err);
|
||||
}
|
||||
|
||||
resolve(min);
|
||||
},
|
||||
index
|
||||
});
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Concatenate all input files and get the data.
|
||||
*
|
||||
* @param {String|Array} input
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
|
||||
const getContentFromFiles = input => {
|
||||
if (!Array.isArray(input)) {
|
||||
return _fs.default.readFileSync(input, 'utf8');
|
||||
}
|
||||
|
||||
return input.map(path => _fs.default.readFileSync(path, 'utf8')).join('\n');
|
||||
};
|
||||
/**
|
||||
* Create folder of the target file.
|
||||
*
|
||||
* @param {String} file - Full path of the file
|
||||
*/
|
||||
|
||||
|
||||
const createDirectory = file => {
|
||||
if (Array.isArray(file)) {
|
||||
file = file[0];
|
||||
}
|
||||
|
||||
_mkdirp.default.sync(file.substr(0, file.lastIndexOf('/')));
|
||||
};
|
||||
/**
|
||||
* Expose `compress()`.
|
||||
*/
|
||||
56
node_modules/@node-minify/core/lib/core.js
generated
vendored
Normal file
56
node_modules/@node-minify/core/lib/core.js
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
"use strict";
|
||||
|
||||
var _setup = require("./setup");
|
||||
|
||||
var _compress = require("./compress");
|
||||
|
||||
/*!
|
||||
* node-minify
|
||||
* Copyright(c) 2011-2019 Rodolphe Stoclin
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Run node-minify.
|
||||
*
|
||||
* @param {Object} settings - Settings from user input
|
||||
*/
|
||||
const minify = settings => {
|
||||
return new Promise((resolve, reject) => {
|
||||
settings = (0, _setup.setup)(settings);
|
||||
|
||||
if (!settings.sync) {
|
||||
(0, _compress.compress)(settings).then(minified => {
|
||||
if (settings.callback) {
|
||||
settings.callback(null, minified);
|
||||
}
|
||||
|
||||
resolve(minified);
|
||||
}).catch(err => {
|
||||
if (settings.callback) {
|
||||
settings.callback(err);
|
||||
}
|
||||
|
||||
reject(err);
|
||||
});
|
||||
} else {
|
||||
const minified = (0, _compress.compress)(settings);
|
||||
|
||||
if (settings.callback) {
|
||||
settings.callback(null, minified);
|
||||
}
|
||||
|
||||
resolve(minified);
|
||||
}
|
||||
});
|
||||
};
|
||||
/**
|
||||
* Expose `minify()`.
|
||||
*/
|
||||
|
||||
|
||||
module.exports = minify;
|
||||
224
node_modules/@node-minify/core/lib/setup.js
generated
vendored
Normal file
224
node_modules/@node-minify/core/lib/setup.js
generated
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.setup = void 0;
|
||||
|
||||
var _path = _interopRequireDefault(require("path"));
|
||||
|
||||
var _glob = _interopRequireDefault(require("glob"));
|
||||
|
||||
var _utils = require("@node-minify/utils");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
/*!
|
||||
* node-minify
|
||||
* Copyright(c) 2011-2019 Rodolphe Stoclin
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default settings.
|
||||
*/
|
||||
const defaultSettings = {
|
||||
sync: false,
|
||||
options: {},
|
||||
buffer: 1000 * 1024,
|
||||
callback: false
|
||||
};
|
||||
/**
|
||||
* Run setup.
|
||||
*
|
||||
* @param {Object} inputSettings
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
const setup = inputSettings => {
|
||||
checkMandatories(inputSettings);
|
||||
let settings = Object.assign(_utils.utils.clone(defaultSettings), inputSettings);
|
||||
settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));
|
||||
settings = Object.assign(settings, checkOutput(settings.input, settings.output));
|
||||
settings = Object.assign(settings, setPublicFolder(settings.input, settings.publicFolder));
|
||||
return settings;
|
||||
};
|
||||
/**
|
||||
* Check the output path, searching for $1
|
||||
* if exist, returns the path remplacing $1 by file name
|
||||
*
|
||||
* @param {String|Array} input - Path file
|
||||
* @param {String} output - Path to the output file
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
exports.setup = setup;
|
||||
|
||||
function checkOutput(input, output) {
|
||||
let reg = new RegExp('\\$1');
|
||||
|
||||
if (reg.test(output)) {
|
||||
if (Array.isArray(input)) {
|
||||
const outputMin = input.map(file => {
|
||||
return _utils.utils.setFileNameMin(file, output);
|
||||
});
|
||||
return {
|
||||
output: outputMin
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
output: _utils.utils.setFileNameMin(input, output)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Handle wildcards in a path, get the real path of each files.
|
||||
*
|
||||
* @param {String|Array} input - Path with wildcards
|
||||
* @param {String} publicFolder - Path to the public folder
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
const wildcards = (input, publicFolder) => {
|
||||
// If it's a string
|
||||
if (!Array.isArray(input)) {
|
||||
return wildcardsString(input, publicFolder);
|
||||
}
|
||||
|
||||
return wildcardsArray(input, publicFolder);
|
||||
};
|
||||
/**
|
||||
* Handle wildcards in a path (string only), get the real path of each files.
|
||||
*
|
||||
* @param {String} input - Path with wildcards
|
||||
* @param {String} publicFolder - Path to the public folder
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
const wildcardsString = (input, publicFolder) => {
|
||||
const output = {};
|
||||
|
||||
if (input.indexOf('*') > -1) {
|
||||
output.input = getFilesFromWildcards(input, publicFolder);
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
/**
|
||||
* Handle wildcards in a path (array only), get the real path of each files.
|
||||
*
|
||||
* @param {Array} input - Path with wildcards
|
||||
* @param {String} publicFolder - Path to the public folder
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
const wildcardsArray = (input, publicFolder) => {
|
||||
let output = {};
|
||||
output.input = input; // Transform all wildcards to path file
|
||||
|
||||
input.forEach(item => {
|
||||
output.input = output.input.concat(getFilesFromWildcards(item, publicFolder));
|
||||
}); // Remove all wildcards from array
|
||||
|
||||
for (let i = 0; i < output.input.length; i++) {
|
||||
if (output.input[i].indexOf('*') > -1) {
|
||||
output.input.splice(i, 1);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
/**
|
||||
* Get the real path of each files.
|
||||
*
|
||||
* @param {String} input - Path with wildcards
|
||||
* @param {String} publicFolder - Path to the public folder
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
const getFilesFromWildcards = (input, publicFolder) => {
|
||||
let output = [];
|
||||
|
||||
if (input.indexOf('*') > -1) {
|
||||
output = _glob.default.sync((publicFolder || '') + input, null);
|
||||
}
|
||||
|
||||
return output;
|
||||
};
|
||||
/**
|
||||
* Prepend the public folder to each file.
|
||||
*
|
||||
* @param {String|Array} input - Path to file(s)
|
||||
* @param {String} publicFolder - Path to the public folder
|
||||
* @return {Object}
|
||||
*/
|
||||
|
||||
|
||||
const setPublicFolder = (input, publicFolder) => {
|
||||
let output = {};
|
||||
|
||||
if (typeof publicFolder !== 'string') {
|
||||
return output;
|
||||
}
|
||||
|
||||
publicFolder = _path.default.normalize(publicFolder);
|
||||
|
||||
if (Array.isArray(input)) {
|
||||
output.input = input.map(item => {
|
||||
// Check if publicFolder is already in path
|
||||
if (_path.default.normalize(item).indexOf(publicFolder) > -1) {
|
||||
return item;
|
||||
}
|
||||
|
||||
return _path.default.normalize(publicFolder + item);
|
||||
});
|
||||
return output;
|
||||
}
|
||||
|
||||
input = _path.default.normalize(input); // Check if publicFolder is already in path
|
||||
|
||||
if (input.indexOf(publicFolder) > -1) {
|
||||
output.input = input;
|
||||
return output;
|
||||
}
|
||||
|
||||
output.input = _path.default.normalize(publicFolder + input);
|
||||
return output;
|
||||
};
|
||||
/**
|
||||
* Check if some settings are here.
|
||||
*
|
||||
* @param {Object} settings
|
||||
*/
|
||||
|
||||
|
||||
const checkMandatories = settings => {
|
||||
['compressor', 'input', 'output'].forEach(item => mandatory(item, settings));
|
||||
};
|
||||
/**
|
||||
* Check if the setting exist.
|
||||
*
|
||||
* @param {String} setting
|
||||
* @param {Object} settings
|
||||
*/
|
||||
|
||||
|
||||
const mandatory = (setting, settings) => {
|
||||
if (!settings[setting]) {
|
||||
throw new Error(setting + ' is mandatory.');
|
||||
}
|
||||
};
|
||||
/**
|
||||
* Expose `setup()`.
|
||||
*/
|
||||
Reference in New Issue
Block a user