Skip to content

Commit 91642f4

Browse files
committed
Run e2e-simple in a realistic scenario
1 parent 99c14e7 commit 91642f4

File tree

1 file changed

+24
-67
lines changed

1 file changed

+24
-67
lines changed

tasks/e2e-simple.sh

+24-67
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,15 @@
1212
# Start in tasks/ even if run from root directory
1313
cd "$(dirname "$0")"
1414

15-
# CLI and app temporary locations
15+
# App temporary location
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'`
1918

2019
function cleanup {
2120
echo 'Cleaning up.'
2221
cd "$root_path"
2322
# Uncomment when snapshot testing is enabled by default:
2423
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
25-
rm -rf "$temp_cli_path" $temp_app_path
2624
}
2725

2826
# Error messages are redirected to stderr
@@ -39,30 +37,6 @@ function handle_exit {
3937
exit
4038
}
4139

42-
function create_react_app {
43-
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
44-
}
45-
46-
function install_package {
47-
local pkg=$(basename $1)
48-
49-
# Clean target (for safety)
50-
rm -rf node_modules/$pkg/
51-
rm -rf node_modules/**/$pkg/
52-
53-
# Copy package into node_modules/ ignoring installed deps
54-
# rsync -a ${1%/} node_modules/ --exclude node_modules
55-
cp -R ${1%/} node_modules/
56-
rm -rf node_modules/$pkg/node_modules/
57-
58-
# Install `dependencies`
59-
cd node_modules/$pkg/
60-
yarn --production
61-
# Remove our packages to ensure side-by-side versions are used (which we link)
62-
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
63-
cd ../..
64-
}
65-
6640
# Check for the existence of one or more files.
6741
function exists {
6842
for f in $*; do
@@ -102,6 +76,21 @@ grep -v "postinstall" package.json > temp && mv temp package.json
10276
yarn
10377
mv package.json.bak package.json
10478

79+
yarn global add verdaccio
80+
# Start local registry
81+
tmp_registry_log=`mktemp`
82+
nohup verdaccio &>$tmp_registry_log &
83+
# Wait for `verdaccio` to boot
84+
grep -q 'http address' <(tail -f $tmp_registry_log)
85+
86+
# Set registry to local registry
87+
npm set registry http://localhost:4873
88+
yarn config set registry http://localhost:4873
89+
90+
# Login so we can publish packages
91+
yarn global add [email protected]
92+
npm-cli-login -u user -p password -e [email protected] -r http://localhost:4873 --quotes
93+
10594
# We removed the postinstall, so do it manually here
10695
node bootstrap.js
10796

@@ -142,48 +131,21 @@ CI=true yarn test
142131
# Test local start command
143132
yarn start --smoke-test
144133

145-
# ******************************************************************************
146-
# Next, pack react-scripts and create-react-app so we can verify they work.
147-
# ******************************************************************************
148-
149-
# Pack CLI
150-
cd "$root_path"/packages/create-react-app
151-
cli_path=$PWD/`npm pack`
152-
153-
# Go to react-scripts
154-
cd "$root_path"/packages/react-scripts
155-
156-
# Save package.json because we're going to touch it
157-
cp package.json package.json.orig
158-
159-
# Replace own dependencies (those in the `packages` dir) with the local paths
160-
# of those packages.
161-
node "$root_path"/tasks/replace-own-deps.js
162-
163-
# Finally, pack react-scripts
164-
scripts_path="$root_path"/packages/react-scripts/`npm pack`
165-
166-
# Restore package.json
167-
rm package.json
168-
mv package.json.orig package.json
134+
git clean -f
135+
./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
169136

170137
# ******************************************************************************
171-
# Now that we have packed them, create a clean app folder and install them.
138+
# Install react-scripts prerelease via create-react-app prerelease.
172139
# ******************************************************************************
173140

174-
# Install the CLI in a temporary location
175-
cd "$temp_cli_path"
176-
177-
# Initialize package.json before installing the CLI because npm will not install
178-
# the CLI properly in the temporary location if it is missing.
179-
yarn init --yes
180-
181-
# Now we can install the CLI from the local package.
182-
yarn add "$cli_path"
141+
# Install latest CLI
142+
yarn global add create-react-app
183143

184144
# Install the app in a temporary location
185145
cd $temp_app_path
186-
create_react_app --scripts-version="$scripts_path" test-app
146+
create-react-app test-app
147+
148+
# TODO: verify we installed prerelease
187149

188150
# ******************************************************************************
189151
# Now that we used create-react-app to create an app depending on react-scripts,
@@ -291,11 +253,6 @@ verify_module_scope
291253
# Eject...
292254
echo yes | npm run eject
293255

294-
# ...but still link to the local packages
295-
install_package "$root_path"/packages/babel-preset-react-app
296-
install_package "$root_path"/packages/eslint-config-react-app
297-
install_package "$root_path"/packages/react-dev-utils
298-
299256
# Test the build
300257
yarn build
301258
# Check for expected output

0 commit comments

Comments
 (0)