@node-minify/core 8.0.0-beta.0 → 8.0.2-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +4 -6
- package/dist/index.js +4 -15
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +208 -175
- package/dist/index.mjs.map +1 -0
- package/package.json +5 -5
package/dist/index.d.ts
CHANGED
|
@@ -6,11 +6,9 @@ import { Settings } from '@node-minify/types';
|
|
|
6
6
|
* MIT Licensed
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*/
|
|
14
|
-
declare const minify: (settings: Settings) => Promise<unknown>;
|
|
9
|
+
declare const minify: {
|
|
10
|
+
(settings: Settings): Promise<unknown>;
|
|
11
|
+
default: any;
|
|
12
|
+
};
|
|
15
13
|
|
|
16
14
|
export { minify as default };
|
package/dist/index.js
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
1
2
|
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
6
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
8
|
var __copyProps = (to, from, except, desc) => {
|
|
12
9
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
10
|
for (let key of __getOwnPropNames(from))
|
|
@@ -20,14 +17,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
20
17
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
18
|
mod
|
|
22
19
|
));
|
|
23
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
24
|
-
|
|
25
|
-
// src/index.ts
|
|
26
|
-
var src_exports = {};
|
|
27
|
-
__export(src_exports, {
|
|
28
|
-
default: () => src_default
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(src_exports);
|
|
31
20
|
|
|
32
21
|
// src/setup.ts
|
|
33
22
|
var import_path = __toESM(require("path"));
|
|
@@ -220,11 +209,11 @@ var minify = (settings) => {
|
|
|
220
209
|
}
|
|
221
210
|
});
|
|
222
211
|
};
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
0 && (module.exports = {});
|
|
212
|
+
minify.default = minify;
|
|
213
|
+
module.exports = minify;
|
|
226
214
|
/*!
|
|
227
215
|
* node-minify
|
|
228
216
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
229
217
|
* MIT Licensed
|
|
230
218
|
*/
|
|
219
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/setup.ts","../src/compress.ts","../src/compressInMemory.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport path from 'path';\nimport globby from 'globby';\nimport { utils } from '@node-minify/utils';\nimport { Dictionary } from '@node-minify/types';\n\n/**\n * Default settings.\n */\nconst defaultSettings = {\n sync: false,\n options: {},\n buffer: 1000 * 1024,\n callback: false\n};\n\n/**\n * Run setup.\n *\n * @param {Object} inputSettings\n * @return {Object}\n */\nconst setup = (inputSettings: {}) => {\n let settings = Object.assign(utils.clone(defaultSettings), inputSettings);\n\n // In memory\n if (settings.content) {\n checkMandatoriesMemoryContent(inputSettings);\n return settings;\n }\n\n checkMandatories(inputSettings);\n\n settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));\n settings = Object.assign(\n settings,\n checkOutput(settings.input, settings.output, settings.publicFolder, settings.replaceInPlace)\n );\n settings = Object.assign(settings, setPublicFolder(settings.input, settings.publicFolder));\n\n return settings;\n};\n\n/**\n * Check the output path, searching for $1\n * if exist, returns the path remplacing $1 by file name\n *\n * @param {String|Array} input - Path file\n * @param {String} output - Path to the output file\n * @param {String} publicFolder - Path to the public folder\n * @param {Boolean} replaceInPlace - True to replace file in same folder\n * @return {Object}\n */\nconst checkOutput = (input: string | string[], output: string, publicFolder: string, replaceInPlace: boolean) => {\n let reg = new RegExp('\\\\$1');\n if (reg.test(output)) {\n if (Array.isArray(input)) {\n const outputMin = input.map(file =>\n utils.setFileNameMin(file, output, replaceInPlace ? null : publicFolder, replaceInPlace)\n );\n return { output: outputMin };\n } else {\n return { output: utils.setFileNameMin(input, output, replaceInPlace ? null : publicFolder, replaceInPlace) };\n }\n }\n};\n\n/**\n * Handle wildcards in a path, get the real path of each files.\n *\n * @param {String|Array} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcards = (input: string | string[], publicFolder: string) => {\n // If it's a string\n if (!Array.isArray(input)) {\n return wildcardsString(input, publicFolder);\n }\n\n return wildcardsArray(input, publicFolder);\n};\n\n/**\n * Handle wildcards in a path (string only), get the real path of each files.\n *\n * @param {String} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcardsString = (input: string, publicFolder: string) => {\n const output: { input?: string[] } = {};\n\n if (input.indexOf('*') > -1) {\n output.input = getFilesFromWildcards(input, publicFolder);\n }\n\n return output;\n};\n\n/**\n * Handle wildcards in a path (array only), get the real path of each files.\n *\n * @param {Array} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcardsArray = (input: string[], publicFolder: string) => {\n let output: { input?: string[] } = {};\n let isWildcardsPresent = false;\n\n output.input = input;\n\n // Transform all wildcards to path file\n const inputWithPublicFolder = input.map(item => {\n if (item.indexOf('*') > -1) {\n isWildcardsPresent = true;\n }\n return (publicFolder || '') + item;\n });\n\n if (isWildcardsPresent) {\n output.input = globby.sync(inputWithPublicFolder);\n }\n\n // Remove all wildcards from array\n for (let i = 0; i < output.input.length; i++) {\n if (output.input[i].indexOf('*') > -1) {\n output.input.splice(i, 1);\n\n i--;\n }\n }\n\n return output;\n};\n\n/**\n * Get the real path of each files.\n *\n * @param {String} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst getFilesFromWildcards = (input: string, publicFolder: string) => {\n let output: string[] = [];\n\n if (input.indexOf('*') > -1) {\n output = globby.sync((publicFolder || '') + input);\n }\n\n return output;\n};\n\n/**\n * Prepend the public folder to each file.\n *\n * @param {String|Array} input - Path to file(s)\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst setPublicFolder = (input: string | string[], publicFolder: string) => {\n let output: { input?: string | string[] } = {};\n\n if (typeof publicFolder !== 'string') {\n return output;\n }\n\n publicFolder = path.normalize(publicFolder);\n\n if (Array.isArray(input)) {\n output.input = input.map(item => {\n // Check if publicFolder is already in path\n if (path.normalize(item).indexOf(publicFolder) > -1) {\n return item;\n }\n return path.normalize(publicFolder + item);\n });\n return output;\n }\n\n input = path.normalize(input);\n\n // Check if publicFolder is already in path\n if (input.indexOf(publicFolder) > -1) {\n output.input = input;\n return output;\n }\n\n output.input = path.normalize(publicFolder + input);\n\n return output;\n};\n\n/**\n * Check if some settings are here.\n *\n * @param {Object} settings\n */\nconst checkMandatories = (settings: {}) => {\n ['compressor', 'input', 'output'].forEach(item => mandatory(item, settings));\n};\n\n/**\n * Check if some settings are here for memory content.\n *\n * @param {Object} settings\n */\nconst checkMandatoriesMemoryContent = (settings: {}) => {\n ['compressor', 'content'].forEach(item => mandatory(item, settings));\n};\n\n/**\n * Check if the setting exist.\n *\n * @param {String} setting\n * @param {Object} settings\n */\nconst mandatory = (setting: string, settings: Dictionary<string>) => {\n if (!settings[setting]) {\n throw new Error(setting + ' is mandatory.');\n }\n};\n\n/**\n * Expose `setup()`.\n */\nexport { setup };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport fs from 'fs';\nimport mkdirp from 'mkdirp';\nimport { utils } from '@node-minify/utils';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run compressor.\n *\n * @param {Object} settings\n */\nconst compress = (settings: Settings) => {\n if (typeof settings.compressor !== 'function') {\n throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);\n }\n\n createDirectory(settings.output);\n\n if (Array.isArray(settings.output)) {\n return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);\n } else {\n return utils.compressSingleFile(settings);\n }\n};\n\n/**\n * Compress an array of files in sync.\n *\n * @param {Object} settings\n */\nconst compressArrayOfFilesSync = (settings: Settings) => {\n return (\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n return utils.runSync({ settings, content, index });\n })\n );\n};\n\n/**\n * Compress an array of files in async.\n *\n * @param {Object} settings\n */\nconst compressArrayOfFilesAsync = (settings: Settings) => {\n let sequence = Promise.resolve();\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n sequence = sequence.then(() => utils.runAsync({ settings, content, index }));\n });\n return sequence;\n};\n\n/**\n * Create folder of the target file.\n *\n * @param {String} file - Full path of the file\n */\nconst createDirectory = (file: string) => {\n if (Array.isArray(file)) {\n file = file[0];\n }\n const dir = file && file.substr(0, file.lastIndexOf('/'));\n if (!dir) {\n return;\n }\n if (!fs.statSync(dir).isDirectory()) {\n mkdirp.sync(dir);\n }\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { utils } from '@node-minify/utils';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run compressor.\n *\n * @param {Object} settings\n */\nconst compressInMemory = (settings: Settings) => {\n if (typeof settings.compressor !== 'function') {\n throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);\n }\n\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compressInMemory };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { setup } from './setup';\nimport { compress } from './compress';\nimport { compressInMemory } from './compressInMemory';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run node-minify.\n *\n * @param {Object} settings - Settings from user input\n */\nconst minify = (settings: Settings) => {\n return new Promise((resolve, reject) => {\n const method = settings.content ? compressInMemory : compress;\n settings = setup(settings);\n if (!settings.sync) {\n method(settings)\n .then((minified: string) => {\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n })\n .catch((err: Error) => {\n if (settings.callback) {\n settings.callback(err);\n }\n reject(err);\n });\n } else {\n const minified = method(settings);\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n }\n });\n};\n\n/**\n * Expose `minify()`.\n */\nminify.default = minify;\nexport = minify;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AASA,kBAAiB;AACjB,oBAAmB;AACnB,mBAAsB;AAMtB,IAAM,kBAAkB;AAAA,EACtB,MAAM;AAAA,EACN,SAAS,CAAC;AAAA,EACV,QAAQ,MAAO;AAAA,EACf,UAAU;AACZ;AAQA,IAAM,QAAQ,CAAC,kBAAsB;AACnC,MAAI,WAAW,OAAO,OAAO,mBAAM,MAAM,eAAe,GAAG,aAAa;AAGxE,MAAI,SAAS,SAAS;AACpB,kCAA8B,aAAa;AAC3C,WAAO;AAAA,EACT;AAEA,mBAAiB,aAAa;AAE9B,aAAW,OAAO,OAAO,UAAU,UAAU,SAAS,OAAO,SAAS,YAAY,CAAC;AACnF,aAAW,OAAO;AAAA,IAChB;AAAA,IACA,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MAAI,CAAC,KAAK;AACR;AAAA,EACF;AACA,MAAI,CAAC,UAAAC,QAAG,SAAS,GAAG,EAAE,YAAY,GAAG;AACnC,kBAAAC,QAAO,KAAK,GAAG;AAAA,EACjB;AACF;;;ACtEA,IAAAC,gBAAsB;AAQtB,IAAM,mBAAmB,CAAC,aAAuB;AAC/C,MAAI,OAAO,SAAS,eAAe,YAAY;AAC7C,UAAM,IAAI,MAAM,6EAA6E;AAAA,EAC/F;AAEA,SAAO,oBAAM,mBAAmB,QAAQ;AAC1C;;;ACJA,IAAM,SAAS,CAAC,aAAuB;AACrC,SAAO,IAAI,QAAQ,CAAC,SAAS,WAAW;AACtC,UAAM,SAAS,SAAS,UAAU,mBAAmB;AACrD,eAAW,MAAM,QAAQ;AACzB,QAAI,CAAC,SAAS,MAAM;AAClB,aAAO,QAAQ,EACZ,KAAK,CAAC,aAAqB;AAC1B,YAAI,SAAS,UAAU;AACrB,mBAAS,SAAS,MAAM,QAAQ;AAAA,QAClC;AACA,gBAAQ,QAAQ;AAAA,MAClB,CAAC,EACA,MAAM,CAAC,QAAe;AACrB,YAAI,SAAS,UAAU;AACrB,mBAAS,SAAS,GAAG;AAAA,QACvB;AACA,eAAO,GAAG;AAAA,MACZ,CAAC;AAAA,IACL,OAAO;AACL,YAAM,WAAW,OAAO,QAAQ;AAChC,UAAI,SAAS,UAAU;AACrB,iBAAS,SAAS,MAAM,QAAQ;AAAA,MAClC;AACA,cAAQ,QAAQ;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAKA,OAAO,UAAU;AACjB,iBAAS;","names":["globby","path","import_utils","fs","mkdirp","import_utils"]}
|
package/dist/index.mjs
CHANGED
|
@@ -1,200 +1,233 @@
|
|
|
1
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
+
var __esm = (fn, res) => function __init() {
|
|
3
|
+
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
4
|
+
};
|
|
5
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
6
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
// src/setup.ts
|
|
2
10
|
import path from "path";
|
|
3
11
|
import globby from "globby";
|
|
4
12
|
import { utils } from "@node-minify/utils";
|
|
5
|
-
var defaultSettings
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
var checkOutput = (input, output, publicFolder, replaceInPlace) => {
|
|
27
|
-
let reg = new RegExp("\\$1");
|
|
28
|
-
if (reg.test(output)) {
|
|
29
|
-
if (Array.isArray(input)) {
|
|
30
|
-
const outputMin = input.map(
|
|
31
|
-
(file) => utils.setFileNameMin(file, output, replaceInPlace ? null : publicFolder, replaceInPlace)
|
|
13
|
+
var defaultSettings, setup, checkOutput, wildcards, wildcardsString, wildcardsArray, getFilesFromWildcards, setPublicFolder, checkMandatories, checkMandatoriesMemoryContent, mandatory;
|
|
14
|
+
var init_setup = __esm({
|
|
15
|
+
"src/setup.ts"() {
|
|
16
|
+
"use strict";
|
|
17
|
+
defaultSettings = {
|
|
18
|
+
sync: false,
|
|
19
|
+
options: {},
|
|
20
|
+
buffer: 1e3 * 1024,
|
|
21
|
+
callback: false
|
|
22
|
+
};
|
|
23
|
+
setup = (inputSettings) => {
|
|
24
|
+
let settings = Object.assign(utils.clone(defaultSettings), inputSettings);
|
|
25
|
+
if (settings.content) {
|
|
26
|
+
checkMandatoriesMemoryContent(inputSettings);
|
|
27
|
+
return settings;
|
|
28
|
+
}
|
|
29
|
+
checkMandatories(inputSettings);
|
|
30
|
+
settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));
|
|
31
|
+
settings = Object.assign(
|
|
32
|
+
settings,
|
|
33
|
+
checkOutput(settings.input, settings.output, settings.publicFolder, settings.replaceInPlace)
|
|
32
34
|
);
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
35
|
+
settings = Object.assign(settings, setPublicFolder(settings.input, settings.publicFolder));
|
|
36
|
+
return settings;
|
|
37
|
+
};
|
|
38
|
+
checkOutput = (input, output, publicFolder, replaceInPlace) => {
|
|
39
|
+
let reg = new RegExp("\\$1");
|
|
40
|
+
if (reg.test(output)) {
|
|
41
|
+
if (Array.isArray(input)) {
|
|
42
|
+
const outputMin = input.map(
|
|
43
|
+
(file) => utils.setFileNameMin(file, output, replaceInPlace ? null : publicFolder, replaceInPlace)
|
|
44
|
+
);
|
|
45
|
+
return { output: outputMin };
|
|
46
|
+
} else {
|
|
47
|
+
return { output: utils.setFileNameMin(input, output, replaceInPlace ? null : publicFolder, replaceInPlace) };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
wildcards = (input, publicFolder) => {
|
|
52
|
+
if (!Array.isArray(input)) {
|
|
53
|
+
return wildcardsString(input, publicFolder);
|
|
54
|
+
}
|
|
55
|
+
return wildcardsArray(input, publicFolder);
|
|
56
|
+
};
|
|
57
|
+
wildcardsString = (input, publicFolder) => {
|
|
58
|
+
const output = {};
|
|
59
|
+
if (input.indexOf("*") > -1) {
|
|
60
|
+
output.input = getFilesFromWildcards(input, publicFolder);
|
|
61
|
+
}
|
|
62
|
+
return output;
|
|
63
|
+
};
|
|
64
|
+
wildcardsArray = (input, publicFolder) => {
|
|
65
|
+
let output = {};
|
|
66
|
+
let isWildcardsPresent = false;
|
|
67
|
+
output.input = input;
|
|
68
|
+
const inputWithPublicFolder = input.map((item) => {
|
|
69
|
+
if (item.indexOf("*") > -1) {
|
|
70
|
+
isWildcardsPresent = true;
|
|
71
|
+
}
|
|
72
|
+
return (publicFolder || "") + item;
|
|
73
|
+
});
|
|
74
|
+
if (isWildcardsPresent) {
|
|
75
|
+
output.input = globby.sync(inputWithPublicFolder);
|
|
76
|
+
}
|
|
77
|
+
for (let i = 0; i < output.input.length; i++) {
|
|
78
|
+
if (output.input[i].indexOf("*") > -1) {
|
|
79
|
+
output.input.splice(i, 1);
|
|
80
|
+
i--;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return output;
|
|
84
|
+
};
|
|
85
|
+
getFilesFromWildcards = (input, publicFolder) => {
|
|
86
|
+
let output = [];
|
|
87
|
+
if (input.indexOf("*") > -1) {
|
|
88
|
+
output = globby.sync((publicFolder || "") + input);
|
|
89
|
+
}
|
|
90
|
+
return output;
|
|
91
|
+
};
|
|
92
|
+
setPublicFolder = (input, publicFolder) => {
|
|
93
|
+
let output = {};
|
|
94
|
+
if (typeof publicFolder !== "string") {
|
|
95
|
+
return output;
|
|
96
|
+
}
|
|
97
|
+
publicFolder = path.normalize(publicFolder);
|
|
98
|
+
if (Array.isArray(input)) {
|
|
99
|
+
output.input = input.map((item) => {
|
|
100
|
+
if (path.normalize(item).indexOf(publicFolder) > -1) {
|
|
101
|
+
return item;
|
|
102
|
+
}
|
|
103
|
+
return path.normalize(publicFolder + item);
|
|
104
|
+
});
|
|
105
|
+
return output;
|
|
106
|
+
}
|
|
107
|
+
input = path.normalize(input);
|
|
108
|
+
if (input.indexOf(publicFolder) > -1) {
|
|
109
|
+
output.input = input;
|
|
110
|
+
return output;
|
|
111
|
+
}
|
|
112
|
+
output.input = path.normalize(publicFolder + input);
|
|
113
|
+
return output;
|
|
114
|
+
};
|
|
115
|
+
checkMandatories = (settings) => {
|
|
116
|
+
["compressor", "input", "output"].forEach((item) => mandatory(item, settings));
|
|
117
|
+
};
|
|
118
|
+
checkMandatoriesMemoryContent = (settings) => {
|
|
119
|
+
["compressor", "content"].forEach((item) => mandatory(item, settings));
|
|
120
|
+
};
|
|
121
|
+
mandatory = (setting, settings) => {
|
|
122
|
+
if (!settings[setting]) {
|
|
123
|
+
throw new Error(setting + " is mandatory.");
|
|
124
|
+
}
|
|
125
|
+
};
|
|
112
126
|
}
|
|
113
|
-
};
|
|
127
|
+
});
|
|
114
128
|
|
|
115
129
|
// src/compress.ts
|
|
116
130
|
import fs from "fs";
|
|
117
131
|
import mkdirp from "mkdirp";
|
|
118
132
|
import { utils as utils2 } from "@node-minify/utils";
|
|
119
|
-
var compress
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
133
|
+
var compress, compressArrayOfFilesSync, compressArrayOfFilesAsync, createDirectory;
|
|
134
|
+
var init_compress = __esm({
|
|
135
|
+
"src/compress.ts"() {
|
|
136
|
+
"use strict";
|
|
137
|
+
compress = (settings) => {
|
|
138
|
+
if (typeof settings.compressor !== "function") {
|
|
139
|
+
throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);
|
|
140
|
+
}
|
|
141
|
+
createDirectory(settings.output);
|
|
142
|
+
if (Array.isArray(settings.output)) {
|
|
143
|
+
return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);
|
|
144
|
+
} else {
|
|
145
|
+
return utils2.compressSingleFile(settings);
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
compressArrayOfFilesSync = (settings) => {
|
|
149
|
+
return Array.isArray(settings.input) && settings.input.forEach((input, index) => {
|
|
150
|
+
const content = utils2.getContentFromFiles(input);
|
|
151
|
+
return utils2.runSync({ settings, content, index });
|
|
152
|
+
});
|
|
153
|
+
};
|
|
154
|
+
compressArrayOfFilesAsync = (settings) => {
|
|
155
|
+
let sequence = Promise.resolve();
|
|
156
|
+
Array.isArray(settings.input) && settings.input.forEach((input, index) => {
|
|
157
|
+
const content = utils2.getContentFromFiles(input);
|
|
158
|
+
sequence = sequence.then(() => utils2.runAsync({ settings, content, index }));
|
|
159
|
+
});
|
|
160
|
+
return sequence;
|
|
161
|
+
};
|
|
162
|
+
createDirectory = (file) => {
|
|
163
|
+
if (Array.isArray(file)) {
|
|
164
|
+
file = file[0];
|
|
165
|
+
}
|
|
166
|
+
const dir = file && file.substr(0, file.lastIndexOf("/"));
|
|
167
|
+
if (!dir) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
if (!fs.statSync(dir).isDirectory()) {
|
|
171
|
+
mkdirp.sync(dir);
|
|
172
|
+
}
|
|
173
|
+
};
|
|
154
174
|
}
|
|
155
|
-
};
|
|
175
|
+
});
|
|
156
176
|
|
|
157
177
|
// src/compressInMemory.ts
|
|
158
178
|
import { utils as utils3 } from "@node-minify/utils";
|
|
159
|
-
var compressInMemory
|
|
160
|
-
|
|
161
|
-
|
|
179
|
+
var compressInMemory;
|
|
180
|
+
var init_compressInMemory = __esm({
|
|
181
|
+
"src/compressInMemory.ts"() {
|
|
182
|
+
"use strict";
|
|
183
|
+
compressInMemory = (settings) => {
|
|
184
|
+
if (typeof settings.compressor !== "function") {
|
|
185
|
+
throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);
|
|
186
|
+
}
|
|
187
|
+
return utils3.compressSingleFile(settings);
|
|
188
|
+
};
|
|
162
189
|
}
|
|
163
|
-
|
|
164
|
-
};
|
|
190
|
+
});
|
|
165
191
|
|
|
166
192
|
// src/index.ts
|
|
167
|
-
var
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
193
|
+
var require_src = __commonJS({
|
|
194
|
+
"src/index.ts"(exports, module) {
|
|
195
|
+
init_setup();
|
|
196
|
+
init_compress();
|
|
197
|
+
init_compressInMemory();
|
|
198
|
+
var minify = (settings) => {
|
|
199
|
+
return new Promise((resolve, reject) => {
|
|
200
|
+
const method = settings.content ? compressInMemory : compress;
|
|
201
|
+
settings = setup(settings);
|
|
202
|
+
if (!settings.sync) {
|
|
203
|
+
method(settings).then((minified) => {
|
|
204
|
+
if (settings.callback) {
|
|
205
|
+
settings.callback(null, minified);
|
|
206
|
+
}
|
|
207
|
+
resolve(minified);
|
|
208
|
+
}).catch((err) => {
|
|
209
|
+
if (settings.callback) {
|
|
210
|
+
settings.callback(err);
|
|
211
|
+
}
|
|
212
|
+
reject(err);
|
|
213
|
+
});
|
|
214
|
+
} else {
|
|
215
|
+
const minified = method(settings);
|
|
216
|
+
if (settings.callback) {
|
|
217
|
+
settings.callback(null, minified);
|
|
218
|
+
}
|
|
219
|
+
resolve(minified);
|
|
180
220
|
}
|
|
181
|
-
reject(err);
|
|
182
221
|
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
}
|
|
190
|
-
});
|
|
191
|
-
};
|
|
192
|
-
var src_default = minify;
|
|
193
|
-
export {
|
|
194
|
-
src_default as default
|
|
195
|
-
};
|
|
222
|
+
};
|
|
223
|
+
minify.default = minify;
|
|
224
|
+
module.exports = minify;
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
export default require_src();
|
|
196
228
|
/*!
|
|
197
229
|
* node-minify
|
|
198
230
|
* Copyright(c) 2011-2022 Rodolphe Stoclin
|
|
199
231
|
* MIT Licensed
|
|
200
232
|
*/
|
|
233
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/setup.ts","../src/compress.ts","../src/compressInMemory.ts","../src/index.ts"],"sourcesContent":["/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport path from 'path';\nimport globby from 'globby';\nimport { utils } from '@node-minify/utils';\nimport { Dictionary } from '@node-minify/types';\n\n/**\n * Default settings.\n */\nconst defaultSettings = {\n sync: false,\n options: {},\n buffer: 1000 * 1024,\n callback: false\n};\n\n/**\n * Run setup.\n *\n * @param {Object} inputSettings\n * @return {Object}\n */\nconst setup = (inputSettings: {}) => {\n let settings = Object.assign(utils.clone(defaultSettings), inputSettings);\n\n // In memory\n if (settings.content) {\n checkMandatoriesMemoryContent(inputSettings);\n return settings;\n }\n\n checkMandatories(inputSettings);\n\n settings = Object.assign(settings, wildcards(settings.input, settings.publicFolder));\n settings = Object.assign(\n settings,\n checkOutput(settings.input, settings.output, settings.publicFolder, settings.replaceInPlace)\n );\n settings = Object.assign(settings, setPublicFolder(settings.input, settings.publicFolder));\n\n return settings;\n};\n\n/**\n * Check the output path, searching for $1\n * if exist, returns the path remplacing $1 by file name\n *\n * @param {String|Array} input - Path file\n * @param {String} output - Path to the output file\n * @param {String} publicFolder - Path to the public folder\n * @param {Boolean} replaceInPlace - True to replace file in same folder\n * @return {Object}\n */\nconst checkOutput = (input: string | string[], output: string, publicFolder: string, replaceInPlace: boolean) => {\n let reg = new RegExp('\\\\$1');\n if (reg.test(output)) {\n if (Array.isArray(input)) {\n const outputMin = input.map(file =>\n utils.setFileNameMin(file, output, replaceInPlace ? null : publicFolder, replaceInPlace)\n );\n return { output: outputMin };\n } else {\n return { output: utils.setFileNameMin(input, output, replaceInPlace ? null : publicFolder, replaceInPlace) };\n }\n }\n};\n\n/**\n * Handle wildcards in a path, get the real path of each files.\n *\n * @param {String|Array} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcards = (input: string | string[], publicFolder: string) => {\n // If it's a string\n if (!Array.isArray(input)) {\n return wildcardsString(input, publicFolder);\n }\n\n return wildcardsArray(input, publicFolder);\n};\n\n/**\n * Handle wildcards in a path (string only), get the real path of each files.\n *\n * @param {String} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcardsString = (input: string, publicFolder: string) => {\n const output: { input?: string[] } = {};\n\n if (input.indexOf('*') > -1) {\n output.input = getFilesFromWildcards(input, publicFolder);\n }\n\n return output;\n};\n\n/**\n * Handle wildcards in a path (array only), get the real path of each files.\n *\n * @param {Array} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst wildcardsArray = (input: string[], publicFolder: string) => {\n let output: { input?: string[] } = {};\n let isWildcardsPresent = false;\n\n output.input = input;\n\n // Transform all wildcards to path file\n const inputWithPublicFolder = input.map(item => {\n if (item.indexOf('*') > -1) {\n isWildcardsPresent = true;\n }\n return (publicFolder || '') + item;\n });\n\n if (isWildcardsPresent) {\n output.input = globby.sync(inputWithPublicFolder);\n }\n\n // Remove all wildcards from array\n for (let i = 0; i < output.input.length; i++) {\n if (output.input[i].indexOf('*') > -1) {\n output.input.splice(i, 1);\n\n i--;\n }\n }\n\n return output;\n};\n\n/**\n * Get the real path of each files.\n *\n * @param {String} input - Path with wildcards\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst getFilesFromWildcards = (input: string, publicFolder: string) => {\n let output: string[] = [];\n\n if (input.indexOf('*') > -1) {\n output = globby.sync((publicFolder || '') + input);\n }\n\n return output;\n};\n\n/**\n * Prepend the public folder to each file.\n *\n * @param {String|Array} input - Path to file(s)\n * @param {String} publicFolder - Path to the public folder\n * @return {Object}\n */\nconst setPublicFolder = (input: string | string[], publicFolder: string) => {\n let output: { input?: string | string[] } = {};\n\n if (typeof publicFolder !== 'string') {\n return output;\n }\n\n publicFolder = path.normalize(publicFolder);\n\n if (Array.isArray(input)) {\n output.input = input.map(item => {\n // Check if publicFolder is already in path\n if (path.normalize(item).indexOf(publicFolder) > -1) {\n return item;\n }\n return path.normalize(publicFolder + item);\n });\n return output;\n }\n\n input = path.normalize(input);\n\n // Check if publicFolder is already in path\n if (input.indexOf(publicFolder) > -1) {\n output.input = input;\n return output;\n }\n\n output.input = path.normalize(publicFolder + input);\n\n return output;\n};\n\n/**\n * Check if some settings are here.\n *\n * @param {Object} settings\n */\nconst checkMandatories = (settings: {}) => {\n ['compressor', 'input', 'output'].forEach(item => mandatory(item, settings));\n};\n\n/**\n * Check if some settings are here for memory content.\n *\n * @param {Object} settings\n */\nconst checkMandatoriesMemoryContent = (settings: {}) => {\n ['compressor', 'content'].forEach(item => mandatory(item, settings));\n};\n\n/**\n * Check if the setting exist.\n *\n * @param {String} setting\n * @param {Object} settings\n */\nconst mandatory = (setting: string, settings: Dictionary<string>) => {\n if (!settings[setting]) {\n throw new Error(setting + ' is mandatory.');\n }\n};\n\n/**\n * Expose `setup()`.\n */\nexport { setup };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport fs from 'fs';\nimport mkdirp from 'mkdirp';\nimport { utils } from '@node-minify/utils';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run compressor.\n *\n * @param {Object} settings\n */\nconst compress = (settings: Settings) => {\n if (typeof settings.compressor !== 'function') {\n throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);\n }\n\n createDirectory(settings.output);\n\n if (Array.isArray(settings.output)) {\n return settings.sync ? compressArrayOfFilesSync(settings) : compressArrayOfFilesAsync(settings);\n } else {\n return utils.compressSingleFile(settings);\n }\n};\n\n/**\n * Compress an array of files in sync.\n *\n * @param {Object} settings\n */\nconst compressArrayOfFilesSync = (settings: Settings) => {\n return (\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n return utils.runSync({ settings, content, index });\n })\n );\n};\n\n/**\n * Compress an array of files in async.\n *\n * @param {Object} settings\n */\nconst compressArrayOfFilesAsync = (settings: Settings) => {\n let sequence = Promise.resolve();\n Array.isArray(settings.input) &&\n settings.input.forEach((input, index) => {\n const content = utils.getContentFromFiles(input);\n sequence = sequence.then(() => utils.runAsync({ settings, content, index }));\n });\n return sequence;\n};\n\n/**\n * Create folder of the target file.\n *\n * @param {String} file - Full path of the file\n */\nconst createDirectory = (file: string) => {\n if (Array.isArray(file)) {\n file = file[0];\n }\n const dir = file && file.substr(0, file.lastIndexOf('/'));\n if (!dir) {\n return;\n }\n if (!fs.statSync(dir).isDirectory()) {\n mkdirp.sync(dir);\n }\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compress };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { utils } from '@node-minify/utils';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run compressor.\n *\n * @param {Object} settings\n */\nconst compressInMemory = (settings: Settings) => {\n if (typeof settings.compressor !== 'function') {\n throw new Error(`compressor should be a function, maybe you forgot to install the compressor`);\n }\n\n return utils.compressSingleFile(settings);\n};\n\n/**\n * Expose `compress()`.\n */\nexport { compressInMemory };\n","/*!\n * node-minify\n * Copyright(c) 2011-2022 Rodolphe Stoclin\n * MIT Licensed\n */\n\n/**\n * Module dependencies.\n */\nimport { setup } from './setup';\nimport { compress } from './compress';\nimport { compressInMemory } from './compressInMemory';\nimport { Settings } from '@node-minify/types';\n\n/**\n * Run node-minify.\n *\n * @param {Object} settings - Settings from user input\n */\nconst minify = (settings: Settings) => {\n return new Promise((resolve, reject) => {\n const method = settings.content ? compressInMemory : compress;\n settings = setup(settings);\n if (!settings.sync) {\n method(settings)\n .then((minified: string) => {\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n })\n .catch((err: Error) => {\n if (settings.callback) {\n settings.callback(err);\n }\n reject(err);\n });\n } else {\n const minified = method(settings);\n if (settings.callback) {\n settings.callback(null, minified);\n }\n resolve(minified);\n }\n });\n};\n\n/**\n * Expose `minify()`.\n */\nminify.default = minify;\nexport = minify;\n"],"mappings":";;;;;;;;;AASA,OAAO,UAAU;AACjB,OAAO,YAAY;AACnB,SAAS,aAAa;AAXtB,IAiBM,iBAaA,OA+BA,aAqBA,WAgBA,iBAiBA,gBAqCA,uBAiBA,iBAsCA,kBASA,+BAUA;AAlON;AAAA;AAAA;AAiBA,IAAM,kBAAkB;AAAA,MACtB,MAAM;AAAA,MACN,SAAS,CAAC;AAAA,MACV,QAAQ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AAU;AACrB,uBAAS,SAAS,GAAG;AAAA,YACvB;AACA,mBAAO,GAAG;AAAA,UACZ,CAAC;AAAA,QACL,OAAO;AACL,gBAAM,WAAW,OAAO,QAAQ;AAChC,cAAI,SAAS,UAAU;AACrB,qBAAS,SAAS,MAAM,QAAQ;AAAA,UAClC;AACA,kBAAQ,QAAQ;AAAA,QAClB;AAAA,MACF,CAAC;AAAA,IACH;AAKA,WAAO,UAAU;AACjB,qBAAS;AAAA;AAAA;","names":["utils","utils"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@node-minify/core",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.2-beta.0",
|
|
4
4
|
"description": "core of @node-minify",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"compressor",
|
|
@@ -40,17 +40,17 @@
|
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"clean": "pnpm dlx rimraf dist",
|
|
43
|
-
"build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean",
|
|
43
|
+
"build": "npm run clean && tsup src/index.ts --format cjs,esm --dts --clean --sourcemap",
|
|
44
44
|
"prepublishOnly": "npm run build"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@node-minify/utils": "8.0.
|
|
47
|
+
"@node-minify/utils": "8.0.2-beta.0",
|
|
48
48
|
"globby": "11.1.0",
|
|
49
49
|
"mkdirp": "1.0.4"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@node-minify/types": "8.0.
|
|
52
|
+
"@node-minify/types": "8.0.2-beta.0",
|
|
53
53
|
"@types/mkdirp": "^1.0.2"
|
|
54
54
|
},
|
|
55
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "bd2fe186257749fcb9bf7a9ff1ce61fb922c4ade"
|
|
56
56
|
}
|