firebase-tools 12.2.1 → 12.3.1
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/functions-secrets-access.js +2 -0
- package/lib/commands/functions-secrets-destroy.js +1 -0
- package/lib/commands/functions-secrets-get.js +2 -0
- package/lib/commands/functions-secrets-prune.js +3 -2
- package/lib/commands/functions-secrets-set.js +8 -0
- package/lib/commands/hosting-channel-deploy.js +5 -3
- package/lib/commands/index.js +2 -0
- package/lib/commands/internaltesting-frameworks-compose.js +20 -0
- package/lib/deploy/functions/release/executor.js +19 -10
- package/lib/deploy/functions/release/fabricator.js +22 -8
- package/lib/deploy/index.js +1 -1
- package/lib/emulator/auth/operations.js +2 -2
- package/lib/emulator/commandUtils.js +1 -1
- package/lib/emulator/controller.js +6 -2
- package/lib/emulator/functionsEmulatorShared.js +3 -0
- package/lib/frameworks/angular/index.js +10 -9
- package/lib/frameworks/astro/index.js +8 -6
- package/lib/frameworks/compose/discover/index.js +23 -0
- package/lib/frameworks/compose/driver/docker.js +177 -0
- package/lib/frameworks/compose/driver/hooks.js +22 -0
- package/lib/frameworks/compose/driver/index.js +16 -0
- package/lib/frameworks/compose/driver/local.js +42 -0
- package/lib/frameworks/compose/index.js +30 -0
- package/lib/frameworks/compose/interfaces.js +21 -0
- package/lib/frameworks/index.js +57 -48
- package/lib/frameworks/next/index.js +18 -17
- package/lib/frameworks/nuxt/index.js +7 -7
- package/lib/frameworks/nuxt2/index.js +2 -1
- package/lib/frameworks/utils.js +37 -22
- package/lib/frameworks/vite/index.js +2 -1
- package/lib/functions/secrets.js +8 -1
- package/lib/serve/index.js +1 -1
- package/package.json +1 -1
- package/templates/extensions/extension.yaml +7 -57
- package/templates/extensions/javascript/index.js +1 -1
|
@@ -30,7 +30,7 @@ exports.discover = discover;
|
|
|
30
30
|
async function build(cwd) {
|
|
31
31
|
await (0, utils_1.warnIfCustomBuildScript)(cwd, exports.name, DEFAULT_BUILD_SCRIPT);
|
|
32
32
|
const cli = (0, utils_1.getNodeModuleBin)("nuxt", cwd);
|
|
33
|
-
const { ssr: wantsBackend, app: { baseURL }, } = await getConfig(cwd);
|
|
33
|
+
const { ssr: wantsBackend, app: { baseURL: baseUrl }, } = await getConfig(cwd);
|
|
34
34
|
const command = wantsBackend ? ["build"] : ["generate"];
|
|
35
35
|
const build = (0, cross_spawn_1.sync)(cli, command, {
|
|
36
36
|
cwd,
|
|
@@ -43,11 +43,11 @@ async function build(cwd) {
|
|
|
43
43
|
? []
|
|
44
44
|
: [
|
|
45
45
|
{
|
|
46
|
-
source: path_1.posix.join(
|
|
47
|
-
destination: path_1.posix.join(
|
|
46
|
+
source: path_1.posix.join(baseUrl, "**"),
|
|
47
|
+
destination: path_1.posix.join(baseUrl, "200.html"),
|
|
48
48
|
},
|
|
49
49
|
];
|
|
50
|
-
return { wantsBackend, rewrites };
|
|
50
|
+
return { wantsBackend, rewrites, baseUrl };
|
|
51
51
|
}
|
|
52
52
|
exports.build = build;
|
|
53
53
|
async function ɵcodegenPublicDirectory(root, dest) {
|
|
@@ -64,12 +64,11 @@ async function ɵcodegenFunctionsDirectory(sourceDir) {
|
|
|
64
64
|
const packageJson = JSON.parse(packageJsonBuffer.toString());
|
|
65
65
|
packageJson.dependencies || (packageJson.dependencies = {});
|
|
66
66
|
packageJson.dependencies["nitro-output"] = `file:${serverDir}`;
|
|
67
|
-
|
|
68
|
-
return { packageJson, frameworksEntry: "nitro", baseUrl };
|
|
67
|
+
return { packageJson, frameworksEntry: "nitro" };
|
|
69
68
|
}
|
|
70
69
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
71
70
|
async function getDevModeHandle(cwd) {
|
|
72
|
-
const host = new Promise((resolve) => {
|
|
71
|
+
const host = new Promise((resolve, reject) => {
|
|
73
72
|
const cli = (0, utils_1.getNodeModuleBin)("nuxt", cwd);
|
|
74
73
|
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd: cwd });
|
|
75
74
|
serve.stdout.on("data", (data) => {
|
|
@@ -81,6 +80,7 @@ async function getDevModeHandle(cwd) {
|
|
|
81
80
|
serve.stderr.on("data", (data) => {
|
|
82
81
|
process.stderr.write(data);
|
|
83
82
|
});
|
|
83
|
+
serve.on("exit", reject);
|
|
84
84
|
});
|
|
85
85
|
return (0, utils_1.simpleProxy)(await host);
|
|
86
86
|
}
|
|
@@ -60,7 +60,7 @@ async function ɵcodegenFunctionsDirectory(rootDir, destDir) {
|
|
|
60
60
|
}
|
|
61
61
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
62
62
|
async function getDevModeHandle(cwd) {
|
|
63
|
-
const host = new Promise((resolve) => {
|
|
63
|
+
const host = new Promise((resolve, reject) => {
|
|
64
64
|
const cli = (0, utils_1.getNodeModuleBin)("nuxt", cwd);
|
|
65
65
|
const serve = (0, cross_spawn_1.spawn)(cli, ["dev"], { cwd });
|
|
66
66
|
serve.stdout.on("data", (data) => {
|
|
@@ -72,6 +72,7 @@ async function getDevModeHandle(cwd) {
|
|
|
72
72
|
serve.stderr.on("data", (data) => {
|
|
73
73
|
process.stderr.write(data);
|
|
74
74
|
});
|
|
75
|
+
serve.on("exit", reject);
|
|
75
76
|
});
|
|
76
77
|
return (0, utils_3.simpleProxy)(await host);
|
|
77
78
|
}
|
package/lib/frameworks/utils.js
CHANGED
|
@@ -32,16 +32,31 @@ async function warnIfCustomBuildScript(dir, framework, defaultBuildScripts) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
exports.warnIfCustomBuildScript = warnIfCustomBuildScript;
|
|
35
|
+
function proxyResponse(original, next) {
|
|
36
|
+
return (response) => {
|
|
37
|
+
const { statusCode, statusMessage } = response;
|
|
38
|
+
if (!statusCode) {
|
|
39
|
+
original.end();
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (statusCode === 404) {
|
|
43
|
+
return next();
|
|
44
|
+
}
|
|
45
|
+
const headers = "getHeaders" in response ? response.getHeaders() : response.headers;
|
|
46
|
+
original.writeHead(statusCode, statusMessage, headers);
|
|
47
|
+
response.pipe(original);
|
|
48
|
+
};
|
|
49
|
+
}
|
|
35
50
|
function simpleProxy(hostOrRequestHandler) {
|
|
36
51
|
const agent = new http_1.Agent({ keepAlive: true });
|
|
52
|
+
const firebaseDefaultsJSON = process.env.__FIREBASE_DEFAULTS__;
|
|
53
|
+
const authTokenSyncURL = firebaseDefaultsJSON && JSON.parse(firebaseDefaultsJSON)._authTokenSyncURL;
|
|
37
54
|
return async (originalReq, originalRes, next) => {
|
|
38
55
|
const { method, headers, url: path } = originalReq;
|
|
39
56
|
if (!method || !path) {
|
|
40
57
|
originalRes.end();
|
|
41
58
|
return;
|
|
42
59
|
}
|
|
43
|
-
const firebaseDefaultsJSON = process.env.__FIREBASE_DEFAULTS__;
|
|
44
|
-
const authTokenSyncURL = firebaseDefaultsJSON && JSON.parse(firebaseDefaultsJSON)._authTokenSyncURL;
|
|
45
60
|
if (path === authTokenSyncURL) {
|
|
46
61
|
return next();
|
|
47
62
|
}
|
|
@@ -61,8 +76,13 @@ function simpleProxy(hostOrRequestHandler) {
|
|
|
61
76
|
};
|
|
62
77
|
const req = (0, http_1.request)(opts, (response) => {
|
|
63
78
|
const { statusCode, statusMessage, headers } = response;
|
|
64
|
-
|
|
65
|
-
|
|
79
|
+
if (statusCode === 404) {
|
|
80
|
+
next();
|
|
81
|
+
}
|
|
82
|
+
else {
|
|
83
|
+
originalRes.writeHead(statusCode, statusMessage, headers);
|
|
84
|
+
response.pipe(originalRes);
|
|
85
|
+
}
|
|
66
86
|
});
|
|
67
87
|
originalReq.pipe(req);
|
|
68
88
|
req.on("error", (err) => {
|
|
@@ -71,7 +91,9 @@ function simpleProxy(hostOrRequestHandler) {
|
|
|
71
91
|
});
|
|
72
92
|
}
|
|
73
93
|
else {
|
|
74
|
-
await hostOrRequestHandler(originalReq, originalRes);
|
|
94
|
+
await Promise.resolve(hostOrRequestHandler(originalReq, originalRes, next));
|
|
95
|
+
const proxiedRes = new http_1.ServerResponse(originalReq);
|
|
96
|
+
proxyResponse(originalRes, next)(proxiedRes);
|
|
75
97
|
}
|
|
76
98
|
};
|
|
77
99
|
}
|
|
@@ -183,25 +205,18 @@ function getFrameworksBuildTarget(purpose, validOptions) {
|
|
|
183
205
|
}
|
|
184
206
|
return frameworksBuild;
|
|
185
207
|
}
|
|
186
|
-
else if (
|
|
187
|
-
return "production";
|
|
188
|
-
}
|
|
189
|
-
else if (process.env.NODE_ENV) {
|
|
190
|
-
switch (process.env.NODE_ENV) {
|
|
191
|
-
case "development":
|
|
192
|
-
return "development";
|
|
193
|
-
case "production":
|
|
194
|
-
case "test":
|
|
195
|
-
return "production";
|
|
196
|
-
default:
|
|
197
|
-
throw new error_1.FirebaseError(`We cannot infer your build target from a non-standard NODE_ENV. Please set the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable. Valid values are: ${validOptions.join(", ")}`);
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
else if (purpose === "test") {
|
|
208
|
+
else if (["test", "deploy"].includes(purpose)) {
|
|
201
209
|
return "production";
|
|
202
210
|
}
|
|
203
|
-
|
|
204
|
-
|
|
211
|
+
switch (process.env.NODE_ENV) {
|
|
212
|
+
case undefined:
|
|
213
|
+
case "development":
|
|
214
|
+
return "development";
|
|
215
|
+
case "production":
|
|
216
|
+
case "test":
|
|
217
|
+
return "production";
|
|
218
|
+
default:
|
|
219
|
+
throw new error_1.FirebaseError(`We cannot infer your build target from a non-standard NODE_ENV. Please set the FIREBASE_FRAMEWORKS_BUILD_TARGET environment variable. Valid values are: ${validOptions.join(", ")}`);
|
|
205
220
|
}
|
|
206
221
|
}
|
|
207
222
|
exports.getFrameworksBuildTarget = getFrameworksBuildTarget;
|
|
@@ -72,7 +72,7 @@ async function ɵcodegenPublicDirectory(root, dest) {
|
|
|
72
72
|
}
|
|
73
73
|
exports.ɵcodegenPublicDirectory = ɵcodegenPublicDirectory;
|
|
74
74
|
async function getDevModeHandle(dir) {
|
|
75
|
-
const host = new Promise((resolve) => {
|
|
75
|
+
const host = new Promise((resolve, reject) => {
|
|
76
76
|
const cli = (0, utils_1.getNodeModuleBin)("vite", dir);
|
|
77
77
|
const serve = (0, cross_spawn_1.spawn)(cli, [], { cwd: dir });
|
|
78
78
|
serve.stdout.on("data", (data) => {
|
|
@@ -84,6 +84,7 @@ async function getDevModeHandle(dir) {
|
|
|
84
84
|
serve.stderr.on("data", (data) => {
|
|
85
85
|
process.stderr.write(data);
|
|
86
86
|
});
|
|
87
|
+
serve.on("exit", reject);
|
|
87
88
|
});
|
|
88
89
|
return (0, utils_1.simpleProxy)(await host);
|
|
89
90
|
}
|
package/lib/functions/secrets.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.inUse = exports.getSecretVersions = exports.of = exports.ensureSecret = exports.ensureValidKey = exports.labels = exports.isFirebaseManaged = void 0;
|
|
3
|
+
exports.updateEndpointSecret = exports.pruneAndDestroySecrets = exports.pruneSecrets = exports.inUse = exports.getSecretVersions = exports.of = exports.ensureSecret = exports.ensureValidKey = exports.ensureApi = exports.labels = exports.isFirebaseManaged = void 0;
|
|
4
4
|
const utils = require("../utils");
|
|
5
5
|
const poller = require("../operation-poller");
|
|
6
6
|
const gcf = require("../gcp/cloudfunctions");
|
|
7
|
+
const ensureApiEnabled = require("../ensureApiEnabled");
|
|
7
8
|
const secretManager_1 = require("../gcp/secretManager");
|
|
8
9
|
const error_1 = require("../error");
|
|
9
10
|
const utils_1 = require("../utils");
|
|
@@ -12,6 +13,7 @@ const env_1 = require("./env");
|
|
|
12
13
|
const logger_1 = require("../logger");
|
|
13
14
|
const api_1 = require("../api");
|
|
14
15
|
const functional_1 = require("../functional");
|
|
16
|
+
const projectUtils_1 = require("../projectUtils");
|
|
15
17
|
const FIREBASE_MANAGED = "firebase-managed";
|
|
16
18
|
function isFirebaseManaged(secret) {
|
|
17
19
|
return Object.keys(secret.labels || []).includes(FIREBASE_MANAGED);
|
|
@@ -27,6 +29,11 @@ function toUpperSnakeCase(key) {
|
|
|
27
29
|
.replace(/([a-z])([A-Z])/g, "$1_$2")
|
|
28
30
|
.toUpperCase();
|
|
29
31
|
}
|
|
32
|
+
function ensureApi(options) {
|
|
33
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
34
|
+
return ensureApiEnabled.ensure(projectId, "secretmanager.googleapis.com", "runtimeconfig", true);
|
|
35
|
+
}
|
|
36
|
+
exports.ensureApi = ensureApi;
|
|
30
37
|
async function ensureValidKey(key, options) {
|
|
31
38
|
const transformedKey = toUpperSnakeCase(key);
|
|
32
39
|
if (transformedKey !== key) {
|
package/lib/serve/index.js
CHANGED
|
@@ -19,7 +19,7 @@ async function serve(options) {
|
|
|
19
19
|
options.port = parseInt(options.port, 10);
|
|
20
20
|
if (targetNames.includes("hosting") && config.extract(options).some((it) => it.source)) {
|
|
21
21
|
experiments.assertEnabled("webframeworks", "emulate a web framework");
|
|
22
|
-
await (0, frameworks_1.prepareFrameworks)(targetNames,
|
|
22
|
+
await (0, frameworks_1.prepareFrameworks)("emulate", targetNames, undefined, options);
|
|
23
23
|
}
|
|
24
24
|
const isDemoProject = constants_1.Constants.isDemoProject((0, projectUtils_1.getProjectId)(options) || "");
|
|
25
25
|
targetNames.forEach((targetName) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
# Learn detailed information about the fields of an extension.yaml file in the docs:
|
|
2
2
|
# https://firebase.google.com/docs/extensions/reference/extension-yaml
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
# Identifier for your extension
|
|
5
|
+
# TODO: Replace this with an descriptive name for your extension.
|
|
6
|
+
name: greet-the-world
|
|
5
7
|
version: 0.0.1 # Follow semver versioning
|
|
6
8
|
specVersion: v1beta # Version of the Firebase Extensions specification
|
|
7
9
|
|
|
@@ -14,12 +16,13 @@ description: >-
|
|
|
14
16
|
|
|
15
17
|
license: Apache-2.0 # https://spdx.org/licenses/
|
|
16
18
|
|
|
17
|
-
# Public URL for the source code of your extension
|
|
18
|
-
|
|
19
|
+
# Public URL for the source code of your extension.
|
|
20
|
+
# TODO: Replace this with your GitHub repo.
|
|
21
|
+
sourceUrl: https://github.com/ORG_OR_USER/REPO_NAME
|
|
19
22
|
|
|
20
23
|
# Specify whether a paid-tier billing plan is required to use your extension.
|
|
21
24
|
# Learn more in the docs: https://firebase.google.com/docs/extensions/reference/extension-yaml#billing-required-field
|
|
22
|
-
billingRequired:
|
|
25
|
+
billingRequired: true
|
|
23
26
|
|
|
24
27
|
# In an `apis` field, list any Google APIs (like Cloud Translation, BigQuery, etc.)
|
|
25
28
|
# required for your extension to operate.
|
|
@@ -39,8 +42,6 @@ resources:
|
|
|
39
42
|
description: >-
|
|
40
43
|
HTTP request-triggered function that responds with a specified greeting message
|
|
41
44
|
properties:
|
|
42
|
-
# LOCATION is a user-configured parameter value specified by the user during installation.
|
|
43
|
-
location: ${LOCATION}
|
|
44
45
|
# httpsTrigger is used for an HTTP triggered function.
|
|
45
46
|
httpsTrigger: {}
|
|
46
47
|
runtime: "nodejs16"
|
|
@@ -58,54 +59,3 @@ params:
|
|
|
58
59
|
default: Hello
|
|
59
60
|
required: true
|
|
60
61
|
immutable: false
|
|
61
|
-
|
|
62
|
-
- param: LOCATION
|
|
63
|
-
label: Cloud Functions location
|
|
64
|
-
description: >-
|
|
65
|
-
Where do you want to deploy the functions created for this extension?
|
|
66
|
-
For help selecting a location, refer to the [location selection
|
|
67
|
-
guide](https://firebase.google.com/docs/functions/locations).
|
|
68
|
-
type: select
|
|
69
|
-
options:
|
|
70
|
-
- label: Iowa (us-central1)
|
|
71
|
-
value: us-central1
|
|
72
|
-
- label: South Carolina (us-east1)
|
|
73
|
-
value: us-east1
|
|
74
|
-
- label: Northern Virginia (us-east4)
|
|
75
|
-
value: us-east4
|
|
76
|
-
- label: Los Angeles (us-west2)
|
|
77
|
-
value: us-west2
|
|
78
|
-
- label: Salt Lake City (us-west3)
|
|
79
|
-
value: us-west3
|
|
80
|
-
- label: Las Vegas (us-west4)
|
|
81
|
-
value: us-west4
|
|
82
|
-
- label: Warsaw (europe-central2)
|
|
83
|
-
value: europe-central2
|
|
84
|
-
- label: Belgium (europe-west1)
|
|
85
|
-
value: europe-west1
|
|
86
|
-
- label: London (europe-west2)
|
|
87
|
-
value: europe-west2
|
|
88
|
-
- label: Frankfurt (europe-west3)
|
|
89
|
-
value: europe-west3
|
|
90
|
-
- label: Zurich (europe-west6)
|
|
91
|
-
value: europe-west6
|
|
92
|
-
- label: Hong Kong (asia-east2)
|
|
93
|
-
value: asia-east2
|
|
94
|
-
- label: Tokyo (asia-northeast1)
|
|
95
|
-
value: asia-northeast1
|
|
96
|
-
- label: Osaka (asia-northeast2)
|
|
97
|
-
value: asia-northeast2
|
|
98
|
-
- label: Seoul (asia-northeast3)
|
|
99
|
-
value: asia-northeast3
|
|
100
|
-
- label: Mumbai (asia-south1)
|
|
101
|
-
value: asia-south1
|
|
102
|
-
- label: Jakarta (asia-southeast2)
|
|
103
|
-
value: asia-southeast2
|
|
104
|
-
- label: Montreal (northamerica-northeast1)
|
|
105
|
-
value: northamerica-northeast1
|
|
106
|
-
- label: Sao Paulo (southamerica-east1)
|
|
107
|
-
value: southamerica-east1
|
|
108
|
-
- label: Sydney (australia-southeast1)
|
|
109
|
-
value: australia-southeast1
|
|
110
|
-
required: true
|
|
111
|
-
immutable: true
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* Reference PARAMETERS in your functions code with:
|
|
6
6
|
* `process.env.<parameter-name>`
|
|
7
7
|
* Learn more about building extensions in the docs:
|
|
8
|
-
* https://firebase.google.com/docs/extensions/
|
|
8
|
+
* https://firebase.google.com/docs/extensions/publishers
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
11
|
const functions = require("firebase-functions");
|