Skip to content

Commit

Permalink
V2 (#147)
Browse files Browse the repository at this point in the history
Merge in v2 update of the changesets cli
  • Loading branch information
Noviny committed Sep 13, 2019
1 parent 5331b87 commit ca8ff58
Show file tree
Hide file tree
Showing 90 changed files with 1,933 additions and 3,240 deletions.
89 changes: 0 additions & 89 deletions .changeset/config.js

This file was deleted.

4 changes: 4 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"changelog": "./getChangelogEntry.js",
"commit": false
}
5 changes: 5 additions & 0 deletions .changeset/curvy-olives-play.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/get-release-plan": minor
---

Initial Release
42 changes: 42 additions & 0 deletions .changeset/getChangelogEntry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
require("dotenv").config();
const { getInfo } = require("@changesets/get-github-info");

const getReleaseLine = async (changeset, type) => {
const [firstLine, ...futureLines] = changeset.summary
.split("\n")
.map(l => l.trimRight());

if (changeset.commit) {
let { links } = await getInfo({
repo: "atlassian/changesets",
commit: changeset.commit
});
return `- ${links.commit}${links.pull === null ? "" : ` ${links.pull}`}${
links.user === null ? "" : ` Thanks ${links.user}!`
} - ${firstLine}\n${futureLines.map(l => ` ${l}`).join("\n")}`;
} else {
return `- ${firstLine}\n${futureLines.map(l => ` ${l}`).join("\n")}`;
}
};

const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
if (dependenciesUpdated.length === 0) return "";

changesets.map(cs => cs.commit).filter(_ => _);

const changesetLink = `- Updated dependencies [${changesets
.map(cs => cs.commit)
.filter(_ => _)
.join(", ")}]:`;

const updatedDepenenciesList = dependenciesUpdated.map(
dependency => ` - ${dependency.name}@${dependency.newVersion}`
);

return [changesetLink, ...updatedDepenenciesList].join("\n");
};

module.exports = {
getDependencyReleaseLine,
getReleaseLine
};
5 changes: 5 additions & 0 deletions .changeset/soft-seas-shake.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"bolt-check": patch
---

Use `@changesets/get-version-range-type` to get version range type, to avoid having this function duplicated
16 changes: 16 additions & 0 deletions .changeset/v2-changed-command-line-args.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@changesets/cli": major
---

#### Changed command line argument names

We have removed command line arguments that overrwrite the config. The following commands can no longer
be passed in:

- `updateChangelog`
- `isPublic`
- `skipCI`
- `commit`

This has been done to avoid overloading the number of ways you can pass options, as within any single
repository, there should be a single consistent way in which these values are always provided.
28 changes: 28 additions & 0 deletions .changeset/v2-changed-config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
"@changesets/cli": major
---

#### Changed how Config works

The Changesets config is now written in JSON with fewer options. The new defaults are shown below.

```json
{
"$schema": "https://unpkg.com/@changesets/config/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"linked": [],
"access": "private"
}
```

**Reasoning**: Having a JSON config makes it easier to build other tools on changesets because the config can be read without executing user code that could potentially be unsafe. It also means we can have easy autocompletion and descriptions in editors that don't go out of date like the comments in the JS config along with being able to packagise changelog entry generators.

##### Migrating

1. Run `yarn changeset init` to create a config file in the new format at `.changeset/config.json`
1. If you're using changelogs, move `getReleaseLine` and `getDependencyReleaseLine` to their own module and set the changelog option to the path to the module. If you're not using changelogs, set the changelog option to `false`. In the future, we will be providing packages to write changelogs for common use cases
1. Set `access` to `"public"` if `publishOptions.public` is `true`, otherwise set it to `"private"`
1. If you use `linked`, copy your linked package groups from the JS config to the the JSON file
1. If you use `commit` and `skipCI` in `versionOptions` or `publishOptions`, set commit to `true`, all commits will include a skip ci message. if you have a use case for only using commit on one command or not including a skip ci message by default
1. Delete `.changeset/config.js`
21 changes: 21 additions & 0 deletions .changeset/v2-changes-to-changelog-generation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
"@changesets/cli": major
---

#### Changelog generation functions have minor changes

In addition to how these functions are defined (see changes to config), the data that is passed through
to these functions is notably different to what it was before. For the most part, the changelog functions
simply receive richer information, based on the new changelog format.

**BREAKING**: The release objects and dependency release objects now use `release.newVersion` for the latest
version, instead of the previous `release.version`.

The `@changesets/types` package includes exports for both `GetReleaseLine` as well as `GetDependencyReleaseLine`.

If you were using the default changelog generation scripts, you won't need to worry. Otherwise, we recommend updating
your command and manually running `version` to ensure you are still getting the changelogs you expect.

**Looking further forward** We are already aware that we want to change how people write these generation functions,
including opening up more flexibility, and access to things such as the underlying release plan. This will likely require
a breaking change in the future, but we thought we were changing enough this release that we didn't want too much turmoil. 😁
16 changes: 16 additions & 0 deletions .changeset/v2-renamed-commands.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@changesets/cli": major
---

#### Renamed commands

- `bump` has been renamed to `version`
- `release` has been renamed to `publish`

This is a reversion to the changes made in `1.0.0`.

**Reasoning**: We switched the names because we wanted to avoid confusion with the related
tasks in npm. While technically it removed confusion that this was doing the same thing as
`npm version`, or `npm publish`, the new terms did not convey easily grokkable meanings. As
we weren't benefiting from the new names, we have decided to revert to names that have more
meaning within the community, even though these commands do slightly more than this.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"commit": true,
"changelog": "./getChangelogEntry.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,13 @@ const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
);

const updatedDepenenciesList = dependenciesUpdated.map(
dependency => ` - ${dependency.name}@${dependency.version}`
dependency => ` - ${dependency.name}@${dependency.newVersion}`
);

return [...changesetLinks, ...updatedDepenenciesList].join("\n");
};

const changesetOptions = {
commit: true
};
const versionOptions = {
commit: true,
skipCI: true,
module.exports = {
getReleaseLine,
getDependencyReleaseLine
};

const publishOptions = {
public: true
};

module.exports = {
versionOptions,
changesetOptions,
publishOptions
};
1 change: 1 addition & 0 deletions __fixtures__/simple-project/.changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
5 changes: 5 additions & 0 deletions __fixtures__/with-git/.changeset/quick-lions-devour.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"pkga-a": minor
---

This is a pretty bogus changeset
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"workspaces": [
"packages/*"
],
"author": "Atlassian Pty Ltd",
"author": "Ben Conolly",
"license": "MIT",
"dependencies": {
"@babel/cli": "^7.4.4",
Expand Down
10 changes: 6 additions & 4 deletions packages/apply-release-plan/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,19 @@
"dependencies": {
"@babel/runtime": "^7.4.4",
"@changesets/config": "^0.1.2",
"@changesets/get-version-range-type": "^0.0.2",
"@changesets/git": "^0.1.2",
"@changesets/types": "^0.1.2",
"@changesets/get-version-range-type": "^0.0.2",
"fs-extra": "^7.0.1",
"get-workspaces": "^0.4.2",
"prettier": "^1.14.3",
"resolve-from": "^5.0.0"
"resolve-from": "^5.0.0",
"lodash.startcase": "^4.4.0",
"outdent": "^0.5.0"
},
"devDependencies": {
"@changesets/git": "^0.1.2",
"jest-fixtures": "^0.5.0",
"lodash.startcase": "^4.4.0",
"outdent": "^0.5.0"
"spawndamnit": "^2.0.0"
}
}
Loading

0 comments on commit ca8ff58

Please sign in to comment.