@adamlui/scss-to-css 1.7.5 → 1.7.6

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
@@ -28,11 +28,11 @@
28
28
 
29
29
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css"><img height=31 src="https://img.shields.io/npm/dt/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
30
30
  <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>
31
- <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.5"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.5-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
31
+ <a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-1.7.6"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.6-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
32
32
  <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code"><img height=31 src="https://img.shields.io/npm/unpacked-size/%40adamlui%2Fscss-to-css?style=for-the-badge&logo=ebox&logoColor=white&color=blue&labelColor=464646"></a>
33
- <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ascss-to-css%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
33
+ <a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_js-utils:scss-to-css/src/scss-to-css.js"><img height=31 src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fsonarcloud.io%2Fapi%2Fmeasures%2Fcomponent%3Fcomponent%3Dadamlui_js-utils%3Ascss-to-css%2Fsrc%2Fscss-to-css.js%26metricKeys%3Dvulnerabilities&query=%24.component.measures.0.value&style=for-the-badge&logo=sonarcloud&logoColor=white&labelColor=464646&label=Vulnerabilities&color=gold"></a>
34
34
 
35
- <img height=6px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
35
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
36
36
 
37
37
  ## ⚡ Installation
38
38
 
@@ -258,8 +258,27 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
258
258
 
259
259
  <br>
260
260
 
261
- <img height=6px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
261
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
262
+
263
+ ## 🛠️ Related utilities
264
+
265
+ ### [🖼️ img-to-webp](https://github.com/adamlui/js-utils/tree/main/img-to-webp)
266
+
267
+ > Recursively compress all images to WEBPs.
268
+ <br>[Download](https://raw.githubusercontent.com/adamlui/js-utils/main/img-to-webp/img-to-webp.js) /
269
+ [Discuss](https://github.com/adamlui/js-utils/discussions)
270
+
271
+ ### [</> minify.js](https://github.com/adamlui/js-utils/tree/main/minify.js#readme)
272
+
273
+ > Recursively minify all JavaScript files.
274
+ <br>[Install](https://github.com/adamlui/js-utils/tree/main/minify.js#-installation) /
275
+ [Readme](https://github.com/adamlui/js-utils/tree/main/minify.js#readme) /
276
+ [Discuss](https://github.com/adamlui/js-utils/discussions)
277
+
278
+ <br>
279
+
280
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
262
281
 
263
- <a href="https://github.com/adamlui/js-utils">**Home**</a> /
282
+ <a href="https://github.com/adamlui/js-utils">**JavaScript utilities**</a> /
264
283
  <a href="https://github.com/adamlui/js-utils/discussions">Discuss</a> /
265
284
  <a href="#--scss-to-css">Back to top ↑</a>
@@ -0,0 +1,17 @@
1
+ #!/usr/bin/env node
2
+ const r=require("fs"),n=require("path"),o=require(__dirname.match(/src/)?"./scss-to-css":"./scss-to-css.min"),i="",t="",c="",e="",l={},a={dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/,help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/};if(process.argv.forEach(s=>{var e;s.startsWith("-")&&((e=Object.keys(a).find(e=>a[e].test(s)))?l[e]=!0:(console.error(`
3
+ ${t}ERROR: Arg [${s}] not recognized.`+i),console.info(`
4
+ ${c}Valid arguments are below.`+i),d(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>a.help.test(e)))d();else if(process.argv.some(e=>a.version.test(e)))console.info("v"+require("./package.json").version);else{const[f="",u=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),p=n.resolve(process.cwd(),f),m=(f&&!r.existsSync(p)&&(console.error(`
5
+ ${t}Error: First argument can only be an existing file or directory.`+`
6
+ '${p}' does not exist.`+i+`
7
+
8
+ ${e}Example valid command:
9
+ >> scss-to-css . output.min.css`+i+`
10
+
11
+ ${c}For all command options:
12
+ >> scss-to-css --help`+i),process.exit(1)),f.endsWith(".scss")?[p]:o.findSCSS(p,{recursive:!l.noRecursion,verbose:!l.quietMode}));if(l.dryRun)0<m.length?(console.info(`
13
+ ${c}SCSS files to be compiled:`+i),m.forEach(e=>console.info(e))):console.info(c+`
14
+ No SCSS files will be compiled.`+i);else{const h=[],g=m.map(e=>{var s=o.compile(e,{minify:!l.noMinify,sourceMaps:!l.noSourceMaps,verbose:!l.quietMode});return s.error&&h.push(e),s}).filter(e=>!e.error);if(g?.forEach(({code:e,srcMap:s,srcPath:o})=>{var i=n.join(n.dirname(o),/(?:src|s[ac]ss)$/.test(n.dirname(o))?"../css":u.endsWith(".css")?n.dirname(u):u||"css"),o=(u.endsWith(".css")&&f.endsWith(".scss")?n.basename(u).replace(/(\.min)?\.css$/,""):n.basename(o,".scss"))+".min.css",o=n.join(i,o);r.existsSync(i)||r.mkdirSync(i,{recursive:!0}),r.writeFileSync(o,e,"utf8"),l.noSourceMaps||r.writeFileSync(o+".map",JSON.stringify(s),"utf8")}),0<g?.length){const S=1<g.length?"s":"";s(`
15
+ ${e}Compilation complete!`+i),s(g.length+" CSS file"+S+(l.noSourceMaps?"":` + ${g.length} source map`+S)+" generated.")}else s(c+"No SCSS files processed."+i);0<h.length&&(s(`
16
+ `+t+h.length+" file"+(1<h.length?"s":"")+" failed to compile:"+i),h.forEach(e=>s(e)))}}function d(e=["cmdFormat","pathArgs","configOptions","infoCmds"]){const s={cmdFormat:[`
17
+ ${c}scss-to-css [inputPath] [outputPath] [options]`+i],pathArgs:["\nPath arguments:"," [inputPath] Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory."," [outputPath] Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, css/ is used)."],configOptions:["\nConfig options:"," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -q, --quiet Suppress all logging except errors."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{s[e]?.forEach(e=>{{const i=process.stdout.columns||80,r=[],s=e.match(/\S+|\s+/g);let o="";s.forEach(e=>{var s=i-(0===r.length?0:30);o.length+e.length>s&&(r.push(0===r.length?o:o.trimStart()),o=""),o+=e}),r.push(0===r.length?o:o.trimStart()),r.forEach((e,s)=>console.info(0===s?e:" ".repeat(30)+e))}})})}function s(e){l.quietMode||console.info(e)}
@@ -1,23 +1,7 @@
1
- #!/usr/bin/env node
2
- const c=require("fs"),l=require("path"),t=require("sass");function a(s,r={}){var e={recursive:!0,verbose:!0,dotFolders:!1};if(r={...e,...r},"string"!=typeof s)return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string.");var o=l.resolve(process.cwd(),s);if(!c.existsSync(o))return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory.\n"+`findSCSS() » ${o} does not exist.`);for(const t of Object.keys(r))if(!Object.prototype.hasOwnProperty.call(e,t)){if("isRecursing"!==t)return console.error(`findSCSS() » ERROR: \`${t}\` is an invalid option.
3
- `+`findSCSS() » Valid options: [ ${Object.keys(e).join(", ")} ]`);if("boolean"!=typeof r[t])return console.error(`findSCSS() » ERROR: \`${t}\` option can only be set to \`true\` or \`false\`.`)}const i=c.readdirSync(s),n=[];return r.verbose&&!r.isRecursing&&console.info("\nfindSCSS() » Searching for SCSS files..."),i.forEach(e=>{var o=l.resolve(s,e);c.statSync(o).isDirectory()&&"node_modules"!=e&&(r.dotFolders||!e.startsWith("."))&&r.recursive?n.push(...a(o,{...r,isRecursing:!0})):e.endsWith(".scss")&&n.push(o)}),!r.isRecursing&&r.verbose&&console.info("findSCSS() » Search complete! "+(0===n.length?"No":n.length)+` file${1<n.length?"s":""} found.`+("compile"!==a.caller.name&&require.main!==module?"\nfindSCSS() » Check returned array.":"")),r.isRecursing||0<n.length?n:[]}function s(e,s={}){var o={minify:!0,sourceMaps:!0,recursive:!0,verbose:!0,dotFolders:!1};if(s={...o,...s},"string"!=typeof e)return console.error("findSCSS() » ERROR: 1st arg <inputPath> must be a string.");if(e=l.resolve(process.cwd(),e),!c.existsSync(e))return console.error("findSCSS() » ERROR: 1st arg <inputPath> must be an existing directory or file.\n"+`findSCSS() » ${e} does not exist.`);for(const n of Object.keys(s)){if(!Object.prototype.hasOwnProperty.call(o,n))return console.error(`compile() » ERROR: \`${n}\` is an invalid option.
4
- `+`compile() » Valid options: [ ${Object.keys(o).join(", ")} ]`);if("boolean"!=typeof s[n])return console.error(`compile() » ERROR: \`${n}\` option can only be set to \`true\` or \`false\`.`)}const r={style:s.minify?"compressed":"expanded",sourceMap:s.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return a(e,{recursive:s.recursive,verbose:s.verbose,dotFolders:s.dotFolders})?.map(e=>{s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var o=t.compile(e,r);return{code:o.css,srcMap:o.sourceMap,srcPath:e}}catch(e){return console.error(`
1
+ const c=require("fs"),l=require("path"),t=require("sass");function a(o,s={}){var e={recursive:!0,verbose:!0,dotFolders:!1};if(s={...e,...s},"string"!=typeof o)return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be a string.");var r=l.resolve(process.cwd(),o);if(!c.existsSync(r))return console.error("findSCSS() » ERROR: 1st arg <searchDir> must be an existing directory.\n"+`findSCSS() » ${r} does not exist.`);for(const t in s)if(!Object.prototype.hasOwnProperty.call(e,t)){if("isRecursing"!==t)return console.error(`findSCSS() » ERROR: \`${t}\` is an invalid option.
2
+ `+`findSCSS() » Valid options: [ ${Object.keys(e).join(", ")} ]`);if("boolean"!=typeof s[t])return console.error(`findSCSS() » ERROR: [${t}] option can only be set to \`true\` or \`false\`.`)}const i=c.readdirSync(o),n=[];return s.verbose&&!s.isRecursing&&console.info("\nfindSCSS() » Searching for SCSS files..."),i.forEach(e=>{var r=l.resolve(o,e);c.statSync(r).isDirectory()&&"node_modules"!=e&&(s.dotFolders||!e.startsWith("."))&&s.recursive?n.push(...a(r,{...s,isRecursing:!0})):e.endsWith(".scss")&&n.push(r)}),!s.isRecursing&&s.verbose&&console.info("findSCSS() » Search complete! "+(0===n.length?"No":n.length)+` file${1<n.length?"s":""} found.`+("compile"===a.caller.name||require.main.filename.endsWith("cli.js")?"":"\nfindSCSS() » Check returned array.")),s.isRecursing||0<n.length?n:[]}function e(e,o={}){var r={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0};if(o={...r,...o},"string"!=typeof e)return console.error("compile() » ERROR: 1st arg <inputPath> must be a string.");if(e=l.resolve(process.cwd(),e),!c.existsSync(e))return console.error("compile() » ERROR: 1st arg <inputPath> must be an existing directory or file.\n"+`compile() » ${e} does not exist.`);for(const n in o){if(!Object.prototype.hasOwnProperty.call(r,n))return console.error(`compile() » ERROR: \`${n}\` is an invalid option.
3
+ `+`compile() » Valid options: [ ${Object.keys(r).join(", ")} ]`);if("boolean"!=typeof o[n])return console.error(`compile() » ERROR: [${n}] option can only be set to \`true\` or \`false\`.`)}const s={style:o.minify?"compressed":"expanded",sourceMap:o.sourceMaps};if(c.existsSync(e)){if(!e.endsWith(".scss"))return a(e,{recursive:o.recursive,verbose:o.verbose,dotFolders:o.dotFolders})?.map(e=>{o.verbose&&console.info(`compile() » Compiling ${e}...`);try{var r=t.compile(e,s);return{code:r.css,srcMap:r.sourceMap,srcPath:e}}catch(e){return console.error(`
5
4
  compile() » ERROR: ${e.message}
6
- `),{error:e}}}).filter(e=>!e.error);s.verbose&&console.info(`compile() » Compiling ${e}...`);try{var i=t.compile(e,r);return{code:i.css,srcMap:i.sourceMap,srcPath:l.resolve(process.cwd(),e)}}catch(e){return console.error(`
5
+ `),{error:e}}}).filter(e=>!e.error);o.verbose&&console.info(`compile() » Compiling ${e}...`);try{var i=t.compile(e,s);return{code:i.css,srcMap:i.sourceMap,srcPath:l.resolve(process.cwd(),e)}}catch(e){return console.error(`
7
6
  compile() » ERROR: ${e.message}
8
- `),{error:e}}}}if(require.main!==module)module.exports={compile:s,findSCSS:a};else{const i="",n="",d="",e="",f={},u={dryRun:/^--?(?:n|dry-?run)$/,includeDotFolders:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,noSourceMaps:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,noRecursion:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/,noMinify:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,quietMode:/^--?q(?:uiet)?(?:-?mode)?$/,help:/^--?h(?:elp)?$/,version:/^--?ve?r?s?i?o?n?$/};if(process.argv.forEach(o=>{var e;o.startsWith("-")&&((e=Object.keys(u).find(e=>u[e].test(o)))?f[e]=!0:(console.error(`
9
- ${n}ERROR: Arg [${o}] not recognized.`+i),console.info(`
10
- ${d}Valid arguments are below.`+i),r(["configOptions","infoCmds"]),process.exit(1)))}),process.argv.some(e=>u.help.test(e)))r();else if(process.argv.some(e=>u.version.test(e)))console.info("v"+require("./package.json").version);else{const[p="",m=""]=process.argv.slice(2).filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,"")),S=l.resolve(process.cwd(),p),h=(p&&!c.existsSync(S)&&(console.error(`
11
- ${n}Error: First argument can only be an existing file or directory.`+`
12
- '${S}' does not exist.`+i+`
13
-
14
- ${e}Example valid command:
15
- >> scss-to-css . output.min.css`+i+`
16
-
17
- ${d}For all command options:
18
- >> scss-to-css --help`+i),process.exit(1)),p.endsWith(".scss")?[S]:a(S,{recursive:!f.noRecursion,verbose:!f.quietMode}));if(f.dryRun)0<h.length?(console.info(`
19
- ${d}SCSS files to be compiled:`+i),h.forEach(e=>console.info(e))):console.info(d+`
20
- No SCSS files will be compiled.`+i);else{const g=[],v=h.map(e=>{var o=s(e,{minify:!f.noMinify,sourceMaps:!f.noSourceMaps,verbose:!f.quietMode});return o.error&&g.push(e),o}).filter(e=>!e.error);if(v?.forEach(({code:e,srcMap:o,srcPath:s})=>{var r=l.join(l.dirname(s),/(?:src|s[ac]ss)$/.test(l.dirname(s))?"../css":m.endsWith(".css")?l.dirname(m):m||"css"),s=(m.endsWith(".css")&&p.endsWith(".scss")?l.basename(m).replace(/(\.min)?\.css$/,""):l.basename(s,".scss"))+".min.css",s=l.join(r,s);c.existsSync(r)||c.mkdirSync(r,{recursive:!0}),c.writeFileSync(s,e,"utf8"),f.noSourceMaps||c.writeFileSync(s+".map",JSON.stringify(o),"utf8")}),0<v?.length){const y=1<v.length?"s":"";o(`
21
- ${e}Compilation complete!`+i),o(v.length+" CSS file"+y+(f.noSourceMaps?"":` + ${v.length} source map`+y)+" generated.")}else o(d+"No SCSS files processed."+i);0<g.length&&(o(`
22
- `+n+g.length+" file"+(1<g.length?"s":"")+" failed to compile:"+i),g.forEach(e=>o(e)))}}function r(e=["cmdFormat","pathArgs","configOptions","infoCmds"]){const o={cmdFormat:[`
23
- ${d}scss-to-css [inputPath] [outputPath] [options]`+i],pathArgs:["\nPath arguments:"," [inputPath] Path to SCSS file or directory containing SCSS files to be compiled, relative to the current working directory."," [outputPath] Path to file or directory where CSS + sourcemap files will be stored, relative to original file location (if not provided, css/ is used)."],configOptions:["\nConfig options:"," -n, --dry-run Don't actually compile the file(s), just show if they will be processed."," -d, --include-dotfolders Include dotfolders in file search."," -S, --no-source-maps Prevent source maps from being generated."," -M, --no-minify Disable minification of output CSS."," -R, --no-recursion Disable recursive file searching."," -q, --quiet Suppress all logging except errors."],infoCmds:["\nInfo commands:"," -h, --help Display help screen."," -v, --version Show version number."]};e.forEach(e=>{o[e]?.forEach(e=>{{const r=process.stdout.columns||80,i=[],o=e.match(/\S+|\s+/g);let s="";o.forEach(e=>{var o=r-(0===i.length?0:30);s.length+e.length>o&&(i.push(0===i.length?s:s.trimStart()),s=""),s+=e}),i.push(0===i.length?s:s.trimStart()),i.forEach((e,o)=>console.info(0===o?e:" ".repeat(30)+e))}})})}function o(e){f.quietMode||console.info(e)}}
7
+ `),{error:e}}}}module.exports={compile:e,findSCSS:a};
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "1.7.5",
3
+ "version": "1.7.6",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",
7
7
  "email": "adam@kudoai.com",
8
8
  "url": "https://github.com/adamlui"
9
9
  },
10
- "homepage": "https://github.com/adamlui/js-utils",
10
+ "homepage": "https://github.com/adamlui/js-utils/tree/main/scss-to-css#readme",
11
11
  "license": "MIT",
12
12
  "main": "dist/scss-to-css.min.js",
13
13
  "files": [