@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
@@ -0,0 +1,541 @@
1
+ const fs = require('fs');
2
+
3
+ async function createMagAssetsStructure(
4
+ customBasePath = 'src/shared/mag_assets'
5
+ ) {
6
+ // Create sample files for each asset type
7
+
8
+ // Sample button (fixed to use 'text' instead of 'label')
9
+ const sampleButton = `icon:
10
+ name: check
11
+ text: Submit
12
+ type: primary
13
+ size: medium
14
+ disabled: false
15
+ `;
16
+ fs.writeFileSync(`${customBasePath}/buttons/submit.yml`, sampleButton);
17
+
18
+ // Sample field
19
+ const sampleField = `type: 1
20
+ model: email
21
+ placeholder: Enter your email
22
+ validators:
23
+ - type: required
24
+ message: Email is required
25
+ - type: email
26
+ message: Please enter a valid email
27
+ `;
28
+ fs.writeFileSync(`${customBasePath}/fields/email.yml`, sampleField);
29
+
30
+ // Sample form
31
+ const sampleForm = `fields:
32
+ - email
33
+ validators: []
34
+ values: {}
35
+ isValid: []
36
+ isTouched: []
37
+ `;
38
+ fs.writeFileSync(`${customBasePath}/forms/contact.yml`, sampleForm);
39
+
40
+ // Sample button group
41
+ const sampleButtonGroup = `buttons:
42
+ - save
43
+ - cancel
44
+ layout: horizontal
45
+ spacing: medium
46
+ alignment: right
47
+ `;
48
+ fs.writeFileSync(
49
+ `${customBasePath}/button_groups/form-actions.yml`,
50
+ sampleButtonGroup
51
+ );
52
+
53
+ // Sample options (fixed format to match working example)
54
+ const sampleOptions = `- - id: low
55
+ label: Low Priority
56
+ - id: medium
57
+ label: Medium Priority
58
+ - id: high
59
+ label: High Priority
60
+ - id: urgent
61
+ label: Urgent
62
+ `;
63
+ fs.writeFileSync(
64
+ `${customBasePath}/options/sample-options.yml`,
65
+ sampleOptions
66
+ );
67
+
68
+ // Sample navigation
69
+ const sampleNav = `items:
70
+ - label: Home
71
+ route: /home
72
+ icon: home
73
+ - label: About
74
+ route: /about
75
+ icon: info
76
+ - label: Contact
77
+ route: /contact
78
+ icon: mail
79
+ layout: horizontal
80
+ position: top
81
+ `;
82
+ fs.writeFileSync(`${customBasePath}/nav/main-nav.yml`, sampleNav);
83
+
84
+ // Sample root.tml navigation template
85
+ const sampleRootTml = `<!-- Root Navigation Menu Template
86
+ This sample file shows navigation entries for each asset type supported by the CLI.
87
+ Customize this file to match your application's navigation structure. -->
88
+
89
+ <nav class="root-navigation">
90
+ <!-- Asset Type: Buttons -->
91
+ <div class="nav-section" data-asset-type="buttons">
92
+ <h3>Interactive Elements</h3>
93
+ <a href="/buttons" class="nav-item">
94
+ <i class="icon-button"></i>
95
+ <span>Buttons</span>
96
+ </a>
97
+ <a href="/button-groups" class="nav-item">
98
+ <i class="icon-group"></i>
99
+ <span>Button Groups</span>
100
+ </a>
101
+ </div>
102
+
103
+ <!-- Asset Type: Forms -->
104
+ <div class="nav-section" data-asset-type="forms">
105
+ <h3>Forms & Fields</h3>
106
+ <a href="/forms" class="nav-item">
107
+ <i class="icon-form"></i>
108
+ <span>Forms</span>
109
+ </a>
110
+ <a href="/fields" class="nav-item">
111
+ <i class="icon-field"></i>
112
+ <span>Fields</span>
113
+ </a>
114
+ <a href="/options" class="nav-item">
115
+ <i class="icon-options"></i>
116
+ <span>Options</span>
117
+ </a>
118
+ </div>
119
+
120
+ <!-- Asset Type: Components -->
121
+ <div class="nav-section" data-asset-type="components">
122
+ <h3>UI Components</h3>
123
+ <a href="/cards" class="nav-item">
124
+ <i class="icon-card"></i>
125
+ <span>Cards</span>
126
+ </a>
127
+ <a href="/modals" class="nav-item">
128
+ <i class="icon-modal"></i>
129
+ <span>Modals</span>
130
+ </a>
131
+ <a href="/tabs" class="nav-item">
132
+ <i class="icon-tabs"></i>
133
+ <span>Tabs</span>
134
+ </a>
135
+ <a href="/jumbotron" class="nav-item">
136
+ <i class="icon-jumbotron"></i>
137
+ <span>Hero Sections</span>
138
+ </a>
139
+ </div>
140
+
141
+ <!-- Asset Type: Content -->
142
+ <div class="nav-section" data-asset-type="content">
143
+ <h3>Content & Media</h3>
144
+ <a href="/icons" class="nav-item">
145
+ <i class="icon-svg"></i>
146
+ <span>Icons</span>
147
+ </a>
148
+ <a href="/images" class="nav-item">
149
+ <i class="icon-image"></i>
150
+ <span>Images</span>
151
+ </a>
152
+ <a href="/watermark" class="nav-item">
153
+ <i class="icon-watermark"></i>
154
+ <span>Watermarks</span>
155
+ </a>
156
+ </div>
157
+
158
+ <!-- Asset Type: System -->
159
+ <div class="nav-section" data-asset-type="system">
160
+ <h3>System & Config</h3>
161
+ <a href="/theme" class="nav-item">
162
+ <i class="icon-theme"></i>
163
+ <span>Themes</span>
164
+ </a>
165
+ <a href="/i18n" class="nav-item">
166
+ <i class="icon-translate"></i>
167
+ <span>Translations</span>
168
+ </a>
169
+ <a href="/pwa" class="nav-item">
170
+ <i class="icon-pwa"></i>
171
+ <span>PWA Settings</span>
172
+ </a>
173
+ <a href="/workers" class="nav-item">
174
+ <i class="icon-worker"></i>
175
+ <span>Web Workers</span>
176
+ </a>
177
+ </div>
178
+ </nav>
179
+
180
+ <!-- Navigation Styles -->
181
+ <style>
182
+ .root-navigation {
183
+ display: grid;
184
+ grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
185
+ gap: 2rem;
186
+ padding: 1rem;
187
+ }
188
+
189
+ .nav-section {
190
+ background: #f8f9fa;
191
+ border-radius: 8px;
192
+ padding: 1rem;
193
+ border: 1px solid #e9ecef;
194
+ }
195
+
196
+ .nav-section h3 {
197
+ margin: 0 0 1rem 0;
198
+ color: #495057;
199
+ font-size: 1.1rem;
200
+ font-weight: 600;
201
+ }
202
+
203
+ .nav-item {
204
+ display: flex;
205
+ align-items: center;
206
+ padding: 0.5rem;
207
+ text-decoration: none;
208
+ color: #6c757d;
209
+ border-radius: 4px;
210
+ margin-bottom: 0.25rem;
211
+ transition: all 0.2s ease;
212
+ }
213
+
214
+ .nav-item:hover {
215
+ background: #e9ecef;
216
+ color: #495057;
217
+ text-decoration: none;
218
+ }
219
+
220
+ .nav-item i {
221
+ margin-right: 0.5rem;
222
+ font-size: 1.1rem;
223
+ width: 1.2rem;
224
+ text-align: center;
225
+ }
226
+ </style>`;
227
+ fs.writeFileSync(`${customBasePath}/nav/root.tml`, sampleRootTml);
228
+
229
+ // Sample theme (TypeScript)
230
+ const sampleTheme = `import { Theme } from '@magmonium/cli';
231
+
232
+ export const theme: Theme = {
233
+ icon: 'sun',
234
+ mode: 'light',
235
+ color: {
236
+ background: '#f3f4f6',
237
+ border: '#e1e4e8',
238
+ frame: '#fafbfc',
239
+ backgroundLite: '#f8f9fa',
240
+ text: '#334955',
241
+ inverseText: '#ffffff',
242
+ textSecondary: '#666666',
243
+ textTertiary: '#888888',
244
+ textQuaternary: '#999999',
245
+ textQuinary: '#aaaaaa',
246
+ textSenary: '#bbbbbb',
247
+ textSeptenary: '#cccccc',
248
+ textOctonary: '#dddddd',
249
+ textNonary: '#eeeeee',
250
+ mm: '#7891ff',
251
+ mmLite: '#99aaff',
252
+ mmDark: '#5566cc',
253
+ focus: '#2f98fb',
254
+ error: '#EB191A',
255
+ errorLight: '#fae7fb',
256
+ warning: '#F77A02',
257
+ fade: '#A4A4A4',
258
+ toolTipBg: '#4D4F59',
259
+ toolTipCol: '#CFD1DD',
260
+ bgFocus: '#F4F4F4',
261
+ clickEffect: 'rgba(0,0,0,.01)',
262
+ successLite: '#e4f8cf',
263
+ success: '#6da82f',
264
+ header: '#517be6',
265
+ highlight: '#c8e5f9',
266
+ wealth: '#de6130',
267
+ page: '#fefaf2',
268
+ pageDark: '#f5efe6',
269
+ focusBg: 'rgba(66, 153, 225, 0.6)',
270
+ modalBackground: 'rgba(0, 0, 0, 0.8)',
271
+
272
+ // Backdrop colors for overlays and depth
273
+ backdropStandard: 'rgba(0, 0, 0, 0.2)',
274
+ backdropGlass: 'rgba(255, 255, 255, 0.3)',
275
+ backdropFrosted: 'rgba(255, 255, 255, 0.1)',
276
+ backdropTheme: 'rgba(120, 145, 255, 0.1)',
277
+ backdropBorder: 'rgba(225, 228, 232, 0.6)',
278
+ backdropFrame: 'rgba(250, 251, 252, 0.8)',
279
+ backdropOverlay: 'rgba(0, 0, 0, 0.4)',
280
+ backdropPopup: 'rgba(255, 255, 255, 0.9)',
281
+ backdropNav: 'rgba(250, 251, 252, 0.95)',
282
+ backdropSidebar: 'rgba(248, 249, 250, 0.9)',
283
+ backdropCard: 'rgba(255, 255, 255, 0.7)',
284
+ backdropSurface: 'rgba(243, 244, 246, 0.8)',
285
+ backdropMm: 'rgba(120, 145, 255, 0.1)',
286
+ backdropError: 'rgba(235, 25, 26, 0.1)',
287
+ backdropWarning: 'rgba(247, 122, 2, 0.1)',
288
+ backdropSuccess: 'rgba(109, 168, 47, 0.1)',
289
+ backdropShadow: 'rgba(0, 0, 0, 0.1)',
290
+ },
291
+ };
292
+ `;
293
+ fs.writeFileSync(`${customBasePath}/theme/default.ts`, sampleTheme);
294
+
295
+ // Sample translation
296
+ const sampleTranslation = `welcome: "Welcome"
297
+ home: "Home"
298
+ about: "About"
299
+ contact: "Contact"
300
+ submit: "Submit"
301
+ cancel: "Cancel"
302
+ `;
303
+ fs.writeFileSync(`${customBasePath}/i18n/en.yml`, sampleTranslation);
304
+
305
+ // Sample app logo (based on magmonium.svg)
306
+ const sampleLogoSvg = `<svg xmlns="http://www.w3.org/2000/svg" viewBox="-15 -15 120 165">
307
+ <!-- Top half -->
308
+ <g>
309
+ <path fill="#1976d2" style="opacity: 0.7;" d="M5 5 L5 65 L85 65 Z" />
310
+ <path fill="#1976d2" style="opacity: 0.3;" d="M85 5 L5 65 L85 65 Z" />
311
+ </g>
312
+
313
+ <!-- Bottom half - with small gap -->
314
+ <g>
315
+ <path fill="#1976d2" style="opacity: 0.3;" d="M5 70 L85 70 L5 130 Z" />
316
+ <path fill="#1976d2" style="opacity: 0.7;" d="M85 70 L5 70 L85 130 Z" />
317
+ </g>
318
+ </svg>`;
319
+ fs.writeFileSync(`${customBasePath}/logo/source.svg`, sampleLogoSvg);
320
+
321
+ // Sample worker mapping
322
+ const sampleWorkerMapping = `{
323
+ "data-processor": "src/workers/data-processor.worker.ts",
324
+ "image-resizer": "src/workers/image-resizer.worker.ts"
325
+ }`;
326
+ fs.writeFileSync(
327
+ `${customBasePath}/workers/worker-mapping.json`,
328
+ sampleWorkerMapping
329
+ );
330
+
331
+ // Sample card
332
+ const sampleCard = `title: Welcome Card
333
+ description: A sample card showing basic card structure
334
+ image: /assets/images/sample-card.jpg
335
+ icon:
336
+ name: star
337
+ color: "#FFD700"
338
+ actions:
339
+ - label: View Details
340
+ action: navigate
341
+ type: primary
342
+ - label: Share
343
+ action: share
344
+ type: secondary
345
+ link: /welcome
346
+ tags:
347
+ - featured
348
+ - welcome
349
+ priority: high
350
+ status: active
351
+ `;
352
+ fs.writeFileSync(`${customBasePath}/cards/welcome-card.yml`, sampleCard);
353
+
354
+ // Sample jumbotron
355
+ const sampleJumbotron = `title: Hero Section
356
+ subtitle: Build amazing PWAs with ease
357
+ description: A powerful CLI tool for compiling assets and building progressive web applications with modern frameworks.
358
+ backgroundImage: /assets/images/hero-bg.jpg
359
+ ctaButtons:
360
+ - label: Get Started
361
+ action: navigate
362
+ type: primary
363
+ variant: large
364
+ - label: Learn More
365
+ action: navigate
366
+ type: secondary
367
+ variant: outline
368
+ alignment: center
369
+ size: large
370
+ variant: hero
371
+ overlay:
372
+ enabled: true
373
+ color: "#000000"
374
+ opacity: 0.4
375
+ textColor: "#ffffff"
376
+ `;
377
+ fs.writeFileSync(
378
+ `${customBasePath}/jumbotron/hero-jumbotron.yml`,
379
+ sampleJumbotron
380
+ );
381
+
382
+ // Sample watermark
383
+ const sampleWatermark = `text: © 2024 Your Company
384
+ type: text
385
+ position: bottom-right
386
+ alignment: right
387
+ opacity: 0.6
388
+ size: small
389
+ color: "#666666"
390
+ fontFamily: Arial, sans-serif
391
+ fontSize: 12
392
+ fontWeight: normal
393
+ margin:
394
+ top: 0
395
+ right: 20
396
+ bottom: 20
397
+ left: 0
398
+ zIndex: 1000
399
+ variant: subtle
400
+ blend: normal
401
+ responsive:
402
+ mobile:
403
+ fontSize: 10
404
+ margin:
405
+ right: 10
406
+ bottom: 10
407
+ desktop:
408
+ fontSize: 14
409
+ `;
410
+ fs.writeFileSync(
411
+ `${customBasePath}/watermark/copyright-watermark.yml`,
412
+ sampleWatermark
413
+ );
414
+
415
+ // Sample modal
416
+ const sampleModal = `title: "Confirmation Dialog"
417
+ content: "Are you sure you want to proceed with this action?"
418
+ size: "md"
419
+ variant: "centered"
420
+ closeButton: true
421
+ backdrop: true
422
+ animation: "fade"
423
+ position: "center"
424
+ buttons:
425
+ - label: "Cancel"
426
+ action: "close"
427
+ type: "button"
428
+ variant: "secondary"
429
+ - label: "Confirm"
430
+ action: "confirm"
431
+ type: "submit"
432
+ variant: "primary"
433
+ overlay:
434
+ enabled: true
435
+ color: "#000000"
436
+ opacity: 0.5
437
+ autoClose:
438
+ enabled: false
439
+ delay: 5000
440
+ keyboard: true
441
+ focus: true
442
+ zIndex: 1050
443
+ `;
444
+ fs.writeFileSync(
445
+ `${customBasePath}/modal/confirmation-modal.yml`,
446
+ sampleModal
447
+ );
448
+
449
+ // Create sample remote configuration
450
+ const sampleRemote = `url: "https://api.example.com/data"
451
+ method: "GET"
452
+ headers:
453
+ Content-Type: "application/json"
454
+ Authorization: "Bearer token-placeholder"
455
+ timeout: 5000
456
+ retries: 3
457
+ cache: true
458
+ cacheDuration: 300
459
+ authentication:
460
+ type: "bearer"
461
+ credentials:
462
+ token: "placeholder-token"
463
+ parameters:
464
+ page: 1
465
+ limit: 20
466
+ responseType: "json"
467
+ errorHandling:
468
+ retry: true
469
+ logErrors: true
470
+ fallback:
471
+ data: []
472
+ status: "offline"
473
+ transform:
474
+ request: "requestTransform"
475
+ response: "responseTransform"
476
+ `;
477
+ fs.writeFileSync(`${customBasePath}/remote/api-config.yml`, sampleRemote);
478
+
479
+ // Create README for mag_assets
480
+ const magAssetsReadme = `# Mag Assets
481
+
482
+ This directory contains the source assets that will be compiled by the \`mag-cli\` tool.
483
+
484
+ ## Structure
485
+
486
+ - **buttons/**: Button definitions (YAML)
487
+ - **button_groups/**: Button group layouts (YAML)
488
+ - **cards/**: Card component definitions (YAML)
489
+ - **jumbotron/**: Jumbotron/hero section definitions (YAML)
490
+ - **watermark/**: Watermark and branding configurations (YAML)
491
+ - **modal/**: Modal/dialog component definitions (YAML)
492
+ - **fields/**: Form field definitions (YAML)
493
+ - **forms/**: Form configurations (YAML)
494
+ - **options/**: Option lists and select data (YAML)
495
+ - **nav/**: Navigation structures (YAML) and template files (.tml)
496
+ - **icons/**: SVG icons for compilation
497
+ - **logo/**: App logo source (SVG)
498
+ - **theme/**: Theme definitions (TypeScript)
499
+ - **i18n/**: Translation files (YAML)
500
+ - **images/**: Static images
501
+ - **workers/**: Web worker configurations (JSON)
502
+ - **remote/**: Remote API configurations and endpoints (YAML)
503
+
504
+ ## App Logo
505
+
506
+ The \`logo/\` folder contains a source SVG (any filename) that compiles into the app's icon set:
507
+ \`icon.svg\`, \`192x192.png\`, \`512x512.png\`, \`180x180.png\`, \`32x32.png\`, \`favicon.ico\`.
508
+
509
+ Replace the svg in \`logo/\` with your custom icon. The build process will automatically generate all required sizes.
510
+
511
+ ## Web Workers
512
+
513
+ The \`workers/\` folder contains a mapping file (\`worker-mapping.json\`) that defines the relationship between worker names and their TypeScript source files. The build process will compile these TypeScript worker files into minified JavaScript files in the \`assets/workers/\` directory.
514
+
515
+ Format: \`{"worker-name": "path/to/worker.ts"}\`
516
+
517
+ ## Navigation Templates
518
+
519
+ The \`navs/\` folder can contain both YAML navigation structures and HTML template files:
520
+ - **YAML files (*.yml, *.yaml)**: Navigation configuration compiled to JSON
521
+ - **Template files (*.tml)**: HTML templates for navigation components
522
+
523
+ The \`root.tml\` file is a sample navigation template that demonstrates how to organize navigation entries for each supported asset type. It includes:
524
+ - Categorized navigation sections (Interactive Elements, Forms & Fields, UI Components, etc.)
525
+ - Asset type data attributes for easy styling and scripting
526
+ - Responsive grid layout with hover effects
527
+ - Icon placeholders for each navigation item
528
+
529
+ Customize the \`root.tml\` template to match your application's design system and navigation patterns.
530
+
531
+ ## Usage
532
+
533
+ Run \`mag-cli assets\` to compile all assets from this directory to the configured output directory.
534
+ Run \`mag-cli assets --watch\` to watch for changes during development.
535
+ Run \`mag-cli build\` to compile assets + build project + create deployment zip.
536
+ Run \`mag-cli zip\` to build and create deployment zip only.
537
+ `;
538
+ fs.writeFileSync(`${customBasePath}/README.md`, magAssetsReadme);
539
+ }
540
+
541
+ module.exports = createMagAssetsStructure;
@@ -0,0 +1,120 @@
1
+ const fs = require('fs');
2
+
3
+ async function createMagCliConfig(customPaths = null) {
4
+ const defaultPaths = customPaths || {
5
+ source: 'src/shared/mag_assets',
6
+ output: 'src/shared/assets',
7
+ };
8
+
9
+ const magCliConfig = `module.exports = {
10
+ // Custom paths configuration
11
+ // Single project:
12
+ paths: {
13
+ source: "${defaultPaths.source}",
14
+ output: "${defaultPaths.output}",
15
+ },
16
+
17
+ // Multiple projects (uncomment to use):
18
+ // paths: [
19
+ // {
20
+ // source: "project1/mag_assets",
21
+ // output: "project1/public/assets",
22
+ // },
23
+ // {
24
+ // source: "project2/mag_assets",
25
+ // output: "project2/public/assets",
26
+ // }
27
+ // ],
28
+
29
+ // SVG compiler configuration
30
+ svg: {
31
+ inputPaths: ["./${defaultPaths.source}/icons"],
32
+ outputPath: "./${defaultPaths.output}",
33
+ spriteSheet: true,
34
+ optimize: true,
35
+ },
36
+
37
+ // Theme compiler configuration
38
+ theme: {
39
+ inputPaths: ["./${defaultPaths.source}/styles"],
40
+ outputPath: "./${defaultPaths.output}/styles",
41
+ format: "scss", // or "css", "json"
42
+ sassVariables: true,
43
+ },
44
+
45
+ // Translation compiler configuration
46
+ i18n: {
47
+ inputPaths: ["./${defaultPaths.source}/i18n"],
48
+ outputPath: "./${defaultPaths.output}/i18n",
49
+ defaultLocale: "en",
50
+ },
51
+
52
+ // PWA icon compiler configuration
53
+ pwa: {
54
+ inputPaths: ["./${defaultPaths.source}/pwa"],
55
+ outputPath: "./${defaultPaths.output}",
56
+ iconSizes: [72, 96, 128, 144, 152, 192, 384, 512],
57
+ outputFormat: "svg",
58
+ },
59
+
60
+ // Options compiler configuration
61
+ options: {
62
+ inputPaths: ["./${defaultPaths.source}/options"],
63
+ outputPath: "./${defaultPaths.output}/options",
64
+ },
65
+
66
+ // Field compiler configuration
67
+ fields: {
68
+ inputPaths: ["./${defaultPaths.source}/fields"],
69
+ outputPath: "./${defaultPaths.output}/fields",
70
+ },
71
+
72
+ // Button compiler configuration
73
+ buttons: {
74
+ inputPaths: ["./${defaultPaths.source}/buttons"],
75
+ outputPath: "./${defaultPaths.output}/buttons",
76
+ },
77
+
78
+ // Button group compiler configuration
79
+ buttonGroups: {
80
+ inputPaths: ["./${defaultPaths.source}/button_groups"],
81
+ outputPath: "./${defaultPaths.output}/button_groups",
82
+ },
83
+
84
+ // Form compiler configuration
85
+ forms: {
86
+ inputPaths: ["./${defaultPaths.source}/forms"],
87
+ outputPath: "./${defaultPaths.output}/forms",
88
+ validationRules: true,
89
+ generateTypes: true,
90
+ },
91
+
92
+ // Navigation compiler configuration
93
+ nav: {
94
+ inputPaths: ["./${defaultPaths.source}/navs"],
95
+ outputPath: "./${defaultPaths.output}/navs",
96
+ },
97
+
98
+ // Copy configuration for remaining files
99
+ copy: {
100
+ inputPaths: ["./${defaultPaths.source}"],
101
+ outputPath: "./${defaultPaths.output}",
102
+ preserveStructure: true,
103
+ overwrite: true,
104
+ exclude: [
105
+ "**/*.svg",
106
+ "**/*.scss",
107
+ "**/*.sass",
108
+ "**/*.css",
109
+ "**/*.json",
110
+ "**/*.yaml",
111
+ "**/*.yml",
112
+ ],
113
+ },
114
+ };
115
+ `;
116
+
117
+ fs.writeFileSync('mag-cli.config.js', magCliConfig);
118
+ }
119
+
120
+ module.exports = createMagCliConfig;