()
| 636 | } |
| 637 | |
| 638 | async _getVercelConfig(): Promise<VercelConfig> { |
| 639 | const { compileVercelConfig } = await import('../compile-vercel-config'); |
| 640 | await compileVercelConfig(this.cwd); |
| 641 | const configPath = getVercelConfigPath(this.cwd); |
| 642 | |
| 643 | const [ |
| 644 | pkg = null, |
| 645 | // The default empty `vercel.json` is used to serve all |
| 646 | // files as static when no `vercel.json` is present |
| 647 | vercelConfig = { version: 2, [fileNameSymbol]: 'vercel.json' }, |
| 648 | ] = await Promise.all([ |
| 649 | this.readJsonFile<PackageJson>('package.json'), |
| 650 | this.readJsonFile<VercelConfig>(configPath), |
| 651 | ]); |
| 652 | |
| 653 | await this.validateVercelConfig(vercelConfig); |
| 654 | |
| 655 | this.projectSettings = { |
| 656 | ...this.originalProjectSettings, |
| 657 | ...pickOverrides(vercelConfig), |
| 658 | }; |
| 659 | |
| 660 | const { error: routeError, routes: maybeRoutes } = |
| 661 | getTransformedRoutes(vercelConfig); |
| 662 | if (routeError) { |
| 663 | output.prettyError(routeError); |
| 664 | await this.exit(); |
| 665 | } |
| 666 | vercelConfig.routes = maybeRoutes || []; |
| 667 | |
| 668 | // no builds -> zero config |
| 669 | // |
| 670 | // Skip zero-config builder detection when the dev server already has |
| 671 | // resolved services (`experimentalServices`/`experimentalServicesV2`): the |
| 672 | // services orchestrator owns building and running them. Without this, |
| 673 | // `detectBuilders` runs with the remote `framework: "services"` setting but |
| 674 | // no service config threaded in, and errors with "no services declared". |
| 675 | const hasResolvedServices = !!this.services && this.services.length > 0; |
| 676 | if ( |
| 677 | !vercelConfig.experimentalServices && |
| 678 | !hasResolvedServices && |
| 679 | (!vercelConfig.builds || vercelConfig.builds.length === 0) |
| 680 | ) { |
| 681 | const featHandleMiss = true; // enable for zero config |
| 682 | const { projectSettings, cleanUrls, trailingSlash } = vercelConfig; |
| 683 | |
| 684 | const files = (await getFiles(this.cwd, {})).map(f => |
| 685 | relative(this.cwd, f) |
| 686 | ); |
| 687 | |
| 688 | const detectedBuilders = await detectBuilders(files, pkg, { |
| 689 | tag: 'latest', |
| 690 | functions: vercelConfig.functions, |
| 691 | projectSettings: projectSettings || this.projectSettings, |
| 692 | featHandleMiss, |
| 693 | cleanUrls, |
| 694 | trailingSlash, |
| 695 | workPath: this.cwd, |
no test coverage detected