scss-variable-extractor 1.6.4 → 1.6.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.
@@ -0,0 +1,7 @@
1
+ node_modules
2
+ coverage
3
+ dist
4
+ *.log
5
+ .git
6
+ test/fixtures
7
+ templates
@@ -0,0 +1,18 @@
1
+ {
2
+ "semi": true,
3
+ "trailingComma": "es5",
4
+ "singleQuote": true,
5
+ "printWidth": 100,
6
+ "tabWidth": 2,
7
+ "useTabs": false,
8
+ "arrowParens": "avoid",
9
+ "endOfLine": "lf",
10
+ "overrides": [
11
+ {
12
+ "files": "*.scss",
13
+ "options": {
14
+ "singleQuote": false
15
+ }
16
+ }
17
+ ]
18
+ }
@@ -1,35 +1,31 @@
1
- {
2
- "src": "./apps/subapp/src",
3
- "output": "./libs/styles/_variables.scss",
4
- "threshold": 2,
5
- "categories": {
6
- "colors": true,
7
- "spacing": true,
8
- "fontSizes": true,
9
- "fontWeights": true,
10
- "fontFamilies": true,
11
- "borderRadius": true,
12
- "shadows": true,
13
- "zIndex": true,
14
- "sizing": true,
15
- "lineHeight": true,
16
- "opacity": true,
17
- "transitions": true
18
- },
19
- "spacingScale": {
20
- "xxs": "2px",
21
- "xs": "4px",
22
- "sm": "8px",
23
- "md": "16px",
24
- "lg": "24px",
25
- "xl": "32px",
26
- "xxl": "48px"
27
- },
28
- "ignore": [
29
- "**/node_modules/**",
30
- "**/dist/**",
31
- "**/_variables.scss"
32
- ],
33
- "importStyle": "use",
34
- "reportFormat": "table"
35
- }
1
+ {
2
+ "src": "./apps/subapp/src",
3
+ "output": "./libs/styles/_variables.scss",
4
+ "threshold": 2,
5
+ "categories": {
6
+ "colors": true,
7
+ "spacing": true,
8
+ "fontSizes": true,
9
+ "fontWeights": true,
10
+ "fontFamilies": true,
11
+ "borderRadius": true,
12
+ "shadows": true,
13
+ "zIndex": true,
14
+ "sizing": true,
15
+ "lineHeight": true,
16
+ "opacity": true,
17
+ "transitions": true
18
+ },
19
+ "spacingScale": {
20
+ "xxs": "2px",
21
+ "xs": "4px",
22
+ "sm": "8px",
23
+ "md": "16px",
24
+ "lg": "24px",
25
+ "xl": "32px",
26
+ "xxl": "48px"
27
+ },
28
+ "ignore": ["**/node_modules/**", "**/dist/**", "**/_variables.scss"],
29
+ "importStyle": "use",
30
+ "reportFormat": "table"
31
+ }
@@ -0,0 +1,262 @@
1
+ # Multi-App Dependency Analysis Guide
2
+
3
+ ## Your Scenario: Cafe Library Submodule + Unified App
4
+
5
+ This guide shows how to use the new `analyze-dependencies` command for your specific setup with:
6
+
7
+ - Multiple apps (unified, customer, admin, etc.)
8
+ - Git submodule: fluffySubby library
9
+ - Apps that reference each other's styles
10
+
11
+ ## Step 1: Create Configuration File
12
+
13
+ Create `multi-app-config.json` in your workspace root:
14
+
15
+ ```json
16
+ {
17
+ "workspaceRoot": ".",
18
+ "apps": [
19
+ {
20
+ "name": "unified-app",
21
+ "path": "./apps/unified/src",
22
+ "type": "app",
23
+ "description": "Unified app that references other apps"
24
+ },
25
+ {
26
+ "name": "customer-app",
27
+ "path": "./apps/customer/src",
28
+ "type": "app",
29
+ "description": "Customer-facing app"
30
+ },
31
+ {
32
+ "name": "admin-app",
33
+ "path": "./apps/admin/src",
34
+ "type": "app",
35
+ "description": "Admin dashboard"
36
+ }
37
+ ],
38
+ "sharedLibraries": [
39
+ {
40
+ "name": "fluffySubby-lib",
41
+ "path": "./libs/fluffySubby",
42
+ "type": "library",
43
+ "isSubmodule": true,
44
+ "description": "Git submodule fluffySubby library - shared across apps"
45
+ }
46
+ ]
47
+ }
48
+ ```
49
+
50
+ ## Step 2: Run Analysis
51
+
52
+ ```bash
53
+ npx scss-extract analyze-dependencies --config multi-app-config.json
54
+ ```
55
+
56
+ ## What You'll See
57
+
58
+ ### App Overview
59
+
60
+ ```
61
+ 📱 unified-app: 45 files, 127 classes, 38 variables
62
+ 📱 customer-app: 32 files, 89 classes, 25 variables
63
+ 📱 admin-app: 28 files, 76 classes, 22 variables
64
+ 📚 fluffySubby-lib: 15 files, 54 classes, 31 variables (submodule)
65
+ ```
66
+
67
+ ### Dependencies Detected
68
+
69
+ ```
70
+ Dependencies:
71
+ Strong (explicit imports):
72
+ unified-app → fluffySubby-lib (@use) ← Unified uses fluffySubby library
73
+ customer-app → fluffySubby-lib (@use) ← Customer uses fluffySubby library
74
+ unified-app → customer-app (@use) ← ⚠️ Unified imports from customer!
75
+
76
+ Weak (shared classes):
77
+ unified-app ↔ customer-app (12 shared classes)
78
+ customer-app ↔ admin-app (8 shared classes)
79
+ ```
80
+
81
+ ### Recommendations
82
+
83
+ ```
84
+ 💡 Recommendations:
85
+
86
+ 🟡 fluffySubby-lib is a root dependency - already set up correctly as submodule ✓
87
+ 🟡 12 CSS classes shared between unified-app and customer-app - should be in fluffySubby-lib
88
+ 🟡 unified-app imports from customer-app - consider extracting shared styles to fluffySubby-lib
89
+ 🔴 Potential circular dependency if customer-app also imports from unified-app
90
+ ```
91
+
92
+ ## Step 3: Understanding the Results
93
+
94
+ ### What the Tool Tells You
95
+
96
+ **1. Which App Relies on Which:**
97
+
98
+ - ✅ fluffySubby-lib is used by unified-app and customer-app (good - it's a library)
99
+ - ⚠️ unified-app imports from customer-app (might be problematic)
100
+ - ℹ️ Shows you the dependency chain
101
+
102
+ **2. What Should Be Shared:**
103
+
104
+ - Classes used in 2+ apps → Move to fluffySubby-lib
105
+ - Variables used in 2+ apps → Move to fluffySubby-lib
106
+ - App-specific styles → Keep in app
107
+
108
+ **3. Organization Strategy:**
109
+
110
+ ```
111
+ Recommended Structure:
112
+
113
+ libs/fluffySubby/ (git submodule)
114
+ ├── styles/
115
+ │ ├── _variables.scss ← Shared variables (tool identifies these)
116
+ │ ├── _utilities.scss ← Shared classes (tool identifies these)
117
+ │ ├── _mixins.scss ← Shared mixins
118
+ │ └── index.scss ← Main export
119
+
120
+ apps/unified/
121
+ └── src/styles/
122
+ └── unified-specific.scss ← Only unified-specific styles
123
+
124
+ apps/customer/
125
+ └── src/styles/
126
+ └── customer-specific.scss ← Only customer-specific styles
127
+ ```
128
+
129
+ ## Step 4: Act on Recommendations
130
+
131
+ ### If Tool Says: "Move these classes to fluffySubby-lib"
132
+
133
+ **Classes detected in multiple apps:**
134
+
135
+ - `.btn-primary` (in unified, customer, admin)
136
+ - `.card-container` (in unified, customer)
137
+ - `.header-nav` (in all apps)
138
+
139
+ **Action:**
140
+
141
+ ```bash
142
+ # The tool tells you exactly what to move
143
+ # Create utilities file in fluffySubby-lib
144
+ touch libs/fluffySubby/styles/_utilities.scss
145
+
146
+ # Add the shared classes there
147
+ # Tool can show you which classes from the analysis
148
+ ```
149
+
150
+ ### If Tool Says: "Circular dependency detected"
151
+
152
+ **Example:** unified-app → customer-app → unified-app
153
+
154
+ **Action:**
155
+
156
+ 1. Review what unified-app needs from customer-app
157
+ 2. Extract those shared styles to fluffySubby-lib
158
+ 3. Both apps import from fluffySubby-lib instead
159
+
160
+ ## Step 5: Export Detailed Analysis (Optional)
161
+
162
+ ```bash
163
+ # Get JSON output for detailed review
164
+ npx scss-extract analyze-dependencies --config multi-app-config.json --format json > dependency-analysis.json
165
+
166
+ # Review:
167
+ # - Exact list of shared classes
168
+ # - Exact list of shared variables
169
+ # - Complete import graph
170
+ # - Step-by-step migration plan
171
+ ```
172
+
173
+ ## Common Patterns the Tool Detects
174
+
175
+ ### ✅ Good Pattern
176
+
177
+ ```
178
+ unified-app → fluffySubby-lib (submodule)
179
+ customer-app → fluffySubby-lib (submodule)
180
+ admin-app → fluffySubby-lib (submodule)
181
+ ```
182
+
183
+ **Tool says:** ✓ Good architecture, fluffySubby-lib is properly used as shared library
184
+
185
+ ### ⚠️ Warning Pattern
186
+
187
+ ```
188
+ unified-app → customer-app → styles.scss
189
+ ```
190
+
191
+ **Tool says:** ⚠️ unified-app depends on customer-app styles - extract to fluffySubby-lib
192
+
193
+ ### 🔴 Problem Pattern
194
+
195
+ ```
196
+ unified-app → customer-app
197
+ customer-app → unified-app
198
+ ```
199
+
200
+ **Tool says:** 🔴 Circular dependency - extract shared styles to fluffySubby-lib immediately
201
+
202
+ ## Real Example: Your Cafe Library
203
+
204
+ **Before Analysis:**
205
+
206
+ ```
207
+ // unified-app/styles.scss
208
+ @use '../../customer-app/src/styles/buttons'; ← Bad: app imports from app
209
+ @use '../../../libs/fluffySubby/styles' as fluffySubby; ← Good: app imports from lib
210
+ ```
211
+
212
+ **After Analysis & Refactoring:**
213
+
214
+ ```
215
+ // Move shared styles to fluffySubby-lib
216
+ libs/fluffySubby/styles/_buttons.scss
217
+
218
+ // unified-app/styles.scss
219
+ @use '../../../libs/fluffySubby/styles' as fluffySubby; ← Good: only lib imports
220
+
221
+ // customer-app/styles.scss
222
+ @use '../../../libs/fluffySubby/styles' as fluffySubby; ← Good: only lib imports
223
+ ```
224
+
225
+ ## Questions the Tool Answers
226
+
227
+ ❓ **"Where should I put this style?"**
228
+ → Tool tells you if it's used in 1 app (keep local) or 2+ apps (move to fluffySubby-lib)
229
+
230
+ ❓ **"Is my unified app correctly using the fluffySubby library?"**
231
+ → Tool shows dependency graph and highlights if it's importing from apps instead
232
+
233
+ ❓ **"What styles should be in the fluffySubby submodule vs app-specific?"**
234
+ → Tool identifies exactly which classes/variables are shared
235
+
236
+ ❓ **"Are there any circular dependencies?"**
237
+ → Tool detects and highlights them with 🔴 critical priority
238
+
239
+ ## Next Steps After Analysis
240
+
241
+ 1. **Review the recommendations** - Prioritize critical (🔴) and high (🟡) items
242
+ 2. **Move shared styles to fluffySubby-lib** - Use the tool's list of shared classes/variables
243
+ 3. **Update imports** - Change app-to-app imports to app-to-lib imports
244
+ 4. **Test** - Ensure all apps still work correctly
245
+ 5. **Commit fluffySubby-lib changes** - Update the submodule
246
+ 6. **Update apps** - Pull latest fluffySubby-lib in each app
247
+
248
+ ## Automation Coming Soon
249
+
250
+ Future versions will support:
251
+
252
+ ```bash
253
+ # Auto-migrate shared styles to library
254
+ npx scss-extract migrate-to-library --config multi-app-config.json
255
+
256
+ # Auto-update imports
257
+ npx scss-extract update-imports --config multi-app-config.json
258
+ ```
259
+
260
+ ---
261
+
262
+ **Bottom Line:** The tool analyzes your multi-app setup and tells you exactly which app relies on which, what should be shared vs app-specific, and the best way to organize everything!