mirror of
https://github.com/LukeHagar/vercel.git
synced 2025-12-09 12:57:46 +00:00
[cli] Update NowConfig references to VercelConfig (#6256)
The `NowConfig` interface is deprecated.
This commit is contained in:
@@ -19,7 +19,7 @@ import link from '../../util/output/link';
|
|||||||
import { User } from '../../types';
|
import { User } from '../../types';
|
||||||
import { getCommandName } from '../../util/pkg-name';
|
import { getCommandName } from '../../util/pkg-name';
|
||||||
import toHost from '../../util/to-host';
|
import toHost from '../../util/to-host';
|
||||||
import { NowConfig } from '../../util/dev/types';
|
import { VercelConfig } from '../../util/dev/types';
|
||||||
|
|
||||||
type Options = {
|
type Options = {
|
||||||
'--debug': boolean;
|
'--debug': boolean;
|
||||||
@@ -421,7 +421,7 @@ function handleCreateAliasError<T>(
|
|||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getTargetsForAlias(args: string[], { alias }: NowConfig) {
|
function getTargetsForAlias(args: string[], { alias }: VercelConfig) {
|
||||||
if (args.length) {
|
if (args.length) {
|
||||||
return [args[args.length - 1]]
|
return [args[args.length - 1]]
|
||||||
.map(target => (target.indexOf('.') !== -1 ? toHost(target) : target))
|
.map(target => (target.indexOf('.') !== -1 ? toHost(target) : target))
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import chalk from 'chalk';
|
|||||||
import Client from '../client';
|
import Client from '../client';
|
||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { User } from '../../types';
|
import { User } from '../../types';
|
||||||
import { NowConfig } from '../dev/types';
|
import { VercelConfig } from '../dev/types';
|
||||||
import getDeploymentsByAppName from '../deploy/get-deployments-by-appname';
|
import getDeploymentsByAppName from '../deploy/get-deployments-by-appname';
|
||||||
import getDeploymentByIdOrHost from '../deploy/get-deployment-by-id-or-host';
|
import getDeploymentByIdOrHost from '../deploy/get-deployment-by-id-or-host';
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ export async function getDeploymentForAlias(
|
|||||||
localConfigPath: string | undefined,
|
localConfigPath: string | undefined,
|
||||||
user: User,
|
user: User,
|
||||||
contextName: string,
|
contextName: string,
|
||||||
localConfig: NowConfig
|
localConfig: VercelConfig
|
||||||
) {
|
) {
|
||||||
output.spinner(`Fetching deployment to alias in ${chalk.bold(contextName)}`);
|
output.spinner(`Fetching deployment to alias in ${chalk.bold(contextName)}`);
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import responseError from './response-error';
|
|||||||
import ua from './ua';
|
import ua from './ua';
|
||||||
import printIndications from './print-indications';
|
import printIndications from './print-indications';
|
||||||
import { AuthConfig, GlobalConfig } from '../types';
|
import { AuthConfig, GlobalConfig } from '../types';
|
||||||
import { NowConfig } from './dev/types';
|
import { VercelConfig } from './dev/types';
|
||||||
import doSsoLogin from './login/sso';
|
import doSsoLogin from './login/sso';
|
||||||
import { writeToAuthConfigFile } from './config/files';
|
import { writeToAuthConfigFile } from './config/files';
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ export interface ClientOptions {
|
|||||||
authConfig: AuthConfig;
|
authConfig: AuthConfig;
|
||||||
output: Output;
|
output: Output;
|
||||||
config: GlobalConfig;
|
config: GlobalConfig;
|
||||||
localConfig: NowConfig;
|
localConfig: VercelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default class Client extends EventEmitter {
|
export default class Client extends EventEmitter {
|
||||||
@@ -37,7 +37,7 @@ export default class Client extends EventEmitter {
|
|||||||
authConfig: AuthConfig;
|
authConfig: AuthConfig;
|
||||||
output: Output;
|
output: Output;
|
||||||
config: GlobalConfig;
|
config: GlobalConfig;
|
||||||
localConfig: NowConfig;
|
localConfig: VercelConfig;
|
||||||
|
|
||||||
constructor(opts: ClientOptions) {
|
constructor(opts: ClientOptions) {
|
||||||
super();
|
super();
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import getLocalPathConfig from './local-path';
|
|||||||
import { NowError } from '../now-error';
|
import { NowError } from '../now-error';
|
||||||
import error from '../output/error';
|
import error from '../output/error';
|
||||||
import highlight from '../output/highlight';
|
import highlight from '../output/highlight';
|
||||||
import { NowConfig } from '../dev/types';
|
import { VercelConfig } from '../dev/types';
|
||||||
import { AuthConfig, GlobalConfig } from '../../types';
|
import { AuthConfig, GlobalConfig } from '../../types';
|
||||||
|
|
||||||
const VERCEL_DIR = getGlobalPathConfig();
|
const VERCEL_DIR = getGlobalPathConfig();
|
||||||
@@ -100,8 +100,8 @@ export function getAuthConfigFilePath() {
|
|||||||
|
|
||||||
export function readLocalConfig(
|
export function readLocalConfig(
|
||||||
prefix: string = process.cwd()
|
prefix: string = process.cwd()
|
||||||
): NowConfig | null {
|
): VercelConfig | null {
|
||||||
let config: NowConfig | null = null;
|
let config: VercelConfig | null = null;
|
||||||
let target = '';
|
let target = '';
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { CantParseJSONFile } from '../errors-ts';
|
import { CantParseJSONFile } from '../errors-ts';
|
||||||
import readJSONFile from '../read-json-file';
|
import readJSONFile from '../read-json-file';
|
||||||
import { NowConfig } from '../dev/types';
|
import { VercelConfig } from '../dev/types';
|
||||||
import getLocalConfigPath from './local-path';
|
import getLocalConfigPath from './local-path';
|
||||||
|
|
||||||
export default async function readConfig(dir: string) {
|
export default async function readConfig(dir: string) {
|
||||||
@@ -13,7 +13,7 @@ export default async function readConfig(dir: string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result) {
|
if (result) {
|
||||||
return result as NowConfig;
|
return result as VercelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
import Now from '../../util';
|
import Now from '../../util';
|
||||||
import { NowConfig } from '../dev/types';
|
import { VercelConfig } from '../dev/types';
|
||||||
import { Org } from '../../types';
|
import { Org } from '../../types';
|
||||||
import ua from '../ua';
|
import ua from '../ua';
|
||||||
import { linkFolderToProject } from '../projects/link';
|
import { linkFolderToProject } from '../projects/link';
|
||||||
@@ -43,7 +43,7 @@ export default async function processDeployment({
|
|||||||
uploadStamp: () => string;
|
uploadStamp: () => string;
|
||||||
deployStamp: () => string;
|
deployStamp: () => string;
|
||||||
quiet: boolean;
|
quiet: boolean;
|
||||||
nowConfig?: NowConfig;
|
nowConfig?: VercelConfig;
|
||||||
force?: boolean;
|
force?: boolean;
|
||||||
withCache?: boolean;
|
withCache?: boolean;
|
||||||
org: Org;
|
org: Org;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import { LambdaSizeExceededError } from '../errors-ts';
|
|||||||
import DevServer from './server';
|
import DevServer from './server';
|
||||||
import { getBuilder } from './builder-cache';
|
import { getBuilder } from './builder-cache';
|
||||||
import {
|
import {
|
||||||
NowConfig,
|
VercelConfig,
|
||||||
BuildMatch,
|
BuildMatch,
|
||||||
BuildResult,
|
BuildResult,
|
||||||
BuilderInputs,
|
BuilderInputs,
|
||||||
@@ -96,7 +96,7 @@ async function createBuildProcess(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function executeBuild(
|
export async function executeBuild(
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
devServer: DevServer,
|
devServer: DevServer,
|
||||||
files: BuilderInputs,
|
files: BuilderInputs,
|
||||||
match: BuildMatch,
|
match: BuildMatch,
|
||||||
@@ -383,7 +383,7 @@ export async function executeBuild(
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function getBuildMatches(
|
export async function getBuildMatches(
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
cwd: string,
|
cwd: string,
|
||||||
output: Output,
|
output: Output,
|
||||||
devServer: DevServer,
|
devServer: DevServer,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import PCRE from 'pcre-to-regexp';
|
|||||||
import isURL from './is-url';
|
import isURL from './is-url';
|
||||||
import DevServer from './server';
|
import DevServer from './server';
|
||||||
|
|
||||||
import { NowConfig, HttpHeadersConfig, RouteResult } from './types';
|
import { VercelConfig, HttpHeadersConfig, RouteResult } from './types';
|
||||||
import { isHandler, Route, HandleValue } from '@vercel/routing-utils';
|
import { isHandler, Route, HandleValue } from '@vercel/routing-utils';
|
||||||
|
|
||||||
export function resolveRouteParameters(
|
export function resolveRouteParameters(
|
||||||
@@ -50,7 +50,7 @@ export async function devRouter(
|
|||||||
reqMethod?: string,
|
reqMethod?: string,
|
||||||
routes?: Route[],
|
routes?: Route[],
|
||||||
devServer?: DevServer,
|
devServer?: DevServer,
|
||||||
nowConfig?: NowConfig,
|
nowConfig?: VercelConfig,
|
||||||
previousHeaders?: HttpHeadersConfig,
|
previousHeaders?: HttpHeadersConfig,
|
||||||
missRoutes?: Route[],
|
missRoutes?: Route[],
|
||||||
phase?: HandleValue | null
|
phase?: HandleValue | null
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ import sleep from '../sleep';
|
|||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { relative } from '../path-helpers';
|
import { relative } from '../path-helpers';
|
||||||
import { getDistTag } from '../get-dist-tag';
|
import { getDistTag } from '../get-dist-tag';
|
||||||
import getNowConfigPath from '../config/local-path';
|
import getVercelConfigPath from '../config/local-path';
|
||||||
import { MissingDotenvVarsError } from '../errors-ts';
|
import { MissingDotenvVarsError } from '../errors-ts';
|
||||||
import cliPkg from '../pkg';
|
import cliPkg from '../pkg';
|
||||||
import { getVercelDirectory } from '../projects/link';
|
import { getVercelDirectory } from '../projects/link';
|
||||||
@@ -73,7 +73,7 @@ import errorTemplate502 from './templates/error_502';
|
|||||||
import redirectTemplate from './templates/redirect';
|
import redirectTemplate from './templates/redirect';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NowConfig,
|
VercelConfig,
|
||||||
DevServerOptions,
|
DevServerOptions,
|
||||||
BuildMatch,
|
BuildMatch,
|
||||||
BuildResult,
|
BuildResult,
|
||||||
@@ -145,7 +145,7 @@ export default class DevServer {
|
|||||||
private devServerPids: Set<number>;
|
private devServerPids: Set<number>;
|
||||||
private projectSettings?: ProjectSettings;
|
private projectSettings?: ProjectSettings;
|
||||||
|
|
||||||
private getNowConfigPromise: Promise<NowConfig> | null;
|
private getVercelConfigPromise: Promise<VercelConfig> | null;
|
||||||
private blockingBuildsPromise: Promise<void> | null;
|
private blockingBuildsPromise: Promise<void> | null;
|
||||||
private updateBuildersPromise: Promise<void> | null;
|
private updateBuildersPromise: Promise<void> | null;
|
||||||
private updateBuildersTimeout: NodeJS.Timeout | undefined;
|
private updateBuildersTimeout: NodeJS.Timeout | undefined;
|
||||||
@@ -181,7 +181,7 @@ export default class DevServer {
|
|||||||
this.inProgressBuilds = new Map();
|
this.inProgressBuilds = new Map();
|
||||||
this.devCacheDir = join(getVercelDirectory(cwd), 'cache');
|
this.devCacheDir = join(getVercelDirectory(cwd), 'cache');
|
||||||
|
|
||||||
this.getNowConfigPromise = null;
|
this.getVercelConfigPromise = null;
|
||||||
this.blockingBuildsPromise = null;
|
this.blockingBuildsPromise = null;
|
||||||
this.updateBuildersPromise = null;
|
this.updateBuildersPromise = null;
|
||||||
this.startPromise = null;
|
this.startPromise = null;
|
||||||
@@ -244,7 +244,7 @@ export default class DevServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const nowConfig = await this.getNowConfig();
|
const nowConfig = await this.getVercelConfig();
|
||||||
|
|
||||||
// Update the build matches in case an entrypoint was created or deleted
|
// Update the build matches in case an entrypoint was created or deleted
|
||||||
await this.updateBuildMatches(nowConfig);
|
await this.updateBuildMatches(nowConfig);
|
||||||
@@ -375,7 +375,7 @@ export default class DevServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async updateBuildMatches(
|
async updateBuildMatches(
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
isInitial = false
|
isInitial = false
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const fileList = this.resolveBuildFiles(this.files);
|
const fileList = this.resolveBuildFiles(this.files);
|
||||||
@@ -460,7 +460,7 @@ export default class DevServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async invalidateBuildMatches(
|
async invalidateBuildMatches(
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
updatedBuilders: string[]
|
updatedBuilders: string[]
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
if (updatedBuilders.length === 0) {
|
if (updatedBuilders.length === 0) {
|
||||||
@@ -516,25 +516,25 @@ export default class DevServer {
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
clearNowConfigPromise = () => {
|
clearVercelConfigPromise = () => {
|
||||||
this.getNowConfigPromise = null;
|
this.getVercelConfigPromise = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
getNowConfig(): Promise<NowConfig> {
|
getVercelConfig(): Promise<VercelConfig> {
|
||||||
if (this.getNowConfigPromise) {
|
if (this.getVercelConfigPromise) {
|
||||||
return this.getNowConfigPromise;
|
return this.getVercelConfigPromise;
|
||||||
}
|
}
|
||||||
this.getNowConfigPromise = this._getNowConfig();
|
this.getVercelConfigPromise = this._getVercelConfig();
|
||||||
|
|
||||||
// Clean up the promise once it has resolved
|
// Clean up the promise once it has resolved
|
||||||
const clear = this.clearNowConfigPromise;
|
const clear = this.clearVercelConfigPromise;
|
||||||
this.getNowConfigPromise.finally(clear);
|
this.getVercelConfigPromise.finally(clear);
|
||||||
|
|
||||||
return this.getNowConfigPromise;
|
return this.getVercelConfigPromise;
|
||||||
}
|
}
|
||||||
|
|
||||||
async _getNowConfig(): Promise<NowConfig> {
|
async _getVercelConfig(): Promise<VercelConfig> {
|
||||||
const configPath = getNowConfigPath(this.cwd);
|
const configPath = getVercelConfigPath(this.cwd);
|
||||||
|
|
||||||
const [
|
const [
|
||||||
pkg = null,
|
pkg = null,
|
||||||
@@ -543,10 +543,10 @@ export default class DevServer {
|
|||||||
config = { version: 2, [fileNameSymbol]: 'vercel.json' },
|
config = { version: 2, [fileNameSymbol]: 'vercel.json' },
|
||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.readJsonFile<PackageJson>('package.json'),
|
this.readJsonFile<PackageJson>('package.json'),
|
||||||
this.readJsonFile<NowConfig>(configPath),
|
this.readJsonFile<VercelConfig>(configPath),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
await this.validateNowConfig(config);
|
await this.validateVercelConfig(config);
|
||||||
const { error: routeError, routes: maybeRoutes } = getTransformedRoutes({
|
const { error: routeError, routes: maybeRoutes } = getTransformedRoutes({
|
||||||
nowConfig: config,
|
nowConfig: config,
|
||||||
});
|
});
|
||||||
@@ -634,7 +634,7 @@ export default class DevServer {
|
|||||||
config.builds.sort(sortBuilders);
|
config.builds.sort(sortBuilders);
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.validateNowConfig(config);
|
await this.validateVercelConfig(config);
|
||||||
|
|
||||||
this.caseSensitive = hasNewRoutingProperties(config);
|
this.caseSensitive = hasNewRoutingProperties(config);
|
||||||
this.apiDir = detectApiDirectory(config.builds || []);
|
this.apiDir = detectApiDirectory(config.builds || []);
|
||||||
@@ -710,8 +710,8 @@ export default class DevServer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async tryValidateOrExit(
|
async tryValidateOrExit(
|
||||||
config: NowConfig,
|
config: VercelConfig,
|
||||||
validate: (c: NowConfig) => string | null
|
validate: (c: VercelConfig) => string | null
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const message = validate(config);
|
const message = validate(config);
|
||||||
|
|
||||||
@@ -721,7 +721,7 @@ export default class DevServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async validateNowConfig(config: NowConfig): Promise<void> {
|
async validateVercelConfig(config: VercelConfig): Promise<void> {
|
||||||
if (config.version === 1) {
|
if (config.version === 1) {
|
||||||
this.output.error('Cannot run `version: 1` projects.');
|
this.output.error('Cannot run `version: 1` projects.');
|
||||||
await this.exit(1);
|
await this.exit(1);
|
||||||
@@ -855,7 +855,7 @@ export default class DevServer {
|
|||||||
.replace('[::]', 'localhost')
|
.replace('[::]', 'localhost')
|
||||||
.replace('127.0.0.1', 'localhost');
|
.replace('127.0.0.1', 'localhost');
|
||||||
|
|
||||||
const nowConfig = await this.getNowConfig();
|
const nowConfig = await this.getVercelConfig();
|
||||||
const devCommandPromise = this.runDevCommand();
|
const devCommandPromise = this.runDevCommand();
|
||||||
|
|
||||||
const files = await getFiles(this.cwd, { output: this.output });
|
const files = await getFiles(this.cwd, { output: this.output });
|
||||||
@@ -982,7 +982,7 @@ export default class DevServer {
|
|||||||
|
|
||||||
if (devProcess) {
|
if (devProcess) {
|
||||||
ops.push(
|
ops.push(
|
||||||
new Promise((resolve, reject) => {
|
new Promise<void>((resolve, reject) => {
|
||||||
devProcess.once('exit', () => resolve());
|
devProcess.once('exit', () => resolve());
|
||||||
try {
|
try {
|
||||||
process.kill(devProcess.pid);
|
process.kill(devProcess.pid);
|
||||||
@@ -1201,7 +1201,7 @@ export default class DevServer {
|
|||||||
match: BuildMatch,
|
match: BuildMatch,
|
||||||
requestPath: string | null,
|
requestPath: string | null,
|
||||||
req: http.IncomingMessage | null,
|
req: http.IncomingMessage | null,
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
previousBuildResult?: BuildResult,
|
previousBuildResult?: BuildResult,
|
||||||
filesChanged?: string[],
|
filesChanged?: string[],
|
||||||
filesRemoved?: string[]
|
filesRemoved?: string[]
|
||||||
@@ -1290,7 +1290,7 @@ export default class DevServer {
|
|||||||
this.output.debug(`${chalk.bold(method)} ${req.url}`);
|
this.output.debug(`${chalk.bold(method)} ${req.url}`);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const nowConfig = await this.getNowConfig();
|
const nowConfig = await this.getVercelConfig();
|
||||||
await this.serveProjectAsNowV2(req, res, nowRequestId, nowConfig);
|
await this.serveProjectAsNowV2(req, res, nowRequestId, nowConfig);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
@@ -1339,7 +1339,7 @@ export default class DevServer {
|
|||||||
req: http.IncomingMessage,
|
req: http.IncomingMessage,
|
||||||
res: http.ServerResponse,
|
res: http.ServerResponse,
|
||||||
nowRequestId: string,
|
nowRequestId: string,
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
routes: Route[] | undefined = nowConfig.routes,
|
routes: Route[] | undefined = nowConfig.routes,
|
||||||
callLevel: number = 0
|
callLevel: number = 0
|
||||||
) => {
|
) => {
|
||||||
@@ -1992,7 +1992,7 @@ export default class DevServer {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
async hasFilesystem(dest: string, nowConfig: NowConfig): Promise<boolean> {
|
async hasFilesystem(dest: string, nowConfig: VercelConfig): Promise<boolean> {
|
||||||
if (
|
if (
|
||||||
await findBuildMatch(
|
await findBuildMatch(
|
||||||
this.buildMatches,
|
this.buildMatches,
|
||||||
@@ -2181,7 +2181,7 @@ async function findBuildMatch(
|
|||||||
files: BuilderInputs,
|
files: BuilderInputs,
|
||||||
requestPath: string,
|
requestPath: string,
|
||||||
devServer: DevServer,
|
devServer: DevServer,
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
isFilesystem = false
|
isFilesystem = false
|
||||||
): Promise<BuildMatch | null> {
|
): Promise<BuildMatch | null> {
|
||||||
requestPath = requestPath.replace(/^\//, '');
|
requestPath = requestPath.replace(/^\//, '');
|
||||||
@@ -2219,7 +2219,7 @@ async function shouldServe(
|
|||||||
files: BuilderInputs,
|
files: BuilderInputs,
|
||||||
requestPath: string,
|
requestPath: string,
|
||||||
devServer: DevServer,
|
devServer: DevServer,
|
||||||
nowConfig: NowConfig,
|
nowConfig: VercelConfig,
|
||||||
isFilesystem = false
|
isFilesystem = false
|
||||||
): Promise<boolean> {
|
): Promise<boolean> {
|
||||||
const {
|
const {
|
||||||
@@ -2284,7 +2284,7 @@ async function findMatchingRoute(
|
|||||||
match: BuildMatch,
|
match: BuildMatch,
|
||||||
requestPath: string,
|
requestPath: string,
|
||||||
devServer: DevServer,
|
devServer: DevServer,
|
||||||
nowConfig: NowConfig
|
nowConfig: VercelConfig
|
||||||
): Promise<RouteResult | void> {
|
): Promise<RouteResult | void> {
|
||||||
const reqUrl = `/${requestPath}`;
|
const reqUrl = `/${requestPath}`;
|
||||||
for (const buildResult of match.buildResults.values()) {
|
for (const buildResult of match.buildResults.values()) {
|
||||||
@@ -2305,7 +2305,7 @@ async function findMatchingRoute(
|
|||||||
function findAsset(
|
function findAsset(
|
||||||
match: BuildMatch,
|
match: BuildMatch,
|
||||||
requestPath: string,
|
requestPath: string,
|
||||||
nowConfig: NowConfig
|
nowConfig: VercelConfig
|
||||||
): { asset: BuilderOutput; assetKey: string } | void {
|
): { asset: BuilderOutput; assetKey: string } | void {
|
||||||
if (!match.buildOutput) {
|
if (!match.buildOutput) {
|
||||||
return;
|
return;
|
||||||
@@ -2397,7 +2397,7 @@ function filterFrontendBuilds(build: Builder) {
|
|||||||
return !frontendRuntimeSet.has(name || '');
|
return !frontendRuntimeSet.has(name || '');
|
||||||
}
|
}
|
||||||
|
|
||||||
function hasNewRoutingProperties(nowConfig: NowConfig) {
|
function hasNewRoutingProperties(nowConfig: VercelConfig) {
|
||||||
return (
|
return (
|
||||||
typeof nowConfig.cleanUrls !== undefined ||
|
typeof nowConfig.cleanUrls !== undefined ||
|
||||||
typeof nowConfig.headers !== undefined ||
|
typeof nowConfig.headers !== undefined ||
|
||||||
|
|||||||
@@ -14,12 +14,12 @@ import {
|
|||||||
Lambda,
|
Lambda,
|
||||||
PackageJson,
|
PackageJson,
|
||||||
} from '@vercel/build-utils';
|
} from '@vercel/build-utils';
|
||||||
import { NowConfig } from '@vercel/client';
|
import { VercelConfig } from '@vercel/client';
|
||||||
import { HandleValue, Route } from '@vercel/routing-utils';
|
import { HandleValue, Route } from '@vercel/routing-utils';
|
||||||
import { Output } from '../output';
|
import { Output } from '../output';
|
||||||
import { ProjectEnvVariable, ProjectSettings } from '../../types';
|
import { ProjectEnvVariable, ProjectSettings } from '../../types';
|
||||||
|
|
||||||
export { NowConfig };
|
export { VercelConfig };
|
||||||
|
|
||||||
export interface DevServerOptions {
|
export interface DevServerOptions {
|
||||||
output: Output;
|
output: Output;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import {
|
|||||||
rewritesSchema,
|
rewritesSchema,
|
||||||
trailingSlashSchema,
|
trailingSlashSchema,
|
||||||
} from '@vercel/routing-utils';
|
} from '@vercel/routing-utils';
|
||||||
import { NowConfig } from './types';
|
import { VercelConfig } from './types';
|
||||||
import {
|
import {
|
||||||
functionsSchema,
|
functionsSchema,
|
||||||
buildsSchema,
|
buildsSchema,
|
||||||
@@ -36,7 +36,7 @@ const vercelConfigSchema = {
|
|||||||
const ajv = new Ajv();
|
const ajv = new Ajv();
|
||||||
const validate = ajv.compile(vercelConfigSchema);
|
const validate = ajv.compile(vercelConfigSchema);
|
||||||
|
|
||||||
export function validateConfig(config: NowConfig): NowBuildError | null {
|
export function validateConfig(config: VercelConfig): NowBuildError | null {
|
||||||
if (!validate(config)) {
|
if (!validate(config)) {
|
||||||
if (validate.errors && validate.errors[0]) {
|
if (validate.errors && validate.errors[0]) {
|
||||||
const error = validate.errors[0];
|
const error = validate.errors[0];
|
||||||
|
|||||||
@@ -9,15 +9,15 @@ import {
|
|||||||
import humanizePath from './humanize-path';
|
import humanizePath from './humanize-path';
|
||||||
import readJSONFile from './read-json-file';
|
import readJSONFile from './read-json-file';
|
||||||
import readPackage from './read-package';
|
import readPackage from './read-package';
|
||||||
import { NowConfig } from './dev/types';
|
import { VercelConfig } from './dev/types';
|
||||||
import { Output } from './output';
|
import { Output } from './output';
|
||||||
|
|
||||||
let config: NowConfig;
|
let config: VercelConfig;
|
||||||
|
|
||||||
export default async function getConfig(
|
export default async function getConfig(
|
||||||
output: Output,
|
output: Output,
|
||||||
configFile?: string
|
configFile?: string
|
||||||
): Promise<NowConfig | Error> {
|
): Promise<VercelConfig | Error> {
|
||||||
// If config was already read, just return it
|
// If config was already read, just return it
|
||||||
if (config) {
|
if (config) {
|
||||||
return config;
|
return config;
|
||||||
@@ -44,7 +44,7 @@ export default async function getConfig(
|
|||||||
return localConfig;
|
return localConfig;
|
||||||
}
|
}
|
||||||
if (localConfig !== null) {
|
if (localConfig !== null) {
|
||||||
config = localConfig as NowConfig;
|
config = localConfig as VercelConfig;
|
||||||
config[fileNameSymbol] = configFile;
|
config[fileNameSymbol] = configFile;
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -68,13 +68,13 @@ export default async function getConfig(
|
|||||||
}
|
}
|
||||||
if (vercelConfig !== null) {
|
if (vercelConfig !== null) {
|
||||||
output.debug(`Found config in file "${vercelFilePath}"`);
|
output.debug(`Found config in file "${vercelFilePath}"`);
|
||||||
config = vercelConfig as NowConfig;
|
config = vercelConfig as VercelConfig;
|
||||||
config[fileNameSymbol] = 'vercel.json';
|
config[fileNameSymbol] = 'vercel.json';
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
if (nowConfig !== null) {
|
if (nowConfig !== null) {
|
||||||
output.debug(`Found config in file "${nowFilePath}"`);
|
output.debug(`Found config in file "${nowFilePath}"`);
|
||||||
config = nowConfig as NowConfig;
|
config = nowConfig as VercelConfig;
|
||||||
config[fileNameSymbol] = 'now.json';
|
config[fileNameSymbol] = 'now.json';
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ export default async function getConfig(
|
|||||||
}
|
}
|
||||||
if (pkgConfig) {
|
if (pkgConfig) {
|
||||||
output.debug(`Found config in package ${pkgFilePath}`);
|
output.debug(`Found config in package ${pkgFilePath}`);
|
||||||
config = pkgConfig as NowConfig;
|
config = pkgConfig as VercelConfig;
|
||||||
config[fileNameSymbol] = 'package.json';
|
config[fileNameSymbol] = 'package.json';
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { join, basename } from 'path';
|
|||||||
import chalk from 'chalk';
|
import chalk from 'chalk';
|
||||||
import { remove } from 'fs-extra';
|
import { remove } from 'fs-extra';
|
||||||
import { ProjectLinkResult, ProjectSettings } from '../../types';
|
import { ProjectLinkResult, ProjectSettings } from '../../types';
|
||||||
import { NowConfig } from '../dev/types';
|
import { VercelConfig } from '../dev/types';
|
||||||
import {
|
import {
|
||||||
getLinkedProject,
|
getLinkedProject,
|
||||||
linkFolderToProject,
|
linkFolderToProject,
|
||||||
@@ -134,7 +134,7 @@ export default async function setupAndLink(
|
|||||||
return { status: 'error', exitCode: 1 };
|
return { status: 'error', exitCode: 1 };
|
||||||
}
|
}
|
||||||
|
|
||||||
let localConfig: NowConfig = {};
|
let localConfig: VercelConfig = {};
|
||||||
if (client.localConfig && !(client.localConfig instanceof Error)) {
|
if (client.localConfig && !(client.localConfig instanceof Error)) {
|
||||||
localConfig = client.localConfig;
|
localConfig = client.localConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import path from 'path';
|
import path from 'path';
|
||||||
import { CantParseJSONFile } from './errors-ts';
|
import { CantParseJSONFile } from './errors-ts';
|
||||||
import readJSONFile from './read-json-file';
|
import readJSONFile from './read-json-file';
|
||||||
import { NowConfig } from './dev/types';
|
import { VercelConfig } from './dev/types';
|
||||||
import { PackageJson } from '@vercel/build-utils';
|
import { PackageJson } from '@vercel/build-utils';
|
||||||
|
|
||||||
interface CustomPackage extends PackageJson {
|
interface CustomPackage extends PackageJson {
|
||||||
now?: NowConfig;
|
now?: VercelConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async function readPackage(file?: string) {
|
export default async function readPackage(file?: string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user