From 12a1f7502972a214890365b4441bab37c0c41a65 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Fri, 27 Dec 2024 15:08:13 +0100 Subject: [PATCH] update location of output path in success message (#208) --- .changeset/unlucky-spiders-lay.md | 5 +++++ packages/cloudflare/src/cli/build/bundle-server.ts | 12 +++++++++++- .../patches/investigated/copy-package-cli-files.ts | 5 +++-- 3 files changed, 19 insertions(+), 3 deletions(-) create mode 100644 .changeset/unlucky-spiders-lay.md diff --git a/.changeset/unlucky-spiders-lay.md b/.changeset/unlucky-spiders-lay.md new file mode 100644 index 00000000..75a233d3 --- /dev/null +++ b/.changeset/unlucky-spiders-lay.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +update location of output path in success message diff --git a/packages/cloudflare/src/cli/build/bundle-server.ts b/packages/cloudflare/src/cli/build/bundle-server.ts index 6af72db6..158590bd 100644 --- a/packages/cloudflare/src/cli/build/bundle-server.ts +++ b/packages/cloudflare/src/cli/build/bundle-server.ts @@ -124,7 +124,7 @@ globalThis.__BUILD_TIMESTAMP_MS__ = ${Date.now()}; ); } - console.log(`\x1b[35mWorker saved in \`${openNextServerBundle}\` 🚀\n\x1b[0m`); + console.log(`\x1b[35mWorker saved in \`${getOutputWorkerPath(openNextOptions)}\` 🚀\n\x1b[0m`); } /** @@ -220,3 +220,13 @@ async function patchCodeWithValidations( console.log(`All ${patches.length} patches applied\n`); return patchedCode; } + +/** + * Gets the path of the worker.js file generated by the build process + * + * @param openNextOptions the open-next build options + * @returns the path of the worker.js file that the build process generates + */ +export function getOutputWorkerPath(openNextOptions: BuildOptions): string { + return path.join(openNextOptions.outputDir, "worker.js"); +} diff --git a/packages/cloudflare/src/cli/build/patches/investigated/copy-package-cli-files.ts b/packages/cloudflare/src/cli/build/patches/investigated/copy-package-cli-files.ts index 818bcbdd..e0cb6931 100644 --- a/packages/cloudflare/src/cli/build/patches/investigated/copy-package-cli-files.ts +++ b/packages/cloudflare/src/cli/build/patches/investigated/copy-package-cli-files.ts @@ -4,11 +4,12 @@ import path from "node:path"; import type { BuildOptions } from "@opennextjs/aws/build/helper.js"; import { Config } from "../../../config.js"; +import { getOutputWorkerPath } from "../../bundle-server.js"; /** * Copies the template files present in the cloudflare adapter package into the standalone node_modules folder */ -export function copyPackageCliFiles(packageDistDir: string, config: Config, openNextConfig: BuildOptions) { +export function copyPackageCliFiles(packageDistDir: string, config: Config, openNextOptions: BuildOptions) { console.log("# copyPackageTemplateFiles"); const sourceDir = path.join(packageDistDir, "cli"); const destinationDir = path.join(config.paths.internal.package, "cli"); @@ -17,6 +18,6 @@ export function copyPackageCliFiles(packageDistDir: string, config: Config, open fs.copyFileSync( path.join(packageDistDir, "cli", "templates", "worker.js"), - path.join(openNextConfig.outputDir, "worker.js") + getOutputWorkerPath(openNextOptions) ); }