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

Commit 97d5561

Browse files
authored
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

Diff for: .travis.yml

+13-13
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

Diff for: package.json

+12-9
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": [

Diff for: packages/react-dev-utils/package.json

+1-1
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"

Diff for: packages/react-error-overlay/package.json

+1-1
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",

Diff for: packages/react-scripts/package.json

+1-1
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",

Diff for: tasks/e2e-installs.sh

+53-69
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 [email protected] &>$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 [email protected] -u user -p password -e [email protected] -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

0 commit comments

Comments
 (0)