@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,1114 @@
1
+ const fs = require('fs');
2
+
3
+ async function createConfigFiles(
4
+ projectName,
5
+ isMonorepoApp = false,
6
+ technology = 'angular',
7
+ companyName = null
8
+ ) {
9
+ if (technology === 'react') {
10
+ await createReactConfigFiles(projectName, isMonorepoApp, companyName);
11
+ } else {
12
+ await createAngularConfigFiles(projectName, isMonorepoApp, companyName);
13
+ }
14
+ }
15
+
16
+ async function createAngularConfigFiles(
17
+ projectName,
18
+ isMonorepoApp,
19
+ companyName = null
20
+ ) {
21
+ // Angular configuration
22
+ const angularJson = {
23
+ $schema: './node_modules/@angular/cli/lib/config/schema.json',
24
+ version: 1,
25
+ newProjectRoot: 'projects',
26
+ projects: {
27
+ [projectName]: {
28
+ projectType: 'application',
29
+ schematics: {
30
+ '@schematics/angular:component': {
31
+ style: 'scss',
32
+ },
33
+ },
34
+ root: '',
35
+ sourceRoot: 'src',
36
+ prefix: 'app',
37
+ architect: {
38
+ build: {
39
+ builder: '@angular-architects/native-federation:build',
40
+ options: {},
41
+ configurations: {
42
+ production: {
43
+ target: `${projectName}:esbuild:production`,
44
+ },
45
+ development: {
46
+ target: `${projectName}:esbuild:development`,
47
+ dev: true,
48
+ },
49
+ },
50
+ defaultConfiguration: 'production',
51
+ },
52
+ serve: {
53
+ builder: '@angular-architects/native-federation:build',
54
+ options: {
55
+ target: `${projectName}:serve-original:development`,
56
+ rebuildDelay: 0,
57
+ dev: true,
58
+ port: 0,
59
+ },
60
+ },
61
+ 'extract-i18n': {
62
+ builder: '@angular-devkit/build-angular:extract-i18n',
63
+ options: {
64
+ buildTarget: `${projectName}:build`,
65
+ },
66
+ },
67
+ test: {
68
+ builder: '@angular-devkit/build-angular:karma',
69
+ options: {
70
+ polyfills: ['zone.js', 'zone.js/testing'],
71
+ tsConfig: 'tsconfig.spec.json',
72
+ inlineStyleLanguage: 'scss',
73
+ assets: [
74
+ { glob: '**/*', input: 'public' },
75
+ {
76
+ glob: '**/*',
77
+ input: 'src/shared/assets',
78
+ output: 'assets',
79
+ },
80
+ ],
81
+ styles: ['src/styles.scss'],
82
+ scripts: [],
83
+ },
84
+ },
85
+ esbuild: {
86
+ builder: '@angular-devkit/build-angular:application',
87
+ options: {
88
+ outputPath:
89
+ companyName && isMonorepoApp
90
+ ? `../../dist/${companyName}/${projectName}`
91
+ : isMonorepoApp
92
+ ? `../../dist/${projectName}`
93
+ : `dist/${projectName}`,
94
+ index: 'src/index.html',
95
+ browser: 'src/bootstrap.ts',
96
+ polyfills: ['zone.js', 'es-module-shims'],
97
+ tsConfig: 'tsconfig.app.json',
98
+ inlineStyleLanguage: 'scss',
99
+ assets: [
100
+ { glob: '**/*', input: 'public' },
101
+ {
102
+ glob: '**/*',
103
+ input: 'src/shared/assets',
104
+ output: 'assets',
105
+ },
106
+ { glob: 'manifest.webmanifest', input: 'src', output: '/' },
107
+ ],
108
+ styles: ['src/styles.scss'],
109
+ scripts: [],
110
+ },
111
+ configurations: {
112
+ production: {
113
+ serviceWorker: 'ngsw-config.json',
114
+ budgets: [
115
+ {
116
+ type: 'initial',
117
+ maximumWarning: '500kB',
118
+ maximumError: '1MB',
119
+ },
120
+ {
121
+ type: 'anyComponentStyle',
122
+ maximumWarning: '4kB',
123
+ maximumError: '8kB',
124
+ },
125
+ ],
126
+ outputHashing: 'all',
127
+ },
128
+ development: {
129
+ optimization: false,
130
+ extractLicenses: false,
131
+ sourceMap: true,
132
+ },
133
+ },
134
+ defaultConfiguration: 'production',
135
+ },
136
+ 'serve-original': {
137
+ builder: '@angular-devkit/build-angular:dev-server',
138
+ configurations: {
139
+ production: {
140
+ buildTarget: `${projectName}:esbuild:production`,
141
+ },
142
+ development: {
143
+ buildTarget: `${projectName}:esbuild:development`,
144
+ },
145
+ },
146
+ defaultConfiguration: 'development',
147
+ options: {
148
+ port: 4200,
149
+ },
150
+ },
151
+ },
152
+ },
153
+ },
154
+ };
155
+
156
+ fs.writeFileSync('angular.json', JSON.stringify(angularJson, null, 2));
157
+
158
+ // Service Worker configuration
159
+ const ngswConfig = {
160
+ $schema: './node_modules/@angular/service-worker/config/schema.json',
161
+ index: '/index.html',
162
+ assetGroups: [
163
+ {
164
+ name: 'app',
165
+ installMode: 'prefetch',
166
+ resources: {
167
+ files: [
168
+ '/favicon.ico',
169
+ '/index.html',
170
+ '/manifest.webmanifest',
171
+ '/*.css',
172
+ '/*.js',
173
+ ],
174
+ },
175
+ },
176
+ {
177
+ name: 'assets',
178
+ installMode: 'lazy',
179
+ updateMode: 'prefetch',
180
+ resources: {
181
+ files: [
182
+ '/assets/**',
183
+ '/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)',
184
+ ],
185
+ },
186
+ },
187
+ ],
188
+ dataGroups: [
189
+ {
190
+ name: 'api-performance',
191
+ urls: ['/api/**'],
192
+ cacheConfig: {
193
+ strategy: 'performance',
194
+ maxSize: 100,
195
+ maxAge: '3d',
196
+ },
197
+ },
198
+ {
199
+ name: 'api-freshness',
200
+ urls: ['/api/**'],
201
+ cacheConfig: {
202
+ strategy: 'freshness',
203
+ maxSize: 100,
204
+ maxAge: '1h',
205
+ timeout: '10s',
206
+ },
207
+ },
208
+ ],
209
+ };
210
+
211
+ fs.writeFileSync('ngsw-config.json', JSON.stringify(ngswConfig, null, 2));
212
+
213
+ // Module Federation configuration
214
+ let federationConfig;
215
+
216
+ if (isMonorepoApp) {
217
+ // Monorepo: expose MainComponent from web component
218
+ federationConfig = `const {
219
+ withNativeFederation,
220
+ shareAll,
221
+ } = require("@angular-architects/native-federation/config");
222
+
223
+ module.exports = withNativeFederation({
224
+ name: "${projectName}",
225
+
226
+ exposes: {
227
+ "./MainComponent": "./src/web/main/main.web-component.ts",
228
+ },
229
+
230
+ shared: {
231
+ ...shareAll({
232
+ singleton: true,
233
+ strictVersion: true,
234
+ requiredVersion: "auto",
235
+ }),
236
+ },
237
+
238
+ skip: [
239
+ "rxjs/ajax",
240
+ "rxjs/fetch",
241
+ "rxjs/testing",
242
+ "rxjs/webSocket",
243
+ // Add further packages you don't need at runtime
244
+ ],
245
+
246
+ // Please read our FAQ about sharing libs:
247
+ // https://shorturl.at/jmzH0
248
+ });
249
+ `;
250
+ } else {
251
+ // Standalone: expose app component
252
+ federationConfig = `const { withNativeFederation, shareAll } = require('@angular-architects/native-federation/config');
253
+
254
+ module.exports = withNativeFederation({
255
+
256
+ name: '${projectName}',
257
+
258
+ exposes: {
259
+ './Component': './src/app/app.component.ts',
260
+ },
261
+
262
+ shared: {
263
+ ...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
264
+ },
265
+
266
+ skip: [
267
+ 'rxjs/ajax',
268
+ 'rxjs/fetch',
269
+ 'rxjs/testing',
270
+ 'rxjs/webSocket',
271
+ // Add further packages you don't need at runtime
272
+ ]
273
+
274
+ // Please read our FAQ about sharing libs:
275
+ // https://shorturl.at/jmzH0
276
+
277
+ });
278
+ `;
279
+ }
280
+
281
+ fs.writeFileSync('federation.config.js', federationConfig);
282
+
283
+ // TypeScript configurations
284
+ let tsConfig;
285
+
286
+ if (isMonorepoApp) {
287
+ // In monorepo: create minimal tsconfig that extends from parent
288
+ tsConfig = {
289
+ extends: '../../tsconfig.json',
290
+ compileOnSave: false,
291
+ compilerOptions: {
292
+ outDir: './dist/out-tsc',
293
+ types: [],
294
+ },
295
+ files: [],
296
+ include: ['src/**/*'],
297
+ exclude: ['src/**/*.spec.ts'],
298
+ };
299
+ } else {
300
+ // Standalone app: full tsconfig
301
+ tsConfig = {
302
+ compileOnSave: false,
303
+ compilerOptions: {
304
+ outDir: './dist/out-tsc',
305
+ strict: true,
306
+ noImplicitOverride: true,
307
+ noPropertyAccessFromIndexSignature: true,
308
+ noImplicitReturns: true,
309
+ noFallthroughCasesInSwitch: true,
310
+ skipLibCheck: true,
311
+ isolatedModules: true,
312
+ esModuleInterop: true,
313
+ sourceMap: true,
314
+ declaration: false,
315
+ experimentalDecorators: true,
316
+ moduleResolution: 'bundler',
317
+ importHelpers: true,
318
+ target: 'ES2022',
319
+ module: 'ES2022',
320
+ lib: ['ES2022', 'dom'],
321
+ },
322
+ angularCompilerOptions: {
323
+ enableI18nLegacyMessageIdFormat: false,
324
+ strictInjectionParameters: true,
325
+ strictInputAccessModifiers: true,
326
+ strictTemplates: true,
327
+ },
328
+ };
329
+ }
330
+
331
+ fs.writeFileSync('tsconfig.json', JSON.stringify(tsConfig, null, 2));
332
+
333
+ const tsConfigApp = {
334
+ extends: './tsconfig.json',
335
+ compilerOptions: {
336
+ outDir: './out-tsc/app',
337
+ types: [],
338
+ },
339
+ files: ['src/bootstrap.ts'],
340
+ include: ['src/**/*.ts', 'src/**/*.d.ts'],
341
+ };
342
+
343
+ fs.writeFileSync('tsconfig.app.json', JSON.stringify(tsConfigApp, null, 2));
344
+
345
+ const tsConfigSpec = {
346
+ extends: './tsconfig.json',
347
+ compilerOptions: {
348
+ outDir: './out-tsc/spec',
349
+ types: ['jasmine'],
350
+ },
351
+ include: ['src/**/*.spec.ts', 'src/**/*.d.ts'],
352
+ };
353
+
354
+ fs.writeFileSync('tsconfig.spec.json', JSON.stringify(tsConfigSpec, null, 2));
355
+
356
+ // Other configuration files
357
+ const gitignore = `# See http://help.github.com/ignore-files/ for more about ignoring files.
358
+
359
+ # Compiled output
360
+ /dist
361
+ /tmp
362
+ /out-tsc
363
+ # Only exists if Bazel was run
364
+ /bazel-out
365
+
366
+ # Dependencies
367
+ /node_modules
368
+
369
+ # Profiling files
370
+ chrome-profiler-events*.json
371
+
372
+ # IDEs and editors
373
+ /.idea
374
+ .project
375
+ .classpath
376
+ .c9/
377
+ *.launch
378
+ .settings/
379
+ *.sublime-workspace
380
+
381
+ # IDE - VSCode
382
+ .vscode/*
383
+ !.vscode/settings.json
384
+ !.vscode/tasks.json
385
+ !.vscode/launch.json
386
+ !.vscode/extensions.json
387
+ .history/*
388
+
389
+ # misc
390
+ /.sass-cache
391
+ /connect.lock
392
+ /coverage
393
+ /libpeerconnection.log
394
+ npm-debug.log
395
+ yarn-error.log
396
+
397
+ # System Files
398
+ .DS_Store
399
+ Thumbs.db
400
+ `;
401
+
402
+ fs.writeFileSync('.gitignore', gitignore);
403
+
404
+ const editorConfig = `# Editor configuration, see https://editorconfig.org
405
+ root = true
406
+
407
+ [*]
408
+ charset = utf-8
409
+ indent_style = space
410
+ indent_size = 2
411
+ insert_final_newline = true
412
+ trim_trailing_whitespace = true
413
+
414
+ [*.ts]
415
+ quote_type = single
416
+
417
+ [*.md]
418
+ max_line_length = off
419
+ trim_trailing_whitespace = false
420
+ `;
421
+
422
+ fs.writeFileSync('.editorconfig', editorConfig);
423
+
424
+ const readme = `# ${projectName}
425
+
426
+ This project is a module federated Progressive Web App (PWA) created with [Angular CLI](https://github.com/angular/angular-cli) and [@angular-architects/native-federation](https://www.npmjs.com/package/@angular-architects/native-federation).
427
+
428
+ ## Development server
429
+
430
+ Run \`npm start\` for a dev server. Navigate to \`http://localhost:4200/\`. The application will automatically reload if you change any of the source files.
431
+
432
+ ## PWA Features
433
+
434
+ This project includes:
435
+
436
+ - ๐Ÿ“ฑ **Progressive Web App** capabilities
437
+ - ๐Ÿ”„ **Service Worker** for caching and offline support
438
+ - ๐Ÿ“ฆ **Web App Manifest** for installation
439
+ - ๐ŸŽจ **PWA Icons** in multiple sizes
440
+ - ๐Ÿ”” **Update notifications** when new versions are available
441
+ - ๐Ÿ“ฑ **Install prompt** for adding to home screen
442
+
443
+ ### Testing PWA Features
444
+
445
+ 1. Build the application: \`npm run build\`
446
+ 2. Serve the PWA: \`npm run serve:pwa\`
447
+ 3. Open http://localhost:8080 in your browser
448
+ 4. Test offline functionality and install prompt
449
+
450
+ ### PWA Scripts
451
+
452
+ - \`npm run serve:pwa\` - Serve built PWA with http-server
453
+ - \`npm run serve:pwa-python\` - Serve PWA with Python server (fallback)
454
+ - \`npm run serve:pwa-live\` - Serve PWA with live-server
455
+ - \`npm run build:deploy\` - Build and create deployment zip
456
+
457
+ ## Asset Management
458
+
459
+ This project is configured to use \`@magmonium/cli\` for asset compilation. To use asset compilation:
460
+
461
+ 1. Install mag-cli globally: \`npm install -g @magmonium/cli\`
462
+ 2. Run \`mag-cli assets\` to compile assets from \`src/shared/mag_assets/\` to \`assets/\`
463
+ 3. Run \`mag-cli assets --watch\` to watch for asset changes during development
464
+ 4. Run \`mag-cli build\` to compile assets + build project + create zip
465
+ 5. Run \`mag-cli zip\` to build and create deployment zip
466
+
467
+ ## Build
468
+
469
+ Run \`npm run build\` to build the project. The build artifacts will be stored in the \`dist/\` directory.
470
+
471
+ ## Module Federation
472
+
473
+ This project is configured as a module federation remote. It exposes:
474
+
475
+ - \`./Component\` - The main app component
476
+
477
+ ## Further help
478
+
479
+ To get more help on the Angular CLI use \`ng help\` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
480
+ `;
481
+
482
+ fs.writeFileSync('README.md', readme);
483
+ }
484
+
485
+ async function createReactConfigFiles(
486
+ projectName,
487
+ isMonorepoApp,
488
+ companyName = null
489
+ ) {
490
+ // Create build.js for React projects
491
+ const outputPathExpression = isMonorepoApp
492
+ ? `\`../../dist/${companyName}/\${projectName}\``
493
+ : '`dist`';
494
+
495
+ const buildJsContent = `const esbuild = require("esbuild");
496
+ const path = require("path");
497
+ const fs = require("fs");
498
+ const { createEsBuildAdapter } = require("@softarc/native-federation-esbuild");
499
+ const { federationBuilder } = require("@softarc/native-federation/build");
500
+
501
+ // Get watch mode from command line arguments
502
+ const isWatchMode = process.argv.includes("--watch");
503
+
504
+ const sass = require("sass");
505
+
506
+ // Sass/CSS injector plugin (for non-module files)
507
+ const sassInjectorPlugin = {
508
+ name: "sass-injector",
509
+ setup(build) {
510
+ // Handle SCSS/Sass files (but NOT .module.* files)
511
+ build.onLoad({ filter: /\\.(scss|sass)$/, namespace: "" }, async (args) => {
512
+ // Skip module files - they should be handled by cssModulesPlugin
513
+ if (args.path.includes('.module.')) {
514
+ return undefined; // Let other plugins handle this
515
+ }
516
+
517
+ const result = sass.compile(args.path, {
518
+ style: "compressed",
519
+ sourceMap: false,
520
+ });
521
+
522
+ const escapedCSS = result.css
523
+ .replace(/\\\\/g, "\\\\\\\\")
524
+ .replace(/\\\`/g, "\\\\\\\`")
525
+ .replace(/[\\][$]/g, "\\\\\\\\\x24");
526
+
527
+ return {
528
+ contents: \`
529
+ const css = \\\`\${escapedCSS}\\\`;
530
+ if (typeof document !== 'undefined') {
531
+ const style = document.createElement('style');
532
+ style.textContent = css;
533
+ if (document.head) {
534
+ document.head.appendChild(style);
535
+ } else {
536
+ document.addEventListener('DOMContentLoaded', () => {
537
+ document.head.appendChild(style);
538
+ });
539
+ }
540
+ }
541
+ export default css;
542
+ \`,
543
+ loader: "js",
544
+ };
545
+ });
546
+
547
+ // Handle CSS files (but NOT .module.* files)
548
+ build.onLoad({ filter: /\\.css$/, namespace: "" }, async (args) => {
549
+ // Skip module files - they should be handled by cssModulesPlugin
550
+ if (args.path.includes('.module.')) {
551
+ return undefined; // Let other plugins handle this
552
+ }
553
+
554
+ const css = await fs.promises.readFile(args.path, "utf8");
555
+ const escapedCSS = css
556
+ .replace(/\\\\/g, "\\\\\\\\")
557
+ .replace(/\\\`/g, "\\\\\\\`")
558
+ .replace(/[\\][$]/g, "\\\\\\\\\x24");
559
+ return {
560
+ contents: \`
561
+ const css = \\\`\${escapedCSS}\\\`;
562
+ if (typeof document !== 'undefined') {
563
+ const style = document.createElement('style');
564
+ style.textContent = css;
565
+ if (document.head) {
566
+ document.head.appendChild(style);
567
+ } else {
568
+ document.addEventListener('DOMContentLoaded', () => {
569
+ document.head.appendChild(style);
570
+ });
571
+ }
572
+ }
573
+ export default css;
574
+ \`,
575
+ loader: "js",
576
+ };
577
+ });
578
+ },
579
+ };
580
+
581
+ // CSS Modules plugin for .module.* files
582
+ const cssModulesPlugin = {
583
+ name: "css-modules",
584
+ setup(build) {
585
+ build.onLoad({ filter: /\\.module\\.(scss|sass|css)$/ }, async (args) => {
586
+ let result;
587
+
588
+ if (args.path.endsWith('.sass') || args.path.endsWith('.scss')) {
589
+ result = sass.compile(args.path, {
590
+ style: "compressed",
591
+ sourceMap: false,
592
+ });
593
+ } else {
594
+ // Handle CSS files
595
+ const cssContent = await fs.promises.readFile(args.path, "utf8");
596
+ result = { css: cssContent };
597
+ }
598
+
599
+ // Extract CSS class names from the compiled CSS
600
+ // This regex matches class selectors at the beginning of CSS rules
601
+ // It looks for a dot followed by a letter/underscore, then word characters
602
+ const classNames = {};
603
+ const classNameRegex = /\\.([a-zA-Z_][a-zA-Z0-9_-]*)\\s*[,{]/g;
604
+ let match;
605
+
606
+ while ((match = classNameRegex.exec(result.css)) !== null) {
607
+ const className = match[1];
608
+ // Keep original class names for CSS modules
609
+ classNames[className] = className;
610
+ }
611
+
612
+ // Fallback: if no classes found with the strict regex, try a more permissive one
613
+ // This handles cases where classes might not be followed by { or ,
614
+ if (Object.keys(classNames).length === 0) {
615
+ const fallbackRegex = /\\.([a-zA-Z_][a-zA-Z0-9_-]*)(?=\\s|$|[.#:[\\],{>+~])/g;
616
+ while ((match = fallbackRegex.exec(result.css)) !== null) {
617
+ const className = match[1];
618
+ classNames[className] = className;
619
+ }
620
+ }
621
+
622
+ const escapedCSS = result.css
623
+ .replace(/\\\\/g, "\\\\\\\\")
624
+ .replace(/\\\`/g, "\\\\\\\`")
625
+ .replace(/[\\][$]/g, "\\\\\\\\\x24");
626
+
627
+ return {
628
+ contents: \`
629
+ const css = \\\`\${escapedCSS}\\\`;
630
+ if (typeof document !== 'undefined') {
631
+ const style = document.createElement('style');
632
+ style.textContent = css;
633
+ if (document.head) {
634
+ document.head.appendChild(style);
635
+ } else {
636
+ document.addEventListener('DOMContentLoaded', () => {
637
+ document.head.appendChild(style);
638
+ });
639
+ }
640
+ }
641
+ export default \${JSON.stringify(classNames)};
642
+ \`,
643
+ loader: "js",
644
+ };
645
+ });
646
+ },
647
+ };
648
+
649
+ async function buildProject(projectName) {
650
+ const tsConfig = "tsconfig.json";
651
+ const outputPath = ${outputPathExpression};
652
+ /*
653
+ * Step 1: Initialize Native Federation
654
+ */
655
+
656
+ await federationBuilder.init({
657
+ options: {
658
+ workspaceRoot: __dirname,
659
+ outputPath,
660
+ tsConfig,
661
+ federationConfig: \`federation.config.js\`,
662
+ verbose: false,
663
+ },
664
+
665
+ /*
666
+ * As this core lib is tooling-agnostic, you
667
+ * need a simple adapter for your bundler.
668
+ * It's just a matter of one function.
669
+ */
670
+ adapter: createEsBuildAdapter({
671
+ plugins: [cssModulesPlugin, sassInjectorPlugin],
672
+ loader: {
673
+ ".css": "text",
674
+ ".scss": "text",
675
+ ".sass": "text",
676
+ },
677
+ }),
678
+ });
679
+
680
+ /*
681
+ * Step 2: Trigger your build process
682
+ *
683
+ * You can use any tool for this. Here, we go with a very
684
+ * simple esbuild-based build.
685
+ *
686
+ * Just respect the externals in \`federationBuilder.externals\`.
687
+ */
688
+
689
+ fs.rmSync(outputPath, { force: true, recursive: true });
690
+
691
+ const buildOptions = {
692
+ entryPoints: [\`src/main.tsx\`],
693
+ external: federationBuilder.externals,
694
+ outdir: outputPath,
695
+ bundle: true,
696
+ platform: "browser",
697
+ format: "esm",
698
+ mainFields: ["es2020", "browser", "module", "main"],
699
+ conditions: ["es2020", "es2015", "module"],
700
+ resolveExtensions: [".ts", ".tsx", ".mjs", ".js", ".css", ".scss", ".sass"],
701
+ tsconfig: tsConfig,
702
+ splitting: true,
703
+ loader: {
704
+ ".css": "text",
705
+ ".scss": "text",
706
+ ".sass": "text",
707
+ },
708
+ plugins: [cssModulesPlugin, sassInjectorPlugin],
709
+ define: {
710
+ 'process.env.REACT_APP_WEBAPP_MODE': JSON.stringify(process.env.REACT_APP_WEBAPP_MODE || 'false'),
711
+ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV || 'development'),
712
+ },
713
+ };
714
+
715
+ if (isWatchMode) {
716
+ // In watch mode, we need to handle file copying differently
717
+ const copyFiles = () => {
718
+ try {
719
+ // Ensure output directory exists
720
+ fs.mkdirSync(outputPath, { recursive: true });
721
+
722
+ // Generate index.html dynamically
723
+ const indexHtml = \`<!DOCTYPE html>
724
+ <html lang="en">
725
+ <head>
726
+ <meta charset="utf-8" />
727
+ <title>${projectName}</title>
728
+ <base href="/" />
729
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
730
+ <link rel="icon" type="image/x-icon" href="favicon.ico" />
731
+ <link rel="manifest" href="manifest.webmanifest" />
732
+ <meta name="theme-color" content="#1976d2" />
733
+ <!-- iOS meta tags -->
734
+ <meta name="apple-mobile-web-app-capable" content="yes" />
735
+ <meta name="apple-mobile-web-app-status-bar-style" content="default" />
736
+ <meta name="apple-mobile-web-app-title" content="${projectName}" />
737
+ <link rel="apple-touch-icon" href="/shared/assets/icons/icon-192x192.svg" />
738
+ <link rel="stylesheet" href="styles.css" />
739
+ <!-- Windows meta tags -->
740
+ <meta name="msapplication-TileImage" content="/shared/assets/icons/icon-144x144.svg" />
741
+ <meta name="msapplication-TileColor" content="#1976d2" />
742
+ </head>
743
+ <body>
744
+ <div id="root"></div>
745
+ <!-- Load the import map generated by Native Federation -->
746
+ <script type="esms-options">
747
+ {
748
+ "shimMode": true
749
+ }
750
+ </script>
751
+ <script src="https://ga.jspm.io/npm:es-module-shims@1.5.17/dist/es-module-shims.js"></script>
752
+ <script type="module-shim" src="main.js"></script>
753
+ </body>
754
+ </html>
755
+ \`;
756
+ fs.writeFileSync(\`\${outputPath}/index.html\`, indexHtml);
757
+ // Compile Sass to CSS
758
+ const scssResult = sass.compile('src/app/styles/global.sass');
759
+ fs.writeFileSync(\`\${outputPath}/styles.css\`, scssResult.css);
760
+ fs.copyFileSync(
761
+ \`src/manifest.webmanifest\`,
762
+ \`\${outputPath}/manifest.webmanifest\`
763
+ );
764
+
765
+ // Copy assets directory if it exists
766
+ if (fs.existsSync(\`assets\`)) {
767
+ fs.cpSync(\`assets\`, \`\${outputPath}/assets\`, { recursive: true });
768
+ }
769
+ } catch (err) {
770
+ console.error("Error copying files:", err);
771
+ }
772
+ };
773
+
774
+ const context = await esbuild.context({
775
+ ...buildOptions,
776
+ plugins: [
777
+ ...buildOptions.plugins,
778
+ {
779
+ name: "copy-files",
780
+ setup(build) {
781
+ build.onEnd(() => {
782
+ copyFiles();
783
+ console.log("Build completed, files copied");
784
+ });
785
+ },
786
+ },
787
+ ],
788
+ });
789
+
790
+ // Initial file copy
791
+ copyFiles();
792
+
793
+ await context.watch();
794
+ console.log("Watching for changes...");
795
+
796
+ // Keep the process running
797
+ process.on("SIGINT", async () => {
798
+ await context.dispose();
799
+ process.exit(0);
800
+ });
801
+ } else {
802
+ await esbuild.build(buildOptions);
803
+
804
+ // Ensure output directory exists
805
+ fs.mkdirSync(outputPath, { recursive: true });
806
+
807
+ // Generate index.html dynamically
808
+ const indexHtml = \`<!DOCTYPE html>
809
+ <html lang="en">
810
+ <head>
811
+ <meta charset="utf-8" />
812
+ <title>${projectName}</title>
813
+ <base href="/" />
814
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
815
+ <link rel="icon" type="image/x-icon" href="favicon.ico" />
816
+ <link rel="manifest" href="manifest.webmanifest" />
817
+ <meta name="theme-color" content="#1976d2" />
818
+ <!-- iOS meta tags -->
819
+ <meta name="apple-mobile-web-app-capable" content="yes" />
820
+ <meta name="apple-mobile-web-app-status-bar-style" content="default" />
821
+ <meta name="apple-mobile-web-app-title" content="${projectName}" />
822
+ <link rel="apple-touch-icon" href="/shared/assets/icons/icon-192x192.svg" />
823
+ <link rel="stylesheet" href="styles.css" />
824
+ <!-- Windows meta tags -->
825
+ <meta name="msapplication-TileImage" content="/shared/assets/icons/icon-144x144.svg" />
826
+ <meta name="msapplication-TileColor" content="#1976d2" />
827
+ </head>
828
+ <body>
829
+ <div id="root"></div>
830
+ <!-- Load the import map generated by Native Federation -->
831
+ <script type="esms-options">
832
+ {
833
+ "shimMode": true
834
+ }
835
+ </script>
836
+ <script src="https://ga.jspm.io/npm:es-module-shims@1.5.17/dist/es-module-shims.js"></script>
837
+ <script type="module-shim" src="main.js"></script>
838
+ </body>
839
+ </html>
840
+ \`;
841
+ fs.writeFileSync(\`\${outputPath}/index.html\`, indexHtml);
842
+ // Compile Sass to CSS
843
+ const scssResult = sass.compile('src/app/styles/global.sass');
844
+ fs.writeFileSync(\`\${outputPath}/styles.css\`, scssResult.css);
845
+ fs.copyFileSync(
846
+ \`src/manifest.webmanifest\`,
847
+ \`\${outputPath}/manifest.webmanifest\`
848
+ );
849
+
850
+ // Copy assets directory if it exists
851
+ if (fs.existsSync(\`assets\`)) {
852
+ fs.cpSync(\`assets\`, \`\${outputPath}/assets\`, { recursive: true });
853
+ }
854
+ }
855
+
856
+ /*
857
+ * Step 3: Let the build method do the additional tasks
858
+ * for supporting Native Federation
859
+ */
860
+
861
+ if (!isWatchMode) {
862
+ await federationBuilder.build();
863
+ }
864
+ }
865
+
866
+ buildProject("${projectName}");
867
+ `;
868
+
869
+ fs.writeFileSync('build.js', buildJsContent);
870
+
871
+ // Native Federation configuration for React
872
+ const federationConfig = `const {
873
+ withNativeFederation,
874
+ shareAll,
875
+ } = require("@softarc/native-federation/build");
876
+
877
+ module.exports = withNativeFederation({
878
+ name: "${projectName}",
879
+
880
+ exposes: {
881
+ "./MainComponent": "./src/shared/magmonium/main.web-component.tsx",
882
+ },
883
+
884
+ shared: shareAll({
885
+ singleton: true,
886
+ strictVersion: true,
887
+ requiredVersion: "auto",
888
+ includeSecondaries: false,
889
+ }),
890
+
891
+ skip: [],
892
+ });
893
+ `;
894
+
895
+ fs.writeFileSync('federation.config.js', federationConfig);
896
+
897
+ // TypeScript configuration for React
898
+ let tsConfig;
899
+ if (isMonorepoApp) {
900
+ tsConfig = {
901
+ extends: '../../tsconfig.json',
902
+ compilerOptions: {
903
+ target: 'ES2020',
904
+ module: 'ESNext',
905
+ lib: ['dom', 'dom.iterable', 'es6'],
906
+ allowJs: true,
907
+ skipLibCheck: true,
908
+ esModuleInterop: true,
909
+ allowSyntheticDefaultImports: true,
910
+ strict: true,
911
+ forceConsistentCasingInFileNames: true,
912
+ moduleResolution: 'node',
913
+ resolveJsonModule: true,
914
+ isolatedModules: true,
915
+ noEmit: false,
916
+ jsx: 'react-jsx',
917
+ outDir: './dist/out-tsc',
918
+ },
919
+ include: ['src/**/*'],
920
+ exclude: ['node_modules', 'dist', '**/*.spec.ts', '**/*.test.ts'],
921
+ };
922
+ } else {
923
+ tsConfig = {
924
+ compilerOptions: {
925
+ target: 'ES2020',
926
+ module: 'ESNext',
927
+ lib: ['dom', 'dom.iterable', 'es6'],
928
+ allowJs: true,
929
+ skipLibCheck: true,
930
+ esModuleInterop: true,
931
+ allowSyntheticDefaultImports: true,
932
+ strict: true,
933
+ forceConsistentCasingInFileNames: true,
934
+ moduleResolution: 'node',
935
+ resolveJsonModule: true,
936
+ isolatedModules: true,
937
+ noEmit: false,
938
+ jsx: 'react-jsx',
939
+ baseUrl: './',
940
+ paths: {
941
+ '@/*': ['src/*'],
942
+ },
943
+ },
944
+ include: ['src/**/*'],
945
+ exclude: ['node_modules', 'dist', '**/*.spec.ts', '**/*.test.ts'],
946
+ };
947
+ }
948
+
949
+ fs.writeFileSync('tsconfig.json', JSON.stringify(tsConfig, null, 2));
950
+
951
+ // ESLint and Jest configurations
952
+ const eslintConfig = {
953
+ env: { browser: true, es2021: true, node: true },
954
+ extends: [
955
+ 'eslint:recommended',
956
+ '@typescript-eslint/recommended',
957
+ 'plugin:react/recommended',
958
+ 'plugin:react-hooks/recommended',
959
+ ],
960
+ parser: '@typescript-eslint/parser',
961
+ parserOptions: {
962
+ ecmaFeatures: { jsx: true },
963
+ ecmaVersion: 'latest',
964
+ sourceType: 'module',
965
+ },
966
+ plugins: ['react', '@typescript-eslint', 'react-hooks'],
967
+ rules: {
968
+ 'react/react-in-jsx-scope': 'off',
969
+ 'react/prop-types': 'off',
970
+ '@typescript-eslint/no-unused-vars': [
971
+ 'error',
972
+ { argsIgnorePattern: '^_' },
973
+ ],
974
+ },
975
+ settings: { react: { version: 'detect' } },
976
+ };
977
+
978
+ fs.writeFileSync('.eslintrc.json', JSON.stringify(eslintConfig, null, 2));
979
+
980
+ const jestConfig = {
981
+ preset: 'ts-jest',
982
+ testEnvironment: 'jsdom',
983
+ setupFilesAfterEnv: ['<rootDir>/src/setupTests.ts'],
984
+ moduleNameMapping: { '\\\\.(css|less|scss|sass)$': 'identity-obj-proxy' },
985
+ transform: { '^.+\\\\.(ts|tsx)$': 'ts-jest' },
986
+ moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
987
+ testMatch: [
988
+ '<rootDir>/src/**/__tests__/**/*.(ts|tsx|js)',
989
+ '<rootDir>/src/**/*.(test|spec).(ts|tsx|js)',
990
+ ],
991
+ collectCoverageFrom: [
992
+ 'src/**/*.(ts|tsx)',
993
+ '!src/**/*.d.ts',
994
+ '!src/index.tsx',
995
+ '!src/bootstrap.tsx',
996
+ ],
997
+ };
998
+
999
+ fs.writeFileSync(
1000
+ 'jest.config.js',
1001
+ `module.exports = ${JSON.stringify(jestConfig, null, 2)};`
1002
+ );
1003
+
1004
+ // Configuration files
1005
+ const gitignore = `# Dependencies
1006
+ node_modules/
1007
+ /.pnp
1008
+ .pnp.js
1009
+
1010
+ # Production build
1011
+ /build
1012
+ /dist
1013
+
1014
+ # Testing
1015
+ /coverage
1016
+
1017
+ # Misc
1018
+ .DS_Store
1019
+ .env.local
1020
+ .env.development.local
1021
+ .env.test.local
1022
+ .env.production.local
1023
+
1024
+ # Logs
1025
+ npm-debug.log*
1026
+ yarn-debug.log*
1027
+ yarn-error.log*
1028
+
1029
+ # IDE
1030
+ .vscode/
1031
+ .idea/
1032
+ *.swp
1033
+ *.swo
1034
+
1035
+ # Optional npm cache directory
1036
+ .npm
1037
+
1038
+ # Yarn Integrity file
1039
+ .yarn-integrity
1040
+
1041
+ # dotenv environment variables file
1042
+ .env
1043
+ .env.test
1044
+
1045
+ # Stores VSCode versions used for testing VSCode extensions
1046
+ .vscode-test
1047
+ `;
1048
+
1049
+ fs.writeFileSync('.gitignore', gitignore);
1050
+
1051
+ const editorConfig = `# Editor configuration, see https://editorconfig.org
1052
+ root = true
1053
+
1054
+ [*]
1055
+ charset = utf-8
1056
+ indent_style = space
1057
+ indent_size = 2
1058
+ insert_final_newline = true
1059
+ trim_trailing_whitespace = true
1060
+
1061
+ [*.{ts,tsx,js,jsx,json}]
1062
+ indent_size = 2
1063
+
1064
+ [*.md]
1065
+ max_line_length = off
1066
+ trim_trailing_whitespace = false
1067
+ `;
1068
+
1069
+ fs.writeFileSync('.editorconfig', editorConfig);
1070
+
1071
+ const readme = `# ${projectName}
1072
+
1073
+ This project is a React module federated Progressive Web App (PWA) created with Webpack and Module Federation.
1074
+
1075
+ ## Development server
1076
+
1077
+ Run \`npm start\` for a dev server. Navigate to \`http://localhost:3000/\`. The application will automatically reload if you change any of the source files.
1078
+
1079
+ ## PWA Features
1080
+
1081
+ This project includes:
1082
+ - ๐Ÿ“ฑ **Progressive Web App** capabilities
1083
+ - ๐Ÿ”„ **Service Worker** for caching and offline support
1084
+ - ๐Ÿ“ฆ **Web App Manifest** for installation
1085
+ - ๐ŸŽจ **PWA Icons** in multiple sizes
1086
+
1087
+ ### Testing PWA Features
1088
+
1089
+ 1. Build the application: \`npm run build\`
1090
+ 2. Serve the PWA: \`npm run serve:pwa\`
1091
+ 3. Open http://localhost:8080 in your browser
1092
+
1093
+ ## Technology Stack
1094
+
1095
+ - โš›๏ธ React 18 with TypeScript
1096
+ - ๐Ÿ“ฆ Webpack 5 with Module Federation
1097
+ - ๐Ÿงช Jest for testing
1098
+ - ๐Ÿ“ ESLint for code quality
1099
+
1100
+ ${
1101
+ isMonorepoApp
1102
+ ? '## Module Federation\n\nThis project exposes:\n- `./MainComponent` - The main React component for micro frontend integration'
1103
+ : ''
1104
+ }
1105
+
1106
+ ## Further help
1107
+
1108
+ For more information about React, visit the [React documentation](https://reactjs.org/).
1109
+ `;
1110
+
1111
+ fs.writeFileSync('README.md', readme);
1112
+ }
1113
+
1114
+ module.exports = createConfigFiles;