Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added test to check for accidental extraneous dependencies #1825

Merged
merged 4 commits into from
Mar 23, 2017
Merged
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
28 changes: 25 additions & 3 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,26 @@ function exists {
done
}

# Check for accidental dependencies in package.json
function checkDependencies {
if ! awk '/"dependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
echo "Dependencies are correct"
else
echo "There are extraneous dependencies in package.json"
exit 1
fi


if ! awk '/"devDependencies": {/{y=1;next}/},/{y=0; next}y' package.json | \
grep -v -q -E '^\s*"react(-dom|-scripts)?"'; then
echo "Dev Dependencies are correct"
else
echo "There are extraneous devDependencies in package.json"
exit 1
fi
}

function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js $*
}
Expand Down Expand Up @@ -95,6 +115,7 @@ cd test-app-version-number
# Check corresponding scripts version is installed.
exists node_modules/react-scripts
grep '"version": "0.4.0"' node_modules/react-scripts/package.json
checkDependencies

# ******************************************************************************
# Test --scripts-version with a tarball url
Expand All @@ -107,6 +128,7 @@ 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
checkDependencies

# ******************************************************************************
# Test --scripts-version with a custom fork of react-scripts
Expand Down Expand Up @@ -161,7 +183,7 @@ exists node_modules/@enoah_netzach/react-scripts
# Test nested folder path as the project name
# ******************************************************************************

#Testing a path that exists
# Testing a path that exists
cd "$temp_app_path"
mkdir test-app-nested-paths-t1
cd test-app-nested-paths-t1
Expand All @@ -170,13 +192,13 @@ 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

#Testing a path that does not exist
# Testing a path that does not exist
cd "$temp_app_path"
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

#Testing a path that is half exists
# 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
Expand Down