firebase-tools-with-isolate 14.10.1 → 14.16.0-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/api.js +5 -1
- package/lib/apphosting/backend.js +40 -15
- package/lib/apptesting/ensureProjectConfigured.js +56 -0
- package/lib/apptesting/invokeTests.js +40 -0
- package/lib/apptesting/parseTestFiles.js +75 -0
- package/lib/apptesting/types.js +18 -0
- package/lib/auth.js +37 -2
- package/lib/command.js +24 -5
- package/lib/commands/apphosting-backends-create.js +8 -5
- package/lib/commands/apptesting-execute.js +101 -0
- package/lib/commands/dataconnect-sdk-generate.js +28 -26
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/dataconnect-sql-diff.js +2 -2
- package/lib/commands/dataconnect-sql-grant.js +7 -2
- package/lib/commands/dataconnect-sql-migrate.js +2 -2
- package/lib/commands/dataconnect-sql-setup.js +3 -5
- package/lib/commands/dataconnect-sql-shell.js +2 -2
- package/lib/commands/ext-export.js +1 -1
- package/lib/commands/firestore-bulkdelete.js +73 -0
- package/lib/commands/firestore-databases-create.js +11 -0
- package/lib/commands/firestore-operations-cancel.js +44 -0
- package/lib/commands/firestore-operations-describe.js +29 -0
- package/lib/commands/firestore-operations-list.js +29 -0
- package/lib/commands/firestore-utils.js +15 -0
- package/lib/commands/functions-config-clone.js +2 -0
- package/lib/commands/functions-config-export.js +5 -2
- package/lib/commands/functions-config-get.js +2 -0
- package/lib/commands/functions-config-set.js +2 -0
- package/lib/commands/functions-config-unset.js +2 -0
- package/lib/commands/index.js +9 -0
- package/lib/commands/init.js +24 -4
- package/lib/commands/internaltesting-functions-discover.js +20 -5
- package/lib/commands/login.js +13 -9
- package/lib/commands/use.js +5 -0
- package/lib/config.js +16 -4
- package/lib/crashlytics/addNote.js +27 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -2
- package/lib/crashlytics/deleteNote.js +23 -0
- package/lib/crashlytics/getIssueDetails.js +26 -0
- package/lib/crashlytics/getSampleCrash.js +34 -0
- package/lib/crashlytics/listNotes.js +29 -0
- package/lib/crashlytics/listTopDevices.js +33 -0
- package/lib/crashlytics/listTopIssues.js +8 -23
- package/lib/crashlytics/listTopOperatingSystems.js +32 -0
- package/lib/crashlytics/listTopVersions.js +32 -0
- package/lib/crashlytics/updateIssue.js +35 -0
- package/lib/crashlytics/utils.js +38 -0
- package/lib/dataconnect/appFinder.js +102 -0
- package/lib/dataconnect/client.js +23 -15
- package/lib/dataconnect/ensureApis.js +6 -9
- package/lib/dataconnect/errors.js +7 -1
- package/lib/dataconnect/freeTrial.js +16 -38
- package/lib/dataconnect/load.js +105 -6
- package/lib/dataconnect/provisionCloudSql.js +67 -70
- package/lib/dataconnect/schemaMigration.js +219 -169
- package/lib/deploy/dataconnect/deploy.js +7 -9
- package/lib/deploy/dataconnect/prepare.js +7 -12
- package/lib/deploy/dataconnect/release.js +43 -31
- package/lib/deploy/firestore/deploy.js +10 -0
- package/lib/deploy/functions/backend.js +7 -1
- package/lib/deploy/functions/build.js +28 -14
- package/lib/deploy/functions/deploy.js +3 -2
- package/lib/deploy/functions/ensure.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +8 -1
- package/lib/deploy/functions/params.js +4 -0
- package/lib/deploy/functions/prepare.js +25 -13
- package/lib/deploy/functions/pricing.js +12 -5
- package/lib/deploy/functions/release/fabricator.js +25 -3
- package/lib/deploy/functions/release/reporter.js +1 -0
- package/lib/deploy/functions/runtimes/discovery/index.js +52 -5
- package/lib/deploy/functions/runtimes/node/index.js +83 -51
- package/lib/emulator/auth/operations.js +10 -1
- package/lib/emulator/commandUtils.js +7 -1
- package/lib/emulator/controller.js +22 -34
- package/lib/emulator/dataconnectEmulator.js +27 -24
- package/lib/emulator/downloadableEmulatorInfo.json +18 -18
- package/lib/emulator/env.js +2 -1
- package/lib/emulator/functionsEmulator.js +12 -2
- package/lib/emulator/hub.js +11 -8
- package/lib/emulator/tasksEmulator.js +1 -1
- package/lib/emulator/ui.js +3 -1
- package/lib/env.js +18 -0
- package/lib/experiments.js +20 -0
- package/lib/extensions/extensionsHelper.js +4 -15
- package/lib/extensions/runtimes/common.js +3 -2
- package/lib/extensions/utils.js +1 -12
- package/lib/firestore/api-sort.js +96 -3
- package/lib/firestore/api-types.js +20 -1
- package/lib/firestore/api.js +144 -15
- package/lib/firestore/pretty-print.js +35 -1
- package/lib/firestore/validator.js +1 -1
- package/lib/functional.js +7 -1
- package/lib/functions/deprecationWarnings.js +21 -0
- package/lib/functions/env.js +31 -16
- package/lib/functions/projectConfig.js +87 -8
- package/lib/functions/secrets.js +3 -0
- package/lib/gcp/cloudfunctions.js +1 -6
- package/lib/gcp/cloudfunctionsv2.js +3 -39
- package/lib/gcp/cloudscheduler.js +1 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +4 -16
- package/lib/gcp/cloudsql/connect.js +4 -3
- package/lib/gcp/cloudsql/permissionsSetup.js +23 -16
- package/lib/gcp/k8s.js +32 -0
- package/lib/gcp/runv2.js +181 -0
- package/lib/gemini/fdcExperience.js +5 -3
- package/lib/init/features/aitools/claude.js +43 -0
- package/lib/init/features/aitools/cursor.js +61 -0
- package/lib/init/features/aitools/gemini.js +58 -0
- package/lib/init/features/aitools/index.js +28 -0
- package/lib/init/features/aitools/promptUpdater.js +111 -0
- package/lib/init/features/aitools/studio.js +17 -0
- package/lib/init/features/aitools/types.js +2 -0
- package/lib/init/features/aitools.js +83 -0
- package/lib/init/features/apptesting/index.js +34 -0
- package/lib/init/features/dataconnect/create_app.js +53 -0
- package/lib/init/features/dataconnect/index.js +280 -186
- package/lib/init/features/dataconnect/sdk.js +232 -144
- package/lib/init/features/index.js +8 -3
- package/lib/init/features/project.js +4 -0
- package/lib/init/index.js +18 -2
- package/lib/management/apps.js +3 -3
- package/lib/management/studio.js +120 -0
- package/lib/mcp/errors.js +5 -7
- package/lib/mcp/index.js +179 -61
- package/lib/mcp/logging-transport.js +23 -0
- package/lib/mcp/prompt.js +10 -0
- package/lib/mcp/prompts/core/deploy.js +101 -0
- package/lib/mcp/prompts/core/index.js +5 -0
- package/lib/mcp/prompts/crashlytics/connect.js +114 -0
- package/lib/mcp/prompts/crashlytics/index.js +5 -0
- package/lib/mcp/prompts/dataconnect/index.js +9 -0
- package/lib/mcp/prompts/dataconnect/schema.js +67 -0
- package/lib/mcp/prompts/index.js +47 -0
- package/lib/mcp/tools/apphosting/fetch_logs.js +22 -22
- package/lib/mcp/tools/apphosting/list_backends.js +10 -10
- package/lib/mcp/tools/auth/disable_user.js +7 -7
- package/lib/mcp/tools/auth/get_user.js +13 -6
- package/lib/mcp/tools/auth/index.js +10 -10
- package/lib/mcp/tools/auth/list_users.js +6 -6
- package/lib/mcp/tools/auth/set_claims.js +7 -7
- package/lib/mcp/tools/auth/set_sms_region_policy.js +6 -6
- package/lib/mcp/tools/core/consult_assistant.js +13 -8
- package/lib/mcp/tools/core/create_android_sha.js +9 -9
- package/lib/mcp/tools/core/create_app.js +7 -7
- package/lib/mcp/tools/core/create_project.js +13 -13
- package/lib/mcp/tools/core/get_admin_sdk_config.js +7 -7
- package/lib/mcp/tools/core/get_environment.js +8 -8
- package/lib/mcp/tools/core/get_project.js +5 -5
- package/lib/mcp/tools/core/get_sdk_config.js +19 -9
- package/lib/mcp/tools/core/index.js +28 -24
- package/lib/mcp/tools/core/init.js +39 -16
- package/lib/mcp/tools/core/list_apps.js +6 -6
- package/lib/mcp/tools/core/list_projects.js +6 -6
- package/lib/mcp/tools/core/login.js +46 -0
- package/lib/mcp/tools/core/logout.js +62 -0
- package/lib/mcp/tools/core/update_environment.js +10 -10
- package/lib/mcp/tools/crashlytics/add_note.js +32 -0
- package/lib/mcp/tools/crashlytics/constants.js +11 -0
- package/lib/mcp/tools/crashlytics/delete_note.js +35 -0
- package/lib/mcp/tools/crashlytics/get_issue_details.js +31 -0
- package/lib/mcp/tools/crashlytics/get_sample_crash.js +43 -0
- package/lib/mcp/tools/crashlytics/index.js +22 -2
- package/lib/mcp/tools/crashlytics/list_notes.js +37 -0
- package/lib/mcp/tools/crashlytics/list_top_devices.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_issues.js +12 -13
- package/lib/mcp/tools/crashlytics/list_top_operating_systems.js +33 -0
- package/lib/mcp/tools/crashlytics/list_top_versions.js +33 -0
- package/lib/mcp/tools/crashlytics/update_issue.js +37 -0
- package/lib/mcp/tools/database/get_data.js +49 -0
- package/lib/mcp/tools/database/get_rules.js +39 -0
- package/lib/mcp/tools/database/index.js +8 -0
- package/lib/mcp/tools/database/set_data.js +57 -0
- package/lib/mcp/tools/database/validate_rules.js +41 -0
- package/lib/mcp/tools/dataconnect/compile.js +43 -0
- package/lib/mcp/tools/dataconnect/execute.js +71 -0
- package/lib/mcp/tools/dataconnect/generate_operation.js +8 -8
- package/lib/mcp/tools/dataconnect/generate_schema.js +6 -6
- package/lib/mcp/tools/dataconnect/index.js +10 -18
- package/lib/mcp/tools/dataconnect/list_services.js +107 -11
- package/lib/mcp/tools/firestore/delete_document.js +13 -13
- package/lib/mcp/tools/firestore/get_documents.js +13 -13
- package/lib/mcp/tools/firestore/list_collections.js +7 -10
- package/lib/mcp/tools/firestore/query_collection.js +13 -13
- package/lib/mcp/tools/index.js +24 -18
- package/lib/mcp/tools/messaging/index.js +2 -2
- package/lib/mcp/tools/messaging/send_message.js +7 -7
- package/lib/mcp/tools/remoteconfig/get_template.js +5 -5
- package/lib/mcp/tools/remoteconfig/index.js +4 -4
- package/lib/mcp/tools/remoteconfig/publish_template.js +7 -7
- package/lib/mcp/tools/remoteconfig/rollback_template.js +6 -6
- package/lib/mcp/tools/rules/get_rules.js +8 -8
- package/lib/mcp/tools/rules/validate_rules.js +10 -10
- package/lib/mcp/tools/storage/get_download_url.js +8 -8
- package/lib/mcp/tools/storage/get_rules.js +8 -8
- package/lib/mcp/types.js +2 -0
- package/lib/mcp/util/dataconnect/compile.js +20 -0
- package/lib/mcp/util/dataconnect/content.js +655 -0
- package/lib/mcp/util/dataconnect/emulator.js +16 -0
- package/lib/mcp/util.js +5 -18
- package/lib/requireAuth.js +14 -4
- package/lib/rtdb.js +10 -6
- package/lib/scopes.js +2 -1
- package/lib/serve/functions.js +4 -3
- package/lib/timeout.js +21 -0
- package/lib/track.js +18 -1
- package/lib/unzip.js +13 -0
- package/lib/utils.js +76 -2
- package/package.json +6 -4
- package/prompts/FIREBASE.md +121 -0
- package/prompts/FIREBASE_FUNCTIONS.md +221 -0
- package/schema/apptesting-yaml.json +64 -0
- package/schema/firebase-config.json +163 -53
- package/templates/init/aitools/cursor-rules-header.txt +8 -0
- package/templates/init/aitools/gemini-extension.json +11 -0
- package/templates/init/apptesting/smoke_test.yaml +6 -0
- package/templates/init/dataconnect/connector.yaml +0 -16
- package/templates/init/dataconnect/dataconnect.yaml +2 -1
- package/templates/init/dataconnect/mutations.gql +29 -29
- package/templates/init/dataconnect/queries.gql +73 -73
- package/templates/init/dataconnect/schema.gql +48 -48
- package/templates/init/firestore/firestore.indexes.json +26 -1
- package/lib/dataconnect/fileUtils.js +0 -168
- package/lib/emulator/adminSdkConfig.test.js +0 -16
- package/lib/extensions/resolveSource.js +0 -23
- package/lib/firestore/api-sort.test.js +0 -74
- package/lib/firestore/backupUtils.test.js +0 -18
- package/lib/firestore/pretty-print.test.js +0 -61
- package/lib/firestore/util.test.js +0 -42
- package/lib/mcp/tools/dataconnect/emulator.js +0 -16
- package/lib/mcp/tools/dataconnect/execute_graphql.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_graphql_read.js +0 -48
- package/lib/mcp/tools/dataconnect/execute_mutation.js +0 -62
- package/lib/mcp/tools/dataconnect/execute_query.js +0 -62
- package/lib/mcp/tools/dataconnect/get_connector.js +0 -31
- package/lib/mcp/tools/dataconnect/get_schema.js +0 -31
- /package/lib/mcp/{tools → util}/dataconnect/converter.js +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Delegate = exports.tryCreateDelegate = void 0;
|
|
4
|
-
const
|
|
4
|
+
const os = require("os");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const portfinder = require("portfinder");
|
|
@@ -22,7 +22,10 @@ const MIN_FUNCTIONS_SDK_VERSION = "3.20.0";
|
|
|
22
22
|
const MIN_FUNCTIONS_SDK_VERSION_FOR_EXTENSIONS_FEATURES = "5.1.0";
|
|
23
23
|
async function tryCreateDelegate(context) {
|
|
24
24
|
const packageJsonPath = path.join(context.sourceDir, "package.json");
|
|
25
|
-
|
|
25
|
+
try {
|
|
26
|
+
await fs.promises.access(packageJsonPath);
|
|
27
|
+
}
|
|
28
|
+
catch {
|
|
26
29
|
logger_1.logger.debug("Customer code is not Node");
|
|
27
30
|
return undefined;
|
|
28
31
|
}
|
|
@@ -93,19 +96,7 @@ class Delegate {
|
|
|
93
96
|
watch() {
|
|
94
97
|
return Promise.resolve(() => Promise.resolve());
|
|
95
98
|
}
|
|
96
|
-
|
|
97
|
-
const env = {
|
|
98
|
-
...envs,
|
|
99
|
-
PORT: port,
|
|
100
|
-
FUNCTIONS_CONTROL_API: "true",
|
|
101
|
-
HOME: process.env.HOME,
|
|
102
|
-
PATH: process.env.PATH,
|
|
103
|
-
NODE_ENV: process.env.NODE_ENV,
|
|
104
|
-
__FIREBASE_FRAMEWORKS_ENTRY__: process.env.__FIREBASE_FRAMEWORKS_ENTRY__,
|
|
105
|
-
};
|
|
106
|
-
if (Object.keys(config || {}).length) {
|
|
107
|
-
env.CLOUD_RUNTIME_CONFIG = JSON.stringify(config);
|
|
108
|
-
}
|
|
99
|
+
findFunctionsBinary() {
|
|
109
100
|
const sourceNodeModulesPath = path.join(this.sourceDir, "node_modules");
|
|
110
101
|
const projectNodeModulesPath = path.join(this.projectDir, "node_modules");
|
|
111
102
|
const sdkPath = require.resolve("firebase-functions", { paths: [this.sourceDir] });
|
|
@@ -120,40 +111,65 @@ class Delegate {
|
|
|
120
111
|
const binPath = path.join(nodeModulesPath, ".bin", "firebase-functions");
|
|
121
112
|
if ((0, fsutils_1.fileExistsSync)(binPath)) {
|
|
122
113
|
logger_1.logger.debug(`Found firebase-functions binary at '${binPath}'`);
|
|
123
|
-
|
|
124
|
-
env,
|
|
125
|
-
cwd: this.sourceDir,
|
|
126
|
-
stdio: ["ignore", "pipe", "pipe"],
|
|
127
|
-
});
|
|
128
|
-
childProcess.stdout?.on("data", (chunk) => {
|
|
129
|
-
logger_1.logger.info(chunk.toString("utf8"));
|
|
130
|
-
});
|
|
131
|
-
childProcess.stderr?.on("data", (chunk) => {
|
|
132
|
-
logger_1.logger.error(chunk.toString("utf8"));
|
|
133
|
-
});
|
|
134
|
-
return Promise.resolve(async () => {
|
|
135
|
-
const p = new Promise((resolve, reject) => {
|
|
136
|
-
childProcess.once("exit", resolve);
|
|
137
|
-
childProcess.once("error", reject);
|
|
138
|
-
});
|
|
139
|
-
try {
|
|
140
|
-
await (0, node_fetch_1.default)(`http://localhost:${port}/__/quitquitquit`);
|
|
141
|
-
}
|
|
142
|
-
catch (e) {
|
|
143
|
-
logger_1.logger.debug("Failed to call quitquitquit. This often means the server failed to start", e);
|
|
144
|
-
}
|
|
145
|
-
setTimeout(() => {
|
|
146
|
-
if (!childProcess.killed) {
|
|
147
|
-
childProcess.kill("SIGKILL");
|
|
148
|
-
}
|
|
149
|
-
}, 10000);
|
|
150
|
-
return p;
|
|
151
|
-
});
|
|
114
|
+
return binPath;
|
|
152
115
|
}
|
|
153
116
|
}
|
|
154
117
|
throw new error_1.FirebaseError("Failed to find location of Firebase Functions SDK. " +
|
|
155
118
|
"Please file a bug on Github (https://github.com/firebase/firebase-tools/).");
|
|
156
119
|
}
|
|
120
|
+
spawnFunctionsProcess(config, envs) {
|
|
121
|
+
const env = {
|
|
122
|
+
...envs,
|
|
123
|
+
FUNCTIONS_CONTROL_API: "true",
|
|
124
|
+
HOME: process.env.HOME,
|
|
125
|
+
PATH: process.env.PATH,
|
|
126
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
127
|
+
__FIREBASE_FRAMEWORKS_ENTRY__: process.env.__FIREBASE_FRAMEWORKS_ENTRY__,
|
|
128
|
+
};
|
|
129
|
+
if (Object.keys(config || {}).length) {
|
|
130
|
+
env.CLOUD_RUNTIME_CONFIG = JSON.stringify(config);
|
|
131
|
+
}
|
|
132
|
+
const binPath = this.findFunctionsBinary();
|
|
133
|
+
const childProcess = spawn(binPath, [this.sourceDir], {
|
|
134
|
+
env,
|
|
135
|
+
cwd: this.sourceDir,
|
|
136
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
137
|
+
});
|
|
138
|
+
childProcess.stdout?.on("data", (chunk) => {
|
|
139
|
+
logger_1.logger.info(chunk.toString("utf8"));
|
|
140
|
+
});
|
|
141
|
+
childProcess.stderr?.on("data", (chunk) => {
|
|
142
|
+
logger_1.logger.error(chunk.toString("utf8"));
|
|
143
|
+
});
|
|
144
|
+
return childProcess;
|
|
145
|
+
}
|
|
146
|
+
execAdmin(config, envs, manifestPath) {
|
|
147
|
+
return this.spawnFunctionsProcess(config, {
|
|
148
|
+
...envs,
|
|
149
|
+
FUNCTIONS_MANIFEST_OUTPUT_PATH: manifestPath,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
serveAdmin(config, envs, port) {
|
|
153
|
+
const childProcess = this.spawnFunctionsProcess(config, { ...envs, PORT: port });
|
|
154
|
+
return Promise.resolve(async () => {
|
|
155
|
+
const p = new Promise((resolve, reject) => {
|
|
156
|
+
childProcess.once("exit", resolve);
|
|
157
|
+
childProcess.once("error", reject);
|
|
158
|
+
});
|
|
159
|
+
try {
|
|
160
|
+
await (0, node_fetch_1.default)(`http://localhost:${port}/__/quitquitquit`);
|
|
161
|
+
}
|
|
162
|
+
catch (e) {
|
|
163
|
+
logger_1.logger.debug("Failed to call quitquitquit. This often means the server failed to start", e);
|
|
164
|
+
}
|
|
165
|
+
setTimeout(() => {
|
|
166
|
+
if (!childProcess.killed) {
|
|
167
|
+
childProcess.kill("SIGKILL");
|
|
168
|
+
}
|
|
169
|
+
}, 10000);
|
|
170
|
+
return p;
|
|
171
|
+
});
|
|
172
|
+
}
|
|
157
173
|
async discoverBuild(config, env) {
|
|
158
174
|
if (!semver.valid(this.sdkVersion)) {
|
|
159
175
|
logger_1.logger.debug(`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`);
|
|
@@ -170,14 +186,30 @@ class Delegate {
|
|
|
170
186
|
}
|
|
171
187
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
172
188
|
if (!discovered) {
|
|
173
|
-
const
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
189
|
+
const discoveryPath = process.env.FIREBASE_FUNCTIONS_DISCOVERY_OUTPUT_PATH;
|
|
190
|
+
if (!discoveryPath) {
|
|
191
|
+
const basePort = 8000 + (0, utils_1.randomInt)(0, 1000);
|
|
192
|
+
const port = await portfinder.getPortPromise({ port: basePort });
|
|
193
|
+
const kill = await this.serveAdmin(config, env, port.toString());
|
|
194
|
+
try {
|
|
195
|
+
discovered = await discovery.detectFromPort(port, this.projectId, this.runtime);
|
|
196
|
+
}
|
|
197
|
+
finally {
|
|
198
|
+
await kill();
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
else if (discoveryPath === "true") {
|
|
202
|
+
const tempDir = await fs.promises.mkdtemp(path.join(os.tmpdir(), "firebase-discovery-"));
|
|
203
|
+
const manifestPath = path.join(tempDir, "functions.yaml");
|
|
204
|
+
logger_1.logger.debug(`Writing functions discovery manifest to temporary file ${manifestPath}`);
|
|
205
|
+
const childProcess = this.execAdmin(config, env, manifestPath);
|
|
206
|
+
discovered = await discovery.detectFromOutputPath(childProcess, manifestPath, this.projectId, this.runtime);
|
|
178
207
|
}
|
|
179
|
-
|
|
180
|
-
|
|
208
|
+
else {
|
|
209
|
+
const manifestPath = path.join(discoveryPath, "functions.yaml");
|
|
210
|
+
logger_1.logger.debug(`Writing functions discovery manifest to ${manifestPath}`);
|
|
211
|
+
const childProcess = this.execAdmin(config, env, manifestPath);
|
|
212
|
+
discovered = await discovery.detectFromOutputPath(childProcess, manifestPath, this.projectId, this.runtime);
|
|
181
213
|
}
|
|
182
214
|
}
|
|
183
215
|
return discovered;
|
|
@@ -1538,7 +1538,16 @@ async function mfaSignInFinalize(state, reqBody) {
|
|
|
1538
1538
|
(0, errors_1.assert)(sessionInfo, "MISSING_SESSION_INFO");
|
|
1539
1539
|
const phoneNumber = verifyPhoneNumber(state, sessionInfo, code);
|
|
1540
1540
|
let { user, signInProvider } = parsePendingCredential(state, reqBody.mfaPendingCredential);
|
|
1541
|
-
const enrollment = user.mfaInfo?.find((enrollment) =>
|
|
1541
|
+
const enrollment = user.mfaInfo?.find((enrollment) => {
|
|
1542
|
+
if (enrollment.unobfuscatedPhoneInfo === phoneNumber) {
|
|
1543
|
+
return true;
|
|
1544
|
+
}
|
|
1545
|
+
if (!!enrollment.unobfuscatedPhoneInfo &&
|
|
1546
|
+
obfuscatePhoneNumber(enrollment.unobfuscatedPhoneInfo) === phoneNumber) {
|
|
1547
|
+
return true;
|
|
1548
|
+
}
|
|
1549
|
+
return false;
|
|
1550
|
+
});
|
|
1542
1551
|
const { updates, extraClaims } = await fetchBlockingFunction(state, state_1.BlockingFunctionEvents.BEFORE_SIGN_IN, user, { signInMethod: signInProvider, signInSecondFactor: "phone" });
|
|
1543
1552
|
user = state.updateUserByLocalId(user.localId, {
|
|
1544
1553
|
...updates,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.getListenOverview = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DEFAULT_CONFIG = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.DESC_VERBOSITY = exports.FLAG_VERBOSITY = exports.FLAG_VERBOSITY_NAME = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
|
|
3
|
+
exports.JAVA_DEPRECATION_WARNING = exports.MIN_SUPPORTED_JAVA_MAJOR_VERSION = exports.checkJavaMajorVersion = exports.emulatorExec = exports.getListenOverview = exports.shutdownWhenKilled = exports.setExportOnExitOptions = exports.parseInspectionPort = exports.beforeEmulatorCommand = exports.errorMissingProject = exports.warnEmulatorNotSupported = exports.printNoticeIfEmulated = exports.DEFAULT_CONFIG = exports.DESC_TEST_PARAMS = exports.FLAG_TEST_PARAMS = exports.DESC_TEST_CONFIG = exports.FLAG_TEST_CONFIG = exports.DESC_UI = exports.FLAG_UI = exports.DESC_VERBOSITY = exports.FLAG_VERBOSITY = exports.FLAG_VERBOSITY_NAME = exports.EXPORT_ON_EXIT_CWD_DANGER = exports.EXPORT_ON_EXIT_USAGE_ERROR = exports.DESC_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT = exports.FLAG_EXPORT_ON_EXIT_NAME = exports.DESC_IMPORT = exports.FLAG_IMPORT = exports.DESC_INSPECT_FUNCTIONS = exports.FLAG_INSPECT_FUNCTIONS = exports.DESC_ONLY = exports.FLAG_ONLY = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const childProcess = require("child_process");
|
|
6
6
|
const controller = require("../emulator/controller");
|
|
@@ -86,6 +86,12 @@ async function warnEmulatorNotSupported(options, emulator) {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
exports.warnEmulatorNotSupported = warnEmulatorNotSupported;
|
|
89
|
+
async function errorMissingProject(options) {
|
|
90
|
+
if (!options.project) {
|
|
91
|
+
throw new error_1.FirebaseError("Project is not defined. Either use `--project` or use `firebase use` to set your active project.");
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.errorMissingProject = errorMissingProject;
|
|
89
95
|
async function beforeEmulatorCommand(options) {
|
|
90
96
|
const optionsWithDefaultConfig = {
|
|
91
97
|
...options,
|
|
@@ -5,6 +5,7 @@ const clc = require("colorette");
|
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const fsConfig = require("../firestore/fsConfig");
|
|
8
|
+
const proto = require("../gcp/proto");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
9
10
|
const track_1 = require("../track");
|
|
10
11
|
const utils = require("../utils");
|
|
@@ -43,7 +44,7 @@ const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
|
43
44
|
const hostingEmulator_1 = require("./hostingEmulator");
|
|
44
45
|
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
45
46
|
const storage_1 = require("./storage");
|
|
46
|
-
const
|
|
47
|
+
const load_1 = require("../dataconnect/load");
|
|
47
48
|
const tasksEmulator_1 = require("./tasksEmulator");
|
|
48
49
|
const apphosting_1 = require("./apphosting");
|
|
49
50
|
const webhook_1 = require("../dataconnect/webhook");
|
|
@@ -96,7 +97,7 @@ function filterEmulatorTargets(options) {
|
|
|
96
97
|
exports.filterEmulatorTargets = filterEmulatorTargets;
|
|
97
98
|
function shouldStart(options, name) {
|
|
98
99
|
if (name === types_1.Emulators.HUB) {
|
|
99
|
-
return
|
|
100
|
+
return true;
|
|
100
101
|
}
|
|
101
102
|
const targets = filterEmulatorTargets(options);
|
|
102
103
|
const emulatorInTargets = targets.includes(name);
|
|
@@ -107,7 +108,7 @@ function shouldStart(options, name) {
|
|
|
107
108
|
if (options.config.src.emulators?.ui?.enabled === false) {
|
|
108
109
|
return false;
|
|
109
110
|
}
|
|
110
|
-
return
|
|
111
|
+
return targets.some((target) => types_1.EMULATORS_SUPPORTED_BY_UI.includes(target));
|
|
111
112
|
}
|
|
112
113
|
if (name === types_1.Emulators.FUNCTIONS && emulatorInTargets) {
|
|
113
114
|
try {
|
|
@@ -115,7 +116,7 @@ function shouldStart(options, name) {
|
|
|
115
116
|
return true;
|
|
116
117
|
}
|
|
117
118
|
catch (err) {
|
|
118
|
-
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS).logLabeled("
|
|
119
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS).logLabeled("ERROR", "functions", `Failed to start Functions emulator: ${err.message}`);
|
|
119
120
|
return false;
|
|
120
121
|
}
|
|
121
122
|
}
|
|
@@ -185,7 +186,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
185
186
|
}
|
|
186
187
|
const hubLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.HUB);
|
|
187
188
|
hubLogger.logLabeled("BULLET", "emulators", `Starting emulators: ${targets.join(", ")}`);
|
|
188
|
-
const projectId = (0, projectUtils_1.getProjectId)(options) ||
|
|
189
|
+
const projectId = (0, projectUtils_1.getProjectId)(options) || hub_1.EmulatorHub.MISSING_PROJECT_PLACEHOLDER;
|
|
189
190
|
const isDemoProject = constants_1.Constants.isDemoProject(projectId);
|
|
190
191
|
if (isDemoProject) {
|
|
191
192
|
hubLogger.logLabeled("BULLET", "emulators", `Detected demo project ID "${projectId}", emulated services will use a demo configuration and attempts to access non-emulated services for this project will fail.`);
|
|
@@ -337,22 +338,26 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
337
338
|
const functionsCfg = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
338
339
|
utils.assertIsStringOrUndefined(options.extDevDir);
|
|
339
340
|
for (const cfg of functionsCfg) {
|
|
340
|
-
const
|
|
341
|
+
const localCfg = (0, projectConfig_1.requireLocal)(cfg, "Remote sources are not supported in the Functions emulator.");
|
|
342
|
+
const functionsDir = path.join(projectDir, localCfg.source);
|
|
341
343
|
const runtime = (options.extDevRuntime ?? cfg.runtime);
|
|
342
344
|
if (runtime && !(0, supported_1.isRuntime)(runtime)) {
|
|
343
345
|
throw new error_1.FirebaseError(`Cannot load functions from ${functionsDir} because it has invalid runtime ${runtime}`);
|
|
344
346
|
}
|
|
345
|
-
|
|
347
|
+
const backend = {
|
|
346
348
|
functionsDir,
|
|
347
349
|
runtime,
|
|
348
|
-
codebase:
|
|
350
|
+
codebase: localCfg.codebase,
|
|
351
|
+
prefix: localCfg.prefix,
|
|
349
352
|
env: {
|
|
350
353
|
...options.extDevEnv,
|
|
351
354
|
},
|
|
352
355
|
secretEnv: [],
|
|
353
356
|
predefinedTriggers: options.extDevTriggers,
|
|
354
|
-
ignore:
|
|
355
|
-
}
|
|
357
|
+
ignore: localCfg.ignore,
|
|
358
|
+
};
|
|
359
|
+
proto.convertIfPresent(backend, localCfg, "configDir", (cd) => path.join(projectDir, cd));
|
|
360
|
+
emulatableBackends.push(backend);
|
|
356
361
|
}
|
|
357
362
|
}
|
|
358
363
|
if (extensionEmulator) {
|
|
@@ -373,7 +378,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
373
378
|
}
|
|
374
379
|
const functionsLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FUNCTIONS);
|
|
375
380
|
const functionsAddr = legacyGetFirstAddr(types_1.Emulators.FUNCTIONS);
|
|
376
|
-
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
377
381
|
const inspectFunctions = commandUtils.parseInspectionPort(options);
|
|
378
382
|
if (inspectFunctions) {
|
|
379
383
|
functionsLogger.logLabeled("WARN", "functions", `You are running the Functions emulator in debug mode. This means that functions will execute in sequence rather than in parallel.`);
|
|
@@ -462,13 +466,8 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
462
466
|
firestoreLogger.logLabeled("WARN", "firestore", "The emulator will default to allowing all reads and writes. Learn more about this option: https://firebase.google.com/docs/emulator-suite/install_and_configure#security_rules_configuration.");
|
|
463
467
|
}
|
|
464
468
|
if (singleProjectModeEnabled) {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
args.single_project_mode_error = false;
|
|
468
|
-
}
|
|
469
|
-
else {
|
|
470
|
-
firestoreLogger.logLabeled("DEBUG", "firestore", "Could not enable single_project_mode: missing projectId.");
|
|
471
|
-
}
|
|
469
|
+
args.single_project_mode = true;
|
|
470
|
+
args.single_project_mode_error = false;
|
|
472
471
|
}
|
|
473
472
|
const firestoreEmulator = new firestoreEmulator_1.FirestoreEmulator(args);
|
|
474
473
|
await startEmulator(firestoreEmulator);
|
|
@@ -526,9 +525,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
526
525
|
}
|
|
527
526
|
}
|
|
528
527
|
if (listenForEmulator.auth) {
|
|
529
|
-
if (!projectId) {
|
|
530
|
-
throw new error_1.FirebaseError(`Cannot start the ${constants_1.Constants.description(types_1.Emulators.AUTH)} without a project: run 'firebase init' or provide the --project flag`);
|
|
531
|
-
}
|
|
532
528
|
const authAddr = legacyGetFirstAddr(types_1.Emulators.AUTH);
|
|
533
529
|
const authEmulator = new auth_2.AuthEmulator({
|
|
534
530
|
host: authAddr.host,
|
|
@@ -547,9 +543,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
547
543
|
}
|
|
548
544
|
}
|
|
549
545
|
if (listenForEmulator.pubsub) {
|
|
550
|
-
if (!projectId) {
|
|
551
|
-
throw new error_1.FirebaseError("Cannot start the Pub/Sub emulator without a project: run 'firebase init' or provide the --project flag");
|
|
552
|
-
}
|
|
553
546
|
const pubsubAddr = legacyGetFirstAddr(types_1.Emulators.PUBSUB);
|
|
554
547
|
const pubsubEmulator = new pubsubEmulator_1.PubsubEmulator({
|
|
555
548
|
host: pubsubAddr.host,
|
|
@@ -560,7 +553,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
560
553
|
await startEmulator(pubsubEmulator);
|
|
561
554
|
}
|
|
562
555
|
if (listenForEmulator.dataconnect) {
|
|
563
|
-
const config = (0,
|
|
556
|
+
const config = (0, load_1.readFirebaseJson)(options.config);
|
|
564
557
|
if (!config.length) {
|
|
565
558
|
throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
|
|
566
559
|
}
|
|
@@ -572,7 +565,6 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
572
565
|
projectId,
|
|
573
566
|
auto_download: true,
|
|
574
567
|
configDir: config[0].source,
|
|
575
|
-
rc: options.rc,
|
|
576
568
|
config: options.config,
|
|
577
569
|
autoconnectToPostgres: true,
|
|
578
570
|
postgresListen: listenForEmulator["dataconnect.postgres"],
|
|
@@ -613,7 +605,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
613
605
|
const storageEmulator = new storage_1.StorageEmulator({
|
|
614
606
|
host: storageAddr.host,
|
|
615
607
|
port: storageAddr.port,
|
|
616
|
-
projectId
|
|
608
|
+
projectId,
|
|
617
609
|
rules: (0, config_1.getStorageRulesConfig)(projectId, options),
|
|
618
610
|
});
|
|
619
611
|
await startEmulator(storageEmulator);
|
|
@@ -672,13 +664,12 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
672
664
|
await startEmulator(loggingEmulator);
|
|
673
665
|
}
|
|
674
666
|
if (showUI && !shouldStart(options, types_1.Emulators.UI)) {
|
|
675
|
-
hubLogger.logLabeled("WARN", "emulators", "The Emulator UI is not starting
|
|
676
|
-
"emulators have a UI component
|
|
677
|
-
"determine the Project ID. Pass the --project flag to specify a project.");
|
|
667
|
+
hubLogger.logLabeled("WARN", "emulators", "The Emulator UI is not starting because none of the running " +
|
|
668
|
+
"emulators have a UI component.");
|
|
678
669
|
}
|
|
679
670
|
if (listenForEmulator.ui) {
|
|
680
671
|
const ui = new ui_1.EmulatorUI({
|
|
681
|
-
projectId
|
|
672
|
+
projectId,
|
|
682
673
|
listen: listenForEmulator[types_1.Emulators.UI],
|
|
683
674
|
});
|
|
684
675
|
await startEmulator(ui);
|
|
@@ -726,9 +717,6 @@ function getListenConfig(options, emulator) {
|
|
|
726
717
|
}
|
|
727
718
|
async function exportEmulatorData(exportPath, options, initiatedBy) {
|
|
728
719
|
const projectId = options.project;
|
|
729
|
-
if (!projectId) {
|
|
730
|
-
throw new error_1.FirebaseError("Could not determine project ID, make sure you're running in a Firebase project directory or add the --project flag.", { exit: 1 });
|
|
731
|
-
}
|
|
732
720
|
const hubClient = new hubClient_1.EmulatorHubClient(projectId);
|
|
733
721
|
if (!hubClient.foundHub()) {
|
|
734
722
|
throw new error_1.FirebaseError(`Did not find any running emulators for project ${clc.bold(projectId)}.`, { exit: 1 });
|
|
@@ -15,7 +15,6 @@ const emulatorLogger_1 = require("./emulatorLogger");
|
|
|
15
15
|
const types_2 = require("../dataconnect/types");
|
|
16
16
|
const portUtils_1 = require("./portUtils");
|
|
17
17
|
const registry_1 = require("./registry");
|
|
18
|
-
const logger_1 = require("../logger");
|
|
19
18
|
const load_1 = require("../dataconnect/load");
|
|
20
19
|
const pgliteServer_1 = require("./dataconnect/pgliteServer");
|
|
21
20
|
const controller_1 = require("./controller");
|
|
@@ -155,33 +154,37 @@ class DataConnectEmulator {
|
|
|
155
154
|
}
|
|
156
155
|
static async generate(args) {
|
|
157
156
|
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
158
|
-
const cmd = [
|
|
159
|
-
"--logtostderr",
|
|
160
|
-
"-v=2",
|
|
161
|
-
"generate",
|
|
162
|
-
`--config_dir=${args.configDir}`,
|
|
163
|
-
`--connector_id=${args.connectorId}`,
|
|
164
|
-
];
|
|
157
|
+
const cmd = ["--logtostderr", "-v=2", "sdk", "generate", `--config_dir=${args.configDir}`];
|
|
165
158
|
if (args.watch) {
|
|
166
159
|
cmd.push("--watch");
|
|
167
160
|
}
|
|
168
161
|
const env = await DataConnectEmulator.getEnv(args.account);
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
162
|
+
return new Promise((resolve, reject) => {
|
|
163
|
+
try {
|
|
164
|
+
const proc = childProcess.spawn(commandInfo.binary, cmd, { stdio: "inherit", env });
|
|
165
|
+
proc.on("close", (code) => {
|
|
166
|
+
if (code === 0) {
|
|
167
|
+
resolve();
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
reject(new Error(`Command failed with exit code ${code}`));
|
|
171
|
+
}
|
|
172
|
+
});
|
|
173
|
+
proc.on("error", (err) => {
|
|
174
|
+
reject(err);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
catch (e) {
|
|
178
|
+
if ((0, downloadableEmulators_1.isIncomaptibleArchError)(e)) {
|
|
179
|
+
reject(new error_1.FirebaseError(`Unknown system error when running the Data Connect toolkit. ` +
|
|
180
|
+
`You may be able to fix this by installing Rosetta: ` +
|
|
181
|
+
`softwareupdate --install-rosetta`));
|
|
182
|
+
}
|
|
183
|
+
else {
|
|
184
|
+
reject(e);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
});
|
|
185
188
|
}
|
|
186
189
|
static async build(args) {
|
|
187
190
|
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
@@ -54,28 +54,28 @@
|
|
|
54
54
|
},
|
|
55
55
|
"dataconnect": {
|
|
56
56
|
"darwin": {
|
|
57
|
-
"version": "2.
|
|
58
|
-
"expectedSize":
|
|
59
|
-
"expectedChecksum": "
|
|
60
|
-
"expectedChecksumSHA256": "
|
|
61
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v2.
|
|
62
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.
|
|
57
|
+
"version": "2.13.0",
|
|
58
|
+
"expectedSize": 29475680,
|
|
59
|
+
"expectedChecksum": "8bceed44e84d08f135ad10b8b62337e9",
|
|
60
|
+
"expectedChecksumSHA256": "92e0cda1a3fd690421cae4edd7d985e5c5de7069e731ad200ba6988c2321d76c",
|
|
61
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v2.13.0",
|
|
62
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.13.0"
|
|
63
63
|
},
|
|
64
64
|
"win32": {
|
|
65
|
-
"version": "2.
|
|
66
|
-
"expectedSize":
|
|
67
|
-
"expectedChecksum": "
|
|
68
|
-
"expectedChecksumSHA256": "
|
|
69
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-v2.
|
|
70
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.
|
|
65
|
+
"version": "2.13.0",
|
|
66
|
+
"expectedSize": 29965312,
|
|
67
|
+
"expectedChecksum": "67794a3cb334805a06fffd872be7d67c",
|
|
68
|
+
"expectedChecksumSHA256": "2905c570d40e586dd1ca0aeee10785786dc0486500640064e4e1e43be3b97899",
|
|
69
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-v2.13.0",
|
|
70
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.13.0.exe"
|
|
71
71
|
},
|
|
72
72
|
"linux": {
|
|
73
|
-
"version": "2.
|
|
74
|
-
"expectedSize":
|
|
75
|
-
"expectedChecksum": "
|
|
76
|
-
"expectedChecksumSHA256": "
|
|
77
|
-
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v2.
|
|
78
|
-
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.
|
|
73
|
+
"version": "2.13.0",
|
|
74
|
+
"expectedSize": 29401272,
|
|
75
|
+
"expectedChecksum": "d72e185be8b782b8d4bca86d6bc76d2d",
|
|
76
|
+
"expectedChecksumSHA256": "87cb9541f157c3e9986b6eba80d161e6ef1debd17075e4d95e78861d3cdd353f",
|
|
77
|
+
"remoteUrl": "https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v2.13.0",
|
|
78
|
+
"downloadPathRelativeToCacheDir": "dataconnect-emulator-2.13.0"
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
81
|
}
|
package/lib/emulator/env.js
CHANGED
|
@@ -68,7 +68,8 @@ function maybeUsePortForwarding(i) {
|
|
|
68
68
|
}
|
|
69
69
|
const url = `${info.port}-${portForwardingHost}`;
|
|
70
70
|
info.host = url;
|
|
71
|
-
info.listen = info.listen?.map((
|
|
71
|
+
info.listen = info.listen?.map((listen) => {
|
|
72
|
+
const l = { ...listen };
|
|
72
73
|
l.address = url;
|
|
73
74
|
l.port = 443;
|
|
74
75
|
return l;
|
|
@@ -28,8 +28,9 @@ const utils_1 = require("../utils");
|
|
|
28
28
|
const adminSdkConfig_1 = require("./adminSdkConfig");
|
|
29
29
|
const validate_1 = require("../deploy/functions/validate");
|
|
30
30
|
const secretManager_1 = require("../gcp/secretManager");
|
|
31
|
-
const runtimes = require("../deploy/functions/runtimes");
|
|
32
31
|
const backend = require("../deploy/functions/backend");
|
|
32
|
+
const build = require("../deploy/functions/build");
|
|
33
|
+
const runtimes = require("../deploy/functions/runtimes");
|
|
33
34
|
const functionsEnv = require("../functions/env");
|
|
34
35
|
const v1_1 = require("../functions/events/v1");
|
|
35
36
|
const build_1 = require("../deploy/functions/build");
|
|
@@ -82,6 +83,7 @@ class FunctionsEmulator {
|
|
|
82
83
|
this.blockingFunctionsConfig = {};
|
|
83
84
|
this.staticBackends = [];
|
|
84
85
|
this.dynamicBackends = [];
|
|
86
|
+
this.watchers = [];
|
|
85
87
|
this.debugMode = false;
|
|
86
88
|
this.staticBackends = args.emulatableBackends;
|
|
87
89
|
emulatorLogger_1.EmulatorLogger.setVerbosity(this.args.verbosity ? emulatorLogger_1.Verbosity[this.args.verbosity] : emulatorLogger_1.Verbosity["DEBUG"]);
|
|
@@ -273,6 +275,7 @@ class FunctionsEmulator {
|
|
|
273
275
|
],
|
|
274
276
|
persistent: true,
|
|
275
277
|
});
|
|
278
|
+
this.watchers.push(watcher);
|
|
276
279
|
const debouncedLoadTriggers = (0, utils_1.debounce)(() => this.loadTriggers(backend), 1000);
|
|
277
280
|
watcher.on("change", (filePath) => {
|
|
278
281
|
this.logger.log("DEBUG", `File ${filePath} changed, reloading triggers`);
|
|
@@ -294,6 +297,10 @@ class FunctionsEmulator {
|
|
|
294
297
|
for (const pool of Object.values(this.workerPools)) {
|
|
295
298
|
pool.exit();
|
|
296
299
|
}
|
|
300
|
+
for (const watcher of this.watchers) {
|
|
301
|
+
await watcher.close();
|
|
302
|
+
}
|
|
303
|
+
this.watchers = [];
|
|
297
304
|
if (this.destroyServer) {
|
|
298
305
|
await this.destroyServer();
|
|
299
306
|
}
|
|
@@ -329,6 +336,7 @@ class FunctionsEmulator {
|
|
|
329
336
|
projectId: this.args.projectId,
|
|
330
337
|
projectAlias: this.args.projectAlias,
|
|
331
338
|
isEmulator: true,
|
|
339
|
+
configDir: emulatableBackend.configDir,
|
|
332
340
|
};
|
|
333
341
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
334
342
|
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, environment);
|
|
@@ -336,14 +344,15 @@ class FunctionsEmulator {
|
|
|
336
344
|
await this.args.extensionsEmulator.addDynamicExtensions(emulatableBackend.codebase, discoveredBuild);
|
|
337
345
|
await this.loadDynamicExtensionBackends();
|
|
338
346
|
}
|
|
347
|
+
build.applyPrefix(discoveredBuild, emulatableBackend.prefix || "");
|
|
339
348
|
const resolution = await (0, build_1.resolveBackend)({
|
|
340
349
|
build: discoveredBuild,
|
|
341
350
|
firebaseConfig: JSON.parse(firebaseConfig),
|
|
342
|
-
userEnvOpt,
|
|
343
351
|
userEnvs,
|
|
344
352
|
nonInteractive: false,
|
|
345
353
|
isEmulator: true,
|
|
346
354
|
});
|
|
355
|
+
functionsEnv.writeResolvedParams(resolution.envs, userEnvs, userEnvOpt);
|
|
347
356
|
const discoveredBackend = resolution.backend;
|
|
348
357
|
const endpoints = backend.allEndpoints(discoveredBackend);
|
|
349
358
|
(0, functionsEmulatorShared_1.prepareEndpoints)(endpoints);
|
|
@@ -899,6 +908,7 @@ class FunctionsEmulator {
|
|
|
899
908
|
getUserEnvs(backend) {
|
|
900
909
|
const projectInfo = {
|
|
901
910
|
functionsSource: backend.functionsDir,
|
|
911
|
+
configDir: backend.configDir,
|
|
902
912
|
projectId: this.args.projectId,
|
|
903
913
|
projectAlias: this.args.projectAlias,
|
|
904
914
|
isEmulator: true,
|
package/lib/emulator/hub.js
CHANGED
|
@@ -10,8 +10,6 @@ const types_1 = require("./types");
|
|
|
10
10
|
const hubExport_1 = require("./hubExport");
|
|
11
11
|
const registry_1 = require("./registry");
|
|
12
12
|
const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
|
|
13
|
-
const vsCodeUtils_1 = require("../vsCodeUtils");
|
|
14
|
-
const env_1 = require("./env");
|
|
15
13
|
const pkg = require("../../package.json");
|
|
16
14
|
class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
17
15
|
static readLocatorFile(projectId) {
|
|
@@ -21,16 +19,20 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
21
19
|
}
|
|
22
20
|
const data = fs.readFileSync(locatorPath, "utf8").toString();
|
|
23
21
|
const locator = JSON.parse(data);
|
|
24
|
-
if (
|
|
25
|
-
logger_1.logger.debug(`Found locator with
|
|
26
|
-
return undefined;
|
|
22
|
+
if (locator.version !== this.CLI_VERSION) {
|
|
23
|
+
logger_1.logger.debug(`Found emulator locator with different version: ${JSON.stringify(locator)}, CLI_VERSION: ${this.CLI_VERSION}`);
|
|
27
24
|
}
|
|
28
25
|
return locator;
|
|
29
26
|
}
|
|
30
27
|
static getLocatorFilePath(projectId) {
|
|
31
28
|
const dir = os.tmpdir();
|
|
29
|
+
if (!projectId) {
|
|
30
|
+
projectId = EmulatorHub.MISSING_PROJECT_PLACEHOLDER;
|
|
31
|
+
}
|
|
32
32
|
const filename = `hub-${projectId}.json`;
|
|
33
|
-
|
|
33
|
+
const locatorPath = path.join(dir, filename);
|
|
34
|
+
logger_1.logger.debug(`Emulator locator file path: ${locatorPath}`);
|
|
35
|
+
return locatorPath;
|
|
34
36
|
}
|
|
35
37
|
constructor(args) {
|
|
36
38
|
super({
|
|
@@ -45,10 +47,10 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
45
47
|
getRunningEmulatorsMapping() {
|
|
46
48
|
const emulators = {};
|
|
47
49
|
for (const info of registry_1.EmulatorRegistry.listRunningWithInfo()) {
|
|
48
|
-
emulators[info.name] =
|
|
50
|
+
emulators[info.name] = {
|
|
49
51
|
listen: this.args.listenForEmulator[info.name],
|
|
50
52
|
...info,
|
|
51
|
-
}
|
|
53
|
+
};
|
|
52
54
|
}
|
|
53
55
|
return emulators;
|
|
54
56
|
}
|
|
@@ -187,6 +189,7 @@ class EmulatorHub extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
187
189
|
}
|
|
188
190
|
}
|
|
189
191
|
exports.EmulatorHub = EmulatorHub;
|
|
192
|
+
EmulatorHub.MISSING_PROJECT_PLACEHOLDER = "demo-no-project";
|
|
190
193
|
EmulatorHub.CLI_VERSION = pkg.version;
|
|
191
194
|
EmulatorHub.PATH_EXPORT = "/_admin/export";
|
|
192
195
|
EmulatorHub.PATH_DISABLE_FUNCTIONS = "/functions/disableBackgroundTriggers";
|