diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-29 23:41:39 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-29 23:41:39 +0800 |
commit | 29aa09e448c7b379eeea680e2e7c89a4998b04b8 (patch) | |
tree | 15b9147eb9c92cfaaa1da761c0753dcc38ff7bfe /packages/monorepo-scripts/src | |
parent | ac35d8127e1ee3dfaf8e1aa0e182279a9a58787e (diff) | |
download | dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar.gz dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar.bz2 dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar.lz dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar.xz dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.tar.zst dexon-sol-tools-29aa09e448c7b379eeea680e2e7c89a4998b04b8.zip |
Generate CHANGELOG.mds
Diffstat (limited to 'packages/monorepo-scripts/src')
-rw-r--r-- | packages/monorepo-scripts/src/custom_prepublish.ts | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/packages/monorepo-scripts/src/custom_prepublish.ts b/packages/monorepo-scripts/src/custom_prepublish.ts index 90db51465..b18389fcd 100644 --- a/packages/monorepo-scripts/src/custom_prepublish.ts +++ b/packages/monorepo-scripts/src/custom_prepublish.ts @@ -65,6 +65,8 @@ const TODAYS_TIMESTAMP = moment().unix(); fs.writeFileSync(changelogJSONPath, JSON.stringify(changelogs, null, '\t')); // Generate updated CHANGELOG.md const changelogMd = generateChangelogMd(changelogs); + const changelogMdPath = path.join(lernaPackage.location, 'CHANGELOG.md'); + fs.writeFileSync(changelogMdPath, changelogMd); }); })().catch(err => { utils.log(err); @@ -111,5 +113,30 @@ function shouldAddNewChangelogEntry(changelogs: Changelog[]): boolean { } function generateChangelogMd(changelogs: Changelog[]): string { - return ''; + let changelogMd = `<!-- +This file is auto-generated using the monorepo-scripts package. Don't edit directly. +Edit the package's CHANGELOG.json file only. +--> + +CHANGELOG + `; + + _.each(changelogs, changelog => { + const date = moment(changelog.timestamp, 'X').format('MMMM D, YYYY'); + const title = `\n## v${changelog.version} - _${date}_\n\n`; + changelogMd += title; + + let changes = ''; + _.each(changelog.changes, change => { + let line = ` * ${change.note}`; + if (!_.isUndefined(change.pr)) { + line += ` (#${change.pr})`; + } + line += '\n'; + changes += line; + }); + changelogMd += `${changes}`; + }); + + return changelogMd; } |