firebase-tools-with-isolate 13.6.4 → 13.7.3
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/README.md +4 -6
- package/lib/api.js +1 -1
- package/lib/apphosting/app.js +88 -0
- package/lib/apphosting/config.js +97 -0
- package/lib/apphosting/githubConnections.js +265 -0
- package/lib/{init/features/apphosting → apphosting}/index.js +52 -26
- package/lib/{init/features/apphosting → apphosting}/repo.js +10 -10
- package/lib/apphosting/secrets/dialogs.js +170 -0
- package/lib/apphosting/secrets/index.js +97 -0
- package/lib/commands/apphosting-backends-create.js +7 -3
- package/lib/commands/apphosting-backends-delete.js +5 -4
- package/lib/commands/apphosting-backends-get.js +8 -8
- package/lib/commands/apphosting-backends-list.js +2 -2
- package/lib/commands/apphosting-secrets-access.js +24 -0
- package/lib/commands/apphosting-secrets-describe.js +29 -0
- package/lib/commands/apphosting-secrets-grantaccess.js +45 -0
- package/lib/commands/apphosting-secrets-set.js +56 -0
- package/lib/commands/firestore-databases-create.js +1 -0
- package/lib/commands/firestore-databases-restore.js +1 -0
- package/lib/commands/functions-secrets-access.js +2 -2
- package/lib/commands/functions-secrets-describe.js +14 -0
- package/lib/commands/functions-secrets-destroy.js +2 -2
- package/lib/commands/functions-secrets-get.js +3 -17
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +3 -19
- package/lib/commands/index.js +14 -6
- package/lib/deploy/firestore/prepare.js +4 -2
- package/lib/deploy/functions/checkIam.js +3 -6
- package/lib/deploy/functions/containerCleaner.js +1 -15
- package/lib/deploy/functions/deploy.js +2 -2
- package/lib/deploy/functions/params.js +2 -2
- package/lib/deploy/functions/prepare.js +13 -3
- package/lib/deploy/functions/pricing.js +2 -2
- package/lib/deploy/functions/prompts.js +39 -7
- package/lib/deploy/functions/release/fabricator.js +5 -5
- package/lib/deploy/functions/release/index.js +17 -2
- package/lib/deploy/functions/release/planner.js +11 -3
- package/lib/deploy/functions/runtimes/discovery/index.js +3 -3
- package/lib/deploy/functions/runtimes/index.js +6 -43
- package/lib/deploy/functions/runtimes/node/index.js +3 -2
- package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +15 -34
- package/lib/deploy/functions/runtimes/python/index.js +10 -7
- package/lib/deploy/functions/runtimes/supported/index.js +80 -0
- package/lib/deploy/functions/runtimes/supported/types.js +74 -0
- package/lib/deploy/functions/services/index.js +4 -0
- package/lib/downloadUtils.js +1 -0
- package/lib/emulator/controller.js +5 -1
- package/lib/emulator/functionsEmulator.js +2 -2
- package/lib/emulator/hub.js +5 -0
- package/lib/experiments.js +12 -0
- package/lib/extensions/emulator/specHelper.js +7 -6
- package/lib/extensions/extensionsApi.js +2 -2
- package/lib/extensions/localHelper.js +3 -3
- package/lib/firestore/pretty-print.js +5 -0
- package/lib/frameworks/astro/index.js +1 -1
- package/lib/frameworks/flutter/index.js +2 -2
- package/lib/frameworks/next/constants.js +2 -1
- package/lib/frameworks/next/index.js +22 -12
- package/lib/frameworks/next/utils.js +32 -3
- package/lib/functional.js +2 -2
- package/lib/functions/events/v2.js +7 -1
- package/lib/functions/secrets.js +40 -22
- package/lib/gcp/apphosting.js +14 -2
- package/lib/gcp/cloudbuild.js +7 -3
- package/lib/gcp/cloudfunctions.js +5 -5
- package/lib/gcp/cloudfunctionsv2.js +3 -3
- package/lib/gcp/cloudscheduler.js +2 -2
- package/lib/gcp/computeEngine.js +7 -0
- package/lib/gcp/devConnect.js +24 -11
- package/lib/gcp/iam.js +9 -1
- package/lib/gcp/secretManager.js +54 -6
- package/lib/gcp/serviceusage.js +24 -5
- package/lib/init/features/functions/python.js +4 -3
- package/lib/init/features/hosting/github.js +4 -5
- package/lib/init/features/index.js +1 -1
- package/lib/utils.js +23 -6
- package/package.json +4 -4
- package/schema/firebase-config.json +12 -2
- package/templates/init/functions/typescript/_eslintrc +1 -0
- /package/lib/{init/features/apphosting → apphosting}/constants.js +0 -0
|
@@ -1,31 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRuntimeChoice = exports.
|
|
3
|
+
exports.getRuntimeChoice = exports.RUNTIME_NOT_SET = void 0;
|
|
4
4
|
const path = require("path");
|
|
5
|
-
const clc = require("colorette");
|
|
6
5
|
const error_1 = require("../../../../error");
|
|
7
|
-
const
|
|
6
|
+
const supported = require("../supported");
|
|
8
7
|
const cjson = require("cjson");
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
14: "nodejs14",
|
|
15
|
-
16: "nodejs16",
|
|
16
|
-
18: "nodejs18",
|
|
17
|
-
20: "nodejs20",
|
|
18
|
-
};
|
|
19
|
-
const ENGINE_RUNTIMES_NAMES = Object.values(ENGINE_RUNTIMES);
|
|
20
|
-
exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in firebase.json.\n" +
|
|
8
|
+
const supportedNodeVersions = Object.keys(supported.RUNTIMES)
|
|
9
|
+
.filter((s) => supported.runtimeIsLanguage(s, "nodejs"))
|
|
10
|
+
.filter((s) => !supported.isDecommissioned(s))
|
|
11
|
+
.map((s) => s.substring("nodejs".length));
|
|
12
|
+
exports.RUNTIME_NOT_SET = "`runtime` field is required but was not found in firebase.json or package.json.\n" +
|
|
21
13
|
"To fix this, add the following lines to the `functions` section of your firebase.json:\n" +
|
|
22
|
-
|
|
23
|
-
exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG = clc.bold(`functions.runtime value is unsupported. ` +
|
|
24
|
-
`Valid choices are: ${clc.bold("nodejs{10|12|14|16|18|20}")}.`);
|
|
25
|
-
exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG = clc.bold(`package.json in functions directory has an engines field which is unsupported. ` +
|
|
26
|
-
`Valid choices are: ${clc.bold('{"node": 10|12|14|16|18|20}')}`);
|
|
27
|
-
exports.DEPRECATED_NODE_VERSION_INFO = `\n\nDeploys to runtimes below Node.js 10 are now disabled in the Firebase CLI. ` +
|
|
28
|
-
`${clc.bold(`Existing Node.js 8 functions ${clc.underline("will stop executing at a future date")}`)}. Update existing functions to Node.js 10 or greater as soon as possible.`;
|
|
14
|
+
`"runtime": "${supported.latest("nodejs")}" or set the "engine" field in package.json\n`;
|
|
29
15
|
function getRuntimeChoiceFromPackageJson(sourceDir) {
|
|
30
16
|
const packageJsonPath = path.join(sourceDir, "package.json");
|
|
31
17
|
let loaded;
|
|
@@ -39,19 +25,14 @@ function getRuntimeChoiceFromPackageJson(sourceDir) {
|
|
|
39
25
|
if (!engines || !engines.node) {
|
|
40
26
|
throw new error_1.FirebaseError(exports.RUNTIME_NOT_SET);
|
|
41
27
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const errorMessage = (runtimeFromConfig
|
|
47
|
-
? exports.UNSUPPORTED_NODE_VERSION_FIREBASE_JSON_MSG
|
|
48
|
-
: exports.UNSUPPORTED_NODE_VERSION_PACKAGE_JSON_MSG) + exports.DEPRECATED_NODE_VERSION_INFO;
|
|
49
|
-
if (!runtime || !ENGINE_RUNTIMES_NAMES.includes(runtime)) {
|
|
50
|
-
throw new error_1.FirebaseError(errorMessage, { exit: 1 });
|
|
51
|
-
}
|
|
52
|
-
if (runtimes.isDeprecatedRuntime(runtime) || !runtimes.isValidRuntime(runtime)) {
|
|
53
|
-
throw new error_1.FirebaseError(errorMessage, { exit: 1 });
|
|
28
|
+
const runtime = `nodejs${engines.node}`;
|
|
29
|
+
if (!supported.isRuntime(runtime)) {
|
|
30
|
+
throw new error_1.FirebaseError(`Detected node engine ${engines.node} in package.json, which is not a ` +
|
|
31
|
+
`supported version. Valid versions are ${supportedNodeVersions.join(", ")}`);
|
|
54
32
|
}
|
|
55
33
|
return runtime;
|
|
56
34
|
}
|
|
35
|
+
function getRuntimeChoice(sourceDir, runtimeFromConfig) {
|
|
36
|
+
return runtimeFromConfig || getRuntimeChoiceFromPackageJson(sourceDir);
|
|
37
|
+
}
|
|
57
38
|
exports.getRuntimeChoice = getRuntimeChoice;
|
|
@@ -1,27 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Delegate = exports.getPythonBinary = exports.tryCreateDelegate =
|
|
3
|
+
exports.Delegate = exports.getPythonBinary = exports.tryCreateDelegate = void 0;
|
|
4
4
|
const fs = require("fs");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const node_fetch_1 = require("node-fetch");
|
|
7
7
|
const util_1 = require("util");
|
|
8
8
|
const portfinder = require("portfinder");
|
|
9
|
-
const runtimes = require("..");
|
|
10
9
|
const discovery = require("../discovery");
|
|
10
|
+
const supported = require("../supported");
|
|
11
11
|
const logger_1 = require("../../../../logger");
|
|
12
12
|
const python_1 = require("../../../../functions/python");
|
|
13
13
|
const error_1 = require("../../../../error");
|
|
14
|
-
|
|
14
|
+
const functional_1 = require("../../../../functional");
|
|
15
15
|
async function tryCreateDelegate(context) {
|
|
16
16
|
const requirementsTextPath = path.join(context.sourceDir, "requirements.txt");
|
|
17
17
|
if (!(await (0, util_1.promisify)(fs.exists)(requirementsTextPath))) {
|
|
18
18
|
logger_1.logger.debug("Customer code is not Python code.");
|
|
19
19
|
return;
|
|
20
20
|
}
|
|
21
|
-
const runtime = context.runtime
|
|
22
|
-
if (!
|
|
21
|
+
const runtime = context.runtime ?? supported.latest("python");
|
|
22
|
+
if (!supported.isRuntime(runtime)) {
|
|
23
23
|
throw new error_1.FirebaseError(`Runtime ${runtime} is not a valid Python runtime`);
|
|
24
24
|
}
|
|
25
|
+
if (!supported.runtimeIsLanguage(runtime, "python")) {
|
|
26
|
+
throw new error_1.FirebaseError(`Internal error. Trying to construct a python runtime delegate for runtime ${runtime}`, { exit: 1 });
|
|
27
|
+
}
|
|
25
28
|
return Promise.resolve(new Delegate(context.projectId, context.sourceDir, runtime));
|
|
26
29
|
}
|
|
27
30
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
@@ -38,7 +41,7 @@ function getPythonBinary(runtime) {
|
|
|
38
41
|
else if (runtime === "python312") {
|
|
39
42
|
return "python3.12";
|
|
40
43
|
}
|
|
41
|
-
|
|
44
|
+
(0, functional_1.assertExhaustive)(runtime, `Unhandled python runtime ${runtime}`);
|
|
42
45
|
}
|
|
43
46
|
exports.getPythonBinary = getPythonBinary;
|
|
44
47
|
class Delegate {
|
|
@@ -46,7 +49,7 @@ class Delegate {
|
|
|
46
49
|
this.projectId = projectId;
|
|
47
50
|
this.sourceDir = sourceDir;
|
|
48
51
|
this.runtime = runtime;
|
|
49
|
-
this.
|
|
52
|
+
this.language = "python";
|
|
50
53
|
this._bin = "";
|
|
51
54
|
this._modulesDir = "";
|
|
52
55
|
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.guardVersionSupport = exports.isDecommissioned = exports.latest = exports.runtimeIsLanguage = exports.isRuntime = void 0;
|
|
18
|
+
const error_1 = require("../../../../error");
|
|
19
|
+
const utils = require("../../../../utils");
|
|
20
|
+
const types_1 = require("./types");
|
|
21
|
+
__exportStar(require("./types"), exports);
|
|
22
|
+
function isRuntime(maybe) {
|
|
23
|
+
return maybe in types_1.RUNTIMES;
|
|
24
|
+
}
|
|
25
|
+
exports.isRuntime = isRuntime;
|
|
26
|
+
function runtimeIsLanguage(runtime, language) {
|
|
27
|
+
return runtime.startsWith(language);
|
|
28
|
+
}
|
|
29
|
+
exports.runtimeIsLanguage = runtimeIsLanguage;
|
|
30
|
+
function latest(language, runtimes = Object.keys(types_1.RUNTIMES)) {
|
|
31
|
+
const sorted = runtimes
|
|
32
|
+
.filter((s) => runtimeIsLanguage(s, language))
|
|
33
|
+
.sort((left, right) => {
|
|
34
|
+
const leftVersion = +left.substring(language.length);
|
|
35
|
+
const rightVersion = +right.substring(language.length);
|
|
36
|
+
if (isNaN(leftVersion) || isNaN(rightVersion)) {
|
|
37
|
+
throw new error_1.FirebaseError("Internal error. Runtime or language names are malformed", {
|
|
38
|
+
exit: 1,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
return leftVersion - rightVersion;
|
|
42
|
+
});
|
|
43
|
+
const latest = utils.last(sorted);
|
|
44
|
+
if (!latest) {
|
|
45
|
+
throw new error_1.FirebaseError(`Internal error trying to find the latest supported runtime for ${language}`, { exit: 1 });
|
|
46
|
+
}
|
|
47
|
+
return latest;
|
|
48
|
+
}
|
|
49
|
+
exports.latest = latest;
|
|
50
|
+
function isDecommissioned(runtime, now = new Date()) {
|
|
51
|
+
const cutoff = new Date(types_1.RUNTIMES[runtime].decommissionDate);
|
|
52
|
+
return cutoff < now;
|
|
53
|
+
}
|
|
54
|
+
exports.isDecommissioned = isDecommissioned;
|
|
55
|
+
function guardVersionSupport(runtime, now = new Date()) {
|
|
56
|
+
const { deprecationDate, decommissionDate } = types_1.RUNTIMES[runtime];
|
|
57
|
+
const decommission = new Date(decommissionDate);
|
|
58
|
+
if (now >= decommission) {
|
|
59
|
+
throw new error_1.FirebaseError(`Runtime ${types_1.RUNTIMES[runtime].friendly} was decommissioned on ${decommissionDate}. To deploy ` +
|
|
60
|
+
"you must first upgrade your runtime version.", { exit: 1 });
|
|
61
|
+
}
|
|
62
|
+
const deprecation = new Date(deprecationDate);
|
|
63
|
+
if (now >= deprecation) {
|
|
64
|
+
utils.logLabeledWarning("functions", `Runtime ${types_1.RUNTIMES[runtime].friendly} was deprecated on ${deprecationDate} and will be ` +
|
|
65
|
+
`decommissioned on ${decommissionDate}, after which you will not be able ` +
|
|
66
|
+
"to deploy without upgrading. Consider upgrading now to avoid disruption. See " +
|
|
67
|
+
"https://cloud.google.com/functions/docs/runtime-support for full " +
|
|
68
|
+
"details on the lifecycle policy");
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
const warning = new Date(deprecation.getTime() - 90 * 24 * 60 * 60 * 1000);
|
|
72
|
+
if (now >= warning) {
|
|
73
|
+
utils.logLabeledWarning("functions", `Runtime ${types_1.RUNTIMES[runtime].friendly} will be deprecated on ${deprecationDate} and will be ` +
|
|
74
|
+
`decommissioned on ${decommissionDate}, after which you will not be able ` +
|
|
75
|
+
"to deploy without upgrading. Consider upgrading now to avoid disruption. See " +
|
|
76
|
+
"https://cloud.google.com/functions/docs/runtime-support for full " +
|
|
77
|
+
"details on the lifecycle policy");
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.guardVersionSupport = guardVersionSupport;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RUNTIMES = void 0;
|
|
4
|
+
function runtimes(r) {
|
|
5
|
+
return r;
|
|
6
|
+
}
|
|
7
|
+
exports.RUNTIMES = runtimes({
|
|
8
|
+
nodejs6: {
|
|
9
|
+
friendly: "Node.js 6",
|
|
10
|
+
status: "decommissioned",
|
|
11
|
+
deprecationDate: "2019-04-17",
|
|
12
|
+
decommissionDate: "2020-08-01",
|
|
13
|
+
},
|
|
14
|
+
nodejs8: {
|
|
15
|
+
friendly: "Node.js 8",
|
|
16
|
+
status: "decommissioned",
|
|
17
|
+
deprecationDate: "2020-06-05",
|
|
18
|
+
decommissionDate: "2021-02-01",
|
|
19
|
+
},
|
|
20
|
+
nodejs10: {
|
|
21
|
+
friendly: "Node.js 10",
|
|
22
|
+
status: "GA",
|
|
23
|
+
deprecationDate: "2024-01-30",
|
|
24
|
+
decommissionDate: "2025-01-30",
|
|
25
|
+
},
|
|
26
|
+
nodejs12: {
|
|
27
|
+
friendly: "Node.js 12",
|
|
28
|
+
status: "GA",
|
|
29
|
+
deprecationDate: "2024-01-30",
|
|
30
|
+
decommissionDate: "2025-01-30",
|
|
31
|
+
},
|
|
32
|
+
nodejs14: {
|
|
33
|
+
friendly: "Node.js 14",
|
|
34
|
+
status: "GA",
|
|
35
|
+
deprecationDate: "2024-01-30",
|
|
36
|
+
decommissionDate: "2025-01-30",
|
|
37
|
+
},
|
|
38
|
+
nodejs16: {
|
|
39
|
+
friendly: "Node.js 16",
|
|
40
|
+
status: "GA",
|
|
41
|
+
deprecationDate: "2024-01-30",
|
|
42
|
+
decommissionDate: "2025-01-30",
|
|
43
|
+
},
|
|
44
|
+
nodejs18: {
|
|
45
|
+
friendly: "Node.js 18",
|
|
46
|
+
status: "GA",
|
|
47
|
+
deprecationDate: "2025-04-30",
|
|
48
|
+
decommissionDate: "2025-10-31",
|
|
49
|
+
},
|
|
50
|
+
nodejs20: {
|
|
51
|
+
friendly: "Node.js 20",
|
|
52
|
+
status: "GA",
|
|
53
|
+
deprecationDate: "2026-04-30",
|
|
54
|
+
decommissionDate: "2026-10-31",
|
|
55
|
+
},
|
|
56
|
+
python310: {
|
|
57
|
+
friendly: "Python 3.10",
|
|
58
|
+
status: "GA",
|
|
59
|
+
deprecationDate: "2026-10-04",
|
|
60
|
+
decommissionDate: "2027-04-30",
|
|
61
|
+
},
|
|
62
|
+
python311: {
|
|
63
|
+
friendly: "Python 3.11",
|
|
64
|
+
status: "GA",
|
|
65
|
+
deprecationDate: "2027-10-24",
|
|
66
|
+
decommissionDate: "2028-04-30",
|
|
67
|
+
},
|
|
68
|
+
python312: {
|
|
69
|
+
friendly: "Python 3.12",
|
|
70
|
+
status: "GA",
|
|
71
|
+
deprecationDate: "2028-10-02",
|
|
72
|
+
decommissionDate: "2029-04-30",
|
|
73
|
+
},
|
|
74
|
+
});
|
|
@@ -104,6 +104,10 @@ const EVENT_SERVICE_MAPPING = {
|
|
|
104
104
|
"google.cloud.firestore.document.v1.created": firestoreService,
|
|
105
105
|
"google.cloud.firestore.document.v1.updated": firestoreService,
|
|
106
106
|
"google.cloud.firestore.document.v1.deleted": firestoreService,
|
|
107
|
+
"google.cloud.firestore.document.v1.written.withAuthContext": firestoreService,
|
|
108
|
+
"google.cloud.firestore.document.v1.created.withAuthContext": firestoreService,
|
|
109
|
+
"google.cloud.firestore.document.v1.updated.withAuthContext": firestoreService,
|
|
110
|
+
"google.cloud.firestore.document.v1.deleted.withAuthContext": firestoreService,
|
|
107
111
|
};
|
|
108
112
|
function serviceForEndpoint(endpoint) {
|
|
109
113
|
if (backend.isEventTriggered(endpoint)) {
|
package/lib/downloadUtils.js
CHANGED
|
@@ -13,6 +13,7 @@ async function downloadToTmp(remoteUrl) {
|
|
|
13
13
|
const tmpfile = tmp.fileSync();
|
|
14
14
|
const writeStream = fs.createWriteStream(tmpfile.name);
|
|
15
15
|
const res = await c.request({
|
|
16
|
+
ignoreQuotaProject: true,
|
|
16
17
|
method: "GET",
|
|
17
18
|
path: u.pathname,
|
|
18
19
|
queryParams: u.searchParams,
|
|
@@ -41,6 +41,7 @@ const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
|
41
41
|
const frameworks_1 = require("../frameworks");
|
|
42
42
|
const experiments = require("../experiments");
|
|
43
43
|
const portUtils_1 = require("./portUtils");
|
|
44
|
+
const supported_1 = require("../deploy/functions/runtimes/supported");
|
|
44
45
|
const START_LOGGING_EMULATOR = utils.envOverride("START_LOGGING_EMULATOR", "false", (val) => val === "true");
|
|
45
46
|
async function exportOnExit(options) {
|
|
46
47
|
const exportOnExitDir = options.exportOnExit;
|
|
@@ -306,7 +307,10 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
306
307
|
utils.assertIsStringOrUndefined(options.extDevDir);
|
|
307
308
|
for (const cfg of functionsCfg) {
|
|
308
309
|
const functionsDir = path.join(projectDir, cfg.source);
|
|
309
|
-
const runtime = options.extDevRuntime ?? cfg.runtime;
|
|
310
|
+
const runtime = (options.extDevRuntime ?? cfg.runtime);
|
|
311
|
+
if (runtime && !(0, supported_1.isRuntime)(runtime)) {
|
|
312
|
+
throw new error_1.FirebaseError(`Cannot load functions from ${functionsDir} because it has invalid runtime ${runtime}`);
|
|
313
|
+
}
|
|
310
314
|
emulatableBackends.push({
|
|
311
315
|
functionsDir,
|
|
312
316
|
runtime,
|
|
@@ -300,9 +300,9 @@ class FunctionsEmulator {
|
|
|
300
300
|
runtime: emulatableBackend.runtime,
|
|
301
301
|
};
|
|
302
302
|
const runtimeDelegate = await runtimes.getRuntimeDelegate(runtimeDelegateContext);
|
|
303
|
-
logger_1.logger.debug(`Validating ${runtimeDelegate.
|
|
303
|
+
logger_1.logger.debug(`Validating ${runtimeDelegate.language} source`);
|
|
304
304
|
await runtimeDelegate.validate();
|
|
305
|
-
logger_1.logger.debug(`Building ${runtimeDelegate.
|
|
305
|
+
logger_1.logger.debug(`Building ${runtimeDelegate.language} source`);
|
|
306
306
|
await runtimeDelegate.build();
|
|
307
307
|
emulatableBackend.runtime = runtimeDelegate.runtime;
|
|
308
308
|
emulatableBackend.bin = runtimeDelegate.bin;
|
package/lib/emulator/hub.js
CHANGED
|
@@ -60,6 +60,11 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
60
60
|
res.json(body);
|
|
61
61
|
});
|
|
62
62
|
app.post(EmulatorHub.PATH_EXPORT, async (req, res) => {
|
|
63
|
+
if (req.headers.origin) {
|
|
64
|
+
res.status(403).json({
|
|
65
|
+
message: `Export cannot be triggered by external callers.`,
|
|
66
|
+
});
|
|
67
|
+
}
|
|
63
68
|
const path = req.body.path;
|
|
64
69
|
const initiatedBy = req.body.initiatedBy || "unknown";
|
|
65
70
|
utils.logLabeledBullet("emulators", `Received export request. Exporting data to ${path}.`);
|
package/lib/experiments.js
CHANGED
|
@@ -39,6 +39,18 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
39
39
|
"of how that image was created.",
|
|
40
40
|
public: true,
|
|
41
41
|
},
|
|
42
|
+
automaticallydeletegcfartifacts: {
|
|
43
|
+
shortDescription: "Control whether functions cleans up images after deploys",
|
|
44
|
+
fullDescription: "To control costs, Firebase defaults to automatically deleting containers " +
|
|
45
|
+
"created during the build process. This has the side-effect of preventing " +
|
|
46
|
+
"users from rolling back to previous revisions using the Run API. To change " +
|
|
47
|
+
`this behavior, call ${(0, colorette_1.bold)("experiments:disable deletegcfartifactsondeploy")} ` +
|
|
48
|
+
`consider also calling ${(0, colorette_1.bold)("experiments:enable deletegcfartifacts")} ` +
|
|
49
|
+
`to enable the new command ${(0, colorette_1.bold)("functions:deletegcfartifacts")} which` +
|
|
50
|
+
"lets you clean up images manually",
|
|
51
|
+
public: true,
|
|
52
|
+
default: true,
|
|
53
|
+
},
|
|
42
54
|
emulatoruisnapshot: {
|
|
43
55
|
shortDescription: "Load pre-release versions of the emulator UI",
|
|
44
56
|
},
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getRuntime = exports.DEFAULT_RUNTIME = exports.getFunctionProperties = exports.getFunctionResourcesWithParamSubstitution = exports.readFileFromDirectory = exports.readPostinstall = exports.readExtensionYaml = void 0;
|
|
4
|
-
const yaml = require("
|
|
4
|
+
const yaml = require("yaml");
|
|
5
5
|
const path = require("path");
|
|
6
6
|
const fs = require("fs-extra");
|
|
7
|
+
const supported = require("../../deploy/functions/runtimes/supported");
|
|
7
8
|
const error_1 = require("../../error");
|
|
8
9
|
const extensionsHelper_1 = require("../extensionsHelper");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
@@ -16,10 +17,10 @@ const validFunctionTypes = [
|
|
|
16
17
|
];
|
|
17
18
|
function wrappedSafeLoad(source) {
|
|
18
19
|
try {
|
|
19
|
-
return yaml.
|
|
20
|
+
return yaml.parse(source);
|
|
20
21
|
}
|
|
21
22
|
catch (err) {
|
|
22
|
-
if (err instanceof yaml.
|
|
23
|
+
if (err instanceof yaml.YAMLParseError) {
|
|
23
24
|
throw new error_1.FirebaseError(`YAML Error: ${err.message}`, { original: err });
|
|
24
25
|
}
|
|
25
26
|
throw err;
|
|
@@ -76,7 +77,7 @@ function getFunctionProperties(resources) {
|
|
|
76
77
|
return resources.map((r) => r.properties);
|
|
77
78
|
}
|
|
78
79
|
exports.getFunctionProperties = getFunctionProperties;
|
|
79
|
-
exports.DEFAULT_RUNTIME = "
|
|
80
|
+
exports.DEFAULT_RUNTIME = supported.latest("nodejs");
|
|
80
81
|
function getRuntime(resources) {
|
|
81
82
|
if (resources.length === 0) {
|
|
82
83
|
return exports.DEFAULT_RUNTIME;
|
|
@@ -87,7 +88,7 @@ function getRuntime(resources) {
|
|
|
87
88
|
if (!runtime) {
|
|
88
89
|
return exports.DEFAULT_RUNTIME;
|
|
89
90
|
}
|
|
90
|
-
if (
|
|
91
|
+
if (!supported.runtimeIsLanguage(runtime, "nodejs")) {
|
|
91
92
|
invalidRuntimes.push(runtime);
|
|
92
93
|
return exports.DEFAULT_RUNTIME;
|
|
93
94
|
}
|
|
@@ -96,6 +97,6 @@ function getRuntime(resources) {
|
|
|
96
97
|
if (invalidRuntimes.length) {
|
|
97
98
|
throw new error_1.FirebaseError(`The following runtimes are not supported by the Emulator Suite: ${invalidRuntimes.join(", ")}. \n Only Node runtimes are supported.`);
|
|
98
99
|
}
|
|
99
|
-
return
|
|
100
|
+
return supported.latest("nodejs", runtimes);
|
|
100
101
|
}
|
|
101
102
|
exports.getRuntime = getRuntime;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.refNotFoundError = exports.getExtension = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.populateSpec = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
|
|
4
|
-
const yaml = require("
|
|
4
|
+
const yaml = require("yaml");
|
|
5
5
|
const clc = require("colorette");
|
|
6
6
|
const apiv2_1 = require("../apiv2");
|
|
7
7
|
const api_1 = require("../api");
|
|
@@ -225,7 +225,7 @@ function populateSpec(spec) {
|
|
|
225
225
|
for (const r of spec.resources) {
|
|
226
226
|
try {
|
|
227
227
|
if (r.propertiesYaml) {
|
|
228
|
-
r.properties = yaml.
|
|
228
|
+
r.properties = yaml.parse(r.propertiesYaml);
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
231
|
catch (err) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.isLocalExtension = exports.readFile = exports.findExtensionYaml = exports.getLocalExtensionSpec = exports.EXTENSIONS_SPEC_FILE = void 0;
|
|
4
4
|
const fs = require("fs-extra");
|
|
5
5
|
const path = require("path");
|
|
6
|
-
const yaml = require("
|
|
6
|
+
const yaml = require("yaml");
|
|
7
7
|
const fsutils_1 = require("../fsutils");
|
|
8
8
|
const error_1 = require("../error");
|
|
9
9
|
const logger_1 = require("../logger");
|
|
@@ -56,10 +56,10 @@ function isLocalExtension(extensionName) {
|
|
|
56
56
|
exports.isLocalExtension = isLocalExtension;
|
|
57
57
|
function parseYAML(source) {
|
|
58
58
|
try {
|
|
59
|
-
return yaml.
|
|
59
|
+
return yaml.parse(source);
|
|
60
60
|
}
|
|
61
61
|
catch (err) {
|
|
62
|
-
if (err instanceof yaml.
|
|
62
|
+
if (err instanceof yaml.YAMLParseError) {
|
|
63
63
|
throw new error_1.FirebaseError(`YAML Error: ${err.message}`, { original: err });
|
|
64
64
|
}
|
|
65
65
|
throw new error_1.FirebaseError(err.message);
|
|
@@ -7,6 +7,7 @@ const sort = require("./api-sort");
|
|
|
7
7
|
const types = require("./api-types");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const util = require("./util");
|
|
10
|
+
const utils_1 = require("../utils");
|
|
10
11
|
class PrettyPrint {
|
|
11
12
|
prettyPrintIndexes(indexes) {
|
|
12
13
|
if (indexes.length === 0) {
|
|
@@ -163,6 +164,10 @@ class PrettyPrint {
|
|
|
163
164
|
prettyDatabaseString(database) {
|
|
164
165
|
return clc.yellow(typeof database === "string" ? database : database.name);
|
|
165
166
|
}
|
|
167
|
+
firebaseConsoleDatabaseUrl(project, databaseId) {
|
|
168
|
+
const urlFriendlyDatabaseId = databaseId === "(default)" ? "-default-" : databaseId;
|
|
169
|
+
return (0, utils_1.consoleUrl)(project, `/firestore/databases/${urlFriendlyDatabaseId}/data`);
|
|
170
|
+
}
|
|
166
171
|
prettyFieldString(field) {
|
|
167
172
|
let result = "";
|
|
168
173
|
const parsedName = util.parseFieldName(field.name);
|
|
@@ -10,7 +10,7 @@ const utils_2 = require("./utils");
|
|
|
10
10
|
exports.name = "Astro";
|
|
11
11
|
exports.support = "experimental";
|
|
12
12
|
exports.type = 2;
|
|
13
|
-
exports.supportedRange = "2 -
|
|
13
|
+
exports.supportedRange = "2 - 4";
|
|
14
14
|
async function discover(dir) {
|
|
15
15
|
if (!(0, fs_extra_1.existsSync)((0, path_1.join)(dir, "package.json")))
|
|
16
16
|
return;
|
|
@@ -4,7 +4,7 @@ exports.ɵcodegenPublicDirectory = exports.build = exports.init = exports.discov
|
|
|
4
4
|
const cross_spawn_1 = require("cross-spawn");
|
|
5
5
|
const fs_extra_1 = require("fs-extra");
|
|
6
6
|
const path_1 = require("path");
|
|
7
|
-
const
|
|
7
|
+
const yaml = require("yaml");
|
|
8
8
|
const promises_1 = require("fs/promises");
|
|
9
9
|
const error_1 = require("../../error");
|
|
10
10
|
const utils_1 = require("./utils");
|
|
@@ -18,7 +18,7 @@ async function discover(dir) {
|
|
|
18
18
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "web"))))
|
|
19
19
|
return;
|
|
20
20
|
const pubSpecBuffer = await (0, promises_1.readFile)((0, path_1.join)(dir, "pubspec.yaml"));
|
|
21
|
-
const pubSpec =
|
|
21
|
+
const pubSpec = yaml.parse(pubSpecBuffer.toString());
|
|
22
22
|
const usingFlutter = pubSpec.dependencies?.flutter;
|
|
23
23
|
if (!usingFlutter)
|
|
24
24
|
return;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
|
|
3
|
+
exports.WEBPACK_LAYERS = exports.ESBUILD_VERSION = exports.CONFIG_FILES = exports.SERVER_REFERENCE_MANIFEST = exports.APP_PATHS_MANIFEST = exports.ROUTES_MANIFEST = exports.PRERENDER_MANIFEST = exports.PAGES_MANIFEST = exports.MIDDLEWARE_MANIFEST = exports.IMAGES_MANIFEST = exports.EXPORT_MARKER = exports.APP_PATH_ROUTES_MANIFEST = void 0;
|
|
4
4
|
exports.APP_PATH_ROUTES_MANIFEST = "app-path-routes-manifest.json";
|
|
5
5
|
exports.EXPORT_MARKER = "export-marker.json";
|
|
6
6
|
exports.IMAGES_MANIFEST = "images-manifest.json";
|
|
@@ -10,6 +10,7 @@ exports.PRERENDER_MANIFEST = "prerender-manifest.json";
|
|
|
10
10
|
exports.ROUTES_MANIFEST = "routes-manifest.json";
|
|
11
11
|
exports.APP_PATHS_MANIFEST = "app-paths-manifest.json";
|
|
12
12
|
exports.SERVER_REFERENCE_MANIFEST = "server-reference-manifest.json";
|
|
13
|
+
exports.CONFIG_FILES = ["next.config.js", "next.config.mjs"];
|
|
13
14
|
exports.ESBUILD_VERSION = "0.19.2";
|
|
14
15
|
const WEBPACK_LAYERS_NAMES = {
|
|
15
16
|
shared: "shared",
|
|
@@ -7,7 +7,6 @@ const promises_1 = require("fs/promises");
|
|
|
7
7
|
const path_1 = require("path");
|
|
8
8
|
const fs_extra_1 = require("fs-extra");
|
|
9
9
|
const url_1 = require("url");
|
|
10
|
-
const fs_1 = require("fs");
|
|
11
10
|
const semver_1 = require("semver");
|
|
12
11
|
const clc = require("colorette");
|
|
13
12
|
const stream_chain_1 = require("stream-chain");
|
|
@@ -39,7 +38,7 @@ async function discover(dir) {
|
|
|
39
38
|
if (!(await (0, fs_extra_1.pathExists)((0, path_1.join)(dir, "package.json"))))
|
|
40
39
|
return;
|
|
41
40
|
const version = (0, utils_2.getNextVersion)(dir);
|
|
42
|
-
if (!(await (0,
|
|
41
|
+
if (!(await (0, utils_2.whichNextConfigFile)(dir)) && !version)
|
|
43
42
|
return;
|
|
44
43
|
return { mayWantBackend: true, publicDirectory: (0, path_1.join)(dir, PUBLIC_DIR), version };
|
|
45
44
|
}
|
|
@@ -335,7 +334,8 @@ exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
|
335
334
|
async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context) {
|
|
336
335
|
const { distDir } = await getConfig(sourceDir);
|
|
337
336
|
const packageJson = await (0, utils_1.readJSON)((0, path_1.join)(sourceDir, "package.json"));
|
|
338
|
-
|
|
337
|
+
const configFile = await (0, utils_2.whichNextConfigFile)(sourceDir);
|
|
338
|
+
if (configFile) {
|
|
339
339
|
try {
|
|
340
340
|
const productionDeps = await new Promise((resolve) => {
|
|
341
341
|
const dependencies = [];
|
|
@@ -360,8 +360,14 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
360
360
|
});
|
|
361
361
|
const esbuildArgs = productionDeps
|
|
362
362
|
.map((it) => `--external:${it}`)
|
|
363
|
-
.concat("--bundle", "--platform=node", `--target=node${constants_1.NODE_VERSION}`,
|
|
364
|
-
|
|
363
|
+
.concat("--bundle", "--platform=node", `--target=node${constants_1.NODE_VERSION}`, "--log-level=error");
|
|
364
|
+
if (configFile === "next.config.mjs") {
|
|
365
|
+
esbuildArgs.push(...[`--outfile=${(0, path_1.join)(destDir, configFile)}`, "--format=esm"]);
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
esbuildArgs.push(`--outfile=${(0, path_1.join)(destDir, configFile)}`);
|
|
369
|
+
}
|
|
370
|
+
const bundle = (0, cross_spawn_1.sync)("npx", ["--yes", `esbuild@${constants_2.ESBUILD_VERSION}`, configFile, ...esbuildArgs], {
|
|
365
371
|
cwd: sourceDir,
|
|
366
372
|
timeout: BUNDLE_NEXT_CONFIG_TIMEOUT,
|
|
367
373
|
});
|
|
@@ -370,9 +376,9 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
370
376
|
}
|
|
371
377
|
}
|
|
372
378
|
catch (e) {
|
|
373
|
-
console.warn(
|
|
379
|
+
console.warn(`Unable to bundle ${configFile} for use in Cloud Functions, proceeding with deploy but problems may be encountered.`);
|
|
374
380
|
console.error(e.message || e);
|
|
375
|
-
(0, fs_extra_1.copy)((0, path_1.join)(sourceDir,
|
|
381
|
+
await (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, configFile), (0, path_1.join)(destDir, configFile));
|
|
376
382
|
}
|
|
377
383
|
}
|
|
378
384
|
if (await (0, fs_extra_1.pathExists)((0, path_1.join)(sourceDir, "public"))) {
|
|
@@ -389,8 +395,11 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
389
395
|
dotEnv["VERCEL_URL"] = deploymentDomain;
|
|
390
396
|
}
|
|
391
397
|
}
|
|
392
|
-
|
|
393
|
-
|
|
398
|
+
const [productionDistDirfiles] = await Promise.all([
|
|
399
|
+
(0, utils_2.getProductionDistDirFiles)(sourceDir, distDir),
|
|
400
|
+
(0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir)),
|
|
401
|
+
]);
|
|
402
|
+
await Promise.all(productionDistDirfiles.map((file) => (0, fs_extra_1.copy)(file, file.replace(sourceDir, destDir), { recursive: true })));
|
|
394
403
|
return { packageJson, frameworksEntry: "next.js", dotEnv };
|
|
395
404
|
}
|
|
396
405
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
@@ -420,7 +429,8 @@ exports.getDevModeHandle = getDevModeHandle;
|
|
|
420
429
|
async function getConfig(dir) {
|
|
421
430
|
var _a;
|
|
422
431
|
let config = {};
|
|
423
|
-
|
|
432
|
+
const configFile = await (0, utils_2.whichNextConfigFile)(dir);
|
|
433
|
+
if (configFile) {
|
|
424
434
|
const version = (0, utils_2.getNextVersion)(dir);
|
|
425
435
|
if (!version)
|
|
426
436
|
throw new Error("Unable to find the next dep, try NPM installing?");
|
|
@@ -433,10 +443,10 @@ async function getConfig(dir) {
|
|
|
433
443
|
}
|
|
434
444
|
else {
|
|
435
445
|
try {
|
|
436
|
-
config = await (_a = (0, url_1.pathToFileURL)((0, path_1.join)(dir,
|
|
446
|
+
config = await (_a = (0, url_1.pathToFileURL)((0, path_1.join)(dir, configFile)).toString(), Promise.resolve().then(() => require(_a)));
|
|
437
447
|
}
|
|
438
448
|
catch (e) {
|
|
439
|
-
throw new Error(
|
|
449
|
+
throw new Error(`Unable to load ${configFile}.`);
|
|
440
450
|
}
|
|
441
451
|
}
|
|
442
452
|
}
|