Skip to content

Commit ece4dbf

Browse files
authored
Use npm v7 with workspaces for local development and testing (facebook#11304)
1 parent 08dc7ab commit ece4dbf

File tree

30 files changed

+60115
-10472
lines changed

30 files changed

+60115
-10472
lines changed

.github/workflows/build.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ jobs:
66
build:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v1
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v2
11+
with:
12+
node-version: '14'
13+
cache: 'npm'
14+
- name: Install npm@7
15+
run: npm i -g npm@7
1016
- name: Install
11-
run: yarn --no-progress --non-interactive --no-lockfile
17+
run: npm ci --prefer-offline
1218
- name: Build
13-
run: yarn build
19+
run: npm run build

.github/workflows/integration.yml

+6-12
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,13 @@ jobs:
1818
steps:
1919
- uses: actions/checkout@v2
2020
- name: Setup node
21-
uses: actions/setup-node@v1
21+
uses: actions/setup-node@v2
2222
with:
2323
node-version: ${{ matrix.node }}
24-
- name: Cache dependencies
25-
id: cache
26-
uses: actions/cache@v2
27-
with:
28-
path: |
29-
node_modules
30-
*/*/node_modules
31-
key: ${{ runner.os }}-${{ hashFiles('**/yarn.lock', './yarn.lock') }}
24+
cache: 'npm'
25+
- name: Install npm@7
26+
run: npm i -g npm@7
3227
- name: Install packages
33-
if: steps.cache.outputs.cache-hit != 'true'
34-
run: yarn --frozen-lockfile --prefer-offline
28+
run: npm ci --prefer-offline
3529
- name: Run integration tests
36-
run: yarn test:integration
30+
run: npm run test:integration

.github/workflows/lint.yml

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,14 @@ jobs:
66
lint:
77
runs-on: ubuntu-latest
88
steps:
9-
- uses: actions/checkout@v1
9+
- uses: actions/checkout@v2
10+
- uses: actions/setup-node@v2
11+
with:
12+
node-version: '14'
13+
cache: 'npm'
14+
- name: Install npm@7
15+
run: npm i -g npm@7
1016
- name: Install
11-
run: yarn --no-progress --non-interactive --no-lockfile
17+
run: npm ci --prefer-offline
1218
- name: Alex
13-
run: yarn alex
19+
run: npm run alex

.gitignore

-1
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,3 @@ yarn-debug.log*
1212
yarn-error.log*
1313
/.changelog
1414
.npm/
15-
yarn.lock

CONTRIBUTING.md

+11-9
Original file line numberDiff line numberDiff line change
@@ -90,24 +90,26 @@ All functionality must be retained (and configuration given to the user) if they
9090

9191
## Setting Up a Local Copy
9292

93+
You will need `npm@7` and `yarn@1` in order to bootstrap and test a local copy of this repo.
94+
9395
1. Clone the repo with `git clone https://github.com/facebook/create-react-app`
9496

95-
2. Run `yarn` in the root `create-react-app` folder.
97+
2. Run `npm install` in the root `create-react-app` folder.
9698

97-
Once it is done, you can modify any file locally and run `yarn start`, `yarn test` or `yarn build` like you can in a generated project. It will serve the application from the files located in `packages/cra-template/template`.
99+
Once it is done, you can modify any file locally and run `npm start`, `npm test` or `npm run build` like you can in a generated project. It will serve the application from the files located in `packages/cra-template/template`.
98100

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

101103
```sh
102-
yarn create-react-app my-app
104+
npx create-react-app my-app
103105
cd my-app
104106
```
105107

106-
and then run `yarn start` or `yarn build`.
108+
and then run `npm start` or `npm run build`.
107109

108110
## Contributing to E2E (end to end) tests
109111

110-
**TL;DR** use the command `yarn e2e:docker` to run unit and e2e tests.
112+
**TL;DR** use the command `npm run e2e:docker` to run unit and e2e tests.
111113

112114
More detailed information are in the dedicated [README](/test/README.md).
113115

@@ -143,11 +145,11 @@ By default git would use `CRLF` line endings which would cause the scripts to fa
143145
2. Close the milestone and create a new one for the next release.
144146
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).
145147
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`.
146-
5. Run `yarn compile:lockfile`. The command will generate an updated lockfile in `packages/create-react-app` that should be committed.
148+
5. Run `npm run compile:lockfile`. The command will generate an updated lockfile in `packages/create-react-app` that should be committed.
147149
6. Create a change log entry for the release:
148150

149151
- 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="..."`
150-
- 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`.
152+
- 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`.
151153
- 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.
152154
- 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.
153155

@@ -161,9 +163,9 @@ Make sure to test the released version! If you want to be extra careful, you can
161163
## Releasing the Docs
162164

163165
1. Go to the `docusaurus/website` directory
164-
2. Run `yarn build`
166+
2. Run `npm run build`
165167
3. 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="..."`
166-
4. Run `GIT_USER=<GITHUB_USERNAME> CURRENT_BRANCH=main USE_SSH=true yarn deploy`
168+
4. Run `GIT_USER=<GITHUB_USERNAME> CURRENT_BRANCH=main USE_SSH=true npm run deploy`
167169

168170
---
169171

azure-pipelines-test-job.yml

+5-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ jobs:
3131
versionSpec: $(nodeVersion)
3232
displayName: 'Install Node.js'
3333

34-
- script: yarn --frozen-lockfile
35-
displayName: 'Run yarn'
34+
- script: npm i -g npm@7
35+
displayName: 'Update npm to v7'
36+
37+
- script: npm ci
38+
displayName: 'Run npm ci'
3639

3740
- bash: ${{ parameters.testScript }}
3841
displayName: 'Run tests'

docusaurus/website/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,29 +5,29 @@ This website is built using Docusaurus 2, a modern static website generator.
55
### Installation
66

77
```
8-
$ yarn
8+
$ npm install
99
```
1010

1111
### Local Development
1212

1313
```
14-
$ yarn start
14+
$ npm start
1515
```
1616

1717
This command starts a local development server and open up a browser window. Most changes are reflected live without having to restart the server.
1818

1919
### Build
2020

2121
```
22-
$ yarn build
22+
$ npm run build
2323
```
2424

2525
This command generates static content into the `build` directory and can be served using any static contents hosting service.
2626

2727
### Deployment
2828

2929
```
30-
$ GIT_USER=<Your GitHub username> USE_SSH=1 yarn deploy
30+
$ GIT_USER=<Your GitHub username> USE_SSH=1 npm run deploy
3131
```
3232

3333
If you are using GitHub pages for hosting, this command is a convenient way to build the website and push to the `gh-pages` branch.

0 commit comments

Comments
 (0)