diff --git a/CHANGELOG.md b/CHANGELOG.md index af660938afa..80b2f725d68 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,3 +5,4 @@ - Use Web Framework's well known version range in `firebase init hosting`. (#6562) - Permit use of more SSR regions in Web Frameworks deploys. (#6086) - Limit Web Framework's generated Cloud Function name to 23 characters, fixing deploys for some. (#6260) +- Allow Nuxt as an option during `firebase init hosting`. (#6309) diff --git a/src/frameworks/nuxt/index.ts b/src/frameworks/nuxt/index.ts index 3a029c5f34e..b86001758b2 100644 --- a/src/frameworks/nuxt/index.ts +++ b/src/frameworks/nuxt/index.ts @@ -15,6 +15,7 @@ export const supportedRange = "3"; import { nuxtConfigFilesExist } from "./utils"; import type { NuxtOptions } from "./interfaces"; import { FirebaseError } from "../../error"; +import { execSync } from "child_process"; const DEFAULT_BUILD_SCRIPT = ["nuxt build", "nuxi build"]; @@ -112,3 +113,14 @@ export async function getConfig(dir: string): Promise { const { loadNuxtConfig } = await relativeRequire(dir, "@nuxt/kit"); return await loadNuxtConfig(dir); } + +/** + * Utility method used during project initialization. + */ +export function init(setup: any, config: any) { + execSync(`npx --yes nuxi@"${supportedRange}" init ${setup.hosting.source}`, { + stdio: "inherit", + cwd: config.projectDir, + }); + return Promise.resolve(); +}