Skip to content

Commit 80f6479

Browse files
gaearonPavel Zhytko
authored and
Pavel Zhytko
committed
Switch to Yarn Workspaces (facebook#3755)
* Switch to Yarn Workspaces * Feedback * Move flowconfig * Use publish script * Keep git status check * Fix Flow without perf penalty * Remove Flow from package.json "test" * Try running it from script directly (?) * Try magic incantations * lol flow COME ON * Try to skip Flow on AppVeyor * -df * -df * -df * Try to fix CI * Revert unrelated changes * Update CONTRIBUTING.md
1 parent 973a22b commit 80f6479

12 files changed

+65
-107
lines changed

.yarnrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--install.no-lockfile true

CONTRIBUTING.md

+8-10
Original file line numberDiff line numberDiff line change
@@ -75,20 +75,18 @@ All functionality must be retained (and configuration given to the user) if they
7575

7676
1. Clone the repo with `git clone https://github.com/facebookincubator/create-react-app`
7777

78-
2. Run `npm install` in the root `create-react-app` folder.
78+
2. Run `yarn` in the root `create-react-app` folder.
7979

80-
Once it is done, you can modify any file locally and run `npm start`, `npm test` or `npm run build` just like in a generated project.
80+
Once it is done, you can modify any file locally and run `yarn start`, `yarn test` or `yarn build` just like in a generated project.
8181

8282
If you want to try out the end-to-end flow with the global CLI, you can do this too:
8383

8484
```
85-
npm run create-react-app my-app
85+
yarn create-react-app my-app
8686
cd my-app
8787
```
8888

89-
and then run `npm start` or `npm run build`.
90-
91-
*Note: if you are using yarn, we suggest that you use `yarn install --no-lockfile` instead of the bare `yarn` or `yarn install` because we [intentionally](https://github.com/facebookincubator/create-react-app/pull/2014#issuecomment-300811661) do not ignore or add yarn.lock to our repo.*
89+
and then run `yarn start` or `yarn build`.
9290

9391
## Contributing to E2E (end to end) tests
9492

@@ -104,8 +102,8 @@ The scripts in tasks folder and other scripts in `package.json` will not work in
104102

105103
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/)
106104

107-
### Install Node.js and npm
108-
Even if you have node and npm 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.
105+
### Install Node.js and yarn
106+
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.
109107

110108
### Line endings
111109

@@ -119,11 +117,11 @@ By default git would use `CRLF` line endings which would cause the scripts to fa
119117
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`.
120118
5. Create a change log entry for the release:
121119
* 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="..."`
122-
* Run `npm run 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`.
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`.
123121
* 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.
124122
* 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.
125123
6. Make sure to include “Migrating from ...” instructions for the previous release. Often you can copy and paste them.
126-
7. **Do not run `npm publish`. Instead, run `npm run publish`.**
124+
7. Run `yarn run publish`. (Don’t forget the `run` there.)
127125
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.
128126
9. After publishing, create a GitHub Release with the same text as the changelog entry. See previous Releases for inspiration.
129127

bootstrap.js

-67
This file was deleted.

lerna.json

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
{
2-
"lerna": "2.0.0",
2+
"lerna": "2.6.0",
3+
"npmClient": "yarn",
4+
"useWorkspaces": true,
35
"version": "independent",
46
"changelog": {
57
"repo": "facebookincubator/create-react-app",
@@ -12,8 +14,5 @@
1214
"tag: internal": ":house: Internal"
1315
},
1416
"cacheDir": ".changelog"
15-
},
16-
"packages": [
17-
"packages/*"
18-
]
17+
}
1918
}

package.json

+9-6
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
{
22
"private": true,
3+
"workspaces": [
4+
"packages/*"
5+
],
36
"scripts": {
4-
"build": "node packages/react-scripts/scripts/build.js",
7+
"build": "cd packages/react-scripts && node scripts/build.js",
58
"changelog": "lerna-changelog",
69
"create-react-app": "node tasks/cra.js",
710
"e2e": "tasks/e2e-simple.sh",
811
"e2e:docker": "tasks/local-test.sh",
9-
"postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod",
10-
"publish": "tasks/release.sh",
11-
"start": "node packages/react-scripts/scripts/start.js",
12+
"postinstall": "cd packages/react-error-overlay/ && yarn build:prod",
13+
"publish": "tasks/publish.sh",
14+
"start": "cd packages/react-scripts && node scripts/start.js",
1215
"screencast": "svg-term --cast hItN7sl5yfCPTHxvFg5glhhfp --out screencast.svg --window",
13-
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
16+
"test": "cd packages/react-scripts && node scripts/test.js --env=jsdom",
1417
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
1518
"precommit": "lint-staged"
1619
},
1720
"devDependencies": {
1821
"eslint": "^4.4.1",
1922
"husky": "^0.13.2",
20-
"lerna": "^2.0.0",
23+
"lerna": "^2.6.0",
2124
"lerna-changelog": "^0.6.0",
2225
"lint-staged": "^3.3.1",
2326
"prettier": "1.6.1",
+10-4
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
1-
[ignore]
2-
.*/node_modules/eslint-plugin-jsx-a11y/.*
3-
41
[include]
5-
src/**/*.js
2+
<PROJECT_ROOT>/src/**/*.js
3+
4+
[ignore]
5+
.*/node_modules/.*
6+
.*/.git/.*
7+
.*/__test__/.*
8+
.*/fixtures/.*
69

710
[libs]
11+
flow/
812

913
[options]
14+
module.file_ext=.js
15+
sharedmemory.hash_table_pow=19
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
declare module 'anser' {
2+
declare module.exports: any;
3+
}
4+
5+
declare module 'babel-code-frame' {
6+
declare module.exports: any;
7+
}
8+
9+
declare module 'html-entities' {
10+
declare module.exports: any;
11+
}
12+
13+
declare module 'settle-promise' {
14+
declare module.exports: any;
15+
}
16+
17+
declare module 'source-map' {
18+
declare module.exports: any;
19+
}

packages/react-error-overlay/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"prepublishOnly": "npm run build:prod && npm test",
88
"start": "cross-env NODE_ENV=development node build.js --watch",
9-
"test": "flow && cross-env NODE_ENV=test jest",
9+
"test": "cross-env NODE_ENV=test jest",
1010
"build": "cross-env NODE_ENV=development node build.js",
1111
"build:prod": "cross-env NODE_ENV=production node build.js"
1212
},

tasks/e2e-installs.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,8 @@ yarn config set registry "$custom_registry_url"
9999
npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url" --quotes
100100

101101
# Publish the monorepo
102-
git clean -f
103-
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
102+
git clean -df
103+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
104104

105105
# ******************************************************************************
106106
# Test --scripts-version with a version number

tasks/e2e-kitchensink.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ yarn config set registry "$custom_registry_url"
9191
npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url" --quotes
9292

9393
# Publish the monorepo
94-
git clean -f
95-
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
94+
git clean -df
95+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
9696

9797
# ******************************************************************************
9898
# Now that we have published them, create a clean app folder and install them.

tasks/e2e-simple.sh

+8-2
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ npx [email protected] -u user -p password -e [email protected] -r "$custom_reg
107107
cd packages/react-error-overlay/
108108
./node_modules/.bin/eslint --max-warnings 0 src/
109109
yarn test
110+
111+
if [ $APPVEYOR != 'True' ]; then
112+
# Flow started hanging on AppVeyor after we moved to Yarn Workspaces :-(
113+
yarn flow
114+
fi
115+
110116
cd ../..
111117
cd packages/react-dev-utils/
112118
yarn test
@@ -134,8 +140,8 @@ CI=true yarn test
134140
# Test local start command
135141
yarn start --smoke-test
136142

137-
git clean -f
138-
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
143+
git clean -df
144+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
139145

140146
# ******************************************************************************
141147
# Install react-scripts prerelease via create-react-app prerelease.

tasks/release.sh tasks/publish.sh

+1-8
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,14 @@ set -x
2626
cd ..
2727
root_path=$PWD
2828

29-
# You can only release with npm >= 3
30-
if [ $(npm -v | head -c 1) -lt 3 ]; then
31-
echo "Releasing requires npm >= 3. Aborting.";
32-
exit 1;
33-
fi;
34-
3529
if [ -n "$(git status --porcelain)" ]; then
3630
echo "Your git status is not clean. Aborting.";
3731
exit 1;
3832
fi
3933

40-
cd "$root_path"
4134
# Compile
4235
cd packages/react-error-overlay/
4336
npm run build:prod
4437
cd ../..
4538
# Go!
46-
./node_modules/.bin/lerna publish --independent "$@"
39+
./node_modules/.bin/lerna publish --independent "$@"

0 commit comments

Comments
 (0)