scss-variable-extractor 1.0.0 ā 1.1.0
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/bin/cli.js +10 -10
- package/package.json +4 -4
- package/src/scanner.js +5 -4
package/bin/cli.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
1
|
+
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { Command } = require('commander');
|
|
4
4
|
const chalk = require('chalk');
|
|
@@ -21,18 +21,18 @@ program
|
|
|
21
21
|
program
|
|
22
22
|
.command('analyze')
|
|
23
23
|
.description('Dry-run analysis - identifies repeated values without modifying files')
|
|
24
|
-
.
|
|
24
|
+
.argument('<src>', 'Source directory to scan')
|
|
25
25
|
.option('--threshold <number>', 'Minimum repeat count threshold', parseInt)
|
|
26
26
|
.option('--format <format>', 'Report format (table, json, markdown)', 'table')
|
|
27
27
|
.option('--config <path>', 'Path to config file')
|
|
28
|
-
.action(async (options) => {
|
|
28
|
+
.action(async (src, options) => {
|
|
29
29
|
try {
|
|
30
30
|
console.log(chalk.cyan.bold('\nš SCSS Variable Extraction Analysis\n'));
|
|
31
31
|
|
|
32
32
|
const config = loadConfig(options.config);
|
|
33
33
|
|
|
34
34
|
// Override config with command-line options
|
|
35
|
-
|
|
35
|
+
config.src = src;
|
|
36
36
|
if (options.threshold) config.threshold = options.threshold;
|
|
37
37
|
if (options.format) config.reportFormat = options.format;
|
|
38
38
|
|
|
@@ -85,18 +85,18 @@ program
|
|
|
85
85
|
program
|
|
86
86
|
.command('generate')
|
|
87
87
|
.description('Generate variables file only (does not modify existing SCSS files)')
|
|
88
|
-
.
|
|
88
|
+
.argument('<src>', 'Source directory to scan')
|
|
89
89
|
.option('--output <path>', 'Output path for variables file')
|
|
90
90
|
.option('--threshold <number>', 'Minimum repeat count threshold', parseInt)
|
|
91
91
|
.option('--config <path>', 'Path to config file')
|
|
92
|
-
.action(async (options) => {
|
|
92
|
+
.action(async (src, options) => {
|
|
93
93
|
try {
|
|
94
94
|
console.log(chalk.cyan.bold('\nš Generating SCSS Variables File\n'));
|
|
95
95
|
|
|
96
96
|
const config = loadConfig(options.config);
|
|
97
97
|
|
|
98
98
|
// Override config with command-line options
|
|
99
|
-
|
|
99
|
+
config.src = src;
|
|
100
100
|
if (options.output) config.output = options.output;
|
|
101
101
|
if (options.threshold) config.threshold = options.threshold;
|
|
102
102
|
|
|
@@ -154,18 +154,18 @@ program
|
|
|
154
154
|
program
|
|
155
155
|
.command('refactor')
|
|
156
156
|
.description('Full extraction + replacement (generates variables file and refactors SCSS files)')
|
|
157
|
-
.
|
|
157
|
+
.argument('<src>', 'Source directory to scan')
|
|
158
158
|
.option('--output <path>', 'Output path for variables file')
|
|
159
159
|
.option('--threshold <number>', 'Minimum repeat count threshold', parseInt)
|
|
160
160
|
.option('--config <path>', 'Path to config file')
|
|
161
|
-
.action(async (options) => {
|
|
161
|
+
.action(async (src, options) => {
|
|
162
162
|
try {
|
|
163
163
|
console.log(chalk.cyan.bold('\nš§ SCSS Refactoring - Full Extraction\n'));
|
|
164
164
|
|
|
165
165
|
const config = loadConfig(options.config);
|
|
166
166
|
|
|
167
167
|
// Override config with command-line options
|
|
168
|
-
|
|
168
|
+
config.src = src;
|
|
169
169
|
if (options.output) config.output = options.output;
|
|
170
170
|
if (options.threshold) config.threshold = options.threshold;
|
|
171
171
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scss-variable-extractor",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "Analyzes Angular SCSS files and extracts repeated hardcoded values into reusable variables",
|
|
5
5
|
"bin": {
|
|
6
6
|
"scss-extract": "./bin/cli.js"
|
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"main": "src/index.js",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"test": "jest",
|
|
11
|
-
"analyze": "node bin/cli.js analyze",
|
|
12
|
-
"generate": "node bin/cli.js generate",
|
|
13
|
-
"refactor": "node bin/cli.js refactor"
|
|
11
|
+
"analyze": "node bin/cli.js analyze .",
|
|
12
|
+
"generate": "node bin/cli.js generate .",
|
|
13
|
+
"refactor": "node bin/cli.js refactor ."
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"angular",
|
package/src/scanner.js
CHANGED
|
@@ -9,16 +9,17 @@ const path = require('path');
|
|
|
9
9
|
*/
|
|
10
10
|
async function scanScssFiles(srcPath, ignorePatterns = []) {
|
|
11
11
|
return new Promise((resolve, reject) => {
|
|
12
|
-
const pattern = path.join(srcPath, '**/*.scss');
|
|
12
|
+
const pattern = path.join(srcPath, '**/*.scss').replace(/\\/g, '/');
|
|
13
13
|
|
|
14
14
|
glob(pattern, {
|
|
15
|
-
ignore: ignorePatterns
|
|
16
|
-
absolute: true
|
|
15
|
+
ignore: ignorePatterns
|
|
17
16
|
}, (err, files) => {
|
|
18
17
|
if (err) {
|
|
19
18
|
reject(err);
|
|
20
19
|
} else {
|
|
21
|
-
|
|
20
|
+
// Ensure absolute paths
|
|
21
|
+
const absoluteFiles = files.map(f => path.resolve(f));
|
|
22
|
+
resolve(absoluteFiles);
|
|
22
23
|
}
|
|
23
24
|
});
|
|
24
25
|
});
|