Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(vercel): write vercel.json as a part of setup #10355

Merged
merged 3 commits into from
Apr 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 43 additions & 11 deletions packages/cli/src/commands/setup/deploy/providers/vercel.js
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
// import terminalLink from 'terminal-link'
import path from 'path'

import { Listr } from 'listr2'

import { recordTelemetryAttributes } from '@redwoodjs/cli-helpers'
import { errorTelemetry } from '@redwoodjs/telemetry'

import { printSetupNotes } from '../../../../lib'
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'

const notes = [
'You are ready to deploy to Vercel!',
'See: https://redwoodjs.com/docs/deploy#vercel-deploy',
]

export const handler = async () => {
export async function handler(options) {
recordTelemetryAttributes({
command: 'setup deploy vercel',
})
const tasks = new Listr([updateApiURLTask('/api'), printSetupNotes(notes)], {
rendererOptions: { collapseSubtasks: false },
})

const tasks = new Listr(
[
updateApiURLTask('/api'),
writeVercelConfigTask({ overwriteExisting: options.force }),
printSetupNotes(notes),
],
{
rendererOptions: { collapseSubtasks: false },
},
)

try {
await tasks.run()
} catch (e) {
Expand All @@ -31,3 +36,30 @@ export const handler = async () => {
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',
]
Loading