Commit de1beec6 authored by Joe Haddad's avatar Joe Haddad Committed by Dan Abramov
Browse files

Stop using `npm link` in tests (#3345)

* Try a custom function

* fix path

* install rsync

* Test with node 8

* Ensure package is removed from the tree

* Remove ours

* matching functions

* try cygwin

* try c:/

* sigh

* Try /cygdrive/

* Try /cygdrive/

* Revert "Try /cygdrive/"

This reverts commit ab1ed779456d39bedbdb128a7aec3bb88b8eeb1c.

* Use sub-optimal copy

* Remove rsync install

* Fix variable

* Continue on err

* Don't link react-scripts, lol

* run yarn after eject

* re-enable cleanup

* uninstall yarn

* try with force

* appveyor ... seriously?

* swallow bad eject

* remove eject error swallow

* Revert "run yarn after eject"

This reverts commit eebf1dbc19aeb6e1f66d5ec27bda2d076bea0956.

* Run yarn after eject

* add a comment
parent 345f5508
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 80 additions and 21 deletions
+80 -21
...@@ -2,11 +2,11 @@ image: Visual Studio 2017 ...@@ -2,11 +2,11 @@ image: Visual Studio 2017
environment: environment:
matrix: matrix:
- nodejs_version: 7 - nodejs_version: 8
test_suite: "simple" test_suite: "simple"
- nodejs_version: 7 - nodejs_version: 8
test_suite: "installs" test_suite: "installs"
- nodejs_version: 7 - nodejs_version: 8
test_suite: "kitchensink" test_suite: "kitchensink"
- nodejs_version: 6 - nodejs_version: 6
test_suite: "simple" test_suite: "simple"
......
...@@ -44,6 +44,31 @@ function create_react_app { ...@@ -44,6 +44,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" 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/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# 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
...@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1 ...@@ -162,13 +187,13 @@ npm install test-integrity@^2.0.1
cd "$temp_app_path/test-kitchensink" cd "$temp_app_path/test-kitchensink"
# Link to our preset # Link to our preset
npm link "$root_path"/packages/babel-preset-react-app install_package "$root_path"/packages/babel-preset-react-app
# Link to error overlay package because now it's a dependency # Link to error overlay package because now it's a dependency
# of react-dev-utils and not react-scripts # of react-dev-utils and not react-scripts
npm link "$root_path"/packages/react-error-overlay install_package "$root_path"/packages/react-error-overlay
# Link to test module # Link to test module
npm link "$temp_module_path/node_modules/test-integrity" install_package "$temp_module_path/node_modules/test-integrity"
# Test the build # Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
...@@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \ ...@@ -219,23 +244,25 @@ E2E_FILE=./build/index.html \
# Finally, let's check that everything still works after ejecting. # Finally, let's check that everything still works after ejecting.
# ****************************************************************************** # ******************************************************************************
# Unlink our preset
npm unlink "$root_path"/packages/babel-preset-react-app
# Unlink error overlay
npm unlink "$root_path"/packages/react-error-overlay
# Eject... # Eject...
echo yes | npm run eject echo yes | npm run eject
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarn install --check-files
fi
# ...but still link to the local packages # ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app install_package "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app install_package "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-error-overlay install_package "$root_path"/packages/react-error-overlay
npm link "$root_path"/packages/react-dev-utils install_package "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
# Link to test module # Link to test module
npm link "$temp_module_path/node_modules/test-integrity" install_package "$temp_module_path/node_modules/test-integrity"
# Test the build # Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \ REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
......
...@@ -43,6 +43,31 @@ function create_react_app { ...@@ -43,6 +43,31 @@ function create_react_app {
node "$temp_cli_path"/node_modules/create-react-app/index.js "$@" 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/
if [ "$USE_YARN" = "yes" ]
then
yarn install --production
else
npm install --only=production
fi
# 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
...@@ -306,11 +331,18 @@ verify_module_scope ...@@ -306,11 +331,18 @@ verify_module_scope
# Eject... # Eject...
echo yes | npm run eject echo yes | npm run eject
# Ensure Yarn is ran after eject; at the time of this commit, we don't run Yarn
# after ejecting. Soon, we may only skip Yarn on Windows. Let's try to remove
# this in the near future.
if hash yarnpkg 2>/dev/null
then
yarnpkg install --check-files
fi
# ...but still link to the local packages # ...but still link to the local packages
npm link "$root_path"/packages/babel-preset-react-app install_package "$root_path"/packages/babel-preset-react-app
npm link "$root_path"/packages/eslint-config-react-app install_package "$root_path"/packages/eslint-config-react-app
npm link "$root_path"/packages/react-dev-utils install_package "$root_path"/packages/react-dev-utils
npm link "$root_path"/packages/react-scripts
# Test the build # Test the build
npm run build npm run build
......
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