diff --git a/beachball.config.js b/beachball.config.js index e9d8650a3..45411dd73 100644 --- a/beachball.config.js +++ b/beachball.config.js @@ -4,6 +4,7 @@ // TODO: fix this type ("commit" should be allowed in repo options) /** @type {BeachballConfig & Partial}*/ const config = { + generateChangelog: true, ignorePatterns: [ '.*', '.*/**', diff --git a/change/beachball-5d5354cf-7fea-4291-8be7-1aee3118125e.json b/change/beachball-5d5354cf-7fea-4291-8be7-1aee3118125e.json new file mode 100644 index 000000000..7608ab420 --- /dev/null +++ b/change/beachball-5d5354cf-7fea-4291-8be7-1aee3118125e.json @@ -0,0 +1,7 @@ +{ + "type": "major", + "comment": "[BREAKING] Set `generateChangelog` to `'md'` by default (only write `CHANGELOG.md`, not `CHANGELOG.json`). To keep the old behavior, set `generateChangelog: true`. Or if you're not using the `CHANGELOG.json` files, it's safe to delete them.' (See #978 and #979 for more context.)", + "packageName": "beachball", + "email": "elcraig@microsoft.com", + "dependentChangeType": "patch" +} diff --git a/src/__functional__/changelog/__snapshots__/writeChangelog.test.ts.snap b/src/__functional__/changelog/__snapshots__/writeChangelog.test.ts.snap index 4435f9d3c..8bf195476 100644 --- a/src/__functional__/changelog/__snapshots__/writeChangelog.test.ts.snap +++ b/src/__functional__/changelog/__snapshots__/writeChangelog.test.ts.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`writeChangelog generates basic changelog: changelog md 1`] = ` +exports[`writeChangelog generates basic changelog (md only by default): changelog md 1`] = ` "# Change Log - foo diff --git a/src/__functional__/changelog/writeChangelog.test.ts b/src/__functional__/changelog/writeChangelog.test.ts index d23bcc344..e93cbd9f6 100644 --- a/src/__functional__/changelog/writeChangelog.test.ts +++ b/src/__functional__/changelog/writeChangelog.test.ts @@ -110,7 +110,7 @@ describe('writeChangelog', () => { expect(readChangelogJson(repo.rootPath)).toBeNull(); }); - it('generates basic changelog', async () => { + it('generates basic changelog (md only by default)', async () => { repo = sharedSingleRepo; const options = getOptions(); @@ -129,6 +129,25 @@ describe('writeChangelog', () => { expect(changelogMd).not.toContain('no comment'); expect(changelogMd).toMatchSnapshot('changelog md'); + const changelogJson = readChangelogJson(repo.rootPath); + expect(changelogJson).toBeNull(); + }); + + it('generates basic changelog md and json if generateChangelog is true', async () => { + repo = sharedSingleRepo; + const options = getOptions({ generateChangelog: true }); + + generateChangeFiles([getChange('foo', 'old minor comment')], options); + generateChangeFiles([getChange('foo', 'patch comment', 'patch')], options); + generateChangeFiles([getChange('foo', 'no comment', 'none')], options); + generateChangeFiles([getChange('foo', 'new minor comment', 'minor')], options); + + await writeChangelogWrapper({ options }); + + const changelogMd = readChangelogMd(repo.rootPath); + // Just verify that this one was written (prevoius test covered details) + expect(changelogMd).toMatch(/^# Change Log - foo/); + const changelogJson = readChangelogJson(repo.rootPath); expect(changelogJson).toEqual({ name: 'foo', entries: [expect.anything()] }); expect(changelogJson!.entries[0]).toEqual({ @@ -173,7 +192,7 @@ describe('writeChangelog', () => { it('generates changelogs with dependent changes in monorepo', async () => { repo = sharedMonoRepo; - const options = getOptions(); + const options = getOptions({ generateChangelog: true }); generateChangeFiles([{ packageName: 'foo', comment: 'foo comment' }], options); generateChangeFiles([{ packageName: 'baz', comment: 'baz comment' }], options); @@ -242,7 +261,7 @@ describe('writeChangelog', () => { it('generates changelog in monorepo with grouped change files (groupChanges)', async () => { repo = sharedMonoRepo; - const options = getOptions({ groupChanges: true }); + const options = getOptions({ groupChanges: true, generateChangelog: true }); // these will be in one change file generateChangeFiles([getChange('foo', 'comment 2'), getChange('bar', 'bar comment')], options); @@ -280,6 +299,7 @@ describe('writeChangelog', () => { it('generates grouped changelog in monorepo', async () => { repo = sharedMonoRepo; const options = getOptions({ + generateChangelog: true, changelog: { groups: [ { @@ -351,6 +371,7 @@ describe('writeChangelog', () => { it('generates grouped changelog when path overlaps with regular changelog', async () => { repo = sharedMonoRepo; const options = getOptions({ + generateChangelog: true, changelog: { groups: [ { @@ -497,7 +518,7 @@ describe('writeChangelog', () => { // Most of the previous content tests are handled by renderChangelog, but writeChangelog is // responsible for reading that content and passing it in. repo = sharedSingleRepo; - const options = getOptions(); + const options = getOptions({ generateChangelog: true }); // Write some changes and generate changelogs generateChangeFiles(['foo'], options); @@ -528,7 +549,7 @@ describe('writeChangelog', () => { it('appends to existing changelog when migrating from uniqueFilenames=false to true', async () => { repo = sharedSingleRepo; - const options = getOptions(); + const options = getOptions({ generateChangelog: true }); // Write some changes and generate changelogs generateChangeFiles(['foo'], options); @@ -566,7 +587,10 @@ describe('writeChangelog', () => { it('trims previous changelog entries over maxVersions', async () => { repo = sharedSingleRepo; - const options = getOptions({ changelog: { maxVersions: 2 } }); + const options = getOptions({ + generateChangelog: true, + changelog: { maxVersions: 2 }, + }); // Bump and write three times for (let i = 1; i <= 3; i++) { diff --git a/src/options/getDefaultOptions.ts b/src/options/getDefaultOptions.ts index 8d100198d..0421396cf 100644 --- a/src/options/getDefaultOptions.ts +++ b/src/options/getDefaultOptions.ts @@ -22,7 +22,7 @@ export function getDefaultOptions(): BeachballOptions { depth: undefined, disallowedChangeTypes: null, fetch: true, - generateChangelog: true, + generateChangelog: 'md', gitTags: true, gitTimeout: undefined, message: '', diff --git a/src/types/BeachballOptions.ts b/src/types/BeachballOptions.ts index 9dd4dd6e8..216a017b2 100644 --- a/src/types/BeachballOptions.ts +++ b/src/types/BeachballOptions.ts @@ -112,10 +112,11 @@ export interface RepoOptions { fetch: boolean; /** * Whether to generate changelog files. - * - `true` (default) to generate both CHANGELOG.md and CHANGELOG.json + * - `'md'` (default) to generate only CHANGELOG.md + * - `true` to generate both CHANGELOG.md and CHANGELOG.json * - `false` to skip changelog generation - * - `'md'` to generate only CHANGELOG.md * - `'json'` to generate only CHANGELOG.json + * @default 'md' */ generateChangelog: boolean | 'md' | 'json'; /** Options for bumping package versions together */