Skip to content

Commit

Permalink
let framework handle public directory with emulator (#6674)
Browse files Browse the repository at this point in the history
* use tmp dir for public directory with emulator

* same public path for dev/prod

* remove publicDirectory from discovery

* remove publicDirectory from unit tests

* remove publicDirectory from nuxt2

* changelog
  • Loading branch information
leoortizz committed Jan 23, 2024
1 parent d0972f7 commit 7717b83
Show file tree
Hide file tree
Showing 12 changed files with 9 additions and 22 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
- Add force flag to delete backend (#6635).
- Use framework build target in Vite builds (#6643).
- Use framework build target in NODE_ENV for production Vite builds (#6644)
- Let framework handle public directory with emulator. (#6674)
2 changes: 1 addition & 1 deletion src/frameworks/angular/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export async function discover(dir: string): Promise<Discovery | undefined> {
if (!(await pathExists(join(dir, "package.json")))) return;
if (!(await pathExists(join(dir, "angular.json")))) return;
const version = getAngularVersion(dir);
return { mayWantBackend: true, publicDirectory: join(dir, "src", "assets"), version };
return { mayWantBackend: true, version };
}

export function init(setup: any, config: any) {
Expand Down
3 changes: 1 addition & 2 deletions src/frameworks/astro/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@ export async function discover(dir: string): Promise<Discovery | undefined> {
if (!existsSync(join(dir, "package.json"))) return;
const version = getAstroVersion(dir);
if (!version) return;
const { output, publicDir: publicDirectory } = await getConfig(dir);
const { output } = await getConfig(dir);
return {
mayWantBackend: output !== "static",
publicDirectory,
version,
};
}
Expand Down
2 changes: 1 addition & 1 deletion src/frameworks/flutter/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export async function discover(dir: string): Promise<Discovery | undefined> {
const pubSpec = loadYaml(pubSpecBuffer.toString());
const usingFlutter = pubSpec.dependencies?.flutter;
if (!usingFlutter) return;
return { mayWantBackend: false, publicDirectory: join(dir, "web") };
return { mayWantBackend: false };
}

export function init(setup: any, config: any) {
Expand Down
5 changes: 2 additions & 3 deletions src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ export async function prepareFrameworks(
)
);
}
const { framework, mayWantBackend, publicDirectory } = results;
const { framework, mayWantBackend } = results;
const {
build,
ɵcodegenPublicDirectory,
Expand Down Expand Up @@ -304,7 +304,6 @@ export async function prepareFrameworks(
getDevModeHandle &&
(await getDevModeHandle(getProjectPath(), frameworksBuildTarget, hostingEmulatorInfo));
if (devModeHandle) {
config.public = relative(projectRoot, publicDirectory);
// Attach the handle to options, it will be used when spinning up superstatic
options.frameworksDevModeHandle = devModeHandle;
// null is the dev-mode entry for firebase-framework-tools
Expand Down Expand Up @@ -339,10 +338,10 @@ export async function prepareFrameworks(
site,
});

config.public = relative(projectRoot, hostingDist);
if (wantsBackend && !omitCloudFunction)
codegenFunctionsDirectory = codegenProdModeFunctionsDirectory;
}
config.public = relative(projectRoot, hostingDist);
config.webFramework = `${framework}${codegenFunctionsDirectory ? "_ssr" : ""}`;
if (codegenFunctionsDirectory) {
if (firebaseDefaults) {
Expand Down
1 change: 0 additions & 1 deletion src/frameworks/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ export const enum SupportLevel {

export interface Discovery {
mayWantBackend: boolean;
publicDirectory: string;
version?: string;
vite?: boolean;
}
Expand Down
7 changes: 2 additions & 5 deletions src/frameworks/nuxt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,9 @@ export async function discover(dir: string) {
if (!anyConfigFileExists && !version) return;
if (version && lt(version, "3.0.0-0")) return;

const {
dir: { public: publicDirectory },
ssr: mayWantBackend,
} = await getConfig(dir);
const { ssr: mayWantBackend } = await getConfig(dir);

return { publicDirectory, mayWantBackend, version };
return { mayWantBackend, version };
}

export async function build(cwd: string) {
Expand Down
3 changes: 1 addition & 2 deletions src/frameworks/nuxt2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ export async function discover(rootDir: string) {
if (!(await pathExists(join(rootDir, "package.json")))) return;
const version = getNuxtVersion(rootDir);
if (!version || (version && gte(version, "3.0.0-0"))) return;
const { app } = await getAndLoadNuxt({ rootDir, for: "build" });
return { mayWantBackend: true, publicDirectory: app.options.dir.static, version };
return { mayWantBackend: true, version };
}

/**
Expand Down
2 changes: 0 additions & 2 deletions src/test/frameworks/angular/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import * as sinon from "sinon";
import * as fsExtra from "fs-extra";

import { discover } from "../../../frameworks/angular";
import { join } from "path";

describe("Angular", () => {
describe("discovery", () => {
Expand All @@ -22,7 +21,6 @@ describe("Angular", () => {
sandbox.stub(fsExtra, "pathExists").resolves(true);
expect(await discover(cwd)).to.deep.equal({
mayWantBackend: true,
publicDirectory: join(cwd, "src", "assets"),
version: undefined,
});
});
Expand Down
2 changes: 0 additions & 2 deletions src/test/frameworks/astro/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe("Astro", () => {
});
expect(await discover(cwd)).to.deep.equal({
mayWantBackend: false,
publicDirectory: publicDir,
version: "2.2.2",
});
});
Expand Down Expand Up @@ -84,7 +83,6 @@ describe("Astro", () => {
});
expect(await discover(cwd)).to.deep.equal({
mayWantBackend: true,
publicDirectory: publicDir,
version: "2.2.2",
});
});
Expand Down
1 change: 0 additions & 1 deletion src/test/frameworks/flutter/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ describe("Flutter", () => {
);
expect(await discover(cwd)).to.deep.equal({
mayWantBackend: false,
publicDirectory: "web",
});
});

Expand Down
2 changes: 0 additions & 2 deletions src/test/frameworks/nuxt/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ describe("Nuxt 2 utils", () => {

expect(await discoverNuxt2(discoverNuxtDir)).to.deep.equal({
mayWantBackend: true,
publicDirectory: "static",
version: "2.15.8",
});
});
Expand Down Expand Up @@ -75,7 +74,6 @@ describe("Nuxt 2 utils", () => {

expect(await discoverNuxt3(discoverNuxtDir)).to.deep.equal({
mayWantBackend: true,
publicDirectory: "public",
version: "3.0.0",
});
});
Expand Down

0 comments on commit 7717b83

Please sign in to comment.