FluidFramework/build-tools/packages
Tyler Butler 8ae7837bd1
improvement(build-cli): Handle changesets that apply to no packages (#22433)
Contains changes for two flub commands, `generate:releaseNotes` and
`generate:changelog`.

### generate:releaseNotes

The changeset generator no longer fails with an error message when no
changes are detected. Instead, it outputs a prompt:

> No changed packages have been detected. Do you want to create a
changeset associated with no packages?

If the user selects Yes, then the package selection is skipped but the
user can still provide a summary, description, and release notes
section. If they select No, then they can select affected packages from
the complete list.

The prompt chain was simplified by using functions for the "type"
property and returning false when the question should be skipped. This
allows all the questions to be in a single prompt chain and
conditionally ask questions based on previous responses and other input.

The full prompt flow is now:

1. IFF no changed packages are detected, ask "Do you want to create a
changeset associated with no packages?". If YES, go to 3. IF NO, go to
2.
2. Prompt to select affected packages and bump levels.
3. Prompt to select release notes section.
4. Prompt to enter summary.
5. Prompt to enter body.

The code was also reorganized to optimize checking for changes. The
previous code ended up comparing the local to the remote at least twice;
now that check is only done twice if the user is prompted to select a
different target branch - and does. Otherwise, the check is done once
and the results of that check are used where needed. This speeds up the
default case.

### generate:changelog

When generating changelogs, we invoke the `changeset version` command to
apply the changesets to all the packages. This is what actually writes
the changelogs. However, our changesets have additional custom metadata
in a second front-matter section (see
https://github.com/microsoft/FluidFramework/wiki/Changesets#custom-metadata).
To enable the existing tools like
[@changesets/cli](https://www.npmjs.com/package/@changesets/cli) to work
with our changesets, commands like the `generate:changelog` command
first updates all the changesets to be "canonical" changesets by
removing the additional metadata section. We update the changesets to be
canonical, then we invoke `changeset version`, which consumes the
updated changesets, and then do some cleanup on the resulting changes.
2024-09-11 15:01:01 -07:00
..
build-cli improvement(build-cli): Handle changesets that apply to no packages (#22433) 2024-09-11 15:01:01 -07:00
build-tools fix(generate:typetests): Move type compat exports back to build-tools (#22443) 2024-09-09 16:13:18 -07:00
bundle-size-tools Update webpack-related dependencies (#22447) 2024-09-10 23:11:36 +00:00
version-tools Update build-tools versions to latest (0.44.0) (#22407) 2024-09-06 11:47:26 -07:00