@@ -11,7 +11,7 @@ const { CliUx } = require('@oclif/core');
1111const { extractPhrases } = require ( '../api/extract' ) ;
1212const { uploadPhrases, pollJob } = require ( '../api/upload' ) ;
1313const { mergePayload } = require ( '../api/merge' ) ;
14- const { stringToArray } = require ( '../api/utils' ) ;
14+ const { stringToArray, normalizeArray } = require ( '../api/utils' ) ;
1515
1616/**
1717 * Test if path is folder
@@ -161,6 +161,41 @@ class PushCommand extends Command {
161161 : 'Uploading content to Transifex' ;
162162
163163 this . log ( '' ) ;
164+
165+ /**
166+ * Print detailed verbose output for a group of items
167+ *
168+ * @param {String } label - Label for the group
169+ * @param {Array } items - Items to display
170+ * @param {String } groupColor - Color for the group label
171+ */
172+ const printVerboseGroup = ( label , items , groupColor = 'white' ) => {
173+ const arr = normalizeArray ( items ) ;
174+ if ( ! arr . length ) return ;
175+ this . log ( ` ${ label } : ${ arr . length } ` [ groupColor ] ) ;
176+ arr . forEach ( ( item ) => {
177+ const {
178+ key = '' ,
179+ string = '' ,
180+ context = [ ] ,
181+ occurrences = [ ] ,
182+ } = item ;
183+ if ( string ) {
184+ if ( key !== string ) {
185+ this . log ( ` └─ ${ key } : ${ string . underline } ` ) ;
186+ } else {
187+ this . log ( ` └─ ${ string . underline } ` ) ;
188+ }
189+ if ( occurrences . length ) {
190+ this . log ( ` └─ occurrences: ${ occurrences . join ( ', ' ) } ` . gray ) ;
191+ }
192+ if ( context . length ) {
193+ this . log ( ` └─ context: ${ context } ` . gray ) ;
194+ }
195+ }
196+ } ) ;
197+ } ;
198+
164199 CliUx . ux . action . start ( uploadMessage , '' , { stdout : true } ) ;
165200 try {
166201 let res = await uploadPhrases ( payload , {
@@ -207,20 +242,29 @@ class PushCommand extends Command {
207242 if ( status === 'completed' ) {
208243 CliUx . ux . action . stop ( 'Success' . green ) ;
209244 this . log ( `${ '✓' . green } Successfully pushed strings to Transifex:` ) ;
210- if ( res . created > 0 ) {
211- this . log ( ` Created strings: ${ res . created . toString ( ) . green } ` ) ;
212- }
213- if ( res . updated > 0 ) {
214- this . log ( ` Updated strings: ${ res . updated . toString ( ) . green } ` ) ;
215- }
216- if ( res . skipped > 0 ) {
217- this . log ( ` Skipped strings: ${ res . skipped . toString ( ) . green } ` ) ;
218- }
219- if ( res . deleted > 0 ) {
220- this . log ( ` Deleted strings: ${ res . deleted . toString ( ) . green } ` ) ;
221- }
222- if ( res . failed > 0 ) {
223- this . log ( ` Failed strings: ${ res . failed . toString ( ) . red } ` ) ;
245+
246+ if ( res . verbose && flags . verbose ) {
247+ printVerboseGroup ( 'Created strings' , res . verbose . created , 'green' ) ;
248+ printVerboseGroup ( 'Updated strings' , res . verbose . updated , 'yellow' ) ;
249+ printVerboseGroup ( 'Deleted strings' , res . verbose . deleted , 'red' ) ;
250+ printVerboseGroup ( 'Skipped strings' , res . verbose . skipped , 'green' ) ;
251+ printVerboseGroup ( 'Failed strings' , res . verbose . failed , 'red' ) ;
252+ } else {
253+ if ( res . created > 0 ) {
254+ this . log ( ` Created strings: ${ res . created } ` . green ) ;
255+ }
256+ if ( res . updated > 0 ) {
257+ this . log ( ` Updated strings: ${ res . updated } ` . yellow ) ;
258+ }
259+ if ( res . deleted > 0 ) {
260+ this . log ( ` Deleted strings: ${ res . deleted } ` . red ) ;
261+ }
262+ if ( res . skipped > 0 ) {
263+ this . log ( ` Skipped strings: ${ res . skipped } ` . green ) ;
264+ }
265+ if ( res . failed > 0 ) {
266+ this . log ( ` Failed strings: ${ res . failed } ` . red ) ;
267+ }
224268 }
225269 } else {
226270 CliUx . ux . action . stop ( 'Failed' . red ) ;
0 commit comments