@expressots/cli 3.0.0 → 4.0.0-preview.2

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