1 | const { hasRequiredDeps, hasRequiredFiles, getYarnOrNPMCommand, scanScripts } = require('./utils/jsdetect')
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | module.exports = function() {
|
7 |
|
8 | if (!hasRequiredFiles(['package.json'])) return false
|
9 |
|
10 | if (!hasRequiredDeps(['react-scripts'])) return false
|
11 |
|
12 |
|
13 |
|
14 | const possibleArgsArrs = scanScripts({
|
15 | preferredScriptsArr: ['start', 'serve', 'run'],
|
16 | preferredCommand: 'react-scripts start'
|
17 | })
|
18 |
|
19 | if (possibleArgsArrs.length === 0) {
|
20 |
|
21 | possibleArgsArrs.push(['react-scripts', 'start'])
|
22 | }
|
23 |
|
24 | return {
|
25 | type: 'create-react-app',
|
26 | command: getYarnOrNPMCommand(),
|
27 | port: 8888,
|
28 | proxyPort: 3000,
|
29 | env: { ...process.env, BROWSER: 'none', PORT: 3000 },
|
30 | stdio: ['inherit', 'pipe', 'pipe'],
|
31 | possibleArgsArrs,
|
32 | urlRegexp: new RegExp(`(http://)([^:]+:)${3000}(/)?`, 'g'),
|
33 | dist: 'public'
|
34 | }
|
35 | }
|