@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,41 @@
1
+ const path = require('path');
2
+
3
+ function sanitizeI18nCommand(program) {
4
+ program
5
+ .command('sanitize-i18n')
6
+ .description(
7
+ 'Scan all i18n YAML files for syntax errors (unclosed quotes, bare %, colon-in-value) and auto-fix them.'
8
+ )
9
+ .option('--dry-run', 'Preview fixes without writing files', false)
10
+ .option('-v, --verbose', 'Log each file processed', false)
11
+ .option('--root <path>', 'Workspace root (defaults to cwd)', process.cwd())
12
+ .action(async (options) => {
13
+ const root = path.resolve(options.root);
14
+ const { I18nSanitizer } = require('../../src/index.js');
15
+
16
+ const sanitizer = new I18nSanitizer(options.verbose);
17
+
18
+ const roots = [
19
+ path.join(root, 'libs', 'one', 'mag_assets', 'i18n'),
20
+ path.join(root, 'apps', 'm-comics', 'mag_assets', 'i18n'),
21
+ path.join(root, 'apps', 'm-finance', 'mag_assets', 'i18n'),
22
+ path.join(root, 'apps', 'm-wallet', 'mag_assets', 'i18n'),
23
+ path.join(root, 'apps', 'm-ui', 'mag_assets', 'i18n'),
24
+ ].filter(Boolean);
25
+
26
+ const results = await sanitizer.sanitizeAll(roots, options.dryRun);
27
+
28
+ const fixed = results.filter((r) => r.fixed);
29
+ const unfixable = results.filter((r) => r.unfixable);
30
+
31
+ if (unfixable.length > 0) {
32
+ console.log(`\nUnfixable files (manual review needed):`);
33
+ unfixable.forEach((r) => console.log(` ${r.file}: ${r.error}`));
34
+ }
35
+
36
+ console.log(`\nSummary: ${fixed.length} fixed, ${unfixable.length} need manual review`);
37
+ if (options.dryRun) console.log('(dry-run — no files written)');
38
+ });
39
+ }
40
+
41
+ module.exports = sanitizeI18nCommand;
@@ -0,0 +1,32 @@
1
+ const { TranslationManager } = require('../../src/index.js');
2
+
3
+ function translateCommand(program) {
4
+ program
5
+ .command('translate')
6
+ .description(
7
+ 'Interactive translation manager - find and add missing translations'
8
+ )
9
+ .option('-c, --config <path>', 'Config file path', './mag-cli.config.js')
10
+ .option('-s, --source <path>', 'Source directory to scan', './src')
11
+ .option(
12
+ '-o, --output <path>',
13
+ 'Output directory for translations',
14
+ './src/shared/assets/i18n'
15
+ )
16
+ .option('-l, --locales <locales>', 'Comma-separated list of locales', 'en')
17
+ .option('--auto', 'Auto-translate missing keys using AI')
18
+ .action(async (options) => {
19
+ const locales = options.locales.split(',').map((l) => l.trim());
20
+
21
+ const manager = new TranslationManager({
22
+ sourceDir: options.source,
23
+ outputDir: options.output,
24
+ locales: locales,
25
+ autoTranslate: options.auto,
26
+ });
27
+
28
+ await manager.findAndAddMissingTranslations();
29
+ });
30
+ }
31
+
32
+ module.exports = translateCommand;
@@ -0,0 +1,540 @@
1
+ const { execSync } = require('child_process');
2
+ const fs = require('fs');
3
+ const path = require('path');
4
+ const inquirer = require('inquirer');
5
+
6
+ function zipCommand(program) {
7
+ program
8
+ .command('zip [appName]')
9
+ .description('Build project and create deployment zip file')
10
+ .option('-c, --config <path>', 'Config file path', './mag-cli.config.js')
11
+ .option('-v, --verbose', 'Verbose output')
12
+ .option('--skip-assets', 'Skip asset compilation')
13
+ .option('--skip-build', 'Skip project build')
14
+ .option('--skip-version-bump', 'Skip version bump')
15
+ .option('--minor', 'Bump minor version instead of patch version')
16
+ .option('--major', 'Bump major version instead of patch version')
17
+ .option('--company <name>', 'Company name for monorepo lookup')
18
+ .action(async (appName, options) => {
19
+ try {
20
+ const context = await determineContext(appName, options);
21
+
22
+ if (context.type === 'monorepo-external') {
23
+ await handleMonorepoExternal(context, options);
24
+ } else if (context.type === 'monorepo-internal') {
25
+ await handleMonorepoInternal(context, options);
26
+ } else {
27
+ await handleStandalone(context, options);
28
+ }
29
+
30
+ console.log('šŸŽ‰ Zip creation completed successfully!');
31
+ } catch (error) {
32
+ console.error(`āŒ Zip creation failed: ${error.message}`);
33
+ process.exit(1);
34
+ }
35
+ });
36
+ }
37
+
38
+ async function determineContext(appName, options) {
39
+ const cwd = process.cwd();
40
+ const packageJsonPath = path.join(cwd, 'package.json');
41
+
42
+ // Check if we're in a monorepo app directory
43
+ if (fs.existsSync(packageJsonPath)) {
44
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
45
+ const isMonorepoApp =
46
+ packageJson.name.startsWith('@') && cwd.includes('/apps/');
47
+
48
+ if (isMonorepoApp) {
49
+ return {
50
+ type: 'monorepo-internal',
51
+ appName: packageJson.name.split('/')[1],
52
+ companyName: packageJson.name.split('/')[0].replace('@', ''),
53
+ monorepoRoot: path.resolve(cwd, '../..'),
54
+ currentApp: cwd,
55
+ };
56
+ }
57
+ }
58
+
59
+ // Check if we're in monorepo root
60
+ const rootPackageJsonPath = path.join(cwd, 'package.json');
61
+ if (fs.existsSync(rootPackageJsonPath)) {
62
+ const rootPackageJson = JSON.parse(
63
+ fs.readFileSync(rootPackageJsonPath, 'utf-8')
64
+ );
65
+ if (rootPackageJson.workspaces && fs.existsSync(path.join(cwd, 'apps'))) {
66
+ return {
67
+ type: 'monorepo-external',
68
+ monorepoRoot: cwd,
69
+ companyName: rootPackageJson.name.replace('-monorepo', ''),
70
+ requestedApp: appName,
71
+ };
72
+ }
73
+ }
74
+
75
+ // External to monorepo - need to find it
76
+ if (options.company || appName) {
77
+ return {
78
+ type: 'monorepo-external',
79
+ requestedCompany: options.company,
80
+ requestedApp: appName,
81
+ currentDir: cwd,
82
+ };
83
+ }
84
+
85
+ // Standalone app
86
+ return {
87
+ type: 'standalone',
88
+ currentDir: cwd,
89
+ };
90
+ }
91
+
92
+ async function handleMonorepoExternal(context, options) {
93
+ let companyName = context.companyName || context.requestedCompany;
94
+ let monorepoRoot = context.monorepoRoot;
95
+
96
+ // If we don't have a company name, prompt for it
97
+ if (!companyName) {
98
+ const companyPrompt = await inquirer.prompt([
99
+ {
100
+ type: 'input',
101
+ name: 'companyName',
102
+ message: 'Enter company name to find monorepo:',
103
+ validate: (input) =>
104
+ input.trim().length > 0 || 'Company name is required',
105
+ },
106
+ ]);
107
+ companyName = companyPrompt.companyName.toLowerCase();
108
+ }
109
+
110
+ // Find monorepo if not already found
111
+ if (!monorepoRoot) {
112
+ const possiblePaths = [
113
+ path.join(context.currentDir, `${companyName}-monorepo`),
114
+ path.join(context.currentDir, '..', `${companyName}-monorepo`),
115
+ path.join(context.currentDir, '..', '..', `${companyName}-monorepo`),
116
+ ];
117
+
118
+ for (const possiblePath of possiblePaths) {
119
+ if (
120
+ fs.existsSync(possiblePath) &&
121
+ fs.existsSync(path.join(possiblePath, 'apps'))
122
+ ) {
123
+ monorepoRoot = possiblePath;
124
+ break;
125
+ }
126
+ }
127
+
128
+ if (!monorepoRoot) {
129
+ throw new Error(
130
+ `Monorepo not found for company: ${companyName}. Searched: ${possiblePaths.join(
131
+ ', '
132
+ )}`
133
+ );
134
+ }
135
+ }
136
+
137
+ // Get available apps
138
+ const appsDir = path.join(monorepoRoot, 'apps');
139
+ const availableApps = fs
140
+ .readdirSync(appsDir)
141
+ .filter((item) => fs.statSync(path.join(appsDir, item)).isDirectory());
142
+
143
+ if (availableApps.length === 0) {
144
+ throw new Error('No apps found in monorepo');
145
+ }
146
+
147
+ let selectedApps = [];
148
+
149
+ // Determine which apps to process
150
+ if (context.requestedApp) {
151
+ if (!availableApps.includes(context.requestedApp)) {
152
+ throw new Error(
153
+ `App '${
154
+ context.requestedApp
155
+ }' not found. Available apps: ${availableApps.join(', ')}`
156
+ );
157
+ }
158
+ selectedApps = [context.requestedApp];
159
+ } else {
160
+ // Prompt for app selection
161
+ const appSelection = await inquirer.prompt([
162
+ {
163
+ type: 'list',
164
+ name: 'choice',
165
+ message: 'What would you like to zip?',
166
+ choices: [
167
+ { name: `All apps (${availableApps.length} apps)`, value: 'all' },
168
+ { name: 'Select specific app', value: 'specific' },
169
+ ],
170
+ },
171
+ ]);
172
+
173
+ if (appSelection.choice === 'all') {
174
+ selectedApps = availableApps;
175
+ } else {
176
+ const specificApp = await inquirer.prompt([
177
+ {
178
+ type: 'list',
179
+ name: 'appName',
180
+ message: 'Select app to zip:',
181
+ choices: availableApps,
182
+ },
183
+ ]);
184
+ selectedApps = [specificApp.appName];
185
+ }
186
+ }
187
+
188
+ // Process each selected app
189
+ for (const appName of selectedApps) {
190
+ console.log(`\nšŸ“¦ Processing app: ${appName}`);
191
+ await processApp(
192
+ {
193
+ appName,
194
+ companyName,
195
+ monorepoRoot,
196
+ appPath: path.join(appsDir, appName),
197
+ },
198
+ options
199
+ );
200
+ }
201
+ }
202
+
203
+ async function handleMonorepoInternal(context, options) {
204
+ console.log(`šŸ“¦ Processing current app: ${context.appName}`);
205
+ await processApp(
206
+ {
207
+ appName: context.appName,
208
+ companyName: context.companyName,
209
+ monorepoRoot: context.monorepoRoot,
210
+ appPath: context.currentApp,
211
+ },
212
+ options
213
+ );
214
+ }
215
+
216
+ async function handleStandalone(context, options) {
217
+ const packageJsonPath = path.join(context.currentDir, 'package.json');
218
+ if (!fs.existsSync(packageJsonPath)) {
219
+ throw new Error('No package.json found - not in a valid project directory');
220
+ }
221
+
222
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
223
+
224
+ // Process standalone app
225
+ await processStandaloneApp(context.currentDir, packageJson, options);
226
+ }
227
+
228
+ async function processApp(appContext, options) {
229
+ const { appName, companyName, appPath } = appContext;
230
+
231
+ // Change to app directory
232
+ const originalDir = process.cwd();
233
+ process.chdir(appPath);
234
+
235
+ try {
236
+ // Read app package.json for version
237
+ const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
238
+
239
+ // Handle version bump
240
+ let newVersion = packageJson.version;
241
+ if (!options.skipVersionBump) {
242
+ newVersion = await handleVersionBump(packageJson, options);
243
+ }
244
+
245
+ // Step 1: Build assets (unless skipped)
246
+ if (!options.skipAssets) {
247
+ console.log('šŸŽØ Building assets...');
248
+ try {
249
+ execSync(`mag-cli assets -c ${options.config}`, {
250
+ stdio: options.verbose ? 'inherit' : 'pipe',
251
+ });
252
+ console.log('āœ… Assets built successfully');
253
+ } catch {
254
+ console.log('āš ļø Asset build failed, continuing...');
255
+ }
256
+ }
257
+
258
+ // Step 2: Build the project (unless skipped)
259
+ if (!options.skipBuild) {
260
+ console.log('šŸ—ļø Building project...');
261
+ if (fs.existsSync('angular.json')) {
262
+ execSync('npm run build', {
263
+ stdio: options.verbose ? 'inherit' : 'pipe',
264
+ });
265
+ console.log('āœ… Project built successfully');
266
+ } else {
267
+ console.log('āš ļø No angular.json found - skipping project build');
268
+ }
269
+ }
270
+
271
+ // Step 3: Create deployment zip
272
+ console.log('šŸ“¦ Creating deployment zip...');
273
+ await createMonorepoDeploymentZip(
274
+ appName,
275
+ companyName,
276
+ newVersion,
277
+ options.verbose
278
+ );
279
+ console.log(`āœ… Deployment zip created for ${appName}`);
280
+ } finally {
281
+ process.chdir(originalDir);
282
+ }
283
+ }
284
+
285
+ async function processStandaloneApp(appDir, packageJson, options) {
286
+ const originalDir = process.cwd();
287
+ process.chdir(appDir);
288
+
289
+ try {
290
+ // Handle version bump
291
+ let newVersion = packageJson.version;
292
+ if (!options.skipVersionBump) {
293
+ newVersion = await handleVersionBump(packageJson, options);
294
+ }
295
+
296
+ // Step 1: Build assets (unless skipped)
297
+ if (!options.skipAssets) {
298
+ console.log('šŸŽØ Building assets...');
299
+ try {
300
+ execSync(`mag-cli assets -c ${options.config}`, {
301
+ stdio: options.verbose ? 'inherit' : 'pipe',
302
+ });
303
+ console.log('āœ… Assets built successfully');
304
+ } catch {
305
+ console.log('āš ļø Asset build failed, continuing...');
306
+ }
307
+ }
308
+
309
+ // Step 2: Build the project (unless skipped)
310
+ if (!options.skipBuild) {
311
+ console.log('šŸ—ļø Building project...');
312
+ if (fs.existsSync('angular.json')) {
313
+ execSync('npm run build', {
314
+ stdio: options.verbose ? 'inherit' : 'pipe',
315
+ });
316
+ console.log('āœ… Project built successfully');
317
+ } else {
318
+ console.log('āš ļø No angular.json found - skipping project build');
319
+ }
320
+ }
321
+
322
+ // Step 3: Create deployment zip
323
+ console.log('šŸ“¦ Creating deployment zip...');
324
+ await createStandaloneDeploymentZip(
325
+ packageJson.name,
326
+ newVersion,
327
+ options.verbose
328
+ );
329
+ console.log('āœ… Deployment zip created successfully');
330
+ } finally {
331
+ process.chdir(originalDir);
332
+ }
333
+ }
334
+
335
+ async function handleVersionBump(packageJson, options) {
336
+ const currentVersion = packageJson.version;
337
+
338
+ // Ask for version bump type
339
+ const versionPrompt = await inquirer.prompt([
340
+ {
341
+ type: 'list',
342
+ name: 'bumpType',
343
+ message: `Current version is ${currentVersion}. How would you like to bump the version?`,
344
+ choices: [
345
+ { name: 'No change (keep current version)', value: 'none' },
346
+ { name: 'Patch (x.x.X) - Bug fixes', value: 'patch' },
347
+ { name: 'Minor (x.X.x) - New features', value: 'minor' },
348
+ { name: 'Major (X.x.x) - Breaking changes', value: 'major' },
349
+ ],
350
+ default: options.major ? 'major' : options.minor ? 'minor' : 'patch',
351
+ },
352
+ ]);
353
+
354
+ if (versionPrompt.bumpType === 'none') {
355
+ return currentVersion;
356
+ }
357
+
358
+ // Parse and bump version
359
+ const versionParts = currentVersion.split('.').map(Number);
360
+ if (versionParts.length !== 3) {
361
+ throw new Error(`Invalid version format: ${currentVersion}`);
362
+ }
363
+
364
+ switch (versionPrompt.bumpType) {
365
+ case 'major':
366
+ versionParts[0] += 1;
367
+ versionParts[1] = 0;
368
+ versionParts[2] = 0;
369
+ break;
370
+ case 'minor':
371
+ versionParts[1] += 1;
372
+ versionParts[2] = 0;
373
+ break;
374
+ case 'patch':
375
+ versionParts[2] += 1;
376
+ break;
377
+ }
378
+
379
+ const newVersion = versionParts.join('.');
380
+ console.log(
381
+ `šŸ“ˆ Version (${versionPrompt.bumpType}): ${currentVersion} → ${newVersion}`
382
+ );
383
+
384
+ // Update package.json
385
+ packageJson.version = newVersion;
386
+ fs.writeFileSync('package.json', JSON.stringify(packageJson, null, 2) + '\n');
387
+
388
+ return newVersion;
389
+ }
390
+
391
+ async function createMonorepoDeploymentZip(
392
+ appName,
393
+ companyName,
394
+ version,
395
+ verbose = false
396
+ ) {
397
+ const date = new Date().toISOString().split('T')[0];
398
+
399
+ // Define paths for monorepo structure with company name
400
+ const baseDistPath = companyName
401
+ ? `../../dist/${companyName}/${appName}`
402
+ : `../../dist/${appName}`;
403
+
404
+ // Try multiple possible source directories (prioritize post-build copied files)
405
+ const possibleSourceDirs = [
406
+ baseDistPath, // Post-build copied files (preferred)
407
+ `${baseDistPath}/browser`, // Standard Angular browser folder
408
+ ];
409
+
410
+ let sourceDir = null;
411
+ for (const dir of possibleSourceDirs) {
412
+ if (fs.existsSync(dir) && fs.existsSync(path.join(dir, 'index.html'))) {
413
+ sourceDir = dir;
414
+ break;
415
+ }
416
+ }
417
+
418
+ const outputDir = baseDistPath;
419
+ const zipName = `${companyName}-${appName}-${version}-${date}.zip`;
420
+ const zipPath = path.join(outputDir, zipName);
421
+
422
+ console.log(`šŸ“¦ Creating deployment zip: ${zipName}`);
423
+
424
+ // Check if source directory exists
425
+ if (!sourceDir) {
426
+ throw new Error(
427
+ `Build directory not found. Tried: ${possibleSourceDirs.join(
428
+ ', '
429
+ )}. Run build first.`
430
+ );
431
+ }
432
+
433
+ // Ensure output directory exists
434
+ if (!fs.existsSync(outputDir)) {
435
+ fs.mkdirSync(outputDir, { recursive: true });
436
+ }
437
+
438
+ await createZipFile(sourceDir, zipPath, verbose);
439
+
440
+ console.log(`šŸ“ Location: ${zipPath}`);
441
+ logDeploymentInstructions();
442
+ }
443
+
444
+ async function createStandaloneDeploymentZip(
445
+ projectName,
446
+ version,
447
+ verbose = false
448
+ ) {
449
+ const date = new Date().toISOString().split('T')[0];
450
+ const cleanProjectName = projectName.replace('@', '').replace('/', '-');
451
+
452
+ // Define paths for standalone structure
453
+ let sourceDir = `dist/${cleanProjectName.split('-').pop()}/browser`;
454
+ const outputDir = `dist/${cleanProjectName.split('-').pop()}`;
455
+ const zipName = `${cleanProjectName}-${version}-${date}.zip`;
456
+ const zipPath = path.join(outputDir, zipName);
457
+
458
+ console.log(`šŸ“¦ Creating deployment zip: ${zipName}`);
459
+
460
+ // Check if source directory exists
461
+ if (!fs.existsSync(sourceDir)) {
462
+ // Try alternative paths
463
+ const altPaths = [
464
+ `dist/browser`,
465
+ `dist/${projectName}/browser`,
466
+ `build`,
467
+ `dist`,
468
+ ];
469
+ let foundPath = null;
470
+ for (const altPath of altPaths) {
471
+ if (fs.existsSync(altPath)) {
472
+ foundPath = altPath;
473
+ break;
474
+ }
475
+ }
476
+
477
+ if (!foundPath) {
478
+ throw new Error(
479
+ `Build directory not found. Tried: ${sourceDir}, ${altPaths.join(', ')}`
480
+ );
481
+ }
482
+ sourceDir = foundPath;
483
+ }
484
+
485
+ // Ensure output directory exists
486
+ if (!fs.existsSync(outputDir)) {
487
+ fs.mkdirSync(outputDir, { recursive: true });
488
+ }
489
+
490
+ await createZipFile(sourceDir, zipPath, verbose);
491
+
492
+ console.log(`šŸ“ Location: ${zipPath}`);
493
+ logDeploymentInstructions();
494
+ }
495
+
496
+ async function createZipFile(sourceDir, zipPath, verbose = false) {
497
+ // Create zip command based on platform
498
+ const isWindows = process.platform === 'win32';
499
+ let zipCommand;
500
+
501
+ if (isWindows) {
502
+ zipCommand = `powershell Compress-Archive -Path "${sourceDir}/*" -DestinationPath "${zipPath}" -Force`;
503
+ } else {
504
+ zipCommand = `cd "${sourceDir}" && zip -r "${path.resolve(zipPath)}" .`;
505
+ }
506
+
507
+ try {
508
+ execSync(zipCommand, { stdio: verbose ? 'inherit' : 'pipe' });
509
+
510
+ // Get file size
511
+ const stats = fs.statSync(zipPath);
512
+ const fileSizeInMB = (stats.size / (1024 * 1024)).toFixed(2);
513
+ console.log(`šŸ“ Size: ${fileSizeInMB} MB`);
514
+ } catch (error) {
515
+ console.error(`āŒ Failed to create zip file:`, error.message);
516
+
517
+ if (isWindows) {
518
+ console.log(`\nšŸ’” Alternative for Windows:`);
519
+ console.log(` 1. Manually zip the contents of: ${sourceDir}`);
520
+ console.log(` 2. Name the zip file: ${path.basename(zipPath)}`);
521
+ } else {
522
+ console.log(`\nšŸ’” Alternative:`);
523
+ console.log(
524
+ ` Install zip utility: sudo apt-get install zip (Ubuntu) or brew install zip (macOS)`
525
+ );
526
+ }
527
+
528
+ throw error;
529
+ }
530
+ }
531
+
532
+ function logDeploymentInstructions() {
533
+ console.log(`\nšŸ“‹ Deployment Instructions:`);
534
+ console.log(`1. Extract the zip file`);
535
+ console.log(`2. Upload contents directly to your web server root`);
536
+ console.log(`3. Ensure HTTPS is enabled (required for PWA)`);
537
+ console.log(`4. The app will automatically register the service worker`);
538
+ }
539
+
540
+ module.exports = zipCommand;
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@magmonium/cli",
3
+ "version": "0.7.8",
4
+ "description": "A powerful and extensible asset compilation tool that can be shared across multiple projects",
5
+ "bin": {
6
+ "mag-cli": "bin/cli.js"
7
+ },
8
+ "main": "./src/index.js",
9
+ "types": "./src/index.d.ts",
10
+ "files": [
11
+ "src/**/*",
12
+ "bin/**/*",
13
+ "templates/**/*",
14
+ "README.md"
15
+ ],
16
+ "keywords": [
17
+ "build-tool",
18
+ "asset-compilation",
19
+ "svg",
20
+ "scss",
21
+ "i18n",
22
+ "cli",
23
+ "magmonium"
24
+ ],
25
+ "author": "magmonium",
26
+ "license": "MIT",
27
+ "repository": {
28
+ "type": "git",
29
+ "url": "git+https://github.com/magmonium/nx.git",
30
+ "directory": "libs/cli"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "dependencies": {
36
+ "ajv": "^8.0.0",
37
+ "chalk": "^4.1.2",
38
+ "chokidar": "^3.5.3 || ^5.0.0",
39
+ "commander": "^11.0.0",
40
+ "esbuild": "0.27.3",
41
+ "fs-extra": "^11.1.1",
42
+ "glob": "^10.3.10",
43
+ "inquirer": "^8.2.6",
44
+ "ollama": "^0.5.0",
45
+ "png-to-ico": "^3.0.1",
46
+ "sass": "^1.69.5",
47
+ "sharp": "^0.34.5",
48
+ "tsc-alias": "^1.8.16",
49
+ "tslib": "^2.3.0",
50
+ "yaml": "^2.3.4"
51
+ },
52
+ "type": "commonjs"
53
+ }
@@ -0,0 +1,18 @@
1
+ import { BaseCompiler } from '../core/base-compiler';
2
+ import { ButtonGroupCompilerConfig } from '../core/config';
3
+ export declare class ButtonGroupCompiler extends BaseCompiler {
4
+ private watcher;
5
+ private readonly buttonsDir;
6
+ private readonly lookupDirs;
7
+ constructor(config: ButtonGroupCompilerConfig);
8
+ compile(): Promise<void>;
9
+ watch(): Promise<void>;
10
+ private findYAMLFiles;
11
+ private loadAllCompiledButtons;
12
+ private processYAMLFiles;
13
+ private processButtons;
14
+ private writeButtonGroupFiles;
15
+ private isYAMLFile;
16
+ private omitProperty;
17
+ }
18
+ //# sourceMappingURL=button-group-compiler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-group-compiler.d.ts","sourceRoot":"","sources":["../../../../../libs/cli/src/compilers/button-group-compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,EAAE,yBAAyB,EAAE,MAAM,gBAAgB,CAAC;AA+B3D,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,OAAO,CAAC,OAAO,CAA4B;IAC3C,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IACpC,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAW;gBAE1B,MAAM,EAAE,yBAAyB;IASvC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAgCxB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAuBd,aAAa;YAeb,sBAAsB;YA4CtB,gBAAgB;IAwC9B,OAAO,CAAC,cAAc;YAyBR,qBAAqB;IAenC,OAAO,CAAC,UAAU;IAKlB,OAAO,CAAC,YAAY;CAQrB"}