@expressots/cli 3.0.0 → 4.0.0-preview.3

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 (194) hide show
  1. package/README.md +41 -95
  2. package/bin/cicd/cli.d.ts +6 -0
  3. package/bin/cicd/cli.js +128 -0
  4. package/bin/cicd/form.d.ts +29 -0
  5. package/bin/cicd/form.js +346 -0
  6. package/bin/cicd/generators/azure-devops.d.ts +2 -0
  7. package/bin/cicd/generators/azure-devops.js +370 -0
  8. package/bin/cicd/generators/bitbucket.d.ts +2 -0
  9. package/bin/cicd/generators/bitbucket.js +217 -0
  10. package/bin/cicd/generators/circleci.d.ts +2 -0
  11. package/bin/cicd/generators/circleci.js +274 -0
  12. package/bin/cicd/generators/github-actions.d.ts +14 -0
  13. package/bin/cicd/generators/github-actions.js +426 -0
  14. package/bin/cicd/generators/gitlab-ci.d.ts +2 -0
  15. package/bin/cicd/generators/gitlab-ci.js +237 -0
  16. package/bin/cicd/generators/index.d.ts +6 -0
  17. package/bin/cicd/generators/index.js +15 -0
  18. package/bin/cicd/generators/jenkins.d.ts +2 -0
  19. package/bin/cicd/generators/jenkins.js +248 -0
  20. package/bin/cicd/generators/template-loader.d.ts +17 -0
  21. package/bin/cicd/generators/template-loader.js +128 -0
  22. package/bin/cicd/index.d.ts +1 -0
  23. package/bin/cicd/index.js +5 -0
  24. package/bin/cli.d.ts +1 -5
  25. package/bin/cli.js +72 -7
  26. package/bin/commands/project.commands.d.ts +19 -6
  27. package/bin/commands/project.commands.js +602 -66
  28. package/bin/config/index.d.ts +5 -0
  29. package/bin/config/index.js +10 -0
  30. package/bin/config/manager.d.ts +98 -0
  31. package/bin/config/manager.js +222 -0
  32. package/bin/containerize/analyzers/bootstrap-analyzer.d.ts +46 -0
  33. package/bin/containerize/analyzers/bootstrap-analyzer.js +187 -0
  34. package/bin/containerize/analyzers/project-analyzer.d.ts +20 -0
  35. package/bin/containerize/analyzers/project-analyzer.js +150 -0
  36. package/bin/containerize/cli.d.ts +4 -0
  37. package/bin/containerize/cli.js +113 -0
  38. package/bin/containerize/form.d.ts +15 -0
  39. package/bin/containerize/form.js +152 -0
  40. package/bin/containerize/generators/ci-generator.d.ts +31 -0
  41. package/bin/containerize/generators/ci-generator.js +940 -0
  42. package/bin/containerize/generators/docker-compose-generator.d.ts +8 -0
  43. package/bin/containerize/generators/docker-compose-generator.js +187 -0
  44. package/bin/containerize/generators/dockerfile-generator.d.ts +8 -0
  45. package/bin/containerize/generators/dockerfile-generator.js +657 -0
  46. package/bin/containerize/generators/kubernetes-generator.d.ts +8 -0
  47. package/bin/containerize/generators/kubernetes-generator.js +134 -0
  48. package/bin/containerize/generators/template-loader.d.ts +36 -0
  49. package/bin/containerize/generators/template-loader.js +129 -0
  50. package/bin/containerize/index.d.ts +4 -0
  51. package/bin/containerize/index.js +13 -0
  52. package/bin/containerize/presets/preset-registry.d.ts +20 -0
  53. package/bin/containerize/presets/preset-registry.js +102 -0
  54. package/bin/costs/cli.d.ts +5 -0
  55. package/bin/costs/cli.js +185 -0
  56. package/bin/costs/form.d.ts +44 -0
  57. package/bin/costs/form.js +412 -0
  58. package/bin/costs/index.d.ts +4 -0
  59. package/bin/costs/index.js +25 -0
  60. package/bin/costs/pricing-manager.d.ts +84 -0
  61. package/bin/costs/pricing-manager.js +342 -0
  62. package/bin/costs/providers/index.d.ts +32 -0
  63. package/bin/costs/providers/index.js +153 -0
  64. package/bin/costs/sources/api-source.d.ts +10 -0
  65. package/bin/costs/sources/api-source.js +32 -0
  66. package/bin/costs/sources/index.d.ts +6 -0
  67. package/bin/costs/sources/index.js +15 -0
  68. package/bin/costs/sources/local-json-source.d.ts +23 -0
  69. package/bin/costs/sources/local-json-source.js +59 -0
  70. package/bin/costs/sources/remote-json-source.d.ts +11 -0
  71. package/bin/costs/sources/remote-json-source.js +53 -0
  72. package/bin/costs/types.d.ts +53 -0
  73. package/bin/costs/types.js +5 -0
  74. package/bin/dev/cli.d.ts +4 -0
  75. package/bin/dev/cli.js +136 -0
  76. package/bin/dev/form.d.ts +36 -0
  77. package/bin/dev/form.js +254 -0
  78. package/bin/dev/index.d.ts +1 -0
  79. package/bin/dev/index.js +5 -0
  80. package/bin/generate/cli.d.ts +1 -1
  81. package/bin/generate/cli.js +29 -2
  82. package/bin/generate/form.d.ts +5 -1
  83. package/bin/generate/form.js +3 -3
  84. package/bin/generate/templates/nonopinionated/config.tpl +12 -0
  85. package/bin/generate/templates/nonopinionated/event.tpl +10 -0
  86. package/bin/generate/templates/nonopinionated/guard.tpl +18 -0
  87. package/bin/generate/templates/nonopinionated/handler.tpl +12 -0
  88. package/bin/generate/templates/nonopinionated/interceptor.tpl +27 -0
  89. package/bin/generate/templates/opinionated/config.tpl +47 -0
  90. package/bin/generate/templates/opinionated/entity.tpl +1 -8
  91. package/bin/generate/templates/opinionated/event.tpl +15 -0
  92. package/bin/generate/templates/opinionated/guard.tpl +41 -0
  93. package/bin/generate/templates/opinionated/handler.tpl +23 -0
  94. package/bin/generate/templates/opinionated/interceptor.tpl +50 -0
  95. package/bin/generate/utils/command-utils.d.ts +20 -5
  96. package/bin/generate/utils/command-utils.js +145 -48
  97. package/bin/generate/utils/nonopininated-cmd.d.ts +10 -1
  98. package/bin/generate/utils/nonopininated-cmd.js +100 -1
  99. package/bin/generate/utils/opinionated-cmd.d.ts +10 -1
  100. package/bin/generate/utils/opinionated-cmd.js +128 -16
  101. package/bin/generate/utils/string-utils.d.ts +6 -0
  102. package/bin/generate/utils/string-utils.js +13 -1
  103. package/bin/help/cli.d.ts +1 -1
  104. package/bin/help/command-help-registry.d.ts +23 -0
  105. package/bin/help/command-help-registry.js +303 -0
  106. package/bin/help/command-help.d.ts +36 -0
  107. package/bin/help/command-help.js +56 -0
  108. package/bin/help/form.js +127 -22
  109. package/bin/help/main-help.d.ts +8 -0
  110. package/bin/help/main-help.js +126 -0
  111. package/bin/help/render.d.ts +32 -0
  112. package/bin/help/render.js +46 -0
  113. package/bin/info/cli.d.ts +1 -1
  114. package/bin/info/form.d.ts +1 -1
  115. package/bin/info/form.js +11 -11
  116. package/bin/migrate/analyzers/platform-detector.d.ts +14 -0
  117. package/bin/migrate/analyzers/platform-detector.js +116 -0
  118. package/bin/migrate/cli.d.ts +6 -0
  119. package/bin/migrate/cli.js +98 -0
  120. package/bin/migrate/form.d.ts +25 -0
  121. package/bin/migrate/form.js +348 -0
  122. package/bin/migrate/generators/compose-to-k8s.d.ts +2 -0
  123. package/bin/migrate/generators/compose-to-k8s.js +324 -0
  124. package/bin/migrate/generators/compose-to-railway.d.ts +2 -0
  125. package/bin/migrate/generators/compose-to-railway.js +138 -0
  126. package/bin/migrate/generators/compose-to-render.d.ts +2 -0
  127. package/bin/migrate/generators/compose-to-render.js +148 -0
  128. package/bin/migrate/generators/generic-migration.d.ts +9 -0
  129. package/bin/migrate/generators/generic-migration.js +221 -0
  130. package/bin/migrate/generators/heroku-to-fly.d.ts +2 -0
  131. package/bin/migrate/generators/heroku-to-fly.js +291 -0
  132. package/bin/migrate/generators/heroku-to-railway.d.ts +2 -0
  133. package/bin/migrate/generators/heroku-to-railway.js +283 -0
  134. package/bin/migrate/generators/heroku-to-render.d.ts +2 -0
  135. package/bin/migrate/generators/heroku-to-render.js +148 -0
  136. package/bin/migrate/generators/index.d.ts +7 -0
  137. package/bin/migrate/generators/index.js +17 -0
  138. package/bin/migrate/generators/template-loader.d.ts +21 -0
  139. package/bin/migrate/generators/template-loader.js +59 -0
  140. package/bin/migrate/index.d.ts +1 -0
  141. package/bin/migrate/index.js +5 -0
  142. package/bin/new/cli.d.ts +5 -1
  143. package/bin/new/cli.js +77 -14
  144. package/bin/new/form.d.ts +27 -4
  145. package/bin/new/form.js +605 -75
  146. package/bin/profile/analyzers/dockerfile-analyzer.d.ts +27 -0
  147. package/bin/profile/analyzers/dockerfile-analyzer.js +122 -0
  148. package/bin/profile/analyzers/image-analyzer.d.ts +19 -0
  149. package/bin/profile/analyzers/image-analyzer.js +85 -0
  150. package/bin/profile/cli.d.ts +4 -0
  151. package/bin/profile/cli.js +94 -0
  152. package/bin/profile/form.d.ts +56 -0
  153. package/bin/profile/form.js +401 -0
  154. package/bin/profile/index.d.ts +1 -0
  155. package/bin/profile/index.js +5 -0
  156. package/bin/profile/optimizers/index.d.ts +19 -0
  157. package/bin/profile/optimizers/index.js +137 -0
  158. package/bin/providers/add/form.d.ts +1 -1
  159. package/bin/providers/add/form.js +27 -6
  160. package/bin/providers/create/form.js +53 -3
  161. package/bin/scripts/form.js +27 -5
  162. package/bin/studio/cli.d.ts +15 -0
  163. package/bin/studio/cli.js +172 -0
  164. package/bin/studio/index.d.ts +5 -0
  165. package/bin/studio/index.js +9 -0
  166. package/bin/templates/cache.d.ts +54 -0
  167. package/bin/templates/cache.js +180 -0
  168. package/bin/templates/cli.d.ts +8 -0
  169. package/bin/templates/cli.js +294 -0
  170. package/bin/templates/fetcher.d.ts +49 -0
  171. package/bin/templates/fetcher.js +208 -0
  172. package/bin/templates/index.d.ts +11 -0
  173. package/bin/templates/index.js +37 -0
  174. package/bin/templates/manager.d.ts +116 -0
  175. package/bin/templates/manager.js +323 -0
  176. package/bin/templates/renderer.d.ts +49 -0
  177. package/bin/templates/renderer.js +204 -0
  178. package/bin/templates/types.d.ts +51 -0
  179. package/bin/templates/types.js +5 -0
  180. package/bin/utils/add-module-to-container.d.ts +14 -3
  181. package/bin/utils/add-module-to-container.js +327 -98
  182. package/bin/utils/cli-ui.d.ts +49 -3
  183. package/bin/utils/cli-ui.js +133 -13
  184. package/bin/utils/index.d.ts +4 -0
  185. package/bin/utils/index.js +4 -0
  186. package/bin/utils/input-validation.d.ts +50 -0
  187. package/bin/utils/input-validation.js +143 -0
  188. package/bin/utils/package-manager-commands.d.ts +24 -0
  189. package/bin/utils/package-manager-commands.js +50 -0
  190. package/bin/utils/safe-spawn.d.ts +35 -0
  191. package/bin/utils/safe-spawn.js +51 -0
  192. package/bin/utils/update-tsconfig-paths.d.ts +35 -0
  193. package/bin/utils/update-tsconfig-paths.js +326 -0
  194. package/package.json +165 -156
@@ -0,0 +1,8 @@
1
+ import type { ProjectAnalysis } from "../analyzers/project-analyzer";
2
+ type GeneratorOptions = {
3
+ environment: string;
4
+ preset: string;
5
+ [key: string]: any;
6
+ };
7
+ export declare function generateDockerCompose(options: GeneratorOptions, analysis?: ProjectAnalysis): Promise<void>;
8
+ export {};
@@ -0,0 +1,187 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.generateDockerCompose = void 0;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const chalk_1 = __importDefault(require("chalk"));
10
+ const template_loader_1 = require("./template-loader");
11
+ const bootstrap_analyzer_1 = require("../analyzers/bootstrap-analyzer");
12
+ const cli_ui_1 = require("../../utils/cli-ui");
13
+ async function generateDockerCompose(options, analysis) {
14
+ const cwd = process.cwd();
15
+ (0, cli_ui_1.printSection)(`📝 Generating docker-compose.yml`);
16
+ // Always generate production docker-compose.yml plus environment-specific if needed
17
+ const environments = options.environment === "all"
18
+ ? ["development", "production"]
19
+ : options.environment === "development"
20
+ ? ["development", "production"] // Also generate production compose
21
+ : [options.environment];
22
+ for (const env of environments) {
23
+ const templateType = env === "production" ? "compose" : "compose-development";
24
+ const vars = {
25
+ nodeVersion: analysis?.nodeVersion || "20",
26
+ packageManager: "npm",
27
+ entryPoint: "dist/src/main.js",
28
+ port: analysis?.port || 3000,
29
+ hasLocalDeps: analysis?.hasLocalDependencies || false,
30
+ healthCheckEndpoint: analysis?.healthCheckPaths?.[0] || "/health",
31
+ projectName: "expressots-app",
32
+ installCommand: "npm ci",
33
+ buildCommand: "npm run build",
34
+ };
35
+ // Try remote template, fall back to embedded
36
+ const result = await (0, template_loader_1.loadDockerTemplate)(templateType, vars, () => generateDockerComposeContent(env, analysis));
37
+ (0, template_loader_1.logTemplateSource)(`docker-compose.${env}`, result.source);
38
+ const filename = env === "production"
39
+ ? "docker-compose.yml"
40
+ : `docker-compose.${env}.yml`;
41
+ const filepath = path_1.default.join(cwd, filename);
42
+ fs_1.default.writeFileSync(filepath, result.content, "utf-8");
43
+ (0, cli_ui_1.printBullet)(chalk_1.default.green(`✓ Created ${filename}`));
44
+ }
45
+ }
46
+ exports.generateDockerCompose = generateDockerCompose;
47
+ function generateDockerComposeContent(environment, analysis) {
48
+ const port = analysis?.port || 3000;
49
+ const hasDatabase = analysis?.hasDatabase || false;
50
+ const hasRedis = analysis?.hasRedis || false;
51
+ const bootstrapConfig = analysis?.bootstrapConfig;
52
+ const services = [];
53
+ // App service
54
+ const appService = generateAppService(environment, port, hasDatabase, hasRedis, bootstrapConfig);
55
+ services.push(appService);
56
+ // Database service
57
+ if (hasDatabase) {
58
+ services.push(generateDatabaseService(environment));
59
+ }
60
+ // Redis service
61
+ if (hasRedis) {
62
+ services.push(generateRedisService(environment));
63
+ }
64
+ return `# Docker Compose configuration
65
+ # Generated by ExpressoTS CLI
66
+ # Environment: ${environment}
67
+
68
+ version: '3.8'
69
+
70
+ services:
71
+ ${services.join("\n\n")}
72
+
73
+ ${hasDatabase || hasRedis
74
+ ? `
75
+ volumes:
76
+ ${hasDatabase ? " postgres_data:\n driver: local\n" : ""}${hasRedis ? " redis_data:\n driver: local\n" : ""}
77
+ `
78
+ : ""}
79
+ ${generateNetworkConfig()}
80
+ `;
81
+ }
82
+ function generateAppService(environment, port, hasDatabase, hasRedis, bootstrapConfig) {
83
+ const isDev = environment === "development";
84
+ const dockerfile = isDev ? "Dockerfile.development" : "Dockerfile";
85
+ // Check if we should use env_file
86
+ const useEnvFile = bootstrapConfig && (0, bootstrap_analyzer_1.shouldCopyEnvFiles)(bootstrapConfig);
87
+ const envFile = bootstrapConfig
88
+ ? (0, bootstrap_analyzer_1.getEnvFileForEnvironment)(bootstrapConfig, environment)
89
+ : null;
90
+ const envFileExists = envFile && bootstrapConfig?.existingEnvFiles.includes(envFile);
91
+ let service = ` app:
92
+ build:
93
+ context: .
94
+ dockerfile: ${dockerfile}
95
+ container_name: expressots-app-${environment}
96
+ ports:
97
+ - "${port}:${port}"${isDev ? `\n - "9229:9229" # Debug port` : ""}`;
98
+ // env_file section (if bootstrap config requires it)
99
+ if (useEnvFile && envFileExists) {
100
+ service += `\n env_file:
101
+ - ${envFile}`;
102
+ // Also include .env if it exists
103
+ if (bootstrapConfig?.existingEnvFiles.includes(".env") &&
104
+ envFile !== ".env") {
105
+ service += `\n - .env`;
106
+ }
107
+ }
108
+ // Environment variables (always include these, they override env_file)
109
+ service += `\n environment:
110
+ - NODE_ENV=${environment}
111
+ - PORT=${port}`;
112
+ if (hasDatabase) {
113
+ service += `\n - DATABASE_URL=postgresql://postgres:password@db:5432/expressots`;
114
+ }
115
+ if (hasRedis) {
116
+ service += `\n - REDIS_URL=redis://redis:6379`;
117
+ }
118
+ // Add required variables as placeholders if not using env_file
119
+ if (!useEnvFile && bootstrapConfig?.requiredVariables.length) {
120
+ service += `\n # Required variables from bootstrap config (set your values):`;
121
+ for (const varName of bootstrapConfig.requiredVariables) {
122
+ // Skip if already added (DATABASE_URL, REDIS_URL)
123
+ if (varName !== "DATABASE_URL" && varName !== "REDIS_URL") {
124
+ service += `\n - ${varName}=\${${varName}:-}`;
125
+ }
126
+ }
127
+ }
128
+ // Volumes (for dev with hot reload)
129
+ if (isDev) {
130
+ service += `\n volumes:
131
+ - ./src:/app/src
132
+ - /app/node_modules`;
133
+ // Mount env file for hot reload if using env files
134
+ if (useEnvFile && envFileExists) {
135
+ service += `\n - ./${envFile}:/app/${envFile}:ro`;
136
+ }
137
+ }
138
+ // Dependencies
139
+ if (hasDatabase || hasRedis) {
140
+ service += `\n depends_on:`;
141
+ if (hasDatabase)
142
+ service += `\n - db`;
143
+ if (hasRedis)
144
+ service += `\n - redis`;
145
+ }
146
+ service += `\n networks:
147
+ - expressots-network`;
148
+ // Restart policy
149
+ if (!isDev) {
150
+ service += `\n restart: unless-stopped`;
151
+ }
152
+ return service;
153
+ }
154
+ function generateDatabaseService(environment) {
155
+ return ` db:
156
+ image: postgres:16-alpine
157
+ container_name: expressots-db-${environment}
158
+ environment:
159
+ - POSTGRES_USER=postgres
160
+ - POSTGRES_PASSWORD=password
161
+ - POSTGRES_DB=expressots
162
+ ports:
163
+ - "5432:5432"
164
+ volumes:
165
+ - postgres_data:/var/lib/postgresql/data
166
+ networks:
167
+ - expressots-network
168
+ ${environment !== "development" ? "restart: unless-stopped" : ""}`;
169
+ }
170
+ function generateRedisService(environment) {
171
+ return ` redis:
172
+ image: redis:7-alpine
173
+ container_name: expressots-redis-${environment}
174
+ ports:
175
+ - "6379:6379"
176
+ volumes:
177
+ - redis_data:/data
178
+ networks:
179
+ - expressots-network
180
+ ${environment !== "development" ? "restart: unless-stopped" : ""}`;
181
+ }
182
+ function generateNetworkConfig() {
183
+ return `networks:
184
+ expressots-network:
185
+ driver: bridge
186
+ `;
187
+ }
@@ -0,0 +1,8 @@
1
+ import type { ProjectAnalysis } from "../analyzers/project-analyzer";
2
+ type GeneratorOptions = {
3
+ environment: string;
4
+ preset: string;
5
+ [key: string]: any;
6
+ };
7
+ export declare function generateDockerfiles(options: GeneratorOptions, analysis?: ProjectAnalysis): Promise<void>;
8
+ export {};