@turboops/cli 1.0.85-dev.1426 → 1.0.85-dev.1427
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 +54 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -753,6 +753,19 @@ var apiClient = {
|
|
|
753
753
|
async getDeploymentStatus(deploymentId) {
|
|
754
754
|
return this.request("GET", `/project/deployment/status/${deploymentId}`);
|
|
755
755
|
},
|
|
756
|
+
/**
|
|
757
|
+
* Get container logs for a stage (Project Token endpoint for CI/CD)
|
|
758
|
+
*/
|
|
759
|
+
async getContainerLogs(stageId, options) {
|
|
760
|
+
const params = new URLSearchParams();
|
|
761
|
+
if (options?.lines) params.set("lines", String(options.lines));
|
|
762
|
+
if (options?.service) params.set("service", options.service);
|
|
763
|
+
const query = params.toString();
|
|
764
|
+
return this.request(
|
|
765
|
+
"GET",
|
|
766
|
+
`/project/deployment/container-logs/${stageId}${query ? `?${query}` : ""}`
|
|
767
|
+
);
|
|
768
|
+
},
|
|
756
769
|
/**
|
|
757
770
|
* Wait for deployment to complete
|
|
758
771
|
*/
|
|
@@ -2725,6 +2738,7 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2725
2738
|
if (finalStatus.errorMessage) {
|
|
2726
2739
|
logger.error(`Error: ${finalStatus.errorMessage}`);
|
|
2727
2740
|
}
|
|
2741
|
+
await printContainerLogs(env.id);
|
|
2728
2742
|
process.exit(1 /* ERROR */);
|
|
2729
2743
|
} else {
|
|
2730
2744
|
logger.newline();
|
|
@@ -2742,6 +2756,46 @@ var deployCommand = new Command4("deploy").description("Trigger a deployment (fo
|
|
|
2742
2756
|
process.exit(1 /* ERROR */);
|
|
2743
2757
|
}
|
|
2744
2758
|
});
|
|
2759
|
+
async function printContainerLogs(stageId) {
|
|
2760
|
+
try {
|
|
2761
|
+
const { data, error } = await apiClient.getContainerLogs(stageId, {
|
|
2762
|
+
lines: 50
|
|
2763
|
+
});
|
|
2764
|
+
if (error || !data?.logs?.length) {
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
logger.newline();
|
|
2768
|
+
logger.info(chalk6.bold("Container Logs (last 50 lines):"));
|
|
2769
|
+
logger.info(chalk6.dim("\u2500".repeat(80)));
|
|
2770
|
+
for (const log of data.logs) {
|
|
2771
|
+
const time = new Date(log.timestamp).toLocaleTimeString();
|
|
2772
|
+
const levelColor = getLogLevelColor(log.level);
|
|
2773
|
+
const container = log.container ? chalk6.dim(`[${log.container}]`) : "";
|
|
2774
|
+
if (!isJsonMode()) {
|
|
2775
|
+
console.log(
|
|
2776
|
+
` ${chalk6.dim(time)} ${levelColor(log.level.padEnd(5))} ${container} ${log.message}`
|
|
2777
|
+
);
|
|
2778
|
+
}
|
|
2779
|
+
}
|
|
2780
|
+
logger.info(chalk6.dim("\u2500".repeat(80)));
|
|
2781
|
+
} catch {
|
|
2782
|
+
}
|
|
2783
|
+
}
|
|
2784
|
+
function getLogLevelColor(level) {
|
|
2785
|
+
switch (level.toLowerCase()) {
|
|
2786
|
+
case "error":
|
|
2787
|
+
case "fatal":
|
|
2788
|
+
return chalk6.red;
|
|
2789
|
+
case "warn":
|
|
2790
|
+
case "warning":
|
|
2791
|
+
return chalk6.yellow;
|
|
2792
|
+
case "debug":
|
|
2793
|
+
case "trace":
|
|
2794
|
+
return chalk6.dim;
|
|
2795
|
+
default:
|
|
2796
|
+
return chalk6.blue;
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2745
2799
|
function getStatusColor2(status) {
|
|
2746
2800
|
switch (status) {
|
|
2747
2801
|
case "running":
|