Files
create-react-app/tasks/local-test.sh
bradfordlemley b43ad04b88 Add support for yarn and lerna monorepos. (#3741)
* Support for multiple source paths via package.json srcPaths entry.

Initial support for yarn workspace.

Support lerna workspace, fix for when to use template files.

Remove support for specifying srcPaths in package.json.

Re-enable transpilation caching.

* Clean up, use file matching (similar to original) in webpack configs instead of matching function.

* Remove package lock files.

* Fix for eject.
Note: monorepos won't work after eject.
Can be fixed easily with JEST 22.0.?+ which has file pattern matches against realpaths.

* Filter tests to run only tests in monorepo components included by the app.
(Not sure this is desireable, might be cool to be able to easily run all tests in monorepo from one app.)

* Fix conditions for when to use template.

* Fix eject.

* Remove code that is not needed w/ Jest 22.

* Include all cra-comp tests in monorepo instead of trying to include only tests that are dependencies of app.
(tests can be easily filtered via jest cli if desired, e.g. 'npm test -- myapp comp1')

* Pin find-pkg version.

* Hopefully fix jest test file matching on windows by removing first slash.

* E2E tests for monorepo.

* Run monorepo tests in CI.

* Fix and test post-eject build.

* Fix e2e test.

* Fix test suite names in appveyor.

* Include individual package dirs as srcPaths instead of top-level monorepo root.
Fixes build/start after eject.

* Fix running tests after eject.

* Clean up test workspace, add some verifcations.

* Cleanup.

* Try to fix hang when running test on appveyor.

* Don't write babel or lint config to package.json when ejecting.

* Incorporate review comments.
* Simply monorepo pkg finder
* Only include monorepo pkgs if app itself is included in monorepo
* Check for specific tests in e2e

* Fixes for windows.

* Fix for kitchensink mocha tests compiling.

* Add lerna monorepo test.

* Fix lerna bootstrap on windows.

* Incorporate more review comments:
* remove support for lerna w/o yarn workspace
* add react and react-dom as devDeps to comp1 and comp2

* Add monorepo info to user guide.
2018-02-01 20:58:18 +00:00

115 lines
2.7 KiB
Bash
Executable File

#!/usr/bin/env bash
# Copyright (c) 2015-present, Facebook, Inc.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
function print_help {
echo "Usage: ${0} [OPTIONS]"
echo ""
echo "OPTIONS:"
echo " --node-version <version> the node version to use while testing [6]"
echo " --git-branch <branch> the git branch to checkout for testing [the current one]"
echo " --test-suite <suite> which test suite to use ('simple', installs', 'kitchensink', 'all') ['all']"
echo " --interactive gain a bash shell after the test run"
echo " --help print this message and exit"
echo ""
}
cd $(dirname $0)
node_version=6
current_git_branch=`git rev-parse --abbrev-ref HEAD`
git_branch=${current_git_branch}
test_suite=all
interactive=false
while [ "$1" != "" ]; do
case $1 in
"--node-version")
shift
node_version=$1
;;
"--git-branch")
shift
git_branch=$1
;;
"--test-suite")
shift
test_suite=$1
;;
"--interactive")
interactive=true
;;
"--help")
print_help
exit 0
;;
esac
shift
done
test_command="./tasks/e2e-simple.sh && ./tasks/e2e-kitchensink.sh && ./tasks/e2e-installs.sh && ./tasks/e2e-monorepos.sh"
case ${test_suite} in
"all")
;;
"simple")
test_command="./tasks/e2e-simple.sh"
;;
"kitchensink")
test_command="./tasks/e2e-kitchensink.sh"
;;
"installs")
test_command="./tasks/e2e-installs.sh"
;;
"monorepos")
test_command="./tasks/e2e-monorepos.sh"
;;
*)
;;
esac
read -r -d '' apply_changes <<- CMD
cd /var/create-react-app
git config --global user.name "Create React App"
git config --global user.email "cra@email.com"
git stash save -u
git stash show -p > patch
git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 stash^3 >> patch
git stash pop
cd -
mv /var/create-react-app/patch .
git apply patch
rm patch
CMD
if [ ${git_branch} != ${current_git_branch} ]; then
apply_changes=''
fi
read -r -d '' command <<- CMD
echo "prefix=~/.npm" > ~/.npmrc
mkdir ~/.npm
export PATH=\$PATH:~/.npm/bin
set -x
git clone /var/create-react-app create-react-app --branch ${git_branch}
cd create-react-app
${apply_changes}
node --version
npm --version
set +x
${test_command} && echo -e "\n\e[1;32m✔ Job passed\e[0m" || echo -e "\n\e[1;31m✘ Job failes\e[0m"
$([[ ${interactive} == 'true' ]] && echo 'bash')
CMD
docker run \
--env CI=true \
--env NPM_CONFIG_QUIET=true \
--tty \
--user node \
--volume ${PWD}/..:/var/create-react-app \
--workdir /home/node \
$([[ ${interactive} == 'true' ]] && echo '--interactive') \
node:${node_version} \
bash -c "${command}"