firebase-tools 13.23.0 → 13.24.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/apphosting/backend.js +288 -0
- package/lib/apphosting/config.js +39 -8
- package/lib/apphosting/githubConnections.js +18 -12
- package/lib/apphosting/index.js +3 -278
- package/lib/apphosting/rollout.js +12 -9
- package/lib/apphosting/secrets/index.js +66 -1
- package/lib/apphosting/utils.js +41 -0
- package/lib/apphosting/yaml.js +83 -0
- package/lib/bin/firebase.js +2 -2
- package/lib/commands/apphosting-backends-create.js +4 -4
- package/lib/commands/apphosting-backends-delete.js +4 -14
- package/lib/commands/apphosting-config-export.js +51 -0
- package/lib/commands/apphosting-repos-create.js +4 -4
- package/lib/commands/apphosting-rollouts-create.js +3 -4
- package/lib/commands/apphosting-secrets-grantaccess.js +2 -2
- package/lib/commands/functions-secrets-access.js +2 -4
- package/lib/commands/index.js +4 -0
- package/lib/commands/init.js +6 -6
- package/lib/emulator/apphosting/config.js +11 -39
- package/lib/emulator/apphosting/serve.js +6 -2
- package/lib/emulator/commandUtils.js +2 -2
- package/lib/emulator/downloadableEmulators.js +9 -9
- package/lib/emulator/loggingEmulator.js +2 -2
- package/lib/frameworks/next/index.js +10 -2
- package/lib/frameworks/next/utils.js +7 -4
- package/lib/frameworks/vite/index.js +2 -2
- package/lib/fsutils.js +13 -1
- package/lib/gcp/apphosting.js +1 -1
- package/lib/init/features/apphosting.js +3 -0
- package/lib/utils.js +2 -2
- package/package.json +1 -2
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.command = void 0;
|
|
4
|
+
const command_1 = require("../command");
|
|
5
|
+
const logger_1 = require("../logger");
|
|
6
|
+
const projectUtils_1 = require("../projectUtils");
|
|
7
|
+
const requireAuth_1 = require("../requireAuth");
|
|
8
|
+
const secretManager = require("../gcp/secretManager");
|
|
9
|
+
const requirePermissions_1 = require("../requirePermissions");
|
|
10
|
+
const config_1 = require("../apphosting/config");
|
|
11
|
+
const secrets_1 = require("../apphosting/secrets");
|
|
12
|
+
const path_1 = require("path");
|
|
13
|
+
const fs = require("../fsutils");
|
|
14
|
+
const yaml_1 = require("../apphosting/yaml");
|
|
15
|
+
const error_1 = require("../error");
|
|
16
|
+
exports.command = new command_1.Command("apphosting:config:export")
|
|
17
|
+
.description("Export App Hosting configurations such as secrets into an apphosting.local.yaml file")
|
|
18
|
+
.option("-s, --secrets <apphosting.yaml or apphosting.<environment>.yaml file to export secrets from>", "This command combines the base apphosting.yaml with the specified environment-specific file (e.g., apphosting.staging.yaml). If keys conflict, the environment-specific file takes precedence.")
|
|
19
|
+
.before(requireAuth_1.requireAuth)
|
|
20
|
+
.before(secretManager.ensureApi)
|
|
21
|
+
.before(requirePermissions_1.requirePermissions, ["secretmanager.versions.access"])
|
|
22
|
+
.action(async (options) => {
|
|
23
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
24
|
+
const environmentConfigFile = options.secrets;
|
|
25
|
+
const cwd = process.cwd();
|
|
26
|
+
let localAppHostingConfig = yaml_1.AppHostingYamlConfig.empty();
|
|
27
|
+
const backendRoot = (0, config_1.discoverBackendRoot)(cwd);
|
|
28
|
+
if (!backendRoot) {
|
|
29
|
+
throw new error_1.FirebaseError("Missing apphosting.yaml: This command requires an apphosting.yaml configuration file. Please run 'firebase init apphosting' and try again.");
|
|
30
|
+
}
|
|
31
|
+
const localAppHostingConfigPath = (0, path_1.resolve)(backendRoot, config_1.APPHOSTING_LOCAL_YAML_FILE);
|
|
32
|
+
if (fs.fileExistsSync(localAppHostingConfigPath)) {
|
|
33
|
+
localAppHostingConfig = await yaml_1.AppHostingYamlConfig.loadFromFile(localAppHostingConfigPath);
|
|
34
|
+
}
|
|
35
|
+
const configToExport = await (0, secrets_1.loadConfigToExport)(cwd, environmentConfigFile);
|
|
36
|
+
const secretsToExport = configToExport.secrets;
|
|
37
|
+
if (!secretsToExport) {
|
|
38
|
+
logger_1.logger.warn("No secrets found to export in the chosen App Hosting config files");
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
const secretMaterial = await (0, secrets_1.fetchSecrets)(projectId, secretsToExport);
|
|
42
|
+
for (const [key, value] of secretMaterial) {
|
|
43
|
+
localAppHostingConfig.addEnvironmentVariable({
|
|
44
|
+
variable: key,
|
|
45
|
+
value: value,
|
|
46
|
+
availability: ["RUNTIME"],
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
localAppHostingConfig.upsertFile(localAppHostingConfigPath);
|
|
50
|
+
logger_1.logger.info(`Wrote secrets as environment variables to ${config_1.APPHOSTING_LOCAL_YAML_FILE}.`);
|
|
51
|
+
});
|
|
@@ -4,20 +4,20 @@ exports.command = void 0;
|
|
|
4
4
|
const command_1 = require("../command");
|
|
5
5
|
const projectUtils_1 = require("../projectUtils");
|
|
6
6
|
const requireInteractive_1 = require("../requireInteractive");
|
|
7
|
-
const
|
|
8
|
-
const
|
|
7
|
+
const backend_1 = require("../apphosting/backend");
|
|
8
|
+
const apphosting_1 = require("../gcp/apphosting");
|
|
9
9
|
const firedata_1 = require("../gcp/firedata");
|
|
10
10
|
const requireTosAcceptance_1 = require("../requireTosAcceptance");
|
|
11
11
|
exports.command = new command_1.Command("apphosting:repos:create")
|
|
12
12
|
.description("create a Firebase App Hosting Developer Connect Git Repository Link")
|
|
13
13
|
.option("-l, --location <location>", "specify the location of the backend", "")
|
|
14
14
|
.option("-g, --gitconnection <connection>", "id of the connection", "")
|
|
15
|
-
.before(
|
|
15
|
+
.before(apphosting_1.ensureApiEnabled)
|
|
16
16
|
.before(requireInteractive_1.default)
|
|
17
17
|
.before((0, requireTosAcceptance_1.requireTosAcceptance)(firedata_1.APPHOSTING_TOS_ID))
|
|
18
18
|
.action(async (options) => {
|
|
19
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
20
20
|
const location = options.location;
|
|
21
21
|
const connection = options.gitconnection;
|
|
22
|
-
await (0,
|
|
22
|
+
await (0, backend_1.createGitRepoLink)(projectId, location, connection);
|
|
23
23
|
});
|
|
@@ -8,10 +8,9 @@ const error_1 = require("../error");
|
|
|
8
8
|
const rollout_1 = require("../apphosting/rollout");
|
|
9
9
|
exports.command = new command_1.Command("apphosting:rollouts:create <backendId>")
|
|
10
10
|
.description("create a rollout using a build for an App Hosting backend")
|
|
11
|
-
.option("-l, --location <location>", "specify the region of the backend", "
|
|
12
|
-
.option("-
|
|
13
|
-
.option("-
|
|
14
|
-
.option("-gc, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -gb)")
|
|
11
|
+
.option("-l, --location <location>", "specify the region of the backend", "-")
|
|
12
|
+
.option("-b, --git-branch <gitBranch>", "repository branch to deploy (mutually exclusive with -g)")
|
|
13
|
+
.option("-g, --git-commit <gitCommit>", "git commit to deploy (mutually exclusive with -b)")
|
|
15
14
|
.withForce("Skip confirmation before creating rollout")
|
|
16
15
|
.before(apphosting.ensureApiEnabled)
|
|
17
16
|
.action(async (backendId, options) => {
|
|
@@ -9,7 +9,7 @@ const secretManager = require("../gcp/secretManager");
|
|
|
9
9
|
const requirePermissions_1 = require("../requirePermissions");
|
|
10
10
|
const apphosting = require("../gcp/apphosting");
|
|
11
11
|
const secrets = require("../apphosting/secrets");
|
|
12
|
-
const
|
|
12
|
+
const backend_1 = require("../apphosting/backend");
|
|
13
13
|
exports.command = new command_1.Command("apphosting:secrets:grantaccess <secretName>")
|
|
14
14
|
.description("grant service accounts permissions to the provided secret")
|
|
15
15
|
.option("-l, --location <location>", "backend location", "-")
|
|
@@ -39,7 +39,7 @@ exports.command = new command_1.Command("apphosting:secrets:grantaccess <secretN
|
|
|
39
39
|
const location = options.location;
|
|
40
40
|
let backend;
|
|
41
41
|
if (location === "" || location === "-") {
|
|
42
|
-
backend = await (0,
|
|
42
|
+
backend = await (0, backend_1.getBackendForAmbiguousLocation)(projectId, backendId, "Please select the location of your backend:");
|
|
43
43
|
}
|
|
44
44
|
else {
|
|
45
45
|
backend = await apphosting.getBackend(projectId, location, backendId);
|
|
@@ -7,16 +7,14 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
7
7
|
const secretManager_1 = require("../gcp/secretManager");
|
|
8
8
|
const requireAuth_1 = require("../requireAuth");
|
|
9
9
|
const secretManager = require("../gcp/secretManager");
|
|
10
|
+
const secrets_1 = require("../apphosting/secrets");
|
|
10
11
|
exports.command = new command_1.Command("functions:secrets:access <KEY>[@version]")
|
|
11
12
|
.description("Access secret value given secret and its version. Defaults to accessing the latest version.")
|
|
12
13
|
.before(requireAuth_1.requireAuth)
|
|
13
14
|
.before(secretManager.ensureApi)
|
|
14
15
|
.action(async (key, options) => {
|
|
15
16
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
16
|
-
|
|
17
|
-
if (!version) {
|
|
18
|
-
version = "latest";
|
|
19
|
-
}
|
|
17
|
+
const [name, version] = (0, secrets_1.getSecretNameParts)(key);
|
|
20
18
|
const value = await (0, secretManager_1.accessSecretVersion)(projectId, name, version);
|
|
21
19
|
logger_1.logger.info(value);
|
|
22
20
|
});
|
package/lib/commands/index.js
CHANGED
|
@@ -179,6 +179,10 @@ function load(client) {
|
|
|
179
179
|
client.apphosting.rollouts.create = loadCommand("apphosting-rollouts-create");
|
|
180
180
|
client.apphosting.rollouts.list = loadCommand("apphosting-rollouts-list");
|
|
181
181
|
}
|
|
182
|
+
if (experiments.isEnabled("emulatorapphosting")) {
|
|
183
|
+
client.apphosting.config = {};
|
|
184
|
+
client.apphosting.config.export = loadCommand("apphosting-config-export");
|
|
185
|
+
}
|
|
182
186
|
}
|
|
183
187
|
client.login = loadCommand("login");
|
|
184
188
|
client.login.add = loadCommand("login-add");
|
package/lib/commands/init.js
CHANGED
|
@@ -37,6 +37,12 @@ let choices = [
|
|
|
37
37
|
name: "Functions: Configure a Cloud Functions directory and its files",
|
|
38
38
|
checked: false,
|
|
39
39
|
},
|
|
40
|
+
{
|
|
41
|
+
value: "apphosting",
|
|
42
|
+
name: "App Hosting: Configure an apphosting.yaml file for App Hosting",
|
|
43
|
+
checked: false,
|
|
44
|
+
hidden: false,
|
|
45
|
+
},
|
|
40
46
|
{
|
|
41
47
|
value: "hosting",
|
|
42
48
|
name: "Hosting: Configure files for Firebase Hosting and (optionally) set up GitHub Action deploys",
|
|
@@ -79,12 +85,6 @@ let choices = [
|
|
|
79
85
|
checked: false,
|
|
80
86
|
hidden: true,
|
|
81
87
|
},
|
|
82
|
-
{
|
|
83
|
-
value: "apphosting",
|
|
84
|
-
name: "App Hosting: Configure an apphosting.yaml file for App Hosting",
|
|
85
|
-
checked: false,
|
|
86
|
-
hidden: false,
|
|
87
|
-
},
|
|
88
88
|
];
|
|
89
89
|
if ((0, experiments_1.isEnabled)("genkit")) {
|
|
90
90
|
choices = [
|
|
@@ -1,45 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocalAppHostingConfiguration =
|
|
3
|
+
exports.getLocalAppHostingConfiguration = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
const file = await (0, utils_1.readFileFromDirectory)(sourceDirectory, fileName);
|
|
13
|
-
const apphostingYaml = await (0, utils_1.wrappedSafeLoad)(file.source);
|
|
14
|
-
const environmentVariables = {};
|
|
15
|
-
const secrets = {};
|
|
16
|
-
if (apphostingYaml.env) {
|
|
17
|
-
for (const env of apphostingYaml.env) {
|
|
18
|
-
if (env.value) {
|
|
19
|
-
environmentVariables[env.variable] = env.value;
|
|
20
|
-
}
|
|
21
|
-
if (env.secret) {
|
|
22
|
-
secrets[env.variable] = env.secret;
|
|
23
|
-
}
|
|
24
|
-
}
|
|
5
|
+
const config_1 = require("../../apphosting/config");
|
|
6
|
+
async function getLocalAppHostingConfiguration(cwd) {
|
|
7
|
+
const appHostingConfigPaths = (0, config_1.discoverConfigsAtBackendRoot)(cwd);
|
|
8
|
+
const fileNameToPathMap = new Map();
|
|
9
|
+
for (const path of appHostingConfigPaths) {
|
|
10
|
+
const fileName = (0, path_1.basename)(path);
|
|
11
|
+
fileNameToPathMap.set(fileName, path);
|
|
25
12
|
}
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
async function getLocalAppHostingConfiguration(sourceDirectory) {
|
|
30
|
-
let apphostingBaseConfig = {};
|
|
31
|
-
let apphostingLocalConfig = {};
|
|
32
|
-
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDirectory, APPHOSTING_YAML))) {
|
|
33
|
-
utils_2.logger.logLabeled("SUCCESS", types_1.Emulators.APPHOSTING, `${APPHOSTING_YAML} found, loading configuration`);
|
|
34
|
-
apphostingBaseConfig = await loadAppHostingYaml(sourceDirectory, APPHOSTING_YAML);
|
|
35
|
-
}
|
|
36
|
-
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDirectory, APPHOSTING_LOCAL_YAML))) {
|
|
37
|
-
utils_2.logger.logLabeled("SUCCESS", types_1.Emulators.APPHOSTING, `${APPHOSTING_LOCAL_YAML} found, loading configuration`);
|
|
38
|
-
apphostingLocalConfig = await loadAppHostingYaml(sourceDirectory, APPHOSTING_LOCAL_YAML);
|
|
39
|
-
}
|
|
40
|
-
return {
|
|
41
|
-
environmentVariables: Object.assign(Object.assign({}, apphostingBaseConfig.environmentVariables), apphostingLocalConfig.environmentVariables),
|
|
42
|
-
secrets: Object.assign(Object.assign({}, apphostingBaseConfig.secrets), apphostingLocalConfig.secrets),
|
|
43
|
-
};
|
|
13
|
+
const baseFilePath = fileNameToPathMap.get(config_1.APPHOSTING_BASE_YAML_FILE);
|
|
14
|
+
const localFilePath = fileNameToPathMap.get(config_1.APPHOSTING_LOCAL_YAML_FILE);
|
|
15
|
+
return await (0, config_1.loadConfigForEnvironment)(localFilePath !== null && localFilePath !== void 0 ? localFilePath : baseFilePath, baseFilePath);
|
|
44
16
|
}
|
|
45
17
|
exports.getLocalAppHostingConfiguration = getLocalAppHostingConfiguration;
|
|
@@ -6,9 +6,9 @@ const portUtils_1 = require("../portUtils");
|
|
|
6
6
|
const utils_1 = require("./utils");
|
|
7
7
|
const constants_1 = require("../constants");
|
|
8
8
|
const spawn_1 = require("../../init/spawn");
|
|
9
|
-
const config_1 = require("./config");
|
|
10
9
|
const utils_2 = require("./utils");
|
|
11
10
|
const types_1 = require("../types");
|
|
11
|
+
const config_1 = require("./config");
|
|
12
12
|
async function start(options) {
|
|
13
13
|
const hostname = constants_1.DEFAULT_HOST;
|
|
14
14
|
let port = constants_1.DEFAULT_PORTS.apphosting;
|
|
@@ -22,7 +22,11 @@ exports.start = start;
|
|
|
22
22
|
async function serve(port, startCommand) {
|
|
23
23
|
const rootDir = process.cwd();
|
|
24
24
|
const apphostingLocalConfig = await (0, config_1.getLocalAppHostingConfiguration)(rootDir);
|
|
25
|
-
const
|
|
25
|
+
const environmentVariablesAsRecord = {};
|
|
26
|
+
for (const env of apphostingLocalConfig.environmentVariables) {
|
|
27
|
+
environmentVariablesAsRecord[env.variable] = env.value;
|
|
28
|
+
}
|
|
29
|
+
const environmentVariablesToInject = Object.assign(Object.assign({}, environmentVariablesAsRecord), { PORT: port.toString() });
|
|
26
30
|
if (startCommand) {
|
|
27
31
|
utils_2.logger.logLabeled("BULLET", types_1.Emulators.APPHOSTING, `running custom start command: '${startCommand}'`);
|
|
28
32
|
await (0, spawn_1.spawnWithCommandString)(startCommand, rootDir, environmentVariablesToInject);
|
|
@@ -384,5 +384,5 @@ async function checkJavaMajorVersion() {
|
|
|
384
384
|
}
|
|
385
385
|
exports.checkJavaMajorVersion = checkJavaMajorVersion;
|
|
386
386
|
exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = 11;
|
|
387
|
-
exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java
|
|
388
|
-
"Please
|
|
387
|
+
exports.JAVA_DEPRECATION_WARNING = "firebase-tools no longer supports Java versions before 11. " +
|
|
388
|
+
"Please install a JDK at version 11 or above to get a compatible runtime.";
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "1.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "1.6.0",
|
|
52
|
+
expectedSize: 25301760,
|
|
53
|
+
expectedChecksum: "4fad7ada11b35ecea6c8aadf132a5a8a",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "1.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "1.6.0",
|
|
58
|
+
expectedSize: 25731072,
|
|
59
|
+
expectedChecksum: "8d3a59cc79cd74199ee1d8c28012297f",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "1.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "1.6.0",
|
|
63
|
+
expectedSize: 25219224,
|
|
64
|
+
expectedChecksum: "ceb10cfca7ded004c48f7724dbc0cccf",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
|
@@ -7,7 +7,7 @@ const triple_beam_1 = require("triple-beam");
|
|
|
7
7
|
const WebSocket = require("ws");
|
|
8
8
|
const TransportStream = require("winston-transport");
|
|
9
9
|
const logger_1 = require("../logger");
|
|
10
|
-
const
|
|
10
|
+
const node_util_1 = require("node:util");
|
|
11
11
|
class LoggingEmulator {
|
|
12
12
|
constructor(args) {
|
|
13
13
|
this.args = args;
|
|
@@ -106,7 +106,7 @@ class WebSocketTransport extends TransportStream {
|
|
|
106
106
|
if (bundle.data && bundle.data.metadata && bundle.data.metadata.message) {
|
|
107
107
|
bundle.message = bundle.data.metadata.message;
|
|
108
108
|
}
|
|
109
|
-
bundle.message =
|
|
109
|
+
bundle.message = (0, node_util_1.stripVTControlCharacters)(bundle.message);
|
|
110
110
|
this.history.push(bundle);
|
|
111
111
|
this.connections.forEach((ws) => {
|
|
112
112
|
ws.send(JSON.stringify(bundle));
|
|
@@ -25,7 +25,7 @@ const logger_1 = require("../../logger");
|
|
|
25
25
|
const env_1 = require("../../functions/env");
|
|
26
26
|
const DEFAULT_BUILD_SCRIPT = ["next build"];
|
|
27
27
|
const PUBLIC_DIR = "public";
|
|
28
|
-
exports.supportedRange = "12 -
|
|
28
|
+
exports.supportedRange = "12 - 15.0";
|
|
29
29
|
exports.name = "Next.js";
|
|
30
30
|
exports.support = "preview";
|
|
31
31
|
exports.type = 2;
|
|
@@ -126,8 +126,11 @@ async function build(dir, target, context) {
|
|
|
126
126
|
(0, utils_1.readJSON)((0, path_1.join)(dir, distDir, "server", constants_2.SERVER_REFERENCE_MANIFEST)).catch(() => undefined),
|
|
127
127
|
]);
|
|
128
128
|
if (appPathRoutesManifest) {
|
|
129
|
-
const headersFromMetaFiles = await (0, utils_2.
|
|
129
|
+
const { headers: headersFromMetaFiles, pprRoutes } = await (0, utils_2.getAppMetadataFromMetaFiles)(dir, distDir, baseUrl, appPathRoutesManifest);
|
|
130
130
|
headers.push(...headersFromMetaFiles);
|
|
131
|
+
for (const route of pprRoutes) {
|
|
132
|
+
reasonsForBackend.add(`route with PPR ${route}`);
|
|
133
|
+
}
|
|
131
134
|
if (appPathsManifest) {
|
|
132
135
|
const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
|
|
133
136
|
const notFoundPageKey = ["/_not-found", "/_not-found/page"].find((key) => unrenderedServerComponents.has(key));
|
|
@@ -270,6 +273,7 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
270
273
|
];
|
|
271
274
|
}));
|
|
272
275
|
const routesToCopy = Object.assign(Object.assign({}, prerenderManifest.routes), pagesManifestLikePrerender);
|
|
276
|
+
const { pprRoutes } = await (0, utils_2.getAppMetadataFromMetaFiles)(sourceDir, distDir, basePath, appPathRoutesManifest);
|
|
273
277
|
await Promise.all(Object.entries(routesToCopy).map(async ([path, route]) => {
|
|
274
278
|
var _a, _b;
|
|
275
279
|
if (route.initialRevalidateSeconds) {
|
|
@@ -308,6 +312,10 @@ async function ɵcodegenPublicDirectory(sourceDir, destDir, _, context) {
|
|
|
308
312
|
let defaultDestPath = isDefaultLocale && (0, path_1.join)(destDir, basePath, ...destPartsOrIndex);
|
|
309
313
|
if (!(0, fsutils_1.fileExistsSync)(sourcePath) && (0, fsutils_1.fileExistsSync)(`${sourcePath}.html`)) {
|
|
310
314
|
sourcePath += ".html";
|
|
315
|
+
if (pprRoutes.includes(path)) {
|
|
316
|
+
logger_1.logger.debug(`skipping ${path} due to ppr`);
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
311
319
|
if (localizedDestPath)
|
|
312
320
|
localizedDestPath += ".html";
|
|
313
321
|
if (defaultDestPath)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.installEsbuild = exports.getGlobalEsbuildVersion = exports.findEsbuildPath = exports.whichNextConfigFile = exports.getProductionDistDirFiles = exports.getRoutesWithServerAction = exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.
|
|
3
|
+
exports.installEsbuild = exports.getGlobalEsbuildVersion = exports.findEsbuildPath = exports.whichNextConfigFile = exports.getProductionDistDirFiles = exports.getRoutesWithServerAction = exports.hasStaticAppNotFoundComponent = exports.getNextVersion = exports.getBuildId = exports.getAppMetadataFromMetaFiles = exports.getNonStaticServerComponents = exports.getNonStaticRoutes = exports.getMiddlewareMatcherRegexes = exports.allDependencyNames = exports.isUsingAppDirectory = exports.isUsingNextImageInAppDirectory = exports.isUsingImageOptimization = exports.isUsingMiddleware = exports.hasUnoptimizedImage = exports.usesNextImage = exports.usesAppDirRouter = exports.getNextjsRewritesToUse = exports.isHeaderSupportedByHosting = exports.isRedirectSupportedByHosting = exports.isRewriteSupportedByHosting = exports.cleanI18n = exports.cleanCustomRouteI18n = exports.cleanEscapedChars = exports.I18N_SOURCE = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
@@ -167,8 +167,9 @@ function getNonStaticServerComponents(appPathsManifest, appPathRoutesManifest, p
|
|
|
167
167
|
return new Set(nonStaticServerComponents);
|
|
168
168
|
}
|
|
169
169
|
exports.getNonStaticServerComponents = getNonStaticServerComponents;
|
|
170
|
-
async function
|
|
170
|
+
async function getAppMetadataFromMetaFiles(sourceDir, distDir, basePath, appPathRoutesManifest) {
|
|
171
171
|
const headers = [];
|
|
172
|
+
const pprRoutes = [];
|
|
172
173
|
await Promise.all(Object.entries(appPathRoutesManifest).map(async ([key, source]) => {
|
|
173
174
|
if (!["route", "page"].includes((0, path_1.basename)(key)))
|
|
174
175
|
return;
|
|
@@ -183,11 +184,13 @@ async function getHeadersFromMetaFiles(sourceDir, distDir, basePath, appPathRout
|
|
|
183
184
|
source: path_1.posix.join(basePath, source),
|
|
184
185
|
headers: Object.entries(meta.headers).map(([key, value]) => ({ key, value })),
|
|
185
186
|
});
|
|
187
|
+
if (meta.postponed)
|
|
188
|
+
pprRoutes.push(source);
|
|
186
189
|
}
|
|
187
190
|
}));
|
|
188
|
-
return headers;
|
|
191
|
+
return { headers, pprRoutes };
|
|
189
192
|
}
|
|
190
|
-
exports.
|
|
193
|
+
exports.getAppMetadataFromMetaFiles = getAppMetadataFromMetaFiles;
|
|
191
194
|
async function getBuildId(distDir) {
|
|
192
195
|
const buildId = await (0, promises_1.readFile)((0, path_1.join)(distDir, "BUILD_ID"));
|
|
193
196
|
return buildId.toString();
|
|
@@ -6,7 +6,7 @@ const cross_spawn_1 = require("cross-spawn");
|
|
|
6
6
|
const fs_1 = require("fs");
|
|
7
7
|
const fs_extra_1 = require("fs-extra");
|
|
8
8
|
const path_1 = require("path");
|
|
9
|
-
const
|
|
9
|
+
const node_util_1 = require("node:util");
|
|
10
10
|
const prompt_1 = require("../../prompt");
|
|
11
11
|
const utils_1 = require("../utils");
|
|
12
12
|
exports.name = "Vite";
|
|
@@ -94,7 +94,7 @@ async function getDevModeHandle(dir) {
|
|
|
94
94
|
const serve = (0, cross_spawn_1.spawn)(cli, [], { cwd: dir });
|
|
95
95
|
serve.stdout.on("data", (data) => {
|
|
96
96
|
process.stdout.write(data);
|
|
97
|
-
const dataWithoutAnsiCodes =
|
|
97
|
+
const dataWithoutAnsiCodes = (0, node_util_1.stripVTControlCharacters)(data.toString());
|
|
98
98
|
const match = dataWithoutAnsiCodes.match(/(http:\/\/.+:\d+)/);
|
|
99
99
|
if (match)
|
|
100
100
|
resolve(match[1]);
|
package/lib/fsutils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.readFile = exports.dirExistsSync = exports.fileExistsSync = void 0;
|
|
3
|
+
exports.listFiles = exports.readFile = exports.dirExistsSync = exports.fileExistsSync = void 0;
|
|
4
4
|
const fs_1 = require("fs");
|
|
5
5
|
const error_1 = require("./error");
|
|
6
6
|
function fileExistsSync(path) {
|
|
@@ -33,3 +33,15 @@ function readFile(path) {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
exports.readFile = readFile;
|
|
36
|
+
function listFiles(path) {
|
|
37
|
+
try {
|
|
38
|
+
return (0, fs_1.readdirSync)(path);
|
|
39
|
+
}
|
|
40
|
+
catch (e) {
|
|
41
|
+
if (e.code === "ENOENT") {
|
|
42
|
+
throw new error_1.FirebaseError(`Directory not found: ${path}`);
|
|
43
|
+
}
|
|
44
|
+
throw e;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
exports.listFiles = listFiles;
|
package/lib/gcp/apphosting.js
CHANGED
|
@@ -9,7 +9,7 @@ const ensureApiEnabled_1 = require("../ensureApiEnabled");
|
|
|
9
9
|
const deploymentTool = require("../deploymentTool");
|
|
10
10
|
const error_1 = require("../error");
|
|
11
11
|
const metaprogramming_1 = require("../metaprogramming");
|
|
12
|
-
exports.API_VERSION = "
|
|
12
|
+
exports.API_VERSION = "v1beta";
|
|
13
13
|
exports.client = new apiv2_1.Client({
|
|
14
14
|
urlPrefix: (0, api_1.apphostingOrigin)(),
|
|
15
15
|
auth: true,
|
|
@@ -4,9 +4,12 @@ exports.doSetup = void 0;
|
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const utils = require("../../utils");
|
|
6
6
|
const templates_1 = require("../../templates");
|
|
7
|
+
const cloudbilling_1 = require("../../gcp/cloudbilling");
|
|
7
8
|
const APPHOSTING_YAML_TEMPLATE = (0, templates_1.readTemplateSync)("init/apphosting/apphosting.yaml");
|
|
8
9
|
async function doSetup(setup, config) {
|
|
10
|
+
await (0, cloudbilling_1.checkBillingEnabled)(setup.projectId);
|
|
9
11
|
utils.logBullet("Writing default settings to " + clc.bold("apphosting.yaml") + "...");
|
|
10
12
|
await config.askWriteProjectFile("apphosting.yaml", APPHOSTING_YAML_TEMPLATE);
|
|
13
|
+
utils.logSuccess("Create a new App Hosting backend with `firebase apphosting:backends:create`");
|
|
11
14
|
}
|
|
12
15
|
exports.doSetup = doSetup;
|
package/lib/utils.js
CHANGED
|
@@ -17,7 +17,7 @@ const stream_1 = require("stream");
|
|
|
17
17
|
const winston = require("winston");
|
|
18
18
|
const triple_beam_1 = require("triple-beam");
|
|
19
19
|
const assert_1 = require("assert");
|
|
20
|
-
const
|
|
20
|
+
const node_util_1 = require("node:util");
|
|
21
21
|
const portfinder_1 = require("portfinder");
|
|
22
22
|
const configstore_1 = require("./configstore");
|
|
23
23
|
const error_1 = require("./error");
|
|
@@ -315,7 +315,7 @@ function setupLoggers() {
|
|
|
315
315
|
level: "debug",
|
|
316
316
|
format: winston.format.printf((info) => {
|
|
317
317
|
const segments = [info.message, ...(info[triple_beam_1.SPLAT] || [])].map(tryStringify);
|
|
318
|
-
return `${
|
|
318
|
+
return `${(0, node_util_1.stripVTControlCharacters)(segments.join(" "))}`;
|
|
319
319
|
}),
|
|
320
320
|
}));
|
|
321
321
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "firebase-tools",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.24.0",
|
|
4
4
|
"description": "Command-Line Interface for Firebase",
|
|
5
5
|
"main": "./lib/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -114,7 +114,6 @@
|
|
|
114
114
|
"sql-formatter": "^15.3.0",
|
|
115
115
|
"stream-chain": "^2.2.4",
|
|
116
116
|
"stream-json": "^1.7.3",
|
|
117
|
-
"strip-ansi": "^6.0.1",
|
|
118
117
|
"superstatic": "^9.0.3",
|
|
119
118
|
"tar": "^6.1.11",
|
|
120
119
|
"tcp-port-used": "^1.0.2",
|