MCPcopy Create free account
hub / github.com/vercel/vercel / dev

Function dev

packages/cli/src/commands/dev/dev.ts:40–307  ·  view source on GitHub ↗
(
  client: Client,
  opts: Partial<Options>,
  args: string[],
  telemetry: DevTelemetryClient
)

Source from the content-addressed store, hash-verified

38};
39
40export 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: [

Callers 3

help.test.tsFile · 0.85
index.test.tsFile · 0.85
mainFunction · 0.85

Calls 15

runDevCommandMethod · 0.95
startMethod · 0.95
parseListenFunction · 0.90
resolveProjectCwdFunction · 0.90
getLinkedProjectFunction · 0.90
getCommandNameFunction · 0.90
outputActionRequiredFunction · 0.90
getCommandNamePlainFunction · 0.90
buildCommandWithYesFunction · 0.90
findRepoRootFunction · 0.90
pullEnvRecordsFunction · 0.90

Tested by

no test coverage detected