All files / packages/sds-release-manager/src/utils validation-comment.ts

100% Statements 7/7
100% Branches 12/12
100% Functions 2/2
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50                                          3x     12x 12x 12x         12x 12x     3x                            
/**
 * Builds the deterministic byte-level validation comment posted on a freshly
 * created release PR. Because the six LFS files show only pointer changes in the
 * PR diff, this table is the human-readable view of what actually changed per
 * file (unchanged / version-stamp only / content change with a byte delta).
 */
export type ValidationCommentInput = {
  version: string;
  verdict: 'version-only' | 'content-change';
  target: string;
  artifacts: Array<{
    gitcorePath: string;
    storage: 'git' | 'lfs';
    rawEqual: boolean;
    stampNormalizedEqual: boolean;
    baselineSize: number;
    candidateSize: number;
  }>;
};
 
export function buildValidationComment(input: ValidationCommentInput): string {
  const rows = input.artifacts.map((artifact) => {
    // Raw-equal is unchanged; equal only after stamp-normalization is a
    // version-only re-stamp; otherwise it is a real content change (show bytes).
    const stampOnly = !artifact.rawEqual && artifact.stampNormalizedEqual;
    const difference = artifact.candidateSize - artifact.baselineSize;
    const change = artifact.rawEqual
      ? 'unchanged'
      : stampOnly
        ? 'version stamp'
        : `${difference >= 0 ? '+' : ''}${difference} bytes`;
    const note = artifact.rawEqual ? 'unchanged' : stampOnly ? 'version-only re-stamp' : 'content change';
    return `| \`${artifact.gitcorePath}\` | ${change} | ${note} |`;
  });
 
  return [
    '## release:core-css validation',
    '',
    `Validated SLDS ${input.version} against the \`${input.target}\` baseline.`,
    '',
    '| File | Change | Note |',
    '| --- | --- | --- |',
    ...rows,
    '',
    `All 7 output files stamp **Lightning Design System ${input.version}**.`,
    '',
    '> The six LFS-tracked files show only pointer changes in the PR diff, so this table is the byte-level view of what changed. To verify independently, check out this branch in a gitcore clone with LFS auth and inspect the hydrated files directly.',
  ].join('\n');
}