@adamlui/minify.js 1.5.7 → 1.5.8
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/README.md +1 -1
- package/dist/cli.min.js +2 -2
- package/dist/minify.min.js +2 -2
- package/docs/README.md +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fminify.js?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
25
25
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
26
|
-
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.
|
|
26
|
+
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.8"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.8-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
27
27
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fminify.js?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
28
28
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_minify.js:node.js/src/minify.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_minify.js%3Anode.js%2Fsrc%2Fminify.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
29
29
|
<a href="https://github.com/toolleeo/cli-apps#programming"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
package/dist/cli.min.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Source: https://code.minify-js.org/node.js
|
|
5
5
|
* Documentation: https://docs.minify-js.org/node.js
|
|
6
6
|
*/
|
|
7
|
-
const pkgName="@adamlui/minify.js",copyright="© 2024 Adam Lui & contributors under the MIT license.",cmdFormat="minify-js [inputPath] [outputPath] [options]",srcURL="https://code.minify-js.org/node.js",docURL="https://docs.minify-js.org/#-command-line-usage",minifyJS=require(__dirname.match(/src/)?"./minify":"./minify.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",bw="[1;97m",config={},
|
|
7
|
+
const pkgName="@adamlui/minify.js",copyright="© 2024 Adam Lui & contributors under the MIT license.",cmdFormat="minify-js [inputPath] [outputPath] [options]",srcURL="https://code.minify-js.org/node.js",docURL="https://docs.minify-js.org/node.js/#-command-line-usage",minifyJS=require(__dirname.match(/src/)?"./minify":"./minify.min"),fs=require("fs"),path=require("path"),execSync=require("child_process")["execSync"],nc="[0m",br="[1;91m",by="[1;33m",bg="[1;92m",bw="[1;97m",config={},reArgs={flags:{dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,includeDotFiles:/^--?(?:df|D|(?:include-?)?dot-?files?=?(?:true|1)?)$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMangle:/^--?(?:M|(?:disable|no)-?mangle|mangle=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/},paramOptions:{comment:/^--?comments?(?:=.*|$)/},infoCmds:{help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/}};if(process.argv.forEach(n=>{var e,i,o;n.startsWith("-")&&(e=Object.keys(reArgs.paramOptions).find(e=>reArgs.paramOptions[e].test(n)),o=Object.keys(reArgs.flags).find(e=>reArgs.flags[e].test(n)),i=Object.keys(reArgs.infoCmds).find(e=>reArgs.infoCmds[e].test(n)),o?config[o]=!0:e?(n.includes("=")||(console.error(`
|
|
8
8
|
${br}ERROR: Arg [--${n.replace(/-/g,"")}] requires '=' followed by a value.`+nc),printHelpCmdAndDocURL(),process.exit(1)),o=n.split("=")[1],config[e]=parseInt(o)||o):i||(console.error(`
|
|
9
9
|
${br}ERROR: Arg [${n}] not recognized.`+nc),console.info(`
|
|
10
|
-
${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>
|
|
10
|
+
${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>reArgs.infoCmds.help.test(e)))printHelpSections();else if(process.argv.some(e=>reArgs.infoCmds.version.test(e))){const k=execSync(`npm view ${pkgName} version`).toString().trim()||"none";let e,i=process.cwd();for(;"/"!=i;){const n=path.join(i,"package.json");if(fs.existsSync(n)){const o=require(n);e=(o.dependencies?.[pkgName]||o.devDependencies?.[pkgName])?.match(/(\d+\.\d+\.\d+)/)[0]||"none";break}i=path.dirname(i)}console.info(`
|
|
11
11
|
Global version: `+k),console.info("Local version: "+e)}else{const[p="",q=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),r=path.resolve(process.cwd(),p),s=(p&&!fs.existsSync(r)&&(console.error(`
|
|
12
12
|
${br}Error: First argument can only be an existing file or directory.`+`
|
|
13
13
|
${r} does not exist.`+nc+`
|
package/dist/minify.min.js
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Source: https://code.minify-js.org/node.js
|
|
5
5
|
* Documentation: https://docs.minify-js.org/node.js
|
|
6
6
|
*/
|
|
7
|
-
const fs=require("fs"),path=require("path"),uglifyJS=require("uglify-js");function findJS(i,
|
|
7
|
+
const fs=require("fs"),path=require("path"),uglifyJS=require("uglify-js");function findJS(i,n={}){var e="https://docs.minify-js.org/node.js/#findjssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1};if("string"!=typeof i)console.error("findJS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findJS() » For more help, please visit "+e);else{var r=path.resolve(process.cwd(),i);if(fs.existsSync(r)){if(validateOptions(n,o,e,"findJS('assets/js', { verbose: false, dotFoldes: true })")){n={...o,...n};const s=fs.readdirSync(i),t=[];return n.verbose&&!n.isRecursing&&console.info("findJS() » Searching for unminified JS files..."),s.forEach(e=>{var o=path.resolve(i,e);fs.statSync(o).isDirectory()&&"node_modules"!=e&&(n.dotFolders||!e.startsWith("."))&&n.recursive?t.push(...findJS(o,{...n,isRecursing:!0})):!/\.js(?<!\.min\.js)$/.test(e)||!n.dotFiles&&e.startsWith(".")||t.push(o)}),!n.isRecursing&&n.verbose&&(console.info("findJS() » Search complete! "+(0==t.length?"No":t.length)+` file${0==t.length||1<t.length?"s":""} found.`),"minify"==findJS.caller.name||process.argv.some(e=>e.includes("gulp"))||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findJS() » Check returned array.")),n.isRecursing||0<t.length?t:[]}}else console.error("findJS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findJS() » ${r} does not exist.`),console.info("findJS() » For more help, please visit "+e)}}function minify(e,n={}){var o="https://docs.minify-js.org/node.js/#minifyinput-options",i={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1,mangle:!0,comment:""};if("string"!=typeof e)console.error("minify() » ERROR: 1st arg <input> must be a string."),console.info("minify() » For more help, please visit "+o);else if(validateOptions(n,i,o,"minify('assets/js', { recursive: false, mangle: false })")){const s={mangle:(n={...i,...n}).mangle};return fs.existsSync(e)?e.endsWith(".js")?(n.verbose&&console.info(`minify() » Minifying ${e}...`),o=uglifyJS.minify(fs.readFileSync(e,"utf8"),s),n.comment&&(o.code=r(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):!n.verbose||process.argv.some(e=>e.includes("gulp"))||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:path.resolve(process.cwd(),e),error:o.error}):(i=findJS(e,{recursive:n.recursive,verbose:n.verbose,dotFolders:n.dotFolders,dotFiles:n.dotFiles})?.map(e=>{n.verbose&&console.info(`minify() » Minifying ${e}...`);var o=fs.readFileSync(e,"utf8"),o=uglifyJS.minify(o,s);return n.comment&&(o.code=r(o.code)),o.error&&console.error("minify() » ERROR: "+o.error.message),{code:o.code,srcPath:e,error:o.error}}).filter(e=>!e.error),n.verbose&&(0<i.length?console.info("minify() » Minification complete. Check returned object."):console.info("minify() » No unminified JavaScript files processed.")),i):(n.verbose&&!process.argv.some(e=>e.includes("gulp"))&&console.info("minify() » Minifying passed source code..."),o=uglifyJS.minify(e,s),n.comment&&(o.code=r(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):n.verbose&&!process.argv.some(e=>e.includes("gulp"))&&console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:void 0,error:o.error});function r(e){var o=n.comment.split("\n").map(e=>" * "+e).join("\n"),i=e.indexOf("#!");return 0<=i?(i=e.indexOf("\n",i)+1,e.slice(0,i)+`/**
|
|
8
8
|
${o}
|
|
9
9
|
*/
|
|
10
10
|
`+e.slice(i)):`/**
|
|
11
11
|
${o}
|
|
12
12
|
*/
|
|
13
|
-
`+e}}}function validateOptions(e,o,i,
|
|
13
|
+
`+e}}}function validateOptions(e,o,i,n){const r=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),s=Object.keys(o).join(", "),t=Object.keys(o).filter(e=>"boolean"==typeof o[e]),l=Object.keys(o).filter(e=>Number.isInteger(o[e]));let c="validateOptions() » ";try{c=validateOptions.caller?.name+"() » "}catch(e){}var f=n.split(",").findIndex(e=>e.trim().startsWith("{"))+1,a=(f+=["st","nd","rd"][f-1]||"th",()=>{console.info(`${c}Valid options: [ ${s} ]`),console.info(c+"If omitted, default settings are: "+r)}),d=()=>{console.info(c+"For more help, please visit "+i)};if("object"!=typeof e)return console.error(c+`ERROR: ${"0th"==f?"[O":f+" arg [o"}ptions] can only be an object of key/values.`),console.info(c+"Example valid call: "+n),a(),d(),!1;for(const u in e){if("isRecursing"!=u&&!Object.prototype.hasOwnProperty.call(o,u))return console.error(`${c}ERROR: \`${u}\` is an invalid option.`),a(),d(),!1;if(t.includes(u)){if("mangle"==u){var m=()=>console.error(c+"ERROR: [mangle] option can only be `true`, `false`, or an object w/ key [toplevel] set to `true` or `false`.");if("object"==typeof e.mangle){for(const p in e.mangle)if(!["toplevel"].includes(p)||"boolean"!=typeof e.mangle[p])return m(),d(),!1}else if("boolean"!=typeof e.mangle)return m(),d(),!1}else if("boolean"!=typeof e[u])return console.error(`${c}ERROR: [${u}] option can only be \`true\` or \`false\`.`),d(),!1}else if(l.includes(u)&&(e[u]=parseInt(e[u],10),isNaN(e[u])||e[u]<1))return console.error(`${c}ERROR: [${u}] option can only be an integer > 0.`),d(),!1}return!0}const funcAliases={minify:["compress"],findJS:["find","findJs","findjs","search"]};module.exports={minify:minify,findJS:findJS};for(const $ in funcAliases)funcAliases[$].forEach(e=>module.exports[e]=module.exports[$]);
|
package/docs/README.md
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js"><img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fminify.js?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
25
25
|
<a href="#%EF%B8%8F-mit-license"><img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
26
|
-
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.
|
|
26
|
+
<a href="https://github.com/adamlui/minify.js/releases/tag/node-v1.5.8"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.8-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
27
27
|
<a href="https://www.npmjs.com/package/@adamlui/minify.js?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fminify.js?style=for-the-badge&logo=ebox&logoColor=white&labelColor=464646&color=blue"></a>
|
|
28
28
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_minify.js:node.js/src/minify.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_minify.js%3Anode.js%2Fsrc%2Fminify.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
|
|
29
29
|
<a href="https://github.com/toolleeo/cli-apps#programming"><img height=31 src="https://img.shields.io/badge/Mentioned_in-Awesome-c4a2bd?logo=awesomelists&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|