Skip to content

Commit 201079d

Browse files
arcanisgaearon
authored andcommitted
Caches the Yarn resolution for faster installs (facebook#5270)
* Caches the Yarn resolution for faster installs * Adds the yarn.lock.cached file to the publish list * Removes the copied lockfile when the install fails * Updates the release checklist
1 parent d6682c8 commit 201079d

File tree

7 files changed

+9814
-16
lines changed

7 files changed

+9814
-16
lines changed

CONTRIBUTING.md

+29-12
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,12 @@ Please **ask first** if somebody else is already working on this or the core dev
4242
Please also provide a **test plan**, i.e. specify how you verified that your addition works.
4343

4444
## Folder Structure of Create React App
45+
4546
`create-react-app` is a monorepo, meaning it is divided into independent sub-packages.<br>
4647
These packages can be found in the [`packages/`](https://github.com/facebook/create-react-app/tree/master/packages) directory.
4748

4849
### Overview of directory structure
50+
4951
```
5052
packages/
5153
babel-preset-react-app/
@@ -54,20 +56,31 @@ packages/
5456
react-dev-utils/
5557
react-scripts/
5658
```
59+
5760
### Package Descriptions
61+
5862
#### [babel-preset-react-app](https://github.com/facebook/create-react-app/tree/master/packages/babel-preset-react-app)
63+
5964
This package is a babel preset intended to be used with `react-scripts`.<br>
6065
It targets platforms that React is designed to support (IE 11+) and enables experimental features used heavily at Facebook.<br>
6166
This package is enabled by default for all `create-react-app` scaffolded applications.
67+
6268
#### [create-react-app](https://github.com/facebook/create-react-app/tree/master/packages/create-react-app)
69+
6370
The global CLI command code can be found in this directory, and shouldn't often be changed. It should run on Node 0.10+.
71+
6472
#### [eslint-config-react-app](https://github.com/facebook/create-react-app/tree/master/packages/eslint-config-react-app)
73+
6574
This package contains a conservative set of rules focused on making errors apparent and enforces no style rules.<br>
6675
This package is enabled by default for all `create-react-app` scaffolded applications.
76+
6777
#### [react-dev-utils](https://github.com/facebook/create-react-app/tree/master/packages/react-dev-utils)
78+
6879
This package contains utilities used for `react-scripts` and sister packages.<br>
6980
Its main purpose is to conceal code which the user shouldn't be burdened with upon ejecting.
81+
7082
#### [react-scripts](https://github.com/facebook/create-react-app/tree/master/packages/react-scripts)
83+
7184
This package is the heart of the project, which contains the scripts for setting up the development server, building production builds, configuring all software used, etc.<br>
7285
All functionality must be retained (and configuration given to the user) if they choose to eject.
7386

@@ -96,13 +109,14 @@ More detailed information are in the dedicated [README](/packages/react-scripts/
96109

97110
## Tips for contributors using Windows
98111

99-
The scripts in tasks folder and other scripts in `package.json` will not work in Windows out of the box. However, using [Bash on windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) makes it easier to use those scripts without any workarounds. The steps to do so are detailed below:
112+
The scripts in tasks folder and other scripts in `package.json` will not work in Windows out of the box. However, using [Bash on windows](https://msdn.microsoft.com/en-us/commandline/wsl/about) makes it easier to use those scripts without any workarounds. The steps to do so are detailed below:
100113

101114
### Install Bash on Ubuntu on Windows
102115

103116
A good step by step guide can be found [here](https://www.howtogeek.com/249966/how-to-install-and-use-the-linux-bash-shell-on-windows-10/)
104117

105118
### Install Node.js and yarn
119+
106120
Even if you have node and yarn installed on your windows, it would not be accessible from the bash shell. You would have to install it again. Installing via [`nvm`](https://github.com/creationix/nvm#install-script) is recommended.
107121

108122
### Line endings
@@ -115,18 +129,21 @@ By default git would use `CRLF` line endings which would cause the scripts to fa
115129
2. Close the milestone.
116130
3. In most releases, only `react-scripts` needs to be released. If you don’t have any changes to the `packages/create-react-app` folder, you don’t need to bump its version or publish it (the publish script will publish only changed packages).
117131
4. Note that files in `packages/create-react-app` should be modified with extreme caution. Since it’s a global CLI, any version of `create-react-app` (global CLI) including very old ones should work with the latest version of `react-scripts`.
118-
5. Create a change log entry for the release:
119-
* You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."`
120-
* Run `yarn changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
121-
* Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code.
122-
* Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped.
123-
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
124-
7. Run `npm run publish`. (It has to be `npm run publish` exactly, not just `npm publish` or `yarn publish`.)
125-
8. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
126-
9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
132+
5. Run `yarn compile:lockfile`. The command will generate an updated lockfile in `packages/create-react-app` that should be committed.
133+
6. Create a change log entry for the release:
134+
135+
- You'll need an [access token for the GitHub API](https://help.github.com/articles/creating-an-access-token-for-command-line-use/). Save it to this environment variable: `export GITHUB_AUTH="..."`
136+
- Run `yarn changelog`. The command will find all the labeled pull requests merged since the last release and group them by the label and affected packages, and create a change log entry with all the changes and links to PRs and their authors. Copy and paste it to `CHANGELOG.md`.
137+
- Add a four-space indented paragraph after each non-trivial list item, explaining what changed and why. For each breaking change also write who it affects and instructions for migrating existing code.
138+
- Maybe add some newlines here and there. Preview the result on GitHub to get a feel for it. Changelog generator output is a bit too terse for my taste, so try to make it visually pleasing and well grouped.
139+
140+
7. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
141+
8. Run `npm run publish`. (It has to be `npm run publish` exactly, not just `npm publish` or `yarn publish`.)
142+
9. Wait for a long time, and it will get published. Don’t worry that it’s stuck. In the end the publish script will prompt for versions before publishing the packages.
143+
10. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
127144

128145
Make sure to test the released version! If you want to be extra careful, you can publish a prerelease by running `npm run publish -- --tag next` instead of `npm run publish`.
129146

130-
------------
147+
---
131148

132-
*Many thanks to [h5bp](https://github.com/h5bp/html5-boilerplate/blob/master/.github/CONTRIBUTING.md) for the inspiration with this contributing guide*
149+
_Many thanks to [h5bp](https://github.com/h5bp/html5-boilerplate/blob/master/.github/CONTRIBUTING.md) for the inspiration with this contributing guide_

package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
"screencast": "node ./tasks/screencast.js",
1616
"screencast:error": "svg-term --cast jyu19xGl88FQ3poMY8Hbmfw8y --out screencast-error.svg --window --at 12000 --no-cursor",
1717
"test": "cd packages/react-scripts && node bin/react-scripts.js test",
18-
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'"
18+
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
19+
"compile:lockfile": "node tasks/compile-lockfile.js"
1920
},
2021
"devDependencies": {
2122
"async-sema": "^2.1.3",

packages/create-react-app/createReactApp.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,13 @@ function createApp(name, verbose, version, useNpm, usePnp, template) {
258258
}
259259
}
260260

261+
if (useYarn) {
262+
fs.copySync(
263+
require.resolve('./yarn.lock.cached'),
264+
path.join(root, 'yarn.lock')
265+
);
266+
}
267+
261268
run(
262269
root,
263270
appName,
@@ -422,7 +429,7 @@ function run(
422429
console.log();
423430

424431
// On 'exit' we will delete these files from target directory.
425-
const knownGeneratedFiles = ['package.json', 'node_modules'];
432+
const knownGeneratedFiles = ['package.json', 'yarn.lock', 'node_modules'];
426433
const currentFiles = fs.readdirSync(path.join(root));
427434
currentFiles.forEach(file => {
428435
knownGeneratedFiles.forEach(fileToMatch => {

packages/create-react-app/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
},
1616
"files": [
1717
"index.js",
18-
"createReactApp.js"
18+
"createReactApp.js",
19+
"yarn.lock.cached"
1920
],
2021
"bin": {
2122
"create-react-app": "./index.js"

0 commit comments

Comments
 (0)