@@ -3,7 +3,7 @@ import chalk from "chalk";
33import inquirer from "inquirer" ;
44
55import { readAuthConfig } from "../../utils/utils.js" ;
6- import { getProject , getProjects } from "../../utils/shared.js" ;
6+ import { getProjects } from "../../utils/shared.js" ;
77
88export default class ProjectInfo extends Command {
99 static description =
@@ -71,99 +71,120 @@ export default class ProjectInfo extends Command {
7171 ) ;
7272
7373 try {
74- const projectInfo = await getProject ( projectId , auth , this ) ;
74+ const projects = await getProjects ( auth , this ) ;
75+ const projectInfo = projects . find ( p => p . projectId === projectId ) ;
76+
77+ if ( ! projectInfo ) {
78+ this . error ( chalk . red ( "Project not found." ) ) ;
79+ return ;
80+ }
7581
7682 this . log ( chalk . green ( `Project Name: ${ projectInfo . name } ` ) ) ;
7783 this . log (
7884 chalk . green (
7985 `Description: ${ projectInfo ?. description || "No description" } ` ,
8086 ) ,
8187 ) ;
82- this . log (
83- chalk . green (
84- `Number of Applications: ${ projectInfo . applications . length } ` ,
85- ) ,
86- ) ;
87- this . log (
88- chalk . green (
89- `Number of Compose Services: ${ projectInfo . compose . length } ` ,
90- ) ,
91- ) ;
92- this . log (
93- chalk . green (
94- `Number of MariaDB Databases: ${ projectInfo . mariadb . length } ` ,
95- ) ,
96- ) ;
97- this . log (
98- chalk . green ( `Number of MongoDB Databases: ${ projectInfo . mongo . length } ` ) ,
99- ) ;
100- this . log (
101- chalk . green ( `Number of MySQL Databases: ${ projectInfo . mysql . length } ` ) ,
102- ) ;
103- this . log (
104- chalk . green (
105- `Number of PostgreSQL Databases: ${ projectInfo . postgres . length } ` ,
106- ) ,
107- ) ;
108- this . log (
109- chalk . green ( `Number of Redis Databases: ${ projectInfo . redis . length } ` ) ,
110- ) ;
111-
112- if ( projectInfo . applications . length > 0 ) {
113- this . log ( chalk . blue ( "\nApplications:" ) ) ;
114- // @ts -ignore
115- projectInfo . applications . forEach ( ( app , index : number ) => {
116- this . log ( ` ${ index + 1 } . ${ app . name } ` ) ;
117- } ) ;
118- }
119-
120- if ( projectInfo . compose . length > 0 ) {
121- this . log ( chalk . blue ( "\nCompose Services:" ) ) ;
122- // @ts -ignore
123- projectInfo . compose . forEach ( ( service , index : number ) => {
124- this . log ( ` ${ index + 1 } . ${ service . name } ` ) ;
125- } ) ;
126- }
12788
128- if ( projectInfo . mariadb . length > 0 ) {
129- this . log ( chalk . blue ( "\nMariaDB Databases:" ) ) ;
130- // @ts -ignore
131- projectInfo . mariadb . forEach ( ( db , index : number ) => {
132- this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
89+ // Contar totales de todos los environments
90+ let totalApplications = 0 ;
91+ let totalCompose = 0 ;
92+ let totalMariaDB = 0 ;
93+ let totalMongoDB = 0 ;
94+ let totalMySQL = 0 ;
95+ let totalPostgreSQL = 0 ;
96+ let totalRedis = 0 ;
97+
98+ if ( projectInfo . environments && projectInfo . environments . length > 0 ) {
99+ this . log ( chalk . green ( `Number of Environments: ${ projectInfo . environments . length } ` ) ) ;
100+
101+ // Mostrar información por environment
102+ projectInfo . environments . forEach ( ( env , envIndex ) => {
103+ this . log ( chalk . blue ( `\nEnvironment ${ envIndex + 1 } : ${ env . name } (${ env . description } )` ) ) ;
104+
105+ // Contar recursos por environment
106+ const envApps = env . applications ?. length || 0 ;
107+ const envCompose = env . compose ?. length || 0 ;
108+ const envMariaDB = env . mariadb ?. length || 0 ;
109+ const envMongoDB = env . mongo ?. length || 0 ;
110+ const envMySQL = env . mysql ?. length || 0 ;
111+ const envPostgreSQL = env . postgres ?. length || 0 ;
112+ const envRedis = env . redis ?. length || 0 ;
113+
114+ totalApplications += envApps ;
115+ totalCompose += envCompose ;
116+ totalMariaDB += envMariaDB ;
117+ totalMongoDB += envMongoDB ;
118+ totalMySQL += envMySQL ;
119+ totalPostgreSQL += envPostgreSQL ;
120+ totalRedis += envRedis ;
121+
122+ this . log ( ` Applications: ${ envApps } ` ) ;
123+ this . log ( ` Compose Services: ${ envCompose } ` ) ;
124+ this . log ( ` MariaDB: ${ envMariaDB } ` ) ;
125+ this . log ( ` MongoDB: ${ envMongoDB } ` ) ;
126+ this . log ( ` MySQL: ${ envMySQL } ` ) ;
127+ this . log ( ` PostgreSQL: ${ envPostgreSQL } ` ) ;
128+ this . log ( ` Redis: ${ envRedis } ` ) ;
129+
130+ // Mostrar detalles de applications
131+ if ( envApps > 0 ) {
132+ this . log ( chalk . cyan ( " Applications:" ) ) ;
133+ env . applications . forEach ( ( app , index ) => {
134+ this . log ( ` ${ index + 1 } . ${ app . name } ` ) ;
135+ } ) ;
136+ }
137+
138+ // Mostrar detalles de databases
139+ if ( envMariaDB > 0 ) {
140+ this . log ( chalk . cyan ( " MariaDB Databases:" ) ) ;
141+ env . mariadb . forEach ( ( db , index ) => {
142+ this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
143+ } ) ;
144+ }
145+
146+ if ( envMongoDB > 0 ) {
147+ this . log ( chalk . cyan ( " MongoDB Databases:" ) ) ;
148+ env . mongo . forEach ( ( db , index ) => {
149+ this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
150+ } ) ;
151+ }
152+
153+ if ( envMySQL > 0 ) {
154+ this . log ( chalk . cyan ( " MySQL Databases:" ) ) ;
155+ env . mysql . forEach ( ( db , index ) => {
156+ this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
157+ } ) ;
158+ }
159+
160+ if ( envPostgreSQL > 0 ) {
161+ this . log ( chalk . cyan ( " PostgreSQL Databases:" ) ) ;
162+ env . postgres . forEach ( ( db , index ) => {
163+ this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
164+ } ) ;
165+ }
166+
167+ if ( envRedis > 0 ) {
168+ this . log ( chalk . cyan ( " Redis Databases:" ) ) ;
169+ env . redis . forEach ( ( db , index ) => {
170+ this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
171+ } ) ;
172+ }
133173 } ) ;
174+ } else {
175+ this . log ( chalk . yellow ( "No environments found in this project." ) ) ;
134176 }
135177
136- if ( projectInfo . mongo . length > 0 ) {
137- this . log ( chalk . blue ( "\nMongoDB Databases:" ) ) ;
138- // @ts -ignore
139- projectInfo . mongo . forEach ( ( db , index : number ) => {
140- this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
141- } ) ;
142- }
143-
144- if ( projectInfo . mysql . length > 0 ) {
145- this . log ( chalk . blue ( "\nMySQL Databases:" ) ) ;
146- // @ts -ignore
147- projectInfo . mysql . forEach ( ( db , index : number ) => {
148- this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
149- } ) ;
150- }
178+ // Mostrar totales
179+ this . log ( chalk . green . bold ( "\n📊 Project Totals:" ) ) ;
180+ this . log ( chalk . green ( `Total Applications: ${ totalApplications } ` ) ) ;
181+ this . log ( chalk . green ( `Total Compose Services: ${ totalCompose } ` ) ) ;
182+ this . log ( chalk . green ( `Total MariaDB Databases: ${ totalMariaDB } ` ) ) ;
183+ this . log ( chalk . green ( `Total MongoDB Databases: ${ totalMongoDB } ` ) ) ;
184+ this . log ( chalk . green ( `Total MySQL Databases: ${ totalMySQL } ` ) ) ;
185+ this . log ( chalk . green ( `Total PostgreSQL Databases: ${ totalPostgreSQL } ` ) ) ;
186+ this . log ( chalk . green ( `Total Redis Databases: ${ totalRedis } ` ) ) ;
151187
152- if ( projectInfo . postgres . length > 0 ) {
153- this . log ( chalk . blue ( "\nPostgreSQL Databases:" ) ) ;
154- // @ts -ignore
155- projectInfo . postgres . forEach ( ( db , index : number ) => {
156- this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
157- } ) ;
158- }
159-
160- if ( projectInfo . redis . length > 0 ) {
161- this . log ( chalk . blue ( "\nRedis Databases:" ) ) ;
162- // @ts -ignore
163- projectInfo . redis . forEach ( ( db , index : number ) => {
164- this . log ( ` ${ index + 1 } . ${ db . name } ` ) ;
165- } ) ;
166- }
167188 } catch ( error ) {
168189 this . error (
169190 // @ts -expect-error
0 commit comments