Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 7 additions & 5 deletions packages/void/src/cli/deploy-cloudflare-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
import { DEPLOY_BINDING_IDENTITY_FIELDS, bindingIdentityKey } from './deploy-binding-snapshot.ts';
import type { CloudflareDeploySource, CloudflarePreflight } from './deploy-cloudflare-preflight.ts';
import { prepareCloudflareFrameworkArtifact } from './deploy-cloudflare-static.ts';
import { log, getExitCode } from './deploy-helpers.ts';
import { log, getExitCode, resolveFullDeployBuildCommand } from './deploy-helpers.ts';
import {
validateAuthMigrationSchema,
assertRemoteMigrationsDeployable,
Expand All @@ -35,7 +35,7 @@ import {
} from './deploy-transport.ts';
import { type CloudflareDeployDeps } from './deploy-types.ts';
import { getErrorMessage } from './output.ts';
import { resolveProjectCommand, type FrameworkPreset } from './preset.ts';
import { type FrameworkPreset } from './preset.ts';
import { deleteEnvVarCaseAware } from './provision.ts';

export type CloudflareBuild = Awaited<ReturnType<typeof buildCloudflareWorker>>;
Expand Down Expand Up @@ -96,9 +96,11 @@ export async function buildCloudflareWorker(input: {
const runBuild =
deps.runBuild ??
((env: NodeJS.ProcessEnv) => {
const command = frameworkPreset
? (voidConfig.inference?.build ?? resolveProjectCommand(root, frameworkPreset.buildCommand))
: resolveProjectCommand(root, 'vite build');
const command = resolveFullDeployBuildCommand(
root,
voidConfig.inference?.build,
frameworkPreset?.buildCommand,
).command;
execSync(command, { cwd: root, stdio: 'inherit', env });
});
// The build runs project code without credentials, but it can edit files, including the
Expand Down
5 changes: 3 additions & 2 deletions packages/void/src/cli/deploy-helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,13 +316,14 @@ export function resolveStaticBuildCommand(
export function resolveFullDeployBuildCommand(
root: string,
buildOverride?: string,
fallbackBuildCommand = 'vite build',
): { label: string; command: string } {
if (buildOverride) {
return { label: buildOverride, command: buildOverride };
}
return {
label: formatProjectCommand(root, 'vite build'),
command: resolveProjectCommand(root, 'vite build'),
label: formatProjectCommand(root, fallbackBuildCommand),
command: resolveProjectCommand(root, fallbackBuildCommand),
};
}

Expand Down
15 changes: 15 additions & 0 deletions packages/void/test/unit/deploy-project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,12 @@ describe('resolveFullDeployBuildCommand', () => {
});
});

it('prefers inference.build over a framework build fallback', () => {
expect(
resolveFullDeployBuildCommand(root, 'vp build', FRAMEWORK_PRESETS.nuxt.buildCommand),
).toEqual({ label: 'vp build', command: 'vp build' });
});

it.each([undefined, ''])(
'falls back to the built-in vite build for inference.build %j',
(build) => {
Expand All @@ -406,6 +412,15 @@ describe('resolveFullDeployBuildCommand', () => {
});
},
);

it('uses a framework build command as the fallback when provided', () => {
expect(
resolveFullDeployBuildCommand(root, undefined, FRAMEWORK_PRESETS.nuxt.buildCommand),
).toEqual({
label: formatProjectCommand(root, FRAMEWORK_PRESETS.nuxt.buildCommand),
command: resolveProjectCommand(root, FRAMEWORK_PRESETS.nuxt.buildCommand),
});
});
});

describe('resolveStaticDeployPreset', () => {
Expand Down