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
5 changes: 5 additions & 0 deletions .changeset/light-insects-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@opennextjs/cloudflare": patch
---

feat: `upload` command for worker versions'
7 changes: 5 additions & 2 deletions packages/cloudflare/src/cli/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Arguments = (
minify: boolean;
}
| {
command: "preview" | "deploy";
command: "preview" | "deploy" | "upload";
passthroughArgs: string[];
}
| {
Expand Down Expand Up @@ -53,6 +53,7 @@ export function getArgs(): Arguments {
};
case "preview":
case "deploy":
case "upload":
return {
command: positionals[0],
outputDir,
Expand All @@ -69,7 +70,9 @@ export function getArgs(): Arguments {
environment: getWranglerEnvironmentFlag(passthroughArgs),
};
default:
throw new Error("Error: invalid command, expected 'build' | 'preview' | 'deploy' | 'populateCache'");
throw new Error(
"Error: invalid command, expected 'build' | 'preview' | 'deploy' | 'upload' | 'populateCache'"
);
}
}

Expand Down
18 changes: 18 additions & 0 deletions packages/cloudflare/src/cli/commands/upload.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { BuildOptions } from "@opennextjs/aws/build/helper.js";
import { OpenNextConfig } from "@opennextjs/aws/types/open-next.js";

import { getWranglerEnvironmentFlag, runWrangler } from "../utils/run-wrangler.js";
import { populateCache } from "./populate-cache.js";

export async function upload(
options: BuildOptions,
config: OpenNextConfig,
uploadOptions: { passthroughArgs: string[] }
) {
await populateCache(options, config, {
target: "remote",
environment: getWranglerEnvironmentFlag(uploadOptions.passthroughArgs),
});

runWrangler(options, ["versions upload", ...uploadOptions.passthroughArgs], { logging: "all" });
}
3 changes: 3 additions & 0 deletions packages/cloudflare/src/cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { createOpenNextConfigIfNotExistent, ensureCloudflareConfig } from "./bui
import { deploy } from "./commands/deploy.js";
import { populateCache } from "./commands/populate-cache.js";
import { preview } from "./commands/preview.js";
import { upload } from "./commands/upload.js";

const nextAppDir = process.cwd();

Expand Down Expand Up @@ -43,6 +44,8 @@ async function runCommand(args: Arguments) {
return preview(options, config, args);
case "deploy":
return deploy(options, config, args);
case "upload":
return upload(options, config, args);
case "populateCache":
return populateCache(options, config, args);
}
Expand Down