Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add nuxt init method for firebase hosting #6309

Merged
merged 4 commits into from
Dec 7, 2023
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 12 additions & 0 deletions src/frameworks/nuxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
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"];

Expand All @@ -23,7 +24,7 @@
* @param dir current directory
* @return undefined if project is not Nuxt 2, { mayWantBackend: true, publicDirectory: string } otherwise
*/
export async function discover(dir: string) {

Check warning on line 27 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
if (!(await pathExists(join(dir, "package.json")))) return;

const anyConfigFileExists = await nuxtConfigFilesExist(dir);
Expand All @@ -40,7 +41,7 @@
return { publicDirectory, mayWantBackend, version };
}

export async function build(cwd: string) {

Check warning on line 44 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 44 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
await warnIfCustomBuildScript(cwd, name, DEFAULT_BUILD_SCRIPT);
const cli = getNodeModuleBin("nuxt", cwd);
const {
Expand All @@ -65,7 +66,7 @@
return { wantsBackend, rewrites, baseUrl };
}

export async function ɵcodegenPublicDirectory(root: string, dest: string) {

Check warning on line 69 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 69 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const {
app: { baseURL },
} = await getConfig(root);
Expand All @@ -75,13 +76,13 @@
await copy(distPath, fullDest);
}

export async function ɵcodegenFunctionsDirectory(sourceDir: string) {

Check warning on line 79 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function

Check warning on line 79 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const serverDir = join(sourceDir, ".output", "server");
const packageJsonBuffer = await readFile(join(sourceDir, "package.json"));
const packageJson = JSON.parse(packageJsonBuffer.toString());

Check warning on line 82 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value

packageJson.dependencies ||= {};

Check warning on line 84 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .dependencies on an `any` value
packageJson.dependencies["nitro-output"] = `file:${serverDir}`;

Check warning on line 85 in src/frameworks/nuxt/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe member access .dependencies on an `any` value

return { packageJson, frameworksEntry: "nitro" };
}
Expand Down Expand Up @@ -112,3 +113,14 @@
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();
}
Loading