Unverified Commit 75d71e15 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub
Browse files

Use private registry (#3744)

* Run e2e-simple in a realistic scenario

* Use npx for everything

* oops
parent 99c14e71
3 merge requests!12191Lim.Pisey.168:/Identified - We are currently investigating reports of missing build logs. The issue has been identified and a resolution is in progress. We will provide a further update when available.Mar 21, 09:02 UTC,!12853brikk,!5717Automatically extract project file structure from build bundle file
Showing with 27 additions and 68 deletions
+27 -68
...@@ -12,9 +12,8 @@ ...@@ -12,9 +12,8 @@
# Start in tasks/ even if run from root directory # Start in tasks/ even if run from root directory
cd "$(dirname "$0")" cd "$(dirname "$0")"
# CLI and app temporary locations # App temporary location
# http://unix.stackexchange.com/a/84980 # 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'` temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
function cleanup { function cleanup {
...@@ -22,7 +21,7 @@ function cleanup { ...@@ -22,7 +21,7 @@ function cleanup {
cd "$root_path" cd "$root_path"
# Uncomment when snapshot testing is enabled by default: # Uncomment when snapshot testing is enabled by default:
# rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap # rm ./packages/react-scripts/template/src/__snapshots__/App.test.js.snap
rm -rf "$temp_cli_path" $temp_app_path rm -rf "$temp_app_path"
} }
# Error messages are redirected to stderr # Error messages are redirected to stderr
...@@ -39,30 +38,6 @@ function handle_exit { ...@@ -39,30 +38,6 @@ function handle_exit {
exit exit
} }
function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@"
}
function install_package {
local pkg=$(basename $1)
# Clean target (for safety)
rm -rf node_modules/$pkg/
rm -rf node_modules/**/$pkg/
# Copy package into node_modules/ ignoring installed deps
# rsync -a ${1%/} node_modules/ --exclude node_modules
cp -R ${1%/} node_modules/
rm -rf node_modules/$pkg/node_modules/
# Install `dependencies`
cd node_modules/$pkg/
yarn --production
# Remove our packages to ensure side-by-side versions are used (which we link)
rm -rf node_modules/{babel-preset-react-app,eslint-config-react-app,react-dev-utils,react-error-overlay,react-scripts}
cd ../..
}
# Check for the existence of one or more files. # Check for the existence of one or more files.
function exists { function exists {
for f in $*; do for f in $*; do
...@@ -96,12 +71,31 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then ...@@ -96,12 +71,31 @@ if [ "$EXPECTED" != "$ACTUAL" ]; then
exit 1 exit 1
fi fi
if hash npm 2>/dev/null
then
npm i -g npm@latest
npm cache clean || npm cache verify
fi
# Prevent bootstrap, we only want top-level dependencies # Prevent bootstrap, we only want top-level dependencies
cp package.json package.json.bak cp package.json package.json.bak
grep -v "postinstall" package.json > temp && mv temp package.json grep -v "postinstall" package.json > temp && mv temp package.json
yarn yarn
mv package.json.bak package.json mv package.json.bak package.json
# Start local registry
tmp_registry_log=`mktemp`
nohup npx verdaccio@2.7.2 &>$tmp_registry_log &
# Wait for `verdaccio` to boot
grep -q 'http address' <(tail -f $tmp_registry_log)
# Set registry to local registry
npm set registry http://localhost:4873
yarn config set registry http://localhost:4873
# Login so we can publish packages
npx npm-cli-login@0.0.10 -u user -p password -e user@example.com -r http://localhost:4873 --quotes
# We removed the postinstall, so do it manually here # We removed the postinstall, so do it manually here
node bootstrap.js node bootstrap.js
...@@ -142,48 +136,18 @@ CI=true yarn test ...@@ -142,48 +136,18 @@ CI=true yarn test
# Test local start command # Test local start command
yarn start --smoke-test yarn start --smoke-test
# ****************************************************************************** git clean -f
# Next, pack react-scripts and create-react-app so we can verify they work. ./tasks/release.sh --yes --force-publish=* --skip-git --cd-version=prerelease --exact --npm-tag=latest
# ******************************************************************************
# Pack CLI
cd "$root_path"/packages/create-react-app
cli_path=$PWD/`npm pack`
# Go to react-scripts
cd "$root_path"/packages/react-scripts
# Save package.json because we're going to touch it
cp package.json package.json.orig
# Replace own dependencies (those in the `packages` dir) with the local paths
# of those packages.
node "$root_path"/tasks/replace-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, create a clean app folder and install them. # Install react-scripts prerelease via create-react-app prerelease.
# ****************************************************************************** # ******************************************************************************
# Install the CLI in a temporary location
cd "$temp_cli_path"
# Initialize package.json before installing the CLI because npm will not install
# the CLI properly in the temporary location if it is missing.
yarn init --yes
# Now we can install the CLI from the local package.
yarn add "$cli_path"
# Install the app in a temporary location # Install the app in a temporary location
cd $temp_app_path cd $temp_app_path
create_react_app --scripts-version="$scripts_path" test-app npx create-react-app test-app
# TODO: verify we installed prerelease
# ****************************************************************************** # ******************************************************************************
# Now that we used create-react-app to create an app depending on react-scripts, # Now that we used create-react-app to create an app depending on react-scripts,
...@@ -291,11 +255,6 @@ verify_module_scope ...@@ -291,11 +255,6 @@ verify_module_scope
# Eject... # Eject...
echo yes | npm run eject echo yes | npm run eject
# ...but still link to the local packages
install_package "$root_path"/packages/babel-preset-react-app
install_package "$root_path"/packages/eslint-config-react-app
install_package "$root_path"/packages/react-dev-utils
# Test the build # Test the build
yarn build yarn build
# Check for expected output # Check for expected output
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment