@adamlui/scss-to-css 2.2.0 → 2.2.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/LICENSE.md +1 -1
- package/README.md +2 -2
- package/dist/cli/index.min.js +3 -3
- package/dist/cli/lib/compile.min.js +2 -2
- package/dist/cli/lib/init.min.js +6 -0
- package/dist/cli/lib/jsdelivr.min.js +6 -0
- package/dist/cli/lib/language.min.js +2 -2
- package/dist/cli/lib/log.min.js +7 -6
- package/dist/cli/lib/pkg.min.js +1 -1
- package/dist/cli/lib/settings.min.js +2 -2
- package/dist/data/messages.json +8 -8
- package/dist/data/package-data.json +1 -1
- package/dist/scss-to-css.min.js +2 -2
- package/docs/README.md +2 -2
- package/package.json +14 -12
package/LICENSE.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# 🏛️ MIT License
|
|
2
2
|
|
|
3
|
-
**Copyright © 2024 [Adam Lui](https://github.com/adamlui) & contributors
|
|
3
|
+
**Copyright © 2024 [Adam Lui](https://github.com/adamlui) & contributors.**
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
6
|
|
package/README.md
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
<img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
34
34
|
<a href="#%EF%B8%8F-mit-license">
|
|
35
35
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
36
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.2.
|
|
37
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.
|
|
36
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.2.1">
|
|
37
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
38
38
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code">
|
|
39
39
|
<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>
|
|
40
40
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:src/scss-to-css.js">
|
package/dist/cli/index.min.js
CHANGED
|
@@ -4,6 +4,6 @@
|
|
|
4
4
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
5
5
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
6
6
|
*/
|
|
7
|
-
(async()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e))
|
|
8
|
-
» scss-to-css . output.min.css`),
|
|
9
|
-
${cli.msgs.info_noSCSSfilesWillBeCompiled}.`):e.scss({srcFiles:d,inputPath:
|
|
7
|
+
(async()=>{globalThis.env={args:process.argv.slice(2),devMode:/[\\/]src(?:[\\/]|$)/i.test(__dirname)},env.debugMode=env.args.some(e=>/^--?debug(?:-?mode)?$/.test(e)),env.modExt=`${env.devMode?"":".min"}.js`;let e=require("./lib/compile"+env.modExt),s=require("../scss-to-css"+env.modExt).findSCSS,i=require("fs"),r=require("./lib/init"+env.modExt),o=require("./lib/log"+env.modExt),c=require("path");if(await r.cli(),cli.config.init)return r.configFile();if(cli.config.help)return o.help();if(cli.config.version)return o.version();var[n="",t=""]=env.args.filter(e=>!e.startsWith("-")).map(e=>e.replace(/^\/*/,""));let l=c.resolve(process.cwd(),n);n&&!i.existsSync(l)&&(d=l+".scss",i.existsSync(d)?l=d:(o.error(`${cli.msgs.error_firstArgNotExist}.\n${l} ${cli.msgs.error_doesNotExist}.`),o.success(cli.msgs.info_exampleValidCmd+`:
|
|
8
|
+
» scss-to-css . output.min.css`),o.helpCmdAndDocURL(),process.exit(1)));var d=/s[ac]ss$/.test(l)&&!i.statSync(l).isDirectory()?[l]:s(l,{recursive:!cli.config.noRecursion,verbose:!cli.config.quietMode,ignores:cli.config.ignores});env.debugMode||cli.config.dryRun?d.length?(o.info(cli.msgs.info_scssFilesToBeCompiled+":"),d.forEach(e=>o.dim(e))):o.info(`
|
|
9
|
+
${cli.msgs.info_noSCSSfilesWillBeCompiled}.`):e.scss({srcFiles:d,inputPath:l,inputArg:n,outputArg:t})})();
|
|
@@ -3,6 +3,6 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
5
|
*/
|
|
6
|
-
let log=require(
|
|
6
|
+
let log=require("./log"+env.modExt);module.exports={scss({srcFiles:i,inputPath:e,inputArg:r,outputArg:t}){let o=require("../../scss-to-css"+env.modExt).compile,g=require("fs"),f=require("path"),c=[],s=[];var n;!cli.config.relativeOutput&&g.statSync(e).isDirectory()?(n=o(e,{verbose:!1,minify:!cli.config.noMinify,comment:cli.config.comment,relativeOutput:!1,recursive:!cli.config.noRecursion,dotFolders:cli.config.includeDotFolders,sourceMaps:!cli.config.noSourceMaps,ignores:cli.config.ignores}))&&(n.error?c.push(e):s=[].concat(n)):s=i.map(i=>{var e=o(i,{verbose:!cli.config.quietMode,minify:!cli.config.noMinify,sourceMaps:!cli.config.noSourceMaps,comment:cli.config.comment});return e.error&&c.push(i),e}).filter(i=>!i.error),cli.config.quietMode||(n=1==(e=s.length)?"":"s",e?(log.success(cli.msgs.info_compilationComplete+"!"),log.data(`${e} CSS ${cli.msgs.info_file}${n}${cli.config.noSourceMaps?"":` + ${e} `+cli.msgs.info_srcMap+n} ${cli.msgs.info_generated}.`)):console.info(cli.msgs.info_noSCSSfilesProcessed+"."),c.length&&(log.error(c.length+" "+cli.msgs.info_file+(1==c.length?"":"s"),cli.msgs.info_failedToCompile+":"),c.forEach(i=>log.ifNotQuiet(i)))),s?.length&&(cli.config.copy&&1==s?.length?(log.data(s[0].code),log.ifNotQuiet(`
|
|
7
7
|
${cli.msgs.info_copyingToClip}...`),require("node-clipboardy").writeSync(s[0].code)):(log.ifNotQuiet(`
|
|
8
|
-
${cli.msgs.info_writing}${1<s?.length?"s":""}...`),s?.forEach(({code:i,srcMap:e,srcPath:o,relPath:c})=>{let s,n;if(!cli.config.relativeOutput&&c){let i=
|
|
8
|
+
${cli.msgs.info_writing}${1<s?.length?"s":""}...`),s?.forEach(({code:i,srcMap:e,srcPath:o,relPath:c})=>{let s,n;if(!cli.config.relativeOutput&&c){let i=f.resolve(process.cwd(),t||"css"),e=f.dirname(c);s="."!=e?f.join(i,e):i,n=`${f.basename(o,f.extname(o))}${cli.config.noMinify?"":".min"}.css`}else s=f.join(f.dirname(o),t.endsWith(".css")?f.dirname(t):t||"css"),n=`${t.endsWith(".css")&&/s[ac]ss$/.test(r)?f.basename(t).replace(/(\.min)?\.css$/,""):f.basename(o,f.extname(o))}.min.css`;let l=f.join(s,n);g.mkdirSync(s,{recursive:!0}),g.writeFileSync(l,i,"utf8"),log.ifNotQuiet(` ${log.colors.bg}✓${log.colors.nc} `+f.relative(process.cwd(),l)),cli.config.noSourceMaps||g.writeFileSync(l+".map",JSON.stringify(e),"utf8"),log.ifNotQuiet(` ${log.colors.bg}✓${log.colors.nc} ${f.relative(process.cwd(),l)}.map`)})))}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2024–2026 Adam Lui & contributors under the MIT license.
|
|
3
|
+
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
|
+
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
|
+
*/
|
|
6
|
+
let language=require("./language"+env.modExt),log=require("./log"+env.modExt),settings=require("./settings"+env.modExt),dataPath="../../"+(env.devMode?"../":"data/");module.exports={async cli(){Object.assign(globalThis.cli??={},require(dataPath+"package-data.json")),cli.lang=settings.load("uiLang")||(env.debugMode?language.generateRandomLang({excludes:["en"]}):language.getSysLang()),cli.msgs=await language.getMsgs(cli.lang),cli.urls.cliDocs=cli.urls.docs+"/#-command-line-usage",cli.lang.startsWith("en")||(cli.docLocale=cli.lang.replace("_","-").toLowerCase(),cli.docLocales??=await language.getDocLocales(),cli.docLocales?.includes(cli.docLocale)&&log.debug(cli.urls.cliDocs=cli.urls.docs+`/${cli.docLocale}#readme`)),settings.load()},async configFile(e=settings.configFilename){var a=require("fs"),i=require("path"),t={target:i.resolve(process.cwd(),e)};if(a.existsSync(t.target))return log.warn(cli.msgs.warn_configFileExists+":",t.target);if(a.existsSync(t.src=i.resolve(__dirname,""+dataPath+e)))a.copyFileSync(t.src,t.target);else{i=require("./jsdelivr"+env.modExt).pkgVerURL+`/${e}/`;log.data(cli.msgs.info_fetchingRemoteConfigFrom+` ${i}...`);try{var l=require("./data"+env.modExt),s=await l.fetch(i);if(!s.ok)return log.warn(`${cli.msgs.warn_remoteConfigNotFound}: ${i} (${s.status})`);l.atomicWrite(t.target,await s.text())}catch(e){return log.warn(cli.msgs.warn_remoteConfigFailed+`: ${i} `+e.message)}}log.success(`${cli.msgs.info_configFileCreated}: ${t.target}\n`),log.tip(cli.msgs.tip_editToSetDefaults+"."),log.tip(cli.msgs.tip_cliArgsPrioritized+".")}};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* © 2024–2026 Adam Lui & contributors under the MIT license.
|
|
3
|
+
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
|
+
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
|
+
*/
|
|
6
|
+
module.exports={pkgVerURL(e){e||=cli.version||=require("./pkg"+env.modExt).getVer("local")||"none";e=/^\d+\.\d+\.\d+$/.test(e)?"v"+e:"latest";return cli.urls.jsdelivr+"@"+e},commitURL(e="latest"){return cli.urls.jsdelivr+"@"+e}};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
5
|
*/
|
|
6
|
-
let data=require(
|
|
7
|
-
`),
|
|
6
|
+
let data=require("./data"+env.modExt),log=require("./log"+env.modExt);module.exports={formatCode(e){return e.replace(/([a-z]{2,8})[-_]([a-z]{2})/i,(e,r,a)=>r.toLowerCase()+"_"+a.toUpperCase())},generateRandomLang({includes:e=[],excludes:r=[]}={}){let t=require("fs"),s=require("path"),a=e.length?e:(()=>{var e=s.join(__dirname,"..",".cache"),r=s.join(e,"locales.json");if(t.existsSync(r))try{return JSON.parse(t.readFileSync(r,"utf8"))}catch(e){}var a=s.resolve(process.cwd(),"_locales");return t.existsSync(a)?(a=t.readdirSync(a,{withFileTypes:!0}).filter(e=>e.isDirectory()).map(e=>e.name).filter(e=>/^\w{2}[-_]?\w{0,2}$/.test(e)),t.mkdirSync(e,{recursive:!0}),data.atomicWrite(r,JSON.stringify(a,null,2)),a):["en"]})(),n=new Set(r),o="en";return(a=a.filter(e=>!n.has(e))).length&&(o=a[Math.floor(Math.random()*a.length)]),log.debug(`Random language: ${o}
|
|
7
|
+
`),o},async getDocLocales(){cli.version||=require("./pkg"+env.modExt).getVer("local")||"none";var e=require("./jsdelivr"+env.modExt).pkgVerURL()+"/docs/",r=[];try{for(var a,t=await(await data.fetch(e)).text(),s=/href=".*\/docs\/([^/]+)\/"/g;a=s.exec(t);)r.push(a[1])}catch(e){log.warn(cli.msgs.warn_docLocalesFetchFailed+":",e.message)}return r},async getMsgs(t="en"){if(t=module.exports.formatCode(t),env.msgs&&t==cli.lang)return env.msgs;let e=data.flatten(require(`../../${env.devMode?"../_locales/en/":"data/"}messages.json`));if(!t.startsWith("en")){var s=require("./jsdelivr"+env.modExt).commitURL(cli.commitHashes.locales)+"/_locales/";let r=s+t+"/messages.json",a=0;for(;a<3;)try{e=data.flatten(await(await data.fetch(r)).json());break}catch(e){if(3<=++a)break;log.debug(r=t.includes("-")&&1==a?r.replace(/([^_]*)_[^/]*(\/.*)/,"$1$2"):s+"en/messages.json")}}return e},getSysLang(){try{var e;return"win32"==process.platform?require("child_process").execSync("(Get-Culture).TwoLetterISOLanguageName",{shell:"powershell",encoding:"utf-8"}).trim():((e=process.env).LANG||e.LANGUAGE||e.LC_ALL||e.LC_MESSAGES||e.LC_NAME).split(".")[0]}catch(e){return log.error(cli.msgs.error_failedToFetchSysLang+":",e.message),"en"}},validateLangCode(e){return"string"==typeof e&&/^[a-z]{2,8}(?:[-_][a-z]{2,3})?$/i.test(e)}};
|
package/dist/cli/lib/log.min.js
CHANGED
|
@@ -5,18 +5,19 @@
|
|
|
5
5
|
*/
|
|
6
6
|
module.exports={colors:{nc:"[0m",br:"[1;91m",by:"[1;33m",bo:"[38;5;214m",bg:"[1;92m",bw:"[1;97m",gry:"[90m",blk:"[30m",tlBG:"[106m"},configURL(){this.info(`
|
|
7
7
|
${cli.msgs.info_exampleValidConfigFile}: `+cli.urls.config)},configURLandExit(...s){this.error(...s),this.configURL(),process.exit(1)},data(s){console.log(`
|
|
8
|
-
`+this.colors.bw+s+this.colors.nc)},debug(s){env.debugMode&&console.
|
|
9
|
-
${this.colors.
|
|
10
|
-
|
|
8
|
+
`+this.colors.bw+s+this.colors.nc)},debug(s){env.debugMode&&console.debug(`
|
|
9
|
+
${this.colors.bo}DEBUG:`,s,this.colors.nc,"\n")},dim(s){console.log(""+this.colors.gry+s+this.colors.nc)},error(...s){console.error(`
|
|
10
|
+
${this.colors.br}ERROR:`,...s,this.colors.nc)},errorAndExit(...s){this.error(...s),this.helpCmdAndDocURL(),process.exit(1)},ifNotQuiet(s){cli.config.quietMode||console.info(s)},info(s){console.info(`
|
|
11
|
+
`+this.colors.by+s+this.colors.nc)},tip(s){console.info(this.colors.by+"TIP: "+s+this.colors.nc)},success(s){console.log(`
|
|
11
12
|
`+this.colors.bg+s+this.colors.nc)},warn(...s){console.warn(`
|
|
12
|
-
${this.colors.bo}
|
|
13
|
+
${this.colors.bo}WARNING:`,...s,this.colors.nc)},help(s=["header","usage","pathArgs","flags","params","cmds"]){cli.prefix=""+this.colors.tlBG+this.colors.blk+` ${cli.name.replace(/^@[^/]+\//,"")} ${this.colors.nc} `;let o={header:[`
|
|
13
14
|
├ ${cli.prefix}${cli.msgs.appCopyright}.`,""+cli.prefix+cli.msgs.prefix_source+": "+cli.urls.src],usage:[`
|
|
14
15
|
${this.colors.bw}o ${cli.msgs.helpSection_usage}:`+this.colors.nc,` ${this.colors.bw}» `+this.colors.bg+cli.cmdFormat+this.colors.nc],pathArgs:[`
|
|
15
16
|
${this.colors.bw}o ${cli.msgs.helpSection_pathArgs}:`+this.colors.nc,` [inputPath] ${cli.msgs.inputPathDesc_main}, ${cli.msgs.inputPathDesc_extra}.`,` [outputPath] ${cli.msgs.outputPathDesc_main}, `+cli.msgs.outputPathDesc_extra],flags:[`
|
|
16
17
|
${this.colors.bw}o ${cli.msgs.helpSection_flags}:`+this.colors.nc,` -n, --dry-run ${cli.msgs.optionDesc_dryRun}.`,` -d, --include-dotfolders ${cli.msgs.optionDesc_dotfolders}.`,` -S, --no-source-maps ${cli.msgs.optionDesc_noSourceMaps}.`,` -M, --no-minify ${cli.msgs.optionDesc_noMinify}.`,` -R, --no-recursion ${cli.msgs.optionDesc_noRecursion}.`,` -r, --relative-output ${cli.msgs.optionDesc_relativeOutput}.`,` -c, --copy ${cli.msgs.optionDesc_copy}.`,` -q, --quiet ${cli.msgs.optionDesc_quiet}.`],params:[`
|
|
17
18
|
${this.colors.bw}o ${cli.msgs.helpSection_params}:`+this.colors.nc,`--ignores="dir/,file1.scss,file2.sass" ${cli.msgs.optionDesc_ignores}.`,`--comment="comment" ${cli.msgs.optionDesc_commentMain}. ${cli.msgs.optionDesc_commentExtra}.`,` --ui-lang="code" ${cli.msgs.optionDesc_uiLang}.`,` --config="path/to/file" ${cli.msgs.optionDesc_config}.`],cmds:[`
|
|
18
19
|
${this.colors.bw}o ${cli.msgs.helpSection_cmds}:`+this.colors.nc,` -i, --init ${cli.msgs.optionDesc_init}.`,` -h, --help ${cli.msgs.optionDesc_help}.`,` -v, --version ${cli.msgs.optionDesc_version}.`]};s.forEach(t=>o[t]?.forEach(o=>{{var e=/header|usage/.test(t)?1:41;let i=process.stdout.columns||80,s=o.match(/\S+|\s+/g),c=[],l="";s.forEach(s=>{var o=i-(c.length?e:0);l.length+"| ".length+s.length>o&&(c.push(c.length?l.trimStart():l),l=""),l+=s}),c.push(c.length?l.trimStart():l),c.forEach((s,o)=>console.info("| "+(0==o?s:" ".repeat(e)+s)))}})),console.info(`
|
|
19
|
-
${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.
|
|
20
|
+
${cli.msgs.info_moreHelp}, ${cli.msgs.info_visit}: `+this.colors.bw+cli.urls.cliDocs+this.colors.nc)},helpCmdAndDocURL(){console.info(`
|
|
20
21
|
${cli.msgs.info_moreHelp}, ${cli.msgs.info_type} ${cli.name.split("/")[1]} --help' ${cli.msgs.info_or} ${cli.msgs.info_visit}
|
|
21
|
-
`+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var s=require(
|
|
22
|
+
`+this.colors.bw+cli.urls.docs+this.colors.nc)},version(){var s=require("./pkg"+env.modExt).getVer;this.info(cli.name),this.data(`${cli.msgs.prefix_globalVer}: ${s("global")||"none"}
|
|
22
23
|
${cli.msgs.prefix_localVer}: `+(s("local")||"none"))}};
|
package/dist/cli/lib/pkg.min.js
CHANGED
|
@@ -3,4 +3,4 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
5
|
*/
|
|
6
|
-
let log=require(
|
|
6
|
+
let log=require("./log"+env.modExt);module.exports={getVer(e="any"){let r;if("global"!=e)try{var l=require("path").resolve(process.cwd(),"node_modules",cli.name,"package.json");r=require(l).version}catch(e){log.debug(cli.msgs.error_readingLocalPkgVer+": "+e.message)}if("global"==e||"all"==e&&!r)try{r=require("child_process").execSync(`npm view ${JSON.stringify(cli.name)} version`).toString().trim()}catch(e){log.debug(cli.msgs.error_failedToFetchGlobalVer+": "+e.message)}return r}};
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
5
|
*/
|
|
6
|
-
let fs=require("fs"),log=require(
|
|
7
|
-
`+e.message)}return env.args.forEach(i=>{
|
|
6
|
+
let fs=require("fs"),log=require("./log"+env.modExt),path=require("path");(globalThis.cli??={}).config={},module.exports={configFilename:"scss-to-css.config.mjs",controls:{dryRun:{type:"flag",regex:/^--?(?:n|dry-?run)$/},includeDotFolders:{type:"flag",regex:/^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/},noSourceMaps:{type:"flag",regex:/^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/},noRecursion:{type:"flag",regex:/^--?(?:R|(?:disable|no)-?recursi(?:on|ve)|recursi(?:on|ve)=(?:false|0))$/},noMinify:{type:"flag",regex:/^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/},relativeOutput:{type:"flag",regex:/^--?(?:r|relative-?output?=?(?:true|1)?)$/},copy:{type:"flag",regex:/^--?c(?:opy)?$/},quietMode:{type:"flag",regex:/^--?q(?:uiet)?(?:-?mode)?$/},ignores:{type:"param",parser:e=>e.split(",").map(e=>e.trim()),regex:/^--?(?:ignores?|(?:ignore|skip|exclude)(?:d?-?files?)?)(?:=.*|$)/},comment:{type:"param",parser:e=>e.replace(/\\n/g,"\n"),regex:/^--?comments?(?:=.*)?$/},uiLang:{type:"param",valType:"langCode",regex:/^--?ui-?lang(?:=.*|$)/},config:{type:"param",valType:"filepath",regex:/^--?config(?:=.*|$)/},init:{type:"cmd",regex:/^-{0,2}i(?:nit)?$/},help:{type:"cmd",regex:/^--?h(?:elp)?$/},version:{type:"cmd",regex:/^--?ve?r?s?i?o?n?$/}},load(e=Object.keys(this.controls)){let r=[].concat(e);if(cli.defaultsSet||arguments.length||(r.forEach(e=>{var i=this.controls[e];i.mode||(cli.config[e]??=i.defaultVal??("param"==i.type&&""))}),cli.defaultsSet=!0),!cli.configPathTried){e=env.args.find(e=>this.controls.config.regex.test(e));if(e){/=/.test(e)||log.errorAndExit(`[${e}] `+cli.msgs.error_mustIncludePath);e=e.split("=")[1];cli.configPath=path.isAbsolute(e)?e:path.resolve(process.cwd(),e),fs.existsSync(cli.configPath)||log.configURLandExit(cli.msgs.error_configFileNotFound+":",cli.configPath)}else for(var i of[".mjs",".cjs",".js"]){i=path.resolve(process.cwd(),this.configFilename.replace(/\.[^.]+$/,i));if(fs.existsSync(i)){cli.configPath=i;break}}cli.configPathTried=!0}if(cli.configPath)try{let e=require(cli.configPath),o=e?.default??e;o&&"object"==typeof o||log.configURLandExit(cli.msgs.error_invalidConfigFile+"."),Object.assign(cli.config,arguments.length?r.reduce((e,i)=>o[i]?{...e,[i]:o[i]}:e,{}):o)}catch(e){log.configURLandExit(cli.msgs.error_failedToLoadConfigFile+":",cli.configPath,`
|
|
7
|
+
`+e.message)}return env.args.forEach(i=>{var e,o;/^[^-]|--?(?:config|debug)/.test(i)&&"init"!=i||(!(e=Object.keys(this.controls).find(e=>this.controls[e]?.regex?.test(i)))&&cli.msgs&&log.errorAndExit(`[${i}] ${cli.msgs.error_notRecognized}.`),r.includes(e)&&((o=this.controls[e]).mode?cli.config.mode=e.replace(/mode$/i,"").toLowerCase():cli.config[e]="param"!=o.type||(i.split("=")[1]?.trim()??"")))}),this.parseValidateConfig(r),1==r.length?cli.config[r[0]]:cli.config},parseValidateConfig(e=Object.keys(this.controls)){let r=require("./language"+env.modExt);for(let o of[].concat(e)){let e=this.controls[o],i=cli.config[o];e.parser&&!e.parsed&&(cli.config[o]=e.parser(i),e.parsed=!0),e.valType&&{positiveInt(){var e=parseInt(i,10);(isNaN(e)||e<1)&&log.errorAndExit(`[${o}] ${cli.msgs.error_nonPositiveNum}: `+i),cli.config[o]=e},filepath(){i&&!fs.existsSync(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidFilepath}: `+i)},langCode(){i&&!r.validateLangCode(i)&&log.errorAndExit(`[${o}] ${cli.msgs.error_invalidLangCode}: `+i)}}[e.valType]()}}};
|
package/dist/data/messages.json
CHANGED
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"appName": { "message": "scss-to-css" },
|
|
3
3
|
"appCopyright": { "message": "© 2024–2026 Adam Lui & contributors under the MIT license" },
|
|
4
|
-
"prefix_error": { "message": "ERROR" },
|
|
5
|
-
"prefix_tip": { "message": "TIP" },
|
|
6
|
-
"prefix_warning": { "message": "WARNING" },
|
|
7
4
|
"prefix_globalVer": { "message": "Global version" },
|
|
8
5
|
"prefix_localVer": { "message": "Local version" },
|
|
9
6
|
"prefix_source": { "message": "Source" },
|
|
10
7
|
"error_readingLocalPkgVer": { "message": "Error reading local package version" },
|
|
11
8
|
"error_notRecognized": { "message": "not recognized" },
|
|
12
9
|
"error_nonPositiveNum": { "message": "argument can only be > 0" },
|
|
10
|
+
"error_invalidFilepath": { "message": "must be a valid existing file path. Got" },
|
|
11
|
+
"error_invalidLangCode": { "message": "is an invalid language code" },
|
|
13
12
|
"error_invalidURL": { "message": "Invalid URL" },
|
|
14
13
|
"error_invalidConfigFile": { "message": "Config file must export an object" },
|
|
15
14
|
"error_configFileNotFound": { "message": "Config file not found" },
|
|
16
15
|
"error_failedToLoadConfigFile": { "message": "Failed to load config file" },
|
|
17
16
|
"error_failedToFetchGlobalVer": { "message": "Failed to fetch global version" },
|
|
17
|
+
"error_failedToFetchSysLang": { "message": "Failed to fetch system language" },
|
|
18
18
|
"error_mustIncludePath": { "message": "must include =path" },
|
|
19
|
-
"warn_configFileExists": { "message": "Config file already exists" },
|
|
20
|
-
"info_exampleValidConfigFile": { "message": "Example valid config file" },
|
|
21
19
|
"error_firstArgNotExist": { "message": "First argument can only be an existing file or directory" },
|
|
22
20
|
"error_doesNotExist": { "message": "does not exist" },
|
|
21
|
+
"warn_configFileExists": { "message": "Config file already exists" },
|
|
22
|
+
"warn_remoteConfigNotFound": { "message": "Remote config file not found" },
|
|
23
|
+
"warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
|
|
24
|
+
"warn_docLocalesFetchFailed": { "message": "Failed to fetch doc locales" },
|
|
25
|
+
"info_exampleValidConfigFile": { "message": "Example valid config file" },
|
|
23
26
|
"info_exampleValidCmd": { "message": "Example valid command" },
|
|
24
27
|
"info_scssFilesToBeCompiled": { "message": "SCSS files to be compiled" },
|
|
25
28
|
"info_noSCSSfilesWillBeCompiled": { "message": "No SCSS files will be compiled" },
|
|
@@ -37,9 +40,6 @@
|
|
|
37
40
|
"info_visit": { "message": "visit" },
|
|
38
41
|
"info_configFileCreated": { "message": "Config file created" },
|
|
39
42
|
"info_fetchingRemoteConfigFrom": { "message": "Fetching remote config file from" },
|
|
40
|
-
"warn_remoteConfigNotFound": { "message": "Remote config file not found" },
|
|
41
|
-
"warn_remoteConfigFailed": { "message": "Failed to fetch remote config file" },
|
|
42
|
-
"warn_docLocalesFetchFailed": { "message": "Failed to fetch doc locales" },
|
|
43
43
|
"tip_editToSetDefaults": { "message": "Edit this file to customize defaults" },
|
|
44
44
|
"tip_cliArgsPrioritized": { "message": "CLI arguments always override these values" },
|
|
45
45
|
"helpSection_usage": { "message": "Usage" },
|
package/dist/scss-to-css.min.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* Source: https://github.com/adamlui/scss-to-css/tree/main/src
|
|
4
4
|
* Documentation: https://github.com/adamlui/scss-to-css/tree/main/docs
|
|
5
5
|
*/
|
|
6
|
-
let fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(
|
|
6
|
+
let fs=require("fs"),path=require("path"),sass=require("sass");function findSCSS(o,i={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#findscsssearchdir-options",r={recursive:!0,verbose:!0,dotFolders:!1,ignores:[]};if(log.prefix="findSCSS()","string"!=typeof o)log.errHelpURLandThrow({errMsg:"1st arg <searchDir> must be a string.",helpURL:e});else{var s=path.resolve(process.cwd(),o);if(!fs.existsSync(s))return log.error("1st arg <searchDir> must be an existing directory."),log.error(s+" does not exist."),log.helpURL(e)}if(validateOptions({options:i,defaultOptions:r,helpURL:e,exampleCall:"findSCSS('assets/scss', { verbose: false, dotFolders: true })"})){(i={...r,...i}).ignoreFiles&&(i.ignores=[...i.ignores,...i.ignoreFiles]);let e=fs.readdirSync(o),s=[];return i.verbose&&!i.isRecursing&&log.info("Searching for files..."),e.forEach(e=>{let r=path.resolve(o,e);i.ignores.some(s=>s.endsWith("/")?r.split(path.sep).some(e=>e==s.replace(/\/$/,"")):e==s)?i.verbose&&log.info(`** ${e} ignored`):fs.statSync(r).isDirectory()&&"node_modules"!=e&&i.recursive&&(i.dotFolders||!e.startsWith("."))?s.push(...findSCSS(r,{...i,isRecursing:!0})):/s[ac]ss$/.test(e)&&s.push(r)}),i.verbose&&!i.isRecursing&&(log.info("Search complete!",`${s.length||"No"} file${1==s.length?"":"s"} found.`),"compile"!=findSCSS.caller?.name)&&"undefined"!=typeof window&&log.info("Check returned array."),i.isRecursing||s.length?s:[]}}function compile(i,t={}){var e="https://github.com/adamlui/scss-to-css/tree/main/docs/#compileinput-options",s={recursive:!0,verbose:!0,dotFolders:!1,minify:!0,sourceMaps:!0,relativeOutput:!1,ignores:[],comment:""};if(log.prefix="compile()","string"!=typeof i&&log.errHelpURLandThrow({errMsg:"1st arg <input> must be a string.",helpURL:e}),validateOptions({options:t,defaultOptions:s,helpURL:e,exampleCall:"compile('assets/scss', { recursive: false, minify: false })"})){(t={...s,...t}).ignoreFiles&&(t.ignores=[...t.ignores,...t.ignoreFiles]);let o={style:t.minify?"compressed":"expanded",sourceMap:t.sourceMaps,charset:!1};if(fs.existsSync(i)){if(!/s[ac]ss$/.test(i)||!fs.statSync(i).isFile())return e=findSCSS(i,t)?.map(e=>{t.verbose&&log.info(`** Compiling ${e}...`);try{var s=sass.compile(e,o),r=t.relativeOutput?void 0:path.relative(path.resolve(process.cwd(),i),e);return t.comment&&(s.css=prependComment(s.css,t.comment)),{code:s.css,srcMap:s.sourceMap,srcPath:e,relPath:r,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}).filter(e=>!e.error),t.verbose&&(e.length&&"undefined"!=typeof window?log.info("Compilation complete! Check returned object."):log.info("No SCSS files processed.")),e;t.verbose&&log.info(`** Compiling ${i}...`);try{var r=sass.compile(i,o);return t.comment&&(r.css=prependComment(r.css,t.comment)),t.verbose&&"undefined"!=typeof window&&log.info("Compilation complete! Check returned object."),{code:r.css,srcMap:r.sourceMap,srcPath:path.resolve(process.cwd(),i),error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}else{t.verbose&&log.info("** Compiling passed source code...");try{var n=sass.compileString(i,o);return t.comment&&(n.css=prependComment(n.css,t.comment)),{code:n.css,srcMap:n.sourceMap,srcPath:void 0,error:void 0}}catch(e){return log.error(e.message),{code:void 0,srcMap:void 0,srcPath:void 0,error:e}}}}}function prependComment(e,s){let r="";var o=e.match(/^#!.*\n/);return o&&(r=o[0],e=e.slice(r.length)),`${r}/**
|
|
7
7
|
${s.split("\n").map(e=>" * "+e).join("\n")}
|
|
8
8
|
*/
|
|
9
|
-
`+e}function validateOptions({options:e,defaultOptions:s,helpURL:
|
|
9
|
+
`+e}function validateOptions({options:e,defaultOptions:s,helpURL:r,exampleCall:o}){var i,t,n=Object.keys(s).filter(e=>"boolean"==typeof s[e]),l=Object.keys(s).filter(e=>Number.isInteger(s[e]));if("object"!=typeof e)return i=o.split(",").findIndex(e=>e.trim().startsWith("{"))+1,i+=["st","nd","rd"][i-1]||"th",log.error(`${"0th"==i?"[O":i+" arg [o"}ptions] can only be an object of key/vals.`),log.info("Example valid call:",o),log.validOptions(s),log.helpURL(r),!1;for(t in e)if("isRecursing"!=t&&Object.prototype.hasOwnProperty.call(s,t)){if(n.includes(t)&&"boolean"!=typeof e[t])return log.error(`[${t}] option can only be \`true\` or \`false\`.`),log.helpURL(r),!1;if(l.includes(t)&&(e[t]=parseInt(e[t],10),isNaN(e[t])||e[t]<1))return log.error(`[${t}] option can only be an integer > 0.`),log.helpURL(r),!1}return!0}Object.assign(globalThis.api??={},require(`${/[\\/]src(?:[\\/]|$)/i.test(__dirname)?"../":"./data/"}package-data.json`)),api.aliases={compile:["build","Build","Compile","compress","Compress","minify","Minify"],findSCSS:["find","Find","findscss","findScss","Findscss","FindScss","FindSCSS","search","Search"]};let log={prefix:api.name,errHelpURLandThrow({errMsg:e,helpURL:s}){throw this.error(e),this.helpURL(s),new Error(e)},error(...e){console.error(this.prefix+" » ERROR:",...e)},helpURL(e=api.urls?.docs){this.info("For more help, please visit",e)},info(...e){console.info(this.prefix+" »",...e)},validOptions(e){var s=Object.keys(e).join(", "),e=JSON.stringify(e,null,2).replace(/"([^"]+)":/g,"$1:").replace(/"/g,"'").replace(/\n\s*/g," ");this.info(`Valid options: [${s}]`),this.info("If omitted, default settings are: "+e)}};module.exports={compile:compile,findSCSS:findSCSS};for(let s in api.aliases)api.aliases[s].forEach(e=>module.exports[e]??=module.exports[s]);
|
package/docs/README.md
CHANGED
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
<img height=31 src="https://img.shields.io/npm/dm/%40adamlui%2Fscss-to-css?logo=npm&color=af68ff&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
34
34
|
<a href="#%EF%B8%8F-mit-license">
|
|
35
35
|
<img height=31 src="https://img.shields.io/badge/License-MIT-orange.svg?logo=internetarchive&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
36
|
-
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.2.
|
|
37
|
-
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.
|
|
36
|
+
<a href="https://github.com/adamlui/js-utils/releases/tag/scss-to-css-2.2.1">
|
|
37
|
+
<img height=31 src="https://img.shields.io/badge/Latest_Build-2.2.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
|
|
38
38
|
<a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=code">
|
|
39
39
|
<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>
|
|
40
40
|
<a href="https://sonarcloud.io/component_measures?metric=new_vulnerabilities&id=adamlui_scss-to-css:src/scss-to-css.js">
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adamlui/scss-to-css",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "Recursively compile all SCSS files into minified CSS",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Adam Lui",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"lint:all": "eslint .",
|
|
48
48
|
"lint:fix": "eslint . --fix --cache",
|
|
49
49
|
"lint:fix-all": "eslint . --fix",
|
|
50
|
-
"translate": "
|
|
50
|
+
"translate": "translate-messages",
|
|
51
51
|
"build": "node utils/build",
|
|
52
52
|
"build:js": "node utils/build --js",
|
|
53
53
|
"build:data": "node utils/build --data",
|
|
@@ -62,14 +62,16 @@
|
|
|
62
62
|
"url": "git+https://github.com/adamlui/scss-to-css.git"
|
|
63
63
|
},
|
|
64
64
|
"keywords": [
|
|
65
|
-
"scss",
|
|
66
|
-
"compiler",
|
|
67
|
-
"minifier",
|
|
68
|
-
"cli",
|
|
69
65
|
"api",
|
|
70
|
-
"
|
|
66
|
+
"cli",
|
|
67
|
+
"compiler",
|
|
68
|
+
"compression",
|
|
71
69
|
"css",
|
|
72
|
-
"
|
|
70
|
+
"sass",
|
|
71
|
+
"scss",
|
|
72
|
+
"stylesheets",
|
|
73
|
+
"minifier",
|
|
74
|
+
"utility"
|
|
73
75
|
],
|
|
74
76
|
"bugs": {
|
|
75
77
|
"url": "https://github.com/adamlui/scss-to-css/issues"
|
|
@@ -79,11 +81,11 @@
|
|
|
79
81
|
"sass": "^1.97.3"
|
|
80
82
|
},
|
|
81
83
|
"devDependencies": {
|
|
82
|
-
"@adamlui/minify.js": "^2.
|
|
83
|
-
"@eslint/json": "^1.0.
|
|
84
|
+
"@adamlui/minify.js": "^2.3.0",
|
|
85
|
+
"@eslint/json": "^1.0.1",
|
|
84
86
|
"@eslint/markdown": "^7.5.1",
|
|
85
|
-
"@stylistic/eslint-plugin": "^5.
|
|
86
|
-
"eslint": "^9.39.
|
|
87
|
+
"@stylistic/eslint-plugin": "^5.9.0",
|
|
88
|
+
"eslint": "^9.39.3",
|
|
87
89
|
"eslint-plugin-import": "^2.32.0",
|
|
88
90
|
"eslint-plugin-regexp": "^3.0.0",
|
|
89
91
|
"husky": "^9.1.7"
|