10
10
// Makes the script crash on unhandled rejections instead of silently
11
11
// ignoring them. In the future, promise rejections that are not handled will
12
12
// terminate the Node.js process with a non-zero exit code.
13
- process . on ( 'unhandledRejection' , err => {
13
+ process . on ( 'unhandledRejection' , ( err ) => {
14
14
throw err ;
15
15
} ) ;
16
16
@@ -86,7 +86,7 @@ module.exports = function (
86
86
appName ,
87
87
verbose ,
88
88
originalDirectory ,
89
- templateName
89
+ templateName ,
90
90
) {
91
91
const appPackage = require ( path . join ( appPath , 'package.json' ) ) ;
92
92
const useYarn = fs . existsSync ( path . join ( appPath , 'yarn.lock' ) ) ;
@@ -95,26 +95,26 @@ module.exports = function (
95
95
console . log ( '' ) ;
96
96
console . error (
97
97
`A template was not provided. This is likely because you're using an outdated version of ${ chalk . cyan (
98
- 'create-react-app'
99
- ) } .`
98
+ 'create-react-app' ,
99
+ ) } .`,
100
100
) ;
101
101
console . error (
102
102
`Please note that global installs of ${ chalk . cyan (
103
- 'create-react-app'
104
- ) } are no longer supported.`
103
+ 'create-react-app' ,
104
+ ) } are no longer supported.`,
105
105
) ;
106
106
console . error (
107
107
`You can fix this by running ${ chalk . cyan (
108
- 'npm uninstall -g create-react-app'
108
+ 'npm uninstall -g create-react-app' ,
109
109
) } or ${ chalk . cyan (
110
- 'yarn global remove create-react-app'
111
- ) } before using ${ chalk . cyan ( 'create-react-app' ) } again.`
110
+ 'yarn global remove create-react-app' ,
111
+ ) } before using ${ chalk . cyan ( 'create-react-app' ) } again.`,
112
112
) ;
113
113
return ;
114
114
}
115
115
116
116
const templatePath = path . dirname (
117
- require . resolve ( `${ templateName } /package.json` , { paths : [ appPath ] } )
117
+ require . resolve ( `${ templateName } /package.json` , { paths : [ appPath ] } ) ,
118
118
) ;
119
119
120
120
const templateJsonPath = path . join ( templatePath , 'template.json' ) ;
@@ -132,8 +132,8 @@ module.exports = function (
132
132
console . log (
133
133
chalk . red (
134
134
'Root-level `dependencies` and `scripts` keys in `template.json` were deprecated for Create React App 5.\n' +
135
- 'This template needs to be updated to use the new `package` key.'
136
- )
135
+ 'This template needs to be updated to use the new `package` key.' ,
136
+ ) ,
137
137
) ;
138
138
console . log ( 'For more information, visit https://cra.link/templates' ) ;
139
139
}
@@ -170,12 +170,14 @@ module.exports = function (
170
170
171
171
// Keys from templatePackage that will be added to appPackage,
172
172
// replacing any existing entries.
173
- const templatePackageToReplace = Object . keys ( templatePackage ) . filter ( key => {
174
- return (
175
- ! templatePackageBlacklist . includes ( key ) &&
176
- ! templatePackageToMerge . includes ( key )
177
- ) ;
178
- } ) ;
173
+ const templatePackageToReplace = Object . keys ( templatePackage ) . filter (
174
+ ( key ) => {
175
+ return (
176
+ ! templatePackageBlacklist . includes ( key ) &&
177
+ ! templatePackageToMerge . includes ( key )
178
+ ) ;
179
+ } ,
180
+ ) ;
179
181
180
182
// Copy over some of the devDependencies
181
183
appPackage . dependencies = appPackage . dependencies || { } ;
@@ -189,7 +191,7 @@ module.exports = function (
189
191
test : 'react-scripts test' ,
190
192
eject : 'react-scripts eject' ,
191
193
} ,
192
- templateScripts
194
+ templateScripts ,
193
195
) ;
194
196
195
197
// Update scripts for Yarn users
@@ -199,33 +201,33 @@ module.exports = function (
199
201
...acc ,
200
202
[ key ] : value . replace ( / ( n p m r u n | n p m ) / , 'yarn ' ) ,
201
203
} ) ,
202
- { }
204
+ { } ,
203
205
) ;
204
206
}
205
207
206
- // Setup the eslint config
207
- appPackage . eslintConfig = {
208
- extends : 'react-app' ,
209
- } ;
208
+ // // Setup the eslint config
209
+ // appPackage.eslintConfig = {
210
+ // extends: 'react-app',
211
+ // };
210
212
211
213
// Setup the browsers list
212
214
appPackage . browserslist = defaultBrowsers ;
213
215
214
216
// Add templatePackage keys/values to appPackage, replacing existing entries
215
- templatePackageToReplace . forEach ( key => {
217
+ templatePackageToReplace . forEach ( ( key ) => {
216
218
appPackage [ key ] = templatePackage [ key ] ;
217
219
} ) ;
218
220
219
221
fs . writeFileSync (
220
222
path . join ( appPath , 'package.json' ) ,
221
- JSON . stringify ( appPackage , null , 2 ) + os . EOL
223
+ JSON . stringify ( appPackage , null , 2 ) + os . EOL ,
222
224
) ;
223
225
224
226
const readmeExists = fs . existsSync ( path . join ( appPath , 'README.md' ) ) ;
225
227
if ( readmeExists ) {
226
228
fs . renameSync (
227
229
path . join ( appPath , 'README.md' ) ,
228
- path . join ( appPath , 'README.old.md' )
230
+ path . join ( appPath , 'README.old.md' ) ,
229
231
) ;
230
232
}
231
233
@@ -235,7 +237,7 @@ module.exports = function (
235
237
fs . copySync ( templateDir , appPath ) ;
236
238
} else {
237
239
console . error (
238
- `Could not locate supplied template: ${ chalk . green ( templateDir ) } `
240
+ `Could not locate supplied template: ${ chalk . green ( templateDir ) } ` ,
239
241
) ;
240
242
return ;
241
243
}
@@ -247,7 +249,7 @@ module.exports = function (
247
249
fs . writeFileSync (
248
250
path . join ( appPath , 'README.md' ) ,
249
251
readme . replace ( / ( n p m r u n | n p m ) / g, 'yarn ' ) ,
250
- 'utf8'
252
+ 'utf8' ,
251
253
) ;
252
254
} catch ( err ) {
253
255
// Silencing the error. As it fall backs to using default npm commands.
@@ -266,7 +268,7 @@ module.exports = function (
266
268
fs . moveSync (
267
269
path . join ( appPath , 'gitignore' ) ,
268
270
path . join ( appPath , '.gitignore' ) ,
269
- [ ]
271
+ [ ] ,
270
272
) ;
271
273
}
272
274
@@ -295,7 +297,7 @@ module.exports = function (
295
297
// '--no-audit', // https://github.com/facebook/create-react-app/issues/11174
296
298
'--save' ,
297
299
verbose && '--verbose' ,
298
- ] . filter ( e => e ) ;
300
+ ] . filter ( ( e ) => e ) ;
299
301
}
300
302
301
303
// Install additional template dependencies, if present.
@@ -307,7 +309,7 @@ module.exports = function (
307
309
args = args . concat (
308
310
dependenciesToInstall . map ( ( [ dependency , version ] ) => {
309
311
return `${ dependency } @${ version } ` ;
310
- } )
312
+ } ) ,
311
313
) ;
312
314
}
313
315
@@ -329,7 +331,7 @@ module.exports = function (
329
331
}
330
332
}
331
333
332
- if ( args . find ( arg => arg . includes ( 'typescript' ) ) ) {
334
+ if ( args . find ( ( arg ) => arg . includes ( 'typescript' ) ) ) {
333
335
console . log ( ) ;
334
336
verifyTypeScriptSetup ( ) ;
335
337
}
@@ -373,21 +375,21 @@ module.exports = function (
373
375
console . log ( ' Starts the development server.' ) ;
374
376
console . log ( ) ;
375
377
console . log (
376
- chalk . cyan ( ` ${ displayedCommand } ${ useYarn ? '' : 'run ' } build` )
378
+ chalk . cyan ( ` ${ displayedCommand } ${ useYarn ? '' : 'run ' } build` ) ,
377
379
) ;
378
380
console . log ( ' Bundles the app into static files for production.' ) ;
379
381
console . log ( ) ;
380
382
console . log ( chalk . cyan ( ` ${ displayedCommand } test` ) ) ;
381
383
console . log ( ' Starts the test runner.' ) ;
382
384
console . log ( ) ;
383
385
console . log (
384
- chalk . cyan ( ` ${ displayedCommand } ${ useYarn ? '' : 'run ' } eject` )
386
+ chalk . cyan ( ` ${ displayedCommand } ${ useYarn ? '' : 'run ' } eject` ) ,
385
387
) ;
386
388
console . log (
387
- ' Removes this tool and copies build dependencies, configuration files'
389
+ ' Removes this tool and copies build dependencies, configuration files' ,
388
390
) ;
389
391
console . log (
390
- ' and scripts into the app directory. If you do this, you can’t go back!'
392
+ ' and scripts into the app directory. If you do this, you can’t go back!' ,
391
393
) ;
392
394
console . log ( ) ;
393
395
console . log ( 'We suggest that you begin by typing:' ) ;
@@ -398,8 +400,8 @@ module.exports = function (
398
400
console . log ( ) ;
399
401
console . log (
400
402
chalk . yellow (
401
- 'You had a `README.md` file, we renamed it to `README.old.md`'
402
- )
403
+ 'You had a `README.md` file, we renamed it to `README.old.md`' ,
404
+ ) ,
403
405
) ;
404
406
}
405
407
console . log ( ) ;
0 commit comments