Skip to content

Commit 275967e

Browse files
authored
Use changesets (emotion-js#1343)
* Add changesets * Change some docs and remove unused things * Remove @changesets/get-github-info for now * Update stuff * Update stuff * Add a test changeset * Revert "Add a test changeset" This reverts commit c5de643. * Remove lerna stuff
1 parent 59dd99c commit 275967e

9 files changed

+635
-1666
lines changed

.changeset/README.md

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# Changesets
2+
3+
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works with `bolt` to help you release components from a mono-repository. You can find the full documentation for it [here](https://www.npmjs.com/package/@changesets/cli)
4+
5+
To help you get started though, here are some things you should know about this folder:
6+
7+
## Changesets are automatically generated
8+
9+
Changesets are generated by the `yarn changeset` or `npx changeset` command. As long as you are following a changeset release flow, you shouldn't have any problems.
10+
11+
## Each changeset is its own folder
12+
13+
We use hashes by default for these folder names to avoid collisions when generating them, but there's no harm that will come from renaming them.
14+
15+
## Changesets are automatically removed
16+
17+
When `changeset bump` or equivalent command is run, all the changeset folders are removed. This is so we only ever use a changeset once. This makes this a very bad place to store any other information.
18+
19+
## Changesets come in two parts
20+
21+
You should treat these parts quite differently:
22+
23+
- `changes.md` is a file you should feel free to edit as much as you want. It will be prepended to your changelog when you next run your version command.
24+
- `changes.json` is a file that includes information about releases, what should be versioned by the version command. We strongly recommend against editing this directly, as you may make a new changeset that puts your bolt repository into an invalid state.
25+
26+
## I want to edit the information in a `changes.json` - how do I do it safely?
27+
28+
The best option is to make a new changeset using the changeset command, copy over the `changes.md`, then delete the old changeset.
29+
30+
## Can I rename the folder for my changeset?
31+
32+
Absolutely! We need unique hashes to make changesets play nicely with git, but changing your folder from our hash to your own name isn't going to cause any problems.
33+
34+
## Can I manually delete changesets?
35+
36+
You can, but you should be aware this will remove the intent to release communicated by the changeset, and should be done with caution.

.changeset/config.js

+115
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
require('dotenv').config()
2+
const { getInfo } = require('@changesets/get-github-info')
3+
4+
/*
5+
Hey, welcome to the changeset config! This file has been generated
6+
for you with the default configs we use, and some comments around
7+
what options mean, so that it's easy to customise your workflow.
8+
9+
You should update this as you need to craft your workflow.
10+
11+
Config provided by a CI command takes precedence over the contents of this file.
12+
13+
If a config option isn't present here, we will fall back to the defaults.
14+
*/
15+
16+
const changesetOptions = {
17+
// If true, we will automatically commit the changeset when the command is run
18+
commit: false
19+
}
20+
21+
// This function takes information about a changeset to generate an entry for it in your
22+
// changelog. We provide the full changeset object as well as the version.
23+
// It may be a good idea to replace the commit hash with a link to the commit.
24+
25+
/* the default shape is:
26+
### Bump Type
27+
28+
- GIT_HASH: A summary message you wrote, indented?
29+
*/
30+
31+
const getReleaseLine = async (changeset, type) => {
32+
const [firstLine, ...futureLines] = changeset.summary
33+
.split('\n')
34+
.map(l => l.trimRight())
35+
36+
let { links } = await getInfo({
37+
repo: 'emotion-js/emotion',
38+
commit: changeset.commit
39+
})
40+
41+
return `- ${links.commit}${links.pull === null ? '' : ` ${links.pull}`}${
42+
links.user === null ? '' : ` Thanks ${links.user}!`
43+
} - ${firstLine}\n${futureLines.map(l => ` ${l}`).join('\n')}`
44+
}
45+
46+
// This function takes information about what dependencies we are updating in the package.
47+
// It provides an array of related changesets, as well as the dependencies updated.
48+
49+
/*
50+
- Updated dependencies: [ABCDEFG]:
51+
- Updated dependencies: [HIJKLMN]:
52+
- dependencyA@1.0.1
53+
- dependencyb@1.2.0
54+
*/
55+
const getDependencyReleaseLine = async (changesets, dependenciesUpdated) => {
56+
if (dependenciesUpdated.length === 0) return ''
57+
58+
const changesetLinks = changesets.map(
59+
changeset => `- Updated dependencies [${changeset.commit}]:`
60+
)
61+
62+
const updatedDepenenciesList = dependenciesUpdated.map(
63+
dependency => ` - ${dependency.name}@${dependency.version}`
64+
)
65+
66+
return [...changesetLinks, ...updatedDepenenciesList].join('\n')
67+
}
68+
69+
const versionOptions = {
70+
// If true, we will automatically commit the version updating when the command is run
71+
commit: false,
72+
// Adds a skipCI flag to the commit - only valid if `commit` is also true.
73+
skipCI: false,
74+
// Do not modify the `changelog.md` files for packages that are updated
75+
updateChangelog: true,
76+
// A function that returns a string. It takes in options about a change. This allows you to customise your changelog entries
77+
getReleaseLine,
78+
// A function that returns a string. It takes in options about when a pacakge is updated because
79+
getDependencyReleaseLine,
80+
// An array of arrays that defines packages that are linked.
81+
// Linked packages are packages that should be at the same version when they're released.
82+
// If you've used Lerna to version packages before, this is very similar.
83+
linked: [
84+
[
85+
'@emotion/core',
86+
'@emotion/styled',
87+
'@emotion/styled-base',
88+
'@emotion/cache',
89+
'@emotion/css',
90+
'create-emotion',
91+
'emotion',
92+
'emotion-server',
93+
'create-emotion-server',
94+
'babel-plugin-emotion',
95+
'@emotion/babel-preset-css-prop',
96+
'jest-emotion',
97+
'@emotion/native',
98+
'@emotion/primitives',
99+
'@emotion/primitives-core',
100+
'eslint-plugin-emotion',
101+
'emotion-theming'
102+
]
103+
]
104+
}
105+
106+
const publishOptions = {
107+
// This sets whether unpublished packages are public by default. We err on the side of caution here.
108+
public: false
109+
}
110+
111+
module.exports = {
112+
versionOptions,
113+
changesetOptions,
114+
publishOptions
115+
}

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ package-lock.json
99
.DS_Store
1010
.cache
1111
public/
12-
!playgrounds/cra/public
12+
!playgrounds/cra/public
13+
.env

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# New Changes
2+
3+
All new changes are now documented in `CHANGELOG.md` files in each package's directory.
4+
15
## v10.0.0 (2018-10-27)
26

37
Emotion 10 is a big change that we're really excited about with improvements to the css prop, a Global component for dynamic global styles, zero config SSR, lots of small fixes and improvements and more with an incremental adoption strategy. For a higher-level overview, read the [Medium article on Emotion 10](https://medium.com/emotion-js/announcing-emotion-10-f1a4b17b8ccd). For a migration guide, visit [the migrating to Emotion 10 page on emotion.sh](https://emotion.sh/docs/migrating-to-emotion-10)

CONTRIBUTING.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@
88
- Run `yarn` in the repository's root directory to install everything you need for development.
99
- Run `yarn build` in the root directory to build the modules.
1010

11-
> NOTE:
12-
>
13-
> lerna is **NOT** used for installing packages. Only yarn is used. lerna is only used for publishing
14-
1511
## Running Tests
1612

1713
- `yarn test` will run the tests once.
@@ -29,3 +25,7 @@
2925
- Run above installation steps and then
3026
- Run `yarn start:site` to run a development server of gatsby.
3127
- Run `yarn build:site` to create a build of the assets for the documentation website.
28+
29+
## Changesets
30+
31+
Emotion uses [changesets](https://github.com/Noviny/changesets) to do versioning. What that means for contributors is that you need to add a changeset by running `yarn changeset` which contains what packages should be bumped, their associated semver bump types and some markdown which will be inserted into changelogs.

RELEASING.md

+4-9
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
# Releasing Emotion
22

3-
Emotion contains packages versions in two different ways. The "primary" packages that are intended for use by app or component library authors are versioned together. "secondary" packages that are utilities and may be used without the rest of emotion are versioned independently.
3+
Emotion uses [changesets](https://github.com/Noviny/changesets) to do versioning. This makes releasing really easy and changelogs are automatically generated.
44

55
## How to do a release
66

7-
1. Make sure you have [bolt](https://github.com/boltpkg/bolt) installed globally
8-
2. Run `yarn version-packages`. Primary packages should all be bumped to the same version. Secondary packages should be bumped according to whatever changes have happened to them.
9-
3. Run `git tag vCURRENTPRIMARYPACKAGESVERSION`
10-
4. Run `NPM_CONFIG_OTP=PUTANOTPCODEHERE bolt publish`. If the 2FA code times out while publishing, run the command again with a new code, only the packages that were not published will be published.
11-
12-
## Problems to solve
13-
14-
- How should changelogs work with this setup, lerna-changelog's output is not very nice for all these packages. Maybe we should use [@atlaskit/build-releases](https://www.npmjs.com/package/@atlaskit/build-releases)?
7+
1. Run `yarn` to make sure everything is up to date
8+
2. Run `yarn version-packages`.
9+
3. Run `NPM_CONFIG_OTP=PUTANOTPCODEHERE yarn release`. If the 2FA code times out while publishing, run the command again with a new code, only the packages that were not published will be published.

lerna.json

-14
This file was deleted.

package.json

+10-17
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,22 @@
88
"test:size": "npm-run-all build size",
99
"test:debug": "node --inspect-brk ./node_modules/jest/bin/jest.js --runInBand --watch",
1010
"test": "jest",
11-
"test:typescript": "lerna run test:typescript --parallel",
11+
"test:typescript": "yarn workspaces run test:typescript",
1212
"coverage": "jest --coverage --no-cache --ci --runInBand",
13-
"test:prod": "npm run build && jest -c jest.dist.js --no-cache --ci --runInBand",
13+
"test:prod": "yarn build && jest -c jest.dist.js --no-cache --ci --runInBand",
1414
"lint:check": "eslint .",
1515
"test:watch": "jest --watch",
1616
"size": "bundlesize",
17-
"release": "npm run build && lerna publish",
1817
"lint": "eslint . --fix",
19-
"benchmark": "lerna exec --scope benchmarks npm run benchmark",
20-
"start:site": "lerna exec --scope emotion-site npm run start:site",
21-
"build:site": "lerna exec --scope emotion-site npm run build:site",
18+
"benchmark": "cd scripts/benchmarks && yarn benchmark",
19+
"start:site": "cd site && yarn start:site",
20+
"build:site": "cd site && yarn build:site",
2221
"flow": "flow",
2322
"flow:check": "flow check --flowconfig-name=.flowconfig-ci",
2423
"postinstall": "opencollective postinstall && preconstruct dev",
25-
"version-packages": "lerna version --preid=beta"
24+
"changeset": "changeset",
25+
"version-packages": "changeset bump",
26+
"release": "yarn build && changeset release"
2627
},
2728
"resolutions": {
2829
"**/react": "16.8.1",
@@ -37,6 +38,8 @@
3738
"@babel/preset-react": "^7.0.0",
3839
"@babel/preset-stage-0": "^7.0.0",
3940
"@babel/register": "^7.0.0",
41+
"@changesets/cli": "^1.1.1",
42+
"@changesets/get-github-info": "^0.1.1",
4043
"babel-check-duplicated-nodes": "^1.0.0",
4144
"babel-core": "^7.0.0-bridge.0",
4245
"babel-eslint": "^8.2.3",
@@ -66,7 +69,6 @@
6669
"eslint-plugin-react": "^7.3.0",
6770
"eslint-plugin-standard": "^3.0.1",
6871
"flow-bin": "^0.89.0",
69-
"get-lerna-packages": "^0.1.0",
7072
"hoist-non-react-statics": "^3.3.0",
7173
"husky": "^1.1.3",
7274
"jest": "^24.1.0",
@@ -75,7 +77,6 @@
7577
"jest-serializer-html": "^4.0.1",
7678
"jest-watch-typeahead": "^0.2.0",
7779
"jsdom": "^11.3.0",
78-
"lerna": "^3.4.0",
7980
"lint-staged": "^7.2.0",
8081
"module-alias": "^2.0.1",
8182
"npm-run-all": "^4.0.2",
@@ -180,14 +181,6 @@
180181
"**/dtslint"
181182
]
182183
},
183-
"bolt": {
184-
"workspaces": [
185-
"packages/*",
186-
"site",
187-
"scripts/*",
188-
"playgrounds/*"
189-
]
190-
},
191184
"preconstruct": {
192185
"packages": [
193186
"packages/*"

0 commit comments

Comments
 (0)