Skip to content

Commit

Permalink
[breaking] Set generateChangelog to md by default (see #979)
Browse files Browse the repository at this point in the history
  • Loading branch information
ecraig12345 committed Nov 26, 2024
1 parent 3f82b99 commit 3b19f1e
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 10 deletions.
1 change: 1 addition & 0 deletions beachball.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
// TODO: fix this type ("commit" should be allowed in repo options)
/** @type {BeachballConfig & Partial<CliOptions>}*/
const config = {
generateChangelog: true,
ignorePatterns: [
'.*',
'.*/**',
Expand Down
7 changes: 7 additions & 0 deletions change/beachball-5d5354cf-7fea-4291-8be7-1aee3118125e.json
Original file line number Diff line number Diff line change
@@ -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": "[email protected]",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -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
<!-- This log was last generated on (date) and should not be manually modified. -->
Expand Down
36 changes: 30 additions & 6 deletions src/__functional__/changelog/writeChangelog.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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({
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -280,6 +299,7 @@ describe('writeChangelog', () => {
it('generates grouped changelog in monorepo', async () => {
repo = sharedMonoRepo;
const options = getOptions({
generateChangelog: true,
changelog: {
groups: [
{
Expand Down Expand Up @@ -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: [
{
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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++) {
Expand Down
2 changes: 1 addition & 1 deletion src/options/getDefaultOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function getDefaultOptions(): BeachballOptions {
depth: undefined,
disallowedChangeTypes: null,
fetch: true,
generateChangelog: true,
generateChangelog: 'md',
gitTags: true,
gitTimeout: undefined,
message: '',
Expand Down
5 changes: 3 additions & 2 deletions src/types/BeachballOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,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 */
Expand Down

0 comments on commit 3b19f1e

Please sign in to comment.