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

Fix travis build #302

Merged
merged 2 commits into from
Apr 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
---
# Use Ubuntu Precise instead of new default Trusty which cause build fail
# with pre installed yarn v0.17.8
# https://github.com/facebookincubator/create-react-app/issues/3054
# TODO: remove after Trusty environment is updated with a lastet version of yarn
dist: precise
dist: trusty
language: node_js
node_js:
- 6
- 8
- 9
cache:
directories:
- node_modules
Expand All @@ -16,13 +12,17 @@ cache:
install: true
script:
- 'if [ $TEST_SUITE = "simple" ]; then tasks/e2e-simple.sh; fi'
- 'if [ $TEST_SUITE = "kitchensink" ]; then tasks/e2e-kitchensink.sh; fi'
- 'if [ $TEST_SUITE = "old-node" ]; then tasks/e2e-old-node.sh; fi'
# Disabled for the moment, since it requires additional work to be done.
# - 'if [ $TEST_SUITE = "installs" ]; then tasks/e2e-installs.sh; fi'
env:
global:
- USE_YARN=no
matrix:
- TEST_SUITE=simple
- TEST_SUITE=install
# There's a weird Yarn/Lerna bug related to prerelease versions.
# TODO: reenable after we ship 1.0.
# - node_js: 6
# env: USE_YARN=yes TEST_SUITE=simple
- TEST_SUITE=kitchensink
# See comment above
# - TEST_SUITE=installs
matrix:
include:
- node_js: 6
env: TEST_SUITE=kitchensink
21 changes: 12 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
{
"private": true,
"workspaces": [
"packages/*"
],
"scripts": {
"build": "node packages/react-scripts/scripts/build.js",
"build": "cd packages/react-scripts && node scripts/build.js",
"changelog": "lerna-changelog",
"create-react-app": "tasks/cra.sh",
"create-react-app": "node tasks/cra.js",
"e2e": "tasks/e2e-simple.sh",
"e2e:docker": "tasks/local-test.sh",
"postinstall": "node bootstrap.js && cd packages/react-error-overlay/ && npm run build:prod",
"publish": "tasks/release.sh",
"start": "node packages/react-scripts/scripts/start.js",
"test": "node packages/react-scripts/scripts/test.js --env=jsdom",
"format": "prettier --trailing-comma es5 --single-quote --write \"packages/*/*.js\" \"packages/*/!(node_modules)/**/*.js\"",
"postinstall": "cd packages/react-error-overlay/ && yarn build:prod",
"publish": "tasks/publish.sh",
"start": "cd packages/react-scripts && node scripts/start.js",
"test": "cd packages/react-scripts && node scripts/test.js --env=jsdom",
"format": "prettier --trailing-comma es5 --single-quote --write 'packages/*/*.js' 'packages/*/!(node_modules)/**/*.js'",
"precommit": "lint-staged"
},
"devDependencies": {
Expand All @@ -20,10 +23,10 @@
"@types/react-dom": "^15.5.0",
"eslint": "^4.4.1",
"husky": "^0.13.2",
"lerna": "^2.0.0",
"lerna": "2.6.0",
"lerna-changelog": "^0.6.0",
"lint-staged": "^3.3.1",
"prettier": "^1.5.2"
"prettier": "1.6.1"
},
"lint-staged": {
"*.js": [
Expand Down
2 changes: 1 addition & 1 deletion packages/react-dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"text-table": "0.2.0"
},
"devDependencies": {
"jest": "20.0.4"
"jest": "22.4.2"
},
"scripts": {
"test": "jest"
Expand Down
2 changes: 1 addition & 1 deletion packages/react-error-overlay/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"eslint-plugin-react": "7.1.0",
"flow-bin": "^0.63.1",
"html-entities": "1.2.1",
"jest": "20.0.4",
"jest": "22.4.2",
"jest-fetch-mock": "1.2.1",
"object-assign": "4.1.1",
"promise": "8.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/react-scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"fork-ts-checker-webpack-plugin": "^0.2.8",
"fs-extra": "3.0.1",
"html-webpack-plugin": "2.29.0",
"jest": "22.1.4",
"jest": "22.4.2",
"object-assign": "4.1.1",
"postcss-flexbugs-fixes": "3.2.0",
"postcss-loader": "2.0.8",
Expand Down
122 changes: 53 additions & 69 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ cd "$(dirname "$0")"

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

function cleanup {
echo 'Cleaning up.'
cd "$root_path"
rm -rf "$temp_cli_path" "$temp_app_path"
rm -rf "$temp_app_path"
npm set registry "$original_npm_registry_url"
yarn config set registry "$original_yarn_registry_url"
}

# Error messages are redirected to stderr
Expand Down Expand Up @@ -55,10 +59,6 @@ function checkDependencies {
fi
}

function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}

# Exit the script with a helpful error message when any error is encountered
trap 'set +x; handle_error $LINENO $BASH_COMMAND' ERR

Expand All @@ -72,98 +72,82 @@ set -x
cd ..
root_path=$PWD

# Clear cache to avoid issues with incorrect packages being used
if hash yarnpkg 2>/dev/null
then
# AppVeyor uses an old version of yarn.
# Once updated to 0.24.3 or above, the workaround can be removed
# and replaced with `yarnpkg cache clean`
# Issues:
# https://github.com/yarnpkg/yarn/issues/2591
# https://github.com/appveyor/ci/issues/1576
# https://github.com/facebookincubator/create-react-app/pull/2400
# When removing workaround, you may run into
# https://github.com/facebookincubator/create-react-app/issues/2030
case "$(uname -s)" in
*CYGWIN*|MSYS*|MINGW*) yarn=yarn.cmd;;
*) yarn=yarnpkg;;
esac
$yarn cache clean
fi

if hash npm 2>/dev/null
then
# npm 5 is too buggy right now
if [ $(npm -v | head -c 1) -eq 5 ]; then
npm i -g npm@^4.x
fi;
npm i -g npm@latest
npm cache clean || npm cache verify
fi

# Prevent bootstrap, we only want top-level dependencies
cp package.json package.json.bak
grep -v "postinstall" package.json > temp && mv temp package.json
npm install
mv package.json.bak package.json
# Bootstrap monorepo
yarn

if [ "$USE_YARN" = "yes" ]
then
# Install Yarn so that the test can use it to install packages.
npm install -g yarn
yarn cache clean
fi
# ******************************************************************************
# First, publish the monorepo.
# ******************************************************************************

# Start local registry
tmp_registry_log=`mktemp`
nohup npx [email protected] &>$tmp_registry_log &
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)

# We removed the postinstall, so do it manually
node bootstrap.js
# Set registry to local registry
npm set registry "$custom_registry_url"
yarn config set registry "$custom_registry_url"

cd packages/react-error-overlay/
npm run build:prod
cd ../..
# Login so we can publish packages
npx [email protected] -u user -p password -e [email protected] -r "$custom_registry_url" --quotes

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

# ******************************************************************************
# First, pack and install create-react-app.
# Test --scripts-version with a version number
# ******************************************************************************

# Pack CLI
cd "$root_path"/packages/create-react-app
cli_path=$PWD/`npm pack`
cd "$temp_app_path"
npx create-react-app --scripts-version=1.0.17 test-app-version-number
Copy link
Owner

Choose a reason for hiding this comment

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

I think --scripts-version here will install react-scripts right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This test suite is disabled for now.

cd test-app-version-number

# Install the CLI in a temporary location
cd "$temp_cli_path"
npm install "$cli_path"
# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a version number
# Test --use-npm flag
# ******************************************************************************

cd "$temp_app_path"
create_react_app --scripts-version=0.4.0 test-app-version-number
cd test-app-version-number
npx create-react-app --use-npm --scripts-version=1.0.17 test-use-npm-flag
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above

cd test-use-npm-flag

# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
[ ! -e "yarn.lock" ] && echo "yarn.lock correctly does not exist"
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
Copy link
Owner

Choose a reason for hiding this comment

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

Our version is different now

checkDependencies

# ******************************************************************************
# Test --scripts-version with a tarball url
# ******************************************************************************

cd "$temp_app_path"
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
npx create-react-app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-1.0.17.tgz test-app-tarball-url
Copy link
Owner

Choose a reason for hiding this comment

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

Same as above

cd test-app-tarball-url

# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
grep '"version": "1.0.17"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a custom fork of react-scripts
# ******************************************************************************

cd "$temp_app_path"
create_react_app --scripts-version=react-scripts-fork test-app-fork
npx create-react-app --scripts-version=react-scripts-fork test-app-fork
cd test-app-fork

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

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

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

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

# Check corresponding scripts version is installed.
Expand All @@ -216,22 +200,22 @@ cd "$temp_app_path"
mkdir test-app-nested-paths-t1
cd test-app-nested-paths-t1
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
create_react_app test-app-nested-paths-t1/aa/bb/cc/dd
npx create-react-app test-app-nested-paths-t1/aa/bb/cc/dd
cd test-app-nested-paths-t1/aa/bb/cc/dd
npm start -- --smoke-test
yarn start --smoke-test

# Testing a path that does not exist
cd "$temp_app_path"
create_react_app test-app-nested-paths-t2/aa/bb/cc/dd
npx create-react-app test-app-nested-paths-t2/aa/bb/cc/dd
cd test-app-nested-paths-t2/aa/bb/cc/dd
npm start -- --smoke-test
yarn start --smoke-test

# Testing a path that is half exists
cd "$temp_app_path"
mkdir -p test-app-nested-paths-t3/aa
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
npx create-react-app test-app-nested-paths-t3/aa/bb/cc/dd
cd test-app-nested-paths-t3/aa/bb/cc/dd
npm start -- --smoke-test
yarn start --smoke-test

# Cleanup
cleanup
cleanup
Loading