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

add double quotes to escape spaces in paths in e2e #1707

Merged
merged 3 commits into from
Mar 5, 2017
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
10 changes: 5 additions & 5 deletions tasks/cra.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ root_path=$PWD
# ******************************************************************************

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

cd packages/react-scripts

Expand All @@ -61,10 +61,10 @@ 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
node "$root_path"/tasks/replace-own-deps.js

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

# Restore package.json
rm package.json
Expand All @@ -79,8 +79,8 @@ mv package.json.orig package.json
yarn cache clean || true

# Go back to the root directory and run the command from here
cd $root_path
node packages/create-react-app/index.js --scripts-version=$scripts_path "$@"
cd "$root_path"
node packages/create-react-app/index.js --scripts-version="$scripts_path" "$@"

# Cleanup
cleanup
26 changes: 13 additions & 13 deletions tasks/e2e-installs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`

function cleanup {
echo 'Cleaning up.'
cd $root_path
rm -rf $temp_cli_path $temp_app_path
cd "$root_path"
rm -rf "$temp_cli_path" "$temp_app_path"
}

# Error messages are redirected to stderr
Expand Down Expand Up @@ -77,18 +77,18 @@ fi
# ******************************************************************************

# Pack CLI
cd $root_path/packages/create-react-app
cd "$root_path"/packages/create-react-app
cli_path=$PWD/`npm pack`

# Install the CLI in a temporary location
cd $temp_cli_path
npm install $cli_path
cd "$temp_cli_path"
npm install "$cli_path"

# ******************************************************************************
# Test --scripts-version with a version number
# ******************************************************************************

cd $temp_app_path
cd "$temp_app_path"
create_react_app --scripts-version=0.4.0 test-app-version-number
cd test-app-version-number

Expand All @@ -100,7 +100,7 @@ grep '"version": "0.4.0"' node_modules/react-scripts/package.json
# Test --scripts-version with a tarball url
# ******************************************************************************

cd $temp_app_path
cd "$temp_app_path"
create_react_app --scripts-version=https://registry.npmjs.org/react-scripts/-/react-scripts-0.4.0.tgz test-app-tarball-url
cd test-app-tarball-url

Expand All @@ -112,7 +112,7 @@ grep '"version": "0.4.0"' node_modules/react-scripts/package.json
# Test --scripts-version with a custom fork of react-scripts
# ******************************************************************************

cd $temp_app_path
cd "$temp_app_path"
create_react_app --scripts-version=react-scripts-fork test-app-fork
cd test-app-fork

Expand All @@ -123,7 +123,7 @@ exists node_modules/react-scripts-fork
# Test project folder is deleted on failing package installation
# ******************************************************************************

cd $temp_app_path
cd "$temp_app_path"
# we will install a non-existing package to simulate a failed installataion.
create_react_app --scripts-version=`date +%s` test-app-should-not-exist || true
# confirm that the project folder was deleted
Expand All @@ -133,7 +133,7 @@ test ! -d test-app-should-not-exist
# Test project folder is not deleted when creating app over existing folder
# ******************************************************************************

cd $temp_app_path
cd "$temp_app_path"
mkdir test-app-should-remain
echo '## Hello' > ./test-app-should-remain/README.md
# we will install a non-existing package to simulate a failed installataion.
Expand All @@ -150,7 +150,7 @@ fi
# ******************************************************************************

#Testing a path that exists
cd $temp_app_path
cd "$temp_app_path"
mkdir test-app-nested-paths-t1
cd test-app-nested-paths-t1
mkdir -p test-app-nested-paths-t1/aa/bb/cc/dd
Expand All @@ -159,13 +159,13 @@ cd test-app-nested-paths-t1/aa/bb/cc/dd
npm start -- --smoke-test

#Testing a path that does not exist
cd $temp_app_path
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
cd $temp_app_path
cd "$temp_app_path"
mkdir -p test-app-nested-paths-t3/aa
create_react_app test-app-nested-paths-t3/aa/bb/cc/dd
cd test-app-nested-paths-t3/aa/bb/cc/dd
Expand Down
32 changes: 16 additions & 16 deletions tasks/e2e-kitchensink.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`
function cleanup {
echo 'Cleaning up.'
ps -ef | grep 'react-scripts' | grep -v grep | awk '{print $2}' | xargs kill -s 9
cd $root_path
cd "$root_path"
# TODO: fix "Device or resource busy" and remove ``|| $CI`
rm -rf $temp_cli_path $temp_app_path || $CI
rm -rf "$temp_cli_path" $temp_app_path || $CI
}

# Error messages are redirected to stderr
Expand All @@ -42,7 +42,7 @@ function handle_exit {
}

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 "$@"
}

# Check for the existence of one or more files.
Expand Down Expand Up @@ -79,21 +79,21 @@ fi
# ******************************************************************************

# Pack CLI
cd $root_path/packages/create-react-app
cd "$root_path"/packages/create-react-app
cli_path=$PWD/`npm pack`

# Go to react-scripts
cd $root_path/packages/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
node "$root_path"/tasks/replace-own-deps.js

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

# Restore package.json
rm package.json
Expand All @@ -104,12 +104,12 @@ mv package.json.orig package.json
# ******************************************************************************

# Install the CLI in a temporary location
cd $temp_cli_path
npm install $cli_path
cd "$temp_cli_path"
npm install "$cli_path"

# Install the app in a temporary location
cd $temp_app_path
create_react_app --scripts-version=$scripts_path --internal-testing-template=$root_path/packages/react-scripts/fixtures/kitchensink test-kitchensink
create_react_app --scripts-version="$scripts_path" --internal-testing-template="$root_path"/packages/react-scripts/fixtures/kitchensink test-kitchensink

# ******************************************************************************
# Now that we used create-react-app to create an app depending on react-scripts,
Expand All @@ -120,7 +120,7 @@ create_react_app --scripts-version=$scripts_path --internal-testing-template=$ro
cd test-kitchensink

# Link to our preset
npm link $root_path/packages/babel-preset-react-app
npm link "$root_path"/packages/babel-preset-react-app

# Test the build
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down Expand Up @@ -172,16 +172,16 @@ E2E_FILE=./build/index.html \
# ******************************************************************************

# Unlink our preset
npm unlink $root_path/packages/babel-preset-react-app
npm unlink "$root_path"/packages/babel-preset-react-app

# 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
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
REACT_APP_SHELL_ENV_MESSAGE=fromtheshell \
Expand Down
28 changes: 14 additions & 14 deletions tasks/e2e-simple.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ temp_app_path=`mktemp -d 2>/dev/null || mktemp -d -t 'temp_app_path'`

function cleanup {
echo 'Cleaning up.'
cd $root_path
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
rm -rf "$temp_cli_path" $temp_app_path
}

# Error messages are redirected to stderr
Expand All @@ -42,7 +42,7 @@ function handle_exit {
}

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 "$@"
}

# Check for the existence of one or more files.
Expand Down Expand Up @@ -126,21 +126,21 @@ npm start -- --smoke-test
# ******************************************************************************

# Pack CLI
cd $root_path/packages/create-react-app
cd "$root_path"/packages/create-react-app
cli_path=$PWD/`npm pack`

# Go to react-scripts
cd $root_path/packages/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
node "$root_path"/tasks/replace-own-deps.js

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

# Restore package.json
rm package.json
Expand All @@ -151,12 +151,12 @@ mv package.json.orig package.json
# ******************************************************************************

# Install the CLI in a temporary location
cd $temp_cli_path
npm install $cli_path
cd "$temp_cli_path"
npm install "$cli_path"

# Install the app in a temporary location
cd $temp_app_path
create_react_app --scripts-version=$scripts_path test-app
create_react_app --scripts-version="$scripts_path" test-app
Copy link
Contributor Author

@viankakrisna viankakrisna Mar 3, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line here still causes error even when wrapped with ""

here's the full log

Compiled successfully!

The app is running at:

  http://localhost:3000/

Note that the development build is not optimized.
To create a production build, use npm run build.

+ cd '/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/create-react-app'
++ npm pack
+ cli_path='/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/create-react-app/create-react-app-1.2.1.tgz'
+ cd '/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/react-scripts'
+ cp package.json package.json.orig
+ node '/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/tasks/replace-own-deps.js'
Replaced local dependencies.
++ npm pack
+ scripts_path='/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/react-scripts/react-scripts-0.9.3.tgz'
+ rm package.json
+ mv package.json.orig package.json
+ cd /var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.VTXHaGfC
+ npm install '/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/create-react-app/create-react-app-1.2.1.tgz'
/private/var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.VTXHaGfC
└─┬ create-react-app@1.2.1 
  ├─┬ chalk@1.1.3 
  │ ├── ansi-styles@2.2.1 
  │ ├── escape-string-regexp@1.0.5 
  │ ├─┬ has-ansi@2.0.0 
  │ │ └── ansi-regex@2.1.1 
  │ ├── strip-ansi@3.0.1 
  │ └── supports-color@2.0.0 
  ├─┬ commander@2.9.0 
  │ └── graceful-readlink@1.0.1 
  ├─┬ cross-spawn@4.0.2 
  │ ├─┬ lru-cache@4.0.2 
  │ │ ├── pseudomap@1.0.2 
  │ │ └── yallist@2.0.0 
  │ └─┬ which@1.2.12 
  │   └── isexe@1.1.2 
  ├─┬ fs-extra@1.0.0 
  │ ├── graceful-fs@4.1.11 
  │ ├── jsonfile@2.4.0 
  │ └── klaw@1.3.1 
  ├── semver@5.3.0 
  └─┬ validate-npm-package-name@3.0.0 
    └── builtins@1.0.3 

npm WARN enoent ENOENT: no such file or directory, open '/private/var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.VTXHaGfC/package.json'
npm WARN tmp.VTXHaGfC No description
npm WARN tmp.VTXHaGfC No repository field.
npm WARN tmp.VTXHaGfC No README data
npm WARN tmp.VTXHaGfC No license field.
+ cd /var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.8YzQUV2S
+ create_react_app '--scripts-version=/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/react-scripts/react-scripts-0.9.3.tgz' test-app
+ node /var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.VTXHaGfC/node_modules/create-react-app/index.js --scripts-version=/Users/adeviankakrisnafadlil/Local Sites/create-react-app-extra/packages/react-scripts/react-scripts-0.9.3.tgz test-app
Creating a new React app in /private/var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.8YzQUV2S/Sites/create-react-app-extra/packages/react-scripts/react-scripts-0.9.3.tgz.

Installing packages. This might take a couple minutes.
Installing react, react-dom, and /Users/adeviankakrisnafadlil/Local...

yarn add v0.21.3
info No lockfile found.
[1/4] 🔍  Resolving packages...
error Couldn't find package "/Users/adeviankakrisnafadlil/Local" on the "npm" registry.
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

Aborting installation.
  yarnpkg add --exact react react-dom /Users/adeviankakrisnafadlil/Local has failed.

Deleting generated file... package.json
Deleting react-scripts-0.9.3.tgz/ from /private/var/folders/f9/35kw1ffx64944m7ws1k3ytqh0000gn/T/tmp.8YzQUV2S/Sites/create-react-app-extra/packages/react-scripts
Done.
++ set +x
e2e-simple.sh: ERROR! An error was encountered executing line 159.
Cleaning up.
Exiting with error.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

It calls create-react-app in the packages folders and somehow failed to resolve proper path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work with npm? Might be a yarn bug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how to test it with npm? can i disable yarn temporarily on my machine?


# ******************************************************************************
# Now that we used create-react-app to create an app depending on react-scripts,
Expand Down Expand Up @@ -243,10 +243,10 @@ verify_env_url
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
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
Expand Down
2 changes: 1 addition & 1 deletion tasks/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,6 @@ if [ -n "$(git status --porcelain)" ]; then
exit 1;
fi

cd $root_path
cd "$root_path"
# Go!
./node_modules/.bin/lerna publish --independent "$@"