-
Notifications
You must be signed in to change notification settings - Fork 557
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add linked option to config * Remove a thing * Add docs * Add a changeset
- Loading branch information
Showing
14 changed files
with
295 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"releases": [{ "name": "@changesets/cli", "type": "minor" }], | ||
"dependents": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Add linked packages/lockstep |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Linked Packages | ||
|
||
Linked packages allow you to specify a group or groups of packages that should be versioned together. There are some complex cases, so some examples are shown below to demonstrate various cases. | ||
|
||
- Linked packages will still only bumped when there is a changeset for them (this can mean because you explicitly choose to add a changeset for it or because it's a dependant of something being released) | ||
- Packages that have changesets and are in a set of linked packages will **always** be versioned to the highest current version in the set of linked packages + the highest bump type from changesets in the set of linked packages | ||
|
||
## Examples | ||
|
||
### General example | ||
|
||
I have three packages, `pkg-a`, `pkg-b` and `pkg-c`. `pkg-a` and `pkg-b` are linked but `pkg-c` is not so the config looks like this. | ||
|
||
```jsx | ||
// stuff... | ||
|
||
const versionOptions = { | ||
...otherStuff, | ||
linked: [["pkg-a", "pkg-b"]] | ||
}; | ||
|
||
// stuff... | ||
``` | ||
|
||
- `pkg-a` is at `1.0.0` | ||
- `pkg-b` is at `1.0.0` | ||
- `pkg-c` is at `1.0.0` | ||
|
||
I have a changeset with a patch for `pkg-a`, minor for `pkg-b` and major for `pkg-c` and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `1.1.0` | ||
- `pkg-b` is at `1.1.0` | ||
- `pkg-c` is at `2.0.0` | ||
|
||
I now have another changeset with a minor for `pkg-a` and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `1.2.0` | ||
- `pkg-b` is at `1.1.0` | ||
- `pkg-c` is at `2.0.0` | ||
|
||
I now have another changeset with a minor for `pkg-b` and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `1.2.0` | ||
- `pkg-b` is at `1.3.0` | ||
- `pkg-c` is at `2.0.0` | ||
|
||
I now have another changeset with patches for all three packages and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `1.3.1` | ||
- `pkg-b` is at `1.3.1` | ||
- `pkg-c` is at `2.0.1` | ||
|
||
### Example with dependants | ||
|
||
I have two packages, `pkg-a`, `pkg-b` which are linked. `pkg-a` has a dependency on `pkg-b`. | ||
|
||
```jsx | ||
// stuff... | ||
|
||
const versionOptions = { | ||
...otherStuff, | ||
linked: [["pkg-a", "pkg-b"]] | ||
}; | ||
|
||
// stuff... | ||
``` | ||
|
||
- `pkg-a` is at `1.0.0` | ||
- `pkg-b` is at `1.0.0` | ||
|
||
I have a changeset with a major for `pkg-b` and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `2.0.0` | ||
- `pkg-b` is at `2.0.0` | ||
|
||
I now have another changeset with a major for `pkg-a` and I do a release, the resulting versions will be: | ||
|
||
- `pkg-a` is at `3.0.0` | ||
- `pkg-b` is at `2.0.0` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/cli/src/__fixtures__/linked-packages/.changeset/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
# We just want a file in here so git collects it |
88 changes: 88 additions & 0 deletions
88
packages/cli/src/__fixtures__/linked-packages/.changeset/config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
/* | ||
Hey, welcome to the changeset config! This file has been generated | ||
for you with the default configs we use, and some comments around | ||
what options mean, so that it's easy to customise your workflow. | ||
You should update this as you need to craft your workflow. | ||
Config provided by a CI command takes precedence over the contents of this file. | ||
If a config option isn't present here, we will fall back to the defaults. | ||
*/ | ||
|
||
const changesetOptions = { | ||
// If true, we will automatically commit the changeset when the command is run | ||
commit: false | ||
}; | ||
|
||
// This function takes information about a changeset to generate an entry for it in your | ||
// changelog. We provide the full changeset object as well as the version. | ||
// It may be a good idea to replace the commit hash with a link to the commit. | ||
|
||
/* the default shape is: | ||
### Bump Type | ||
- GIT_HASH: A summary message you wrote, indented? | ||
*/ | ||
|
||
// eslint-disable-next-line no-unused-vars | ||
const getReleaseLine = async (changeset, type) => { | ||
const [firstLine, ...futureLines] = changeset.summary | ||
.split("\n") | ||
.map(l => l.trimRight()); | ||
|
||
return `- ${changeset.commit}: ${firstLine}\n${futureLines | ||
.map(l => ` ${l}`) | ||
.join("\n")}`; | ||
}; | ||
|
||
// This function takes information about what dependencies we are updating in the package. | ||
// It provides an array of related changesets, as well as the dependencies updated. | ||
|
||
/* | ||
- Updated dependencies: [ABCDEFG]: | ||
- Updated dependencies: [HIJKLMN]: | ||
- dependencyA@1.0.1 | ||
- dependencyb@1.2.0 | ||
*/ | ||
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => { | ||
if (dependenciesUpdated.length === 0) return ""; | ||
|
||
const changesetLinks = changesets.map( | ||
changeset => `- Updated dependencies [${changeset.commit}]:` | ||
); | ||
|
||
const updatedDepenenciesList = dependenciesUpdated.map( | ||
dependency => ` - ${dependency.name}@${dependency.version}` | ||
); | ||
|
||
return [...changesetLinks, ...updatedDepenenciesList].join("\n"); | ||
}; | ||
|
||
const versionOptions = { | ||
// If true, we will automatically commit the version updating when the command is run | ||
commit: false, | ||
// Adds a skipCI flag to the commit - only valid if `commit` is also true. | ||
skipCI: false, | ||
// Do not modify the `changelog.md` files for packages that are updated | ||
updateChangelog: true, | ||
// A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries | ||
getReleaseLine, | ||
// A function that returns a string. It takes in options about when a pacakge is updated because | ||
getDependencyReleaseLine, | ||
// An array of arrays that defines packages that are linked. | ||
// Linked packages are packages that should be at the same version when they're released. | ||
// If you've used Lerna to version packages before, this is very similar. | ||
linked: [["pkg-a", "pkg-b"]] | ||
}; | ||
|
||
const publishOptions = { | ||
// This sets whether unpublished packages are public by default. We err on the side of caution here. | ||
public: false | ||
}; | ||
|
||
module.exports = { | ||
versionOptions, | ||
changesetOptions, | ||
publishOptions | ||
}; |
11 changes: 11 additions & 0 deletions
11
packages/cli/src/__fixtures__/linked-packages/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"private": true, | ||
"name": "simple-project", | ||
"description": "three projects, each depending on one other", | ||
"version": "1.0.0", | ||
"bolt": { | ||
"workspaces": [ | ||
"packages/*" | ||
] | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/cli/src/__fixtures__/linked-packages/packages/pkg-a/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"name": "pkg-a", | ||
"version": "1.0.0", | ||
"dependencies": { | ||
"pkg-b": "0.1.0" | ||
} | ||
} |
4 changes: 4 additions & 0 deletions
4
packages/cli/src/__fixtures__/linked-packages/packages/pkg-b/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name": "pkg-b", | ||
"version": "0.1.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters