MCPcopy Create free account
hub / github.com/firebase/firebase-tools / fetchWebSetup

Function fetchWebSetup

src/fetchWebSetup.ts:98–130  ·  view source on GitHub ↗
(options: any)

Source from the content-addressed store, hash-verified

96 * @return web app configuration.
97 */
98export async function fetchWebSetup(options: any): Promise<WebConfig> {
99 const projectId = needProjectId(options);
100
101 // When using the emulators with a fake project ID, use a fake web config
102 if (Constants.isDemoProject(projectId)) {
103 return constructDefaultWebSetup(projectId);
104 }
105
106 // Try to determine the appId from the default Hosting site, if it is linked.
107 let hostingAppId: string | undefined = undefined;
108 try {
109 const sites = await listAllSites(projectId);
110 const defaultSite = sites.find((s) => s.type === "DEFAULT_SITE");
111 if (defaultSite && defaultSite.appId) {
112 hostingAppId = defaultSite.appId;
113 }
114 } catch (e: any) {
115 logger.debug("Failed to list hosting sites");
116 logger.debug(e);
117 }
118
119 // Get the web app config for the appId, or use the '-' special value if the appId is not known
120 const appId = hostingAppId || "-";
121 const res = await apiClient.get<WebConfig>(`/projects/${projectId}/webApps/${appId}/config`);
122 const config = res.body;
123
124 if (!config.appId && hostingAppId) {
125 config.appId = hostingAppId;
126 }
127
128 setCachedWebSetup(config.projectId, config);
129 return config;
130}

Callers 2

implicitInitFunction · 0.90

Calls 5

needProjectIdFunction · 0.90
constructDefaultWebSetupFunction · 0.85
listAllSitesFunction · 0.85
setCachedWebSetupFunction · 0.85
isDemoProjectMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…