import path from "pathe";
import { getPackageManagerRunner } from "../../util/detect-package-manager.js";
import { spreadBuildProps, spreadDevProps, Website, } from "../website.js";
/**
 * Creates and deploys a Nuxt application using the Cloudflare Workers preset.
 *
 * This resource simplifies deploying Nuxt applications by providing sensible
 * defaults for the build command, main entrypoint, and assets directory
 * based on the `cloudflare-module` preset output.
 *
 * It wraps the underlying `Website` resource.
 *
 * @param id A unique identifier for the resource.
 * @param props Configuration options for the Nuxt deployment, overriding defaults.
 * @returns A promise that resolves to the deployed Cloudflare Worker details.
 *
 * @example
 * // Deploy a basic Nuxt site with default settings
 * const nuxtSite = await Nuxt("my-nuxt-app");
 *
 * @example
 * // Deploy with custom bindings and build command
 * const db = await D1Database("my-db");
 * const nuxtSiteWithDb = await Nuxt("my-nuxt-app-with-db", {
 *   command: "npm run build:cloudflare", // Specify a custom build command
 *   bindings: {
 *     DB: db, // Add custom bindings
 *   },
 * });
 */
export async function Nuxt(id, props) {
    const runner = await getPackageManagerRunner();
    return await Website(id, {
        ...props,
        noBundle: props?.noBundle ?? true,
        build: spreadBuildProps(props, `${runner} nuxt build`),
        dev: spreadDevProps(props, `${runner} nuxt dev`),
        compatibility: "node",
        // Default entry point for cloudflare-module preset
        entrypoint: props?.entrypoint ?? "./.output/server/index.mjs",
        // Default static assets directory for cloudflare-module preset
        assets: props?.assets ?? path.join(".output", "public"),
    });
}
//# sourceMappingURL=nuxt.js.map