buildflow

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 1, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package buildflow is the single entry point for "prepare a Next.js project for deployment". Both `nextdeploy build` and `nextdeploy ship` call Run; ship continues on to deploy, build exits.

Why this exists: until this consolidation, build and ship had divergent pre-deploy contracts.

  • `nextdeploy build` validated output mode + features and produced a VPS tarball, but never invoked `next build` itself.
  • `nextdeploy ship` only ran `next build` for the Cloudflare path (forcing --webpack), and skipped the build-side validations entirely.

The result was inconsistent pre-conditions across the three deployment targets (VPS, AWS Lambda, Cloudflare Worker) and two places where "should we rebuild?" / "is this output valid?" logic lived. Run owns both questions for every target.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Opts

type Opts struct {
	// ProjectDir is the working directory containing package.json and
	// next.config.*. Defaults to "." when empty.
	ProjectDir string

	// Cfg drives target-aware behavior. Required.
	Cfg *config.NextDeployConfig

	// Force bypasses the incremental skip (git-commit unchanged → no
	// rebuild). Wired to `nextdeploy build --force`. Ship always passes
	// false because shipping with an unverified-stale build is a footgun.
	Force bool

	// Log receives lifecycle messages. Required.
	Log *shared.Logger
}

Opts configures a single Run invocation.

type Result

type Result struct {
	Payload nextcore.NextCorePayload

	// EffectiveTarget is the target this build was prepared for —
	// "serverless" or "vps". Resolved from Cfg + payload.
	EffectiveTarget string

	// StandaloneDir is the path to .next/standalone. Populated when
	// OutputMode is standalone (required for serverless, common for VPS).
	StandaloneDir string

	// ReleaseDir / TarballPath are populated only on the VPS path —
	// the artifact `nextdeploy ship` uploads to the remote daemon.
	ReleaseDir  string
	TarballPath string

	// Skipped is true when the incremental check matched and no rebuild
	// was attempted. `nextdeploy build` treats this as "exit success";
	// ship treats it as "use the existing artifacts".
	Skipped bool
}

Result is the artifact set produced by a Run.

func Run

func Run(ctx context.Context, opts Opts) (*Result, error)

Run executes the unified build flow:

  1. Incremental skip (unless Force): if git commit is unchanged, return early with a fresh metadata payload.
  2. Generate metadata (nextcore.GenerateMetadata) — reads next.config and the routes/prerender manifests.
  3. Validate output mode + features against the resolved target.
  4. Decide whether `next build` needs to run, and with which flags (Cloudflare requires --webpack; AWS / VPS take the user's default).
  5. For VPS: copy public/ + static/ + metadata.json into the release directory and create app.tar.gz.
  6. Audit the standalone tree — informational warnings for size.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL