bdy 1.25.38-dev → 1.25.38-dev-pr

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.
Files changed (103) hide show
  1. package/distTs/package.json +2 -1
  2. package/distTs/src/api/client.js +191 -1
  3. package/distTs/src/autocomplete.js +90 -0
  4. package/distTs/src/cliError.js +5 -0
  5. package/distTs/src/cliIndex.js +3 -0
  6. package/distTs/src/command/artifact/downloadDir.js +110 -0
  7. package/distTs/src/command/autocomplete/install.js +16 -0
  8. package/distTs/src/command/autocomplete/uninstall.js +16 -0
  9. package/distTs/src/command/autocomplete.js +14 -0
  10. package/distTs/src/command/environment/resolve.js +39 -0
  11. package/distTs/src/command/login.js +1 -1
  12. package/distTs/src/command/package/create.js +64 -0
  13. package/distTs/src/command/package/delete.js +38 -0
  14. package/distTs/src/command/package/docker/login.js +26 -0
  15. package/distTs/src/command/package/docker.js +11 -0
  16. package/distTs/src/command/package/download.js +138 -0
  17. package/distTs/src/command/package/get.js +36 -0
  18. package/distTs/src/command/package/list.js +31 -0
  19. package/distTs/src/command/package/publish.js +241 -0
  20. package/distTs/src/command/package/version/delete.js +39 -0
  21. package/distTs/src/command/package/version/get.js +45 -0
  22. package/distTs/src/command/package/version/list.js +47 -0
  23. package/distTs/src/command/package/version.js +16 -0
  24. package/distTs/src/command/package.js +26 -0
  25. package/distTs/src/command/pipeline/run/apply.js +62 -0
  26. package/distTs/src/command/pr/comment/add.js +66 -0
  27. package/distTs/src/command/pr/comment/list.js +169 -0
  28. package/distTs/src/command/pr/comment/status.js +48 -0
  29. package/distTs/src/command/pr/comment.js +19 -0
  30. package/distTs/src/command/pr/create.js +43 -0
  31. package/distTs/src/command/pr/diff.js +227 -0
  32. package/distTs/src/command/pr/file/list.js +124 -0
  33. package/distTs/src/command/pr/file/mark.js +45 -0
  34. package/distTs/src/command/pr/file.js +16 -0
  35. package/distTs/src/command/pr/get.js +29 -0
  36. package/distTs/src/command/pr/list.js +79 -0
  37. package/distTs/src/command/pr/merge.js +66 -0
  38. package/distTs/src/command/pr/review/request.js +29 -0
  39. package/distTs/src/command/pr/review/start.js +29 -0
  40. package/distTs/src/command/pr/review/verdict.js +81 -0
  41. package/distTs/src/command/pr/review.js +18 -0
  42. package/distTs/src/command/pr/shared.js +595 -0
  43. package/distTs/src/command/pr/state.js +38 -0
  44. package/distTs/src/command/pr/summary.js +316 -0
  45. package/distTs/src/command/pr/update.js +54 -0
  46. package/distTs/src/command/pr/updateBranch.js +22 -0
  47. package/distTs/src/command/pr/versions.js +42 -0
  48. package/distTs/src/command/pr.js +39 -0
  49. package/distTs/src/command/scrape/validation.js +154 -0
  50. package/distTs/src/command/scrape.js +144 -0
  51. package/distTs/src/command/suiteLink.js +14 -0
  52. package/distTs/src/command/tests/visual/result/download.js +31 -0
  53. package/distTs/src/command/tests/visual/result/get.js +68 -0
  54. package/distTs/src/command/tests/visual/result/list.js +49 -0
  55. package/distTs/src/command/tests/visual/result.js +23 -0
  56. package/distTs/src/command/tests/visual/session/get.js +70 -0
  57. package/distTs/src/command/tests/visual/session/list.js +69 -0
  58. package/distTs/src/command/tests/visual/session/open.js +22 -0
  59. package/distTs/src/command/tests/visual/session/reviewUrl.js +37 -0
  60. package/distTs/src/command/tests/visual/session/update.js +26 -0
  61. package/distTs/src/command/tests/visual/shared/context.js +144 -0
  62. package/distTs/src/command/tests/visual/shared/diffRegions.js +172 -0
  63. package/distTs/src/command/tests/visual/shared/format.js +21 -0
  64. package/distTs/src/command/tests/visual/shared/lookup.js +107 -0
  65. package/distTs/src/command/tests/visual/shared/options.js +90 -0
  66. package/distTs/src/command/tests/visual/shared/review.js +146 -0
  67. package/distTs/src/command/tests/visual/shared/reviewUrl.js +62 -0
  68. package/distTs/src/command/tests/visual/shared/session.js +217 -0
  69. package/distTs/src/command/tests/visual/snapshot/get.js +46 -0
  70. package/distTs/src/command/tests/visual/snapshot/list.js +68 -0
  71. package/distTs/src/command/tests/visual/snapshot/open.js +26 -0
  72. package/distTs/src/command/tests/visual/snapshot/reviewUrl.js +48 -0
  73. package/distTs/src/command/tests/visual/snapshot.js +28 -0
  74. package/distTs/src/command/tests/visual/suite/create.js +38 -0
  75. package/distTs/src/command/tests/visual/suite/delete.js +29 -0
  76. package/distTs/src/command/tests/visual/suite/get.js +43 -0
  77. package/distTs/src/command/tests/visual/suite/list.js +35 -0
  78. package/distTs/src/command/tests/visual/suite/open.js +20 -0
  79. package/distTs/src/command/tests/visual/suite/update.js +47 -0
  80. package/distTs/src/command/tests/visual/suite.js +30 -0
  81. package/distTs/src/command/ut/upload.js +86 -0
  82. package/distTs/src/command/ut.js +12 -0
  83. package/distTs/src/command/vt/close.js +27 -0
  84. package/distTs/src/command/vt/compare/validation.js +46 -0
  85. package/distTs/src/command/vt/compare.js +100 -0
  86. package/distTs/src/command/vt/exec.js +82 -0
  87. package/distTs/src/command/vt/installBrowser.js +20 -0
  88. package/distTs/src/command/vt/shared/validation.js +145 -0
  89. package/distTs/src/command/vt/storybook.js +138 -0
  90. package/distTs/src/command/vt.js +20 -0
  91. package/distTs/src/command/yaml/agents.js +88 -0
  92. package/distTs/src/command/yaml/init.js +110 -0
  93. package/distTs/src/main.js +190 -0
  94. package/distTs/src/output/pipeline.js +54 -56
  95. package/distTs/src/output.js +72 -22
  96. package/distTs/src/texts.js +450 -1
  97. package/distTs/src/tunnel/output/interactive/tunnel.js +14 -10
  98. package/distTs/src/tunnel/output/noninteractive/tunnel.js +3 -1
  99. package/distTs/src/types/options.js +2 -0
  100. package/distTs/src/types/scrape.js +2 -0
  101. package/distTs/src/types/visualTests.js +2 -0
  102. package/distTs/src/utils.js +133 -3
  103. package/package.json +2 -1
@@ -579,7 +579,7 @@ class OutputPipeline {
579
579
  return;
580
580
  }
581
581
  commands.forEach((command) => {
582
- output_1.default.normal(`${output_1.default.getTermKitDimColor(` ${texts_1.TXT_PIPELINE_RUN_NEXT}`)}${output_1.default.getTermKitMutedColor(command)}`);
582
+ output_1.default.markup(`${output_1.default.getTermKitDimColor(` ${texts_1.TXT_PIPELINE_RUN_NEXT}`)}${output_1.default.getTermKitMutedColor(command)}`);
583
583
  });
584
584
  }
585
585
  static _jsonActionsLogsHelp(identifier, runId, flags, actionRunId) {
@@ -1295,28 +1295,28 @@ class OutputPipeline {
1295
1295
  this.jsonAction(identifier, runId, action, flags);
1296
1296
  }
1297
1297
  else {
1298
- output_1.default.normal(this._runDetailsHeader());
1299
- output_1.default.normal(this._runDetailsId(action.runId, tabs));
1300
- output_1.default.normal(this._runHtmlUrl(action.url, tabs));
1301
- output_1.default.normal(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
1298
+ output_1.default.markup(this._runDetailsHeader());
1299
+ output_1.default.markup(this._runDetailsId(action.runId, tabs));
1300
+ output_1.default.markup(this._runHtmlUrl(action.url, tabs));
1301
+ output_1.default.markup(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
1302
1302
  const target = this._runActionTarget(action, tabs);
1303
1303
  if (target) {
1304
- output_1.default.normal(target);
1304
+ output_1.default.markup(target);
1305
1305
  }
1306
1306
  const loop = this._runLoopVariables(action.loop, action.loopValues, tabs);
1307
1307
  if (loop) {
1308
- output_1.default.normal(loop);
1308
+ output_1.default.markup(loop);
1309
1309
  }
1310
1310
  const started = this._runDetailsStarted(action.status, action.started, null, tabs);
1311
1311
  if (started) {
1312
- output_1.default.normal(started);
1312
+ output_1.default.markup(started);
1313
1313
  }
1314
1314
  const finished = this._runDetailsFinished(action.status, action.finished, tabs);
1315
1315
  if (finished) {
1316
- output_1.default.normal(finished);
1316
+ output_1.default.markup(finished);
1317
1317
  }
1318
- output_1.default.normal('');
1319
- output_1.default.normal(this._runLogsHeader());
1318
+ output_1.default.markup('');
1319
+ output_1.default.markup(this._runLogsHeader());
1320
1320
  }
1321
1321
  drawnStart = true;
1322
1322
  }
@@ -1326,9 +1326,7 @@ class OutputPipeline {
1326
1326
  this.jsonLog(logs[actionLogsStart]);
1327
1327
  }
1328
1328
  else {
1329
- // log lines are payload inside markup - escape so % and ^
1330
- // sequences in build output render verbatim
1331
- output_1.default.normal(output_1.default.getTermKitDimColor(` ${output_1.default.escapeTermKit(logs[actionLogsStart])}`));
1329
+ output_1.default.markup(output_1.default.getTermKitDimColor(` ${logs[actionLogsStart]}`));
1332
1330
  }
1333
1331
  }
1334
1332
  if (action &&
@@ -1351,39 +1349,39 @@ class OutputPipeline {
1351
1349
  }
1352
1350
  else {
1353
1351
  if (logsEnd && action?.outputtedVariables.length) {
1354
- output_1.default.normal('');
1355
- output_1.default.normal(this._runOutputHeader());
1356
- output_1.default.normal(output_1.default.getTermKitDimColor(' Variables '), false);
1352
+ output_1.default.markup('');
1353
+ output_1.default.markup(this._runOutputHeader());
1354
+ output_1.default.markup(output_1.default.getTermKitDimColor(' Variables '), false);
1357
1355
  action.outputtedVariables.forEach((v, i) => {
1358
1356
  let line = '';
1359
1357
  if (i > 0)
1360
1358
  line += ' ';
1361
- line += output_1.default.getTermKitMutedColor(output_1.default.escapeTermKit(v.key));
1359
+ line += output_1.default.getTermKitMutedColor(v.key);
1362
1360
  line += output_1.default.getTermKitDimColor(` = "`);
1363
- line += output_1.default.getTermKitBlueColor(output_1.default.escapeTermKit(v.value));
1361
+ line += output_1.default.getTermKitBlueColor(v.value);
1364
1362
  line += output_1.default.getTermKitDimColor('"');
1365
- output_1.default.normal(line);
1363
+ output_1.default.markup(line);
1366
1364
  });
1367
1365
  }
1368
1366
  if (logsEnd && action && totalFetchesCount > 1) {
1369
- output_1.default.normal('');
1370
- output_1.default.normal(this._runDetailsHeader());
1371
- output_1.default.normal(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
1367
+ output_1.default.markup('');
1368
+ output_1.default.markup(this._runDetailsHeader());
1369
+ output_1.default.markup(this._runDetailsStatus(action.status, action.started, action.finished, tabs));
1372
1370
  const target = this._runActionTarget(action, tabs);
1373
1371
  if (target) {
1374
- output_1.default.normal(target);
1372
+ output_1.default.markup(target);
1375
1373
  }
1376
1374
  const loop = this._runLoopVariables(action.loop, action.loopValues, tabs);
1377
1375
  if (loop) {
1378
- output_1.default.normal(loop);
1376
+ output_1.default.markup(loop);
1379
1377
  }
1380
1378
  const started = this._runDetailsStarted(action.status, action.started, null, tabs);
1381
1379
  if (started) {
1382
- output_1.default.normal(started);
1380
+ output_1.default.markup(started);
1383
1381
  }
1384
1382
  const finished = this._runDetailsFinished(action.status, action.finished, tabs);
1385
1383
  if (finished) {
1386
- output_1.default.normal(finished);
1384
+ output_1.default.markup(finished);
1387
1385
  }
1388
1386
  }
1389
1387
  }
@@ -1449,32 +1447,32 @@ class OutputPipeline {
1449
1447
  }
1450
1448
  const draw = (r) => {
1451
1449
  if (!run) {
1452
- output_1.default.normal(this._runDetailsHeader());
1453
- output_1.default.normal(this._runDetailsId(r.runId, tabs));
1454
- output_1.default.normal(this._runHtmlUrl(r.url, tabs));
1455
- output_1.default.normal(this._runDetailsStatus(r.status, r.started, r.finished, tabs));
1456
- output_1.default.normal(this._runDetailsTriggerer(r, tabs));
1450
+ output_1.default.markup(this._runDetailsHeader());
1451
+ output_1.default.markup(this._runDetailsId(r.runId, tabs));
1452
+ output_1.default.markup(this._runHtmlUrl(r.url, tabs));
1453
+ output_1.default.markup(this._runDetailsStatus(r.status, r.started, r.finished, tabs));
1454
+ output_1.default.markup(this._runDetailsTriggerer(r, tabs));
1457
1455
  if (r?.description)
1458
- output_1.default.normal(this._runDetailsDescription(r, tabs));
1456
+ output_1.default.markup(this._runDetailsDescription(r, tabs));
1459
1457
  const started = this._runDetailsStarted(r.status, r.started, r.delayed, tabs);
1460
1458
  if (started)
1461
- output_1.default.normal(started);
1459
+ output_1.default.markup(started);
1462
1460
  const finished = this._runDetailsFinished(r.status, r.finished, tabs);
1463
1461
  if (finished)
1464
- output_1.default.normal(finished);
1462
+ output_1.default.markup(finished);
1465
1463
  const context = this._runContext(r, tabs);
1466
1464
  if (context.length > 0) {
1467
- output_1.default.normal('');
1465
+ output_1.default.markup('');
1468
1466
  context.forEach((str) => {
1469
- output_1.default.normal(str);
1467
+ output_1.default.markup(str);
1470
1468
  });
1471
1469
  }
1472
- output_1.default.normal('');
1473
- output_1.default.normal(this._runActionsHeader(tabs));
1470
+ output_1.default.markup('');
1471
+ output_1.default.markup(this._runActionsHeader(tabs));
1474
1472
  }
1475
1473
  const actions = this._runActions(r, true, 0, -1, tabs);
1476
1474
  actions.forEach((str) => {
1477
- output_1.default.normal(str);
1475
+ output_1.default.markup(str);
1478
1476
  });
1479
1477
  run = r;
1480
1478
  };
@@ -1515,42 +1513,42 @@ class OutputPipeline {
1515
1513
  else {
1516
1514
  if (totalFetchesCount > 1 || noFollow) {
1517
1515
  if (!noFollow)
1518
- output_1.default.normal('');
1519
- output_1.default.normal(this._runDetailsHeader());
1516
+ output_1.default.markup('');
1517
+ output_1.default.markup(this._runDetailsHeader());
1520
1518
  if (noFollow) {
1521
- output_1.default.normal(this._runDetailsId(run.runId, tabs));
1522
- output_1.default.normal(this._runHtmlUrl(run.url, tabs));
1519
+ output_1.default.markup(this._runDetailsId(run.runId, tabs));
1520
+ output_1.default.markup(this._runHtmlUrl(run.url, tabs));
1523
1521
  }
1524
- output_1.default.normal(this._runDetailsStatus(run.status, run.started, run.finished, tabs));
1522
+ output_1.default.markup(this._runDetailsStatus(run.status, run.started, run.finished, tabs));
1525
1523
  if (noFollow) {
1526
- output_1.default.normal(this._runDetailsTriggerer(run, tabs));
1524
+ output_1.default.markup(this._runDetailsTriggerer(run, tabs));
1527
1525
  if (run?.description)
1528
- output_1.default.normal(this._runDetailsDescription(run, tabs));
1526
+ output_1.default.markup(this._runDetailsDescription(run, tabs));
1529
1527
  }
1530
1528
  const started = this._runDetailsStarted(run.status, run.started, run.delayed, tabs);
1531
1529
  if (started)
1532
- output_1.default.normal(started);
1530
+ output_1.default.markup(started);
1533
1531
  const finished = this._runDetailsFinished(run.status, run.finished, tabs);
1534
1532
  if (finished)
1535
- output_1.default.normal(finished);
1533
+ output_1.default.markup(finished);
1536
1534
  if (noFollow) {
1537
1535
  const context = this._runContext(run, tabs);
1538
1536
  if (context.length > 0) {
1539
- output_1.default.normal('');
1537
+ output_1.default.markup('');
1540
1538
  context.forEach((str) => {
1541
- output_1.default.normal(str);
1539
+ output_1.default.markup(str);
1542
1540
  });
1543
1541
  }
1544
- output_1.default.normal('');
1545
- output_1.default.normal(this._runActionsHeader(tabs));
1542
+ output_1.default.markup('');
1543
+ output_1.default.markup(this._runActionsHeader(tabs));
1546
1544
  const actions = this._runActions(run, true, 0, -1, tabs);
1547
1545
  actions.forEach((str) => {
1548
- output_1.default.normal(str);
1546
+ output_1.default.markup(str);
1549
1547
  });
1550
1548
  }
1551
1549
  }
1552
- output_1.default.normal(this._dimLine());
1553
- output_1.default.normal(this._runActionsLogsHelp(identifier, runId, flags));
1550
+ output_1.default.markup(this._dimLine());
1551
+ output_1.default.markup(this._runActionsLogsHelp(identifier, runId, flags));
1554
1552
  }
1555
1553
  await finishRun(run);
1556
1554
  }
@@ -98,61 +98,61 @@ class Output {
98
98
  return chalk_1.default.hex('#00C9FF')(text);
99
99
  }
100
100
  static getTermKitCyanColor(text) {
101
- return `^C${text}^:`;
101
+ return `^C${this.escapeTermKit(text)}^:`;
102
102
  }
103
103
  static getBlueColor(text) {
104
104
  return chalk_1.default.hex('#1A86FD')(text);
105
105
  }
106
106
  static getTermKitBlueColor(text) {
107
- return `^B${text}^:`;
107
+ return `^B${this.escapeTermKit(text)}^:`;
108
108
  }
109
109
  static getPurpleColor(text) {
110
110
  return chalk_1.default.hex('#A06BC4')(text);
111
111
  }
112
112
  static getTermKitPurpleColor(text) {
113
- return `^M${text}^:`;
113
+ return `^M${this.escapeTermKit(text)}^:`;
114
114
  }
115
115
  static getMutedColor(text) {
116
116
  return chalk_1.default.hex('#8B8D98')(text);
117
117
  }
118
118
  static getTermKitMutedColor(text) {
119
- return `^w${text}^:`;
119
+ return `^w${this.escapeTermKit(text)}^:`;
120
120
  }
121
121
  static getDimColor(text) {
122
122
  return chalk_1.default.hex('#4A4A4A')(text);
123
123
  }
124
124
  static getTermKitDimColor(text) {
125
- return `^K${text}^:`;
125
+ return `^K${this.escapeTermKit(text)}^:`;
126
126
  }
127
127
  static getArgColor(text) {
128
128
  return chalk_1.default.hex('#5A8AB5')(text);
129
129
  }
130
130
  static getTermKitArgColor(text) {
131
- return `^B${text}^:`;
131
+ return `^B${this.escapeTermKit(text)}^:`;
132
132
  }
133
133
  static getLabelColor(text) {
134
134
  return chalk_1.default.hex('#D1D5DB')(text);
135
135
  }
136
136
  static getTermKitLabelColor(text) {
137
- return `^W${text}^:`;
137
+ return `^W${this.escapeTermKit(text)}^:`;
138
138
  }
139
139
  static getGreenColor(text) {
140
140
  return chalk_1.default.greenBright(text);
141
141
  }
142
142
  static getTermKitGreenColor(text) {
143
- return `^G${text}^:`;
143
+ return `^G${this.escapeTermKit(text)}^:`;
144
144
  }
145
145
  static getYellowColor(text) {
146
146
  return chalk_1.default.yellow(text);
147
147
  }
148
148
  static getTermKitYellowColor(text) {
149
- return `^Y${text}^:`;
149
+ return `^Y${this.escapeTermKit(text)}^:`;
150
150
  }
151
151
  static getRedColor(text) {
152
152
  return chalk_1.default.redBright(text);
153
153
  }
154
154
  static getTermKitRedColor(text) {
155
- return `^R${text}^:`;
155
+ return `^R${this.escapeTermKit(text)}^:`;
156
156
  }
157
157
  static getInquirerTheme() {
158
158
  return {
@@ -191,7 +191,7 @@ class Output {
191
191
  this.clearUndici();
192
192
  this.clearTerminal();
193
193
  if (msg)
194
- getTerminal()(`${msg}\n`);
194
+ process.stdout.write(`${msg}\n`);
195
195
  process.exit(0);
196
196
  }
197
197
  static exitCode(code) {
@@ -200,17 +200,29 @@ class Output {
200
200
  process.exit(code);
201
201
  }
202
202
  static newline() {
203
- getTerminal()('\n');
203
+ process.stdout.write('\n');
204
204
  this.inlineOutput = false;
205
205
  }
206
206
  static muted(txt, newLine = true) {
207
207
  this.normal(this.getMutedColor(txt), newLine);
208
208
  }
209
+ // Plain text, colored with chalk (the get*Color helpers). Written as is:
210
+ // terminal-kit would read ^x as markup and % as printf formatting, and so
211
+ // drop characters from user content and code (a ^ with the character after
212
+ // it, e.g. [^/]+ shown as []+).
209
213
  static normal(txt, newLine = true) {
214
+ process.stdout.write(newLine ? `${txt}\n` : txt);
215
+ this.inlineOutput = !newLine;
216
+ }
217
+ // Text with terminal-kit markup, built with the getTermKit*Color helpers
218
+ // (they escape what they color). markupOnly: ^ markup without printf
219
+ // formatting, the same as ScreenBuffer.put, so one escaped string renders
220
+ // the same in both.
221
+ static markup(txt, newLine = true) {
210
222
  let msg = txt;
211
223
  if (newLine)
212
224
  msg += '\n';
213
- getTerminal()(msg);
225
+ getTerminal().markupOnly(msg);
214
226
  this.inlineOutput = !newLine;
215
227
  }
216
228
  static progress(quiet, output = this.normal.bind(this)) {
@@ -239,13 +251,11 @@ class Output {
239
251
  return this.data(`No examples for ${command}.`);
240
252
  this.data(`EXAMPLES:\n${examples.map((example) => ` ### ${example.description}\n ${example.command}`).join('\n')}`);
241
253
  }
242
- // For payload embedded in terminal-kit markup (e.g. a dimmed log line):
243
- // neutralizes the ^-markup and %-formatting the payload would otherwise
244
- // trigger, so it renders verbatim while the surrounding markup still
245
- // works. Only for strings printed via terminal() - ScreenBuffer.put does
246
- // not printf-format, so there %% would render double.
254
+ // Payload inside terminal-kit markup renders verbatim: ^^ is a literal ^.
255
+ // % needs nothing, neither markup() nor ScreenBuffer.put printf-formats.
256
+ // The getTermKit*Color helpers call it on their text.
247
257
  static escapeTermKit(txt) {
248
- return txt.replace(/[%^]/g, '$&$&');
258
+ return txt.replace(/\^/g, '^^');
249
259
  }
250
260
  static writeStderr(txt) {
251
261
  process.stderr.write(`${txt}\n`);
@@ -379,7 +389,7 @@ class Output {
379
389
  if (!this.s && this.isTTY()) {
380
390
  this.s = await getTerminal().spinner();
381
391
  if (txt)
382
- getTerminal()(` ${txt}`);
392
+ process.stdout.write(` ${txt}`);
383
393
  }
384
394
  }
385
395
  static agentTunnels(tunnels) {
@@ -403,7 +413,7 @@ class Output {
403
413
  }
404
414
  static newCliVersion(version) {
405
415
  getTerminal().gray(`New version available (${version}). Run `);
406
- getTerminal()(' bdy version ');
416
+ process.stdout.write(' bdy version ');
407
417
  getTerminal().gray(`for details.\n\n`);
408
418
  }
409
419
  static newCliDockerVersion(version) {
@@ -443,7 +453,45 @@ class Output {
443
453
  const table = [...Object.entries(data)];
444
454
  this.table(table, false);
445
455
  }
446
- static table(data, firstRowBlue = true) {
456
+ /**
457
+ * terminal-kit's ANSI parser knows only the 16 basic colors: in `38;5;145`
458
+ * (256 colors) it takes the 5 for blink, and `38;2;r;g;b` (truecolor) turns
459
+ * into dim. This rewrites both to the nearest basic foreground color.
460
+ */
461
+ static toBasicAnsi(text) {
462
+ const basic = (r, g, b) => {
463
+ const max = Math.max(r, g, b);
464
+ const min = Math.min(r, g, b);
465
+ // greys: dark grey (90) or white (37)
466
+ if (max - min < 40)
467
+ return max < 180 ? 90 : 37;
468
+ const bright = max > 200;
469
+ // a channel counts when it is close to the strongest one
470
+ const code = (r > max * 0.7 ? 1 : 0) + (g > max * 0.7 ? 2 : 0) + (b > max * 0.7 ? 4 : 0);
471
+ return (bright ? 90 : 30) + code;
472
+ };
473
+ const fromIndex = (n) => {
474
+ if (n < 8)
475
+ return 30 + n;
476
+ if (n < 16)
477
+ return 90 + n - 8;
478
+ if (n >= 232) {
479
+ const v = 8 + (n - 232) * 10;
480
+ return basic(v, v, v);
481
+ }
482
+ const c = n - 16;
483
+ const level = (x) => (x === 0 ? 0 : 55 + x * 40);
484
+ return basic(level(Math.floor(c / 36)), level(Math.floor(c / 6) % 6), level(c % 6));
485
+ };
486
+ const esc = String.fromCharCode(27);
487
+ return text
488
+ .replace(new RegExp(`${esc}\\[38;5;(\\d+)m`, 'g'), (_, n) => `${esc}[${fromIndex(Number(n))}m`)
489
+ .replace(new RegExp(`${esc}\\[38;2;(\\d+);(\\d+);(\\d+)m`, 'g'), (_, r, g, b) => `${esc}[${basic(Number(r), Number(g), Number(b))}m`);
490
+ }
491
+ /** `ansi`: cells may carry chalk colors (widths are measured without the escape codes). */
492
+ static table(data, firstRowBlue = true, ansi = false) {
493
+ if (ansi)
494
+ data = data.map((row) => row.map((cell) => this.toBasicAnsi(cell)));
447
495
  // apply padding
448
496
  for (let i = 0; i < data.length; i += 1) {
449
497
  for (let j = 0; j < data[i].length; j += 1) {
@@ -465,6 +513,8 @@ class Output {
465
513
  };
466
514
  if (firstRowBlue)
467
515
  opts.firstRowTextAttr = { color: 'blue' };
516
+ if (ansi)
517
+ opts.contentHasMarkup = 'ansi';
468
518
  getTerminal().table(data, opts);
469
519
  }
470
520
  static configTunnels(tunnels) {