Skip to content

Commit 3104ae7

Browse files
committed
TX-16599: Native push --verbose command group created, updated, skipped, failed strings
1 parent 9061d28 commit 3104ae7

File tree

1 file changed

+55
-14
lines changed

1 file changed

+55
-14
lines changed

packages/cli/src/commands/push.js

Lines changed: 55 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,39 @@ class PushCommand extends Command {
161161
: 'Uploading content to Transifex';
162162

163163
this.log('');
164+
165+
// --------- helpers to print verbose groups ----------
166+
const normalizeArray = (maybeArr) => {
167+
if (!maybeArr) return [];
168+
if (Array.isArray(maybeArr)) return maybeArr;
169+
if (typeof maybeArr === 'string') {
170+
try {
171+
const parsed = JSON.parse(maybeArr);
172+
return Array.isArray(parsed) ? parsed : [];
173+
} catch (_) {
174+
return [];
175+
}
176+
}
177+
return [];
178+
};
179+
180+
const printVerboseGroup = (label, items) => {
181+
const arr = normalizeArray(items);
182+
if (!arr.length) return;
183+
this.log(` ${label}: ${arr.length.toString().green}`);
184+
arr.forEach((item) => {
185+
const string = item?.string ?? '';
186+
const key = item?.key ?? '';
187+
const occurrences = Array.isArray(item?.occurrences) ? item.occurrences : [];
188+
const context = Array.isArray(item?.context) ? item.context : [];
189+
this.log(` └─ ${JSON.stringify(string)}`.white);
190+
this.log(` └─ key: ${JSON.stringify(key)}`.gray);
191+
this.log(` └─ occurrences: ${JSON.stringify(occurrences)}`.gray);
192+
this.log(` └─ context: ${JSON.stringify(context)}`.gray);
193+
});
194+
};
195+
// ----------------------------------------------------------------------
196+
164197
CliUx.ux.action.start(uploadMessage, '', { stdout: true });
165198
try {
166199
let res = await uploadPhrases(payload, {
@@ -207,20 +240,28 @@ class PushCommand extends Command {
207240
if (status === 'completed') {
208241
CliUx.ux.action.stop('Success'.green);
209242
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}`);
243+
if (res.verbose) {
244+
printVerboseGroup('Created strings', res.verbose.created);
245+
printVerboseGroup('Updated strings', res.verbose.updated);
246+
printVerboseGroup('Skipped strings', res.verbose.skipped);
247+
printVerboseGroup('Deleted strings', res.verbose.deleted);
248+
printVerboseGroup('Failed strings', res.verbose.failed);
249+
} else {
250+
if (res.created > 0) {
251+
this.log(` Created strings: ${res.created.toString().green}`);
252+
}
253+
if (res.updated > 0) {
254+
this.log(` Updated strings: ${res.updated.toString().green}`);
255+
}
256+
if (res.skipped > 0) {
257+
this.log(` Skipped strings: ${res.skipped.toString().green}`);
258+
}
259+
if (res.deleted > 0) {
260+
this.log(` Deleted strings: ${res.deleted.toString().green}`);
261+
}
262+
if (res.failed > 0) {
263+
this.log(` Failed strings: ${res.failed.toString().red}`);
264+
}
224265
}
225266
} else {
226267
CliUx.ux.action.stop('Failed'.red);

0 commit comments

Comments
 (0)