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

Limit web frameworks generated functionId to 20 chars max #6260

Merged
merged 5 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
- Fixed an issue preventing Angular apps using ng-deploy from being emulated or deployed. (#6584)
- 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 20 characters, fixing deploys for some. (#6260)
3 changes: 2 additions & 1 deletion src/frameworks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
/**
*
*/
export async function discover(dir: string, warn = true) {

Check warning on line 63 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const allFrameworkTypes = [
...new Set(Object.values(WebFrameworks).map(({ type }) => type)),
].sort();
Expand All @@ -87,20 +87,20 @@
const BUILD_MEMO = new Map<string[], Promise<BuildResult | void>>();

// Memoize the build based on both the dir and the environment variables
function memoizeBuild(

Check warning on line 90 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
dir: string,
build: (dir: string, target: string) => Promise<BuildResult | void>,
deps: any[],

Check warning on line 93 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
target: string
) {
const key = [dir, ...deps];

Check warning on line 96 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe spread of an `any` value in an array
for (const existingKey of BUILD_MEMO.keys()) {
if (isDeepStrictEqual(existingKey, key)) {
return BUILD_MEMO.get(existingKey);
}
}
const value = build(dir, target);
BUILD_MEMO.set(key, value);

Check warning on line 103 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any[]` assigned to a parameter of type `string[]`
return value;
}

Expand All @@ -108,7 +108,7 @@
* Use a function to ensure the same codebase name is used here and
* during hosting deploy.
*/
export function generateSSRCodebaseId(site: string) {

Check warning on line 111 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
return `firebase-frameworks-${site}`;
}

Expand Down Expand Up @@ -174,8 +174,9 @@
`Hosting config for site ${site} places server-side content in region ${ssrRegion} which is not known. Valid regions are ${validRegions}`
);
}
const getProjectPath = (...args: string[]) => join(projectRoot, source, ...args);

Check warning on line 177 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing return type on function
const functionId = `ssr${site.toLowerCase().replace(/-/g, "")}`;
// Combined traffic tag (19 chars) and functionId cannot exceed 46 characters.
const functionId = `ssr${site.toLowerCase().replace(/-/g, "").substring(0, 20)}`;
const usesFirebaseAdminSdk = !!findDependency("firebase-admin", { cwd: getProjectPath() });
const usesFirebaseJsSdk = !!findDependency("@firebase/app", { cwd: getProjectPath() });
if (usesFirebaseAdminSdk) {
Expand Down Expand Up @@ -209,9 +210,9 @@
if (selectedSite) {
const { appId } = selectedSite;
if (appId) {
firebaseConfig = await getAppConfig(appId, AppPlatform.WEB);

Check warning on line 213 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
firebaseDefaults ||= {};
firebaseDefaults.config = firebaseConfig;

Check warning on line 215 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
} else {
const defaultConfig = await implicitInit(options);
if (defaultConfig.json) {
Expand All @@ -220,7 +221,7 @@
You can link a Web app to a Hosting site here https://console.firebase.google.com/project/${project}/settings/general/web`
);
firebaseDefaults ||= {};
firebaseDefaults.config = JSON.parse(defaultConfig.json);

Check warning on line 224 in src/frameworks/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
} else {
// N.B. None of us know when this can ever happen and the deploy would
// still succeed. Maaaaybe if someone tried calling firebase serve
Expand Down