From 60e658352a45210fff08eae4cfa8a8ebce2aa4e5 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:11:30 +0100 Subject: [PATCH 01/17] Try using async cross-spawn on ejecting --- packages/react-scripts/scripts/eject.js | 32 +++++++++++++++---------- 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index c771e075d35..89a67b9f346 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -23,7 +23,7 @@ const chalk = require('chalk'); const paths = require('../config/paths'); const createJestConfig = require('./utils/createJestConfig'); const inquirer = require('react-dev-utils/inquirer'); -const spawnSync = require('react-dev-utils/crossSpawn').sync; +const spawn = require('react-dev-utils/crossSpawn'); const green = chalk.green; const cyan = chalk.cyan; @@ -215,20 +215,28 @@ inquirer // It's not essential that this succeeds } } - - if (fs.existsSync(paths.yarnLockFile)) { + + let child = null; + const useYarn = fs.existsSync(paths.yarnLockFile); + if (useYarn) { console.log(cyan('Running yarn...')); - spawnSync('yarnpkg', [], { stdio: 'inherit' }); + child = spawn('yarnpkg', [], { stdio: 'inherit' }); } else { console.log(cyan('Running npm install...')); - spawnSync('npm', ['install'], { stdio: 'inherit' }); + child = spawn('npm', ['install'], { stdio: 'inherit' }); } - console.log(green('Ejected successfully!')); - console.log(); - console.log( - green('Please consider sharing why you ejected in this survey:') - ); - console.log(green(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); - console.log(); + child.on('close', code => { + console.log(green('Ejected successfully!')); + if (code !== 0) { + // Ignore? + } + console.log(); + + console.log( + green('Please consider sharing why you ejected in this survey:') + ); + console.log(green(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); + console.log(); + }); }); From 821fb3002f4e2b2bb74ce8923b507224dd05fa4d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:13:41 +0100 Subject: [PATCH 02/17] Check if AppVeyor fixed --- tasks/e2e-simple.sh | 159 -------------------------------------------- 1 file changed, 159 deletions(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 163bec0818a..780c30d956b 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -122,39 +122,9 @@ then fi # Lint own code -./node_modules/.bin/eslint --max-warnings 0 packages/babel-preset-react-app/ -./node_modules/.bin/eslint --max-warnings 0 packages/create-react-app/ -./node_modules/.bin/eslint --max-warnings 0 packages/eslint-config-react-app/ -./node_modules/.bin/eslint --max-warnings 0 packages/react-dev-utils/ -./node_modules/.bin/eslint --max-warnings 0 packages/react-scripts/ -cd packages/react-error-overlay/ -./node_modules/.bin/eslint --max-warnings 0 src/ -npm test npm run build:prod cd ../.. -# ****************************************************************************** -# First, test the create-react-app development environment. -# This does not affect our users but makes sure we can develop it. -# ****************************************************************************** - -# Test local build command -npm run build -# Check for expected output -exists build/*.html -exists build/static/js/*.js -exists build/static/css/*.css -exists build/static/media/*.svg -exists build/favicon.ico - -# Run tests with CI flag -CI=true npm test -# Uncomment when snapshot testing is enabled by default: -# exists template/src/__snapshots__/App.test.js.snap - -# Test local start command -npm start -- --smoke-test - # ****************************************************************************** # Next, pack react-scripts and create-react-app so we can verify they work. # ****************************************************************************** @@ -198,104 +168,6 @@ npm install "$cli_path" cd $temp_app_path create_react_app --scripts-version="$scripts_path" test-app -# ****************************************************************************** -# Now that we used create-react-app to create an app depending on react-scripts, -# let's make sure all npm scripts are in the working state. -# ****************************************************************************** - -function verify_env_url { - # Backup package.json because we're going to make it dirty - cp package.json package.json.orig - - # Test default behavior - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 0 || exit 1 - - # Test relative path build - awk -v n=2 -v s=" \"homepage\": \".\"," 'NR == n {print s} {print}' package.json > tmp && mv tmp package.json - - npm run build - # Disabled until this can be tested - # grep -F -R --exclude=*.map "../../static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"./static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - - PUBLIC_URL="/anabsolute" npm run build - grep -F -R --exclude=*.map "/anabsolute/static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - - # Test absolute path build - sed "2s/.*/ \"homepage\": \"\/testingpath\",/" package.json > tmp && mv tmp package.json - - npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - - PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 - - # Test absolute url build - sed "2s/.*/ \"homepage\": \"https:\/\/www.example.net\/testingpath\",/" package.json > tmp && mv tmp package.json - - npm run build - grep -F -R --exclude=*.map "/testingpath/static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - - PUBLIC_URL="https://www.example.net/overridetest" npm run build - grep -F -R --exclude=*.map "https://www.example.net/overridetest/static/" build/ -q; test $? -eq 0 || exit 1 - grep -F -R --exclude=*.map "\"/static/" build/ -q; test $? -eq 1 || exit 1 - grep -F -R --exclude=*.map "testingpath/static" build/ -q; test $? -eq 1 || exit 1 - - # Restore package.json - rm package.json - mv package.json.orig package.json -} - -function verify_module_scope { - # Create stub json file - echo "{}" >> sample.json - - # Save App.js, we're going to modify it - cp src/App.js src/App.js.bak - - # Add an out of scope import - echo "import sampleJson from '../sample'" | cat - src/App.js > src/App.js.temp && mv src/App.js.temp src/App.js - - # Make sure the build fails - npm run build; test $? -eq 1 || exit 1 - # TODO: check for error message - - # Restore App.js - rm src/App.js - mv src/App.js.bak src/App.js -} - -# Enter the app directory -cd test-app - -# Test the build -npm run build -# Check for expected output -exists build/*.html -exists build/static/js/*.js -exists build/static/css/*.css -exists build/static/media/*.svg -exists build/favicon.ico - -# Run tests with CI flag -CI=true npm test -# Uncomment when snapshot testing is enabled by default: -# exists src/__snapshots__/App.test.js.snap - -# Test the server -npm start -- --smoke-test - -# Test environment handling -verify_env_url - -# Test reliance on webpack internals -verify_module_scope # ****************************************************************************** # Finally, let's check that everything still works after ejecting. @@ -304,37 +176,6 @@ verify_module_scope # 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 -exists build/*.html -exists build/static/js/*.js -exists build/static/css/*.css -exists build/static/media/*.svg -exists build/favicon.ico - -# Run tests, overring the watch option to disable it. -# `CI=true npm test` won't work here because `npm test` becomes just `jest`. -# We should either teach Jest to respect CI env variable, or make -# `scripts/test.js` survive ejection (right now it doesn't). -npm test -- --watch=no -# Uncomment when snapshot testing is enabled by default: -# exists src/__snapshots__/App.test.js.snap - -# Test the server -npm start -- --smoke-test - -# Test environment handling -verify_env_url - -# Test reliance on webpack internals -verify_module_scope # Cleanup cleanup From e197bffd3f691e07bfbb09f037e3709953578c4c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:21:47 +0100 Subject: [PATCH 03/17] Oops --- tasks/e2e-simple.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 780c30d956b..9734be82e4d 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -122,6 +122,7 @@ then fi # Lint own code +cd packages/react-error-overlay/ npm run build:prod cd ../.. From 2c93b2e1e64af73f61a84bd7f507566d9e959767 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:30:05 +0100 Subject: [PATCH 04/17] Update e2e-simple.sh --- tasks/e2e-simple.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 9734be82e4d..2b39e50622a 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -175,6 +175,7 @@ create_react_app --scripts-version="$scripts_path" test-app # ****************************************************************************** # Eject... +cd test-app echo yes | npm run eject From 7fd49a9e3c5a112f513c325324bed425681eb31d Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:38:24 +0100 Subject: [PATCH 05/17] Try execSync. I'm getting desperate --- packages/react-scripts/scripts/eject.js | 28 +++++++++---------------- 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 89a67b9f346..489be1028cc 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -23,7 +23,6 @@ const chalk = require('chalk'); const paths = require('../config/paths'); const createJestConfig = require('./utils/createJestConfig'); const inquirer = require('react-dev-utils/inquirer'); -const spawn = require('react-dev-utils/crossSpawn'); const green = chalk.green; const cyan = chalk.cyan; @@ -216,27 +215,20 @@ inquirer } } - let child = null; - const useYarn = fs.existsSync(paths.yarnLockFile); - if (useYarn) { + if (fs.existsSync(paths.yarnLockFile)) { console.log(cyan('Running yarn...')); - child = spawn('yarnpkg', [], { stdio: 'inherit' }); + execSync('yarnpkg'); } else { console.log(cyan('Running npm install...')); - child = spawn('npm', ['install'], { stdio: 'inherit' }); + execSync('npm install'); } - child.on('close', code => { - console.log(green('Ejected successfully!')); - if (code !== 0) { - // Ignore? - } - console.log(); + console.log(green('Ejected successfully!')); + console.log(); - console.log( - green('Please consider sharing why you ejected in this survey:') - ); - console.log(green(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); - console.log(); - }); + console.log( + green('Please consider sharing why you ejected in this survey:') + ); + console.log(green(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); + console.log(); }); From 28830ac326c22dbd3d1e079abb676f118df90d0e Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:46:13 +0100 Subject: [PATCH 06/17] If that's how you want to play it.. --- packages/react-scripts/scripts/eject.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 489be1028cc..2e2d212f2e9 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -46,6 +46,11 @@ inquirer default: false, }) .then(answer => { + + + // LOL + return + if (!answer.shouldEject) { console.log(cyan('Close one! Eject aborted.')); return; From 6a17e6dc7df9ebeb6c8d6032fb2a6d8d95121d14 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 20:59:21 +0100 Subject: [PATCH 07/17] Narrow down --- packages/react-scripts/scripts/eject.js | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 2e2d212f2e9..bc14b74d03d 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -46,11 +46,6 @@ inquirer default: false, }) .then(answer => { - - - // LOL - return - if (!answer.shouldEject) { console.log(cyan('Close one! Eject aborted.')); return; @@ -222,10 +217,10 @@ inquirer if (fs.existsSync(paths.yarnLockFile)) { console.log(cyan('Running yarn...')); - execSync('yarnpkg'); + //execSync('yarnpkg'); } else { console.log(cyan('Running npm install...')); - execSync('npm install'); + //execSync('npm install'); } console.log(green('Ejected successfully!')); From 8257e43a15c82805d4c5a3ad225f8640151a3c7c Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 21:17:24 +0100 Subject: [PATCH 08/17] Update eject.js --- packages/react-scripts/scripts/eject.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index bc14b74d03d..1b2ea07a1d7 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -222,6 +222,13 @@ inquirer console.log(cyan('Running npm install...')); //execSync('npm install'); } + + try { + execSync('npm install'); + console.log(' OR ME ') + } catch (err) { + console.log(' PLEASE PRINT ME PLEASE ') + } console.log(green('Ejected successfully!')); console.log(); From ccd752c4570631b2e3d372cc7810c87e5e1494bb Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 21:25:23 +0100 Subject: [PATCH 09/17] hum hum --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 1b2ea07a1d7..928f6368600 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -224,7 +224,7 @@ inquirer } try { - execSync('npm install'); + execSync('yarnpkg'); console.log(' OR ME ') } catch (err) { console.log(' PLEASE PRINT ME PLEASE ') From ca1d16ceb736c66f23cb7f903172c4b9203c12bf Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 21:40:00 +0100 Subject: [PATCH 10/17] Uh --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 928f6368600..e5ce4c0d461 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -224,7 +224,7 @@ inquirer } try { - execSync('yarnpkg'); + execSync('yarn'); console.log(' OR ME ') } catch (err) { console.log(' PLEASE PRINT ME PLEASE ') From 845cddc1ddbcab709a39c6e418ce25d3d77f034a Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 21:49:41 +0100 Subject: [PATCH 11/17] Update eject.js --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index e5ce4c0d461..94d714c8f90 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -224,7 +224,7 @@ inquirer } try { - execSync('yarn'); + execSync('yarn.cmd'); console.log(' OR ME ') } catch (err) { console.log(' PLEASE PRINT ME PLEASE ') From b1e9473322e9959a60512a05d3c0ab4c9f61a584 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 21:58:57 +0100 Subject: [PATCH 12/17] Update eject.js --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 94d714c8f90..86556caa549 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -224,7 +224,7 @@ inquirer } try { - execSync('yarn.cmd'); + execSync('yarn.cmd', {stdio: 'inherit'}); console.log(' OR ME ') } catch (err) { console.log(' PLEASE PRINT ME PLEASE ') From 5d42cc6f48870b118fbab36dfa8f014918ad4ec9 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Mon, 26 Jun 2017 23:14:43 +0100 Subject: [PATCH 13/17] Update eject.js --- packages/react-scripts/scripts/eject.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 86556caa549..6df001db855 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -12,9 +12,9 @@ // Makes the script crash on unhandled rejections instead of silently // ignoring them. In the future, promise rejections that are not handled will // terminate the Node.js process with a non-zero exit code. -process.on('unhandledRejection', err => { - throw err; -}); +// process.on('unhandledRejection', err => { +// throw err; +// }); const fs = require('fs-extra'); const path = require('path'); @@ -238,4 +238,10 @@ inquirer ); console.log(green(' http://goo.gl/forms/Bi6CZjk1EqsdelXk1')); console.log(); + }); + + +process.on('beforeExit', code => { + console.log('OH OH NO GONNA EXIT!!!!', code) +}); From 558d96e82ea8f669f244d6ce2a9a7f3303c13eda Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 00:37:10 +0100 Subject: [PATCH 14/17] Update eject.js --- packages/react-scripts/scripts/eject.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/react-scripts/scripts/eject.js b/packages/react-scripts/scripts/eject.js index 6df001db855..d3ca3250b0f 100644 --- a/packages/react-scripts/scripts/eject.js +++ b/packages/react-scripts/scripts/eject.js @@ -242,6 +242,6 @@ inquirer }); -process.on('beforeExit', code => { +process.on('exit', code => { console.log('OH OH NO GONNA EXIT!!!!', code) }); From 3d75bdbe70233c3ff07aca34f47548b947fefcee Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 13:36:10 +0100 Subject: [PATCH 15/17] Update react-scripts.js --- packages/react-scripts/bin/react-scripts.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/react-scripts/bin/react-scripts.js b/packages/react-scripts/bin/react-scripts.js index cb52fe71b09..a70dc4bd425 100755 --- a/packages/react-scripts/bin/react-scripts.js +++ b/packages/react-scripts/bin/react-scripts.js @@ -24,6 +24,8 @@ switch (script) { [require.resolve('../scripts/' + script)].concat(args), { stdio: 'inherit' } ); + console.log('Okay now status: ', result.status) + console.log(result) if (result.signal) { if (result.signal === 'SIGKILL') { console.log( From 2442536f2a236afd026bb78a9e67d3f1424c3aeb Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 13:48:21 +0100 Subject: [PATCH 16/17] Update e2e-simple.sh --- tasks/e2e-simple.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index 2b39e50622a..f9db734549d 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -24,7 +24,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 + # rm -rf "$temp_cli_path" $temp_app_path } # Error messages are redirected to stderr @@ -180,4 +180,4 @@ echo yes | npm run eject # Cleanup -cleanup +#cleanup From 28a06142f9ebb9e9db7d43cf60740ad3c4b8d418 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Tue, 27 Jun 2017 14:15:22 +0100 Subject: [PATCH 17/17] Update e2e-simple.sh --- tasks/e2e-simple.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/e2e-simple.sh b/tasks/e2e-simple.sh index f9db734549d..34a16f40c7f 100755 --- a/tasks/e2e-simple.sh +++ b/tasks/e2e-simple.sh @@ -176,7 +176,7 @@ create_react_app --scripts-version="$scripts_path" test-app # Eject... cd test-app -echo yes | npm run eject +echo yes | yarn.cmd eject # Cleanup