@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.
- package/README.md +41 -95
- package/bin/cicd/cli.d.ts +6 -0
- package/bin/cicd/cli.js +128 -0
- package/bin/cicd/form.d.ts +29 -0
- package/bin/cicd/form.js +346 -0
- package/bin/cicd/generators/azure-devops.d.ts +2 -0
- package/bin/cicd/generators/azure-devops.js +370 -0
- package/bin/cicd/generators/bitbucket.d.ts +2 -0
- package/bin/cicd/generators/bitbucket.js +217 -0
- package/bin/cicd/generators/circleci.d.ts +2 -0
- package/bin/cicd/generators/circleci.js +274 -0
- package/bin/cicd/generators/github-actions.d.ts +14 -0
- package/bin/cicd/generators/github-actions.js +426 -0
- package/bin/cicd/generators/gitlab-ci.d.ts +2 -0
- package/bin/cicd/generators/gitlab-ci.js +237 -0
- package/bin/cicd/generators/index.d.ts +6 -0
- package/bin/cicd/generators/index.js +15 -0
- package/bin/cicd/generators/jenkins.d.ts +2 -0
- package/bin/cicd/generators/jenkins.js +248 -0
- package/bin/cicd/generators/template-loader.d.ts +17 -0
- package/bin/cicd/generators/template-loader.js +128 -0
- package/bin/cicd/index.d.ts +1 -0
- package/bin/cicd/index.js +5 -0
- package/bin/cli.d.ts +1 -5
- package/bin/cli.js +72 -7
- package/bin/commands/project.commands.d.ts +19 -6
- package/bin/commands/project.commands.js +602 -66
- package/bin/config/index.d.ts +5 -0
- package/bin/config/index.js +10 -0
- package/bin/config/manager.d.ts +98 -0
- package/bin/config/manager.js +222 -0
- package/bin/containerize/analyzers/bootstrap-analyzer.d.ts +46 -0
- package/bin/containerize/analyzers/bootstrap-analyzer.js +187 -0
- package/bin/containerize/analyzers/project-analyzer.d.ts +20 -0
- package/bin/containerize/analyzers/project-analyzer.js +150 -0
- package/bin/containerize/cli.d.ts +4 -0
- package/bin/containerize/cli.js +113 -0
- package/bin/containerize/form.d.ts +15 -0
- package/bin/containerize/form.js +152 -0
- package/bin/containerize/generators/ci-generator.d.ts +31 -0
- package/bin/containerize/generators/ci-generator.js +940 -0
- package/bin/containerize/generators/docker-compose-generator.d.ts +8 -0
- package/bin/containerize/generators/docker-compose-generator.js +187 -0
- package/bin/containerize/generators/dockerfile-generator.d.ts +8 -0
- package/bin/containerize/generators/dockerfile-generator.js +657 -0
- package/bin/containerize/generators/kubernetes-generator.d.ts +8 -0
- package/bin/containerize/generators/kubernetes-generator.js +134 -0
- package/bin/containerize/generators/template-loader.d.ts +36 -0
- package/bin/containerize/generators/template-loader.js +129 -0
- package/bin/containerize/index.d.ts +4 -0
- package/bin/containerize/index.js +13 -0
- package/bin/containerize/presets/preset-registry.d.ts +20 -0
- package/bin/containerize/presets/preset-registry.js +102 -0
- package/bin/costs/cli.d.ts +5 -0
- package/bin/costs/cli.js +185 -0
- package/bin/costs/form.d.ts +44 -0
- package/bin/costs/form.js +412 -0
- package/bin/costs/index.d.ts +4 -0
- package/bin/costs/index.js +25 -0
- package/bin/costs/pricing-manager.d.ts +84 -0
- package/bin/costs/pricing-manager.js +342 -0
- package/bin/costs/providers/index.d.ts +32 -0
- package/bin/costs/providers/index.js +153 -0
- package/bin/costs/sources/api-source.d.ts +10 -0
- package/bin/costs/sources/api-source.js +32 -0
- package/bin/costs/sources/index.d.ts +6 -0
- package/bin/costs/sources/index.js +15 -0
- package/bin/costs/sources/local-json-source.d.ts +23 -0
- package/bin/costs/sources/local-json-source.js +59 -0
- package/bin/costs/sources/remote-json-source.d.ts +11 -0
- package/bin/costs/sources/remote-json-source.js +53 -0
- package/bin/costs/types.d.ts +53 -0
- package/bin/costs/types.js +5 -0
- package/bin/dev/cli.d.ts +4 -0
- package/bin/dev/cli.js +136 -0
- package/bin/dev/form.d.ts +36 -0
- package/bin/dev/form.js +254 -0
- package/bin/dev/index.d.ts +1 -0
- package/bin/dev/index.js +5 -0
- package/bin/generate/cli.d.ts +1 -1
- package/bin/generate/cli.js +29 -2
- package/bin/generate/form.d.ts +5 -1
- package/bin/generate/form.js +3 -3
- package/bin/generate/templates/nonopinionated/config.tpl +12 -0
- package/bin/generate/templates/nonopinionated/event.tpl +10 -0
- package/bin/generate/templates/nonopinionated/guard.tpl +18 -0
- package/bin/generate/templates/nonopinionated/handler.tpl +12 -0
- package/bin/generate/templates/nonopinionated/interceptor.tpl +27 -0
- package/bin/generate/templates/opinionated/config.tpl +47 -0
- package/bin/generate/templates/opinionated/entity.tpl +1 -8
- package/bin/generate/templates/opinionated/event.tpl +15 -0
- package/bin/generate/templates/opinionated/guard.tpl +41 -0
- package/bin/generate/templates/opinionated/handler.tpl +23 -0
- package/bin/generate/templates/opinionated/interceptor.tpl +50 -0
- package/bin/generate/utils/command-utils.d.ts +20 -5
- package/bin/generate/utils/command-utils.js +145 -48
- package/bin/generate/utils/nonopininated-cmd.d.ts +10 -1
- package/bin/generate/utils/nonopininated-cmd.js +100 -1
- package/bin/generate/utils/opinionated-cmd.d.ts +10 -1
- package/bin/generate/utils/opinionated-cmd.js +128 -16
- package/bin/generate/utils/string-utils.d.ts +6 -0
- package/bin/generate/utils/string-utils.js +13 -1
- package/bin/help/cli.d.ts +1 -1
- package/bin/help/command-help-registry.d.ts +23 -0
- package/bin/help/command-help-registry.js +303 -0
- package/bin/help/command-help.d.ts +36 -0
- package/bin/help/command-help.js +56 -0
- package/bin/help/form.js +127 -22
- package/bin/help/main-help.d.ts +8 -0
- package/bin/help/main-help.js +126 -0
- package/bin/help/render.d.ts +32 -0
- package/bin/help/render.js +46 -0
- package/bin/info/cli.d.ts +1 -1
- package/bin/info/form.d.ts +1 -1
- package/bin/info/form.js +11 -11
- package/bin/migrate/analyzers/platform-detector.d.ts +14 -0
- package/bin/migrate/analyzers/platform-detector.js +116 -0
- package/bin/migrate/cli.d.ts +6 -0
- package/bin/migrate/cli.js +98 -0
- package/bin/migrate/form.d.ts +25 -0
- package/bin/migrate/form.js +348 -0
- package/bin/migrate/generators/compose-to-k8s.d.ts +2 -0
- package/bin/migrate/generators/compose-to-k8s.js +324 -0
- package/bin/migrate/generators/compose-to-railway.d.ts +2 -0
- package/bin/migrate/generators/compose-to-railway.js +138 -0
- package/bin/migrate/generators/compose-to-render.d.ts +2 -0
- package/bin/migrate/generators/compose-to-render.js +148 -0
- package/bin/migrate/generators/generic-migration.d.ts +9 -0
- package/bin/migrate/generators/generic-migration.js +221 -0
- package/bin/migrate/generators/heroku-to-fly.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-fly.js +291 -0
- package/bin/migrate/generators/heroku-to-railway.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-railway.js +283 -0
- package/bin/migrate/generators/heroku-to-render.d.ts +2 -0
- package/bin/migrate/generators/heroku-to-render.js +148 -0
- package/bin/migrate/generators/index.d.ts +7 -0
- package/bin/migrate/generators/index.js +17 -0
- package/bin/migrate/generators/template-loader.d.ts +21 -0
- package/bin/migrate/generators/template-loader.js +59 -0
- package/bin/migrate/index.d.ts +1 -0
- package/bin/migrate/index.js +5 -0
- package/bin/new/cli.d.ts +5 -1
- package/bin/new/cli.js +77 -14
- package/bin/new/form.d.ts +27 -4
- package/bin/new/form.js +605 -75
- package/bin/profile/analyzers/dockerfile-analyzer.d.ts +27 -0
- package/bin/profile/analyzers/dockerfile-analyzer.js +122 -0
- package/bin/profile/analyzers/image-analyzer.d.ts +19 -0
- package/bin/profile/analyzers/image-analyzer.js +85 -0
- package/bin/profile/cli.d.ts +4 -0
- package/bin/profile/cli.js +94 -0
- package/bin/profile/form.d.ts +56 -0
- package/bin/profile/form.js +401 -0
- package/bin/profile/index.d.ts +1 -0
- package/bin/profile/index.js +5 -0
- package/bin/profile/optimizers/index.d.ts +19 -0
- package/bin/profile/optimizers/index.js +137 -0
- package/bin/providers/add/form.d.ts +1 -1
- package/bin/providers/add/form.js +27 -6
- package/bin/providers/create/form.js +53 -3
- package/bin/scripts/form.js +27 -5
- package/bin/studio/cli.d.ts +15 -0
- package/bin/studio/cli.js +172 -0
- package/bin/studio/index.d.ts +5 -0
- package/bin/studio/index.js +9 -0
- package/bin/templates/cache.d.ts +54 -0
- package/bin/templates/cache.js +180 -0
- package/bin/templates/cli.d.ts +8 -0
- package/bin/templates/cli.js +294 -0
- package/bin/templates/fetcher.d.ts +49 -0
- package/bin/templates/fetcher.js +208 -0
- package/bin/templates/index.d.ts +11 -0
- package/bin/templates/index.js +37 -0
- package/bin/templates/manager.d.ts +116 -0
- package/bin/templates/manager.js +323 -0
- package/bin/templates/renderer.d.ts +49 -0
- package/bin/templates/renderer.js +204 -0
- package/bin/templates/types.d.ts +51 -0
- package/bin/templates/types.js +5 -0
- package/bin/utils/add-module-to-container.d.ts +14 -3
- package/bin/utils/add-module-to-container.js +327 -98
- package/bin/utils/cli-ui.d.ts +49 -3
- package/bin/utils/cli-ui.js +133 -13
- package/bin/utils/index.d.ts +4 -0
- package/bin/utils/index.js +4 -0
- package/bin/utils/input-validation.d.ts +50 -0
- package/bin/utils/input-validation.js +143 -0
- package/bin/utils/package-manager-commands.d.ts +24 -0
- package/bin/utils/package-manager-commands.js +50 -0
- package/bin/utils/safe-spawn.d.ts +35 -0
- package/bin/utils/safe-spawn.js +51 -0
- package/bin/utils/update-tsconfig-paths.d.ts +35 -0
- package/bin/utils/update-tsconfig-paths.js +326 -0
- 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 {};
|