Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit ece4dbf

Browse files
authoredSep 1, 2021
Use npm v7 with workspaces for local development and testing (#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

Lines changed: 9 additions & 3 deletions
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

Lines changed: 6 additions & 12 deletions
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

Lines changed: 9 additions & 3 deletions
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 11 additions & 9 deletions
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

Lines changed: 5 additions & 2 deletions
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

Lines changed: 4 additions & 4 deletions
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.

‎docusaurus/website/yarn.lock

Lines changed: 0 additions & 10309 deletions
This file was deleted.

‎netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[build]
22
base = "docusaurus/website"
33
publish = "docusaurus/website/build"
4-
command = "yarn build"
4+
command = "npm run build"
55

‎package-lock.json

Lines changed: 59997 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"create-react-app": "node tasks/cra.js",
1010
"e2e": "tasks/e2e-simple.sh",
1111
"e2e:docker": "tasks/local-test.sh",
12-
"postinstall": "cd packages/react-error-overlay/ && yarn build:prod",
12+
"postinstall": "npm run build:prod -w react-error-overlay",
1313
"publish": "tasks/publish.sh",
1414
"start": "cd packages/react-scripts && node bin/react-scripts.js start",
1515
"screencast": "node ./tasks/screencast.js",

‎packages/react-error-overlay/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
"start": "cross-env NODE_ENV=development node build.js --watch",
99
"test": "cross-env NODE_ENV=test jest",
1010
"build": "cross-env NODE_ENV=development node build.js",
11-
"build:prod": "cross-env NODE_ENV=production node build.js"
11+
"build:prod": "cross-env NODE_ENV=production node build.js",
12+
"flow": "flow"
1213
},
1314
"repository": {
1415
"type": "git",
@@ -58,7 +59,7 @@
5859
"rimraf": "^3.0.2",
5960
"settle-promise": "1.0.0",
6061
"source-map": "0.5.7",
61-
"webpack": "^5.41.1"
62+
"webpack": "5.41.1"
6263
},
6364
"jest": {
6465
"setupFiles": [

‎packages/react-scripts/fixtures/kitchensink/template/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ This is an end to end kitchensink test suite, but has multiple usages in it.
55
## Running the test suite
66

77
Tests are automatically run by the CI tools.
8-
In order to run them locally, without having to manually install and configure everything, the `yarn e2e:docker` CLI command can be used.
8+
In order to run them locally, without having to manually install and configure everything, the `npm run e2e:docker` CLI command can be used.
99

1010
This is a script that runs a **Docker** container, where the node version, git branch to clone, test suite, and whether to run it with `yarn` or `npm` can be chosen.
11-
Run `yarn e2e:docker --help` to get additional info.
11+
Run `npm run e2e:docker --help` to get additional info.
1212

1313
If you need guidance installing **Docker**, you should follow their [official docs](https://docs.docker.com/engine/installation/).
1414

‎tasks/cra.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ process.on('uncaughtException', handleError);
3939

4040
console.log();
4141
console.log('-------------------------------------------------------');
42-
console.log('Assuming you have already run `yarn` to update the deps.');
42+
console.log('Assuming you have already run `npm install` to update the deps.');
4343
console.log('If not, remember to do this before testing!');
4444
console.log('-------------------------------------------------------');
4545
console.log();
@@ -106,7 +106,7 @@ const scriptsFileName = cp
106106
const scriptsPath = path.join(packagesDir, 'react-scripts', scriptsFileName);
107107

108108
// Now that we have packed them, call the global CLI.
109-
cp.execSync('yarn cache clean');
109+
cp.execSync('npm cache clean');
110110

111111
const args = process.argv.slice(2);
112112

‎tasks/e2e-behavior.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ then
6767
fi
6868

6969
# Bootstrap monorepo
70-
yarn
70+
npm install
7171

7272
# ******************************************************************************
7373
# First, publish the monorepo.

‎tasks/e2e-installs.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ then
8989
fi
9090

9191
# Bootstrap monorepo
92-
yarn
92+
npm install
9393

9494
# ******************************************************************************
9595
# First, publish the monorepo.
@@ -163,9 +163,9 @@ exists src/react-app-env.d.ts
163163
checkTypeScriptDependencies
164164

165165
# Check that the TypeScript template passes smoke tests, build, and normal tests
166-
yarn start --smoke-test
167-
yarn build
168-
CI=true yarn test
166+
npm start -- --smoke-test
167+
npm run build
168+
CI=true npm test
169169

170170
# Check eject behaves and works
171171

@@ -180,9 +180,9 @@ yarn add @babel/plugin-transform-react-jsx-source @babel/plugin-syntax-jsx @babe
180180
exists src/react-app-env.d.ts
181181

182182
# Check that the TypeScript template passes ejected smoke tests, build, and normal tests
183-
yarn start --smoke-test
184-
yarn build
185-
CI=true yarn test
183+
npm start -- --smoke-test
184+
npm run build
185+
CI=true npm test
186186

187187
# ******************************************************************************
188188
# Test --scripts-version with a tarball url
@@ -258,20 +258,20 @@ cd test-app-nested-paths-t1
258258
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
259259
npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd
260260
cd test-app-nested-paths-t1/aa/bb/cc/dd
261-
yarn start --smoke-test
261+
npm start -- --smoke-test
262262

263263
# Testing a path that does not exist
264264
cd "$temp_app_path"
265265
npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd
266266
cd test-app-nested-paths-t2/aa/bb/cc/dd
267-
yarn start --smoke-test
267+
npm start -- --smoke-test
268268

269269
# Testing a path that is half exists
270270
cd "$temp_app_path"
271271
mkdir -p test-app-nested-paths-t3/aa
272272
npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd
273273
cd test-app-nested-paths-t3/aa/bb/cc/dd
274-
yarn start --smoke-test
274+
npm start -- --smoke-test
275275

276276
# ******************************************************************************
277277
# Test when PnP is enabled
@@ -281,8 +281,8 @@ npx create-react-app test-app-pnp --use-pnp
281281
cd test-app-pnp
282282
! exists node_modules
283283
exists .pnp.js
284-
yarn start --smoke-test
285-
yarn build
284+
npm start -- --smoke-test
285+
npm run build
286286

287287
# Cleanup
288288
cleanup

‎tasks/e2e-kitchensink-eject.sh

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ then
7575
fi
7676

7777
# Bootstrap monorepo
78-
yarn
78+
npm install
7979

8080
# ******************************************************************************
8181
# First, publish the monorepo.
@@ -97,7 +97,7 @@ npx create-react-app test-kitchensink --template=file:"$root_path"/packages/reac
9797

9898
# Install the test module
9999
cd "$temp_module_path"
100-
yarn add test-integrity@^2.0.1
100+
npm install test-integrity@^2.0.1
101101

102102
# ******************************************************************************
103103
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -110,9 +110,6 @@ cd "$temp_app_path/test-kitchensink"
110110
# In kitchensink, we want to test all transforms
111111
export BROWSERSLIST='ie 9'
112112

113-
# Link to test module
114-
npm link "$temp_module_path/node_modules/test-integrity"
115-
116113
# ******************************************************************************
117114
# Finally, let's check that everything still works after ejecting.
118115
# ******************************************************************************
@@ -124,14 +121,11 @@ echo yes | npm run eject
124121
rm yarn.lock
125122
yarn add @babel/plugin-transform-react-jsx-source @babel/plugin-syntax-jsx @babel/plugin-transform-react-jsx @babel/plugin-transform-react-jsx-self
126123

127-
# Link to test module
128-
npm link "$temp_module_path/node_modules/test-integrity"
129-
130124
# Test the build
131125
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
132126
NODE_PATH=src \
133127
PUBLIC_URL=http://www.example.org/spa/ \
134-
yarn build
128+
npm run build
135129

136130
# Check for expected output
137131
exists build/*.html
@@ -142,14 +136,14 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
142136
CI=true \
143137
NODE_PATH=src \
144138
NODE_ENV=test \
145-
yarn test --no-cache --runInBand --testPathPattern=src
139+
npm test --no-cache --runInBand --testPathPattern=src
146140

147141
# Test "development" environment
148142
tmp_server_log=`mktemp`
149143
PORT=3002 \
150144
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
151145
NODE_PATH=src \
152-
nohup yarn start &>$tmp_server_log &
146+
nohup npm start &>$tmp_server_log &
153147
grep -q 'You can now view' <(tail -f $tmp_server_log)
154148
E2E_URL="http://localhost:3002" \
155149
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \

‎tasks/e2e-kitchensink.sh

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ then
7575
fi
7676

7777
# Bootstrap monorepo
78-
yarn
78+
npm install
7979

8080
# ******************************************************************************
8181
# First, publish the monorepo.
@@ -97,7 +97,7 @@ npx create-react-app test-kitchensink --template=file:"$root_path"/packages/reac
9797

9898
# Install the test module
9999
cd "$temp_module_path"
100-
yarn add test-integrity@^2.0.1
100+
npm install test-integrity@^2.0.1
101101

102102
# ******************************************************************************
103103
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -110,13 +110,10 @@ cd "$temp_app_path/test-kitchensink"
110110
# In kitchensink, we want to test all transforms
111111
export BROWSERSLIST='ie 9'
112112

113-
# Link to test module
114-
npm link "$temp_module_path/node_modules/test-integrity"
115-
116113
# Test the build
117114
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
118115
PUBLIC_URL=http://www.example.org/spa/ \
119-
yarn build
116+
npm run build
120117

121118
# Check for expected output
122119
exists build/*.html
@@ -127,14 +124,14 @@ exists build/static/js/main.*.js
127124
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
128125
CI=true \
129126
NODE_ENV=test \
130-
yarn test --no-cache --runInBand --testPathPattern=src
127+
npm test --no-cache --runInBand --testPathPattern=src
131128

132129
# Prepare "development" environment
133130
tmp_server_log=`mktemp`
134131
PORT=3001 \
135132
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
136133
NODE_PATH=src \
137-
nohup yarn start &>$tmp_server_log &
134+
nohup npm start &>$tmp_server_log &
138135
grep -q 'You can now view' <(tail -f $tmp_server_log)
139136

140137
# Test "development" environment

‎tasks/e2e-simple.sh

Lines changed: 22 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ then
8282
fi
8383

8484
# Bootstrap monorepo
85-
yarn
85+
npm install
8686

8787
# Start the local NPM registry
8888
startLocalRegistry "$root_path"/tasks/verdaccio.yaml
@@ -96,33 +96,25 @@ startLocalRegistry "$root_path"/tasks/verdaccio.yaml
9696
./node_modules/.bin/eslint --max-warnings 0 packages/react-error-overlay/src/
9797
./node_modules/.bin/eslint --max-warnings 0 packages/react-scripts/
9898

99-
cd packages/react-error-overlay/
100-
yarn test
99+
npm test -w react-error-overlay
101100
if [ "$AGENT_OS" != 'Windows_NT' ]; then
102101
# Flow started hanging on Windows build agents
103-
yarn flow
102+
npm run flow -w react-error-overlay
104103
fi
105-
cd ../..
106104

107-
cd packages/react-dev-utils/
108-
yarn test
109-
cd ../..
105+
npm test -w react-dev-utils
110106

111-
cd packages/babel-plugin-named-asset-import/
112-
yarn test
113-
cd ../..
107+
npm test -w babel-plugin-named-asset-import
114108

115-
cd packages/confusing-browser-globals/
116-
yarn test
117-
cd ../..
109+
npm test -w confusing-browser-globals
118110

119111
# ******************************************************************************
120112
# First, test the create-react-app development environment.
121113
# This does not affect our users but makes sure we can develop it.
122114
# ******************************************************************************
123115

124116
# Test local build command
125-
yarn build
117+
npm run build
126118
# Check for expected output
127119
exists build/*.html
128120
exists build/static/js/*.js
@@ -131,12 +123,12 @@ exists build/static/media/*.svg
131123
exists build/favicon.ico
132124

133125
# Run tests with CI flag
134-
CI=true yarn test
126+
CI=true npm test
135127
# Uncomment when snapshot testing is enabled by default:
136128
# exists template/src/__snapshots__/App.test.js.snap
137129

138130
# Test local start command
139-
yarn start --smoke-test
131+
npm start -- --smoke-test
140132

141133
# Publish the monorepo
142134
publishToLocalRegistry
@@ -166,36 +158,36 @@ function verify_env_url {
166158
# Test relative path build
167159
awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json
168160

169-
yarn build
161+
npm run build
170162
# Disabled until this can be tested
171163
# grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1
172164
grep -F -R --exclude=*.map "\"./static/" build/ -q; test $? -eq 0 || exit 1
173165
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
174166

175-
PUBLIC_URL="/anabsolute" yarn build
167+
PUBLIC_URL="/anabsolute" npm run build
176168
grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1
177169
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
178170

179171
# Test absolute path build
180172
sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json
181173

182-
yarn build
174+
npm run build
183175
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
184176
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
185177

186-
PUBLIC_URL="https://www.example.net/overridetest" yarn build
178+
PUBLIC_URL="https://www.example.net/overridetest" npm run build
187179
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
188180
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
189181
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1
190182

191183
# Test absolute url build
192184
sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json
193185

194-
yarn build
186+
npm run build
195187
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
196188
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
197189

198-
PUBLIC_URL="https://www.example.net/overridetest" yarn build
190+
PUBLIC_URL="https://www.example.net/overridetest" npm run build
199191
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
200192
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
201193
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1
@@ -216,7 +208,7 @@ function verify_module_scope {
216208
echo "import sampleJson from '../sample'" | cat - src/App.js > src/App.js.temp && mv src/App.js.temp src/App.js
217209

218210
# Make sure the build fails
219-
yarn build; test $? -eq 1 || exit 1
211+
npm run build; test $? -eq 1 || exit 1
220212
# TODO: check for error message
221213

222214
rm sample.json
@@ -230,7 +222,7 @@ function verify_module_scope {
230222
cd test-app
231223

232224
# Test the build
233-
yarn build
225+
npm run build
234226
# Check for expected output
235227
exists build/*.html
236228
exists build/static/js/*.js
@@ -239,12 +231,12 @@ exists build/static/media/*.svg
239231
exists build/favicon.ico
240232

241233
# Run tests with CI flag
242-
CI=true yarn test
234+
CI=true npm test
243235
# Uncomment when snapshot testing is enabled by default:
244236
# exists src/__snapshots__/App.test.js.snap
245237

246238
# Test the server
247-
yarn start --smoke-test
239+
npm start -- --smoke-test
248240

249241
# Test environment handling
250242
verify_env_url
@@ -267,7 +259,7 @@ yarn add @babel/plugin-transform-react-jsx-source @babel/plugin-syntax-jsx @babe
267259
test -n "$(git diff --staged --name-only)"
268260

269261
# Test the build
270-
yarn build
262+
npm run build
271263
# Check for expected output
272264
exists build/*.html
273265
exists build/static/js/*.js
@@ -276,15 +268,12 @@ exists build/static/media/*.svg
276268
exists build/favicon.ico
277269

278270
# Run tests, overriding the watch option to disable it.
279-
# `CI=true yarn test` won't work here because `yarn test` becomes just `jest`.
280-
# We should either teach Jest to respect CI env variable, or make
281-
# `scripts/test.js` survive ejection (right now it doesn't).
282-
yarn test --watch=no
271+
npm test --watch=no
283272
# Uncomment when snapshot testing is enabled by default:
284273
# exists src/__snapshots__/App.test.js.snap
285274

286275
# Test the server
287-
yarn start --smoke-test
276+
npm start -- --smoke-test
288277

289278
# Test environment handling
290279
verify_env_url

‎tasks/publish.sh

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ cd ..
2727
root_path=$PWD
2828

2929
if [ -z $CI ]; then
30-
yarn compile:lockfile
30+
npm run compile:lockfile
3131
fi
3232

3333
if [ -n "$(git status --porcelain)" ]; then
@@ -36,9 +36,7 @@ if [ -n "$(git status --porcelain)" ]; then
3636
fi
3737

3838
# Compile
39-
cd packages/react-error-overlay/
40-
npm run build:prod
41-
cd ../..
39+
npm run build:prod -w react-error-overlay
4240

4341
# Get 2FA when not CI
4442
otp=""

‎test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
These tests ensure various functionality contracts are upheld across dependency upgrades.
66

7-
To get started locally, run `cd packages/react-scripts/ && yarn link; cd ../../test/ && ../node_modules/.bin/jest --watchAll`.
7+
To get started locally, run `npx jest test/ --watchAll`.
88

99
It's suggested that you filter down tests to avoid re-running everything. The most common tests will be the webpack messages.<br>
1010
To only run the webpack messages, type `p` followed by `webpack-message` and press `[enter]`.

‎test/fixtures/__shared__/util/scripts.js

Lines changed: 12 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,21 @@ const os = require('os');
44
const stripAnsi = require('strip-ansi');
55
const waitForLocalhost = require('wait-for-localhost');
66

7-
function stripYarn(output) {
8-
let lines = output.split('\n');
9-
10-
let runIndex = lines.findIndex(line => line.match(/^yarn run/));
11-
if (runIndex !== -1) {
12-
lines.splice(0, runIndex + 2);
13-
lines = lines.filter(line => !line.match(/^info Visit.*yarnpkg/));
14-
}
15-
16-
return lines.join('\n');
17-
}
18-
197
function execaSafe(...args) {
208
return execa(...args)
219
.then(({ stdout, stderr, ...rest }) => ({
2210
fulfilled: true,
2311
rejected: false,
24-
stdout: stripYarn(stripAnsi(stdout)),
25-
stderr: stripYarn(stripAnsi(stderr)),
12+
stdout: stripAnsi(stdout),
13+
stderr: stripAnsi(stderr),
2614
...rest,
2715
}))
2816
.catch(err => ({
2917
fulfilled: false,
3018
rejected: true,
3119
reason: err,
3220
stdout: '',
33-
stderr: stripYarn(
34-
stripAnsi(
35-
err.message
36-
.split('\n')
37-
.slice(2)
38-
.join('\n')
39-
)
40-
),
21+
stderr: stripAnsi(err.message.split('\n').slice(2).join('\n')),
4122
}));
4223
}
4324

@@ -63,9 +44,9 @@ module.exports = class ReactScripts {
6344
};
6445

6546
if (smoke) {
66-
return await execaSafe('yarnpkg', ['start', '--smoke-test'], options);
47+
return await execaSafe('npm', ['start', '--smoke-test'], options);
6748
}
68-
const startProcess = execa('yarnpkg', ['start'], options);
49+
const startProcess = execa('npm', ['start'], options);
6950
await waitForLocalhost({ port });
7051
return {
7152
port,
@@ -76,7 +57,7 @@ module.exports = class ReactScripts {
7657
}
7758

7859
async build({ env = {} } = {}) {
79-
return await execaSafe('yarnpkg', ['build'], {
60+
return await execaSafe('npm', ['run', 'build'], {
8061
cwd: this.root,
8162
env: Object.assign({}, { CI: 'false', FORCE_COLOR: '0' }, env),
8263
});
@@ -85,8 +66,8 @@ module.exports = class ReactScripts {
8566
async serve() {
8667
const port = await getPort();
8768
const serveProcess = execa(
88-
'yarnpkg',
89-
['serve', '--', '-p', port, '-s', 'build/'],
69+
'npm',
70+
['run', 'serve', '--', '-p', port, '-s', 'build/'],
9071
{
9172
cwd: this.root,
9273
}
@@ -101,13 +82,9 @@ module.exports = class ReactScripts {
10182
}
10283

10384
async test({ jestEnvironment = 'jsdom', env = {} } = {}) {
104-
return await execaSafe(
105-
'yarnpkg',
106-
['test', '--env', jestEnvironment, '--ci'],
107-
{
108-
cwd: this.root,
109-
env: Object.assign({}, { CI: 'true' }, env),
110-
}
111-
);
85+
return await execaSafe('npm', ['test', '--env', jestEnvironment, '--ci'], {
86+
cwd: this.root,
87+
env: Object.assign({}, { CI: 'true' }, env),
88+
});
11289
}
11390
};

‎test/fixtures/__shared__/util/setup.js

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const tempy = require('tempy');
55
const ReactScripts = require('./scripts');
66

77
module.exports = class TestSetup {
8-
constructor(fixtureName, templateDirectory, { pnp = true } = {}) {
8+
constructor(fixtureName, templateDirectory) {
99
this.fixtureName = fixtureName;
1010

1111
this.templateDirectory = templateDirectory;
@@ -16,7 +16,6 @@ module.exports = class TestSetup {
1616
this.teardown = this.teardown.bind(this);
1717

1818
this.isLocal = !(process.env.CI && process.env.CI !== 'false');
19-
this.settings = { pnp: pnp && !this.isLocal };
2019
}
2120

2221
async setup() {
@@ -28,7 +27,6 @@ module.exports = class TestSetup {
2827
);
2928
await fs.copy(this.templateDirectory, this.testDirectory);
3029
await fs.remove(path.resolve(this.testDirectory, 'test.partial.js'));
31-
await fs.remove(path.resolve(this.testDirectory, '.disable-pnp'));
3230

3331
const packageJson = await fs.readJson(
3432
path.resolve(this.testDirectory, 'package.json')
@@ -51,18 +49,9 @@ module.exports = class TestSetup {
5149
packageJson
5250
);
5351

54-
await execa(
55-
'yarnpkg',
56-
[
57-
'install',
58-
this.settings.pnp ? '--enable-pnp' : null,
59-
'--mutex',
60-
'network',
61-
].filter(Boolean),
62-
{
63-
cwd: this.testDirectory,
64-
}
65-
);
52+
await execa('npm', ['install'], {
53+
cwd: this.testDirectory,
54+
});
6655

6756
if (!shouldInstallScripts) {
6857
await fs.ensureSymlink(
@@ -78,7 +67,7 @@ module.exports = class TestSetup {
7867
),
7968
path.join(this.testDirectory, 'node_modules', '.bin', 'react-scripts')
8069
);
81-
await execa('yarnpkg', ['link', 'react-scripts'], {
70+
await execa('npm', ['link', 'react-scripts'], {
8271
cwd: this.testDirectory,
8372
});
8473
}

‎test/fixtures/boostrap-sass/.disable-pnp

Whitespace-only changes.

‎test/fixtures/global-scss-asset-resolution/.disable-pnp

Whitespace-only changes.

‎test/fixtures/jsconfig/.disable-pnp

Whitespace-only changes.

‎test/fixtures/typescript-advanced/.disable-pnp

Whitespace-only changes.

‎test/fixtures/typescript-typecheck/.disable-pnp

Whitespace-only changes.

‎test/fixtures/typescript/.disable-pnp

Whitespace-only changes.

‎test/fixtures/webpack-message-formatting/.disable-pnp

Whitespace-only changes.

0 commit comments

Comments
 (0)
Please sign in to comment.