Skip to content
This repository was archived by the owner on Jan 26, 2019. It is now read-only.

Commit 97d5561

Browse files
authoredApr 27, 2018
Fix travis build (#302)
Fix travis build
1 parent 55bdf73 commit 97d5561

File tree

10 files changed

+189
-400
lines changed

10 files changed

+189
-400
lines changed
 

‎.travis.yml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
---
2-
# Use Ubuntu Precise instead of new default Trusty which cause build fail
3-
# with pre installed yarn v0.17.8
4-
# https://github.com/facebookincubator/create-react-app/issues/3054
5-
# TODO: remove after Trusty environment is updated with a lastet version of yarn
6-
dist: precise
2+
dist: trusty
73
language: node_js
84
node_js:
9-
- 6
105
- 8
6+
- 9
117
cache:
128
directories:
139
- node_modules
@@ -16,13 +12,17 @@ cache:
1612
install: true
1713
script:
1814
- 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi'
15+
- 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
16+
- 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi'
17+
# Disabled for the moment, since it requires additional work to be done.
18+
# - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
1919
env:
20-
global:
21-
- USE_YARN=no
2220
matrix:
2321
- TEST_SUITE=simple
24-
- TEST_SUITE=install
25-
# There's a weird Yarn/Lerna bug related to prerelease versions.
26-
# TODO: reenable after we ship 1.0.
27-
# - node_js: 6
28-
# env: USE_YARN=yes TEST_SUITE=simple
22+
- TEST_SUITE=kitchensink
23+
# See comment above
24+
# - TEST_SUITE=installs
25+
matrix:
26+
include:
27+
- node_js: 6
28+
env: TEST_SUITE=kitchensink

‎package.json

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,19 @@
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",
6-
"create-react-app": "tasks/cra.sh",
9+
"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-
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
13-
"format": "prettier --trailing-comma es5 --single-quote --write \"packages/*/*.js\" \"packages/*/!(node_modules)/**/*.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",
15+
"test": "cd packages/react-scripts && node scripts/test.js --env=jsdom",
16+
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
1417
"precommit": "lint-staged"
1518
},
1619
"devDependencies": {
@@ -20,10 +23,10 @@
2023
"@types/react-dom": "^15.5.0",
2124
"eslint": "^4.4.1",
2225
"husky": "^0.13.2",
23-
"lerna": "^2.0.0",
26+
"lerna": "2.6.0",
2427
"lerna-changelog": "^0.6.0",
2528
"lint-staged": "^3.3.1",
26-
"prettier": "^1.5.2"
29+
"prettier": "1.6.1"
2730
},
2831
"lint-staged": {
2932
"*.js": [

‎packages/react-dev-utils/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"text-table": "0.2.0"
5757
},
5858
"devDependencies": {
59-
"jest": "20.0.4"
59+
"jest": "22.4.2"
6060
},
6161
"scripts": {
6262
"test": "jest"

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"eslint-plugin-react": "7.1.0",
4949
"flow-bin": "^0.63.1",
5050
"html-entities": "1.2.1",
51-
"jest": "20.0.4",
51+
"jest": "22.4.2",
5252
"jest-fetch-mock": "1.2.1",
5353
"object-assign": "4.1.1",
5454
"promise": "8.0.1",

‎packages/react-scripts/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
"fork-ts-checker-webpack-plugin": "^0.2.8",
3636
"fs-extra": "3.0.1",
3737
"html-webpack-plugin": "2.29.0",
38-
"jest": "22.1.4",
38+
"jest": "22.4.2",
3939
"object-assign": "4.1.1",
4040
"postcss-flexbugs-fixes": "3.2.0",
4141
"postcss-loader": "2.0.8",

‎tasks/e2e-installs.sh

Lines changed: 53 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ cd "$(dirname "$0")"
1414

1515
# CLI and app temporary locations
1616
# http://unix.stackexchange.com/a/84980
17-
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
1817
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
18+
custom_registry_url=http://localhost:4873
19+
original_npm_registry_url=`npm get registry`
20+
original_yarn_registry_url=`yarn config get registry`
1921

2022
function cleanup {
2123
echo 'Cleaning up.'
2224
cd "$root_path"
23-
rm -rf "$temp_cli_path" "$temp_app_path"
25+
rm -rf "$temp_app_path"
26+
npm set registry "$original_npm_registry_url"
27+
yarn config set registry "$original_yarn_registry_url"
2428
}
2529

2630
# Error messages are redirected to stderr
@@ -55,10 +59,6 @@ function checkDependencies {
5559
fi
5660
}
5761

58-
function create_react_app {
59-
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
60-
}
61-
6262
# Exit the script with a helpful error message when any error is encountered
6363
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR
6464

@@ -72,98 +72,82 @@ set -x
7272
cd ..
7373
root_path=$PWD
7474

75-
# Clear cache to avoid issues with incorrect packages being used
76-
if hash yarnpkg 2>/dev/null
77-
then
78-
# AppVeyor uses an old version of yarn.
79-
# Once updated to 0.24.3 or above, the workaround can be removed
80-
# and replaced with `yarnpkg cache clean`
81-
# Issues:
82-
# https://github.com/yarnpkg/yarn/issues/2591
83-
# https://github.com/appveyor/ci/issues/1576
84-
# https://github.com/facebookincubator/create-react-app/pull/2400
85-
# When removing workaround, you may run into
86-
# https://github.com/facebookincubator/create-react-app/issues/2030
87-
case "$(uname -s)" in
88-
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
89-
*) yarn=yarnpkg;;
90-
esac
91-
$yarn cache clean
92-
fi
93-
9475
if hash npm 2>/dev/null
9576
then
96-
# npm 5 is too buggy right now
97-
if [ $(npm -v | head -c 1) -eq 5 ]; then
98-
npm i -g npm@^4.x
99-
fi;
77+
npm i -g npm@latest
10078
npm cache clean || npm cache verify
10179
fi
10280

103-
# Prevent bootstrap, we only want top-level dependencies
104-
cp package.json package.json.bak
105-
grep -v "postinstall" package.json > temp && mv temp package.json
106-
npm install
107-
mv package.json.bak package.json
81+
# Bootstrap monorepo
82+
yarn
10883

109-
if [ "$USE_YARN" = "yes" ]
110-
then
111-
# Install Yarn so that the test can use it to install packages.
112-
npm install -g yarn
113-
yarn cache clean
114-
fi
84+
# ******************************************************************************
85+
# First, publish the monorepo.
86+
# ******************************************************************************
87+
88+
# Start local registry
89+
tmp_registry_log=`mktemp`
90+
nohup npx verdaccio@2.7.2 &>$tmp_registry_log &
91+
# Wait for `verdaccio` to boot
92+
grep -q 'http address' <(tail -f $tmp_registry_log)
11593

116-
# We removed the postinstall, so do it manually
117-
node bootstrap.js
94+
# Set registry to local registry
95+
npm set registry "$custom_registry_url"
96+
yarn config set registry "$custom_registry_url"
11897

119-
cd packages/react-error-overlay/
120-
npm run build:prod
121-
cd ../..
98+
# Login so we can publish packages
99+
npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes
100+
101+
# Publish the monorepo
102+
git clean -df
103+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
122104

123105
# ******************************************************************************
124-
# First, pack and install create-react-app.
106+
# Test --scripts-version with a version number
125107
# ******************************************************************************
126108

127-
# Pack CLI
128-
cd "$root_path"/packages/create-react-app
129-
cli_path=$PWD/`npm pack`
109+
cd "$temp_app_path"
110+
npx create-react-app --scripts-version=1.0.17 test-app-version-number
111+
cd test-app-version-number
130112

131-
# Install the CLI in a temporary location
132-
cd "$temp_cli_path"
133-
npm install "$cli_path"
113+
# Check corresponding scripts version is installed.
114+
exists node_modules/react-scripts
115+
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
116+
checkDependencies
134117

135118
# ******************************************************************************
136-
# Test --scripts-version with a version number
119+
# Test --use-npm flag
137120
# ******************************************************************************
138121

139122
cd "$temp_app_path"
140-
create_react_app --scripts-version=0.4.0 test-app-version-number
141-
cd test-app-version-number
123+
npx create-react-app --use-npm --scripts-version=1.0.17 test-use-npm-flag
124+
cd test-use-npm-flag
142125

143126
# Check corresponding scripts version is installed.
144127
exists node_modules/react-scripts
145-
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
128+
[ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist"
129+
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
146130
checkDependencies
147131

148132
# ******************************************************************************
149133
# Test --scripts-version with a tarball url
150134
# ******************************************************************************
151135

152136
cd "$temp_app_path"
153-
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
137+
npx create-react-app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url
154138
cd test-app-tarball-url
155139

156140
# Check corresponding scripts version is installed.
157141
exists node_modules/react-scripts
158-
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
142+
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
159143
checkDependencies
160144

161145
# ******************************************************************************
162146
# Test --scripts-version with a custom fork of react-scripts
163147
# ******************************************************************************
164148

165149
cd "$temp_app_path"
166-
create_react_app --scripts-version=react-scripts-fork test-app-fork
150+
npx create-react-app --scripts-version=react-scripts-fork test-app-fork
167151
cd test-app-fork
168152

169153
# Check corresponding scripts version is installed.
@@ -175,7 +159,7 @@ exists node_modules/react-scripts-fork
175159

176160
cd "$temp_app_path"
177161
# we will install a non-existing package to simulate a failed installataion.
178-
create_react_app --scripts-version=`date +%s` test-app-should-not-exist || true
162+
npx create-react-app --scripts-version=`date +%s` test-app-should-not-exist || true
179163
# confirm that the project folder was deleted
180164
test ! -d test-app-should-not-exist
181165

@@ -187,7 +171,7 @@ cd "$temp_app_path"
187171
mkdir test-app-should-remain
188172
echo '## Hello' > ./test-app-should-remain/README.md
189173
# we will install a non-existing package to simulate a failed installataion.
190-
create_react_app --scripts-version=`date +%s` test-app-should-remain || true
174+
npx create-react-app --scripts-version=`date +%s` test-app-should-remain || true
191175
# confirm the file exist
192176
test -e test-app-should-remain/README.md
193177
# confirm only README.md is the only file in the directory
@@ -201,7 +185,7 @@ fi
201185

202186
cd $temp_app_path
203187
curl "https://registry.npmjs.org/@enoah_netzach/react-scripts/-/react-scripts-0.9.0.tgz" -o enoah-scripts-0.9.0.tgz
204-
create_react_app --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
188+
npx create-react-app --scripts-version=$temp_app_path/enoah-scripts-0.9.0.tgz test-app-scoped-fork-tgz
205189
cd test-app-scoped-fork-tgz
206190

207191
# Check corresponding scripts version is installed.
@@ -216,22 +200,22 @@ cd "$temp_app_path"
216200
mkdir test-app-nested-paths-t1
217201
cd test-app-nested-paths-t1
218202
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
219-
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
203+
npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd
220204
cd test-app-nested-paths-t1/aa/bb/cc/dd
221-
npm start -- --smoke-test
205+
yarn start --smoke-test
222206

223207
# Testing a path that does not exist
224208
cd "$temp_app_path"
225-
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
209+
npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd
226210
cd test-app-nested-paths-t2/aa/bb/cc/dd
227-
npm start -- --smoke-test
211+
yarn start --smoke-test
228212

229213
# Testing a path that is half exists
230214
cd "$temp_app_path"
231215
mkdir -p test-app-nested-paths-t3/aa
232-
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
216+
npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd
233217
cd test-app-nested-paths-t3/aa/bb/cc/dd
234-
npm start -- --smoke-test
218+
yarn start --smoke-test
235219

236220
# Cleanup
237-
cleanup
221+
cleanup

‎tasks/e2e-kitchensink.sh

Lines changed: 37 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,20 @@ cd "$(dirname "$0")"
1414

1515
# CLI, app, and test module temporary locations
1616
# http://unix.stackexchange.com/a/84980
17-
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
1817
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
1918
temp_module_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_module_path'`
19+
custom_registry_url=http://localhost:4873
20+
original_npm_registry_url=`npm get registry`
21+
original_yarn_registry_url=`yarn config get registry`
2022

2123
function cleanup {
2224
echo 'Cleaning up.'
2325
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -9
2426
cd "$root_path"
2527
# TODO: fix "Device or resource busy" and remove ``|| $CI`
26-
rm -rf "$temp_cli_path" "$temp_app_path" "$temp_module_path" || $CI
28+
rm -rf "$temp_app_path" "$temp_module_path" || $CI
29+
npm set registry "$original_npm_registry_url"
30+
yarn config set registry "$original_yarn_registry_url"
2731
}
2832

2933
# Error messages are redirected to stderr
@@ -40,35 +44,6 @@ function handle_exit {
4044
exit
4145
}
4246

43-
function create_react_app {
44-
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
45-
}
46-
47-
function install_package {
48-
local pkg=$(basename $1)
49-
50-
# Clean target (for safety)
51-
rm -rf node_modules/$pkg/
52-
rm -rf node_modules/**/$pkg/
53-
54-
# Copy package into node_modules/ ignoring installed deps
55-
# rsync -a ${1%/} node_modules/ --exclude node_modules
56-
cp -R ${1%/} node_modules/
57-
rm -rf node_modules/$pkg/node_modules/
58-
59-
# Install `dependencies`
60-
cd node_modules/$pkg/
61-
if [ "$USE_YARN" = "yes" ]
62-
then
63-
yarn install --production
64-
else
65-
npm install --only=production
66-
fi
67-
# Remove our packages to ensure side-by-side versions are used (which we link)
68-
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
69-
cd ../..
70-
}
71-
7247
# Check for the existence of one or more files.
7348
function exists {
7449
for f in $*; do
@@ -89,94 +64,47 @@ set -x
8964
cd ..
9065
root_path=$PWD
9166

92-
# Clear cache to avoid issues with incorrect packages being used
93-
if hash yarnpkg 2>/dev/null
94-
then
95-
# AppVeyor uses an old version of yarn.
96-
# Once updated to 0.24.3 or above, the workaround can be removed
97-
# and replaced with `yarnpkg cache clean`
98-
# Issues:
99-
# https://github.com/yarnpkg/yarn/issues/2591
100-
# https://github.com/appveyor/ci/issues/1576
101-
# https://github.com/facebookincubator/create-react-app/pull/2400
102-
# When removing workaround, you may run into
103-
# https://github.com/facebookincubator/create-react-app/issues/2030
104-
case "$(uname -s)" in
105-
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
106-
*) yarn=yarnpkg;;
107-
esac
108-
$yarn cache clean
109-
fi
110-
11167
if hash npm 2>/dev/null
11268
then
113-
# npm 5 is too buggy right now
114-
if [ $(npm -v | head -c 1) -eq 5 ]; then
115-
npm i -g npm@^4.x
116-
fi;
69+
npm i -g npm@latest
11770
npm cache clean || npm cache verify
11871
fi
11972

120-
# Prevent bootstrap, we only want top-level dependencies
121-
cp package.json package.json.bak
122-
grep -v "postinstall" package.json > temp && mv temp package.json
123-
npm install
124-
mv package.json.bak package.json
125-
126-
if [ "$USE_YARN" = "yes" ]
127-
then
128-
# Install Yarn so that the test can use it to install packages.
129-
npm install -g yarn
130-
yarn cache clean
131-
fi
132-
133-
# We removed the postinstall, so do it manually
134-
node bootstrap.js
135-
136-
cd packages/react-error-overlay/
137-
npm run build:prod
138-
cd ../..
73+
# Bootstrap monorepo
74+
yarn
13975

14076
# ******************************************************************************
141-
# First, pack react-scripts and create-react-app so we can use them.
77+
# First, publish the monorepo.
14278
# ******************************************************************************
14379

144-
# Pack CLI
145-
cd "$root_path"/packages/create-react-app
146-
cli_path=$PWD/`npm pack`
147-
148-
# Go to react-scripts
149-
cd "$root_path"/packages/react-scripts
80+
# Start local registry
81+
tmp_registry_log=`mktemp`
82+
nohup npx verdaccio@2.7.2 &>$tmp_registry_log &
83+
# Wait for `verdaccio` to boot
84+
grep -q 'http address' <(tail -f $tmp_registry_log)
15085

151-
# Save package.json because we're going to touch it
152-
cp package.json package.json.orig
86+
# Set registry to local registry
87+
npm set registry "$custom_registry_url"
88+
yarn config set registry "$custom_registry_url"
15389

154-
# Replace own dependencies (those in the `packages` dir) with the local paths
155-
# of those packages.
156-
node "$root_path"/tasks/replace-own-deps.js
90+
# Login so we can publish packages
91+
npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes
15792

158-
# Finally, pack react-scripts
159-
scripts_path="$root_path"/packages/react-scripts/`npm pack`
160-
161-
# Restore package.json
162-
rm package.json
163-
mv package.json.orig package.json
93+
# Publish the monorepo
94+
git clean -df
95+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
16496

16597
# ******************************************************************************
166-
# Now that we have packed them, create a clean app folder and install them.
98+
# Now that we have published them, create a clean app folder and install them.
16799
# ******************************************************************************
168100

169-
# Install the CLI in a temporary location
170-
cd "$temp_cli_path"
171-
npm install "$cli_path"
172-
173101
# Install the app in a temporary location
174102
cd $temp_app_path
175-
create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
103+
npx create-react-app --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink
176104

177105
# Install the test module
178106
cd "$temp_module_path"
179-
npm install test-integrity@^2.0.1
107+
yarn add test-integrity@^2.0.1
180108

181109
# ******************************************************************************
182110
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -186,20 +114,14 @@ npm install test-integrity@^2.0.1
186114
# Enter the app directory
187115
cd "$temp_app_path/test-kitchensink"
188116

189-
# Link to our preset
190-
install_package "$root_path"/packages/babel-preset-react-app
191-
# Link to error overlay package because now it's a dependency
192-
# of react-dev-utils and not react-scripts
193-
install_package "$root_path"/packages/react-error-overlay
194-
195117
# Link to test module
196-
install_package "$temp_module_path/node_modules/test-integrity"
118+
npm link "$temp_module_path/node_modules/test-integrity"
197119

198120
# Test the build
199121
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
200122
NODE_PATH=src \
201123
PUBLIC_URL=http://www.example.org/spa/ \
202-
npm run build
124+
yarn build
203125

204126
# Check for expected output
205127
exists build/*.html
@@ -210,22 +132,15 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
210132
CI=true \
211133
NODE_PATH=src \
212134
NODE_ENV=test \
213-
npm test -- --no-cache --testPathPattern=src
135+
yarn test --no-cache --testPathPattern=src
214136

215137
# Test "development" environment
216138
tmp_server_log=`mktemp`
217139
PORT=3001 \
218140
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
219141
NODE_PATH=src \
220-
nohup npm start &>$tmp_server_log &
221-
while true
222-
do
223-
if grep -q 'You can now view' $tmp_server_log; then
224-
break
225-
else
226-
sleep 1
227-
fi
228-
done
142+
nohup yarn start &>$tmp_server_log &
143+
grep -q 'You can now view' <(tail -f $tmp_server_log)
229144
E2E_URL="http://localhost:3001" \
230145
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
231146
CI=true NODE_PATH=src \
@@ -247,28 +162,14 @@ E2E_FILE=./build/index.html \
247162
# Eject...
248163
echo yes | npm run eject
249164

250-
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
251-
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
252-
# this in the near future.
253-
if hash yarnpkg 2>/dev/null
254-
then
255-
yarn install --check-files
256-
fi
257-
258-
# ...but still link to the local packages
259-
install_package "$root_path"/packages/babel-preset-react-app
260-
install_package "$root_path"/packages/eslint-config-react-app
261-
install_package "$root_path"/packages/react-error-overlay
262-
install_package "$root_path"/packages/react-dev-utils
263-
264165
# Link to test module
265-
install_package "$temp_module_path/node_modules/test-integrity"
166+
npm link "$temp_module_path/node_modules/test-integrity"
266167

267168
# Test the build
268169
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
269170
NODE_PATH=src \
270171
PUBLIC_URL=http://www.example.org/spa/ \
271-
npm run build
172+
yarn build
272173

273174
# Check for expected output
274175
exists build/*.html
@@ -279,22 +180,15 @@ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
279180
CI=true \
280181
NODE_PATH=src \
281182
NODE_ENV=test \
282-
npm test -- --no-cache --testPathPattern=src
183+
yarn test --no-cache --testPathPattern=src
283184

284185
# Test "development" environment
285186
tmp_server_log=`mktemp`
286187
PORT=3002 \
287188
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
288189
NODE_PATH=src \
289-
nohup npm start &>$tmp_server_log &
290-
while true
291-
do
292-
if grep -q 'You can now view' $tmp_server_log; then
293-
break
294-
else
295-
sleep 1
296-
fi
297-
done
190+
nohup yarn start &>$tmp_server_log &
191+
grep -q 'You can now view' <(tail -f $tmp_server_log)
298192
E2E_URL="http://localhost:3002" \
299193
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
300194
CI=true NODE_PATH=src \
@@ -310,4 +204,4 @@ E2E_FILE=./build/index.html \
310204
node_modules/.bin/mocha --require babel-register --require babel-polyfill integration/*.test.js
311205

312206
# Cleanup
313-
cleanup
207+
cleanup

‎tasks/e2e-old-node.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,4 @@ err_output=`node "$root_path"/packages/create-react-app/index.js test-node-versi
5858
[[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1
5959

6060
# Cleanup
61-
cleanup
61+
cleanup

‎tasks/e2e-simple.sh

Lines changed: 69 additions & 155 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,21 @@
1212
# Start in tasks/ even if run from root directory
1313
cd "$(dirname "$0")"
1414

15-
# CLI and app temporary locations
15+
# App temporary location
1616
# http://unix.stackexchange.com/a/84980
17-
temp_cli_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_cli_path'`
1817
temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
18+
custom_registry_url=http://localhost:4873
19+
original_npm_registry_url=`npm get registry`
20+
original_yarn_registry_url=`yarn config get registry`
1921

2022
function cleanup {
2123
echo 'Cleaning up.'
2224
cd "$root_path"
2325
# Uncomment when snapshot testing is enabled by default:
2426
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
25-
rm -rf "$temp_cli_path" $temp_app_path
27+
rm -rf "$temp_app_path"
28+
npm set registry "$original_npm_registry_url"
29+
yarn config set registry "$original_yarn_registry_url"
2630
}
2731

2832
# Error messages are redirected to stderr
@@ -39,35 +43,6 @@ function handle_exit {
3943
exit
4044
}
4145

42-
function create_react_app {
43-
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
44-
}
45-
46-
function install_package {
47-
local pkg=$(basename $1)
48-
49-
# Clean target (for safety)
50-
rm -rf node_modules/$pkg/
51-
rm -rf node_modules/**/$pkg/
52-
53-
# Copy package into node_modules/ ignoring installed deps
54-
# rsync -a ${1%/} node_modules/ --exclude node_modules
55-
cp -R ${1%/} node_modules/
56-
rm -rf node_modules/$pkg/node_modules/
57-
58-
# Install `dependencies`
59-
cd node_modules/$pkg/
60-
if [ "$USE_YARN" = "yes" ]
61-
then
62-
yarn install --production
63-
else
64-
npm install --only=production
65-
fi
66-
# Remove our packages to ensure side-by-side versions are used (which we link)
67-
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
68-
cd ../..
69-
}
70-
7146
# Check for the existence of one or more files.
7247
function exists {
7348
for f in $*; do
@@ -88,65 +63,40 @@ set -x
8863
cd ..
8964
root_path=$PWD
9065

91-
# Clear cache to avoid issues with incorrect packages being used
92-
if hash yarnpkg 2>/dev/null
93-
then
94-
# AppVeyor uses an old version of yarn.
95-
# Once updated to 0.24.3 or above, the workaround can be removed
96-
# and replaced with `yarnpkg cache clean`
97-
# Issues:
98-
# https://github.com/yarnpkg/yarn/issues/2591
99-
# https://github.com/appveyor/ci/issues/1576
100-
# https://github.com/facebookincubator/create-react-app/pull/2400
101-
# When removing workaround, you may run into
102-
# https://github.com/facebookincubator/create-react-app/issues/2030
103-
case "$(uname -s)" in
104-
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
105-
*) yarn=yarnpkg;;
106-
esac
107-
$yarn cache clean
66+
# Make sure we don't introduce accidental references to PATENTS.
67+
EXPECTED='packages/react-error-overlay/fixtures/bundle.mjs
68+
packages/react-error-overlay/fixtures/bundle.mjs.map
69+
packages/react-error-overlay/fixtures/bundle_u.mjs
70+
packages/react-error-overlay/fixtures/bundle_u.mjs.map
71+
tasks/e2e-simple.sh'
72+
ACTUAL=$(git grep -l PATENTS)
73+
if [ "$EXPECTED" != "$ACTUAL" ]; then
74+
echo "PATENTS crept into some new files?"
75+
diff -u <(echo "$EXPECTED") <(echo "$ACTUAL") || true
76+
exit 1
10877
fi
10978

11079
if hash npm 2>/dev/null
11180
then
112-
# npm 5 is too buggy right now
113-
if [ $(npm -v | head -c 1) -eq 5 ]; then
114-
npm i -g npm@^4.x
115-
fi;
81+
npm i -g npm@latest
11682
npm cache clean || npm cache verify
11783
fi
11884

119-
# Prevent bootstrap, we only want top-level dependencies
120-
cp package.json package.json.bak
121-
grep -v "postinstall" package.json > temp && mv temp package.json
122-
npm install
123-
mv package.json.bak package.json
124-
125-
# We need to install create-react-app deps to test it
126-
cd "$root_path"/packages/create-react-app
127-
npm install
128-
cd "$root_path"
129-
130-
# If the node version is < 6, the script should just give an error.
131-
nodeVersion=`node --version | cut -d v -f2`
132-
nodeMajor=`echo $nodeVersion | cut -d. -f1`
133-
nodeMinor=`echo $nodeVersion | cut -d. -f2`
134-
if [[ nodeMajor -lt 6 ]]
135-
then
136-
cd $temp_app_path
137-
err_output=`node "$root_path"/packages/create-react-app/index.js test-node-version 2>&1 > /dev/null || echo ''`
138-
[[ $err_output =~ You\ are\ running\ Node ]] && exit 0 || exit 1
139-
fi
85+
# Bootstrap monorepo
86+
yarn
14087

141-
if [ "$USE_YARN" = "yes" ]
142-
then
143-
# Install Yarn so that the test can use it to install packages.
144-
npm install -g yarn
145-
yarn cache clean
146-
fi
88+
# Start local registry
89+
tmp_registry_log=`mktemp`
90+
nohup npx verdaccio@2.7.2 &>$tmp_registry_log &
91+
# Wait for `verdaccio` to boot
92+
grep -q 'http address' <(tail -f $tmp_registry_log)
14793

148-
# We removed the postinstall, so do it manually here
149-
node bootstrap.js
94+
# Set registry to local registry
95+
npm set registry "$custom_registry_url"
96+
yarn config set registry "$custom_registry_url"
97+
98+
# Login so we can publish packages
99+
npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r "$custom_registry_url" --quotes
150100

151101
# Lint own code
152102
./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/
@@ -156,8 +106,16 @@ node bootstrap.js
156106
./node_modules/.bin/eslint --max-warnings 0 packages/react-scripts/
157107
cd packages/react-error-overlay/
158108
./node_modules/.bin/eslint --max-warnings 0 src/
159-
npm test
160-
npm run build:prod
109+
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+
116+
cd ../..
117+
cd packages/react-dev-utils/
118+
yarn test
161119
cd ../..
162120

163121
# ******************************************************************************
@@ -166,7 +124,7 @@ cd ../..
166124
# ******************************************************************************
167125

168126
# Test local build command
169-
npm run build
127+
yarn build
170128
# Check for expected output
171129
exists build/*.html
172130
exists build/static/js/*.js
@@ -175,55 +133,25 @@ exists build/static/media/*.svg
175133
exists build/favicon.ico
176134

177135
# Run tests with CI flag
178-
CI=true npm test
136+
CI=true yarn test
179137
# Uncomment when snapshot testing is enabled by default:
180138
# exists template/src/__snapshots__/App.test.js.snap
181139

182140
# Test local start command
183-
npm start -- --smoke-test
184-
185-
# ******************************************************************************
186-
# Next, pack react-scripts and create-react-app so we can verify they work.
187-
# ******************************************************************************
188-
189-
# Pack CLI
190-
cd "$root_path"/packages/create-react-app
191-
cli_path=$PWD/`npm pack`
192-
193-
# Go to react-scripts
194-
cd "$root_path"/packages/react-scripts
141+
yarn start --smoke-test
195142

196-
# Save package.json because we're going to touch it
197-
cp package.json package.json.orig
198-
199-
# Replace own dependencies (those in the `packages` dir) with the local paths
200-
# of those packages.
201-
node "$root_path"/tasks/replace-own-deps.js
202-
203-
# Finally, pack react-scripts
204-
scripts_path="$root_path"/packages/react-scripts/`npm pack`
205-
206-
# Restore package.json
207-
rm package.json
208-
mv package.json.orig package.json
143+
git clean -df
144+
./tasks/publish.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
209145

210146
# ******************************************************************************
211-
# Now that we have packed them, create a clean app folder and install them.
147+
# Install react-scripts prerelease via create-react-app prerelease.
212148
# ******************************************************************************
213149

214-
# Install the CLI in a temporary location
215-
cd "$temp_cli_path"
216-
217-
# Initialize package.json before installing the CLI because npm will not install
218-
# the CLI properly in the temporary location if it is missing.
219-
npm init --yes
220-
221-
# Now we can install the CLI from the local package.
222-
npm install "$cli_path"
223-
224150
# Install the app in a temporary location
225151
cd $temp_app_path
226-
create_react_app --scripts-version="$scripts_path" test-app
152+
npx create-react-app test-app --scripts-version=react-scripts-ts
153+
154+
# TODO: verify we installed prerelease
227155

228156
# ******************************************************************************
229157
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -240,36 +168,36 @@ function verify_env_url {
240168
# Test relative path build
241169
awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json
242170

243-
npm run build
171+
yarn build
244172
# Disabled until this can be tested
245173
# grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1
246174
grep -F -R --exclude=*.map "\"./static/" build/ -q; test $? -eq 0 || exit 1
247175
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
248176

249-
PUBLIC_URL="/anabsolute" npm run build
177+
PUBLIC_URL="/anabsolute" yarn build
250178
grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1
251179
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
252180

253181
# Test absolute path build
254182
sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json
255183

256-
npm run build
184+
yarn build
257185
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
258186
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
259187

260-
PUBLIC_URL="https://www.example.net/overridetest" npm run build
188+
PUBLIC_URL="https://www.example.net/overridetest" yarn build
261189
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
262190
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
263191
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1
264192

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

268-
npm run build
196+
yarn build
269197
grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1
270198
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
271199

272-
PUBLIC_URL="https://www.example.net/overridetest" npm run build
200+
PUBLIC_URL="https://www.example.net/overridetest" yarn build
273201
grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1
274202
grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1
275203
grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1
@@ -283,14 +211,14 @@ function verify_module_scope {
283211
# Create stub json file
284212
echo "{}" >> sample.json
285213

286-
# Save App.js, we're going to modify it
214+
# Save App.tsx, we're going to modify it
287215
cp src/App.tsx src/App.tsx.bak
288216

289217
# Add an out of scope import
290-
echo "import sampleJson from '../sample.json'" | cat - src/App.tsx > src/App.tsx.temp && mv src/App.tsx.temp src/App.tsx
218+
echo "import sampleJson from '../sample'" | cat - src/App.tsx > src/App.tsx.temp && mv src/App.tsx.temp src/App.tsx
291219

292220
# Make sure the build fails
293-
npm run build; test $? -eq 1 || exit 1
221+
yarn build; test $? -eq 1 || exit 1
294222
# TODO: check for error message
295223

296224
# Restore App.tsx
@@ -302,22 +230,21 @@ function verify_module_scope {
302230
cd test-app
303231

304232
# Test the build
305-
npm run build
233+
yarn build
306234
# Check for expected output
307-
pwd
308235
exists build/*.html
309236
exists build/static/js/*.js
310237
exists build/static/css/*.css
311238
exists build/static/media/*.svg
312239
exists build/favicon.ico
313240

314241
# Run tests with CI flag
315-
CI=true npm test
242+
CI=true yarn test
316243
# Uncomment when snapshot testing is enabled by default:
317-
# exists src/__snapshots__/App.test.tsx.snap
244+
# exists src/__snapshots__/App.test.js.snap
318245

319246
# Test the server
320-
npm start -- --smoke-test
247+
yarn start --smoke-test
321248

322249
# Test environment handling
323250
verify_env_url
@@ -332,21 +259,8 @@ verify_module_scope
332259
# Eject...
333260
echo yes | npm run eject
334261

335-
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
336-
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
337-
# this in the near future.
338-
if hash yarnpkg 2>/dev/null
339-
then
340-
yarnpkg install --check-files
341-
fi
342-
343-
# ...but still link to the local packages
344-
install_package "$root_path"/packages/babel-preset-react-app
345-
install_package "$root_path"/packages/eslint-config-react-app
346-
install_package "$root_path"/packages/react-dev-utils
347-
348262
# Test the build
349-
npm run build
263+
yarn build
350264
# Check for expected output
351265
exists build/*.html
352266
exists build/static/js/*.js
@@ -355,15 +269,15 @@ exists build/static/media/*.svg
355269
exists build/favicon.ico
356270

357271
# Run tests, overring the watch option to disable it.
358-
# `CI=true npm test` won't work here because `npm test` becomes just `jest`.
272+
# `CI=true yarn test` won't work here because `yarn test` becomes just `jest`.
359273
# We should either teach Jest to respect CI env variable, or make
360274
# `scripts/test.js` survive ejection (right now it doesn't).
361-
npm test -- --watch=no
275+
yarn test --watch=no
362276
# Uncomment when snapshot testing is enabled by default:
363277
# exists src/__snapshots__/App.test.js.snap
364278

365279
# Test the server
366-
npm start -- --smoke-test
280+
yarn start --smoke-test
367281

368282
# Test environment handling
369283
verify_env_url
@@ -372,4 +286,4 @@ verify_env_url
372286
verify_module_scope
373287

374288
# Cleanup
375-
cleanup
289+
cleanup

‎tasks/local-test.sh

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ function print_help {
1111
echo " --node-version <version> the node version to use while testing [6]"
1212
echo " --git-branch <branch> the git branch to checkout for testing [the current one]"
1313
echo " --test-suite <suite> which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']"
14-
echo " --yarn if present, use yarn as the package manager"
1514
echo " --interactive gain a bash shell after the test run"
1615
echo " --help print this message and exit"
1716
echo ""
@@ -22,7 +21,6 @@ cd $(dirname $0)
2221
node_version=6
2322
current_git_branch=`git rev-parse --abbrev-ref HEAD`
2423
git_branch=${current_git_branch}
25-
use_yarn=no
2624
test_suite=all
2725
interactive=false
2826

@@ -36,9 +34,6 @@ while [ "$1" != "" ]; do
3634
shift
3735
git_branch=$1
3836
;;
39-
"--yarn")
40-
use_yarn=yes
41-
;;
4237
"--test-suite")
4338
shift
4439
test_suite=$1
@@ -107,11 +102,10 @@ CMD
107102
docker run \
108103
--env CI=true \
109104
--env NPM_CONFIG_QUIET=true \
110-
--env USE_YARN=${use_yarn} \
111105
--tty \
112106
--user node \
113107
--volume ${PWD}/..:/var/create-react-app \
114108
--workdir /home/node \
115109
$([[ ${interactive} == 'true' ]] && echo '--interactive') \
116110
node:${node_version} \
117-
bash -c "${command}"
111+
bash -c "${command}"

0 commit comments

Comments
 (0)
This repository has been archived.