diff options
author | Fabio Berger <me@fabioberger.com> | 2018-04-03 08:45:30 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-04-03 08:45:30 +0800 |
commit | dd87588dfec2b9ec79b47b72e1dd99afadcbabe7 (patch) | |
tree | f3858b931543dbd5d5231ed29b0eafdb6aaa7b58 /packages/monorepo-scripts | |
parent | 29042e1939315b997422d095fc1c23364f752a63 (diff) | |
download | dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar.gz dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar.bz2 dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar.lz dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar.xz dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.tar.zst dexon-sol-tools-dd87588dfec2b9ec79b47b72e1dd99afadcbabe7.zip |
Now that every version of a package published has a corresponding entry in it's CHANGELOG we no longer need the isPublished flag. Remove it.
Diffstat (limited to 'packages/monorepo-scripts')
-rw-r--r-- | packages/monorepo-scripts/src/postpublish_utils.ts | 44 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/publish.ts | 7 | ||||
-rw-r--r-- | packages/monorepo-scripts/src/types.ts | 1 |
3 files changed, 19 insertions, 33 deletions
diff --git a/packages/monorepo-scripts/src/postpublish_utils.ts b/packages/monorepo-scripts/src/postpublish_utils.ts index 236b54379..ca4c92f5d 100644 --- a/packages/monorepo-scripts/src/postpublish_utils.ts +++ b/packages/monorepo-scripts/src/postpublish_utils.ts @@ -91,7 +91,7 @@ export const postpublishUtils = { ); }, async publishReleaseNotesAsync(cwd: string, packageName: string, version: string, assets: string[]): Promise<void> { - const notes = this.getReleaseNotes(packageName); + const notes = this.getReleaseNotes(packageName, version); const releaseName = this.getReleaseName(packageName, version); const tag = this.getTag(packageName, version); const finalAssets = this.adjustAssetPaths(cwd, assets); @@ -109,9 +109,8 @@ export const postpublishUtils = { reuseDraftOnly: false, assets, }); - this.updateChangelogIsPublished(packageName); }, - getReleaseNotes(packageName: string) { + getReleaseNotes(packageName: string, version: string) { const packageNameWithNamespace = packageName.replace('@0xproject/', ''); const changelogJSONPath = path.join( constants.monorepoRootPath, @@ -122,33 +121,20 @@ export const postpublishUtils = { const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8'); const changelogs = JSON.parse(changelogJSON); const latestLog = changelogs[0]; - if (_.isUndefined(latestLog.isPublished)) { - let notes = ''; - _.each(latestLog.changes, change => { - notes += `* ${change.note}`; - if (change.pr) { - notes += ` (${change.pr})`; - } - notes += `\n`; - }); - return notes; + // We sanity check that the version for the changelog notes we are about to publish to Github + // correspond to the new version of the package. + if (version !== latestLog.version) { + throw new Error('Expected CHANGELOG.json latest entry version to coincide with published version.'); } - return 'N/A'; - }, - updateChangelogIsPublished(packageName: string) { - const packageNameWithNamespace = packageName.replace('@0xproject/', ''); - const changelogJSONPath = path.join( - constants.monorepoRootPath, - 'packages', - packageNameWithNamespace, - 'CHANGELOG.json', - ); - const changelogJSON = fs.readFileSync(changelogJSONPath, 'utf-8'); - const changelogs = JSON.parse(changelogJSON); - const latestLog = changelogs[0]; - latestLog.isPublished = true; - changelogs[0] = latestLog; - fs.writeFileSync(changelogJSONPath, JSON.stringify(changelogs, null, '\t')); + let notes = ''; + _.each(latestLog.changes, change => { + notes += `* ${change.note}`; + if (change.pr) { + notes += ` (${change.pr})`; + } + notes += `\n`; + }); + return notes; }, getTag(packageName: string, version: string) { return `${packageName}@${version}`; diff --git a/packages/monorepo-scripts/src/publish.ts b/packages/monorepo-scripts/src/publish.ts index d749ec630..adc1de64a 100644 --- a/packages/monorepo-scripts/src/publish.ts +++ b/packages/monorepo-scripts/src/publish.ts @@ -48,7 +48,7 @@ const semverNameToIndex: { [semver: string]: number } = { } const currentVersion = lernaPackage.package.version; - const shouldAddNewEntry = shouldAddNewChangelogEntry(changelogs); + const shouldAddNewEntry = shouldAddNewChangelogEntry(currentVersion, changelogs); if (shouldAddNewEntry) { // Create a new entry for a patch version with generic changelog entry. const nextPatchVersion = utils.getNextPatchVersion(currentVersion); @@ -174,12 +174,13 @@ function getChangelogJSONOrCreateIfMissing(packageName: string, changelogPath: s } } -function shouldAddNewChangelogEntry(changelogs: Changelog[]): boolean { +function shouldAddNewChangelogEntry(currentVersion: string, changelogs: Changelog[]): boolean { if (_.isEmpty(changelogs)) { return true; } const lastEntry = changelogs[0]; - return !!lastEntry.isPublished; + const lastEntryCurrentVersion = lastEntry.version === currentVersion; + return lastEntryCurrentVersion; } function generateChangelogMd(changelogs: Changelog[]): string { diff --git a/packages/monorepo-scripts/src/types.ts b/packages/monorepo-scripts/src/types.ts index 7adec202f..9e6edd186 100644 --- a/packages/monorepo-scripts/src/types.ts +++ b/packages/monorepo-scripts/src/types.ts @@ -13,7 +13,6 @@ export interface Changelog { timestamp?: number; version: string; changes: Changes[]; - isPublished?: boolean; } export enum SemVerIndex { |