MCPcopy Create free account
hub / github.com/remix-run/react-router / generateChangelogContent

Function generateChangelogContent

scripts/changes/changes.ts:509–595  ·  view source on GitHub ↗
(
  release: PackageRelease,
  options: {
    /** Whether to include package name in heading. Default: false */
    includePackageName?: boolean;
    /** Whether to include the date in heading. Default: false */
    includeDate?: boolean;
    /** Markdown heading level (2 = ##, 3 = ###). Default: 2 */
    headingLevel?: 2 | 3;
    /** Optional footer to append at the end */
    footerLines?: string[];
    /** Optional "What's Changed" section to include before generated change sections */
    whatsChanged?: string;
    /** Whether to skip sorting changes (for root changelog generation). Default: false */
    skipSort?: boolean;
  } = {},
)

Source from the content-addressed store, hash-verified

507 * Generates changelog content for a package release
508 */
509export function generateChangelogContent(
510 release: PackageRelease,
511 options: {
512 /** Whether to include package name in heading. Default: false */
513 includePackageName?: boolean;
514 /** Whether to include the date in heading. Default: false */
515 includeDate?: boolean;
516 /** Markdown heading level (2 = ##, 3 = ###). Default: 2 */
517 headingLevel?: 2 | 3;
518 /** Optional footer to append at the end */
519 footerLines?: string[];
520 /** Optional "What's Changed" section to include before generated change sections */
521 whatsChanged?: string;
522 /** Whether to skip sorting changes (for root changelog generation). Default: false */
523 skipSort?: boolean;
524 } = {},
525): string {
526 let { includePackageName = false, headingLevel = 2 } = options;
527 let lines: string[] = [];
528
529 let headingPrefix = "#".repeat(headingLevel);
530 let packagePart = includePackageName ? `${release.packageName} ` : "";
531 lines.push(`${headingPrefix} ${packagePart}v${release.nextVersion}`);
532 lines.push("");
533
534 if (options.includeDate) {
535 let now = new Date();
536 // Generate a YYYY-MM-DD date for the local timezone, not GMT
537 let dateStr = new Date(
538 now.getFullYear(),
539 now.getMonth(),
540 now.getDate(),
541 now.getHours() - now.getTimezoneOffset() / 60,
542 )
543 .toISOString()
544 .substring(0, 10);
545 lines.push(`Date: ${dateStr}`);
546 lines.push("");
547 }
548
549 let subheadingLevel = headingLevel + 1;
550
551 if (options.whatsChanged) {
552 lines.push(options.whatsChanged.trim());
553 lines.push("");
554 }
555
556 // Generate sections in order: major, minor, patch (skipping empty sections)
557 for (let bumpType of bumpTypes) {
558 let section = generateBumpTypeSection(
559 release.changes,
560 bumpType,
561 subheadingLevel,
562 { skipSort: options.skipSort },
563 );
564 if (section) {
565 lines.push(section);
566 }

Callers 2

version.tsFile · 0.90
generatePackageChangelogFunction · 0.90

Calls 3

getGitTagFunction · 0.90
generateBumpTypeSectionFunction · 0.85
pushMethod · 0.65

Tested by

no test coverage detected