-
Notifications
You must be signed in to change notification settings - Fork 433
Feat: use framework info #1704
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
Feat: use framework info #1704
Changes from all commits
03c434b
54f2344
9f697f9
3b70530
5dd4c18
2577c75
80d391d
c954cf1
1a18528
154ef97
1d4374e
b32abba
ff73065
39afead
706df6a
d4708cb
fab41c8
1e0e5ef
2e78cad
2aa90a0
f748ace
2d1700b
21efa2d
ae4ddfb
350fde5
89127c8
0671ee6
e170646
80bda0c
bfbb432
ed6cae1
8f9bdb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,7 +12,7 @@ const waitPort = require('wait-port') | |
|
|
||
| const { startFunctionsServer } = require('../../lib/functions/server') | ||
| const Command = require('../../utils/command') | ||
| const { serverSettings } = require('../../utils/detect-server') | ||
| const { detectServerSettings } = require('../../utils/detect-server-settings') | ||
| const { getSiteInformation, injectEnvVariables } = require('../../utils/dev') | ||
| const { startLiveTunnel } = require('../../utils/live-tunnel') | ||
| const { NETLIFYDEV, NETLIFYDEVLOG, NETLIFYDEVWARN, NETLIFYDEVERR } = require('../../utils/logo') | ||
|
|
@@ -31,7 +31,7 @@ const startStaticServer = async ({ settings, log }) => { | |
| }) | ||
|
|
||
| await promisify(server.start.bind(server))() | ||
| log(`\n${NETLIFYDEVLOG} Server listening to`, settings.frameworkPort) | ||
| log(`\n${NETLIFYDEVLOG} Static server listening to`, settings.frameworkPort) | ||
| } | ||
|
|
||
| const isNonExistingCommandError = ({ command, error }) => { | ||
|
|
@@ -53,14 +53,14 @@ const isNonExistingCommandError = ({ command, error }) => { | |
| } | ||
|
|
||
| const startFrameworkServer = async function ({ settings, log, exit }) { | ||
| if (settings.noCmd) { | ||
| if (settings.useStaticServer) { | ||
| return await startStaticServer({ settings, log }) | ||
| } | ||
|
|
||
| log(`${NETLIFYDEVLOG} Starting Netlify Dev with ${settings.framework || 'custom config'}`) | ||
|
|
||
| // we use reject=false to avoid rejecting synchronously when the command doesn't exist | ||
| const frameworkProcess = execa(settings.command, settings.args, { preferLocal: true, reject: false }) | ||
| const frameworkProcess = execa.command(settings.command, { preferLocal: true, reject: false }) | ||
|
Contributor
Author
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.
|
||
| frameworkProcess.stdout.pipe(stripAnsiCc.stream()).pipe(process.stdout) | ||
| frameworkProcess.stderr.pipe(stripAnsiCc.stream()).pipe(process.stderr) | ||
| process.stdin.pipe(frameworkProcess.stdin) | ||
|
|
@@ -70,17 +70,17 @@ const startFrameworkServer = async function ({ settings, log, exit }) { | |
| // eslint-disable-next-line promise/catch-or-return,promise/prefer-await-to-then | ||
| frameworkProcess.then(async () => { | ||
| const result = await frameworkProcess | ||
| const [commandWithoutArgs] = settings.command.split(' ') | ||
| // eslint-disable-next-line promise/always-return | ||
| if (result.failed && isNonExistingCommandError({ command: settings.command, error: result })) { | ||
| if (result.failed && isNonExistingCommandError({ command: commandWithoutArgs, error: result })) { | ||
| log( | ||
| NETLIFYDEVERR, | ||
| `Failed launching framework server. Please verify ${chalk.magenta(`'${settings.command}'`)} exists`, | ||
| `Failed launching framework server. Please verify ${chalk.magenta(`'${commandWithoutArgs}'`)} exists`, | ||
| ) | ||
| } else { | ||
| const commandWithArgs = `${settings.command} ${settings.args.join(' ')}` | ||
| const errorMessage = result.failed | ||
| ? `${NETLIFYDEVERR} ${result.shortMessage}` | ||
| : `${NETLIFYDEVWARN} "${commandWithArgs}" exited with code ${result.exitCode}` | ||
| : `${NETLIFYDEVWARN} "${settings.command}" exited with code ${result.exitCode}` | ||
|
|
||
| log(`${errorMessage}. Shutting down Netlify Dev server`) | ||
| } | ||
|
|
@@ -98,7 +98,7 @@ const startFrameworkServer = async function ({ settings, log, exit }) { | |
| port: settings.frameworkPort, | ||
| output: 'silent', | ||
| timeout: FRAMEWORK_PORT_TIMEOUT, | ||
| ...(settings.disableLocalServerPolling ? {} : { protocol: 'http' }), | ||
| ...(settings.pollingStrategies.includes('HTTP') && { protocol: 'http' }), | ||
| }) | ||
|
|
||
| if (!open) { | ||
|
|
@@ -208,7 +208,7 @@ class DevCommand extends Command { | |
|
|
||
| let settings = {} | ||
| try { | ||
| settings = await serverSettings(devConfig, flags, site.root, log) | ||
| settings = await detectServerSettings(devConfig, flags, site.root, log) | ||
| } catch (error) { | ||
| log(NETLIFYDEVERR, error.message) | ||
| exit(1) | ||
|
|
@@ -249,7 +249,11 @@ DevCommand.description = `Local dev server | |
| The dev command will run a local dev server with Netlify's proxy and redirect rules | ||
| ` | ||
|
|
||
| DevCommand.examples = ['$ netlify dev', '$ netlify dev -c "yarn start"', '$ netlify dev -c hugo'] | ||
| DevCommand.examples = [ | ||
| '$ netlify dev', | ||
| '$ netlify dev -d public', | ||
| '$ netlify dev -c "hugo server -w" --targetPort 1313', | ||
| ] | ||
|
|
||
| DevCommand.strict = false | ||
|
|
||
|
|
||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.