From 84b820abc62c0aabea974ab8ed22f3ada05240fb Mon Sep 17 00:00:00 2001 From: Fabio Berger Date: Thu, 29 Mar 2018 20:03:11 +0200 Subject: Show semver diff --- packages/monorepo-scripts/src/custom_prepublish.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'packages/monorepo-scripts/src') diff --git a/packages/monorepo-scripts/src/custom_prepublish.ts b/packages/monorepo-scripts/src/custom_prepublish.ts index b18389fcd..98ed3e8d3 100644 --- a/packages/monorepo-scripts/src/custom_prepublish.ts +++ b/packages/monorepo-scripts/src/custom_prepublish.ts @@ -6,6 +6,7 @@ import * as _ from 'lodash'; import * as moment from 'moment'; import * as path from 'path'; import { exec as execAsync } from 'promisify-child-process'; +import semverDiff = require('semver-diff'); import semverSort = require('semver-sort'); import { Changelog, Changes, UpdatedPackage } from './types'; @@ -22,7 +23,9 @@ const TODAYS_TIMESTAMP = moment().unix(); const relevantLernaPackages = _.filter(allLernaPackages, pkg => { return _.includes(updatedPackageNames, pkg.package.name); }); + const packageToVersionChange: { [name: string]: string } = {}; _.each(relevantLernaPackages, lernaPackage => { + const packageName = lernaPackage.package.name; const changelogJSONPath = path.join(lernaPackage.location, 'CHANGELOG.json'); const changelogJSON = getChangelogJSONOrCreateIfMissing(lernaPackage.package.name, changelogJSONPath); let changelogs: Changelog[]; @@ -49,6 +52,7 @@ const TODAYS_TIMESTAMP = moment().unix(); ], }; changelogs = [newChangelogEntry, ...changelogs]; + packageToVersionChange[packageName] = semverDiff(currentVersion, nextPatchVersion); } else { // Update existing entry with timestamp const lastEntry = changelogs[0]; @@ -59,6 +63,7 @@ const TODAYS_TIMESTAMP = moment().unix(); const proposedNextVersion = lastEntry.version; lastEntry.version = updateVersionNumberIfNeeded(currentVersion, proposedNextVersion); changelogs[0] = lastEntry; + packageToVersionChange[packageName] = semverDiff(currentVersion, lastEntry.version); } // Save updated CHANGELOG.json @@ -68,6 +73,11 @@ const TODAYS_TIMESTAMP = moment().unix(); const changelogMdPath = path.join(lernaPackage.location, 'CHANGELOG.md'); fs.writeFileSync(changelogMdPath, changelogMd); }); + utils.log(`All CHANGELOGS successfully updated. Please commit and push these changes to development.`); + utils.log(`New package versions are:`); + _.each(packageToVersionChange, (versionChange: string, pkgName: string) => { + utils.log(`${pkgName}: ${versionChange}`); + }); })().catch(err => { utils.log(err); process.exit(1); -- cgit v1.2.3