Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Yarn Workspaces #3755

Merged
merged 18 commits into from
Jan 12, 2018
Merged
1 change: 1 addition & 0 deletions .yarnrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--install.no-lockfile true
18 changes: 8 additions & 10 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,18 @@ All functionality must be retained (and configuration given to the user) if they

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

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

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.
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.

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

```
npm run create-react-app my-app
yarn create-react-app my-app
cd my-app
```

and then run `npm start` or `npm run build`.

*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.*
and then run `yarn start` or `yarn build`.

## Contributing to E2E (end to end) tests

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

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

### Install Node.js and npm
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.
### Install Node.js and yarn
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.

### Line endings

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

Expand Down
67 changes: 0 additions & 67 deletions bootstrap.js

This file was deleted.

9 changes: 4 additions & 5 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
{
"lerna": "2.0.0",
"lerna": "2.6.0",
"npmClient": "yarn",
"useWorkspaces": true,
"version": "independent",
"changelog": {
"repo": "facebookincubator/create-react-app",
Expand All @@ -12,8 +14,5 @@
"tag: internal": ":house: Internal"
},
"cacheDir": ".changelog"
},
"packages": [
"packages/*"
]
}
}
15 changes: 9 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build": "node packages/react-scripts/scripts/build.js",
"build": "cd packages/react-scripts && node scripts/build.js",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change in this PR? Do workspaces have an issue with working directories?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't remember. I think it might not be related to YW but to Yarn in general (which sets cwd to the project you run the script in).

"changelog": "lerna-changelog",
"create-react-app": "node tasks/cra.js",
"e2e": "tasks/e2e-simple.sh",
"e2e:docker": "tasks/local-test.sh",
"postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod",
"publish": "tasks/release.sh",
"start": "node packages/react-scripts/scripts/start.js",
"postinstall": "cd packages/react-error-overlay/ && yarn build:prod",
"publish": "tasks/publish.sh",
"start": "cd packages/react-scripts && node scripts/start.js",
"screencast": "svg-term --cast hItN7sl5yfCPTHxvFg5glhhfp --out screencast.svg --window",
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
"test": "cd packages/react-scripts && node scripts/test.js --env=jsdom",
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
"precommit": "lint-staged"
},
"devDependencies": {
"eslint": "^4.4.1",
"husky": "^0.13.2",
"lerna": "^2.0.0",
"lerna": "^2.6.0",
"lerna-changelog": "^0.6.0",
"lint-staged": "^3.3.1",
"prettier": "1.6.1",
Expand Down
14 changes: 10 additions & 4 deletions packages/react-error-overlay/.flowconfig
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
[ignore]
.*/node_modules/eslint-plugin-jsx-a11y/.*

[include]
src/**/*.js
<PROJECT_ROOT>/src/**/*.js

[ignore]
.*/node_modules/.*
.*/.git/.*
.*/__test__/.*
.*/fixtures/.*

[libs]
flow/

[options]
module.file_ext=.js
sharedmemory.hash_table_pow=19
19 changes: 19 additions & 0 deletions packages/react-error-overlay/flow/env.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
declare module 'anser' {
declare module.exports: any;
}

declare module 'babel-code-frame' {
declare module.exports: any;
}

declare module 'html-entities' {
declare module.exports: any;
}

declare module 'settle-promise' {
declare module.exports: any;
}

declare module 'source-map' {
declare module.exports: any;
}
2 changes: 1 addition & 1 deletion packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"scripts": {
"prepublishOnly": "npm run build:prod && npm test",
"start": "cross-env NODE_ENV=development node build.js --watch",
"test": "flow && cross-env NODE_ENV=test jest",
"test": "cross-env NODE_ENV=test jest",
"build": "cross-env NODE_ENV=development node build.js",
"build:prod": "cross-env NODE_ENV=production node build.js"
},
Expand Down
4 changes: 2 additions & 2 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ yarn config set registry "$custom_registry_url"
npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url" --quotes

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

# ******************************************************************************
# Test --scripts-version with a version number
Expand Down
4 changes: 2 additions & 2 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ yarn config set registry "$custom_registry_url"
npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url" --quotes

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

# ******************************************************************************
# Now that we have published them, create a clean app folder and install them.
Expand Down
10 changes: 8 additions & 2 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@ npx [email protected] -u user -p password -e [email protected] -r "$custom_reg
cd packages/react-error-overlay/
./node_modules/.bin/eslint --max-warnings 0 src/
yarn test

if [ $APPVEYOR != 'True' ]; then
# Flow started hanging on AppVeyor after we moved to Yarn Workspaces :-(
yarn flow
fi

cd ../..
cd packages/react-dev-utils/
yarn test
Expand Down Expand Up @@ -134,8 +140,8 @@ CI=true yarn test
# Test local start command
yarn start --smoke-test

git clean -f
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
git clean -df
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest

# ******************************************************************************
# Install react-scripts prerelease via create-react-app prerelease.
Expand Down
9 changes: 1 addition & 8 deletions tasks/release.sh → tasks/publish.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,14 @@ set -x
cd ..
root_path=$PWD

# You can only release with npm >= 3
if [ $(npm -v | head -c 1) -lt 3 ]; then
echo "Releasing requires npm >= 3. Aborting.";
exit 1;
fi;

if [ -n "$(git status --porcelain)" ]; then
echo "Your git status is not clean. Aborting.";
exit 1;
fi

cd "$root_path"
# Compile
cd packages/react-error-overlay/
npm run build:prod
cd ../..
# Go!
./node_modules/.bin/lerna publish --independent "$@"
./node_modules/.bin/lerna publish --independent "$@"