use directories for structure

This commit is contained in:
s2
2020-05-26 10:37:57 +02:00
parent 66580d4847
commit ae4aaf2668
1287 changed files with 92093 additions and 13113 deletions

26
node_modules/minify/ChangeLog generated vendored
View File

@@ -1,3 +1,29 @@
2020.03.21, v5.1.1
feature:
- (package) try-to-catch v3.0.0
- (package) try-catch v3.0.0
2020.01.22, v5.1.0
feature:
- (package) eslint-plugin-node v11.0.0
- (package) nyc v15.0.0
- (minify) add ability to pass options to HTML, JS, CSS and IMG parsers (#52)
2019.12.18, v5.0.0
feature:
- (minify) drop support of node < 10
- (package) putout v7.3.1
- (package) eslint-plugin-node v10.0.0
- (package) eslint-plugin-putout v3.0.0
- (package) madrun v5.0.1
- (package) try-to-catch v2.0.0
2019.07.11, v4.1.3
feature:

60
node_modules/minify/README.md generated vendored
View File

@@ -42,8 +42,14 @@ const hello="world";for(let l=0;l<hello.length;l++)console.log(hello[l]);
```js
const minify = require('minify');
const options = {
html: {
removeAttributeQuotes: false,
removeOptionalTags: false
},
};
minify('./client.js')
minify('./client.js', options)
.then(console.log)
.catch(console.error);
@@ -54,9 +60,15 @@ Or with `async-await` and [try-to-catch](https://github.com/coderaiser/try-to-ca
```js
const minify = require('minify');
const tryToCatch = require('try-to-catch');
const options = {
html: {
removeAttributeQuotes: false,
removeOptionalTags: false
}
};
async () => {
const [error, data] = await tryToCatch(minify, './client.js');
const [error, data] = await tryToCatch(minify, './client.js', options);
if (error)
return console.error(error.message);
@@ -65,6 +77,50 @@ async () => {
}();
```
## Options
The options object accepts configuration for `html`, `css`, `js`, and `img` like so:
```js
const options = {
html: {
removeAttributeQuotes: false,
},
css: {
compatibility: '*',
},
js: {
ecma: 5,
},
img: {
maxSize: 4096,
}
}
```
Full documentation for options that each file type accepts can be found on the pages of the libraries used by minify to process the files:
- HTML: https://github.com/kangax/html-minifier
- CSS: https://github.com/jakubpawlowicz/clean-css
- JS: https://github.com/terser/terser
- IMG: https://github.com/Filirom1/css-base64-images
Minify sets a few defaults for HTML that may differ from the base `html-minifier` settings:
- removeComments: true
- removeCommentsFromCDATA: true
- removeCDATASectionsFromCDATA: true
- collapseWhitespace: true
- collapseBooleanAttributes: true
- removeAttributeQuotes: true
- removeRedundantAttributes: true
- useShortDoctype: true
- removeEmptyAttributes: true
- removeEmptyElements: false
- removeOptionalTags: true
- removeScriptTypeAttributes: true
- removeStyleLinkTypeAttributes: true
- minifyJS: true
- minifyCSS: true
## License
MIT

2
node_modules/minify/bin/minify.js generated vendored
View File

@@ -14,7 +14,7 @@ const Argv = process.argv;
const files = Argv.slice(2);
const [In] = files;
log.error = function(e) {
log.error = (e) => {
console.error(e);
process.stdin.pause();
};

7
node_modules/minify/lib/css.js generated vendored
View File

@@ -9,14 +9,17 @@ const Clean = require('clean-css');
* minify css data.
*
* @param data
* @param userOptions - (optional) object that may contain a `css` key with an object of options
*/
module.exports = (data) => {
module.exports = (data, userOptions) => {
assert(data);
const options = userOptions && userOptions.css || {};
const {
styles,
errors,
} = new Clean().minify(data);
} = new Clean(options).minify(data);
const [error] = errors;

13
node_modules/minify/lib/html.js generated vendored
View File

@@ -5,7 +5,7 @@
const assert = require('assert');
const Minifier = require('html-minifier');
const Options = {
const defaultOptions = {
removeComments: true,
removeCommentsFromCDATA: true,
removeCDATASectionsFromCDATA: true,
@@ -32,11 +32,16 @@ const Options = {
* minify html data.
*
* @param data
* @param callback
* @param userOptions - (optional) object that may contain an `html` key with an object of options
*/
module.exports = (data) => {
module.exports = (data, userOptions) => {
assert(data);
return Minifier.minify(data, Options);
const options = {
...defaultOptions,
...userOptions && userOptions.html || {},
};
return Minifier.minify(data, options);
};

16
node_modules/minify/lib/img.js generated vendored
View File

@@ -8,7 +8,9 @@ const fromString = promisify(require('css-b64-images').fromString);
const ONE_KB = 2 ** 10;
const maxSize = 100 * ONE_KB;
const defaultOptions = {
maxSize: 100 * ONE_KB,
};
/**
* minify css data.
@@ -16,16 +18,20 @@ const maxSize = 100 * ONE_KB;
*
* @param name
* @param data
* @param userOptions - (optional) object that may contain an `img` key with an object of options
*/
module.exports = async (name, data) => {
module.exports = async (name, data, userOptions) => {
const dir = path.dirname(name);
const dirRelative = dir + '/../';
const options = {
...defaultOptions,
...userOptions && userOptions.img || {},
};
assert(name);
assert(data);
return fromString(data, dir, dirRelative, {
maxSize,
});
return fromString(data, dir, dirRelative, options);
};

7
node_modules/minify/lib/js.js generated vendored
View File

@@ -7,14 +7,17 @@ const assert = require('assert');
* minify js data.
*
* @param data
* @param userOptions - (optional) object that may contain a `js` key with an object of options
*/
module.exports = (data) => {
module.exports = (data, userOptions) => {
assert(data);
const options = userOptions && userOptions.js || {};
const {
error,
code,
} = terser.minify(data);
} = terser.minify(data, options);
if (error)
throw error;

27
node_modules/minify/lib/minify.js generated vendored
View File

@@ -2,12 +2,10 @@
const DIR = __dirname + '/';
const fs = require('fs');
const {readFile} = require('fs').promises;
const path = require('path');
const {promisify} = require('util');
const tryToCatch = require('try-to-catch');
const readFile = promisify(fs.readFile);
const log = require('debug')('minify');
@@ -22,7 +20,7 @@ function check(name) {
throw Error('name could not be empty!');
}
async function minify(name) {
async function minify(name, userOptions) {
const EXT = ['js', 'html', 'css'];
check(name);
@@ -34,7 +32,7 @@ async function minify(name) {
throw Error(`File type "${ext}" not supported.`);
log('optimizing ' + path.basename(name));
return optimize(name);
return optimize(name, userOptions);
}
function getName(file) {
@@ -49,9 +47,10 @@ function getName(file) {
/**
* function minificate js,css and html files
*
* @param files - js, css or html file path
* @param {string} file - js, css or html file path
* @param {object} userOptions - object with optional `html`, `css, `js`, and `img` keys, which each can contain options to be combined with defaults and passed to the respective minifier
*/
async function optimize(file) {
async function optimize(file, userOptions) {
check(file);
const name = getName(file);
@@ -59,24 +58,26 @@ async function optimize(file) {
log('reading file ' + path.basename(name));
const data = await readFile(name, 'utf8');
return onDataRead(file, data);
return onDataRead(file, data, userOptions);
}
/**
* Processing of files
* @param fileData {name, data}
* Processing of files
* @param {string} filename
* @param {string} data - the contents of the file
* @param {object} userOptions - object with optional `html`, `css, `js`, and `img` keys, which each can contain options to be combined with defaults and passed to the respective minifier
*/
async function onDataRead(filename, data) {
async function onDataRead(filename, data, userOptions) {
log('file ' + path.basename(filename) + ' read');
const ext = path.extname(filename).replace(/^\./, '');
const optimizedData = await minify[ext](data);
const optimizedData = await minify[ext](data, userOptions);
let b64Optimize;
if (ext === 'css')
[, b64Optimize] = await tryToCatch(minify.img, filename, optimizedData);
[, b64Optimize] = await tryToCatch(minify.img, filename, optimizedData, userOptions);
return b64Optimize || optimizedData;
}

40
node_modules/minify/package.json generated vendored
View File

@@ -1,27 +1,27 @@
{
"_from": "minify@^4.1.1",
"_id": "minify@4.1.3",
"_from": "minify@^5.1.0",
"_id": "minify@5.1.1",
"_inBundle": false,
"_integrity": "sha512-ykuscavxivSmVpcCzsXmsVTukWYLUUtPhHj0w2ILvHDGqC+hsuTCihBn9+PJBd58JNvWTNg9132J9nrrI2anzA==",
"_integrity": "sha512-1aAsFXuW+CpkqzHe1sQpJuPDMuX3o13laF1hs0rH0BhQTRwvYDuzrYgB5qXqR/8WafaqK3+oHQVaaSHHMFw3Pg==",
"_location": "/minify",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "minify@^4.1.1",
"raw": "minify@^5.1.0",
"name": "minify",
"escapedName": "minify",
"rawSpec": "^4.1.1",
"rawSpec": "^5.1.0",
"saveSpec": null,
"fetchSpec": "^4.1.1"
"fetchSpec": "^5.1.0"
},
"_requiredBy": [
"/minifyfromhtml"
],
"_resolved": "https://registry.npmjs.org/minify/-/minify-4.1.3.tgz",
"_shasum": "58467922d14303f55a3a28fa79641371955b8fbd",
"_spec": "minify@^4.1.1",
"_where": "/home/s2/Code/vanillajs-seed/node_modules/minifyfromhtml",
"_resolved": "https://registry.npmjs.org/minify/-/minify-5.1.1.tgz",
"_shasum": "6b361361859d3a562ff6a097ae064c20bccb5b40",
"_spec": "minify@^5.1.0",
"_where": "D:\\Projects\\siag\\vanillajs-seed\\node_modules\\minifyfromhtml",
"author": {
"name": "coderaiser",
"email": "mnemonic.enemy@gmail.com",
@@ -40,25 +40,23 @@
"debug": "^4.1.0",
"html-minifier": "^4.0.0",
"terser": "^4.0.0",
"try-catch": "^2.0.0",
"try-to-catch": "^1.0.2"
"try-catch": "^3.0.0",
"try-to-catch": "^3.0.0"
},
"deprecated": false,
"description": "Minifier of js, css, html and img",
"devDependencies": {
"coveralls": "^3.0.0",
"eslint": "^6.0.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-putout": "^1.5.0",
"madrun": "^2.1.2",
"nyc": "^14.1.1",
"putout": "^4.32.0",
"redrun": "^7.0.2",
"rimraf": "^2.6.1",
"eslint-plugin-node": "^11.0.0",
"eslint-plugin-putout": "^3.0.0",
"madrun": "^5.0.1",
"nyc": "^15.0.0",
"putout": "^7.3.1",
"supertape": "^1.2.3"
},
"engines": {
"node": ">= 8.0.0"
"node": ">= 10"
},
"homepage": "http://coderaiser.github.io/minify",
"keywords": [
@@ -90,5 +88,5 @@
"report": "madrun report",
"test": "madrun test"
},
"version": "4.1.3"
"version": "5.1.1"
}