@adamlui/minify.js 1.5.6 → 1.5.7
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 +6 -6
- 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.7"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.7-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
|
@@ -7,7 +7,7 @@
|
|
|
7
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={},argRegex={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(argRegex.paramOptions).find(e=>argRegex.paramOptions[e].test(n)),o=Object.keys(argRegex.flags).find(e=>argRegex.flags[e].test(n)),i=Object.keys(argRegex.infoCmds).find(e=>argRegex.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"]),
|
|
10
|
+
${by}Valid arguments are below.`+nc),printHelpSections(["flags","paramOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>argRegex.infoCmds.help.test(e)))printHelpSections();else if(process.argv.some(e=>argRegex.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+`
|
|
@@ -18,11 +18,11 @@ ${by}JS files to be minified:`+nc),s.forEach(e=>console.info(e))):console.info(b
|
|
|
18
18
|
No JS files will be minified.`+nc);else{const w=[],x=s.map(e=>{var n=minifyJS.minify(e,{verbose:!config.quietMode,mangle:!config.noMangle,comment:config.comment?.replace(/\\n/g,"\n")});return n.error&&w.push(e),n}).filter(e=>!e.error);x?.forEach(({code:e,srcPath:n})=>{var i=path.join(path.dirname(n),(/so?u?rce?$/.test(path.dirname(n))?"../":"")+(q.endsWith(".js")?path.dirname(q):q||"min")),n=(q.endsWith(".js")&&p.endsWith(".js")?path.basename(q).replace(/(\.min)?\.js$/,""):path.basename(n,".js"))+".min.js",n=path.join(i,n);fs.existsSync(i)||fs.mkdirSync(i,{recursive:!0}),fs.writeFileSync(n,e,"utf8")}),0<x?.length?(printIfNotQuiet(`
|
|
19
19
|
${bg}Minification complete!`+nc),printIfNotQuiet(`${x.length} file${1<x.length?"s":""} minified.`)):printIfNotQuiet(by+"No unminified JavaScript files processed."+nc),0<w.length&&(printIfNotQuiet(`
|
|
20
20
|
`+br+w.length+" file"+(1<w.length?"s":"")+" failed to minify:"+nc),w.forEach(e=>printIfNotQuiet(e)))}}function printHelpSections(e=["header","usage","pathArgs","flags","paramOptions","infoCmds"]){var n=`[106m[30m ${pkgName.replace(/^@[^/]+\//,"")} ${nc} `;const i={header:[`
|
|
21
|
-
├ `+n+copyright,n+"Source: "+srcURL
|
|
22
|
-
${bw}o Usage:`+nc,` ${bw}
|
|
21
|
+
├ `+n+copyright,n+"Source: "+srcURL],usage:[`
|
|
22
|
+
${bw}o Usage:`+nc,` ${bw}» `+(bg+cmdFormat+nc)],pathArgs:[`
|
|
23
23
|
${bw}o Path arguments:`+nc," [inputPath] Path to JS file or directory containing JS files to be minified, relative to the current working directory."," [outputPath] Path to file or directory where minified files will be stored, relative to original file location (if not provided, min/ is used)."],flags:[`
|
|
24
24
|
${bw}o Boolean options:`+nc," -n, --dry-run Don't actually minify the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -D, --include-dotfiles Include dotfiles in file search."," -R, --no-recursion Disable recursive file searching."," -M, --no-mangle Disable mangling names."," -q, --quiet Suppress all logging except errors."],paramOptions:[`
|
|
25
25
|
${bw}o Parameter options:`+nc,'--comment="comment" Prepend comment to minified code.'],infoCmds:[`
|
|
26
|
-
${bw}o Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(
|
|
27
|
-
|
|
28
|
-
`+(docURL+nc))}function printIfNotQuiet(e){config.quietMode||console.info(e)}
|
|
26
|
+
${bw}o Info commands:`+nc," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(t=>{i[t]?.forEach(e=>{{var o=/header|usage/.test(t)?1:29;const r=process.stdout.columns||80,s=[],n=e.match(/\S+|\s+/g);let i="";n.forEach(e=>{var n=r-(0==s.length?0:o);i.length+"| ".length+e.length>n&&(s.push(0==s.length?i:i.trimStart()),i=""),i+=e}),s.push(0==s.length?i:i.trimStart()),s.forEach((e,n)=>console.info("| "+(0==n?e:" ".repeat(o)+e)))}})}),console.info("\nFor more help, please visit: "+bw+docURL+nc)}function printHelpCmdAndDocURL(){console.info(`
|
|
27
|
+
For more help, type 'minify.js --help' or visit
|
|
28
|
+
`+(bw+docURL+nc))}function printIfNotQuiet(e){config.quietMode||console.info(e)}
|
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.7"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.5.7-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>
|