-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
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
Beaufity output of eject.js script #769
Merged
Merged
Changes from 4 commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
350b2bc
Beaufity output of eject.js script
azakordonets 822ad8c
change formatting of the eject.js output and move colors to cyan
azakordonets bfe4850
change message about file copy
azakordonets 1c5f505
add missing three dots to some statements in eject.js script
azakordonets 173e87c
change color of "copying files" line and do not repeat copy path anym…
azakordonets 41345b7
fix merge conflict
azakordonets 259b6f5
Remove yellow color from "Removing dependency" line
azakordonets 52b7123
changing color to "Adding dependency" line
azakordonets 917404e
Add line that outputs which react script is getting replaced by simil…
azakordonets 1a8ff9e
remove not used anymore colors
azakordonets 4b9fa8a
add console line about updating Jest configs
azakordonets f6f635d
fix typo
azakordonets 79a4c2b
change formatting of replacing script output in eject.js
azakordonets c440b27
fix merge conflicts
azakordonets 52c432f
remove "Writing package.json" file console output
azakordonets 308a21e
make quotes cyan in "Replacing script" console output
azakordonets 2e208c9
update console log output for Jest, Babel, ESLint update and group th…
azakordonets 40fa310
Style nits
gaearon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,18 +13,22 @@ var path = require('path'); | |
var prompt = require('react-dev-utils/prompt'); | ||
var rimrafSync = require('rimraf').sync; | ||
var spawnSync = require('cross-spawn').sync; | ||
var chalk = require('chalk'); | ||
var green = chalk.green; | ||
var cyan = chalk.cyan; | ||
var red = chalk.red; | ||
var yellow = chalk.yellow; | ||
|
||
prompt( | ||
'Are you sure you want to eject? This action is permanent.', | ||
false | ||
).then(shouldEject => { | ||
if (!shouldEject) { | ||
console.log('Close one! Eject aborted.'); | ||
console.log(cyan('Close one! Eject aborted.')); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Ejecting...'); | ||
console.log(); | ||
|
||
var ownPath = path.join(__dirname, '..'); | ||
var appPath = path.join(ownPath, '..', '..'); | ||
|
@@ -61,8 +65,10 @@ prompt( | |
fs.mkdirSync(path.join(appPath, 'config', 'jest')); | ||
fs.mkdirSync(path.join(appPath, 'scripts')); | ||
|
||
console.log(); | ||
console.log(cyan('Copying files...')); | ||
files.forEach(function(file) { | ||
console.log('Copying ' + file + ' to ' + appPath); | ||
console.log(cyan(' Copying ') + file+ ' to ' + appPath); | ||
var content = fs | ||
.readFileSync(path.join(ownPath, file), 'utf8') | ||
// Remove dead code from .js files on eject | ||
|
@@ -76,21 +82,21 @@ prompt( | |
|
||
var ownPackage = require(path.join(ownPath, 'package.json')); | ||
var appPackage = require(path.join(appPath, 'package.json')); | ||
|
||
console.log(cyan('Updating dependencies...')); | ||
var ownPackageName = ownPackage.name; | ||
console.log('Removing dependency: ' + ownPackageName); | ||
console.log(yellow(' Removing dependency: ') + ownPackageName); | ||
delete appPackage.devDependencies[ownPackageName]; | ||
|
||
Object.keys(ownPackage.dependencies).forEach(function (key) { | ||
// For some reason optionalDependencies end up in dependencies after install | ||
if (ownPackage.optionalDependencies[key]) { | ||
return; | ||
} | ||
console.log('Adding dependency: ' + key); | ||
console.log(cyan(' Adding dependency: ') + key); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Similar, let’s make dependency name |
||
appPackage.devDependencies[key] = ownPackage.dependencies[key]; | ||
}); | ||
|
||
console.log('Updating scripts'); | ||
console.log(); | ||
console.log(cyan('Updating scripts...')); | ||
delete appPackage.scripts['eject']; | ||
Object.keys(appPackage.scripts).forEach(function (key) { | ||
appPackage.scripts[key] = appPackage.scripts[key] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let’s print each step here?
|
||
|
@@ -107,20 +113,21 @@ prompt( | |
true | ||
); | ||
|
||
console.log('Writing package.json'); | ||
console.log(); | ||
console.log(cyan('Writing ') + 'package.json...'); | ||
fs.writeFileSync( | ||
path.join(appPath, 'package.json'), | ||
JSON.stringify(appPackage, null, 2) | ||
); | ||
console.log(); | ||
|
||
console.log('Running npm install...'); | ||
console.log(cyan('Running npm install...')); | ||
rimrafSync(ownPath); | ||
spawnSync('npm', ['install'], {stdio: 'inherit'}); | ||
console.log('Ejected successfully!'); | ||
console.log(green('Ejected successfully!')); | ||
console.log(); | ||
|
||
console.log('Please consider sharing why you ejected in this survey:'); | ||
console.log(' 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() | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you try making
file
andappPath
cyan instead ofCopying
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking at the output, it prints the same giant appPath on every single line.
Suggestion: could we put this path in the header instead?