scss-variable-extractor 1.6.5 → 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,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!
package/README.md CHANGED
@@ -16,7 +16,8 @@ A standalone, reusable CLI tool that analyzes Angular project SCSS files, identi
16
16
  🔄 **Bootstrap to Material Migration** - Converts Bootstrap classes to Angular Material MDC components and utilities
17
17
  🎨 **Theme Generation** - Creates dark/light theme structure with Material Design support
18
18
  ✨ **Auto Formatting** - Prettier integration for consistent code style
19
- 🌍 **Global Styles Preservation** - Moves ::ng-deep and !important styles to global files
19
+ 🌍 **Global Styles Preservation** - Moves ::ng-deep and !important styles to global files
20
+ 🔗 **Multi-App Dependency Analysis** - Analyzes style dependencies across apps, submodules, and libraries
20
21
 
21
22
  ## Installation
22
23
 
@@ -644,6 +645,258 @@ The formatting runs automatically before releases to ensure code quality.
644
645
 
645
646
  ---
646
647
 
648
+ ## Multi-App Dependency Analysis
649
+
650
+ Perfect for **monorepos**, **multi-repo setups**, and **projects with git submodules**. Analyzes style dependencies across multiple apps to recommend the best organization strategy.
651
+
652
+ ### Use Cases
653
+
654
+ **Ideal for:**
655
+
656
+ - ✅ Multiple apps sharing styles
657
+ - ✅ Git submodules (like a fluffySubby library used by multiple apps)
658
+ - ✅ Apps that reference other apps' styles
659
+ - ✅ Determining where to put shared styles
660
+ - ✅ Identifying circular dependencies
661
+ - ✅ Planning style library extraction
662
+
663
+ ### Command
664
+
665
+ ```bash
666
+ npx scss-extract analyze-dependencies --config multi-app.json
667
+ ```
668
+
669
+ ### Configuration File
670
+
671
+ Create a `multi-app.json` file describing your workspace:
672
+
673
+ ```json
674
+ {
675
+ "workspaceRoot": ".",
676
+ "apps": [
677
+ {
678
+ "name": "unified-app",
679
+ "path": "./apps/unified/src",
680
+ "type": "app",
681
+ "description": "Unified app that references other apps"
682
+ },
683
+ {
684
+ "name": "customer-app",
685
+ "path": "./apps/customer/src",
686
+ "type": "app"
687
+ },
688
+ {
689
+ "name": "admin-app",
690
+ "path": "./apps/admin/src",
691
+ "type": "app"
692
+ }
693
+ ],
694
+ "sharedLibraries": [
695
+ {
696
+ "name": "libs",
697
+ "path": "./libs/lib1",
698
+ "type": "library",
699
+ "isSubmodule": true,
700
+ "description": "Git submodule fluffySubby library"
701
+ }
702
+ ]
703
+ }
704
+ ```
705
+
706
+ ### What It Analyzes
707
+
708
+ **1. Cross-App Dependencies:**
709
+
710
+ - Detects which apps import styles from other apps
711
+ - Identifies apps using git submodule styles
712
+ - Finds apps referencing each other
713
+
714
+ **2. Shared Styles:**
715
+
716
+ - CSS classes used in multiple apps
717
+ - SCSS variables duplicated across apps
718
+ - Mixins defined in multiple places
719
+
720
+ **3. Dependency Graph:**
721
+
722
+ - Builds a complete dependency map
723
+ - Shows which apps depend on which
724
+ - Detects circular dependencies (âš ī¸ critical issues)
725
+
726
+ **4. Organization Recommendations:**
727
+
728
+ - Suggests creating shared style libraries
729
+ - Recommends where to put common styles
730
+ - Identifies styles to consolidate
731
+
732
+ ### Example Output
733
+
734
+ ```
735
+ 🔗 Multi-App Dependency Analysis
736
+
737
+ Apps & Libraries:
738
+ 📱 unified-app: 45 files, 127 classes, 38 variables
739
+ 📱 customer-app: 32 files, 89 classes, 25 variables
740
+ 📱 admin-app: 28 files, 76 classes, 22 variables
741
+ 📚 libs: 15 files, 54 classes, 31 variables
742
+
743
+ Dependencies:
744
+ Strong (explicit imports):
745
+ unified-app → libs (@use)
746
+ customer-app → libs (@use)
747
+ unified-app → customer-app (@use)
748
+
749
+ Weak (shared classes):
750
+ customer-app ↔ admin-app (12 shared classes)
751
+ unified-app ↔ admin-app (8 shared classes)
752
+
753
+ Shared Styles:
754
+ 23 shared CSS classes
755
+ Examples: .btn-primary, .card-container, .header-nav, .footer-links
756
+ 15 shared variables
757
+ Examples: $primary-color, $spacing-md, $border-radius
758
+
759
+ 💡 Recommendations:
760
+
761
+ 🟡 [Architecture] libs is a root dependency - consider making it a shared library
762
+ 🟡 [Shared Styles] 23 CSS classes are shared across multiple apps - move to shared library
763
+ 🟡 [Shared Styles] 15 SCSS variables are shared across multiple apps - consolidate in shared library
764
+ đŸŸĸ [Best Practices] unified-app imports Material styles directly - consider creating shared theme library
765
+
766
+ 📋 Organization Plan:
767
+
768
+ 1. Create shared library structure
769
+ Set up shared styles library with proper organization
770
+ ✓ Automated: scss-extract migrate-to-library --type variables
771
+
772
+ 2. Extract shared variables
773
+ Move shared SCSS variables to library
774
+
775
+ 3. Extract shared classes
776
+ Move shared CSS classes to library
777
+
778
+ 4. Update imports in apps
779
+ Update @use/@import statements to reference shared library
780
+
781
+ 5. Test and validate
782
+ Build all apps and verify styles work correctly
783
+ ⚠ Manual step required
784
+ ```
785
+
786
+ ### Real-World Example: Cafe Library Submodule
787
+
788
+ **Your Setup:**
789
+
790
+ - Multiple apps (unified, customer, admin)
791
+ - Git submodule: `fluffySubby` library
792
+ - Apps reference each other's styles
793
+
794
+ **Problem:** Not sure where to put shared styles
795
+
796
+ **Solution:**
797
+
798
+ ```bash
799
+ # 1. Analyze dependencies
800
+ npx scss-extract analyze-dependencies --config multi-app.json --format json > analysis.json
801
+
802
+ # 2. Review recommendations
803
+ # Tool will tell you:
804
+ # - Which apps depend on fluffySubby library
805
+ # - Which styles should be in fluffySubby vs app-specific
806
+ # - If unified-app should be a library or just uses others
807
+
808
+ # 3. Create organization based on recommendations
809
+ npx scss-extract generate-themes --output ./libs/lib1/styles
810
+
811
+ # 4. Move shared styles
812
+ # Tool identifies what's truly shared vs app-specific
813
+ ```
814
+
815
+ **Recommended Structure (based on analysis):**
816
+
817
+ ```
818
+ libs/
819
+ fluffySubby/ # Git submodule
820
+ styles/
821
+ _variables.scss # Shared variables (identified by tool)
822
+ _mixins.scss # Shared mixins
823
+ _utilities.scss # Shared utility classes
824
+ index.scss # Main export
825
+ apps/
826
+ unified/
827
+ src/
828
+ styles/
829
+ app-specific.scss # Unified-specific styles
830
+ customer/
831
+ src/
832
+ styles/
833
+ app-specific.scss # Customer-specific styles
834
+ admin/
835
+ src/
836
+ styles/
837
+ app-specific.scss # Admin-specific styles
838
+ ```
839
+
840
+ ### Advanced: Detecting App Relationships
841
+
842
+ The tool understands these patterns:
843
+
844
+ **1. App A uses Library B (git submodule):**
845
+
846
+ ```scss
847
+ // unified-app/styles.scss
848
+ @use '../../../libs/lib1/styles' as fluffySubby;
849
+ ```
850
+
851
+ ✅ **Recommendation:** Keep styles in fluffySubby library, unified-app imports them
852
+
853
+ **2. App A uses App B's styles:**
854
+
855
+ ```scss
856
+ // unified-app/styles.scss
857
+ @use '../../customer-app/styles' as customer;
858
+ ```
859
+
860
+ âš ī¸ **Warning:** Circular dependency risk
861
+
862
+ 💡 **Recommendation:** Extract shared styles to library
863
+
864
+ **3. Multiple apps share classes:**
865
+
866
+ ```scss
867
+ // customer-app
868
+ .btn-primary { ... }
869
+
870
+ // admin-app
871
+ .btn-primary { ... } // Duplicate!
872
+ ```
873
+
874
+ 💡 **Recommendation:** Move to shared library
875
+
876
+ ### Quick Start
877
+
878
+ ```bash
879
+ # 1. Create config
880
+ cat > multi-app.json << EOF
881
+ {
882
+ "apps": [
883
+ { "name": "app1", "path": "./apps/app1/src" },
884
+ { "name": "app2", "path": "./apps/app2/src" }
885
+ ],
886
+ "sharedLibraries": [
887
+ { "name": "fluffySubby", "path": "./libs/lib1", "isSubmodule": true }
888
+ ]
889
+ }
890
+ EOF
891
+
892
+ # 2. Analyze
893
+ npx scss-extract analyze-dependencies --config multi-app.json
894
+
895
+ # 3. Follow recommendations
896
+ ```
897
+
898
+ ---
899
+
647
900
  ## Configuration
648
901
 
649
902
  Create a `.scssextractrc.json` file in your project root:
@@ -931,6 +1184,21 @@ MIT License - see [LICENSE](./LICENSE) file for details
931
1184
 
932
1185
  ## Changelog
933
1186
 
1187
+ ### 1.8.0 (2026-02-12)
1188
+
1189
+ - **Added:** `analyze-dependencies` command for multi-app dependency analysis
1190
+ - **Added:** Support for analyzing monorepos and multi-repo setups
1191
+ - **Added:** Git submodule detection and analysis
1192
+ - **Added:** Cross-app style dependency detection
1193
+ - **Added:** Dependency graph visualization
1194
+ - **Added:** Circular dependency detection
1195
+ - **Added:** Shared style identification across apps
1196
+ - **Added:** Organization recommendations based on app relationships
1197
+ - **Added:** Multi-app configuration file support
1198
+ - **Improved:** Better understanding of which app relies on which
1199
+ - **Improved:** Automatic detection of shared vs app-specific styles
1200
+ - **Documented:** Comprehensive guide for fluffySubby library and unified app scenarios
1201
+
934
1202
  ### 1.7.0 (2026-02-12)
935
1203
 
936
1204
  - **Added:** `generate-themes` command for automatic dark/light theme structure generation