@@ -13,7 +13,7 @@ const log = rootLogger.child('build')
13
13
/**
14
14
* If you add a new deploy target, please start by adding a new item to the `SUPPORTED_DEPLOY_TARGETS`
15
15
*/
16
- const SUPPORTED_DEPLOY_TARGETS = [ 'now ' , 'heroku' ] as const
16
+ const SUPPORTED_DEPLOY_TARGETS = [ 'vercel ' , 'heroku' ] as const
17
17
18
18
export const formattedSupportedDeployTargets = SUPPORTED_DEPLOY_TARGETS . map ( ( t ) => `"${ t } "` ) . join ( ', ' )
19
19
@@ -40,7 +40,7 @@ export function normalizeTarget(inputDeployTarget: string | undefined): Supporte
40
40
}
41
41
42
42
const TARGET_TO_BUILD_OUTPUT : Record < SupportedTargets , string > = {
43
- now : 'dist' ,
43
+ vercel : 'dist' ,
44
44
heroku : DEFAULT_BUILD_FOLDER_PATH_RELATIVE_TO_PROJECT_ROOT ,
45
45
}
46
46
@@ -54,7 +54,7 @@ export function computeBuildOutputFromTarget(target: SupportedTargets | null) {
54
54
55
55
type ValidatorResult = { valid : boolean }
56
56
const TARGET_VALIDATORS : Record < SupportedTargets , ( layout : Layout ) => ValidatorResult > = {
57
- now : validateNow ,
57
+ vercel : validateVercel ,
58
58
heroku : validateHeroku ,
59
59
}
60
60
@@ -63,30 +63,29 @@ export function validateTarget(target: SupportedTargets, layout: Layout): Valida
63
63
return validator ( layout )
64
64
}
65
65
66
- interface NowJson {
66
+ interface VercelJson {
67
67
version : 1 | 2
68
68
name : string
69
69
builds ?: Array < { src : string ; use : string } >
70
70
routes ?: Array < { src : string ; dest : string } >
71
71
}
72
72
73
73
/**
74
- * Validate the user's now configuration file.
74
+ * Validate the user's vercel configuration file.
75
75
*/
76
- function validateNow ( layout : Layout ) : ValidatorResult {
77
- const maybeNowJson = findFileRecurisvelyUpwardSync ( 'now .json' , { cwd : layout . projectRoot } )
76
+ function validateVercel ( layout : Layout ) : ValidatorResult {
77
+ const maybeVercelJson = findFileRecurisvelyUpwardSync ( 'vercel .json' , { cwd : layout . projectRoot } )
78
78
const startModulePath = `${ layout . build . tsOutputDir } /${ START_MODULE_NAME } .js`
79
79
let isValid = true
80
80
81
- // Make sure there's a now .json file
82
- if ( ! maybeNowJson ) {
83
- log . trace ( 'creating now .json because none exists yet' )
81
+ // Make sure there's a vercel .json file
82
+ if ( ! maybeVercelJson ) {
83
+ log . trace ( 'creating vercel .json because none exists yet' )
84
84
const projectName = layout . packageJson ?. content . name ?? 'now_rename_me'
85
85
86
- const nowJsonContent = stripIndent `
86
+ const vercelJsonContent = stripIndent `
87
87
{
88
88
"version": 2,
89
- "name": "${ projectName } ",
90
89
"builds": [
91
90
{
92
91
"src": "${ startModulePath } ",
@@ -96,38 +95,38 @@ function validateNow(layout: Layout): ValidatorResult {
96
95
"routes": [{ "src": "/.*", "dest": "${ startModulePath } " }]
97
96
}
98
97
`
99
- const nowJsonPath = Path . join ( layout . projectRoot , 'now .json' )
100
- fs . write ( nowJsonPath , nowJsonContent )
101
- log . warn ( `No \`now .json\` file were found. We scaffolded one for you in ${ nowJsonPath } ` )
98
+ const vercelJsonPath = Path . join ( layout . projectRoot , 'vercel .json' )
99
+ fs . write ( vercelJsonPath , vercelJsonContent )
100
+ log . warn ( `No \`vercel .json\` file were found. We scaffolded one for you in ${ vercelJsonPath } ` )
102
101
} else {
103
- const nowJson : NowJson = fs . read ( maybeNowJson . path , 'json' )
102
+ const vercelJson : VercelJson = fs . read ( maybeVercelJson . path , 'json' )
104
103
105
- // Make sure the now .json file has the right `builds` values
104
+ // Make sure the vercel .json file has the right `builds` values
106
105
if (
107
- ! nowJson . builds ||
108
- ! nowJson . builds . find (
109
- ( build ) => Path . join ( maybeNowJson . dir , build . src ) === startModulePath && build . use === '@now/node'
106
+ ! vercelJson . builds ||
107
+ ! vercelJson . builds . find (
108
+ ( build ) => Path . join ( maybeVercelJson . dir , build . src ) === startModulePath && build . use === '@now/node'
110
109
)
111
110
) {
112
- log . error ( `We could not find a proper builder in your \`now .json\` file` )
113
- log . error ( `Found: "builds": ${ JSON . stringify ( nowJson . builds ) } ` )
111
+ log . error ( `We could not find a proper builder in your \`vercel .json\` file` )
112
+ log . error ( `Found: "builds": ${ JSON . stringify ( vercelJson . builds ) } ` )
114
113
log . error ( `Expected: "builds": [{ src: "${ startModulePath } ", use: '@now/node' }, ...]` )
115
114
console . log ( '\n' )
116
115
isValid = false
117
116
}
118
117
119
- // Make sure the now .json file has a `routes` property
120
- if ( ! nowJson . routes ) {
121
- log . error ( `We could not find a \`routes\` property in your \`now .json\` file.` )
118
+ // Make sure the vercel .json file has a `routes` property
119
+ if ( ! vercelJson . routes ) {
120
+ log . error ( `We could not find a \`routes\` property in your \`vercel .json\` file.` )
122
121
log . error ( `Expected: "routes": [{ "src": "/.*", "dest": "${ startModulePath } " }]` )
123
122
console . log ( '\n' )
124
123
isValid = false
125
124
}
126
125
127
- // Make sure the now .json file has the right `routes` values
128
- if ( ! nowJson . routes ?. find ( ( route ) => Path . join ( maybeNowJson . dir , route . dest ) === startModulePath ) ) {
129
- log . error ( `We could not find a route property that redirects to your api in your \`now .json\` file.` )
130
- log . error ( `Found: "routes": ${ JSON . stringify ( nowJson . routes ) } ` )
126
+ // Make sure the vercel .json file has the right `routes` values
127
+ if ( ! vercelJson . routes ?. find ( ( route ) => Path . join ( maybeVercelJson . dir , route . dest ) === startModulePath ) ) {
128
+ log . error ( `We could not find a route property that redirects to your api in your \`vercel .json\` file.` )
129
+ log . error ( `Found: "routes": ${ JSON . stringify ( vercelJson . routes ) } ` )
131
130
log . error ( `Expected: "routes": [{ src: '/.*', dest: "${ startModulePath } " }, ...]` )
132
131
console . log ( '\n' )
133
132
isValid = false
@@ -216,7 +215,7 @@ function validateHeroku(layout: Layout): ValidatorResult {
216
215
}
217
216
218
217
const TARGET_TO_POST_BUILD_MESSAGE : Record < SupportedTargets , string > = {
219
- now : `Please run \`now \` to deploy your nexus server. Your endpoint will be available at http://<id>.now.sh/graphql` ,
218
+ vercel : `Please run \`vercel\` or \`vc \` to deploy your nexus server. Your endpoint will be available at http://<id>.now.sh/graphql` ,
220
219
heroku : `\
221
220
Please run the following commands to deploy to heroku:
222
221
0 commit comments