firebase-tools 11.14.4 → 11.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commands/database-push.js +5 -0
- package/lib/commands/database-remove.js +2 -1
- package/lib/commands/database-set.js +5 -0
- package/lib/commands/database-update.js +5 -0
- package/lib/database/remove.js +2 -2
- package/lib/database/removeRemote.js +7 -2
- package/lib/deploy/functions/prepare.js +21 -8
- package/lib/deploy/hosting/convertConfig.js +21 -7
- package/lib/deploy/hosting/prepare.js +16 -5
- package/lib/deploy/hosting/release.js +2 -2
- package/lib/dynamicImport.js +7 -10
- package/lib/emulator/auth/server.js +2 -3
- package/lib/emulator/downloadableEmulators.js +65 -50
- package/lib/emulator/functionsEmulatorShared.js +12 -1
- package/lib/emulator/functionsRuntimeWorker.js +9 -2
- package/lib/experiments.js +4 -4
- package/lib/extensions/provisioningHelper.js +10 -4
- package/lib/frameworks/index.js +9 -4
- package/lib/frameworks/next/index.js +65 -20
- package/lib/serve/hosting.js +4 -4
- package/npm-shrinkwrap.json +600 -50
- package/package.json +2 -2
package/lib/frameworks/index.js
CHANGED
|
@@ -139,12 +139,14 @@ async function prepareFrameworks(targetNames, context, options, emulators = [])
|
|
|
139
139
|
}
|
|
140
140
|
const configs = (0, config_1.hostingConfig)(options);
|
|
141
141
|
let firebaseDefaults = undefined;
|
|
142
|
-
if (configs.length === 0)
|
|
142
|
+
if (configs.length === 0) {
|
|
143
143
|
return;
|
|
144
|
+
}
|
|
144
145
|
for (const config of configs) {
|
|
145
146
|
const { source, site, public: publicDir } = config;
|
|
146
|
-
if (!source)
|
|
147
|
+
if (!source) {
|
|
147
148
|
continue;
|
|
149
|
+
}
|
|
148
150
|
config.rewrites || (config.rewrites = []);
|
|
149
151
|
config.redirects || (config.redirects = []);
|
|
150
152
|
config.headers || (config.headers = []);
|
|
@@ -152,8 +154,9 @@ async function prepareFrameworks(targetNames, context, options, emulators = [])
|
|
|
152
154
|
const dist = (0, path_1.join)(projectRoot, ".firebase", site);
|
|
153
155
|
const hostingDist = (0, path_1.join)(dist, "hosting");
|
|
154
156
|
const functionsDist = (0, path_1.join)(dist, "functions");
|
|
155
|
-
if (publicDir)
|
|
157
|
+
if (publicDir) {
|
|
156
158
|
throw new Error(`hosting.public and hosting.source cannot both be set in firebase.json`);
|
|
159
|
+
}
|
|
157
160
|
const getProjectPath = (...args) => (0, path_1.join)(projectRoot, source, ...args);
|
|
158
161
|
const functionName = `ssr${site.toLowerCase().replace(/-/g, "")}`;
|
|
159
162
|
const usesFirebaseAdminSdk = !!findDependency("firebase-admin", { cwd: getProjectPath() });
|
|
@@ -232,8 +235,9 @@ async function prepareFrameworks(targetNames, context, options, emulators = [])
|
|
|
232
235
|
if (devModeHandle) {
|
|
233
236
|
config.public = (0, path_1.relative)(projectRoot, publicDirectory);
|
|
234
237
|
options.frameworksDevModeHandle = devModeHandle;
|
|
235
|
-
if (mayWantBackend && firebaseDefaults)
|
|
238
|
+
if (mayWantBackend && firebaseDefaults) {
|
|
236
239
|
codegenFunctionsDirectory = codegenDevModeFunctionsDirectory;
|
|
240
|
+
}
|
|
237
241
|
}
|
|
238
242
|
else {
|
|
239
243
|
const { wantsBackend = false, rewrites = [], redirects = [], headers = [], } = (await build(getProjectPath())) || {};
|
|
@@ -248,6 +252,7 @@ async function prepareFrameworks(targetNames, context, options, emulators = [])
|
|
|
248
252
|
if (wantsBackend)
|
|
249
253
|
codegenFunctionsDirectory = codegenProdModeFunctionsDirectory;
|
|
250
254
|
}
|
|
255
|
+
config.webFramework = `${framework}${codegenFunctionsDirectory ? "_ssr" : ""}`;
|
|
251
256
|
if (codegenFunctionsDirectory) {
|
|
252
257
|
if (firebaseDefaults)
|
|
253
258
|
firebaseDefaults._authTokenSyncURL = "/__session";
|
|
@@ -12,6 +12,7 @@ const prompt_1 = require("../../prompt");
|
|
|
12
12
|
const semver_1 = require("semver");
|
|
13
13
|
const logger_1 = require("../../logger");
|
|
14
14
|
const error_1 = require("../../error");
|
|
15
|
+
const fsutils_1 = require("../../fsutils");
|
|
15
16
|
const CLI_COMMAND = (0, path_1.join)("node_modules", ".bin", process.platform === "win32" ? "next.cmd" : "next");
|
|
16
17
|
exports.name = "Next.js";
|
|
17
18
|
exports.support = "experimental";
|
|
@@ -20,6 +21,10 @@ function getNextVersion(cwd) {
|
|
|
20
21
|
var _a;
|
|
21
22
|
return (_a = (0, __1.findDependency)("next", { cwd, depth: 0, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
|
|
22
23
|
}
|
|
24
|
+
function getReactVersion(cwd) {
|
|
25
|
+
var _a;
|
|
26
|
+
return (_a = (0, __1.findDependency)("react-dom", { cwd, omitDev: false })) === null || _a === void 0 ? void 0 : _a.version;
|
|
27
|
+
}
|
|
23
28
|
async function discover(dir) {
|
|
24
29
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
25
30
|
return;
|
|
@@ -30,6 +35,10 @@ async function discover(dir) {
|
|
|
30
35
|
exports.discover = discover;
|
|
31
36
|
async function build(dir) {
|
|
32
37
|
const { default: nextBuild } = (0, __1.relativeRequire)(dir, "next/dist/build");
|
|
38
|
+
const reactVersion = getReactVersion(dir);
|
|
39
|
+
if (reactVersion && (0, semver_1.gte)(reactVersion, "18.0.0")) {
|
|
40
|
+
process.env.__NEXT_REACT_ROOT = "true";
|
|
41
|
+
}
|
|
33
42
|
await nextBuild(dir, null, false, false, true).catch((e) => {
|
|
34
43
|
console.error(e.message);
|
|
35
44
|
throw e;
|
|
@@ -46,12 +55,19 @@ async function build(dir) {
|
|
|
46
55
|
const exportDetailBuffer = exportDetailExists ? await (0, promises_1.readFile)(exportDetailPath) : undefined;
|
|
47
56
|
const exportDetailJson = exportDetailBuffer && JSON.parse(exportDetailBuffer.toString());
|
|
48
57
|
if (exportDetailJson === null || exportDetailJson === void 0 ? void 0 : exportDetailJson.success) {
|
|
58
|
+
const appPathRoutesManifestPath = (0, path_1.join)(dir, distDir, "app-path-routes-manifest.json");
|
|
59
|
+
const appPathRoutesManifestJSON = (0, fsutils_1.fileExistsSync)(appPathRoutesManifestPath)
|
|
60
|
+
? await (0, promises_1.readFile)(appPathRoutesManifestPath).then((it) => JSON.parse(it.toString()))
|
|
61
|
+
: {};
|
|
49
62
|
const prerenderManifestJSON = await (0, promises_1.readFile)((0, path_1.join)(dir, distDir, "prerender-manifest.json")).then((it) => JSON.parse(it.toString()));
|
|
50
63
|
const anyDynamicRouteFallbacks = !!Object.values(prerenderManifestJSON.dynamicRoutes || {}).find((it) => it.fallback !== false);
|
|
51
64
|
const pagesManifestJSON = await (0, promises_1.readFile)((0, path_1.join)(dir, distDir, "server", "pages-manifest.json")).then((it) => JSON.parse(it.toString()));
|
|
52
65
|
const prerenderedRoutes = Object.keys(prerenderManifestJSON.routes);
|
|
53
66
|
const dynamicRoutes = Object.keys(prerenderManifestJSON.dynamicRoutes);
|
|
54
|
-
const unrenderedPages =
|
|
67
|
+
const unrenderedPages = [
|
|
68
|
+
...Object.keys(pagesManifestJSON),
|
|
69
|
+
...Object.values(appPathRoutesManifestJSON),
|
|
70
|
+
].filter((it) => !(["/_app", "/", "/_error", "/_document", "/404"].includes(it) ||
|
|
55
71
|
prerenderedRoutes.includes(it) ||
|
|
56
72
|
dynamicRoutes.includes(it)));
|
|
57
73
|
if (!anyDynamicRouteFallbacks && unrenderedPages.length === 0) {
|
|
@@ -85,7 +101,7 @@ async function init(setup) {
|
|
|
85
101
|
message: "What language would you like to use?",
|
|
86
102
|
choices: ["JavaScript", "TypeScript"],
|
|
87
103
|
});
|
|
88
|
-
(0, child_process_1.execSync)(`npx --yes create-next-app@latest -e hello-world ${setup.hosting.source} ${language === "TypeScript" ? "--ts" : ""}`, { stdio: "inherit" });
|
|
104
|
+
(0, child_process_1.execSync)(`npx --yes create-next-app@latest -e hello-world ${setup.hosting.source} --use-npm ${language === "TypeScript" ? "--ts" : ""}`, { stdio: "inherit" });
|
|
89
105
|
}
|
|
90
106
|
exports.init = init;
|
|
91
107
|
async function ɵcodegenPublicDirectory(sourceDir, destDir) {
|
|
@@ -98,23 +114,32 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir) {
|
|
|
98
114
|
(0, fs_extra_1.copy)(exportDetailJson.outDirectory, destDir);
|
|
99
115
|
}
|
|
100
116
|
else {
|
|
117
|
+
const publicPath = (0, path_1.join)(sourceDir, "public");
|
|
101
118
|
await (0, promises_1.mkdir)((0, path_1.join)(destDir, "_next", "static"), { recursive: true });
|
|
102
|
-
await (0, fs_extra_1.
|
|
119
|
+
if (await (0, fs_extra_1.pathExists)(publicPath)) {
|
|
120
|
+
await (0, fs_extra_1.copy)(publicPath, destDir);
|
|
121
|
+
}
|
|
103
122
|
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, "static"), (0, path_1.join)(destDir, "_next", "static"));
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
123
|
+
for (const file of ["index.html", "404.html", "500.html"]) {
|
|
124
|
+
const pagesPath = (0, path_1.join)(sourceDir, distDir, "server", "pages", file);
|
|
125
|
+
if (await (0, fs_extra_1.pathExists)(pagesPath)) {
|
|
126
|
+
await (0, promises_1.copyFile)(pagesPath, (0, path_1.join)(destDir, file));
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
129
|
+
const appPath = (0, path_1.join)(sourceDir, distDir, "server", "app", file);
|
|
130
|
+
if (await (0, fs_extra_1.pathExists)(appPath)) {
|
|
131
|
+
await (0, promises_1.copyFile)(appPath, (0, path_1.join)(destDir, file));
|
|
132
|
+
}
|
|
133
|
+
}
|
|
113
134
|
const prerenderManifestBuffer = await (0, promises_1.readFile)((0, path_1.join)(sourceDir, distDir, "prerender-manifest.json"));
|
|
114
135
|
const prerenderManifest = JSON.parse(prerenderManifestBuffer.toString());
|
|
115
|
-
for (const
|
|
116
|
-
if (prerenderManifest.routes[
|
|
117
|
-
const
|
|
136
|
+
for (const path in prerenderManifest.routes) {
|
|
137
|
+
if (prerenderManifest.routes[path]) {
|
|
138
|
+
const { initialRevalidateSeconds } = prerenderManifest.routes[path];
|
|
139
|
+
if (initialRevalidateSeconds) {
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const parts = path
|
|
118
143
|
.split("/")
|
|
119
144
|
.slice(1)
|
|
120
145
|
.filter((it) => !!it);
|
|
@@ -122,10 +147,28 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir) {
|
|
|
122
147
|
const dataPath = `${(0, path_1.join)(...partsOrIndex)}.json`;
|
|
123
148
|
const htmlPath = `${(0, path_1.join)(...partsOrIndex)}.html`;
|
|
124
149
|
await (0, promises_1.mkdir)((0, path_1.join)(destDir, (0, path_1.dirname)(htmlPath)), { recursive: true });
|
|
125
|
-
|
|
126
|
-
|
|
150
|
+
const pagesHtmlPath = (0, path_1.join)(sourceDir, distDir, "server", "pages", htmlPath);
|
|
151
|
+
if (await (0, fs_extra_1.pathExists)(pagesHtmlPath)) {
|
|
152
|
+
await (0, promises_1.copyFile)(pagesHtmlPath, (0, path_1.join)(destDir, htmlPath));
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
const appHtmlPath = (0, path_1.join)(sourceDir, distDir, "server", "app", htmlPath);
|
|
156
|
+
if (await (0, fs_extra_1.pathExists)(appHtmlPath)) {
|
|
157
|
+
await (0, promises_1.copyFile)(appHtmlPath, (0, path_1.join)(destDir, htmlPath));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
const dataRoute = prerenderManifest.routes[path].dataRoute;
|
|
127
161
|
await (0, promises_1.mkdir)((0, path_1.join)(destDir, (0, path_1.dirname)(dataRoute)), { recursive: true });
|
|
128
|
-
|
|
162
|
+
const pagesDataPath = (0, path_1.join)(sourceDir, distDir, "server", "pages", dataPath);
|
|
163
|
+
if (await (0, fs_extra_1.pathExists)(pagesDataPath)) {
|
|
164
|
+
await (0, promises_1.copyFile)(pagesDataPath, (0, path_1.join)(destDir, dataRoute));
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
const appDataPath = (0, path_1.join)(sourceDir, distDir, "server", "app", dataPath);
|
|
168
|
+
if (await (0, fs_extra_1.pathExists)(appDataPath)) {
|
|
169
|
+
await (0, promises_1.copyFile)(appDataPath, (0, path_1.join)(destDir, dataRoute));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
129
172
|
}
|
|
130
173
|
}
|
|
131
174
|
}
|
|
@@ -154,9 +197,11 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir) {
|
|
|
154
197
|
platform: "node",
|
|
155
198
|
});
|
|
156
199
|
}
|
|
157
|
-
await (0,
|
|
200
|
+
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, "public"))) {
|
|
201
|
+
await (0, promises_1.mkdir)((0, path_1.join)(destDir, "public"));
|
|
202
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, "public"), (0, path_1.join)(destDir, "public"));
|
|
203
|
+
}
|
|
158
204
|
await (0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir));
|
|
159
|
-
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, "public"), (0, path_1.join)(destDir, "public"));
|
|
160
205
|
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir), (0, path_1.join)(destDir, distDir));
|
|
161
206
|
return { packageJson, frameworksEntry: "next.js" };
|
|
162
207
|
}
|
package/lib/serve/hosting.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.connect = exports.start = exports.stop = void 0;
|
|
4
4
|
const morgan = require("morgan");
|
|
5
|
-
const
|
|
5
|
+
const { server: superstatic } = require("superstatic");
|
|
6
6
|
const clc = require("colorette");
|
|
7
7
|
const net_1 = require("net");
|
|
8
8
|
const detectProjectRoot_1 = require("../detectProjectRoot");
|
|
@@ -36,13 +36,13 @@ function startServer(options, config, port, init) {
|
|
|
36
36
|
const after = options.frameworksDevModeHandle && {
|
|
37
37
|
files: options.frameworksDevModeHandle,
|
|
38
38
|
};
|
|
39
|
-
const server = (
|
|
39
|
+
const server = superstatic({
|
|
40
40
|
debug: false,
|
|
41
41
|
port: port,
|
|
42
|
-
|
|
42
|
+
host: options.host,
|
|
43
43
|
config: config,
|
|
44
44
|
compression: true,
|
|
45
|
-
cwd: (0, detectProjectRoot_1.detectProjectRoot)(options)
|
|
45
|
+
cwd: (0, detectProjectRoot_1.detectProjectRoot)(options),
|
|
46
46
|
stack: "strict",
|
|
47
47
|
before: {
|
|
48
48
|
files: (req, res, next) => {
|