diff --git a/.changeset/friendly-vans-hammer.md b/.changeset/friendly-vans-hammer.md deleted file mode 100644 index 85a0004dc..000000000 --- a/.changeset/friendly-vans-hammer.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@changesets/config": patch ---- - -Include the information about `false` being a valid value for the `changelog` option in the validation message for the `changelog` option. diff --git a/.changeset/mean-mugs-return.md b/.changeset/mean-mugs-return.md deleted file mode 100644 index 9ab9d81d7..000000000 --- a/.changeset/mean-mugs-return.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"@changesets/apply-release-plan": patch -"@changesets/cli": patch ---- - -Fixed an issue with generating changelogs not being skipped when the `changelog` config option was set to `false`. diff --git a/.changeset/silver-toys-turn.md b/.changeset/silver-toys-turn.md deleted file mode 100644 index 941025b6f..000000000 --- a/.changeset/silver-toys-turn.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"@changesets/cli": patch ---- - -Attempt to log `stdout` when publish fails if `stderr` is empty and JSON error can't be retrieved from none of those. diff --git a/README.md b/README.md index 52d67245a..c82537068 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,10 @@ To make releasing easier, you can use [this changesets github action](https://gi - [SvelteKit](https://kit.svelte.dev/) - [Hydrogen](https://hydrogen.shopify.dev) - [react-pdf](https://github.com/diegomura/react-pdf) +- [GraphQL Code Generator](https://github.com/dotansimha/graphql-code-generator) +- [GraphQL Yoga](https://github.com/dotansimha/graphql-yoga) +- [GraphQL-Mesh](https://github.com/Urigo/graphql-mesh) +- [GraphiQL](https://github.com/graphql/graphiql) - [wagmi](https://github.com/wagmi-dev/wagmi) - [refine](https://github.com/pankod/refine) diff --git a/__fixtures__/private-package-without-version-field/.changeset/config.json b/__fixtures__/private-package-without-version-field/.changeset/config.json new file mode 100644 index 000000000..0967ef424 --- /dev/null +++ b/__fixtures__/private-package-without-version-field/.changeset/config.json @@ -0,0 +1 @@ +{} diff --git a/__fixtures__/private-package-without-version-field/package.json b/__fixtures__/private-package-without-version-field/package.json new file mode 100644 index 000000000..b245108a3 --- /dev/null +++ b/__fixtures__/private-package-without-version-field/package.json @@ -0,0 +1,9 @@ +{ + "private": true, + "name": "private-package-without-version-field", + "description": "Base yarn workspace work", + "version": "1.0.0", + "workspaces": [ + "packages/*" + ] +} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json new file mode 100644 index 000000000..ee09b194d --- /dev/null +++ b/__fixtures__/private-package-without-version-field/packages/pkg-a/package.json @@ -0,0 +1,4 @@ +{ + "name": "pkg-a", + "version": "1.0.0" +} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json new file mode 100644 index 000000000..1a17612fe --- /dev/null +++ b/__fixtures__/private-package-without-version-field/packages/pkg-b/package.json @@ -0,0 +1,4 @@ +{ + "name": "pkg-b", + "private": true +} diff --git a/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json b/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json new file mode 100644 index 000000000..888ba5c7e --- /dev/null +++ b/__fixtures__/private-package-without-version-field/packages/pkg-c/package.json @@ -0,0 +1,4 @@ +{ + "name": "pkg-c", + "version": "1.0.0" +} diff --git a/docs/automating-changesets.md b/docs/automating-changesets.md index 2bbdc708c..fd54332d9 100644 --- a/docs/automating-changesets.md +++ b/docs/automating-changesets.md @@ -1,6 +1,6 @@ # Automating Changesets -While changesets is designed to work with a fully manual process, it also provides tools to help automate these releases. These can be broken into two major decisions: +While changesets are designed to work with a fully manual process, it also provides tools to help automate these releases. These can be broken into two major decisions: 1. How do I want to ensure pull requests have changesets? 2. How do I run the version and publish commands? @@ -14,7 +14,7 @@ Here we have a quick-start recommended workflow, with more ## How do I want to ensure pull requests have changesets? -Changesets are committed to files, and so a diligent reviewer can always technically tell if a changeset is absent and request one be added. As humans though, a file not being there is easy to miss. We recommend adding some way to detect the presence or absence of changesets on a pull request so you don't have to, as well as highlight it to pull-request makers so you don't have to. +Changesets are committed to files, so a diligent reviewer can always technically tell if a changeset is absent and request one be added. As humans though, a file not being there is easy to miss. We recommend adding some way to detect the presence or absence of changesets on a pull request so you don't have to, as well as highlight it to pull-request makers so you don't have to. This has two main approaches. @@ -24,15 +24,15 @@ In this approach, a pull request may be merged if no changeset is present, and a ### Blocking -In some cases, you may want to make CI fail if not changeset is present, to ensure no PR can be merged without a changeset. To do this: +Sometimes, you may want to make CI fail if no changeset is present to ensure no PR can be merged without a changeset. To do this: -In your CI process add a step that runs: +In your CI process, add a step that runs: ```bash changeset status --since=main ``` -This will exit with the exit code 1 if there have been no new changesets since master. +This will exit with exit code 1 if there have been no new changesets since master. In some cases, you may _want_ to merge a change without doing any releases (such as when you only change tests or build tools). In this case, you can run `changeset --empty`. This will add a special changeset that does not release anything. @@ -46,10 +46,10 @@ We have a [github action](https://github.com/changesets/action) that If you don't want to use this action, the manual workflow we recommend for running the `version` and `publish` commands is: - A release coordinator (RC) calls to stop any merging to the base branch -- The RC pull down the base branch, runs `changeset version`, then make a new PR with the versioning changes +- The RC pulls down the base branch, runs `changeset version`, then makes a new PR with the versioning changes - The versioning changes are merged back into the base branch - The RC pulls the base branch again and runs `changeset publish` - The RC runs `git push --follow-tags` to push the release tags back - The RC unblocks merging to the base branch -This is a lot of steps, and is quite finnicky (we have to pull from the base branch twice). Feel free to finesse it to your own circumstances. +This is a lot of steps and is quite finicky (we have to pull from the base branch twice). Feel free to finesse it to your own circumstances. diff --git a/packages/apply-release-plan/CHANGELOG.md b/packages/apply-release-plan/CHANGELOG.md index 01fc4378a..1a25a23cf 100644 --- a/packages/apply-release-plan/CHANGELOG.md +++ b/packages/apply-release-plan/CHANGELOG.md @@ -1,5 +1,14 @@ # @changesets/apply-release-plan +## 6.0.4 + +### Patch Changes + +- [#900](https://github.com/changesets/changesets/pull/900) [`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e) Thanks [@sdirosa](https://github.com/sdirosa)! - Fixed an issue with generating changelogs not being skipped when the `changelog` config option was set to `false`. + +- Updated dependencies [[`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e)]: + - @changesets/config@2.1.1 + ## 6.0.3 ### Patch Changes diff --git a/packages/apply-release-plan/package.json b/packages/apply-release-plan/package.json index cbca59f57..09039b175 100644 --- a/packages/apply-release-plan/package.json +++ b/packages/apply-release-plan/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/apply-release-plan", - "version": "6.0.3", + "version": "6.0.4", "description": "Takes a release plan and applies it to packages", "main": "dist/apply-release-plan.cjs.js", "module": "dist/apply-release-plan.esm.js", @@ -8,7 +8,7 @@ "repository": "https://github.com/changesets/changesets/tree/main/packages/apply-release-plan", "dependencies": { "@babel/runtime": "^7.10.4", - "@changesets/config": "^2.1.0", + "@changesets/config": "^2.1.1", "@changesets/get-version-range-type": "^0.3.2", "@changesets/git": "^1.4.1", "@changesets/types": "^5.1.0", diff --git a/packages/assemble-release-plan/CHANGELOG.md b/packages/assemble-release-plan/CHANGELOG.md index 39485fc3e..d58746c12 100644 --- a/packages/assemble-release-plan/CHANGELOG.md +++ b/packages/assemble-release-plan/CHANGELOG.md @@ -1,5 +1,11 @@ # @changesets/assemble-release-plan +## 5.2.1 + +### Patch Changes + +- [#914](https://github.com/changesets/changesets/pull/914) [`b023e4b`](https://github.com/changesets/changesets/commit/b023e4b3d1ad793a5dd1187b720e8103cebfb937) Thanks [@Andarist](https://github.com/Andarist)! - Fixed an issue with the `assembleReleasePlan`'s signature not being compatible with the old shape of the `config` and `snapshot` parameters. This could have caused runtime errors during snapshot releases when only some of the Changesets transitive dependencies were updated without other ones. + ## 5.2.0 ### Minor Changes diff --git a/packages/assemble-release-plan/package.json b/packages/assemble-release-plan/package.json index 488f17f31..2ecc0ad71 100644 --- a/packages/assemble-release-plan/package.json +++ b/packages/assemble-release-plan/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/assemble-release-plan", - "version": "5.2.0", + "version": "5.2.1", "description": "Reads changesets and adds information on dependents that need bumping", "main": "dist/assemble-release-plan.cjs.js", "module": "dist/assemble-release-plan.esm.js", diff --git a/packages/assemble-release-plan/src/index.ts b/packages/assemble-release-plan/src/index.ts index 83964cf6f..3ffb6fa77 100644 --- a/packages/assemble-release-plan/src/index.ts +++ b/packages/assemble-release-plan/src/index.ts @@ -117,28 +117,55 @@ function getNewVersion( return incrementVersion(release, preInfo); } +type OptionalProp = Omit & Partial>; + function assembleReleasePlan( changesets: NewChangeset[], packages: Packages, - config: Config, + config: OptionalProp, // intentionally not using an optional parameter here so the result of `readPreState` has to be passed in here preState: PreState | undefined, // snapshot: undefined -> not using snaphot // snapshot: { tag: undefined } -> --snapshot (empty tag) // snapshot: { tag: "canary" } -> --snapshot canary - snapshot?: SnapshotReleaseParameters + snapshot?: SnapshotReleaseParameters | string | boolean ): ReleasePlan { + // TODO: remove `refined*` in the next major version of this package + // just use `config` and `snapshot` parameters directly, typed as: `config: Config, snapshot?: SnapshotReleaseParameters` + const refinedConfig: Config = config.snapshot + ? (config as Config) + : { + ...config, + snapshot: { + prereleaseTemplate: null, + useCalculatedVersion: ( + config.___experimentalUnsafeOptions_WILL_CHANGE_IN_PATCH as any + ).useCalculatedVersionForSnapshots, + }, + }; + const refinedSnapshot: SnapshotReleaseParameters | undefined = + typeof snapshot === "string" + ? { tag: snapshot } + : typeof snapshot === "boolean" + ? { tag: undefined } + : snapshot; + let packagesByName = new Map( packages.packages.map((x) => [x.packageJson.name, x]) ); const relevantChangesets = getRelevantChangesets( changesets, - config.ignore, + refinedConfig.ignore, preState ); - const preInfo = getPreInfo(changesets, packagesByName, config, preState); + const preInfo = getPreInfo( + changesets, + packagesByName, + refinedConfig, + preState + ); // releases is, at this point a list of all packages we are going to releases, // flattened down to one release per package, having a reference back to their @@ -146,12 +173,12 @@ function assembleReleasePlan( let releases = flattenReleases( relevantChangesets, packagesByName, - config.ignore + refinedConfig.ignore ); let dependencyGraph = getDependentsGraph(packages, { bumpVersionsWithWorkspaceProtocolOnly: - config.bumpVersionsWithWorkspaceProtocolOnly, + refinedConfig.bumpVersionsWithWorkspaceProtocolOnly, }); let releasesValidated = false; @@ -162,16 +189,20 @@ function assembleReleasePlan( packagesByName, dependencyGraph, preInfo, - config, + config: refinedConfig, }); // `releases` might get mutated here let fixedConstraintUpdated = matchFixedConstraint( releases, packagesByName, - config + refinedConfig + ); + let linksUpdated = applyLinks( + releases, + packagesByName, + refinedConfig.linked ); - let linksUpdated = applyLinks(releases, packagesByName, config.linked); releasesValidated = !linksUpdated && !dependentAdded && !fixedConstraintUpdated; @@ -193,7 +224,7 @@ function assembleReleasePlan( }); } else if ( existingRelease.type === "none" && - !config.ignore.includes(pkg.packageJson.name) + !refinedConfig.ignore.includes(pkg.packageJson.name) ) { existingRelease.type = "patch"; } @@ -203,7 +234,11 @@ function assembleReleasePlan( // Caching the snapshot version here and use this if it is snapshot release const snapshotSuffix = - snapshot && getSnapshotSuffix(config.snapshot.prereleaseTemplate, snapshot); + refinedSnapshot && + getSnapshotSuffix( + refinedConfig.snapshot.prereleaseTemplate, + refinedSnapshot + ); return { changesets: relevantChangesets, @@ -214,7 +249,7 @@ function assembleReleasePlan( ? getSnapshotVersion( incompleteRelease, preInfo, - config.snapshot.useCalculatedVersion, + refinedConfig.snapshot.useCalculatedVersion, snapshotSuffix ) : getNewVersion(incompleteRelease, preInfo), diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index e4aecb7cd..9882b6042 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -1,5 +1,28 @@ # @changesets/cli +## 2.24.3 + +### Patch Changes + +- Updated dependencies [[`b023e4b`](https://github.com/changesets/changesets/commit/b023e4b3d1ad793a5dd1187b720e8103cebfb937)]: + - @changesets/assemble-release-plan@5.2.1 + - @changesets/get-release-plan@3.0.14 + +## 2.24.2 + +### Patch Changes + +- [#900](https://github.com/changesets/changesets/pull/900) [`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e) Thanks [@sdirosa](https://github.com/sdirosa)! - Fixed an issue with generating changelogs not being skipped when the `changelog` config option was set to `false`. + +* [#720](https://github.com/changesets/changesets/pull/720) [`0fd56e1`](https://github.com/changesets/changesets/commit/0fd56e17092c7258de57adf7dd4ba08406c8e440) Thanks [@bhovhannes](https://github.com/bhovhannes)! - Private packages without a `version` field are no longer listed when adding a changeset. + +- [#844](https://github.com/changesets/changesets/pull/844) [`8627ec1`](https://github.com/changesets/changesets/commit/8627ec1faba53644b366c314be248e1bba48f329) Thanks [@Andarist](https://github.com/Andarist)! - Attempt to log `stdout` when publish fails if `stderr` is empty and JSON error can't be retrieved from none of those. + +- Updated dependencies [[`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e), [`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e)]: + - @changesets/config@2.1.1 + - @changesets/apply-release-plan@6.0.4 + - @changesets/get-release-plan@3.0.13 + ## 2.24.1 ### Patch Changes diff --git a/packages/cli/package.json b/packages/cli/package.json index 598898825..3cb6960d9 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/cli", - "version": "2.24.1", + "version": "2.24.3", "description": "Organise your package versioning and publishing to make both contributors and maintainers happy", "bin": { "changeset": "bin.js" @@ -31,13 +31,13 @@ "license": "MIT", "dependencies": { "@babel/runtime": "^7.10.4", - "@changesets/apply-release-plan": "^6.0.3", - "@changesets/assemble-release-plan": "^5.2.0", + "@changesets/apply-release-plan": "^6.0.4", + "@changesets/assemble-release-plan": "^5.2.1", "@changesets/changelog-git": "^0.1.12", - "@changesets/config": "^2.1.0", + "@changesets/config": "^2.1.1", "@changesets/errors": "^0.1.4", "@changesets/get-dependents-graph": "^1.3.3", - "@changesets/get-release-plan": "^3.0.12", + "@changesets/get-release-plan": "^3.0.14", "@changesets/git": "^1.4.1", "@changesets/logger": "^0.0.5", "@changesets/pre": "^1.0.12", diff --git a/packages/cli/src/commands/add/__tests__/add.ts b/packages/cli/src/commands/add/__tests__/add.ts index a75c9bd94..78f8d8138 100644 --- a/packages/cli/src/commands/add/__tests__/add.ts +++ b/packages/cli/src/commands/add/__tests__/add.ts @@ -214,6 +214,16 @@ describe("Changesets", () => { { ...defaultConfig, ignore: ["pkg-b"] } ); + // @ts-ignore + const { choices } = askCheckboxPlus.mock.calls[0][1][0]; + expect(choices).toEqual(["pkg-a", "pkg-c"]); + }); + it("should not include private packages without a version in the prompt", async () => { + const cwd = await f.copy("private-package-without-version-field"); + + mockUserResponses({ releases: { "pkg-a": "patch" } }); + await addChangeset(cwd, { empty: false }, defaultConfig); + // @ts-ignore const { choices } = askCheckboxPlus.mock.calls[0][1][0]; expect(choices).toEqual(["pkg-a", "pkg-c"]); diff --git a/packages/cli/src/commands/add/createChangeset.ts b/packages/cli/src/commands/add/createChangeset.ts index 22c55dd0a..f5898b8f2 100644 --- a/packages/cli/src/commands/add/createChangeset.ts +++ b/packages/cli/src/commands/add/createChangeset.ts @@ -98,6 +98,12 @@ function formatPkgNameAndVersion(pkgName: string, version: string) { return `${bold(pkgName)}@${bold(version)}`; } +function getPkgJsonByName(packages: Package[]) { + return new Map( + packages.map(({ packageJson }) => [packageJson.name, packageJson]) + ); +} + export default async function createChangeset( changedPackages: Array, allPackages: Package[] @@ -110,9 +116,7 @@ export default async function createChangeset( allPackages ); - let pkgJsonsByName = new Map( - allPackages.map(({ packageJson }) => [packageJson.name, packageJson]) - ); + let pkgJsonsByName = getPkgJsonByName(allPackages); let pkgsLeftToGetBumpTypeFor = new Set(packagesToRelease); diff --git a/packages/cli/src/commands/add/index.ts b/packages/cli/src/commands/add/index.ts index ddf88123d..c15b90f2e 100644 --- a/packages/cli/src/commands/add/index.ts +++ b/packages/cli/src/commands/add/index.ts @@ -13,22 +13,26 @@ import { getCommitFunctions } from "../../commit/getCommitFunctions"; import createChangeset from "./createChangeset"; import printConfirmationMessage from "./messages"; import { ExternalEditor } from "external-editor"; +import { PackageJSON } from "@changesets/types"; -type UnwrapPromise> = T extends Promise - ? R - : never; +function isListablePackage(config: Config, packageJson: PackageJSON) { + return ( + !config.ignore.includes(packageJson.name) && + (packageJson.version || !packageJson.private) + ); +} export default async function add( cwd: string, { empty, open }: { empty?: boolean; open?: boolean }, config: Config ) { - const packages = (await getPackages(cwd)).packages.filter( - (pkg) => !config.ignore.includes(pkg.packageJson.name) + const packages = (await getPackages(cwd)).packages.filter((pkg) => + isListablePackage(config, pkg.packageJson) ); const changesetBase = path.resolve(cwd, ".changeset"); - let newChangeset: UnwrapPromise>; + let newChangeset: Awaited>; if (empty) { newChangeset = { confirmed: true, @@ -40,11 +44,11 @@ export default async function add( cwd, ref: config.baseBranch, }); - const changePackagesName = changedPackages - .map((pkg) => pkg.packageJson.name) - .filter((pkgName) => !config.ignore.includes(pkgName)); + const changedPackagesName = changedPackages + .filter((pkg) => isListablePackage(config, pkg.packageJson)) + .map((pkg) => pkg.packageJson.name); - newChangeset = await createChangeset(changePackagesName, packages); + newChangeset = await createChangeset(changedPackagesName, packages); printConfirmationMessage(newChangeset, packages.length > 1); if (!newChangeset.confirmed) { diff --git a/packages/config/CHANGELOG.md b/packages/config/CHANGELOG.md index 689f1b4b3..0b702bb85 100644 --- a/packages/config/CHANGELOG.md +++ b/packages/config/CHANGELOG.md @@ -1,5 +1,11 @@ # @changesets/config +## 2.1.1 + +### Patch Changes + +- [#900](https://github.com/changesets/changesets/pull/900) [`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e) Thanks [@sdirosa](https://github.com/sdirosa)! - Include the information about `false` being a valid value for the `changelog` option in the validation message for the `changelog` option. + ## 2.1.0 ### Minor Changes diff --git a/packages/config/package.json b/packages/config/package.json index 816a7ecf9..5142919ed 100644 --- a/packages/config/package.json +++ b/packages/config/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/config", - "version": "2.1.0", + "version": "2.1.1", "description": "Utilities for reading and parsing Changeset's config", "main": "dist/config.cjs.js", "module": "dist/config.esm.js", diff --git a/packages/get-release-plan/CHANGELOG.md b/packages/get-release-plan/CHANGELOG.md index 250ff56a3..df056d398 100644 --- a/packages/get-release-plan/CHANGELOG.md +++ b/packages/get-release-plan/CHANGELOG.md @@ -1,5 +1,19 @@ # @changesets/get-release-plan +## 3.0.14 + +### Patch Changes + +- Updated dependencies [[`b023e4b`](https://github.com/changesets/changesets/commit/b023e4b3d1ad793a5dd1187b720e8103cebfb937)]: + - @changesets/assemble-release-plan@5.2.1 + +## 3.0.13 + +### Patch Changes + +- Updated dependencies [[`7d998ee`](https://github.com/changesets/changesets/commit/7d998eeb16064b5442ebc49ad31dec7b841d504e)]: + - @changesets/config@2.1.1 + ## 3.0.12 ### Patch Changes diff --git a/packages/get-release-plan/package.json b/packages/get-release-plan/package.json index de2bb1495..579025f95 100644 --- a/packages/get-release-plan/package.json +++ b/packages/get-release-plan/package.json @@ -1,6 +1,6 @@ { "name": "@changesets/get-release-plan", - "version": "3.0.12", + "version": "3.0.14", "description": "Reads changesets and adds information on dependents that need bumping", "main": "dist/get-release-plan.cjs.js", "module": "dist/get-release-plan.esm.js", @@ -8,8 +8,8 @@ "repository": "https://github.com/changesets/changesets/tree/main/packages/get-release-plan", "dependencies": { "@babel/runtime": "^7.10.4", - "@changesets/assemble-release-plan": "^5.2.0", - "@changesets/config": "^2.1.0", + "@changesets/assemble-release-plan": "^5.2.1", + "@changesets/config": "^2.1.1", "@changesets/pre": "^1.0.12", "@changesets/read": "^0.5.7", "@changesets/types": "^5.1.0",