Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions change/beachball-02900cbb-2206-4ec3-8b28-089b5f504e16.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-13a1b781-2b1a-4eff-ad1a-03696ad51619.json

This file was deleted.

7 changes: 7 additions & 0 deletions change/beachball-2aa1650c-1853-4549-bd89-242886aecfa8.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "major",
"comment": "`hooks.prebump` no longer receives `packageInfos`. This was never in the signature, and trying to modify it is likely to not fully behave as you might expect. Please open an issue if you were using this and we can find an alternative.",
"packageName": "beachball",
"email": "elcraig@microsoft.com",
"dependentChangeType": "patch"
}
7 changes: 0 additions & 7 deletions change/beachball-5caa022b-9249-4fea-b216-e88a82a478b3.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-69f402ed-44c3-432a-9726-2202c787f535.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-c431c165-ed07-4220-917b-e89d21ea4b1c.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-da3685e4-59a8-4263-b0ad-8a6f050a9c3a.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-dacf9757-cd64-4e18-aec1-146f011ebc6e.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-e606449d-61ec-4934-8a24-91aa58cae28b.json

This file was deleted.

7 changes: 0 additions & 7 deletions change/beachball-edbf2503-62e3-4578-ac81-96c2cb48bf45.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-337918d3-ea78-4c2e-9b54-f1fe3587642e.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-37a6b8a7-6fa0-4f2a-8ef5-34bca5edf36a.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-4095d8fa-faa9-49db-8687-4a11e49f08fd.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-6873ab67-6141-4270-b410-176ceca62bc9.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-9f7b2622-c36c-4110-b9f3-8e9196f26a24.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-c8006efc-15a3-4418-871f-356266015edf.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-e0ebd254-f3c4-4b0b-aa4f-533fe9300419.json

This file was deleted.

11 changes: 0 additions & 11 deletions change/change-eda9658e-2a58-43ae-a053-2baadf355f1d.json

This file was deleted.

23 changes: 8 additions & 15 deletions docs/overview/v3-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,6 @@ To migrate, simply remove the leading `!` from all `exclude` patterns.

The logic for determining the comparison remote and branch is stricter: beachball now throws if no remotes are defined, or if the root `package.json` specifies a `repository` field but no matching remote is found. If your `branch` option contains a `/`, beachball checks whether the leading segment matches a configured remote name, and falls back to the default remote otherwise.

### `prebump` hook version parameter now matches the docs

In v2, `hooks.prebump` received the post-bump package version even though the hook runs before Beachball writes version changes to disk. In v3, this is corrected to receive the pre-bump version as documented.

### Custom changelog rendering changes

Only relevant for custom changelog renderers: `PackageChangelog.tag` and `ChangelogJsonEntry.tag` are now `undefined` when the package had no associated git tag (previously a value was always present).
Expand All @@ -98,18 +94,15 @@ In v3, `shouldPublish: false` packages are full participants in all steps of the
- If a published package has a `shouldPublish: false` package in its production dependencies, Beachball will exit with an error (same as with `private: true` deps)
- Since `shouldPublish: false` is redundant with `private: true`, `beachball migrate` reports this as an error

### Renamed options

- Rename `BeachballOptions.changelog.groups[*].masterPackageName` to `mainPackageName`

### Removed options
### `BeachballOptions`/`RepoOptions` updates

- `new`: This option was never needed if PR builds run `beachball check` (a new package without a change file already causes an error), and it had a significant performance cost because it checked the registry for _all_ unmodified packages.
- `packStyle`: packing always uses the layered style now.
- `help` and `version` properties: these still work on the command line but were removed from `BeachballOptions`
- Rename `changelog.groups[*].masterPackageName` to `mainPackageName`.
- Removed rarely-used options:
- `new`: This option was never needed if PR builds run `beachball check` (a new package without a change file already causes an error), and it had a significant performance cost because it checked the registry for _all_ unmodified packages.
- `packStyle`: packing always uses the layered style now.
- `help` and `version` properties: these still work on the command line but were removed from `BeachballOptions`
- `hooks.prebump` no longer receives `packageInfos`. This was never in the signature, and trying to modify it may lead to unexpected behavior. Please open an issue if you were using this and we can find an alternative.

### Other changes

- If you're deep importing beachball's internal helpers:
- Some deprecated signatures have been removed. Use the new signatures (which pre-calculate and share context) instead.
- `BumpInfo` now contains `originalPackageInfos` for `prebump` hook correctness.
- If you're deep importing beachball's internal helpers, some deprecated signatures have been removed. Use the new signatures (which pre-calculate and share context) instead.
5 changes: 3 additions & 2 deletions packages/beachball/src/__e2e__/bump.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,11 +555,12 @@ describe('bump command', () => {
prebump: jest.fn<NonNullable<HooksOptions['prebump']>>(async (packagePath, name, version) => {
expect(packagePath.endsWith('pkg-1')).toBeTruthy();
expect(name).toBe('pkg-1');
expect(version).toBe('1.0.0');
// "prebump" receives the bumped version, but is called before writing to disk
expect(version).toBe('1.1.0');

await new Promise(resolve => setTimeout(resolve, 0)); // simulate async work
const jsonPath = path.join(packagePath, 'package.json');
expect(readJson<PackageJson>(jsonPath).version).toBe('1.0.0');
expect(readJson<PackageJson>(jsonPath).version).toBe('1.0.0'); // not bumped on disk yet
}),
postbump: jest.fn<NonNullable<HooksOptions['postbump']>>(async (packagePath, name, version) => {
expect(packagePath.endsWith('pkg-1')).toBeTruthy();
Expand Down
16 changes: 15 additions & 1 deletion packages/beachball/src/__functional__/commands/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { describe, expect, it, afterEach, jest } from '@jest/globals';
import { initMockLogs } from '../../__fixtures__/mockLogs';
import { migrate } from '../../commands/migrate';
import { getOptions as _getOptions } from '../../options/getOptions';
import type { RepoOptions } from '../../types/BeachballOptions';
import type { HooksOptions, RepoOptions } from '../../types/BeachballOptions';
import { removeTempDir } from '../../__fixtures__/tmpdir';
import { createTestFileStructureType, updateJsonFile } from '../../__fixtures__/createTestFileStructure';
import fs from 'fs';
Expand Down Expand Up @@ -68,6 +68,20 @@ describe('migrate command', () => {
`);
});

it('errors on "hooks.prebump" with more than 3 params', () => {
tempRoot = createTestFileStructureType('single');
const fn: HooksOptions['postbump'] = (_pth, _name, _version, _pkgInfos) => {};
const options = getOptions({
hooks: { prebump: fn as HooksOptions['prebump'] },
});

expect(() => migrate(options)).toThrow(BeachballError);
expect(logs.getMockLines('all')).toMatchInlineSnapshot(`
"[error] The following updates are needed for v3:
[error] • \`hooks.prebump\` no longer receives \`packageInfos\`. See migration guide."
`);
});

it('warns on public packages using shouldPublish option', () => {
tempRoot = createTestFileStructureType('monorepo');
updateJsonFile(path.join(tempRoot, 'packages/foo/package.json'), { beachball: { shouldPublish: false } });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ describe('publishToRegistry', () => {
const npmMock = initNpmMock();
const logs = initMockLogs();

/** Needs a real fake temp root for mock npm publish */
let tempRoot: string;
let defaultOptions: BeachballOptions;

Expand Down Expand Up @@ -62,7 +61,6 @@ describe('publishToRegistry', () => {
return {
changeFileChangeInfos: [],
packageInfos,
originalPackageInfos: makePackageInfos(partialPackageInfos, { path: tempRoot }),
calculatedChangeTypes: Object.fromEntries(names.map(n => [n, 'patch' as const])),
packageGroups: {},
modifiedPackages: new Set(names),
Expand Down Expand Up @@ -231,7 +229,7 @@ describe('publishToRegistry', () => {
expect(prebump).toHaveBeenCalledTimes(1);
expect(postbump).toHaveBeenCalledTimes(1);
const fooPath = expect.stringMatching(/packages[\\/]foo$/);
expect(prebump as typeof postbump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.0', expect.anything());
expect(prebump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.1');
expect(postbump).toHaveBeenCalledWith(fooPath, 'foo', '1.0.1', expect.anything());
});

Expand Down
Loading