Skip to content

Commit

Permalink
Merge branch 'main' into prefer-local-prettier
Browse files Browse the repository at this point in the history
# Conflicts:
#	packages/assemble-release-plan/src/index.ts
#	packages/cli/src/commands/add/index.ts
  • Loading branch information
Andarist committed Aug 29, 2022
2 parents f2eed37 + 8e64d41 commit 08b5c19
Show file tree
Hide file tree
Showing 24 changed files with 161 additions and 60 deletions.
5 changes: 0 additions & 5 deletions .changeset/friendly-vans-hammer.md

This file was deleted.

6 changes: 0 additions & 6 deletions .changeset/mean-mugs-return.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/silver-toys-turn.md

This file was deleted.

4 changes: 4 additions & 0 deletions README.md
Expand Up @@ -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)

Expand Down
@@ -0,0 +1 @@
{}
@@ -0,0 +1,9 @@
{
"private": true,
"name": "private-package-without-version-field",
"description": "Base yarn workspace work",
"version": "1.0.0",
"workspaces": [
"packages/*"
]
}
@@ -0,0 +1,4 @@
{
"name": "pkg-a",
"version": "1.0.0"
}
@@ -0,0 +1,4 @@
{
"name": "pkg-b",
"private": true
}
@@ -0,0 +1,4 @@
{
"name": "pkg-c",
"version": "1.0.0"
}
14 changes: 7 additions & 7 deletions 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?
Expand All @@ -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.

Expand All @@ -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.

Expand All @@ -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.
9 changes: 9 additions & 0 deletions 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
Expand Down
4 changes: 2 additions & 2 deletions packages/apply-release-plan/package.json
@@ -1,14 +1,14 @@
{
"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",
"license": "MIT",
"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",
Expand Down
6 changes: 6 additions & 0 deletions 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
Expand Down
2 changes: 1 addition & 1 deletion 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",
Expand Down
39 changes: 27 additions & 12 deletions packages/assemble-release-plan/src/index.ts
Expand Up @@ -117,41 +117,48 @@ function getNewVersion(
return incrementVersion(release, preInfo);
}

type OptionalProp<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;

function assembleReleasePlan(
changesets: NewChangeset[],
packages: Packages,
config: Config,
config: OptionalProp<Config, "snapshot">,
// 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 {
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
// changesets, and with a calculated new versions
let releases = flattenReleases(
relevantChangesets,
packagesByName,
config.ignore
refinedConfig.ignore
);

let dependencyGraph = getDependentsGraph(packages, {
bumpVersionsWithWorkspaceProtocolOnly:
config.bumpVersionsWithWorkspaceProtocolOnly,
refinedConfig.bumpVersionsWithWorkspaceProtocolOnly,
});

let releasesValidated = false;
Expand All @@ -162,16 +169,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;
Expand All @@ -193,7 +204,7 @@ function assembleReleasePlan(
});
} else if (
existingRelease.type === "none" &&
!config.ignore.includes(pkg.packageJson.name)
!refinedConfig.ignore.includes(pkg.packageJson.name)
) {
existingRelease.type = "patch";
}
Expand All @@ -203,7 +214,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,
Expand All @@ -214,7 +229,7 @@ function assembleReleasePlan(
? getSnapshotVersion(
incompleteRelease,
preInfo,
config.snapshot.useCalculatedVersion,
refinedConfig.snapshot.useCalculatedVersion,
snapshotSuffix
)
: getNewVersion(incompleteRelease, preInfo),
Expand Down
23 changes: 23 additions & 0 deletions 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
Expand Down
10 changes: 5 additions & 5 deletions 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"
Expand Down Expand Up @@ -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",
Expand Down
10 changes: 10 additions & 0 deletions packages/cli/src/commands/add/__tests__/add.ts
Expand Up @@ -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"]);
Expand Down
10 changes: 7 additions & 3 deletions packages/cli/src/commands/add/createChangeset.ts
Expand Up @@ -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<string>,
allPackages: Package[]
Expand All @@ -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);

Expand Down

0 comments on commit 08b5c19

Please sign in to comment.