@magmonium/cli 0.7.8

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.
Files changed (204) hide show
  1. package/README.md +392 -0
  2. package/bin/README.md +244 -0
  3. package/bin/cli.js +55 -0
  4. package/bin/commands/assets-wc.js +249 -0
  5. package/bin/commands/assets.js +943 -0
  6. package/bin/commands/build.js +242 -0
  7. package/bin/commands/clean.js +621 -0
  8. package/bin/commands/compile-i18n.js +91 -0
  9. package/bin/commands/config-ci.js +266 -0
  10. package/bin/commands/configure-wc.js +167 -0
  11. package/bin/commands/connect.js +188 -0
  12. package/bin/commands/create-app.js +946 -0
  13. package/bin/commands/deploy.js +100 -0
  14. package/bin/commands/fix-i18n.js +40 -0
  15. package/bin/commands/generate.js +765 -0
  16. package/bin/commands/init/config-files.js +1114 -0
  17. package/bin/commands/init/mag-assets.js +541 -0
  18. package/bin/commands/init/mag-cli-config.js +120 -0
  19. package/bin/commands/init/monorepo-structure.js +735 -0
  20. package/bin/commands/init/package-json.js +308 -0
  21. package/bin/commands/init/project-structure.js +189 -0
  22. package/bin/commands/init/pwa-files.js +204 -0
  23. package/bin/commands/init/source-files.js +2596 -0
  24. package/bin/commands/init.js +591 -0
  25. package/bin/commands/lib.js +508 -0
  26. package/bin/commands/patch-wc-env.js +136 -0
  27. package/bin/commands/refractor.js +51 -0
  28. package/bin/commands/sanitize-i18n.js +41 -0
  29. package/bin/commands/translate.js +32 -0
  30. package/bin/commands/zip.js +540 -0
  31. package/package.json +53 -0
  32. package/src/compilers/button-group-compiler.d.ts +18 -0
  33. package/src/compilers/button-group-compiler.d.ts.map +1 -0
  34. package/src/compilers/button-group-compiler.js +151 -0
  35. package/src/compilers/button-group-compiler.js.map +1 -0
  36. package/src/compilers/copy-compiler.d.ts +14 -0
  37. package/src/compilers/copy-compiler.d.ts.map +1 -0
  38. package/src/compilers/copy-compiler.js +170 -0
  39. package/src/compilers/copy-compiler.js.map +1 -0
  40. package/src/compilers/field-compiler.d.ts +15 -0
  41. package/src/compilers/field-compiler.d.ts.map +1 -0
  42. package/src/compilers/field-compiler.js +153 -0
  43. package/src/compilers/field-compiler.js.map +1 -0
  44. package/src/compilers/form-compiler.d.ts +15 -0
  45. package/src/compilers/form-compiler.d.ts.map +1 -0
  46. package/src/compilers/form-compiler.js +220 -0
  47. package/src/compilers/form-compiler.js.map +1 -0
  48. package/src/compilers/logo-compiler.d.ts +14 -0
  49. package/src/compilers/logo-compiler.d.ts.map +1 -0
  50. package/src/compilers/logo-compiler.js +114 -0
  51. package/src/compilers/logo-compiler.js.map +1 -0
  52. package/src/compilers/options-compiler.d.ts +46 -0
  53. package/src/compilers/options-compiler.d.ts.map +1 -0
  54. package/src/compilers/options-compiler.js +329 -0
  55. package/src/compilers/options-compiler.js.map +1 -0
  56. package/src/compilers/pwa-build.d.ts +7 -0
  57. package/src/compilers/pwa-build.d.ts.map +1 -0
  58. package/src/compilers/pwa-build.js +62 -0
  59. package/src/compilers/pwa-build.js.map +1 -0
  60. package/src/compilers/svg-compiler.d.ts +12 -0
  61. package/src/compilers/svg-compiler.d.ts.map +1 -0
  62. package/src/compilers/svg-compiler.js +123 -0
  63. package/src/compilers/svg-compiler.js.map +1 -0
  64. package/src/compilers/tabs-compiler.d.ts +25 -0
  65. package/src/compilers/tabs-compiler.d.ts.map +1 -0
  66. package/src/compilers/tabs-compiler.js +422 -0
  67. package/src/compilers/tabs-compiler.js.map +1 -0
  68. package/src/compilers/theme-compiler.d.ts +14 -0
  69. package/src/compilers/theme-compiler.d.ts.map +1 -0
  70. package/src/compilers/theme-compiler.js +144 -0
  71. package/src/compilers/theme-compiler.js.map +1 -0
  72. package/src/compilers/translation-compiler.d.ts +17 -0
  73. package/src/compilers/translation-compiler.d.ts.map +1 -0
  74. package/src/compilers/translation-compiler.js +232 -0
  75. package/src/compilers/translation-compiler.js.map +1 -0
  76. package/src/compilers/web-component/index.d.ts +3 -0
  77. package/src/compilers/web-component/index.d.ts.map +1 -0
  78. package/src/compilers/web-component/index.js +6 -0
  79. package/src/compilers/web-component/index.js.map +1 -0
  80. package/src/compilers/web-component/lib/builder.d.ts +45 -0
  81. package/src/compilers/web-component/lib/builder.d.ts.map +1 -0
  82. package/src/compilers/web-component/lib/builder.js +341 -0
  83. package/src/compilers/web-component/lib/builder.js.map +1 -0
  84. package/src/compilers/web-component/lib/class-name.d.ts +4 -0
  85. package/src/compilers/web-component/lib/class-name.d.ts.map +1 -0
  86. package/src/compilers/web-component/lib/class-name.js +24 -0
  87. package/src/compilers/web-component/lib/class-name.js.map +1 -0
  88. package/src/compilers/web-component/lib/config-data.d.ts +9 -0
  89. package/src/compilers/web-component/lib/config-data.d.ts.map +1 -0
  90. package/src/compilers/web-component/lib/config-data.js +14 -0
  91. package/src/compilers/web-component/lib/config-data.js.map +1 -0
  92. package/src/compilers/web-component/lib/ng-build.d.ts +8 -0
  93. package/src/compilers/web-component/lib/ng-build.d.ts.map +1 -0
  94. package/src/compilers/web-component/lib/ng-build.js +685 -0
  95. package/src/compilers/web-component/lib/ng-build.js.map +1 -0
  96. package/src/compilers/web-component/lib/resource-inliner.d.ts +9 -0
  97. package/src/compilers/web-component/lib/resource-inliner.d.ts.map +1 -0
  98. package/src/compilers/web-component/lib/resource-inliner.js +355 -0
  99. package/src/compilers/web-component/lib/resource-inliner.js.map +1 -0
  100. package/src/compilers/web-component/lib/web-component-name.d.ts +3 -0
  101. package/src/compilers/web-component/lib/web-component-name.d.ts.map +1 -0
  102. package/src/compilers/web-component/lib/web-component-name.js +47 -0
  103. package/src/compilers/web-component/lib/web-component-name.js.map +1 -0
  104. package/src/compilers/web-component/lib/web-component-wrapper.d.ts +3 -0
  105. package/src/compilers/web-component/lib/web-component-wrapper.d.ts.map +1 -0
  106. package/src/compilers/web-component/lib/web-component-wrapper.js +335 -0
  107. package/src/compilers/web-component/lib/web-component-wrapper.js.map +1 -0
  108. package/src/compilers/web-component/model/type.d.ts +29 -0
  109. package/src/compilers/web-component/model/type.d.ts.map +1 -0
  110. package/src/compilers/web-component/model/type.js +3 -0
  111. package/src/compilers/web-component/model/type.js.map +1 -0
  112. package/src/compilers/worker-compiler.d.ts +12 -0
  113. package/src/compilers/worker-compiler.d.ts.map +1 -0
  114. package/src/compilers/worker-compiler.js +123 -0
  115. package/src/compilers/worker-compiler.js.map +1 -0
  116. package/src/compilers/yaml-compiler.d.ts +18 -0
  117. package/src/compilers/yaml-compiler.d.ts.map +1 -0
  118. package/src/compilers/yaml-compiler.js +139 -0
  119. package/src/compilers/yaml-compiler.js.map +1 -0
  120. package/src/core/base-compiler.d.ts +17 -0
  121. package/src/core/base-compiler.d.ts.map +1 -0
  122. package/src/core/base-compiler.js +78 -0
  123. package/src/core/base-compiler.js.map +1 -0
  124. package/src/core/config.d.ts +640 -0
  125. package/src/core/config.d.ts.map +1 -0
  126. package/src/core/config.js +432 -0
  127. package/src/core/config.js.map +1 -0
  128. package/src/core/file-watcher.d.ts +23 -0
  129. package/src/core/file-watcher.d.ts.map +1 -0
  130. package/src/core/file-watcher.js +63 -0
  131. package/src/core/file-watcher.js.map +1 -0
  132. package/src/index.d.ts +31 -0
  133. package/src/index.d.ts.map +1 -0
  134. package/src/index.js +34 -0
  135. package/src/index.js.map +1 -0
  136. package/src/types/asset-configs.d.ts +189 -0
  137. package/src/types/asset-configs.d.ts.map +1 -0
  138. package/src/types/asset-configs.js +7 -0
  139. package/src/types/asset-configs.js.map +1 -0
  140. package/src/types/theme.d.ts +67 -0
  141. package/src/types/theme.d.ts.map +1 -0
  142. package/src/types/theme.js +3 -0
  143. package/src/types/theme.js.map +1 -0
  144. package/src/utils/file-utils.d.ts +16 -0
  145. package/src/utils/file-utils.d.ts.map +1 -0
  146. package/src/utils/file-utils.js +58 -0
  147. package/src/utils/file-utils.js.map +1 -0
  148. package/src/utils/i18n-compile-validator.d.ts +20 -0
  149. package/src/utils/i18n-compile-validator.d.ts.map +1 -0
  150. package/src/utils/i18n-compile-validator.js +198 -0
  151. package/src/utils/i18n-compile-validator.js.map +1 -0
  152. package/src/utils/i18n-fixer.d.ts +39 -0
  153. package/src/utils/i18n-fixer.d.ts.map +1 -0
  154. package/src/utils/i18n-fixer.js +396 -0
  155. package/src/utils/i18n-fixer.js.map +1 -0
  156. package/src/utils/i18n-sanitizer.d.ts +17 -0
  157. package/src/utils/i18n-sanitizer.d.ts.map +1 -0
  158. package/src/utils/i18n-sanitizer.js +101 -0
  159. package/src/utils/i18n-sanitizer.js.map +1 -0
  160. package/src/utils/i18n-utils.d.ts +21 -0
  161. package/src/utils/i18n-utils.d.ts.map +1 -0
  162. package/src/utils/i18n-utils.js +89 -0
  163. package/src/utils/i18n-utils.js.map +1 -0
  164. package/src/utils/interactive-translator.d.ts +18 -0
  165. package/src/utils/interactive-translator.d.ts.map +1 -0
  166. package/src/utils/interactive-translator.js +401 -0
  167. package/src/utils/interactive-translator.js.map +1 -0
  168. package/src/utils/llama-cpp-translator.d.ts +33 -0
  169. package/src/utils/llama-cpp-translator.d.ts.map +1 -0
  170. package/src/utils/llama-cpp-translator.js +267 -0
  171. package/src/utils/llama-cpp-translator.js.map +1 -0
  172. package/src/utils/logger.d.ts +14 -0
  173. package/src/utils/logger.d.ts.map +1 -0
  174. package/src/utils/logger.js +42 -0
  175. package/src/utils/logger.js.map +1 -0
  176. package/src/utils/ollama-translator.d.ts +38 -0
  177. package/src/utils/ollama-translator.d.ts.map +1 -0
  178. package/src/utils/ollama-translator.js +371 -0
  179. package/src/utils/ollama-translator.js.map +1 -0
  180. package/src/utils/option-utils.d.ts +58 -0
  181. package/src/utils/option-utils.d.ts.map +1 -0
  182. package/src/utils/option-utils.js +123 -0
  183. package/src/utils/option-utils.js.map +1 -0
  184. package/src/utils/platform-utils.d.ts +33 -0
  185. package/src/utils/platform-utils.d.ts.map +1 -0
  186. package/src/utils/platform-utils.js +114 -0
  187. package/src/utils/platform-utils.js.map +1 -0
  188. package/src/utils/pwa-utils.d.ts +28 -0
  189. package/src/utils/pwa-utils.d.ts.map +1 -0
  190. package/src/utils/pwa-utils.js +48 -0
  191. package/src/utils/pwa-utils.js.map +1 -0
  192. package/src/utils/translation-manager.d.ts +43 -0
  193. package/src/utils/translation-manager.d.ts.map +1 -0
  194. package/src/utils/translation-manager.js +302 -0
  195. package/src/utils/translation-manager.js.map +1 -0
  196. package/src/utils/web-translation-providers.d.ts +53 -0
  197. package/src/utils/web-translation-providers.d.ts.map +1 -0
  198. package/src/utils/web-translation-providers.js +190 -0
  199. package/src/utils/web-translation-providers.js.map +1 -0
  200. package/src/utils/yaml-utils.d.ts +9 -0
  201. package/src/utils/yaml-utils.d.ts.map +1 -0
  202. package/src/utils/yaml-utils.js +26 -0
  203. package/src/utils/yaml-utils.js.map +1 -0
  204. package/templates/mag-compile.config.js +77 -0
package/README.md ADDED
@@ -0,0 +1,392 @@
1
+ # @magmonium/cli
2
+
3
+ A powerful and extensible asset compilation tool that can be shared across multiple projects. This tool **intelligently processes all files** in your `mag_assets/` folder - compiling when possible, copying when needed.
4
+
5
+ ## Project Structure
6
+
7
+ This tool follows a simple but powerful convention:
8
+
9
+ - **Source files** go in `mag_assets/` folders
10
+ - **Compiled files** are output to `assets/` folders
11
+ - Files are **automatically compiled** if a compiler exists, otherwise **copied directly**
12
+
13
+ ```
14
+ project/
15
+ ├── mag_assets/ # Source files (tracked in Git)
16
+ │ ├── icons/ # SVG source files → compiled to JSON
17
+ │ ├── styles/ # SCSS/CSS source files → compiled
18
+ │ ├── i18n/ # Translation source files → compiled
19
+ │ ├── images/ # Image files → copied as-is
20
+ │ ├── docs/ # Documentation → copied as-is
21
+ │ └── ... # Any other files → copied as-is
22
+ ├── assets/ # Compiled files (ignored in Git)
23
+ │ ├── icons/ # Compiled SVG assets
24
+ │ ├── styles/ # Compiled CSS/SCSS
25
+ │ ├── i18n/ # Compiled translations
26
+ │ ├── images/ # Copied images
27
+ │ ├── docs/ # Copied documentation
28
+ │ └── ... # All other copied files
29
+ └── mag-build.config.js # Build configuration (optional)
30
+ ```
31
+
32
+ ## Quick Start
33
+
34
+ ### One Command Does Everything
35
+
36
+ ```bash
37
+ # Install globally
38
+ npm install -g @magmonium/cli
39
+
40
+ # Build everything from mag_assets/ to assets/
41
+ mag-build build
42
+
43
+ # That's it! The tool will:
44
+ # ✅ Compile SVG files to JSON + sprite sheets
45
+ # ✅ Compile SCSS/CSS files to optimized CSS
46
+ # ✅ Compile translation files to flattened JSON + TypeScript definitions
47
+ # ✅ Copy all other files (images, docs, etc.) as-is
48
+ ```
49
+
50
+ ### Local Installation
51
+
52
+ ```bash
53
+ # Install as dependency
54
+ npm install @magmonium/cli
55
+
56
+ # Add to package.json
57
+ {
58
+ "scripts": {
59
+ "build": "mag-build build",
60
+ "dev": "mag-build build --watch"
61
+ }
62
+ }
63
+
64
+ # Run
65
+ npm run build
66
+ ```
67
+
68
+ ## Features
69
+
70
+ - 🚀 **One Command**: Single `build` command handles everything intelligently
71
+ - 🎨 **SVG Compilation**: Convert SVG files to JSON with sprite sheet generation
72
+ - 🎭 **Theme Compilation**: Process TypeScript/SCSS/CSS theme files into JSON and CSS formats
73
+ - 🌍 **Translation Compilation**: Handle i18n files with TypeScript definitions
74
+ - 📁 **Smart Copying**: Copy files that don't need compilation automatically
75
+ - 👀 **Watch Mode**: Real-time compilation on file changes
76
+ - 🔧 **Zero Config**: Works out of the box with sensible defaults
77
+ - 🔧 **Configurable**: Optional config file for advanced customization
78
+ - 📦 **NPM Package**: Easy installation and sharing across projects
79
+ - 🌐 **Global CLI**: Can be installed globally for system-wide access
80
+ -
81
+ -
82
+ - 📋 **Tabs Compilation**: Process tab configurations with smart navs/options reference resolution
83
+
84
+ ## CLI Commands
85
+
86
+ ```bash
87
+ # Build everything (compile + copy)
88
+ mag-build build
89
+
90
+ # Watch for changes
91
+ mag-build build --watch
92
+
93
+ # Only copy files (skip compilation)
94
+ mag-build build --copy-only
95
+ ```
96
+
97
+ ## Package.json Integration
98
+
99
+ ### Simple Setup (Recommended)
100
+
101
+ ```json
102
+ {
103
+ "scripts": {
104
+ "build": "mag-build build",
105
+ "dev": "mag-build build --watch"
106
+ }
107
+ }
108
+ ```
109
+
110
+ ### Complete Setup
111
+
112
+ ```json
113
+ {
114
+ "scripts": {
115
+ "build": "mag-build build",
116
+ "dev": "mag-build build --watch",
117
+ "copy": "mag-build build --copy-only"
118
+ }
119
+ }
120
+ ```
121
+
122
+ ## Configuration (Optional)
123
+
124
+ The tool works perfectly with **zero configuration**, but you can customize it:
125
+
126
+ ```javascript
127
+ // mag-build.config.js
128
+ module.exports = {
129
+ svg: {
130
+ inputPaths: ['./mag_assets/icons'],
131
+ outputPath: './assets',
132
+ spriteSheet: true,
133
+ optimize: true,
134
+ },
135
+ theme: {
136
+ inputPaths: ['./mag_assets/theme'],
137
+ outputPath: './assets/theme',
138
+ format: 'json',
139
+ generateCSS: true,
140
+ },
141
+ i18n: {
142
+ inputPaths: ['./mag_assets/i18n'],
143
+ outputPath: './assets/i18n',
144
+ defaultLocale: 'en',
145
+ supportedLocales: ['en', 'es', 'fr'],
146
+ },
147
+ copy: {
148
+ inputPaths: ['./mag_assets'],
149
+ outputPath: './assets',
150
+ patterns: ['**/*.png', '**/*.jpg', '**/*.pdf'], // Specific files only
151
+ exclude: ['**/*.svg', '**/*.scss', '**/*.json'], // Exclude compiled files
152
+ overwrite: true,
153
+ },
154
+ };
155
+ ```
156
+
157
+ ## How It Works
158
+
159
+ 1. **Scans** `mag_assets/` for all files
160
+ 2. **Compiles** files with matching compilers:
161
+ - `.svg` files → JSON + sprite sheets
162
+ - `.scss`, `.sass`, `.css` files → optimized CSS
163
+ - `.json`, `.yaml`, `.yml` translation files → flattened JSON + TypeScript definitions
164
+ 3. **Copies** all other files directly to `assets/`
165
+ 4. **Maintains** directory structure automatically
166
+
167
+ ## File Type Handling
168
+
169
+ | File Type | Action | Output |
170
+ | ----------------------------- | ------- | -------------------------------------------- |
171
+ | `*.svg` | Compile | JSON + sprite sheet |
172
+ | `*.ts` (in theme/) | Compile | JSON + CSS (from TypeScript themes) |
173
+ | `*.scss`, `*.sass`, `*.css` | Compile | Optimized CSS |
174
+ | `*.json`, `*.yaml` (in i18n/) | Compile | Flattened JSON + TypeScript definitions |
175
+ | `*.yaml`, `*.yml` (in tabs/) | Compile | Tab configurations with reference resolution |
176
+ | `*.yaml`, `*.yml` (in navs/) | Compile | Navigation options for tab references |
177
+ | `*.png`, `*.jpg`, `*.gif` | Copy | Unchanged |
178
+ | `*.md`, `*.txt`, `*.pdf` | Copy | Unchanged |
179
+ | All other files | Copy | Unchanged |
180
+
181
+ ## Tabs Compilation
182
+
183
+ The tabs compiler processes YAML files in the `mag_assets/tabs/` directory and generates JSON tab configurations with intelligent reference resolution.
184
+
185
+ ### Basic Tab Configuration
186
+
187
+ ```yaml
188
+ # mag_assets/tabs/main-tabs.yaml
189
+ id: main-tabs
190
+ label: Main Navigation Tabs
191
+ orientation: horizontal
192
+ variant: underline
193
+ size: md
194
+ colorScheme: blue
195
+ isLazy: true
196
+ defaultIndex: 0
197
+ tabs:
198
+ - id: home-tab
199
+ label: Home
200
+ icon:
201
+ name: home
202
+ color: blue
203
+ link: /home
204
+ description: Home page tab
205
+ - id: about-tab
206
+ label: About
207
+ icon:
208
+ name: info
209
+ color: green
210
+ link: /about
211
+ description: About page tab
212
+ ```
213
+
214
+ ### Smart Reference Resolution (navs → options fallback)
215
+
216
+ The tabs compiler intelligently resolves tab references with a **navs-first, options-fallback** strategy:
217
+
218
+ 1. **Primary**: Looks in `mag_assets/navs/` directory first
219
+ 2. **Fallback**: Falls back to `mag_assets/options/` directory if not found in navs
220
+
221
+ #### Navigation Items (navs/)
222
+
223
+ ```yaml
224
+ # mag_assets/navs/store-navs.yml
225
+ - - id: products
226
+ label: Products
227
+ icon:
228
+ name: package
229
+ color: blue
230
+ link: /store/products
231
+ description: Browse all products
232
+ - id: categories
233
+ label: Categories
234
+ icon:
235
+ name: grid
236
+ color: green
237
+ link: /store/categories
238
+ description: Product categories
239
+ ```
240
+
241
+ #### Tab Configuration with References
242
+
243
+ **File-Level Reference (Recommended):**
244
+
245
+ ```yaml
246
+ # mag_assets/tabs/store-tabs.yaml
247
+ id: store-tabs
248
+ label: Store Navigation
249
+ tabs: store # References entire store.yml file
250
+ color: mm # Additional styling properties
251
+ variant: pills
252
+ align: center
253
+ ```
254
+
255
+ **Individual References:**
256
+
257
+ ```yaml
258
+ # mag_assets/tabs/mixed-tabs.yaml
259
+ id: mixed-tabs
260
+ label: Mixed Navigation
261
+ tabs:
262
+ - '@store-navs:products' # Resolves from navs directory (primary)
263
+ - '@store-options:deals' # Falls back to options directory
264
+ - id: inline-tab
265
+ label: Custom Tab
266
+ link: /custom
267
+ ```
268
+
269
+ #### Generated Output
270
+
271
+ ```json
272
+ {
273
+ "id": "store-tabs",
274
+ "label": "Store Navigation",
275
+ "tabs": [
276
+ {
277
+ "id": "products",
278
+ "label": "Products",
279
+ "icon": { "name": "package", "color": "blue" },
280
+ "link": "/store/products",
281
+ "description": "Browse all products"
282
+ },
283
+ {
284
+ "id": "deals",
285
+ "label": "Special Deals",
286
+ "icon": { "name": "percent", "color": "red" },
287
+ "link": "/store/deals",
288
+ "description": "Limited time offers"
289
+ },
290
+ {
291
+ "id": "inline-tab",
292
+ "label": "Custom Tab",
293
+ "link": "/custom"
294
+ }
295
+ ]
296
+ }
297
+ ```
298
+
299
+ ### Reference Formats
300
+
301
+ - `tabs: filename` - References entire file from navs/ first, then options/ (file-level reference)
302
+ - `@filename:option-id` - References an option by ID from the specified file
303
+ - `@filename:0:2` - References using array indices (advanced usage)
304
+ - `filename` - References all options from the specified file
305
+
306
+ ### Configuration Properties
307
+
308
+ Tab configurations support the following properties:
309
+
310
+ ```yaml
311
+ id: string # Required: Unique identifier
312
+ label: string # Required: Display label
313
+ tabs: string | array # Required: File reference or tab array
314
+ orientation: horizontal | vertical # Optional: Tab layout
315
+ variant: default | underline | pills | enclosed | soft-rounded # Optional: Visual style
316
+ size: sm | md | lg # Optional: Size variation
317
+ colorScheme: string # Optional: Color scheme
318
+ color: string # Optional: Custom color
319
+ align: left | center | right # Optional: Alignment
320
+ isLazy: boolean # Optional: Lazy loading
321
+ defaultIndex: number # Optional: Default active tab
322
+ onChange: string # Optional: Change handler
323
+ ```
324
+
325
+ ### Directory Structure
326
+
327
+ ```
328
+ mag_assets/
329
+ ├── tabs/ # Tab configurations
330
+ │ ├── main-tabs.yaml
331
+ │ └── store-tabs.yaml
332
+ ├── navs/ # Navigation items (primary source)
333
+ │ ├── main-navs.yml
334
+ │ └── store-navs.yml
335
+ └── options/ # General options (fallback source)
336
+ ├── store-options.yml
337
+ └── form-options.yml
338
+ ```
339
+
340
+ ### Benefits
341
+
342
+ - **Simple File References**: Use `tabs: filename` for clean, simple configuration
343
+ - **Logical Separation**: Keep navigation items separate from general options
344
+ - **Smart Fallback**: Automatically falls back to options if navs don't exist
345
+ - **Backward Compatible**: Existing `@options:...` references continue to work
346
+ - **Flexible**: Supports file-level references, individual references, and inline definitions
347
+ - **Enhanced Styling**: Additional properties like `color` and `align` for custom styling
348
+
349
+ ## Using in Multiple Projects
350
+
351
+ ### Global Installation (Recommended)
352
+
353
+ ```bash
354
+ # Install once globally
355
+ npm install -g @magmonium/cli
356
+
357
+ # Use in any project
358
+ cd ~/project-a && mag-build build
359
+ cd ~/project-b && mag-build build
360
+ ```
361
+
362
+ ### Project-Specific Installation
363
+
364
+ ```bash
365
+ # Install per project
366
+ npm install @magmonium/cli
367
+
368
+ # Use with npx
369
+ npx mag-build build
370
+ ```
371
+
372
+ ## Benefits
373
+
374
+ 1. **Zero Mental Overhead**: Just run `build` and everything works
375
+ 2. **Intelligent Processing**: Compiles when possible, copies otherwise
376
+ 3. **No Configuration Required**: Works out of the box with sensible defaults
377
+ 4. **Clear Separation**: Source files (`mag_assets/`) vs generated files (`assets/`)
378
+ 5. **Version Control Friendly**: Only source files are tracked
379
+ 6. **Build Process Consistency**: Same `mag_assets/` → `assets/` workflow everywhere
380
+ 7. **Flexibility**: Handles any file type - compiles or copies as appropriate
381
+
382
+ ## Contributing
383
+
384
+ 1. Fork the repository
385
+ 2. Create a feature branch
386
+ 3. Add tests for your changes
387
+ 4. Ensure all tests pass
388
+ 5. Submit a pull request
389
+
390
+ ## License
391
+
392
+ MIT License - see LICENSE file for details.
package/bin/README.md ADDED
@@ -0,0 +1,244 @@
1
+ # CLI Structure
2
+
3
+ This directory contains the modular CLI implementation for the Magmonium CLI Tool.
4
+
5
+ ## Structure
6
+
7
+ ```
8
+ bin/
9
+ ├── cli.js # Main CLI entry point
10
+ ├── commands/ # Command modules
11
+ │ ├── build.js # Build command implementation
12
+ │ ├── translate.js # Translate command implementation
13
+ │ ├── init.js # Init command implementation
14
+ │ └── init/ # Init command helpers
15
+ │ ├── project-structure.js # Creates project directory structure
16
+ │ ├── package-json.js # Creates package.json with PWA dependencies
17
+ │ ├── config-files.js # Creates configuration files (Angular, TypeScript, Service Worker)
18
+ │ ├── source-files.js # Creates Angular source files with PWA features
19
+ │ ├── mag-assets.js # Creates sample mag_assets structure
20
+ │ ├── mag-cli-config.js # Creates mag-cli configuration
21
+ │ └── pwa-files.js # Creates PWA-specific files (icons, deployment)
22
+ └── README.md # This file
23
+ ```
24
+
25
+ ## Commands
26
+
27
+ ### `mag-cli init <project-name>`
28
+
29
+ Creates a new **Progressive Web App (PWA)** with **Module Federation** capabilities.
30
+
31
+ **Features Created:**
32
+
33
+ #### 🏗️ **Project Structure**
34
+
35
+ - Angular 19 application with TypeScript
36
+ - Module Federation with Native Federation
37
+ - Complete project scaffolding with proper directory structure
38
+
39
+ #### 📱 **PWA Features**
40
+
41
+ - **Service Worker** with caching strategies (performance & freshness)
42
+ - **Web App Manifest** for installation and native app experience
43
+ - **App Icons** (192x192, 512x512, 180x180, 32x32, favicon) - auto-generated from `mag_assets/logo/`
44
+ - **Install prompt** with custom install button
45
+ - **Offline support** with intelligent caching
46
+ - **Update notifications** when new versions are available
47
+ - **iOS and Windows meta tags** for better platform support
48
+
49
+ #### 🔧 **Development Tools**
50
+
51
+ - **Logo Compilation**: Automatic icon set generation from `mag_assets/logo/`
52
+ - **PWA Testing**: Multiple server options for testing PWA features
53
+ - `npm run serve:pwa` - HTTP server (recommended)
54
+ - `npm run serve:pwa-python` - Python fallback server
55
+ - `npm run serve:pwa-live` - Live server with auto-reload
56
+ - **Deployment**: `npm run build:deploy` - Creates production-ready zip file
57
+ - **Asset Management**: Integration with @magmonium/cli for asset compilation
58
+
59
+ #### 🎨 **Asset Management**
60
+
61
+ - **mag_assets/** structure for organized asset development
62
+ - **Automatic compilation** from mag_assets to assets
63
+ - **Logo compilation** from `mag_assets/logo/` to `assets/logo/`
64
+ - **Watch mode** for development workflow
65
+ - **Sample assets** included (buttons, forms, fields, logo)
66
+
67
+ #### 📦 **Module Federation**
68
+
69
+ - **Native Federation** configuration
70
+ - **Component exposure** setup
71
+ - **Shared dependencies** optimization
72
+ - **Micro frontend ready** architecture
73
+
74
+ #### 🚀 **Production Ready**
75
+
76
+ - **Service Worker** configuration for production caching
77
+ - **Build optimization** with budgets and tree-shaking
78
+ - **Deployment scripts** for easy server deployment
79
+ - **HTTPS-ready** configuration for PWA requirements
80
+
81
+ **Usage:**
82
+
83
+ ```bash
84
+ mag-cli init my-pwa-app
85
+ cd my-pwa-app
86
+ npm start # Development server
87
+ npm run build # Production build
88
+ npm run serve:pwa # Test PWA features
89
+ npm run build:deploy # Create deployment zip
90
+ ```
91
+
92
+ **Generated Files:**
93
+
94
+ - `src/manifest.webmanifest` - PWA manifest
95
+ - `ngsw-config.json` - Service worker configuration
96
+ - `src/app/services/pwa.service.ts` - PWA functionality service
97
+ - `mag_assets/logo/source.svg` - App logo source (Magmonium logo)
98
+ - `create-deploy-zip.js` - Deployment packaging script
99
+ - `PWA-README.md` - Comprehensive PWA documentation
100
+
101
+ ### `mag-cli assets`
102
+
103
+ Compiles assets from `mag_assets/` to `assets/` directory.
104
+
105
+ **Features:**
106
+
107
+ - SVG compilation and optimization
108
+ - Theme compilation (SCSS/CSS)
109
+ - Translation file processing
110
+ - **Logo compilation** - Generates app icon set from `mag_assets/logo/`
111
+ - Form, button, and component compilation
112
+ - **Worker compilation** - Compiles TypeScript workers to minified JavaScript
113
+ - Copy fallback for unsupported file types
114
+ - Watch mode for development
115
+ - **Custom path support** - Use `-p` option to specify custom base directory
116
+
117
+ **Options:**
118
+
119
+ - `-c, --config <path>` - Config file path (default: "./mag-cli.config.js")
120
+ - `-p, --path <path>` - Base path for mag_assets and assets directories (default: "src/shared")
121
+ - `-w, --watch` - Watch for changes
122
+ - `-v, --verbose` - Verbose output
123
+ - `--copy-only` - Only copy files, skip compilation
124
+
125
+ **Logo Compilation:**
126
+
127
+ The build command includes automatic app logo/icon generation:
128
+
129
+ - **Source**: First `.svg` (alphabetical) found in `mag_assets/logo/`
130
+ - **Output**: Generates `icon.svg`, `192x192.png`, `512x512.png`, `180x180.png`, `32x32.png`, `favicon.ico` in `assets/logo/`
131
+ - **Watch Support**: Automatically regenerates icons when source changes
132
+
133
+ **Usage:**
134
+
135
+ ```bash
136
+ # Standard usage (looks in src/shared/mag_assets)
137
+ mag-cli assets
138
+
139
+ # Custom path (looks in my-app/mag_assets, outputs to my-app/assets)
140
+ mag-cli assets -p my-app
141
+
142
+ # With watch mode for development
143
+ mag-cli assets --watch
144
+
145
+ # With custom path and watch mode
146
+ mag-cli assets -p my-app --watch
147
+
148
+ # Edit your app logo
149
+ echo '<svg>...</svg>' > mag_assets/logo/source.svg
150
+
151
+ # Generate the app icon set
152
+ mag-cli assets
153
+
154
+ # Icons are now available in assets/logo/
155
+ ls assets/logo/
156
+ # icon.svg 192x192.png 512x512.png 180x180.png 32x32.png favicon.ico
157
+
158
+ # Custom path example
159
+ mag-cli assets -p apps/frontend
160
+ # This will:
161
+ # - Look for mag_assets in: apps/frontend/mag_assets/
162
+ # - Output compiled assets to: apps/frontend/assets/
163
+ ```
164
+
165
+ ### `mag-cli translate`
166
+
167
+ Interactive translation manager for finding and adding missing translations.
168
+
169
+ **Features:**
170
+
171
+ - Scans source files for translation keys
172
+ - Interactive prompts for missing translations
173
+ - Multiple locale support
174
+ - Integration with i18n workflow
175
+
176
+ ## App Logo Workflow
177
+
178
+ 1. **Create/Edit Logo**: Place your SVG (any filename) in `mag_assets/logo/`
179
+ 2. **Build**: Run `mag-cli assets` to generate the app icon set
180
+ 3. **Output**: Icons are generated in `assets/logo/`
181
+ 4. **Integration**: Icons are referenced by the PWA manifest and app card
182
+
183
+ **Example:**
184
+
185
+ ```bash
186
+ # Replace the default icon with your custom design
187
+ cat > mag_assets/logo/source.svg << 'EOF'
188
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
189
+ <circle cx="50" cy="50" r="40" fill="#1976d2"/>
190
+ <text x="50" y="55" text-anchor="middle" fill="white" font-size="20">M</text>
191
+ </svg>
192
+ EOF
193
+
194
+ # Generate the app icon set
195
+ mag-cli assets
196
+
197
+ # Verify icons were generated
198
+ ls assets/logo/
199
+ # icon.svg 192x192.png 512x512.png 180x180.png 32x32.png favicon.ico
200
+ ```
201
+
202
+ ## Modular Design Benefits
203
+
204
+ 1. **Maintainability**: Each command is in its own module
205
+ 2. **Testability**: Individual modules can be tested separately
206
+ 3. **Extensibility**: New commands can be added easily
207
+ 4. **Reusability**: Helper modules can be shared between commands
208
+ 5. **Clarity**: Clear separation of concerns
209
+
210
+ ## File Size Comparison
211
+
212
+ The modular approach has significantly reduced file sizes:
213
+
214
+ - **Original cli.js**: ~2000+ lines
215
+ - **New cli.js**: 24 lines (96% reduction)
216
+ - **Individual modules**: 50-400 lines each
217
+ - **Total functionality**: Enhanced with PWA features
218
+
219
+ ## Asset Compilation Pipeline
220
+
221
+ The build system includes a comprehensive asset compilation pipeline:
222
+
223
+ 1. **SVG Icons** (`mag_assets/icons/` → `assets/icons/`)
224
+ 2. **Logo** (`mag_assets/logo/` → `assets/logo/`)
225
+ 3. **Themes** (`mag_assets/styles/` → `assets/styles/`)
226
+ 4. **Translations** (`mag_assets/i18n/` → `assets/i18n/`)
227
+ 5. **Forms** (`mag_assets/forms/` → `assets/forms/`)
228
+ 6. **Buttons** (`mag_assets/buttons/` → `assets/buttons/`)
229
+ 7. **Fields** (`mag_assets/fields/` → `assets/fields/`)
230
+ 8. **Options** (`mag_assets/options/` → `assets/options/`)
231
+ 9. **Navigation** (`mag_assets/navs/` → `assets/navs/`)
232
+ 10. **Copy Fallback** (remaining files)
233
+
234
+ ## PWA Integration
235
+
236
+ The init command now creates a comprehensive PWA that combines:
237
+
238
+ - **Module Federation**: For micro frontend architecture
239
+ - **PWA Capabilities**: For native app-like experience
240
+ - **Asset Management**: With @magmonium/cli integration including app logo compilation
241
+ - **Modern Development**: Angular 19, TypeScript, SCSS
242
+ - **Production Ready**: Service workers, caching, deployment tools, automatic icon generation
243
+
244
+ This creates a modern, installable web application that can be federated with other micro frontends while providing offline capabilities and native app features. The logo compiler ensures your app has properly sized icons for all devices and platforms.
package/bin/cli.js ADDED
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { Command } = require('commander');
4
+ const pkg = require('../package.json');
5
+ const assetsCommand = require('./commands/assets');
6
+ const buildCommand = require('./commands/build');
7
+ const zipCommand = require('./commands/zip');
8
+ const translateCommand = require('./commands/translate');
9
+ const initCommand = require('./commands/init');
10
+ const cleanCommand = require('./commands/clean');
11
+ const libCommand = require('./commands/lib');
12
+ const connectCommand = require('./commands/connect');
13
+ const deployCommand = require('./commands/deploy');
14
+ const configCiCommand = require('./commands/config-ci');
15
+ const configureWcCommand = require('./commands/configure-wc');
16
+ const assetsWcCommand = require('./commands/assets-wc');
17
+ const createAppCommand = require('./commands/create-app');
18
+ const refractorCommand = require('./commands/refractor');
19
+ const fixI18nCommand = require('./commands/fix-i18n');
20
+ const sanitizeI18nCommand = require('./commands/sanitize-i18n');
21
+ const compileI18nCommand = require('./commands/compile-i18n');
22
+ const generateCommand = require('./commands/generate');
23
+ const patchWcEnvCommand = require('./commands/patch-wc-env');
24
+
25
+ const program = new Command();
26
+
27
+ program
28
+ .name('mag-cli')
29
+ .description(
30
+ 'Magmonium CLI Tool - Intelligently compile or copy assets from src/shared/mag_assets to assets'
31
+ )
32
+ .version(pkg.version);
33
+
34
+ // Register commands
35
+ assetsCommand(program);
36
+ buildCommand(program);
37
+ zipCommand(program);
38
+ translateCommand(program);
39
+ initCommand(program);
40
+ cleanCommand(program);
41
+ libCommand(program);
42
+ connectCommand(program);
43
+ deployCommand(program);
44
+ configCiCommand(program);
45
+ configureWcCommand(program);
46
+ assetsWcCommand(program);
47
+ createAppCommand(program);
48
+ refractorCommand(program);
49
+ fixI18nCommand(program);
50
+ sanitizeI18nCommand(program);
51
+ compileI18nCommand(program);
52
+ generateCommand(program);
53
+ patchWcEnvCommand(program);
54
+
55
+ program.parse();