scripts/build-changelog.js
async function run() {
  try {
    // Find last release: Get tags, filter out wrong tags and pre-releases, then take last one.
    const { stdout } = // get last filtered tag, sorted by version numbers in ascending order
      await exec(`git tag | grep '${tagFrom}' | grep -Ev '-' | sort -V | tail -1`);
    const prevTag = stdout.trim();
    const nextVersion = parseVersion(argv[releaseNameParam]);

    // Normalize the given "release-name" for the tile (strip out pre-release information).
    const nextVersionString = `v${nextVersion.major}.${nextVersion.sub}.${nextVersion.minor}`;

    // Read previous changelog to extend it (remove ending line feeds -> added back in later)
    const changelogContent = fs.readFileSync('CHANGELOG.md', { encoding: 'utf8' }).trimRight();

    const config = lernaConfiguration.load();

    // This causes the "Unreleased" title to be replaced by a version that links to a github diff.
    config.nextVersion = `[${
      nextVersionString
    }](https://github.com/shopgate/pwa/compare/${prevTag}...${nextVersionString})`;

    // Skip creation if the "nextVersion" title is already present.
    if (changelogContent.includes(config.nextVersion)) {
      // Output the already existing data when already is there already.
      logger.log(changelogContent);
      return;
    }

    const changelog = new Changelog(config);

    // The "release-name" param is not supposed to be used here. Instead use "HEAD".
    const latestChanges = await changelog.createMarkdown({
      tagFrom: prevTag,
      tagTo,
    });

    // Add changes to the top of the main changelog
    let newChangelog = '# Changelog\n';
    if (appendPreviousChangelog) {
      newChangelog = changelogContent;
    }
    if (latestChanges.trim().length > 0) {
      newChangelog = newChangelog.replace(
        '# Changelog\n',
        `# Changelog\n\n${latestChanges.trim()}\n`
      );
      if (tagTo !== 'HEAD') {
        newChangelog = newChangelog.replace(
          `## ${tagTo} `,
          `## ${config.nextVersion} `
        );
      }
    }

    // Print the output for the bash/makefile to read
    logger.log(newChangelog);
  } catch (error) {
    throw error;
  }
}
async function run() {
  try {
    // Find last release: Get tags, filter out wrong tags and pre-releases, then take last one.
    const { stdout } = // get last filtered tag, sorted by version numbers in ascending order
      await exec(`git tag | grep '${tagFrom}' | grep -Ev '-' | sort -V | tail -1`);
    const prevTag = stdout.trim();
    const nextVersion = parseVersion(argv[releaseNameParam]);

    // Normalize the given "release-name" for the tile (strip out pre-release information).
    const nextVersionString = `v${nextVersion.major}.${nextVersion.sub}.${nextVersion.minor}`;

    // Read previous changelog to extend it (remove ending line feeds -> added back in later)
    const changelogContent = fs.readFileSync('CHANGELOG.md', { encoding: 'utf8' }).trimRight();

    const config = lernaConfiguration.load();

    // This causes the "Unreleased" title to be replaced by a version that links to a github diff.
    config.nextVersion = `[${
      nextVersionString
    }](https://github.com/shopgate/pwa/compare/${prevTag}...${nextVersionString})`;

    // Skip creation if the "nextVersion" title is already present.
    if (changelogContent.includes(config.nextVersion)) {
      // Output the already existing data when already is there already.
      logger.log(changelogContent);
      return;
    }

    const changelog = new Changelog(config);

    // The "release-name" param is not supposed to be used here. Instead use "HEAD".
    const latestChanges = await changelog.createMarkdown({
      tagFrom: prevTag,
      tagTo,
    });

    // Add changes to the top of the main changelog
    let newChangelog = '# Changelog\n';
    if (appendPreviousChangelog) {
      newChangelog = changelogContent;
    }
    if (latestChanges.trim().length > 0) {
      newChangelog = newChangelog.replace(
        '# Changelog\n',
        `# Changelog\n\n${latestChanges.trim()}\n`
      );
      if (tagTo !== 'HEAD') {
        newChangelog = newChangelog.replace(
          `## ${tagTo} `,
          `## ${config.nextVersion} `
        );
      }
    }

    // Print the output for the bash/makefile to read
    logger.log(newChangelog);
  } catch (error) {
    throw error;
  }
}
async function run ( ) { try { // Find last release: Get tags, filter out wrong tags and pre-releases, then take last one. const { stdout } = // get last filtered tag, sorted by version numbers in ascending order await exec ( ` ${ tagFrom } ` ) ; const prevTag = stdout . trim ( ) ; const nextVersion = parseVersion ( argv [ releaseNameParam ] ) ; // Normalize the given "release-name" for the tile (strip out pre-release information). const nextVersionString = ` ${ nextVersion . major } ${ nextVersion . sub } ${ nextVersion . minor } ` ; // Read previous changelog to extend it (remove ending line feeds -> added back in later) const changelogContent = fs . readFileSync ( 'CHANGELOG.md' , { encoding : 'utf8' } ) . trimRight ( ) ; const config = lernaConfiguration . load ( ) ; // This causes the "Unreleased" title to be replaced by a version that links to a github diff. config . nextVersion = ` ${ nextVersionString } ${ prevTag } ${ nextVersionString } ` ; // Skip creation if the "nextVersion" title is already present. if ( changelogContent . includes ( config . nextVersion ) ) { // Output the already existing data when already is there already. logger . log ( changelogContent ) ; return ; } const changelog = new Changelog ( config ) ; // The "release-name" param is not supposed to be used here. Instead use "HEAD". const latestChanges = await changelog . createMarkdown ( { tagFrom : prevTag , tagTo , } ) ; // Add changes to the top of the main changelog let newChangelog = '# Changelog\n' ; if ( appendPreviousChangelog ) { newChangelog = changelogContent ; } if ( latestChanges . trim ( ) . length > 0 ) { newChangelog = newChangelog . replace ( '# Changelog\n' , ` \n \n ${ latestChanges . trim ( ) } \n ` ) ; if ( tagTo !== 'HEAD' ) { newChangelog = newChangelog . replace ( ` ${ tagTo } ` , ` ${ config . nextVersion } ` ) ; } } // Print the output for the bash/makefile to read logger . log ( newChangelog ) ; } catch ( error ) { throw error ; } }
Main async method
Main async method