MCPcopy
hub / github.com/serverless/serverless / renderDiff

Function renderDiff

packages/serverless/lib/plugins/aws/diff/run-diff.js:391–470  ·  view source on GitHub ↗
(stream, templateDiff)

Source from the content-addressed store, hash-verified

389 * adds or renames a section, that test fails and signals an update is needed.
390 */
391export function renderDiff(stream, templateDiff) {
392 const formatter = new Formatter(stream, {}, templateDiff)
393
394 if (
395 templateDiff.awsTemplateFormatVersion ||
396 templateDiff.transform ||
397 templateDiff.description
398 ) {
399 formatter.printSectionHeader('Template')
400 formatter.formatDifference(
401 'AWSTemplateFormatVersion',
402 'AWSTemplateFormatVersion',
403 templateDiff.awsTemplateFormatVersion,
404 )
405 formatter.formatDifference('Transform', 'Transform', templateDiff.transform)
406 formatter.formatDifference(
407 'Description',
408 'Description',
409 templateDiff.description,
410 )
411 formatter.printSectionFooter()
412 }
413
414 // Security section — keep the IAM and security-group tables (genuinely
415 // useful for review) but skip the trailing tracker-link advisory.
416 if (
417 templateDiff.iamChanges.hasChanges ||
418 templateDiff.securityGroupChanges.hasChanges
419 ) {
420 formatter.formatIamChanges(templateDiff.iamChanges)
421 formatter.formatSecurityGroupChanges(templateDiff.securityGroupChanges)
422 formatter.printSectionFooter()
423 }
424
425 // For sections whose values are objects (Parameters, Metadata, Mappings,
426 // Conditions, Outputs), the upstream default renderer dumps the entire
427 // before/after JSON onto a single line. That's unreadable in practice —
428 // especially for Outputs, where a single Lambda Version Ref change drags
429 // the whole Output blob across the screen twice. Render those entries as
430 // a tree-style diff instead, matching how the Resources section already
431 // surfaces property-level changes.
432 const treeFormatter = nestedSectionFormatter(formatter)
433 formatter.formatSection(
434 'Parameters',
435 'Parameter',
436 templateDiff.parameters,
437 treeFormatter,
438 )
439 formatter.formatSection(
440 'Metadata',
441 'Metadata',
442 templateDiff.metadata,
443 treeFormatter,
444 )
445 formatter.formatSection(
446 'Mappings',
447 'Mapping',
448 templateDiff.mappings,

Callers 2

run-diff.test.jsFile · 0.90
runDiffFunction · 0.85

Calls 1

nestedSectionFormatterFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…