@adamlui/scss-to-css 1.7.0 → 1.7.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
@@ -10,7 +10,9 @@
10
10
  <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/hi#readme">हिंदी</a> |
11
11
  <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/bn#readme">বাংলা</a> |
12
12
  <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/mr#readme">मराठी</a> |
13
- <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pa#readme">ਪੰਜਾਬੀ</a>
13
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pa#readme">ਪੰਜਾਬੀ</a> |
14
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/es#readme">Español</a> |
15
+ <a href="https://github.com/adamlui/js-utils/tree/main/scss-to-css/docs/pt#readme">Português</a>
14
16
  </h6>
15
17
  </div>
16
18
 
@@ -20,11 +22,11 @@
20
22
 
21
23
  <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>
22
24
  <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>
23
- <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.0-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
25
+ <a href="https://www.npmjs.com/package/@adamlui/scss-to-css?activeTab=versions"><img height=31 src="https://img.shields.io/badge/Latest_Build-1.7.1-44cc11.svg?logo=icinga&logoColor=white&labelColor=464646&style=for-the-badge"></a>
24
26
  <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>
25
27
  <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>
26
28
 
27
- <img height=8px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
29
+ <img height=6px width="100%" src="https://github.com/adamlui/js-utils/blob/main/docs/images/aqua-separator.png">
28
30
 
29
31
  ## ⚡ Installation
30
32
 
@@ -46,6 +48,10 @@ As a **runtime dependency** (e.g. for on-the-fly compilation), from your project
46
48
  $ npm install @adamlui/scss-to-css
47
49
  ```
48
50
 
51
+ <br>
52
+
53
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
54
+
49
55
  ## 💻 Command line usage
50
56
 
51
57
  The basic **global command** is:
@@ -84,7 +90,8 @@ To use as a **package script**, in your project's `package.json`:
84
90
  ```
85
91
 
86
92
  Replace `<scss-to-css-cmd>` with `scss-to-css` + optional args. Then, `npm run build:css` can be used to run the command.
87
- <br><br>
93
+
94
+ #
88
95
 
89
96
  ### Example commands
90
97
 
@@ -113,7 +120,8 @@ $ scss-to-css input_folder output_folder
113
120
  ```
114
121
 
115
122
  **💡 Note:** Output CSS is minified unless `-M` or `--no-minify` is passed.
116
- <br><br>
123
+
124
+ #
117
125
 
118
126
  ### Command line options
119
127
 
@@ -128,11 +136,15 @@ Config options:
128
136
  -q, --quiet Suppress all logging except errors.
129
137
 
130
138
  Info commands:
131
- -h, --help Display this help screen.
139
+ -h, --help Display help screen.
132
140
  -v, --version Show version number.
133
141
  ```
134
142
 
135
- ## 🔌 API reference
143
+ <br>
144
+
145
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
146
+
147
+ ## 🔌 API usage
136
148
 
137
149
  You can also import **scss-to-css** into your app to use its API methods, both as an ECMAScript module or a CommonJS module.
138
150
 
@@ -148,6 +160,8 @@ import * as scssToCSS from '@adamlui/scss-to-css';
148
160
  const scssToCSS = require('@adamlui/scss-to-css');
149
161
  ```
150
162
 
163
+ #
164
+
151
165
  ### `compile(inputPath[, options])`
152
166
 
153
167
  Compiles SCSS found in the `inputPath` provided into CSS data.
@@ -165,11 +179,11 @@ If a **directory path** is passed, SCSS files are searched for (recursively by d
165
179
 
166
180
  ```js
167
181
  // Outputs paths to SCSS files in working directory + all nested directories
168
- const results = scssToCSS.compile('.');
169
- results.forEach(result => console.log(result.srcPath));
182
+ const compileResults = scssToCSS.compile('.');
183
+ compileResults.forEach(result => console.log(result.srcPath));
170
184
 
171
185
  // Outputs compiled CSS from 2nd SCSS file if found, or `undefined` if not found
172
- console.log(results[1].code);
186
+ console.log(compileResults[1].code);
173
187
  ```
174
188
 
175
189
  Options are boolean, passed as object properties. For example:
@@ -179,16 +193,17 @@ Options are boolean, passed as object properties. For example:
179
193
  scssToCSS.compile(inputDir, { minify: false });
180
194
  ```
181
195
 
182
- Possible parameters (and their default settings) are:
196
+ Available parameters (and their default settings) are:
183
197
 
184
- ```
185
- recursive (true) Recursively search for nested files if dir path
186
- passed.
187
- verbose (true) Show logging in console/terminal.
188
- dotFolders (false) Include dotfolders in file search.
189
- minify (true) Minify output CSS.
190
- sourceMaps (true) Generate CSS source maps.
191
- ```
198
+ Name | Desciption | Default value
199
+ -------------|---------------------------------------------------------|---------------
200
+ `recursive` | Recursively search for nested files if dir path passed. | `true`
201
+ `verbose` | Show logging in console/terminal. | `true`
202
+ `dotFolders` | Include dotfolders in file search. | `false`
203
+ `minify` | Minify output CSS. | `true`
204
+ `sourceMaps` | Generate CSS source maps. | `true`
205
+
206
+ #
192
207
 
193
208
  ### `findSCSS(searchDir[, options])`
194
209
 
@@ -201,21 +216,17 @@ Options are boolean, passed as object properties. For example:
201
216
  scssToCSS.findSCSS(searchDir, { recursive: false });
202
217
  ```
203
218
 
204
- Possible parameters (and their default settings) are:
219
+ Available parameters (and their default settings) are:
205
220
 
206
- ```
207
- recursive (true) Recursively search for nested files if dir path
208
- passed.
209
- verbose (true) Show logging in console/terminal.
210
- dotFolders (false) Include dotfolders in file search.
211
- ```
221
+ Name | Desciption | Default value
222
+ -------------|---------------------------------------------------------|---------------
223
+ `recursive` | Recursively search for nested files if dir path passed. | `true`
224
+ `verbose` | Show logging in console/terminal. | `true`
225
+ `dotFolders` | Include dotfolders in file search. | `false`
212
226
 
213
227
  <br>
214
228
 
215
- ## 💖 Support
216
-
217
- Please consider [giving a GitHub ⭐](https://github.com/adamlui/js-utils) or [funding](https://github.com/sponsors/adamlui) this project if it helped you!
218
- <br><br>
229
+ <img height=6px width="100%" src="https://raw.githubusercontent.com/adamlui/js-utils/main/docs/images/aqua-separator.png">
219
230
 
220
231
  ## 🏛️ MIT License
221
232
 
package/docs/LICENSE.md CHANGED
@@ -10,7 +10,9 @@
10
10
  <a href="hi/LICENSE.md">हिंदी</a> |
11
11
  <a href="bn/LICENSE.md">বাংলা</a> |
12
12
  <a href="mr/LICENSE.md">मराठी</a> |
13
- <a href="pa/LICENSE.md">ਪੰਜਾਬੀ</a>
13
+ <a href="pa/LICENSE.md">ਪੰਜਾਬੀ</a> |
14
+ <a href="es/LICENSE.md">Español</a> |
15
+ <a href="pt/LICENSE.md">Português</a>
14
16
  </h6>
15
17
  </div>
16
18
 
package/docs/SECURITY.md CHANGED
@@ -10,7 +10,9 @@
10
10
  <a href="hi/SECURITY.md">हिंदी</a> |
11
11
  <a href="bn/SECURITY.md">বাংলা</a> |
12
12
  <a href="mr/SECURITY.md">मराठी</a> |
13
- <a href="pa/SECURITY.md">ਪੰਜਾਬੀ</a>
13
+ <a href="pa/SECURITY.md">ਪੰਜਾਬੀ</a> |
14
+ <a href="es/SECURITY.md">Español</a> |
15
+ <a href="pt/SECURITY.md">Português</a>
14
16
  </h6>
15
17
  </div>
16
18
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adamlui/scss-to-css",
3
- "version": "1.7.0",
3
+ "version": "1.7.1",
4
4
  "description": "Recursively compile all SCSS files into minified CSS",
5
5
  "author": {
6
6
  "name": "Adam Lui",
package/scss-to-css.js CHANGED
@@ -82,46 +82,36 @@ else { // run as CLI tool
82
82
  bg = '\x1b[1;92m'; // bright green
83
83
 
84
84
  // Load FLAG settings
85
- const config = {
86
- dryRun: process.argv.some(arg => /^--?(?:n|dry-?run)$/.test(arg)),
87
- includeDotFolders: process.argv.some(arg =>
88
- /^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/.test(arg)),
89
- noSourceMaps: process.argv.some(arg =>
90
- /^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/.test(arg)),
91
- noRecursion: process.argv.some(arg =>
92
- /^--?(?:R|(?:disable|no)-?recursion|recursion=(?:false|0))$/.test(arg)),
93
- noMinify: process.argv.some(arg =>
94
- /^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/.test(arg)),
95
- quietMode: process.argv.some(arg => /^--?q(?:uiet)?(?:-?mode)?$/.test(arg))
85
+ const config = {};
86
+ const argRegex = {
87
+ 'dryRun': /^--?(?:n|dry-?run)$/,
88
+ 'includeDotFolders': /^--?(?:dd?|(?:include-?)?dot-?(?:folder|dir(?:ector(?:y|ie))?)s?=?(?:true|1)?)$/,
89
+ 'noSourceMaps': /^--?(?:S|(?:exclude|disable|no)-?so?u?rce?-?maps?|so?u?rce?-?maps?=(?:false|0))$/,
90
+ 'noRecursion': /^--?(?:R|(?:disable|no)-?recursion|recursion=(?:false|0))$/,
91
+ 'noMinify': /^--?(?:M|(?:disable|no)-?minif(?:y|ication)|minif(?:y|ication)=(?:false|0))$/,
92
+ 'quietMode': /^--?q(?:uiet)?(?:-?mode)?$/,
93
+ 'help': /^--?h(?:elp)?$/,
94
+ 'version': /^--?ve?r?s?i?o?n?$/
96
95
  };
96
+ process.argv.forEach(arg => {
97
+ if (!arg.startsWith('-')) return;
98
+ const matchedFlag = Object.keys(argRegex).find(flag => argRegex[flag].test(arg));
99
+ if (matchedFlag) config[matchedFlag] = true;
100
+ else {
101
+ console.error(`\n${br}ERROR: Arg [${ arg }] not recognized.${nc}`);
102
+ console.info(`\n${by}Valid arguments are below.${nc}`);
103
+ printHelpScreen(['configOptions', 'infoCmds']);
104
+ process.exit(1);
105
+ }});
97
106
 
98
107
  // Show HELP screen if -h or --help passed
99
- if (process.argv.some(arg => /^--?h(?:elp)?$/.test(arg))) {
100
- printHelp(`\n${by}scss-to-css [inputPath] [outputPath] [options]${nc}`);
101
- printHelp('\nPath arguments:');
102
- printHelp(' [inputPath] '
103
- + 'Path to SCSS file or directory containing SCSS files to be compiled,'
104
- + ' relative to the current working directory.');
105
- printHelp(' [outputPath] '
106
- + 'Path to file or directory where CSS + sourcemap files will be stored,'
107
- + ' relative to original file location (if not provided, css/ is used).');
108
- printHelp('\nConfig options:');
109
- printHelp(' -n, --dry-run Don\'t actually compile the file(s),'
110
- + ' just show if they will be processed.');
111
- printHelp(' -d, --include-dotfolders Include dotfolders in file search.');
112
- printHelp(' -S, --no-source-maps Prevent source maps from being generated.');
113
- printHelp(' -M, --no-minify Disable minification of output CSS.');
114
- printHelp(' -R, --no-recursion Disable recursive file searching.');
115
- printHelp(' -q, --quiet Suppress all logging except errors.');
116
- printHelp('\nInfo commands:');
117
- printHelp(' -h, --help Display this help screen.');
118
- printHelp(' -v, --version Show version number.');
108
+ if (process.argv.some(arg => argRegex.help.test(arg))) printHelpScreen();
119
109
 
120
110
  // Show VERSION number if -v or --version passed
121
- } else if (process.argv.some(arg => /^--?ve?r?s?i?o?n?$/.test(arg))) {
111
+ else if (process.argv.some(arg => argRegex.version.test(arg)))
122
112
  console.info('v' + require('./package.json').version);
123
113
 
124
- } else { // run MAIN routine
114
+ else { // run MAIN routine
125
115
 
126
116
  // Init I/O args
127
117
  const [inputArg = '', outputArg = ''] = ( // default to empty strings for error-less handling
@@ -199,7 +189,7 @@ else { // run as CLI tool
199
189
 
200
190
  // Define LOGGING functions
201
191
 
202
- function printHelp(msg) { // wrap msg + indent 2nd+ lines (for --help screen)
192
+ function printHelpMsg(msg) { // wrap msg + indent 2nd+ lines (for --help screen)
203
193
  const terminalWidth = process.stdout.columns || 80,
204
194
  indentation = 30, lines = [], words = msg.match(/\S+|\s+/g);
205
195
 
@@ -222,5 +212,39 @@ else { // run as CLI tool
222
212
  ));
223
213
  }
224
214
 
215
+ function printHelpScreen(includeSections = ['cmdFormat', 'pathArgs', 'configOptions', 'infoCmds']) {
216
+ const sections = {
217
+ 'cmdFormat': [
218
+ `\n${by}scss-to-css [inputPath] [outputPath] [options]${nc}`
219
+ ],
220
+ 'pathArgs': [
221
+ '\nPath arguments:',
222
+ ' [inputPath] '
223
+ + 'Path to SCSS file or directory containing SCSS files to be compiled,'
224
+ + ' relative to the current working directory.',
225
+ ' [outputPath] '
226
+ + 'Path to file or directory where CSS + sourcemap files will be stored,'
227
+ + ' relative to original file location (if not provided, css/ is used).'
228
+ ],
229
+ 'configOptions': [
230
+ '\nConfig options:',
231
+ ' -n, --dry-run Don\'t actually compile the file(s),'
232
+ + ' just show if they will be processed.',
233
+ ' -d, --include-dotfolders Include dotfolders in file search.',
234
+ ' -S, --no-source-maps Prevent source maps from being generated.',
235
+ ' -M, --no-minify Disable minification of output CSS.',
236
+ ' -R, --no-recursion Disable recursive file searching.',
237
+ ' -q, --quiet Suppress all logging except errors.'
238
+ ],
239
+ 'infoCmds': [
240
+ '\nInfo commands:',
241
+ ' -h, --help Display help screen.',
242
+ ' -v, --version Show version number.'
243
+ ]
244
+ };
245
+ includeSections.forEach(section => { // print valid arg elems
246
+ if (sections[section]) sections[section].forEach(line => printHelpMsg(line)); });
247
+ }
248
+
225
249
  function printIfNotQuiet(msg) { if (!config.quietMode) console.info(msg); }
226
250
  }