@turboops/cli 1.0.33 → 1.0.34
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 +21 -19
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2500,24 +2500,20 @@ import { readFileSync as readFileSync3, existsSync as existsSync4 } from "fs";
|
|
|
2500
2500
|
import { resolve as resolve2 } from "path";
|
|
2501
2501
|
import { Command as Command4 } from "commander";
|
|
2502
2502
|
import chalk6 from "chalk";
|
|
2503
|
+
var DOCKER_TAG_REGEX = /^[a-zA-Z0-9][a-zA-Z0-9._-]{0,127}$/;
|
|
2503
2504
|
function detectCiCommitSha() {
|
|
2504
|
-
|
|
2505
|
-
|
|
2506
|
-
|
|
2507
|
-
|
|
2508
|
-
|
|
2509
|
-
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
2513
|
-
|
|
2514
|
-
|
|
2515
|
-
|
|
2516
|
-
if (process.env.CIRCLE_SHA1) {
|
|
2517
|
-
return process.env.CIRCLE_SHA1;
|
|
2518
|
-
}
|
|
2519
|
-
if (process.env.GIT_COMMIT) {
|
|
2520
|
-
return process.env.GIT_COMMIT;
|
|
2505
|
+
const candidates = [
|
|
2506
|
+
process.env.CI_COMMIT_SHA,
|
|
2507
|
+
process.env.GITHUB_SHA,
|
|
2508
|
+
process.env.BITBUCKET_COMMIT,
|
|
2509
|
+
process.env.BUILD_SOURCEVERSION,
|
|
2510
|
+
process.env.CIRCLE_SHA1,
|
|
2511
|
+
process.env.GIT_COMMIT
|
|
2512
|
+
];
|
|
2513
|
+
for (const sha of candidates) {
|
|
2514
|
+
if (sha && DOCKER_TAG_REGEX.test(sha.trim())) {
|
|
2515
|
+
return sha.trim();
|
|
2516
|
+
}
|
|
2521
2517
|
}
|
|
2522
2518
|
return null;
|
|
2523
2519
|
}
|
|
@@ -2541,14 +2537,20 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2541
2537
|
logger.header(`Deploying: ${project.name} \u2192 ${env.name}`);
|
|
2542
2538
|
const isFirstStage = !env.stageOrder || env.stageOrder === 0;
|
|
2543
2539
|
let imageTag = options.image;
|
|
2540
|
+
if (imageTag && !DOCKER_TAG_REGEX.test(imageTag)) {
|
|
2541
|
+
logger.error(
|
|
2542
|
+
`Invalid image tag format: "${imageTag}". Must be alphanumeric with dots, dashes, or underscores.`
|
|
2543
|
+
);
|
|
2544
|
+
process.exit(11 /* CONFIG_ERROR */);
|
|
2545
|
+
}
|
|
2544
2546
|
if (!imageTag) {
|
|
2545
2547
|
if (isFirstStage) {
|
|
2546
2548
|
const commitSha = detectCiCommitSha();
|
|
2547
2549
|
const ciEnv = detectCiEnvironment();
|
|
2548
2550
|
if (commitSha && ciEnv) {
|
|
2549
|
-
imageTag =
|
|
2551
|
+
imageTag = commitSha;
|
|
2550
2552
|
logger.info(`CI/CD detected (${ciEnv})`);
|
|
2551
|
-
logger.info(`Auto-using image: ${
|
|
2553
|
+
logger.info(`Auto-using image tag: ${commitSha}`);
|
|
2552
2554
|
}
|
|
2553
2555
|
} else {
|
|
2554
2556
|
const ciEnv = detectCiEnvironment();
|