|
@ -23,6 +23,9 @@ const Agent = require('./agent'); |
|
|
const readMetaData = require('./read-metadata'); |
|
|
const readMetaData = require('./read-metadata'); |
|
|
const toHost = require('./to-host'); |
|
|
const toHost = require('./to-host'); |
|
|
|
|
|
|
|
|
|
|
|
// Helpers
|
|
|
|
|
|
const { error } = require('./error'); |
|
|
|
|
|
|
|
|
// How many concurrent HTTP/2 stream uploads
|
|
|
// How many concurrent HTTP/2 stream uploads
|
|
|
const MAX_CONCURRENT = 10; |
|
|
const MAX_CONCURRENT = 10; |
|
|
|
|
|
|
|
@ -77,6 +80,18 @@ module.exports = class Now extends EventEmitter { |
|
|
const opts = { debug: this._debug, hasNowJson }; |
|
|
const opts = { debug: this._debug, hasNowJson }; |
|
|
if (deploymentType === 'npm') { |
|
|
if (deploymentType === 'npm') { |
|
|
files = await getNpmFiles(path, pkg, nowConfig, opts); |
|
|
files = await getNpmFiles(path, pkg, nowConfig, opts); |
|
|
|
|
|
|
|
|
|
|
|
// A `start` or `now-start` npm script, or a `server.js` file
|
|
|
|
|
|
// in the root directory of the deployment are required
|
|
|
|
|
|
if (!hasNpmStart(pkg) && !hasFile(path, files, 'server.js')) { |
|
|
|
|
|
error( |
|
|
|
|
|
'Missing `start` (or `now-start`) script in `package.json`. ' + |
|
|
|
|
|
'See: https://docs.npmjs.com/cli/start.' |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
// eslint-disable-next-line unicorn/no-process-exit
|
|
|
|
|
|
process.exit(1); |
|
|
|
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
files = await getDockerFiles(path, nowConfig, opts); |
|
|
files = await getDockerFiles(path, nowConfig, opts); |
|
|
} |
|
|
} |
|
@ -989,3 +1004,12 @@ async function responseError(res) { |
|
|
|
|
|
|
|
|
return err; |
|
|
return err; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hasNpmStart(pkg) { |
|
|
|
|
|
return pkg.scripts && (pkg.scripts.start || pkg.scripts['now-start']); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function hasFile(base, files, name) { |
|
|
|
|
|
const relative = files.map(file => toRelative(file, base)); |
|
|
|
|
|
return relative.indexOf(name) !== -1; |
|
|
|
|
|
} |
|
|