mirror of
https://github.com/Dokploy/cli.git
synced 2026-06-15 20:25:22 +02:00
feat: enhance project info command with environment details
- Refactored ProjectInfo command to retrieve project information based on environments. - Added detailed logging for applications, compose services, and databases categorized by environment. - Implemented total counts for applications and databases across all environments. - Improved error handling for cases with no environments found.
This commit is contained in:
@@ -3,7 +3,7 @@ import chalk from "chalk";
|
||||
import inquirer from "inquirer";
|
||||
|
||||
import { readAuthConfig } from "../../utils/utils.js";
|
||||
import { getProject, getProjects } from "../../utils/shared.js";
|
||||
import { getProjects } from "../../utils/shared.js";
|
||||
|
||||
export default class ProjectInfo extends Command {
|
||||
static description =
|
||||
@@ -71,7 +71,13 @@ export default class ProjectInfo extends Command {
|
||||
);
|
||||
|
||||
try {
|
||||
const projectInfo = await getProject(projectId, auth, this);
|
||||
const projects = await getProjects(auth, this);
|
||||
const projectInfo = projects.find(p => p.projectId === projectId);
|
||||
|
||||
if (!projectInfo) {
|
||||
this.error(chalk.red("Project not found."));
|
||||
return;
|
||||
}
|
||||
|
||||
this.log(chalk.green(`Project Name: ${projectInfo.name}`));
|
||||
this.log(
|
||||
@@ -79,91 +85,106 @@ export default class ProjectInfo extends Command {
|
||||
`Description: ${projectInfo?.description || "No description"}`,
|
||||
),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(
|
||||
`Number of Applications: ${projectInfo.applications.length}`,
|
||||
),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(
|
||||
`Number of Compose Services: ${projectInfo.compose.length}`,
|
||||
),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(
|
||||
`Number of MariaDB Databases: ${projectInfo.mariadb.length}`,
|
||||
),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(`Number of MongoDB Databases: ${projectInfo.mongo.length}`),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(`Number of MySQL Databases: ${projectInfo.mysql.length}`),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(
|
||||
`Number of PostgreSQL Databases: ${projectInfo.postgres.length}`,
|
||||
),
|
||||
);
|
||||
this.log(
|
||||
chalk.green(`Number of Redis Databases: ${projectInfo.redis.length}`),
|
||||
);
|
||||
|
||||
if (projectInfo.applications.length > 0) {
|
||||
this.log(chalk.blue("\nApplications:"));
|
||||
// @ts-ignore
|
||||
projectInfo.applications.forEach((app, index: number) => {
|
||||
this.log(` ${index + 1}. ${app.name}`);
|
||||
// Contar totales de todos los environments
|
||||
let totalApplications = 0;
|
||||
let totalCompose = 0;
|
||||
let totalMariaDB = 0;
|
||||
let totalMongoDB = 0;
|
||||
let totalMySQL = 0;
|
||||
let totalPostgreSQL = 0;
|
||||
let totalRedis = 0;
|
||||
|
||||
if (projectInfo.environments && projectInfo.environments.length > 0) {
|
||||
this.log(chalk.green(`Number of Environments: ${projectInfo.environments.length}`));
|
||||
|
||||
// Mostrar información por environment
|
||||
projectInfo.environments.forEach((env, envIndex) => {
|
||||
this.log(chalk.blue(`\nEnvironment ${envIndex + 1}: ${env.name} (${env.description})`));
|
||||
|
||||
// Contar recursos por environment
|
||||
const envApps = env.applications?.length || 0;
|
||||
const envCompose = env.compose?.length || 0;
|
||||
const envMariaDB = env.mariadb?.length || 0;
|
||||
const envMongoDB = env.mongo?.length || 0;
|
||||
const envMySQL = env.mysql?.length || 0;
|
||||
const envPostgreSQL = env.postgres?.length || 0;
|
||||
const envRedis = env.redis?.length || 0;
|
||||
|
||||
totalApplications += envApps;
|
||||
totalCompose += envCompose;
|
||||
totalMariaDB += envMariaDB;
|
||||
totalMongoDB += envMongoDB;
|
||||
totalMySQL += envMySQL;
|
||||
totalPostgreSQL += envPostgreSQL;
|
||||
totalRedis += envRedis;
|
||||
|
||||
this.log(` Applications: ${envApps}`);
|
||||
this.log(` Compose Services: ${envCompose}`);
|
||||
this.log(` MariaDB: ${envMariaDB}`);
|
||||
this.log(` MongoDB: ${envMongoDB}`);
|
||||
this.log(` MySQL: ${envMySQL}`);
|
||||
this.log(` PostgreSQL: ${envPostgreSQL}`);
|
||||
this.log(` Redis: ${envRedis}`);
|
||||
|
||||
// Mostrar detalles de applications
|
||||
if (envApps > 0) {
|
||||
this.log(chalk.cyan(" Applications:"));
|
||||
env.applications.forEach((app, index) => {
|
||||
this.log(` ${index + 1}. ${app.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
// Mostrar detalles de databases
|
||||
if (envMariaDB > 0) {
|
||||
this.log(chalk.cyan(" MariaDB Databases:"));
|
||||
env.mariadb.forEach((db, index) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (envMongoDB > 0) {
|
||||
this.log(chalk.cyan(" MongoDB Databases:"));
|
||||
env.mongo.forEach((db, index) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (envMySQL > 0) {
|
||||
this.log(chalk.cyan(" MySQL Databases:"));
|
||||
env.mysql.forEach((db, index) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (envPostgreSQL > 0) {
|
||||
this.log(chalk.cyan(" PostgreSQL Databases:"));
|
||||
env.postgres.forEach((db, index) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (envRedis > 0) {
|
||||
this.log(chalk.cyan(" Redis Databases:"));
|
||||
env.redis.forEach((db, index) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
this.log(chalk.yellow("No environments found in this project."));
|
||||
}
|
||||
|
||||
if (projectInfo.compose.length > 0) {
|
||||
this.log(chalk.blue("\nCompose Services:"));
|
||||
// @ts-ignore
|
||||
projectInfo.compose.forEach((service, index: number) => {
|
||||
this.log(` ${index + 1}. ${service.name}`);
|
||||
});
|
||||
}
|
||||
// Mostrar totales
|
||||
this.log(chalk.green.bold("\n📊 Project Totals:"));
|
||||
this.log(chalk.green(`Total Applications: ${totalApplications}`));
|
||||
this.log(chalk.green(`Total Compose Services: ${totalCompose}`));
|
||||
this.log(chalk.green(`Total MariaDB Databases: ${totalMariaDB}`));
|
||||
this.log(chalk.green(`Total MongoDB Databases: ${totalMongoDB}`));
|
||||
this.log(chalk.green(`Total MySQL Databases: ${totalMySQL}`));
|
||||
this.log(chalk.green(`Total PostgreSQL Databases: ${totalPostgreSQL}`));
|
||||
this.log(chalk.green(`Total Redis Databases: ${totalRedis}`));
|
||||
|
||||
if (projectInfo.mariadb.length > 0) {
|
||||
this.log(chalk.blue("\nMariaDB Databases:"));
|
||||
// @ts-ignore
|
||||
projectInfo.mariadb.forEach((db, index: number) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (projectInfo.mongo.length > 0) {
|
||||
this.log(chalk.blue("\nMongoDB Databases:"));
|
||||
// @ts-ignore
|
||||
projectInfo.mongo.forEach((db, index: number) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (projectInfo.mysql.length > 0) {
|
||||
this.log(chalk.blue("\nMySQL Databases:"));
|
||||
// @ts-ignore
|
||||
projectInfo.mysql.forEach((db, index: number) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (projectInfo.postgres.length > 0) {
|
||||
this.log(chalk.blue("\nPostgreSQL Databases:"));
|
||||
// @ts-ignore
|
||||
projectInfo.postgres.forEach((db, index: number) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
|
||||
if (projectInfo.redis.length > 0) {
|
||||
this.log(chalk.blue("\nRedis Databases:"));
|
||||
// @ts-ignore
|
||||
projectInfo.redis.forEach((db, index: number) => {
|
||||
this.log(` ${index + 1}. ${db.name}`);
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
this.error(
|
||||
// @ts-expect-error
|
||||
|
||||
Reference in New Issue
Block a user