@prisma-next/cli 0.12.0-dev.6 → 0.12.0-dev.7

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.
@@ -1,7 +1,8 @@
1
1
  import { EMPTY_CONTRACT_HASH } from '@prisma-next/migration-tools/constants';
2
- import { bold } from 'colorette';
2
+ import { bold, createColors } from 'colorette';
3
3
  import stringWidth from 'string-width';
4
4
  import type { GlyphMode } from '../glyph-mode';
5
+ import { laneColorForColumn } from './migration-graph-lane-colors';
5
6
  import type {
6
7
  MigrationGraphGridModel,
7
8
  MigrationGraphGridRow,
@@ -116,56 +117,272 @@ function arrowForEdgeKind(
116
117
  return palette.edgeArrow[kind];
117
118
  }
118
119
 
120
+ /**
121
+ * The leftmost lane (column 0) renders with the neutral dim lane style rather
122
+ * than a palette hue — in the common single-lane case it has nothing to be told
123
+ * apart from. Used as the "no owning arc" sentinel during colour resolution.
124
+ */
125
+ const NEUTRAL_LANE = 0;
126
+
127
+ /**
128
+ * Forced bold for branch-coloured names. A branched name pairs its lane hue
129
+ * (also forced, via {@link laneColorForColumn}) with bold; both must emit even
130
+ * when colorette's ambient TTY detection is off, so the colorized branch name
131
+ * is deterministically bold + hue rather than hue-only.
132
+ */
133
+ const { bold: forcedBold } = createColors({ useColor: true });
134
+
135
+ /**
136
+ * The colour-source column for each cell of a row, resolved together because a
137
+ * routed back-arc spans columns and must read as **one hue** rather than a
138
+ * per-column "rainbow". An arc's horizontal bridges, corners, and node-pair
139
+ * connector all take the arc's owning back-lane column (the corner that closes
140
+ * the arc), not the column they pass through.
141
+ */
142
+ interface RowLaneColors {
143
+ /** Colour column for a cell's structural glyph (lane / spine / arc body). */
144
+ readonly lane: readonly number[];
145
+ /** Colour column for a node arc-pair's connector half (`◂` / `─`). */
146
+ readonly connector: readonly number[];
147
+ }
148
+
149
+ /**
150
+ * Resolve per-cell colour columns for a row. Scanning right-to-left lets each
151
+ * arc bridge inherit the corner column that closes it (the arc's back-lane), so
152
+ * the whole arc — vertical run (already its own column), horizontal bridges,
153
+ * corners, crossings, and the `◂`/`─` connector — reads as a single continuous
154
+ * hue. A crossing can only be one colour, so rather than leave it dim (wrong for
155
+ * both crossing lines) it takes the arc owning the horizontal run at this row
156
+ * (the nearest corner to its right); the crossed vertical lane is simply
157
+ * occluded at that one cell and reappears on the next row.
158
+ */
159
+ function resolveRowLaneColors(cells: readonly StructuralCell[]): RowLaneColors {
160
+ const lane = new Array<number>(cells.length);
161
+ const connector = new Array<number>(cells.length);
162
+ let arcCorner = NEUTRAL_LANE;
163
+ for (let column = cells.length - 1; column >= 0; column--) {
164
+ const cell = cells[column];
165
+ connector[column] = arcCorner;
166
+ switch (cell?.kind) {
167
+ case 'arc-branch-corner':
168
+ case 'arc-land-corner':
169
+ arcCorner = column;
170
+ lane[column] = column;
171
+ break;
172
+ case 'arc-branch-tee':
173
+ // An inner co-sourced arc's own back-lane junction: its vertical run
174
+ // continues below in this column, so it keeps its own column hue.
175
+ lane[column] = column;
176
+ break;
177
+ case 'arc-crossing':
178
+ case 'arc-land-bridge':
179
+ lane[column] = arcCorner;
180
+ break;
181
+ case 'horizontal-pass':
182
+ lane[column] = arcCorner === NEUTRAL_LANE ? column : arcCorner;
183
+ break;
184
+ case 'node':
185
+ lane[column] = column;
186
+ arcCorner = NEUTRAL_LANE;
187
+ break;
188
+ default:
189
+ lane[column] = column;
190
+ arcCorner = NEUTRAL_LANE;
191
+ }
192
+ }
193
+ return { lane, connector };
194
+ }
195
+
196
+ /**
197
+ * Per-cell colour for a forward branch/merge connector row, split into the
198
+ * cell's junction `glyph` and its trailing `dash`. A connector's horizontal run
199
+ * is one logical line (a fork into new lanes, or a merge into a surviving lane)
200
+ * and reads best as the colour of the lane each segment serves — not dim-gray
201
+ * or a per-pass-through-column "rainbow".
202
+ */
203
+ interface ConnectorLaneColors {
204
+ /** Colour column for a cell's junction glyph (`├` / `┬` / `┴` / `╮` / `╯`). */
205
+ readonly glyph: readonly number[];
206
+ /** Colour column for a tee's trailing `─` — the branch it leads into. */
207
+ readonly dash: readonly number[];
208
+ }
209
+
210
+ /**
211
+ * Resolve per-cell connector colours. Scanning right-to-left, a corner or an
212
+ * intermediate tee anchors its own lane (its junction glyph takes that column),
213
+ * but a tee's **trailing dash leads into the branch on its right** (the next
214
+ * branch point), so `┬─` reads as "this lane, then on toward the next" rather
215
+ * than tinting the dash with the left lane. The leading tee at `startLane` (the
216
+ * fork/merge origin) and pure horizontal segments inherit the nearest branch
217
+ * point to their right whole-cell, so the run into a branch — or collapsing
218
+ * into a merge corner — stays continuous. Pass-through verticals outside the
219
+ * run keep their own column (column 0 stays neutral).
220
+ */
221
+ function resolveConnectorLaneColors(
222
+ cells: readonly StructuralCell[],
223
+ startLane: number,
224
+ ): ConnectorLaneColors {
225
+ const glyph = new Array<number>(cells.length);
226
+ const dash = new Array<number>(cells.length);
227
+ let owner = NEUTRAL_LANE;
228
+ for (let column = cells.length - 1; column >= 0; column--) {
229
+ const cell = cells[column];
230
+ switch (cell?.kind) {
231
+ case 'branch-corner':
232
+ case 'merge-corner':
233
+ owner = column;
234
+ glyph[column] = column;
235
+ dash[column] = column;
236
+ break;
237
+ case 'branch-tee':
238
+ case 'merge-tee':
239
+ if (column === startLane) {
240
+ const served = owner === NEUTRAL_LANE ? column : owner;
241
+ glyph[column] = served;
242
+ dash[column] = served;
243
+ } else {
244
+ dash[column] = owner === NEUTRAL_LANE ? column : owner;
245
+ glyph[column] = column;
246
+ owner = column;
247
+ }
248
+ break;
249
+ case 'horizontal-pass': {
250
+ const served = owner === NEUTRAL_LANE ? column : owner;
251
+ glyph[column] = served;
252
+ dash[column] = served;
253
+ break;
254
+ }
255
+ default:
256
+ glyph[column] = column;
257
+ dash[column] = column;
258
+ }
259
+ }
260
+ return { glyph, dash };
261
+ }
262
+
263
+ /**
264
+ * Style a structural glyph by its resolved colour column. Column 0 and the
265
+ * neutral sentinel render dim (`style.lane`); columns ≥ 1 take a palette hue.
266
+ */
267
+ function laneStylerForColumn(
268
+ colorColumn: number,
269
+ colorize: boolean,
270
+ style: MigrationListStyler,
271
+ ): (text: string) => string {
272
+ if (!colorize || colorColumn <= NEUTRAL_LANE) {
273
+ return (text) => style.lane(text);
274
+ }
275
+ return laneColorForColumn(colorColumn);
276
+ }
277
+
278
+ /**
279
+ * Tint a branch-owned token (direction arrow, migration name) by its edge's
280
+ * lane so the whole branch row reads in one colour. Column 0 has nothing to be
281
+ * told apart from in the common linear chain, so it keeps the token's existing
282
+ * default styling (`fallback`) rather than a palette hue; only lanes ≥ 1 take a
283
+ * colour. With colour off, the fallback (also colourless) is used unchanged.
284
+ */
285
+ function branchStylerOrDefault(
286
+ column: number,
287
+ colorize: boolean,
288
+ fallback: (text: string) => string,
289
+ ): (text: string) => string {
290
+ if (!colorize || column <= NEUTRAL_LANE) {
291
+ return fallback;
292
+ }
293
+ return laneColorForColumn(column);
294
+ }
295
+
296
+ /**
297
+ * Render a connector tee (`├─` / `┬─` / `┴─`) with its junction glyph and its
298
+ * trailing dash coloured independently: the junction anchors its own lane while
299
+ * the dash leads into the branch on its right.
300
+ */
301
+ function renderConnectorTee(
302
+ pair: string,
303
+ glyphColumn: number,
304
+ dashColumn: number,
305
+ colorize: boolean,
306
+ style: MigrationListStyler,
307
+ ): string {
308
+ const glyph = laneStylerForColumn(glyphColumn, colorize, style);
309
+ if (glyphColumn === dashColumn) {
310
+ return glyph(pair);
311
+ }
312
+ return glyph(pair.slice(0, 1)) + laneStylerForColumn(dashColumn, colorize, style)(pair.slice(1));
313
+ }
314
+
119
315
  /**
120
316
  * A node-marker glyph pair (`○◂`, `○─`, `*<`, `*-`) is the contract node
121
- * marker (`○` / `*`) followed by an arc connector (`◂` / `─` / `<` / `-`).
122
- * The marker is the signal and stays bright (`style.kind`); the connector is
123
- * gutter and stays dim (`style.lane`) consistent with the plain node marker,
124
- * which is never dimmed.
317
+ * marker (`○` / `*`) followed by an arc connector (`◂` / `─` / `<` / `-`). The
318
+ * marker takes its own lane's hue (so each node visibly belongs to its branch);
319
+ * the connector follows the arc it belongs to (its owning back-lane hue).
320
+ * Direction arrows are handled elsewhere — they take their edge's lane hue too.
125
321
  */
126
- function renderNodeMarkerPair(pair: string, style: MigrationListStyler): string {
127
- return style.kind(pair.slice(0, 1)) + style.lane(pair.slice(1));
322
+ function renderNodeMarkerPair(
323
+ pair: string,
324
+ nodeColumn: number,
325
+ arcColumn: number,
326
+ colorize: boolean,
327
+ style: MigrationListStyler,
328
+ ): string {
329
+ const marker = laneStylerForColumn(nodeColumn, colorize, style);
330
+ const connector = laneStylerForColumn(arcColumn, colorize, style);
331
+ return marker(pair.slice(0, 1)) + connector(pair.slice(1));
128
332
  }
129
333
 
130
334
  function renderCellPair(
131
335
  cell: StructuralCell,
336
+ column: number,
337
+ colors: RowLaneColors,
338
+ colorize: boolean,
132
339
  style: MigrationListStyler,
133
340
  palette: MigrationGraphTreeGlyphPalette,
134
341
  ): string {
342
+ const laneColumn = colors.lane[column] ?? column;
343
+ const lane = laneStylerForColumn(laneColumn, colorize, style);
135
344
  switch (cell.kind) {
136
- case 'node':
137
- if (cell.arcLand === true) return renderNodeMarkerPair(palette.arcLand, style);
138
- if (cell.arcTee === true) return renderNodeMarkerPair(palette.arcTee, style);
139
- return style.kind(palette.node);
345
+ case 'node': {
346
+ const arcColumn = colors.connector[column] ?? NEUTRAL_LANE;
347
+ if (cell.arcLand === true) {
348
+ return renderNodeMarkerPair(palette.arcLand, column, arcColumn, colorize, style);
349
+ }
350
+ if (cell.arcTee === true) {
351
+ return renderNodeMarkerPair(palette.arcTee, column, arcColumn, colorize, style);
352
+ }
353
+ return lane(palette.node);
354
+ }
140
355
  case 'vertical-pass':
141
- return style.lane(palette.verticalPass);
356
+ return lane(palette.verticalPass);
142
357
  case 'edge-lane':
143
- // The lane stays dim; the direction arrow (↑ / ↓ / ⟲) is the signal and
144
- // stays bright, like the contract-node marker.
145
358
  return cell.ownsLabel
146
- ? style.lane(palette.verticalPass.trimEnd()) +
147
- style.kind(arrowForEdgeKind(cell.edgeKind, palette))
148
- : style.lane(palette.verticalPass);
359
+ ? lane(palette.verticalPass.trimEnd()) +
360
+ branchStylerOrDefault(
361
+ column,
362
+ colorize,
363
+ style.kind,
364
+ )(arrowForEdgeKind(cell.edgeKind, palette))
365
+ : lane(palette.verticalPass);
149
366
  case 'branch-tee':
150
- return style.lane(palette.branchTee);
367
+ return lane(palette.branchTee);
151
368
  case 'merge-tee':
152
- return style.lane(palette.mergeTee);
369
+ return lane(palette.mergeTee);
153
370
  case 'branch-corner':
154
- return style.lane(palette.branchCorner);
371
+ return lane(palette.branchCorner);
155
372
  case 'merge-corner':
156
- return style.lane(palette.mergeCorner);
373
+ return lane(palette.mergeCorner);
157
374
  case 'arc-branch-corner':
158
- return style.lane(palette.arcBranchCorner);
375
+ return lane(palette.arcBranchCorner);
159
376
  case 'arc-branch-tee':
160
- return style.lane(palette.arcBranchTee);
377
+ return lane(palette.arcBranchTee);
161
378
  case 'arc-land-corner':
162
- return style.lane(palette.arcLandCorner);
379
+ return lane(palette.arcLandCorner);
163
380
  case 'arc-crossing':
164
- return style.lane(palette.arcCrossing);
381
+ return lane(palette.arcCrossing);
165
382
  case 'arc-land-bridge':
166
- return style.lane(palette.arcLandBridge);
383
+ return lane(palette.arcLandBridge);
167
384
  case 'horizontal-pass':
168
- return style.lane(palette.horizontalPass);
385
+ return lane(palette.horizontalPass);
169
386
  case 'empty':
170
387
  return ' ';
171
388
  }
@@ -174,34 +391,53 @@ function renderCellPair(
174
391
  function renderConnectorRow(
175
392
  row: MigrationGraphGridRow,
176
393
  gridWidth: number,
394
+ colorize: boolean,
177
395
  style: MigrationListStyler,
178
396
  palette: MigrationGraphTreeGlyphPalette,
179
397
  ): string {
180
398
  const isMerge = row.kind === 'merge-connector';
181
399
  if (row.cells.length > 0) {
400
+ const colors = resolveConnectorLaneColors(row.cells, row.startLane ?? 0);
182
401
  let seenTee = false;
183
402
  let out = '';
184
- for (const cell of row.cells) {
403
+ for (let column = 0; column < row.cells.length; column++) {
404
+ const cell = row.cells[column];
405
+ if (cell === undefined) continue;
406
+ const glyphColumn = colors.glyph[column] ?? column;
407
+ const dashColumn = colors.dash[column] ?? glyphColumn;
408
+ const lane = laneStylerForColumn(glyphColumn, colorize, style);
185
409
  switch (cell.kind) {
186
410
  case 'branch-tee':
187
- out += style.lane(seenTee ? palette.connectorBranchTeeCo : palette.connectorBranchTee);
411
+ out += renderConnectorTee(
412
+ seenTee ? palette.connectorBranchTeeCo : palette.connectorBranchTee,
413
+ glyphColumn,
414
+ dashColumn,
415
+ colorize,
416
+ style,
417
+ );
188
418
  seenTee = true;
189
419
  break;
190
420
  case 'merge-tee':
191
- out += style.lane(seenTee ? palette.connectorMergeTeeCo : palette.connectorBranchTee);
421
+ out += renderConnectorTee(
422
+ seenTee ? palette.connectorMergeTeeCo : palette.connectorBranchTee,
423
+ glyphColumn,
424
+ dashColumn,
425
+ colorize,
426
+ style,
427
+ );
192
428
  seenTee = true;
193
429
  break;
194
430
  case 'branch-corner':
195
- out += style.lane(palette.branchCorner);
431
+ out += lane(palette.branchCorner);
196
432
  break;
197
433
  case 'merge-corner':
198
- out += style.lane(palette.mergeCorner);
434
+ out += lane(palette.mergeCorner);
199
435
  break;
200
436
  case 'vertical-pass':
201
- out += style.lane(palette.verticalPass);
437
+ out += lane(palette.verticalPass);
202
438
  break;
203
439
  case 'horizontal-pass':
204
- out += style.lane(palette.horizontalPass);
440
+ out += lane(palette.horizontalPass);
205
441
  break;
206
442
  default:
207
443
  out += ' ';
@@ -218,13 +454,15 @@ function renderConnectorRow(
218
454
 
219
455
  const start = row.startLane ?? 0;
220
456
  const end = row.endLane ?? start;
457
+ // The whole fork/merge run reads as one line in the served lane's hue (the
458
+ // corner it reaches); pass-through columns outside the run keep their own.
459
+ const runLane = laneStylerForColumn(end, colorize, style);
221
460
  let out = '';
222
461
  for (let column = 0; column < gridWidth; column++) {
223
462
  if (column < start || column > end) out += ' ';
224
- else if (column === start) out += style.lane(palette.connectorBranchTee);
225
- else if (column === end)
226
- out += style.lane(isMerge ? palette.mergeCorner : palette.branchCorner);
227
- else out += style.lane(isMerge ? palette.connectorMergeTeeCo : palette.connectorBranchTeeCo);
463
+ else if (column === start) out += runLane(palette.connectorBranchTee);
464
+ else if (column === end) out += runLane(isMerge ? palette.mergeCorner : palette.branchCorner);
465
+ else out += runLane(isMerge ? palette.connectorMergeTeeCo : palette.connectorBranchTeeCo);
228
466
  }
229
467
  return out;
230
468
  }
@@ -297,6 +535,13 @@ function padVisible(text: string, targetWidth: number): string {
297
535
  return text + ' '.repeat(padding);
298
536
  }
299
537
 
538
+ const ANSI_ESCAPE = '\x1b';
539
+
540
+ function trimTrailingWhitespace(line: string): string {
541
+ const trailingSpaceBeforeReset = new RegExp(`[\\t ]+((?:${ANSI_ESCAPE}\\[[0-9;]*m)+)$`);
542
+ return line.replace(trailingSpaceBeforeReset, '$1').replace(/\s+$/, '');
543
+ }
544
+
300
545
  function gridWidthForModel(rows: readonly MigrationGraphGridRow[]): number {
301
546
  return rows.reduce(
302
547
  (max, row) =>
@@ -373,11 +618,18 @@ export function renderMigrationGraphTree(
373
618
  }
374
619
 
375
620
  if (row.kind === 'branch-connector' || row.kind === 'merge-connector') {
376
- lines.push(renderConnectorRow(row, gridWidth, style, palette).replace(/\s+$/, ''));
621
+ lines.push(
622
+ trimTrailingWhitespace(renderConnectorRow(row, gridWidth, opts.colorize, style, palette)),
623
+ );
377
624
  continue;
378
625
  }
379
626
 
380
- let gutter = row.cells.map((cell) => renderCellPair(cell, style, palette)).join('');
627
+ const cellColors = resolveRowLaneColors(row.cells);
628
+ let gutter = row.cells
629
+ .map((cell, column) =>
630
+ renderCellPair(cell, column, cellColors, opts.colorize, style, palette),
631
+ )
632
+ .join('');
381
633
  const prevRow = model.rows[rowIndex - 1];
382
634
  let laneSpan = row.cells.length;
383
635
  if (row.kind === 'node') {
@@ -402,12 +654,16 @@ export function renderMigrationGraphTree(
402
654
  ) {
403
655
  gutter = row.cells
404
656
  .slice(0, 1)
405
- .map((cell) => renderCellPair(cell, style, palette))
657
+ .map((cell, column) =>
658
+ renderCellPair(cell, column, cellColors, opts.colorize, style, palette),
659
+ )
406
660
  .join('');
407
661
  } else if (row.kind === 'node' && laneSpan < row.cells.length && !nodeHasArcDecoration(row)) {
408
662
  gutter = row.cells
409
663
  .slice(0, laneSpan)
410
- .map((cell) => renderCellPair(cell, style, palette))
664
+ .map((cell, column) =>
665
+ renderCellPair(cell, column, cellColors, opts.colorize, style, palette),
666
+ )
411
667
  .join('');
412
668
  } else if (gutter.length < laneSpan * 2) {
413
669
  gutter = gutter.padEnd(laneSpan * 2, ' ');
@@ -421,16 +677,18 @@ export function renderMigrationGraphTree(
421
677
  if (contractHash === EMPTY_CONTRACT_HASH) {
422
678
  const trailingLanes = row.cells
423
679
  .slice(1)
424
- .map((cell) => renderCellPair(cell, style, palette))
680
+ .map((cell, offset) =>
681
+ renderCellPair(cell, offset + 1, cellColors, opts.colorize, style, palette),
682
+ )
425
683
  .join('');
426
684
  const emptyGutter = palette.emptySource.padEnd(2, ' ') + trailingLanes;
427
685
  const overlayNames = overlayNamesForContract(contractHash, opts);
428
686
  if (overlayNames.length === 0) {
429
- lines.push(emptyGutter.replace(/\s+$/, ''));
687
+ lines.push(trimTrailingWhitespace(emptyGutter));
430
688
  continue;
431
689
  }
432
690
  const overlay = style.refs(overlayNames);
433
- lines.push(`${padVisible(emptyGutter, dataColumn)}${overlay}`.replace(/\s+$/, ''));
691
+ lines.push(trimTrailingWhitespace(`${padVisible(emptyGutter, dataColumn)}${overlay}`));
434
692
  continue;
435
693
  }
436
694
  const hashText = style.sourceHash(
@@ -442,7 +700,7 @@ export function renderMigrationGraphTree(
442
700
  ? ' '.repeat(Math.max(0, dataColumn - labelColumn - stringWidth(hashText)))
443
701
  : '';
444
702
  const overlay = overlayNames.length > 0 ? style.refs(overlayNames) : '';
445
- lines.push(`${gutterPad}${hashText}${overlayPad}${overlay}`.replace(/\s+$/, ''));
703
+ lines.push(trimTrailingWhitespace(`${gutterPad}${hashText}${overlayPad}${overlay}`));
446
704
  continue;
447
705
  }
448
706
 
@@ -450,10 +708,48 @@ export function renderMigrationGraphTree(
450
708
  if (edge === undefined) continue;
451
709
 
452
710
  const dirNamePadding = ' '.repeat(Math.max(0, dirNameWidth - edge.dirName.length));
453
- const dirName = `${style.dirName(edge.dirName)}${dirNamePadding}`;
711
+ const laneIndex = row.laneIndex ?? 0;
712
+ // A branched name keeps its bold (via `style.dirName`) and adds the lane
713
+ // hue, so it reads as one with its lane/arrow; column-0 names stay bold-only.
714
+ const dirNameStyler =
715
+ opts.colorize && laneIndex > NEUTRAL_LANE
716
+ ? (text: string) => forcedBold(laneColorForColumn(laneIndex)(text))
717
+ : style.dirName;
718
+ const dirName = `${dirNameStyler(edge.dirName)}${dirNamePadding}`;
454
719
  const hashColumn = formatEdgeHashColumn(edge, style, hashLength, palette);
455
- lines.push(`${gutterPad}${dirName}${hashColumn}`.replace(/\s+$/, ''));
720
+ lines.push(trimTrailingWhitespace(`${gutterPad}${dirName}${hashColumn}`));
456
721
  }
457
722
 
458
723
  return lines.join('\n');
459
724
  }
725
+
726
+ export interface RenderMigrationGraphLegendOptions {
727
+ readonly colorize: boolean;
728
+ readonly glyphMode?: GlyphMode;
729
+ }
730
+
731
+ /**
732
+ * A compact key for the `--tree` visual language: the contract marker, the
733
+ * in-lane direction arrows, the empty baseline, the `(refs)` overlay (including
734
+ * the reserved `db` live-database and `contract` working-schema markers), and a
735
+ * worked sample of the data-column `from → to` migration hash arrow.
736
+ *
737
+ * Honors the same glyph palette (unicode vs ASCII) and `colorize` gate as the
738
+ * tree renderer, so the key matches whatever the graph itself drew and stays
739
+ * pipe-safe (zero ANSI when color is off). The caller adds the trailing blank
740
+ * line that separates this stderr key from the graph on stdout.
741
+ */
742
+ export function renderMigrationGraphLegend(opts: RenderMigrationGraphLegendOptions): string {
743
+ const palette = paletteFor(opts.glyphMode ?? 'unicode');
744
+ const style = createAnsiMigrationListStyler({ useColor: opts.colorize });
745
+ const node = palette.node.trimEnd();
746
+ const sampleArrow = `${style.sourceHash('aaaaaa')} ${style.glyph(palette.forwardArrow)} ${style.destHash('bbbbbb')}`;
747
+ return [
748
+ 'Legend:',
749
+ ` ${style.kind(node)} contract ${style.kind(palette.edgeArrow.forward)} forward ${style.kind(palette.edgeArrow.rollback)} rollback`,
750
+ ` ${style.kind(palette.edgeArrow.self)} migration without schema change`,
751
+ ` ${style.glyph(palette.emptySource)} empty database (baseline)`,
752
+ ` ${style.refs(['refs'])} ${DB_MARKER_NAME} / ${CONTRACT_MARKER_NAME} markers`,
753
+ ` ${sampleArrow} migration from contract aaaaaa to bbbbbb`,
754
+ ].join('\n');
755
+ }