From e79d7ba881616e4a38f96b7841eab1b1b2784667 Mon Sep 17 00:00:00 2001 From: Julien Martel Date: Tue, 29 Aug 2023 13:55:01 -0500 Subject: [PATCH 1/2] add nuxt init method for firebase init hosting --- src/frameworks/nuxt/index.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/frameworks/nuxt/index.ts b/src/frameworks/nuxt/index.ts index 8b79667f9c1..8e8304a75a3 100644 --- a/src/frameworks/nuxt/index.ts +++ b/src/frameworks/nuxt/index.ts @@ -14,6 +14,7 @@ export const type = FrameworkType.Toolchain; 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"]; @@ -111,3 +112,16 @@ 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) { + return new Promise((resolve) => { + execSync(`npx --yes nuxi@latest init ${setup.hosting.source}`, { + stdio: "inherit", + cwd: config.projectDir, + }); + resolve(); + }); +} From c7fa611b70a8782ef08aca8753cb3d25d974b67d Mon Sep 17 00:00:00 2001 From: James Daniels Date: Thu, 7 Dec 2023 12:28:38 -0500 Subject: [PATCH 2/2] Changelog, supportedRange, and address feedback --- CHANGELOG.md | 1 + src/frameworks/nuxt/index.ts | 10 ++++------ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1d993b0ba93..1a45e699154 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,3 +4,4 @@ - Warn if a Web Framework is outside a well known version range on deploy/emulate. (#6562) - Use Web Framework's well known version range in `firebase init hosting`. (#6562) - 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 af102a51b85..b86001758b2 100644 --- a/src/frameworks/nuxt/index.ts +++ b/src/frameworks/nuxt/index.ts @@ -118,11 +118,9 @@ export async function getConfig(dir: string): Promise { * Utility method used during project initialization. */ export function init(setup: any, config: any) { - return new Promise((resolve) => { - execSync(`npx --yes nuxi@latest init ${setup.hosting.source}`, { - stdio: "inherit", - cwd: config.projectDir, - }); - resolve(); + execSync(`npx --yes nuxi@"${supportedRange}" init ${setup.hosting.source}`, { + stdio: "inherit", + cwd: config.projectDir, }); + return Promise.resolve(); }