@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,204 @@
1
+ const fs = require('fs');
2
+
3
+ async function createPwaFiles(projectName) {
4
+ // Create PWA README
5
+ const pwaReadme = `# PWA Configuration for ${
6
+ projectName.charAt(0).toUpperCase() + projectName.slice(1)
7
+ }
8
+
9
+ This Angular application has been configured as a Progressive Web App (PWA) with the following features:
10
+
11
+ ## PWA Features Implemented
12
+
13
+ ### 1. Service Worker
14
+
15
+ - **Caching Strategy**: Configured with both performance and freshness strategies
16
+ - **Offline Support**: App shell and assets are cached for offline use
17
+ - **Update Notifications**: Users are notified when new versions are available
18
+
19
+ ### 2. Web App Manifest
20
+
21
+ - **App Name**: "${
22
+ projectName.charAt(0).toUpperCase() + projectName.slice(1)
23
+ } App"
24
+ - **Short Name**: "${
25
+ projectName.charAt(0).toUpperCase() + projectName.slice(1)
26
+ }"
27
+ - **Theme Color**: #1976d2 (Material Blue)
28
+ - **Display Mode**: Standalone (looks like a native app)
29
+ - **Icons**: Multiple sizes (72x72 to 512x512) for different devices
30
+
31
+ ### 3. Install Prompt
32
+
33
+ - **Install Button**: Appears when the app can be installed
34
+ - **Cross-platform**: Works on desktop and mobile browsers
35
+ - **Native Feel**: App runs in standalone mode when installed
36
+
37
+ ## Testing the PWA
38
+
39
+ ### 1. Build the Application
40
+
41
+ \`\`\`bash
42
+ npm run build
43
+ \`\`\`
44
+
45
+ ### 2. Serve the Built Application
46
+
47
+ **Option 1: HTTP Server (recommended)**
48
+
49
+ \`\`\`bash
50
+ npm run serve:pwa
51
+ \`\`\`
52
+
53
+ **Option 2: Python Server (fallback)**
54
+
55
+ \`\`\`bash
56
+ npm run serve:pwa-python
57
+ \`\`\`
58
+
59
+ **Option 3: Live Server (alternative)**
60
+
61
+ \`\`\`bash
62
+ npm run serve:pwa-live
63
+ \`\`\`
64
+
65
+ This will serve the app at \`http://localhost:8080\`
66
+
67
+ ### 3. Test PWA Features
68
+
69
+ #### Install Functionality:
70
+
71
+ 1. Open the app in Chrome/Edge
72
+ 2. Look for the "📱 Install App" button in the top-right corner
73
+ 3. Click to install the app locally
74
+
75
+ #### Offline Functionality:
76
+
77
+ 1. Open the app in a browser
78
+ 2. Open Developer Tools → Network tab
79
+ 3. Check "Offline" to simulate no internet
80
+ 4. Refresh the page - it should still work
81
+
82
+ #### Service Worker:
83
+
84
+ 1. Open Developer Tools → Application tab
85
+ 2. Check "Service Workers" section to see the active worker
86
+ 3. Check "Storage" to see cached resources
87
+
88
+ ## Deployment
89
+
90
+ ### Manual Deployment
91
+
92
+ To deploy the PWA:
93
+
94
+ 1. Build the application: \`npm run build\`
95
+ 2. Upload the contents of \`dist/${projectName}/\` to your web server
96
+ 3. Ensure HTTPS is enabled (required for PWA)
97
+ 4. The app will automatically register the service worker
98
+
99
+ ### Web Server Requirements
100
+
101
+ - **HTTPS**: Required for service worker functionality
102
+ - **Content-Type**: Ensure \`.webmanifest\` files are served with correct MIME type
103
+ - **Cache Headers**: Configure appropriate caching for static assets
104
+
105
+ ## Troubleshooting
106
+
107
+ ### PWA Server Not Working
108
+
109
+ If \`npm run serve:pwa\` doesn't work:
110
+
111
+ 1. **Install http-server globally:**
112
+
113
+ \`\`\`bash
114
+ npm install -g http-server
115
+ \`\`\`
116
+
117
+ 2. **Try alternative servers:**
118
+
119
+ \`\`\`bash
120
+ # Python server (most reliable)
121
+ npm run serve:pwa-python
122
+
123
+ # Live server
124
+ npm run serve:pwa-live
125
+ \`\`\`
126
+
127
+ 3. **Check if files exist:**
128
+
129
+ \`\`\`bash
130
+ ls -la dist/${projectName}/
131
+ # Should show: manifest.webmanifest, ngsw-worker.js, etc.
132
+ \`\`\`
133
+
134
+ 4. **Rebuild if files are missing:**
135
+
136
+ \`\`\`bash
137
+ npm run build
138
+ \`\`\`
139
+
140
+ 5. **Check if server is running:**
141
+ \`\`\`bash
142
+ lsof -i :8080
143
+ curl -I http://localhost:8080
144
+ \`\`\`
145
+
146
+ ### Common Issues
147
+
148
+ - **Manifest 404**: Run \`npm run build\` again
149
+ - **Service Worker not loading**: Ensure HTTPS or localhost
150
+ - **Install button not showing**: Check browser console for errors
151
+ - **Port 8080 in use**: Kill process with \`pkill -f "http-server"\` or \`pkill -f "python3 -m http.server"\`
152
+
153
+ ## File Structure
154
+
155
+ \`\`\`
156
+ src/
157
+ ├── app/
158
+ │ ├── services/
159
+ │ │ └── pwa.service.ts # PWA service for updates and install
160
+ │ ├── app.component.ts # Updated with PWA functionality
161
+ │ ├── app.component.html # Includes install button
162
+ │ └── app.config.ts # Service worker configuration
163
+ ├── assets/
164
+ │ └── icons/ # PWA icons (72x72 to 512x512)
165
+ ├── manifest.webmanifest # PWA manifest file
166
+ └── index.html # Updated with PWA meta tags
167
+
168
+ ngsw-config.json # Service worker configuration
169
+ \`\`\`
170
+
171
+ ## Available Scripts
172
+
173
+ \`\`\`bash
174
+ # Development
175
+ npm start # Serve development version
176
+ npm run build # Build for production
177
+
178
+ # PWA Testing
179
+ npm run serve:pwa # Serve PWA with http-server
180
+ npm run serve:pwa-python # Serve PWA with Python
181
+ npm run serve:pwa-live # Serve PWA with live-server
182
+
183
+ # Asset Management (Magmonium CLI)
184
+ mag-cli assets # Compile src/shared/mag_assets to assets
185
+ mag-cli assets --watch # Watch and compile assets
186
+ mag-cli build # Full build: assets + project
187
+ mag-cli zip # Build and create deployment zip
188
+ \`\`\`
189
+
190
+ ## Module Federation + PWA
191
+
192
+ This project combines:
193
+
194
+ - **Module Federation**: For micro frontend architecture
195
+ - **PWA Capabilities**: For native app-like experience
196
+ - **Asset Management**: With @magmonium/cli tool
197
+
198
+ The result is a modern, installable web application that can be federated with other micro frontends while providing offline capabilities and native app features.
199
+ `;
200
+
201
+ fs.writeFileSync('PWA-README.md', pwaReadme);
202
+ }
203
+
204
+ module.exports = createPwaFiles;