@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.
- package/README.md +392 -0
- package/bin/README.md +244 -0
- package/bin/cli.js +55 -0
- package/bin/commands/assets-wc.js +249 -0
- package/bin/commands/assets.js +943 -0
- package/bin/commands/build.js +242 -0
- package/bin/commands/clean.js +621 -0
- package/bin/commands/compile-i18n.js +91 -0
- package/bin/commands/config-ci.js +266 -0
- package/bin/commands/configure-wc.js +167 -0
- package/bin/commands/connect.js +188 -0
- package/bin/commands/create-app.js +946 -0
- package/bin/commands/deploy.js +100 -0
- package/bin/commands/fix-i18n.js +40 -0
- package/bin/commands/generate.js +765 -0
- package/bin/commands/init/config-files.js +1114 -0
- package/bin/commands/init/mag-assets.js +541 -0
- package/bin/commands/init/mag-cli-config.js +120 -0
- package/bin/commands/init/monorepo-structure.js +735 -0
- package/bin/commands/init/package-json.js +308 -0
- package/bin/commands/init/project-structure.js +189 -0
- package/bin/commands/init/pwa-files.js +204 -0
- package/bin/commands/init/source-files.js +2596 -0
- package/bin/commands/init.js +591 -0
- package/bin/commands/lib.js +508 -0
- package/bin/commands/patch-wc-env.js +136 -0
- package/bin/commands/refractor.js +51 -0
- package/bin/commands/sanitize-i18n.js +41 -0
- package/bin/commands/translate.js +32 -0
- package/bin/commands/zip.js +540 -0
- package/package.json +53 -0
- package/src/compilers/button-group-compiler.d.ts +18 -0
- package/src/compilers/button-group-compiler.d.ts.map +1 -0
- package/src/compilers/button-group-compiler.js +151 -0
- package/src/compilers/button-group-compiler.js.map +1 -0
- package/src/compilers/copy-compiler.d.ts +14 -0
- package/src/compilers/copy-compiler.d.ts.map +1 -0
- package/src/compilers/copy-compiler.js +170 -0
- package/src/compilers/copy-compiler.js.map +1 -0
- package/src/compilers/field-compiler.d.ts +15 -0
- package/src/compilers/field-compiler.d.ts.map +1 -0
- package/src/compilers/field-compiler.js +153 -0
- package/src/compilers/field-compiler.js.map +1 -0
- package/src/compilers/form-compiler.d.ts +15 -0
- package/src/compilers/form-compiler.d.ts.map +1 -0
- package/src/compilers/form-compiler.js +220 -0
- package/src/compilers/form-compiler.js.map +1 -0
- package/src/compilers/logo-compiler.d.ts +14 -0
- package/src/compilers/logo-compiler.d.ts.map +1 -0
- package/src/compilers/logo-compiler.js +114 -0
- package/src/compilers/logo-compiler.js.map +1 -0
- package/src/compilers/options-compiler.d.ts +46 -0
- package/src/compilers/options-compiler.d.ts.map +1 -0
- package/src/compilers/options-compiler.js +329 -0
- package/src/compilers/options-compiler.js.map +1 -0
- package/src/compilers/pwa-build.d.ts +7 -0
- package/src/compilers/pwa-build.d.ts.map +1 -0
- package/src/compilers/pwa-build.js +62 -0
- package/src/compilers/pwa-build.js.map +1 -0
- package/src/compilers/svg-compiler.d.ts +12 -0
- package/src/compilers/svg-compiler.d.ts.map +1 -0
- package/src/compilers/svg-compiler.js +123 -0
- package/src/compilers/svg-compiler.js.map +1 -0
- package/src/compilers/tabs-compiler.d.ts +25 -0
- package/src/compilers/tabs-compiler.d.ts.map +1 -0
- package/src/compilers/tabs-compiler.js +422 -0
- package/src/compilers/tabs-compiler.js.map +1 -0
- package/src/compilers/theme-compiler.d.ts +14 -0
- package/src/compilers/theme-compiler.d.ts.map +1 -0
- package/src/compilers/theme-compiler.js +144 -0
- package/src/compilers/theme-compiler.js.map +1 -0
- package/src/compilers/translation-compiler.d.ts +17 -0
- package/src/compilers/translation-compiler.d.ts.map +1 -0
- package/src/compilers/translation-compiler.js +232 -0
- package/src/compilers/translation-compiler.js.map +1 -0
- package/src/compilers/web-component/index.d.ts +3 -0
- package/src/compilers/web-component/index.d.ts.map +1 -0
- package/src/compilers/web-component/index.js +6 -0
- package/src/compilers/web-component/index.js.map +1 -0
- package/src/compilers/web-component/lib/builder.d.ts +45 -0
- package/src/compilers/web-component/lib/builder.d.ts.map +1 -0
- package/src/compilers/web-component/lib/builder.js +341 -0
- package/src/compilers/web-component/lib/builder.js.map +1 -0
- package/src/compilers/web-component/lib/class-name.d.ts +4 -0
- package/src/compilers/web-component/lib/class-name.d.ts.map +1 -0
- package/src/compilers/web-component/lib/class-name.js +24 -0
- package/src/compilers/web-component/lib/class-name.js.map +1 -0
- package/src/compilers/web-component/lib/config-data.d.ts +9 -0
- package/src/compilers/web-component/lib/config-data.d.ts.map +1 -0
- package/src/compilers/web-component/lib/config-data.js +14 -0
- package/src/compilers/web-component/lib/config-data.js.map +1 -0
- package/src/compilers/web-component/lib/ng-build.d.ts +8 -0
- package/src/compilers/web-component/lib/ng-build.d.ts.map +1 -0
- package/src/compilers/web-component/lib/ng-build.js +685 -0
- package/src/compilers/web-component/lib/ng-build.js.map +1 -0
- package/src/compilers/web-component/lib/resource-inliner.d.ts +9 -0
- package/src/compilers/web-component/lib/resource-inliner.d.ts.map +1 -0
- package/src/compilers/web-component/lib/resource-inliner.js +355 -0
- package/src/compilers/web-component/lib/resource-inliner.js.map +1 -0
- package/src/compilers/web-component/lib/web-component-name.d.ts +3 -0
- package/src/compilers/web-component/lib/web-component-name.d.ts.map +1 -0
- package/src/compilers/web-component/lib/web-component-name.js +47 -0
- package/src/compilers/web-component/lib/web-component-name.js.map +1 -0
- package/src/compilers/web-component/lib/web-component-wrapper.d.ts +3 -0
- package/src/compilers/web-component/lib/web-component-wrapper.d.ts.map +1 -0
- package/src/compilers/web-component/lib/web-component-wrapper.js +335 -0
- package/src/compilers/web-component/lib/web-component-wrapper.js.map +1 -0
- package/src/compilers/web-component/model/type.d.ts +29 -0
- package/src/compilers/web-component/model/type.d.ts.map +1 -0
- package/src/compilers/web-component/model/type.js +3 -0
- package/src/compilers/web-component/model/type.js.map +1 -0
- package/src/compilers/worker-compiler.d.ts +12 -0
- package/src/compilers/worker-compiler.d.ts.map +1 -0
- package/src/compilers/worker-compiler.js +123 -0
- package/src/compilers/worker-compiler.js.map +1 -0
- package/src/compilers/yaml-compiler.d.ts +18 -0
- package/src/compilers/yaml-compiler.d.ts.map +1 -0
- package/src/compilers/yaml-compiler.js +139 -0
- package/src/compilers/yaml-compiler.js.map +1 -0
- package/src/core/base-compiler.d.ts +17 -0
- package/src/core/base-compiler.d.ts.map +1 -0
- package/src/core/base-compiler.js +78 -0
- package/src/core/base-compiler.js.map +1 -0
- package/src/core/config.d.ts +640 -0
- package/src/core/config.d.ts.map +1 -0
- package/src/core/config.js +432 -0
- package/src/core/config.js.map +1 -0
- package/src/core/file-watcher.d.ts +23 -0
- package/src/core/file-watcher.d.ts.map +1 -0
- package/src/core/file-watcher.js +63 -0
- package/src/core/file-watcher.js.map +1 -0
- package/src/index.d.ts +31 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.js +34 -0
- package/src/index.js.map +1 -0
- package/src/types/asset-configs.d.ts +189 -0
- package/src/types/asset-configs.d.ts.map +1 -0
- package/src/types/asset-configs.js +7 -0
- package/src/types/asset-configs.js.map +1 -0
- package/src/types/theme.d.ts +67 -0
- package/src/types/theme.d.ts.map +1 -0
- package/src/types/theme.js +3 -0
- package/src/types/theme.js.map +1 -0
- package/src/utils/file-utils.d.ts +16 -0
- package/src/utils/file-utils.d.ts.map +1 -0
- package/src/utils/file-utils.js +58 -0
- package/src/utils/file-utils.js.map +1 -0
- package/src/utils/i18n-compile-validator.d.ts +20 -0
- package/src/utils/i18n-compile-validator.d.ts.map +1 -0
- package/src/utils/i18n-compile-validator.js +198 -0
- package/src/utils/i18n-compile-validator.js.map +1 -0
- package/src/utils/i18n-fixer.d.ts +39 -0
- package/src/utils/i18n-fixer.d.ts.map +1 -0
- package/src/utils/i18n-fixer.js +396 -0
- package/src/utils/i18n-fixer.js.map +1 -0
- package/src/utils/i18n-sanitizer.d.ts +17 -0
- package/src/utils/i18n-sanitizer.d.ts.map +1 -0
- package/src/utils/i18n-sanitizer.js +101 -0
- package/src/utils/i18n-sanitizer.js.map +1 -0
- package/src/utils/i18n-utils.d.ts +21 -0
- package/src/utils/i18n-utils.d.ts.map +1 -0
- package/src/utils/i18n-utils.js +89 -0
- package/src/utils/i18n-utils.js.map +1 -0
- package/src/utils/interactive-translator.d.ts +18 -0
- package/src/utils/interactive-translator.d.ts.map +1 -0
- package/src/utils/interactive-translator.js +401 -0
- package/src/utils/interactive-translator.js.map +1 -0
- package/src/utils/llama-cpp-translator.d.ts +33 -0
- package/src/utils/llama-cpp-translator.d.ts.map +1 -0
- package/src/utils/llama-cpp-translator.js +267 -0
- package/src/utils/llama-cpp-translator.js.map +1 -0
- package/src/utils/logger.d.ts +14 -0
- package/src/utils/logger.d.ts.map +1 -0
- package/src/utils/logger.js +42 -0
- package/src/utils/logger.js.map +1 -0
- package/src/utils/ollama-translator.d.ts +38 -0
- package/src/utils/ollama-translator.d.ts.map +1 -0
- package/src/utils/ollama-translator.js +371 -0
- package/src/utils/ollama-translator.js.map +1 -0
- package/src/utils/option-utils.d.ts +58 -0
- package/src/utils/option-utils.d.ts.map +1 -0
- package/src/utils/option-utils.js +123 -0
- package/src/utils/option-utils.js.map +1 -0
- package/src/utils/platform-utils.d.ts +33 -0
- package/src/utils/platform-utils.d.ts.map +1 -0
- package/src/utils/platform-utils.js +114 -0
- package/src/utils/platform-utils.js.map +1 -0
- package/src/utils/pwa-utils.d.ts +28 -0
- package/src/utils/pwa-utils.d.ts.map +1 -0
- package/src/utils/pwa-utils.js +48 -0
- package/src/utils/pwa-utils.js.map +1 -0
- package/src/utils/translation-manager.d.ts +43 -0
- package/src/utils/translation-manager.d.ts.map +1 -0
- package/src/utils/translation-manager.js +302 -0
- package/src/utils/translation-manager.js.map +1 -0
- package/src/utils/web-translation-providers.d.ts +53 -0
- package/src/utils/web-translation-providers.d.ts.map +1 -0
- package/src/utils/web-translation-providers.js +190 -0
- package/src/utils/web-translation-providers.js.map +1 -0
- package/src/utils/yaml-utils.d.ts +9 -0
- package/src/utils/yaml-utils.d.ts.map +1 -0
- package/src/utils/yaml-utils.js +26 -0
- package/src/utils/yaml-utils.js.map +1 -0
- 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;
|