-
Notifications
You must be signed in to change notification settings - Fork 994
/
vercel.js
65 lines (55 loc) · 1.45 KB
/
vercel.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import path from 'path'
import { Listr } from 'listr2'
import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
import { errorTelemetry } from '@redwoodjs/telemetry'
import { getPaths, printSetupNotes, writeFile } from '../../../../lib'
import c from '../../../../lib/colors'
import { updateApiURLTask } from '../helpers'
export const command = 'vercel'
export const description = 'Setup Vercel deploy'
export async function handler(options) {
recordTelemetryAttributes({
command: 'setup deploy vercel',
})
const tasks = new Listr(
[
updateApiURLTask('/api'),
writeVercelConfigTask({ overwriteExisting: options.force }),
printSetupNotes(notes),
],
{
rendererOptions: { collapseSubtasks: false },
},
)
try {
await tasks.run()
} catch (e) {
errorTelemetry(process.argv, e.message)
console.error(c.error(e.message))
process.exit(e?.exitCode || 1)
}
}
function writeVercelConfigTask({ overwriteExisting = false } = {}) {
return {
title: 'Writing vercel.json...',
task: (_ctx, task) => {
writeFile(
path.join(getPaths().base, 'vercel.json'),
JSON.stringify(vercelConfig, null, 2),
{ overwriteExisting },
task,
)
},
}
}
const vercelConfig = {
build: {
env: {
ENABLE_EXPERIMENTAL_COREPACK: '1',
},
},
}
const notes = [
'You are ready to deploy to Vercel!',
'See: https://redwoodjs.com/docs/deploy#vercel-deploy',
]