diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-30 02:03:11 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-30 02:03:11 +0800 |
commit | 84b820abc62c0aabea974ab8ed22f3ada05240fb (patch) | |
tree | 7a61e3cca79dbe873158ceea6cd77fd1c5f39388 /packages/monorepo-scripts | |
parent | cc4ff568a9ad976efe28af1eeb0737e9d09ed0fe (diff) | |
download | dexon-sol-tools-84b820abc62c0aabea974ab8ed22f3ada05240fb.tar.gz dexon-sol-tools-84b820abc62c0aabea974ab8ed22f3ada05240fb.tar.zst dexon-sol-tools-84b820abc62c0aabea974ab8ed22f3ada05240fb.zip |
Show semver diff
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/src/custom_prepublish.ts | 10 |
1 files changed, 10 insertions, 0 deletions
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); |