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

Clean up e2e script #867

Merged
merged 2 commits into from
Oct 7, 2016
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
8 changes: 8 additions & 0 deletions tasks/cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@ $root_path/node_modules/.bin/lerna bootstrap

cd packages/react-scripts

# Save package.json because we're going to touch it
cp package.json package.json.orig

# Like bundle-deps, this script modifies packages/react-scripts/package.json,
# copying own dependencies (those in the `packages` dir) to bundledDependencies
node $root_path/tasks/bundle-own-deps.js

# Finally, pack react-scripts
scripts_path=$root_path/packages/react-scripts/`npm pack`

# Restore package.json
rm package.json
mv package.json.orig package.json


# ******************************************************************************
# Now that we have packed them, call the global CLI.
# ******************************************************************************
Expand Down
52 changes: 16 additions & 36 deletions tasks/e2e.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ function cleanup {
cd $root_path
# Uncomment when snapshot testing is enabled by default:
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
rm -rf $temp_cli_path $temp_app_path $clean_path
rm -rf $temp_cli_path $temp_app_path
}

# Error messages are redirected to stderr
Expand Down Expand Up @@ -53,16 +53,16 @@ set -x
cd ..
root_path=$PWD

# Lint
npm install

# Lint own code
./node_modules/.bin/eslint --ignore-path .gitignore ./

# ******************************************************************************
# First, test the create-react-app development environment.
# This does not affect our users but makes sure we can develop it.
# ******************************************************************************

npm install

# Test local build command
npm run build
# Check for expected output
Expand All @@ -84,45 +84,19 @@ npm start -- --smoke-test
# Next, pack react-scripts and create-react-app so we can verify they work.
# ******************************************************************************

# Pack CLI (it doesn't need cleaning)
# Pack CLI
cd $root_path/packages/create-react-app
cli_path=$PWD/`npm pack`

# Packing react-scripts takes more work because we want to clean it up first.
# Create a temporary clean folder that contains production only code.
# Do not overwrite any files in the current folder.
clean_path=`mktemp -d 2>/dev/null || mktemp -d -t 'clean_path'`

# Copy some of the react-scripts project files to the temporary folder.
# Exclude folders that definitely won’t be part of the package from processing.
# We will strip the dev-only code there, `npm pack`, and copy the package back.
cd $root_path
rsync -av --exclude='.git' --exclude=$clean_path\
--exclude='node_modules' --exclude='build'\
'./' $clean_path >/dev/null

# Open the clean folder
cd $clean_path/packages/react-scripts

# Now remove all the code relevant to development of Create React App.
files="$(find -L . -name "*.js" -type f)"
for file in $files; do
sed -i.bak '/\/\/ @remove-on-publish-begin/,/\/\/ @remove-on-publish-end/d' $file
rm $file.bak
done

# Install all our packages
cd $clean_path
$root_path/node_modules/.bin/lerna bootstrap

cd $clean_path/packages/react-scripts
# Go to react-scripts
cd $root_path/packages/react-scripts

# Like bundle-deps, this script modifies packages/react-scripts/package.json,
# copying own dependencies (those in the `packages` dir) to bundledDependencies
node $clean_path/tasks/bundle-own-deps.js
node $root_path/tasks/bundle-own-deps.js

# Finally, pack react-scripts
scripts_path=$clean_path/packages/react-scripts/`npm pack`
scripts_path=$root_path/packages/react-scripts/`npm pack`

# ******************************************************************************
# Now that we have packed them, create a clean app folder and install them.
Expand Down Expand Up @@ -168,9 +142,15 @@ npm start -- --smoke-test
# Finally, let's check that everything still works after ejecting.
# ******************************************************************************

# Eject
# Eject...
echo yes | npm run eject

# ...but still link to the local packages
npm link $root_path/packages/babel-preset-react-app
npm link $root_path/packages/eslint-config-react-app
npm link $root_path/packages/react-dev-utils
npm link $root_path/packages/react-scripts

# Test the build
npm run build
# Check for expected output
Expand Down