( client: Client, opts: Partial<Options>, args: string[], telemetry: DevTelemetryClient )
| 38 | }; |
| 39 | |
| 40 | export default async function dev( |
| 41 | client: Client, |
| 42 | opts: Partial<Options>, |
| 43 | args: string[], |
| 44 | telemetry: DevTelemetryClient |
| 45 | ) { |
| 46 | const [dir = '.'] = args; |
| 47 | let cwd = resolve(dir); |
| 48 | const listen = parseListen(opts['--listen'] || '3000'); |
| 49 | |
| 50 | cwd = await resolveProjectCwd(cwd); |
| 51 | |
| 52 | const projectNameOrId = opts['--project']; |
| 53 | |
| 54 | // retrieve dev command |
| 55 | let link = await getLinkedProject( |
| 56 | client, |
| 57 | cwd, |
| 58 | projectNameOrId, |
| 59 | !!projectNameOrId |
| 60 | ); |
| 61 | |
| 62 | if (link.status === 'not_linked' && !process.env.__VERCEL_SKIP_DEV_CMD) { |
| 63 | if (opts['--local']) { |
| 64 | output.warn( |
| 65 | 'Running dev server in local mode without a project setup:\n' + |
| 66 | ' - Environment variables will not be pulled from Vercel\n' + |
| 67 | ' - Project settings are defined by local configuration\n\n' + |
| 68 | `To link your project, run ${getCommandName('dev')} without \`-L\` or \`--local\` or ${getCommandName('link')}.` |
| 69 | ); |
| 70 | } else if (projectNameOrId) { |
| 71 | await printProjectNotFoundError(client, projectNameOrId, 'dev'); |
| 72 | return 1; |
| 73 | } else { |
| 74 | link = await setupAndLink(client, cwd, { |
| 75 | autoConfirm: opts['--yes'], |
| 76 | link, |
| 77 | successEmoji: 'link', |
| 78 | nonInteractive: client.nonInteractive, |
| 79 | }); |
| 80 | |
| 81 | if (link.status === 'not_linked') { |
| 82 | // User aborted project linking questions |
| 83 | return 0; |
| 84 | } |
| 85 | } |
| 86 | } |
| 87 | |
| 88 | if (link.status === 'error') { |
| 89 | if (link.reason === 'HEADLESS') { |
| 90 | if (client.nonInteractive) { |
| 91 | outputActionRequired( |
| 92 | client, |
| 93 | { |
| 94 | status: 'action_required', |
| 95 | reason: 'confirmation_required', |
| 96 | message: `Command ${getCommandNamePlain('dev')} requires confirmation. Use option --yes to confirm.`, |
| 97 | next: [ |
no test coverage detected