@adamlui/minify.js 1.5.0 → 1.5.1

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 CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  <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>
23
23
  <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>
24
- <a href="https://github.com/adamlui/js-utils/releases/tag/minify.js-1.5.0"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
24
+ <a href="https://github.com/adamlui/js-utils/releases/tag/minify.js-1.5.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
25
25
  <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>
26
26
  <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>
27
27
  <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
@@ -2,7 +2,7 @@
2
2
  const e="https://docs.minify-js.org/#-command-line-usage",n=require(__dirname.match(/src/)?"./minify":"./minify.min"),o=require("fs"),s=require("path"),r="",t="",l="",i="",a={},c={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(i=>{var e,n,o;i.startsWith("-")&&(e=Object.keys(c.paramOptions).find(e=>c.paramOptions[e].test(i)),o=Object.keys(c.flags).find(e=>c.flags[e].test(i)),n=Object.keys(c.infoCmds).find(e=>c.infoCmds[e].test(i)),o?a[o]=!0:e?(i.includes("=")||(console.error(`
3
3
  ${t}ERROR: Arg [--${i.replace(/-/g,"")}] requires '=' followed by a value.`+r),d(),process.exit(1)),o=i.split("=")[1],a[e]=parseInt(o)||o):n||(console.error(`
4
4
  ${t}ERROR: Arg [${i}] not recognized.`+r),console.info(`
5
- ${l}Valid arguments are below.`+r),m(["paramOptions","flags","infoCmds"]),d(),process.exit(1)))}),process.argv.some(e=>c.infoCmds.help.test(e)))m();else if(process.argv.some(e=>c.infoCmds.version.test(e)))console.info("v"+require("./package.json").version);else{const[u="",p=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),h=s.resolve(process.cwd(),u),g=(u&&!o.existsSync(h)&&(console.error(`
5
+ ${l}Valid arguments are below.`+r),m(["flags","paramOptions","infoCmds"]),d(),process.exit(1)))}),process.argv.some(e=>c.infoCmds.help.test(e)))m();else if(process.argv.some(e=>c.infoCmds.version.test(e)))console.info("v"+require("./package.json").version);else{const[u="",p=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),h=s.resolve(process.cwd(),u),g=(u&&!o.existsSync(h)&&(console.error(`
6
6
  ${t}Error: First argument can only be an existing file or directory.`+`
7
7
  ${h} does not exist.`+r+`
8
8
 
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const c=require("fs"),l=require("path"),s=require("uglify-js");function f(r,i={}){var e="https://docs.minify-js.org/#findjssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1};if("string"!=typeof r)console.error("findJS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findJS() » For more help, please visit "+e);else{var n=l.resolve(process.cwd(),r);if(c.existsSync(n)){if(d(i,o,"findJS('assets/js', { verbose: false, dotFoldes: true })")){i={...o,...i};const s=c.readdirSync(r),t=[];return i.verbose&&!i.isRecursing&&console.info("findJS() » Searching for unminified JS files..."),s.forEach(e=>{var o=l.resolve(r,e);c.statSync(o).isDirectory()&&"node_modules"!=e&&(i.dotFolders||!e.startsWith("."))&&i.recursive?t.push(...f(o,{...i,isRecursing:!0})):!/\.js(?<!\.min\.js)$/.test(e)||!i.dotFiles&&e.startsWith(".")||t.push(o)}),!i.isRecursing&&i.verbose&&(console.info("findJS() » Search complete! "+(0===t.length?"No":t.length)+` file${0==t.length||1<t.length?"s":""} found.`),"minify"===f.caller.name||require.main.filename.endsWith("cli.js")||console.info("findJS() » Check returned array.")),i.isRecursing||0<t.length?t:[]}}else console.error("findJS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findJS() » ${n} does not exist.`),console.info("findJS() » For more help, please visit "+e)}}function e(e,r={}){var o={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 https://docs.minify-js.org/#minifyinput-options");else if(d(r,o,"minify('assets/js', { recursive: false, mangle: false })")){const n={mangle:!!(r={...o,...r}).mangle&&{toplevel:!0}};return c.existsSync(e)?e.endsWith(".js")?(r.verbose&&console.info(`minify() » Minifying ${e}...`),o=s.minify(c.readFileSync(e,"utf8"),n),r.comment&&(o.code=i(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):r.verbose&&!require.main.filename.endsWith("cli.js")&&console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:l.resolve(process.cwd(),e),error:o.error}):(o=f(e,{recursive:r.recursive,verbose:r.verbose,dotFolders:r.dotFolders,dotFiles:r.dotFiles})?.map(e=>{r.verbose&&console.info(`minify() » Minifying ${e}...`);var o=c.readFileSync(e,"utf8"),o=s.minify(o,n);return r.comment&&(o.code=i(o.code)),o.error&&console.error("minify() » ERROR: "+o.error.message),{code:o.code,srcPath:e,error:o.error}}).filter(e=>!e.error),r.verbose&&(0<o.length?console.info("minify() » Minification complete. Check returned object."):console.info("minify() » No unminified JavaScript files processed.")),o):(r.verbose&&console.info("minify() » Minifying passed source code..."),o=s.minify(e,n),r.comment&&(o.code=i(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):r.verbose&&console.info("minify() » Minification complete. Check returned object."),{code:o.code,srcPath:void 0,error:o.error});function i(e){return`/*
2
+ const c=require("fs"),l=require("path"),t=require("uglify-js");function f(r,i={}){var e="https://docs.minify-js.org/#findjssearchdir-options",o={recursive:!0,verbose:!0,dotFolders:!1,dotFiles:!1};if("string"!=typeof r)console.error("findJS() » ERROR: 1st arg <searchDir> must be a string."),console.info("findJS() » For more help, please visit "+e);else{var n=l.resolve(process.cwd(),r);if(c.existsSync(n)){if(m(i,o,e,"findJS('assets/js', { verbose: false, dotFoldes: true })")){i={...o,...i};const s=c.readdirSync(r),t=[];return i.verbose&&!i.isRecursing&&console.info("findJS() » Searching for unminified JS files..."),s.forEach(e=>{var o=l.resolve(r,e);c.statSync(o).isDirectory()&&"node_modules"!=e&&(i.dotFolders||!e.startsWith("."))&&i.recursive?t.push(...f(o,{...i,isRecursing:!0})):!/\.js(?<!\.min\.js)$/.test(e)||!i.dotFiles&&e.startsWith(".")||t.push(o)}),!i.isRecursing&&i.verbose&&(console.info("findJS() » Search complete! "+(0===t.length?"No":t.length)+` file${0==t.length||1<t.length?"s":""} found.`),"minify"===f.caller.name||process.argv.some(e=>e.includes("gulp"))||/cli(?:\.min)?\.js$/.test(require.main.filename)||console.info("findJS() » Check returned array.")),i.isRecursing||0<t.length?t:[]}}else console.error("findJS() » ERROR: 1st arg <searchDir> must be an existing directory."),console.error(`findJS() » ${n} does not exist.`),console.info("findJS() » For more help, please visit "+e)}}function e(e,r={}){var o="https://docs.minify-js.org/#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(m(r,i,o,"minify('assets/js', { recursive: false, mangle: false })")){const s={mangle:!!(r={...i,...r}).mangle&&{toplevel:!0}};return c.existsSync(e)?e.endsWith(".js")?(r.verbose&&console.info(`minify() » Minifying ${e}...`),o=t.minify(c.readFileSync(e,"utf8"),s),r.comment&&(o.code=n(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):!r.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:l.resolve(process.cwd(),e),error:o.error}):(i=f(e,{recursive:r.recursive,verbose:r.verbose,dotFolders:r.dotFolders,dotFiles:r.dotFiles})?.map(e=>{r.verbose&&console.info(`minify() » Minifying ${e}...`);var o=c.readFileSync(e,"utf8"),o=t.minify(o,s);return r.comment&&(o.code=n(o.code)),o.error&&console.error("minify() » ERROR: "+o.error.message),{code:o.code,srcPath:e,error:o.error}}).filter(e=>!e.error),r.verbose&&(0<i.length?console.info("minify() » Minification complete. Check returned object."):console.info("minify() » No unminified JavaScript files processed.")),i):(r.verbose&&!process.argv.some(e=>e.includes("gulp"))&&console.info("minify() » Minifying passed source code..."),o=t.minify(e,s),r.comment&&(o.code=n(o.code)),o.error?console.error("minify() » ERROR: "+o.error.message):r.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 n(e){return`/*
3
3
  ${r.comment}
4
4
  */
5
- `+e}}}function d(e,o,r){const i=JSON.stringify(o,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," "),n=Object.keys(o).join(", "),s=Object.keys(o).filter(e=>"boolean"==typeof o[e]),t=Object.keys(o).filter(e=>Number.isInteger(o[e])),c=(d.caller?.name||"validateOptions")+"() » ";var l=()=>{console.info(c+`Valid options: [ ${n} ]`),console.info(c+"If omitted, default settings are: "+i)},f=()=>{console.info(c+"For more help, please visit https://docs.minify-js.org/#-api-usage")};if("object"!=typeof e)return console.error(c+"ERROR: [options] can only be an object of key/values."),console.info(c+"Example valid call: "+r),l(),f(),!1;for(const a in e){if("isRecursing"!=a&&!Object.prototype.hasOwnProperty.call(o,a))return console.error(c+`ERROR: \`${a}\` is an invalid option.`),l(),f(),!1;if(s.includes(a)&&"boolean"!=typeof e[a])return console.error(c+`ERROR: [${a}] option can only be \`true\` or \`false\`.`),f(),!1;if(t.includes(a)&&(e[a]=parseInt(e[a],10),isNaN(e[a])||e[a]<1))return console.error(c+`ERROR: [${a}] option can only be an integer > 0.`),f(),!1}return!0}module.exports={minify:e,find:f,findJS:f};
5
+ `+e}}}function m(e,o,r,i){const n=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]),c=Object.keys(o).filter(e=>Number.isInteger(o[e])),l=(m.caller?.name||"validateOptions")+"() » ";var f=()=>{console.info(l+`Valid options: [ ${s} ]`),console.info(l+"If omitted, default settings are: "+n)},a=()=>{console.info(l+"For more help, please visit "+r)};if("object"!=typeof e)return console.error(l+"ERROR: [options] can only be an object of key/values."),console.info(l+"Example valid call: "+i),f(),a(),!1;for(const d in e){if("isRecursing"!=d&&!Object.prototype.hasOwnProperty.call(o,d))return console.error(l+`ERROR: \`${d}\` is an invalid option.`),f(),a(),!1;if(t.includes(d)&&"boolean"!=typeof e[d])return console.error(l+`ERROR: [${d}] option can only be \`true\` or \`false\`.`),a(),!1;if(c.includes(d)&&(e[d]=parseInt(e[d],10),isNaN(e[d])||e[d]<1))return console.error(l+`ERROR: [${d}] option can only be an integer > 0.`),a(),!1}return!0}module.exports={minify:e,find:f,findJS:f};
package/docs/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  <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>
23
23
  <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>
24
- <a href="https://github.com/adamlui/js-utils/releases/tag/minify.js-1.5.0"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
24
+ <a href="https://github.com/adamlui/js-utils/releases/tag/minify.js-1.5.1"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
25
25
  <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>
26
26
  <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>
27
27
  <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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/minify.js",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "Recursively minify all JavaScript files",
5
5
  "author": {
6
6
  "name": "Adam Lui",
@@ -20,7 +20,7 @@
20
20
  "minify-js": "dist/cli.min.js"
21
21
  },
22
22
  "directories": {
23
- "lib": ".",
23
+ "lib": "./dist",
24
24
  "doc": "./docs",
25
25
  "test": "./utils/test"
26
26
  },
@@ -50,7 +50,7 @@
50
50
  "utils"
51
51
  ],
52
52
  "bugs": {
53
- "url": "https://js-utils.com/issues"
53
+ "url": "https://github.minify-js.org/issues"
54
54
  },
55
55
  "dependencies": {
56
56
  "uglify-js": "^3.17.4"