Skip to content

Commit

Permalink
fix: address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
pichlermarc committed Nov 22, 2023
1 parent 36692da commit a9bf07a
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions scripts/update-changelog.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
/**
* This script updates changelogs after lerna has updated versions in the respective areas (packages/*, experimental/packages/*)
* - removes all empty subsections (bugs, enhancements, etc.) in the changelog.
* - replaces the "Unreleased"-header with the version from the first non-private package in the directory (versions are expected to be uniform across a changelog)
* - adds a new "Unreleased"-header with empty subsections at the top
*
* Usage (from project root):
* - node scripts/update-changelog.js [PATH TO CHANGELOG] [DIRECTORY CONTAINING ASSOCIATED PACKAGES]
* Examples:
* - node scripts/update-changelog.js ./CHANGELOG.md ./packages
* - node scripts/update-changelog.js ./experimental/CHANGELOG.md ./experimental/packages
*/

const fs = require('fs');
const path = require("path");

Expand All @@ -20,10 +33,14 @@ function findFirstPackageVersion(basePath){
for(const packageDir of packageDirs){
const packageJsonPath = path.join(basePath, packageDir, 'package.json');
try {
const packageJson = fs.readFileSync(packageJsonPath, 'utf-8');
const version = JSON.parse(packageJson).version;
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));

if(packageJson.private === true || packageJson.private === 'true'){
console.log('Skipping version from private package at', packageJsonPath);
continue;
}

if(version != null){
if(packageJson.version != null){
return version;
}

Expand Down

0 comments on commit a9bf07a

Please sign in to comment.