@turboops/cli 1.0.0-dev.611 → 1.0.0-dev.613
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 +128 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2226,23 +2226,62 @@ Modifiziere die Datei "${pipelineFile}" entsprechend.` : `Erstelle eine neue ${p
|
|
|
2226
2226
|
Projekt-Slug: ${projectSlug}
|
|
2227
2227
|
Pipeline-Datei: ${pipelineFile}
|
|
2228
2228
|
|
|
2229
|
-
|
|
2230
|
-
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
-
|
|
2244
|
-
|
|
2245
|
-
|
|
2229
|
+
WICHTIG - Branch-zu-Stage-Zuordnung (STRIKT EINHALTEN!):
|
|
2230
|
+
- dev Stage \u2192 deployed NUR wenn Branch == "dev"
|
|
2231
|
+
- test Stage \u2192 deployed NUR wenn Branch == "test"
|
|
2232
|
+
- prod Stage \u2192 deployed NUR wenn Branch == "main"
|
|
2233
|
+
|
|
2234
|
+
PIPELINE-STRUKTUR:
|
|
2235
|
+
|
|
2236
|
+
1. BUILD-JOB (l\xE4uft auf ALLEN Branches: dev, test, main):
|
|
2237
|
+
stages: [build, deploy-dev, deploy-test, deploy-prod]
|
|
2238
|
+
|
|
2239
|
+
build:
|
|
2240
|
+
image: docker:24-dind
|
|
2241
|
+
services: [docker:24-dind]
|
|
2242
|
+
before_script:
|
|
2243
|
+
- docker login -u ${projectSlug} -p \${TURBOOPS_TOKEN} registry.turbo-ops.de
|
|
2244
|
+
script:
|
|
2245
|
+
- docker compose build
|
|
2246
|
+
- docker compose push
|
|
2247
|
+
rules:
|
|
2248
|
+
- if: $CI_COMMIT_BRANCH # L\xE4uft auf ALLEN Branches!
|
|
2249
|
+
|
|
2250
|
+
2. DEPLOY-JOBS (jeder NUR auf seinem Branch!):
|
|
2251
|
+
WICHTIG: KEIN --image Flag n\xF6tig! Die CLI erkennt CI_COMMIT_SHA automatisch!
|
|
2252
|
+
|
|
2253
|
+
deploy-dev:
|
|
2254
|
+
image: node:20-alpine
|
|
2255
|
+
before_script:
|
|
2256
|
+
- npm install -g @turboops/cli
|
|
2257
|
+
- turbo config set token \${TURBOOPS_TOKEN}
|
|
2258
|
+
script:
|
|
2259
|
+
- turbo deploy dev --wait # CLI erkennt Image automatisch via CI_COMMIT_SHA
|
|
2260
|
+
rules:
|
|
2261
|
+
- if: $CI_COMMIT_BRANCH == "dev" # NUR auf dev Branch!
|
|
2262
|
+
needs: [build]
|
|
2263
|
+
|
|
2264
|
+
deploy-test:
|
|
2265
|
+
script:
|
|
2266
|
+
- turbo deploy test --wait
|
|
2267
|
+
rules:
|
|
2268
|
+
- if: $CI_COMMIT_BRANCH == "test" # NUR auf test Branch!
|
|
2269
|
+
needs: [deploy-dev]
|
|
2270
|
+
|
|
2271
|
+
deploy-prod:
|
|
2272
|
+
script:
|
|
2273
|
+
- turbo deploy prod --wait
|
|
2274
|
+
rules:
|
|
2275
|
+
- if: $CI_COMMIT_BRANCH == "main" # NUR auf main Branch!
|
|
2276
|
+
when: manual
|
|
2277
|
+
needs: [deploy-test]
|
|
2278
|
+
|
|
2279
|
+
WICHTIG:
|
|
2280
|
+
- Der Build l\xE4uft auf ALLEN Branches (dev, test, main)
|
|
2281
|
+
- Jeder Deploy-Job l\xE4uft NUR auf seinem zugeordneten Branch
|
|
2282
|
+
- KEIN --image Flag n\xF6tig - CLI erkennt CI_COMMIT_SHA/GITHUB_SHA automatisch
|
|
2283
|
+
- Registry-URL: registry.turbo-ops.de/${projectSlug}
|
|
2284
|
+
- Secrets ben\xF6tigt: TURBOOPS_TOKEN
|
|
2246
2285
|
|
|
2247
2286
|
Erstelle die Datei "${pipelineFile}".`;
|
|
2248
2287
|
const success = await aiToolsService.runWithPrompt(tool, prompt, verbose);
|
|
@@ -2264,17 +2303,58 @@ Erstelle die Datei "${pipelineFile}".`;
|
|
|
2264
2303
|
// src/commands/deploy.ts
|
|
2265
2304
|
import { Command as Command4 } from "commander";
|
|
2266
2305
|
import chalk6 from "chalk";
|
|
2267
|
-
var
|
|
2306
|
+
var REGISTRY_URL = "registry.turbo-ops.de";
|
|
2307
|
+
function detectCiCommitSha() {
|
|
2308
|
+
if (process.env.CI_COMMIT_SHA) {
|
|
2309
|
+
return process.env.CI_COMMIT_SHA;
|
|
2310
|
+
}
|
|
2311
|
+
if (process.env.GITHUB_SHA) {
|
|
2312
|
+
return process.env.GITHUB_SHA;
|
|
2313
|
+
}
|
|
2314
|
+
if (process.env.BITBUCKET_COMMIT) {
|
|
2315
|
+
return process.env.BITBUCKET_COMMIT;
|
|
2316
|
+
}
|
|
2317
|
+
if (process.env.BUILD_SOURCEVERSION) {
|
|
2318
|
+
return process.env.BUILD_SOURCEVERSION;
|
|
2319
|
+
}
|
|
2320
|
+
if (process.env.CIRCLE_SHA1) {
|
|
2321
|
+
return process.env.CIRCLE_SHA1;
|
|
2322
|
+
}
|
|
2323
|
+
if (process.env.GIT_COMMIT) {
|
|
2324
|
+
return process.env.GIT_COMMIT;
|
|
2325
|
+
}
|
|
2326
|
+
return null;
|
|
2327
|
+
}
|
|
2328
|
+
function detectCiEnvironment() {
|
|
2329
|
+
if (process.env.GITLAB_CI) return "GitLab CI";
|
|
2330
|
+
if (process.env.GITHUB_ACTIONS) return "GitHub Actions";
|
|
2331
|
+
if (process.env.BITBUCKET_PIPELINES) return "Bitbucket Pipelines";
|
|
2332
|
+
if (process.env.TF_BUILD) return "Azure DevOps";
|
|
2333
|
+
if (process.env.CIRCLECI) return "CircleCI";
|
|
2334
|
+
if (process.env.JENKINS_URL) return "Jenkins";
|
|
2335
|
+
return null;
|
|
2336
|
+
}
|
|
2337
|
+
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(
|
|
2268
2338
|
"--timeout <ms>",
|
|
2269
2339
|
"Timeout in milliseconds when waiting",
|
|
2270
2340
|
"600000"
|
|
2271
2341
|
).action(async (environment, options) => {
|
|
2272
2342
|
const { project, environment: env } = await getCommandContextWithEnvironment(environment);
|
|
2273
2343
|
logger.header(`Deploying: ${project.name} \u2192 ${env.name}`);
|
|
2344
|
+
let imageTag = options.image;
|
|
2345
|
+
if (!imageTag) {
|
|
2346
|
+
const commitSha = detectCiCommitSha();
|
|
2347
|
+
const ciEnv = detectCiEnvironment();
|
|
2348
|
+
if (commitSha && ciEnv) {
|
|
2349
|
+
imageTag = `${REGISTRY_URL}/${project.slug}:${commitSha}`;
|
|
2350
|
+
logger.info(`CI/CD detected (${ciEnv})`);
|
|
2351
|
+
logger.info(`Auto-using image: ${imageTag}`);
|
|
2352
|
+
}
|
|
2353
|
+
}
|
|
2274
2354
|
logger.info("Triggering deployment...");
|
|
2275
2355
|
const { data: deployment, error } = await apiClient.deploy(
|
|
2276
2356
|
env.id,
|
|
2277
|
-
|
|
2357
|
+
imageTag
|
|
2278
2358
|
);
|
|
2279
2359
|
if (error) {
|
|
2280
2360
|
logger.error(`Failed to trigger deployment: ${error}`);
|
|
@@ -2290,7 +2370,7 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2290
2370
|
status: deployment.status,
|
|
2291
2371
|
environment: env.slug,
|
|
2292
2372
|
project: project.slug,
|
|
2293
|
-
imageTag:
|
|
2373
|
+
imageTag: imageTag || "auto-promotion"
|
|
2294
2374
|
});
|
|
2295
2375
|
if (!options.wait) {
|
|
2296
2376
|
logger.info("Deployment started. Use --wait to wait for completion.");
|
|
@@ -2581,17 +2661,36 @@ async function integratePipelineWithAI2(pipelineType, projectSlug, pipelinePath)
|
|
|
2581
2661
|
Projekt-Slug: ${projectSlug}
|
|
2582
2662
|
Pipeline-Datei: ${pipelinePath}
|
|
2583
2663
|
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
4. Token setzen: turbo config set token \${TURBOOPS_TOKEN}
|
|
2589
|
-
5. Deploy ausf\xFChren: turbo deploy <environment> --image <image-tag> --wait
|
|
2664
|
+
WICHTIG - Branch-zu-Stage-Zuordnung:
|
|
2665
|
+
- dev Stage \u2192 wird NUR auf dem "dev" Branch deployed
|
|
2666
|
+
- test Stage \u2192 wird NUR auf dem "test" Branch deployed
|
|
2667
|
+
- prod Stage \u2192 wird NUR auf dem "main" Branch deployed
|
|
2590
2668
|
|
|
2591
|
-
|
|
2669
|
+
PIPELINE-STRUKTUR:
|
|
2670
|
+
1. Build-Job: L\xE4uft auf ALLEN Branches (dev, test, main)
|
|
2671
|
+
- Docker Images bauen mit docker-compose build
|
|
2672
|
+
- Images pushen mit docker-compose push
|
|
2673
|
+
- Registry: registry.turbo-ops.de/${projectSlug}
|
|
2674
|
+
- Image-Tag: \${CI_COMMIT_SHA} (wird automatisch von CLI erkannt)
|
|
2592
2675
|
|
|
2593
|
-
|
|
2594
|
-
-
|
|
2676
|
+
2. Deploy-Jobs: Jeder Job l\xE4uft NUR auf seinem Branch!
|
|
2677
|
+
- deploy-dev: rules: if: $CI_COMMIT_BRANCH == "dev"
|
|
2678
|
+
- deploy-test: rules: if: $CI_COMMIT_BRANCH == "test"
|
|
2679
|
+
- deploy-prod: rules: if: $CI_COMMIT_BRANCH == "main" (when: manual)
|
|
2680
|
+
|
|
2681
|
+
DEPLOY-BEFEHLE (WICHTIG: KEIN --image Flag n\xF6tig!):
|
|
2682
|
+
- TurboOps CLI installieren: npm install -g @turboops/cli
|
|
2683
|
+
- Token setzen: turbo config set token \${TURBOOPS_TOKEN}
|
|
2684
|
+
- Deploy: turbo deploy <stage> --wait
|
|
2685
|
+
|
|
2686
|
+
Die CLI erkennt automatisch CI_COMMIT_SHA/GITHUB_SHA und verwendet das richtige Image!
|
|
2687
|
+
|
|
2688
|
+
DEPENDENCIES:
|
|
2689
|
+
- deploy-dev needs: [build]
|
|
2690
|
+
- deploy-test needs: [deploy-dev]
|
|
2691
|
+
- deploy-prod needs: [deploy-test]
|
|
2692
|
+
|
|
2693
|
+
Secrets ben\xF6tigt: TURBOOPS_TOKEN
|
|
2595
2694
|
|
|
2596
2695
|
Modifiziere die Datei "${pipelinePath}" entsprechend.`;
|
|
2597
2696
|
const success = await aiToolsService.runWithPrompt(tool, prompt);
|