UNPKG

940 BJavaScriptView Raw
1const { hasRequiredDeps, hasRequiredFiles, getYarnOrNPMCommand, scanScripts } = require('./utils/jsdetect')
2module.exports = function() {
3 // REQUIRED FILES
4 if (!hasRequiredFiles(['package.json', 'static.config.js'])) return false
5 // REQUIRED DEPS
6 if (!hasRequiredDeps(['react-static'])) return false
7
8 /** everything below now assumes that we are within react-static */
9
10 const possibleArgsArrs = scanScripts({
11 preferredScriptsArr: ['start', 'develop', 'dev'],
12 preferredCommand: 'react-static start'
13 })
14
15 if (possibleArgsArrs.length === 0) {
16 // ofer to run it when the user doesnt have any scripts setup! 🤯
17 possibleArgsArrs.push(['react-static', 'start'])
18 }
19 return {
20 type: 'react-static',
21 command: getYarnOrNPMCommand(),
22 port: 8888,
23 proxyPort: 3000,
24 env: { ...process.env },
25 possibleArgsArrs,
26 urlRegexp: new RegExp(`(http://)([^:]+:)${3000}(/)?`, 'g'),
27 dist: 'dist'
28 }
29}