@turboops/cli 1.0.0-dev.612 → 1.0.0-dev.614
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/dist/index.js +162 -42
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2116,16 +2116,24 @@ volumes:
|
|
|
2116
2116
|
\`\`\`
|
|
2117
2117
|
|
|
2118
2118
|
2. Dockerfile f\xFCr jeden Service (im jeweiligen Ordner)
|
|
2119
|
+
KRITISCH: IMMER --ignore-scripts bei npm ci verwenden!
|
|
2119
2120
|
\`\`\`dockerfile
|
|
2120
|
-
#
|
|
2121
|
-
FROM node:
|
|
2121
|
+
# Stage 1: Dependencies
|
|
2122
|
+
FROM node:22-alpine AS deps
|
|
2122
2123
|
WORKDIR /app
|
|
2123
2124
|
COPY package*.json ./
|
|
2124
|
-
|
|
2125
|
+
# KRITISCH: --ignore-scripts verhindert husky/prepare Fehler in Docker!
|
|
2126
|
+
RUN npm ci --ignore-scripts
|
|
2127
|
+
|
|
2128
|
+
# Stage 2: Builder
|
|
2129
|
+
FROM node:22-alpine AS builder
|
|
2130
|
+
WORKDIR /app
|
|
2131
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
2125
2132
|
COPY . .
|
|
2126
2133
|
RUN npm run build
|
|
2127
2134
|
|
|
2128
|
-
|
|
2135
|
+
# Stage 3: Runner (Production)
|
|
2136
|
+
FROM node:22-alpine AS runner
|
|
2129
2137
|
WORKDIR /app
|
|
2130
2138
|
ENV NODE_ENV=production
|
|
2131
2139
|
# Non-root user f\xFCr Sicherheit
|
|
@@ -2151,6 +2159,7 @@ coverage
|
|
|
2151
2159
|
\`\`\`
|
|
2152
2160
|
|
|
2153
2161
|
=== WICHTIGE REGELN ===
|
|
2162
|
+
- KRITISCH: IMMER \`npm ci --ignore-scripts\` verwenden (verhindert husky/prepare Fehler!)
|
|
2154
2163
|
- Pr\xFCfe die tats\xE4chliche Projektstruktur (projects/, packages/, apps/, oder flach)
|
|
2155
2164
|
- Passe Pfade entsprechend an
|
|
2156
2165
|
- NestJS: CMD ["node", "dist/main.js"]
|
|
@@ -2248,6 +2257,7 @@ PIPELINE-STRUKTUR:
|
|
|
2248
2257
|
- if: $CI_COMMIT_BRANCH # L\xE4uft auf ALLEN Branches!
|
|
2249
2258
|
|
|
2250
2259
|
2. DEPLOY-JOBS (jeder NUR auf seinem Branch!):
|
|
2260
|
+
WICHTIG: KEIN --image Flag n\xF6tig! Die CLI erkennt CI_COMMIT_SHA automatisch!
|
|
2251
2261
|
|
|
2252
2262
|
deploy-dev:
|
|
2253
2263
|
image: node:20-alpine
|
|
@@ -2255,21 +2265,21 @@ PIPELINE-STRUKTUR:
|
|
|
2255
2265
|
- npm install -g @turboops/cli
|
|
2256
2266
|
- turbo config set token \${TURBOOPS_TOKEN}
|
|
2257
2267
|
script:
|
|
2258
|
-
- turbo deploy dev --
|
|
2268
|
+
- turbo deploy dev --wait # CLI erkennt Image automatisch via CI_COMMIT_SHA
|
|
2259
2269
|
rules:
|
|
2260
2270
|
- if: $CI_COMMIT_BRANCH == "dev" # NUR auf dev Branch!
|
|
2261
2271
|
needs: [build]
|
|
2262
2272
|
|
|
2263
2273
|
deploy-test:
|
|
2264
2274
|
script:
|
|
2265
|
-
- turbo deploy test --wait
|
|
2275
|
+
- turbo deploy test --wait
|
|
2266
2276
|
rules:
|
|
2267
2277
|
- if: $CI_COMMIT_BRANCH == "test" # NUR auf test Branch!
|
|
2268
2278
|
needs: [deploy-dev]
|
|
2269
2279
|
|
|
2270
2280
|
deploy-prod:
|
|
2271
2281
|
script:
|
|
2272
|
-
- turbo deploy prod --wait
|
|
2282
|
+
- turbo deploy prod --wait
|
|
2273
2283
|
rules:
|
|
2274
2284
|
- if: $CI_COMMIT_BRANCH == "main" # NUR auf main Branch!
|
|
2275
2285
|
when: manual
|
|
@@ -2278,7 +2288,7 @@ PIPELINE-STRUKTUR:
|
|
|
2278
2288
|
WICHTIG:
|
|
2279
2289
|
- Der Build l\xE4uft auf ALLEN Branches (dev, test, main)
|
|
2280
2290
|
- Jeder Deploy-Job l\xE4uft NUR auf seinem zugeordneten Branch
|
|
2281
|
-
- --image
|
|
2291
|
+
- KEIN --image Flag n\xF6tig - CLI erkennt CI_COMMIT_SHA/GITHUB_SHA automatisch
|
|
2282
2292
|
- Registry-URL: registry.turbo-ops.de/${projectSlug}
|
|
2283
2293
|
- Secrets ben\xF6tigt: TURBOOPS_TOKEN
|
|
2284
2294
|
|
|
@@ -2302,17 +2312,58 @@ Erstelle die Datei "${pipelineFile}".`;
|
|
|
2302
2312
|
// src/commands/deploy.ts
|
|
2303
2313
|
import { Command as Command4 } from "commander";
|
|
2304
2314
|
import chalk6 from "chalk";
|
|
2305
|
-
var
|
|
2315
|
+
var REGISTRY_URL = "registry.turbo-ops.de";
|
|
2316
|
+
function detectCiCommitSha() {
|
|
2317
|
+
if (process.env.CI_COMMIT_SHA) {
|
|
2318
|
+
return process.env.CI_COMMIT_SHA;
|
|
2319
|
+
}
|
|
2320
|
+
if (process.env.GITHUB_SHA) {
|
|
2321
|
+
return process.env.GITHUB_SHA;
|
|
2322
|
+
}
|
|
2323
|
+
if (process.env.BITBUCKET_COMMIT) {
|
|
2324
|
+
return process.env.BITBUCKET_COMMIT;
|
|
2325
|
+
}
|
|
2326
|
+
if (process.env.BUILD_SOURCEVERSION) {
|
|
2327
|
+
return process.env.BUILD_SOURCEVERSION;
|
|
2328
|
+
}
|
|
2329
|
+
if (process.env.CIRCLE_SHA1) {
|
|
2330
|
+
return process.env.CIRCLE_SHA1;
|
|
2331
|
+
}
|
|
2332
|
+
if (process.env.GIT_COMMIT) {
|
|
2333
|
+
return process.env.GIT_COMMIT;
|
|
2334
|
+
}
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
function detectCiEnvironment() {
|
|
2338
|
+
if (process.env.GITLAB_CI) return "GitLab CI";
|
|
2339
|
+
if (process.env.GITHUB_ACTIONS) return "GitHub Actions";
|
|
2340
|
+
if (process.env.BITBUCKET_PIPELINES) return "Bitbucket Pipelines";
|
|
2341
|
+
if (process.env.TF_BUILD) return "Azure DevOps";
|
|
2342
|
+
if (process.env.CIRCLECI) return "CircleCI";
|
|
2343
|
+
if (process.env.JENKINS_URL) return "Jenkins";
|
|
2344
|
+
return null;
|
|
2345
|
+
}
|
|
2346
|
+
var deployCommand = new Command4("deploy").description("Trigger a deployment (for CI/CD pipelines)").argument("<environment>", "Environment slug (e.g., production, staging)").option("-i, --image <tag>", "Docker image tag to deploy (auto-detected in CI/CD)").option("-w, --wait", "Wait for deployment to complete", true).option("--no-wait", "Do not wait for deployment to complete").option(
|
|
2306
2347
|
"--timeout <ms>",
|
|
2307
2348
|
"Timeout in milliseconds when waiting",
|
|
2308
2349
|
"600000"
|
|
2309
2350
|
).action(async (environment, options) => {
|
|
2310
2351
|
const { project, environment: env } = await getCommandContextWithEnvironment(environment);
|
|
2311
2352
|
logger.header(`Deploying: ${project.name} \u2192 ${env.name}`);
|
|
2353
|
+
let imageTag = options.image;
|
|
2354
|
+
if (!imageTag) {
|
|
2355
|
+
const commitSha = detectCiCommitSha();
|
|
2356
|
+
const ciEnv = detectCiEnvironment();
|
|
2357
|
+
if (commitSha && ciEnv) {
|
|
2358
|
+
imageTag = `${REGISTRY_URL}/${project.slug}:${commitSha}`;
|
|
2359
|
+
logger.info(`CI/CD detected (${ciEnv})`);
|
|
2360
|
+
logger.info(`Auto-using image: ${imageTag}`);
|
|
2361
|
+
}
|
|
2362
|
+
}
|
|
2312
2363
|
logger.info("Triggering deployment...");
|
|
2313
2364
|
const { data: deployment, error } = await apiClient.deploy(
|
|
2314
2365
|
env.id,
|
|
2315
|
-
|
|
2366
|
+
imageTag
|
|
2316
2367
|
);
|
|
2317
2368
|
if (error) {
|
|
2318
2369
|
logger.error(`Failed to trigger deployment: ${error}`);
|
|
@@ -2328,7 +2379,7 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2328
2379
|
status: deployment.status,
|
|
2329
2380
|
environment: env.slug,
|
|
2330
2381
|
project: project.slug,
|
|
2331
|
-
imageTag:
|
|
2382
|
+
imageTag: imageTag || "auto-promotion"
|
|
2332
2383
|
});
|
|
2333
2384
|
if (!options.wait) {
|
|
2334
2385
|
logger.info("Deployment started. Use --wait to wait for completion.");
|
|
@@ -2583,23 +2634,55 @@ async function createDockerSetupWithAI2() {
|
|
|
2583
2634
|
|
|
2584
2635
|
**Wichtig: TurboOps ben\xF6tigt eine docker-compose.yml auf Root-Ebene!**
|
|
2585
2636
|
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2637
|
+
KRITISCHE ANFORDERUNGEN:
|
|
2638
|
+
|
|
2639
|
+
1. docker-compose.yml im Projekt-Root:
|
|
2640
|
+
- Services f\xFCr alle Komponenten (api, app, etc.)
|
|
2589
2641
|
- Verwende build-Direktive mit Pfad zu den Dockerfiles
|
|
2642
|
+
- KEINE version: Angabe (deprecated)
|
|
2590
2643
|
- Health-Checks f\xFCr alle Services
|
|
2591
|
-
- Production-geeignete Konfiguration
|
|
2592
2644
|
|
|
2593
|
-
2.
|
|
2594
|
-
- Multi-stage builds
|
|
2595
|
-
-
|
|
2596
|
-
-
|
|
2645
|
+
2. Dockerfiles - WICHTIGE REGELN:
|
|
2646
|
+
- Multi-stage builds (deps -> builder -> runner)
|
|
2647
|
+
- IMMER \`npm ci --ignore-scripts\` verwenden (verhindert husky/prepare Fehler!)
|
|
2648
|
+
- Non-root User f\xFCr Production
|
|
2649
|
+
- Minimales Base-Image (node:22-alpine)
|
|
2597
2650
|
|
|
2598
|
-
3.
|
|
2599
|
-
- node_modules, .git,
|
|
2651
|
+
3. .dockerignore auf Root-Ebene:
|
|
2652
|
+
- node_modules, .git, dist, .env*, *.log
|
|
2600
2653
|
|
|
2601
|
-
4.
|
|
2602
|
-
- Pr\xFCfe
|
|
2654
|
+
4. Monorepo-Struktur beachten:
|
|
2655
|
+
- Pr\xFCfe projects/, packages/, apps/ Ordner
|
|
2656
|
+
- Context muss Root sein f\xFCr Monorepo-Zugriff
|
|
2657
|
+
|
|
2658
|
+
DOCKERFILE-TEMPLATE (STRIKT EINHALTEN!):
|
|
2659
|
+
\`\`\`dockerfile
|
|
2660
|
+
# Stage 1: Dependencies
|
|
2661
|
+
FROM node:22-alpine AS deps
|
|
2662
|
+
WORKDIR /app
|
|
2663
|
+
COPY package*.json ./
|
|
2664
|
+
# WICHTIG: --ignore-scripts verhindert husky/prepare Fehler!
|
|
2665
|
+
RUN npm ci --ignore-scripts
|
|
2666
|
+
|
|
2667
|
+
# Stage 2: Builder
|
|
2668
|
+
FROM node:22-alpine AS builder
|
|
2669
|
+
WORKDIR /app
|
|
2670
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
2671
|
+
COPY . .
|
|
2672
|
+
RUN npm run build
|
|
2673
|
+
|
|
2674
|
+
# Stage 3: Runner (Production)
|
|
2675
|
+
FROM node:22-alpine AS runner
|
|
2676
|
+
WORKDIR /app
|
|
2677
|
+
ENV NODE_ENV=production
|
|
2678
|
+
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
|
|
2679
|
+
USER nodejs
|
|
2680
|
+
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
|
2681
|
+
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
2682
|
+
COPY --from=builder --chown=nodejs:nodejs /app/package.json ./
|
|
2683
|
+
EXPOSE 3000
|
|
2684
|
+
CMD ["node", "dist/main.js"]
|
|
2685
|
+
\`\`\`
|
|
2603
2686
|
|
|
2604
2687
|
Erstelle alle notwendigen Dateien.`;
|
|
2605
2688
|
const success = await aiToolsService.runWithPrompt(tool, prompt);
|
|
@@ -2629,17 +2712,19 @@ PIPELINE-STRUKTUR:
|
|
|
2629
2712
|
- Docker Images bauen mit docker-compose build
|
|
2630
2713
|
- Images pushen mit docker-compose push
|
|
2631
2714
|
- Registry: registry.turbo-ops.de/${projectSlug}
|
|
2715
|
+
- Image-Tag: \${CI_COMMIT_SHA} (wird automatisch von CLI erkannt)
|
|
2632
2716
|
|
|
2633
2717
|
2. Deploy-Jobs: Jeder Job l\xE4uft NUR auf seinem Branch!
|
|
2634
2718
|
- deploy-dev: rules: if: $CI_COMMIT_BRANCH == "dev"
|
|
2635
2719
|
- deploy-test: rules: if: $CI_COMMIT_BRANCH == "test"
|
|
2636
2720
|
- deploy-prod: rules: if: $CI_COMMIT_BRANCH == "main" (when: manual)
|
|
2637
2721
|
|
|
2638
|
-
DEPLOY-BEFEHLE:
|
|
2722
|
+
DEPLOY-BEFEHLE (WICHTIG: KEIN --image Flag n\xF6tig!):
|
|
2639
2723
|
- TurboOps CLI installieren: npm install -g @turboops/cli
|
|
2640
2724
|
- Token setzen: turbo config set token \${TURBOOPS_TOKEN}
|
|
2641
|
-
- Deploy
|
|
2642
|
-
|
|
2725
|
+
- Deploy: turbo deploy <stage> --wait
|
|
2726
|
+
|
|
2727
|
+
Die CLI erkennt automatisch CI_COMMIT_SHA/GITHUB_SHA und verwendet das richtige Image!
|
|
2643
2728
|
|
|
2644
2729
|
DEPENDENCIES:
|
|
2645
2730
|
- deploy-dev needs: [build]
|
|
@@ -2667,36 +2752,71 @@ var DOCKER_SETUP_PROMPT = `Analysiere dieses Projekt und erstelle ein vollst\xE4
|
|
|
2667
2752
|
|
|
2668
2753
|
**Wichtig: TurboOps ben\xF6tigt eine docker-compose.yml auf Root-Ebene!**
|
|
2669
2754
|
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2755
|
+
KRITISCHE ANFORDERUNGEN:
|
|
2756
|
+
|
|
2757
|
+
1. docker-compose.yml im Projekt-Root:
|
|
2758
|
+
- Services f\xFCr alle Komponenten (api, app, etc.)
|
|
2673
2759
|
- Verwende build-Direktive mit Pfad zu den Dockerfiles
|
|
2760
|
+
- KEINE version: Angabe (deprecated)
|
|
2674
2761
|
- Health-Checks f\xFCr alle Services
|
|
2675
|
-
- Production-geeignete Konfiguration
|
|
2676
2762
|
|
|
2677
|
-
2.
|
|
2678
|
-
- Multi-stage builds
|
|
2679
|
-
-
|
|
2680
|
-
-
|
|
2763
|
+
2. Dockerfiles - WICHTIGE REGELN:
|
|
2764
|
+
- Multi-stage builds (deps -> builder -> runner)
|
|
2765
|
+
- IMMER \`npm ci --ignore-scripts\` verwenden (verhindert husky/prepare Fehler!)
|
|
2766
|
+
- Non-root User f\xFCr Production
|
|
2767
|
+
- Minimales Base-Image (node:22-alpine)
|
|
2681
2768
|
|
|
2682
|
-
3.
|
|
2683
|
-
- node_modules, .git,
|
|
2769
|
+
3. .dockerignore auf Root-Ebene:
|
|
2770
|
+
- node_modules, .git, dist, .env*, *.log
|
|
2684
2771
|
|
|
2685
|
-
4.
|
|
2686
|
-
- Pr\xFCfe
|
|
2772
|
+
4. Monorepo-Struktur beachten:
|
|
2773
|
+
- Pr\xFCfe projects/, packages/, apps/ Ordner
|
|
2774
|
+
- Context muss Root sein f\xFCr Monorepo-Zugriff
|
|
2687
2775
|
|
|
2688
|
-
|
|
2776
|
+
DOCKERFILE-TEMPLATE (STRIKT EINHALTEN!):
|
|
2777
|
+
\`\`\`dockerfile
|
|
2778
|
+
# Stage 1: Dependencies
|
|
2779
|
+
FROM node:22-alpine AS deps
|
|
2780
|
+
WORKDIR /app
|
|
2781
|
+
COPY package*.json ./
|
|
2782
|
+
# WICHTIG: --ignore-scripts verhindert husky/prepare Fehler!
|
|
2783
|
+
RUN npm ci --ignore-scripts
|
|
2784
|
+
|
|
2785
|
+
# Stage 2: Builder
|
|
2786
|
+
FROM node:22-alpine AS builder
|
|
2787
|
+
WORKDIR /app
|
|
2788
|
+
COPY --from=deps /app/node_modules ./node_modules
|
|
2789
|
+
COPY . .
|
|
2790
|
+
RUN npm run build
|
|
2791
|
+
|
|
2792
|
+
# Stage 3: Runner (Production)
|
|
2793
|
+
FROM node:22-alpine AS runner
|
|
2794
|
+
WORKDIR /app
|
|
2795
|
+
ENV NODE_ENV=production
|
|
2796
|
+
|
|
2797
|
+
# Non-root user
|
|
2798
|
+
RUN addgroup -g 1001 -S nodejs && adduser -S nodejs -u 1001
|
|
2799
|
+
USER nodejs
|
|
2800
|
+
|
|
2801
|
+
COPY --from=builder --chown=nodejs:nodejs /app/dist ./dist
|
|
2802
|
+
COPY --from=builder --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
2803
|
+
COPY --from=builder --chown=nodejs:nodejs /app/package.json ./
|
|
2804
|
+
|
|
2805
|
+
EXPOSE 3000
|
|
2806
|
+
CMD ["node", "dist/main.js"]
|
|
2807
|
+
\`\`\`
|
|
2808
|
+
|
|
2809
|
+
docker-compose.yml TEMPLATE:
|
|
2689
2810
|
\`\`\`yaml
|
|
2690
|
-
version: '3.8'
|
|
2691
2811
|
services:
|
|
2692
2812
|
api:
|
|
2693
2813
|
build:
|
|
2694
2814
|
context: .
|
|
2695
|
-
dockerfile:
|
|
2815
|
+
dockerfile: projects/api/Dockerfile
|
|
2696
2816
|
ports:
|
|
2697
2817
|
- "3000:3000"
|
|
2698
2818
|
healthcheck:
|
|
2699
|
-
test: ["CMD", "
|
|
2819
|
+
test: ["CMD", "wget", "-q", "--spider", "http://localhost:3000/health"]
|
|
2700
2820
|
interval: 30s
|
|
2701
2821
|
timeout: 10s
|
|
2702
2822
|
retries: 3
|