firebase-tools-with-isolate 13.7.3 → 13.11.2
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 +18 -8
- package/lib/apiv2.js +19 -13
- package/lib/apphosting/app.js +40 -59
- package/lib/apphosting/constants.js +2 -2
- package/lib/apphosting/githubConnections.js +7 -9
- package/lib/apphosting/index.js +122 -58
- package/lib/apphosting/repo.js +3 -3
- package/lib/apphosting/secrets/index.js +7 -1
- package/lib/checkValidTargetFilters.js +8 -1
- package/lib/commands/apphosting-backends-create.js +7 -6
- package/lib/commands/apphosting-backends-delete.js +24 -28
- package/lib/commands/apphosting-backends-list.js +4 -5
- package/lib/commands/apphosting-secrets-access.js +1 -1
- package/lib/commands/apphosting-secrets-grantaccess.js +11 -7
- package/lib/commands/apphosting-secrets-set.js +1 -1
- package/lib/commands/dataconnect-sdk-generate.js +43 -0
- package/lib/commands/dataconnect-services-list.js +74 -0
- package/lib/commands/dataconnect-sql-diff.js +25 -0
- package/lib/commands/dataconnect-sql-migrate.js +44 -0
- package/lib/commands/deploy.js +27 -1
- package/lib/commands/index.js +11 -0
- package/lib/commands/init.js +10 -3
- package/lib/commands/setup-emulators-dataconnect.js +12 -0
- package/lib/config.js +1 -0
- package/lib/crashlytics/buildToolsJarHelper.js +2 -1
- package/lib/dataconnect/build.js +14 -0
- package/lib/dataconnect/checkIam.js +30 -0
- package/lib/dataconnect/client.js +104 -0
- package/lib/dataconnect/dataplaneClient.js +16 -0
- package/lib/dataconnect/ensureApis.js +12 -0
- package/lib/dataconnect/errors.js +37 -0
- package/lib/dataconnect/fileUtils.js +92 -0
- package/lib/dataconnect/filters.js +45 -0
- package/lib/dataconnect/freeTrial.js +22 -0
- package/lib/dataconnect/graphqlError.js +15 -0
- package/lib/dataconnect/load.js +40 -0
- package/lib/dataconnect/names.js +66 -0
- package/lib/dataconnect/prompts.js +20 -0
- package/lib/dataconnect/provisionCloudSql.js +91 -0
- package/lib/dataconnect/schemaMigration.js +278 -0
- package/lib/dataconnect/types.js +22 -0
- package/lib/deploy/dataconnect/deploy.js +76 -0
- package/lib/deploy/dataconnect/index.js +9 -0
- package/lib/deploy/dataconnect/prepare.js +33 -0
- package/lib/deploy/dataconnect/release.js +64 -0
- package/lib/deploy/functions/checkIam.js +4 -34
- package/lib/deploy/functions/prepare.js +1 -1
- package/lib/deploy/functions/release/fabricator.js +7 -2
- package/lib/deploy/functions/runtimes/discovery/index.js +2 -1
- package/lib/deploy/functions/runtimes/supported/types.js +6 -0
- package/lib/deploy/index.js +2 -0
- package/lib/downloadUtils.js +2 -2
- package/lib/emulator/constants.js +3 -0
- package/lib/emulator/controller.js +40 -12
- package/lib/emulator/dataconnectEmulator.js +137 -0
- package/lib/emulator/download.js +5 -1
- package/lib/emulator/downloadableEmulators.js +92 -16
- package/lib/emulator/portUtils.js +13 -4
- package/lib/emulator/registry.js +6 -1
- package/lib/emulator/storage/rules/runtime.js +1 -1
- package/lib/emulator/types.js +3 -0
- package/lib/experiments.js +19 -6
- package/lib/extensions/emulator/specHelper.js +5 -39
- package/lib/frameworks/angular/utils.js +8 -3
- package/lib/frameworks/next/index.js +6 -4
- package/lib/frameworks/next/utils.js +1 -1
- package/lib/functions/python.js +4 -3
- package/lib/gcp/apphosting.js +11 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +187 -0
- package/lib/gcp/cloudsql/connect.js +144 -0
- package/lib/gcp/cloudsql/fbToolsAuthClient.js +44 -0
- package/lib/gcp/devConnect.js +1 -1
- package/lib/gcp/firedata.js +27 -0
- package/lib/gcp/iam.js +33 -1
- package/lib/gcp/secretManager.js +1 -1
- package/lib/hosting/interactive.js +4 -0
- package/lib/init/features/dataconnect/index.js +228 -0
- package/lib/init/features/emulators.js +13 -1
- package/lib/init/features/functions/index.js +19 -3
- package/lib/init/features/functions/npm-dependencies.js +12 -23
- package/lib/init/features/genkit.js +53 -0
- package/lib/init/features/index.js +5 -1
- package/lib/init/index.js +2 -0
- package/lib/init/spawn.js +23 -0
- package/lib/logger.js +22 -2
- package/lib/operation-poller.js +8 -2
- package/lib/rc.js +7 -1
- package/lib/requireAuth.js +4 -8
- package/lib/requireTosAcceptance.js +22 -0
- package/lib/track.js +29 -2
- package/lib/utils.js +55 -4
- package/package.json +10 -4
- package/schema/connector-yaml.json +54 -0
- package/schema/dataconnect-yaml.json +72 -0
- package/schema/firebase-config.json +105 -0
- package/templates/extensions/javascript/package.lint.json +2 -2
- package/templates/extensions/javascript/package.nolint.json +2 -2
- package/templates/extensions/typescript/package.lint.json +2 -2
- package/templates/extensions/typescript/package.nolint.json +2 -2
- package/templates/init/dataconnect/connector.yaml +2 -0
- package/templates/init/dataconnect/dataconnect.yaml +10 -0
- package/templates/init/dataconnect/mutations.gql +30 -0
- package/templates/init/dataconnect/queries.gql +51 -0
- package/templates/init/dataconnect/schema.gql +28 -0
- package/templates/init/functions/javascript/_gitignore +2 -1
- package/templates/init/functions/javascript/package.lint.json +2 -2
- package/templates/init/functions/javascript/package.nolint.json +2 -2
- package/templates/init/functions/python/_gitignore +1 -0
- package/templates/init/functions/typescript/_gitignore +1 -0
- package/templates/init/functions/typescript/package.lint.json +2 -2
- package/templates/init/functions/typescript/package.nolint.json +2 -2
- package/lib/monospace/index.js +0 -82
- /package/lib/{monospace/interfaces.js → gcp/cloudsql/types.js} +0 -0
|
@@ -14,6 +14,7 @@ exports.DEFAULT_PORTS = {
|
|
|
14
14
|
auth: 9099,
|
|
15
15
|
storage: 9199,
|
|
16
16
|
eventarc: 9299,
|
|
17
|
+
dataconnect: 9399,
|
|
17
18
|
};
|
|
18
19
|
exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
19
20
|
ui: true,
|
|
@@ -28,6 +29,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
|
28
29
|
storage: false,
|
|
29
30
|
extensions: false,
|
|
30
31
|
eventarc: true,
|
|
32
|
+
dataconnect: true,
|
|
31
33
|
};
|
|
32
34
|
exports.EMULATOR_DESCRIPTION = {
|
|
33
35
|
ui: "Emulator UI",
|
|
@@ -42,6 +44,7 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
42
44
|
storage: "Storage Emulator",
|
|
43
45
|
extensions: "Extensions Emulator",
|
|
44
46
|
eventarc: "Eventarc Emulator",
|
|
47
|
+
dataconnect: "Data Connect Emulator",
|
|
45
48
|
};
|
|
46
49
|
exports.DEFAULT_HOST = "localhost";
|
|
47
50
|
class Constants {
|
|
@@ -12,14 +12,8 @@ const registry_1 = require("./registry");
|
|
|
12
12
|
const types_1 = require("./types");
|
|
13
13
|
const constants_1 = require("./constants");
|
|
14
14
|
const functionsEmulator_1 = require("./functionsEmulator");
|
|
15
|
-
const auth_1 = require("./auth");
|
|
16
|
-
const databaseEmulator_1 = require("./databaseEmulator");
|
|
17
|
-
const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
18
|
-
const hostingEmulator_1 = require("./hostingEmulator");
|
|
19
|
-
const eventarcEmulator_1 = require("./eventarcEmulator");
|
|
20
15
|
const error_1 = require("../error");
|
|
21
16
|
const projectUtils_1 = require("../projectUtils");
|
|
22
|
-
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
23
17
|
const commandUtils = require("./commandUtils");
|
|
24
18
|
const hub_1 = require("./hub");
|
|
25
19
|
const hubExport_1 = require("./hubExport");
|
|
@@ -31,10 +25,9 @@ const hubClient_1 = require("./hubClient");
|
|
|
31
25
|
const prompt_1 = require("../prompt");
|
|
32
26
|
const commandUtils_1 = require("./commandUtils");
|
|
33
27
|
const fsutils_1 = require("../fsutils");
|
|
34
|
-
const storage_1 = require("./storage");
|
|
35
28
|
const config_1 = require("./storage/rules/config");
|
|
36
29
|
const getDefaultDatabaseInstance_1 = require("../getDefaultDatabaseInstance");
|
|
37
|
-
const
|
|
30
|
+
const auth_1 = require("../auth");
|
|
38
31
|
const extensionsEmulator_1 = require("./extensionsEmulator");
|
|
39
32
|
const projectConfig_1 = require("../functions/projectConfig");
|
|
40
33
|
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
@@ -42,6 +35,15 @@ const frameworks_1 = require("../frameworks");
|
|
|
42
35
|
const experiments = require("../experiments");
|
|
43
36
|
const portUtils_1 = require("./portUtils");
|
|
44
37
|
const supported_1 = require("../deploy/functions/runtimes/supported");
|
|
38
|
+
const auth_2 = require("./auth");
|
|
39
|
+
const databaseEmulator_1 = require("./databaseEmulator");
|
|
40
|
+
const eventarcEmulator_1 = require("./eventarcEmulator");
|
|
41
|
+
const dataconnectEmulator_1 = require("./dataconnectEmulator");
|
|
42
|
+
const firestoreEmulator_1 = require("./firestoreEmulator");
|
|
43
|
+
const hostingEmulator_1 = require("./hostingEmulator");
|
|
44
|
+
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
45
|
+
const storage_1 = require("./storage");
|
|
46
|
+
const fileUtils_1 = require("../dataconnect/fileUtils");
|
|
45
47
|
const START_LOGGING_EMULATOR = utils.envOverride("START_LOGGING_EMULATOR", "false", (val) => val === "true");
|
|
46
48
|
async function exportOnExit(options) {
|
|
47
49
|
const exportOnExitDir = options.exportOnExit;
|
|
@@ -350,7 +352,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
350
352
|
if (emulatorsNotRunning.length > 0 && !constants_1.Constants.isDemoProject(projectId)) {
|
|
351
353
|
functionsLogger.logLabeled("WARN", "functions", `The following emulators are not running, calls to these services from the Functions emulator will affect production: ${clc.bold(emulatorsNotRunning.join(", "))}`);
|
|
352
354
|
}
|
|
353
|
-
const account = (0,
|
|
355
|
+
const account = (0, auth_1.getProjectDefaultAccount)(options.projectRoot);
|
|
354
356
|
const functionsEmulator = new functionsEmulator_1.FunctionsEmulator({
|
|
355
357
|
projectId,
|
|
356
358
|
projectDir,
|
|
@@ -490,13 +492,13 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
490
492
|
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`);
|
|
491
493
|
}
|
|
492
494
|
const authAddr = legacyGetFirstAddr(types_1.Emulators.AUTH);
|
|
493
|
-
const authEmulator = new
|
|
495
|
+
const authEmulator = new auth_2.AuthEmulator({
|
|
494
496
|
host: authAddr.host,
|
|
495
497
|
port: authAddr.port,
|
|
496
498
|
projectId,
|
|
497
499
|
singleProjectMode: singleProjectModeEnabled
|
|
498
|
-
?
|
|
499
|
-
:
|
|
500
|
+
? auth_2.SingleProjectMode.WARNING
|
|
501
|
+
: auth_2.SingleProjectMode.NO_WARNING,
|
|
500
502
|
});
|
|
501
503
|
await startEmulator(authEmulator);
|
|
502
504
|
if (exportMetadata.auth) {
|
|
@@ -519,6 +521,32 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
519
521
|
});
|
|
520
522
|
await startEmulator(pubsubEmulator);
|
|
521
523
|
}
|
|
524
|
+
if (listenForEmulator.dataconnect) {
|
|
525
|
+
const config = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
526
|
+
if (!config.length) {
|
|
527
|
+
throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
|
|
528
|
+
}
|
|
529
|
+
else if (config.length > 1) {
|
|
530
|
+
logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
531
|
+
}
|
|
532
|
+
let configDir = config[0].source;
|
|
533
|
+
if (!path.isAbsolute(configDir)) {
|
|
534
|
+
const cwd = options.cwd || process.cwd();
|
|
535
|
+
configDir = path.resolve(path.join(cwd), configDir);
|
|
536
|
+
}
|
|
537
|
+
const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
|
|
538
|
+
listen: listenForEmulator.dataconnect,
|
|
539
|
+
projectId,
|
|
540
|
+
auto_download: true,
|
|
541
|
+
configDir,
|
|
542
|
+
locationId: config[0].location,
|
|
543
|
+
rc: options.rc,
|
|
544
|
+
});
|
|
545
|
+
await startEmulator(dataConnectEmulator);
|
|
546
|
+
if (!utils.isVSCodeExtension()) {
|
|
547
|
+
await dataConnectEmulator.connectToPostgres();
|
|
548
|
+
}
|
|
549
|
+
}
|
|
522
550
|
if (listenForEmulator.storage) {
|
|
523
551
|
const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
|
|
524
552
|
const storageEmulator = new storage_1.StorageEmulator({
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DataConnectEmulatorClient = exports.DataConnectEmulator = void 0;
|
|
4
|
+
const childProcess = require("child_process");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const constants_1 = require("./constants");
|
|
7
|
+
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
8
|
+
const types_1 = require("./types");
|
|
9
|
+
const error_1 = require("../error");
|
|
10
|
+
const emulatorLogger_1 = require("./emulatorLogger");
|
|
11
|
+
const types_2 = require("../dataconnect/types");
|
|
12
|
+
const portUtils_1 = require("./portUtils");
|
|
13
|
+
const registry_1 = require("./registry");
|
|
14
|
+
class DataConnectEmulator {
|
|
15
|
+
constructor(args) {
|
|
16
|
+
this.args = args;
|
|
17
|
+
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT);
|
|
18
|
+
this.emulatorClient = new DataConnectEmulatorClient();
|
|
19
|
+
}
|
|
20
|
+
async start() {
|
|
21
|
+
try {
|
|
22
|
+
const info = await DataConnectEmulator.build({ configDir: this.args.configDir });
|
|
23
|
+
if ((0, types_2.requiresVector)(info.metadata)) {
|
|
24
|
+
if (constants_1.Constants.isDemoProject(this.args.projectId)) {
|
|
25
|
+
this.logger.logLabeled("WARN", "Data Connect", "Detected a 'demo-' project, but vector embeddings require a real project. Operations that use vector_embed will fail.");
|
|
26
|
+
}
|
|
27
|
+
else {
|
|
28
|
+
this.logger.logLabeled("WARN", "Data Connect", "Operations that use vector_embed will make calls to production Vertex AI");
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
catch (err) {
|
|
33
|
+
this.logger.log("DEBUG", `'fdc build' failed with error: ${err.message}`);
|
|
34
|
+
}
|
|
35
|
+
return (0, downloadableEmulators_1.start)(types_1.Emulators.DATACONNECT, {
|
|
36
|
+
auto_download: this.args.auto_download,
|
|
37
|
+
listen: (0, portUtils_1.listenSpecsToString)(this.args.listen),
|
|
38
|
+
config_dir: this.args.configDir,
|
|
39
|
+
project_id: this.args.projectId,
|
|
40
|
+
service_location: this.args.locationId,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
connect() {
|
|
44
|
+
return Promise.resolve();
|
|
45
|
+
}
|
|
46
|
+
stop() {
|
|
47
|
+
return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
|
|
48
|
+
}
|
|
49
|
+
getInfo() {
|
|
50
|
+
return {
|
|
51
|
+
name: this.getName(),
|
|
52
|
+
listen: this.args.listen,
|
|
53
|
+
host: this.args.listen[0].address,
|
|
54
|
+
port: this.args.listen[0].port,
|
|
55
|
+
pid: (0, downloadableEmulators_1.getPID)(types_1.Emulators.DATACONNECT),
|
|
56
|
+
timeout: 10000,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
getName() {
|
|
60
|
+
return types_1.Emulators.DATACONNECT;
|
|
61
|
+
}
|
|
62
|
+
static async generate(args) {
|
|
63
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
64
|
+
const cmd = [
|
|
65
|
+
"generate",
|
|
66
|
+
`--service_location=${args.locationId}`,
|
|
67
|
+
`--config_dir=${args.configDir}`,
|
|
68
|
+
`--connector_id=${args.connectorId}`,
|
|
69
|
+
];
|
|
70
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
71
|
+
if (res.error) {
|
|
72
|
+
throw new error_1.FirebaseError(`Error starting up Data Connect generate: ${res.error.message}`, {
|
|
73
|
+
original: res.error,
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return res.stdout;
|
|
77
|
+
}
|
|
78
|
+
static async build(args) {
|
|
79
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
80
|
+
const cmd = ["build", `--config_dir=${args.configDir}`];
|
|
81
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
82
|
+
if (res.error) {
|
|
83
|
+
throw new error_1.FirebaseError(`Error starting up Data Connect build: ${res.error.message}`, {
|
|
84
|
+
original: res.error,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (res.status !== 0) {
|
|
88
|
+
throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors (exit code ${res.status}): ${res.stderr}`);
|
|
89
|
+
}
|
|
90
|
+
if (res.stderr) {
|
|
91
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT).log("DEBUG", res.stderr);
|
|
92
|
+
}
|
|
93
|
+
try {
|
|
94
|
+
return JSON.parse(res.stdout);
|
|
95
|
+
}
|
|
96
|
+
catch (err) {
|
|
97
|
+
throw new error_1.FirebaseError(`Unable to parse 'fdc build' output: ${res.stdout ?? res.stderr}`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
getLocalConectionString() {
|
|
101
|
+
if ((0, api_1.dataConnectLocalConnString)()) {
|
|
102
|
+
return (0, api_1.dataConnectLocalConnString)();
|
|
103
|
+
}
|
|
104
|
+
return this.args.rc.getDataconnect()?.postgres?.localConnectionString;
|
|
105
|
+
}
|
|
106
|
+
async connectToPostgres(localConnectionString, database, serviceId) {
|
|
107
|
+
const connectionString = localConnectionString ?? this.getLocalConectionString();
|
|
108
|
+
if (!connectionString) {
|
|
109
|
+
this.logger.log("DEBUG", "No Postgres connection string found, not connecting to Postgres");
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
await this.emulatorClient.configureEmulator({ connectionString, database, serviceId });
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
exports.DataConnectEmulator = DataConnectEmulator;
|
|
117
|
+
class DataConnectEmulatorClient {
|
|
118
|
+
constructor() {
|
|
119
|
+
this.client = undefined;
|
|
120
|
+
}
|
|
121
|
+
async configureEmulator(body) {
|
|
122
|
+
if (!this.client) {
|
|
123
|
+
this.client = registry_1.EmulatorRegistry.client(types_1.Emulators.DATACONNECT);
|
|
124
|
+
}
|
|
125
|
+
try {
|
|
126
|
+
const res = await this.client.post("emulator/configure", body);
|
|
127
|
+
return res;
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
if (err.status === 500) {
|
|
131
|
+
throw new error_1.FirebaseError(`Data Connect emulator: ${err.context.body.message}`);
|
|
132
|
+
}
|
|
133
|
+
throw err;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
exports.DataConnectEmulatorClient = DataConnectEmulatorClient;
|
package/lib/emulator/download.js
CHANGED
|
@@ -13,9 +13,13 @@ const downloadUtils = require("../downloadUtils");
|
|
|
13
13
|
tmp.setGracefulCleanup();
|
|
14
14
|
async function downloadEmulator(name) {
|
|
15
15
|
const emulator = downloadableEmulators.getDownloadDetails(name);
|
|
16
|
+
if (emulator.localOnly) {
|
|
17
|
+
emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("WARN", name, `Env variable override detected, skipping download. Using ${emulator} emulator at ${emulator.binaryPath}`);
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
16
20
|
emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("BULLET", name, `downloading ${path.basename(emulator.downloadPath)}...`);
|
|
17
21
|
fs.ensureDirSync(emulator.opts.cacheDir);
|
|
18
|
-
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl);
|
|
22
|
+
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl, !!emulator.opts.auth);
|
|
19
23
|
if (!emulator.opts.skipChecksumAndSize) {
|
|
20
24
|
await validateSize(tmpfile, emulator.opts.expectedSize);
|
|
21
25
|
await validateChecksum(tmpfile, emulator.opts.expectedChecksum);
|
|
@@ -23,9 +23,9 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
23
23
|
expectedChecksum: "2fd771101c0e1f7898c04c9204f2ce63",
|
|
24
24
|
},
|
|
25
25
|
firestore: {
|
|
26
|
-
version: "1.19.
|
|
27
|
-
expectedSize:
|
|
28
|
-
expectedChecksum: "
|
|
26
|
+
version: "1.19.7",
|
|
27
|
+
expectedSize: 66438992,
|
|
28
|
+
expectedChecksum: "aec233bea95c5cfab03881574ec16d6c",
|
|
29
29
|
},
|
|
30
30
|
storage: {
|
|
31
31
|
version: "1.1.3",
|
|
@@ -35,15 +35,32 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
35
35
|
ui: experiments.isEnabled("emulatoruisnapshot")
|
|
36
36
|
? { version: "SNAPSHOT", expectedSize: -1, expectedChecksum: "" }
|
|
37
37
|
: {
|
|
38
|
-
version: "1.
|
|
39
|
-
expectedSize:
|
|
40
|
-
expectedChecksum: "
|
|
38
|
+
version: "1.12.1",
|
|
39
|
+
expectedSize: 3498269,
|
|
40
|
+
expectedChecksum: "a7f4398a00e5ca22abdcd78dc3877d00",
|
|
41
41
|
},
|
|
42
42
|
pubsub: {
|
|
43
|
-
version: "0.8.
|
|
44
|
-
expectedSize:
|
|
45
|
-
expectedChecksum: "
|
|
43
|
+
version: "0.8.14",
|
|
44
|
+
expectedSize: 66786933,
|
|
45
|
+
expectedChecksum: "a9025b3e53fdeafd2969ccb3ba1e1d38",
|
|
46
46
|
},
|
|
47
|
+
dataconnect: process.platform === "darwin"
|
|
48
|
+
? {
|
|
49
|
+
version: "1.2.0",
|
|
50
|
+
expectedSize: 23954240,
|
|
51
|
+
expectedChecksum: "0f250761959519bb5a28fed76ceab2cb",
|
|
52
|
+
}
|
|
53
|
+
: process.platform === "win32"
|
|
54
|
+
? {
|
|
55
|
+
version: "1.2.0",
|
|
56
|
+
expectedSize: 24360960,
|
|
57
|
+
expectedChecksum: "168ce32c742e1d26037c52bdbb7d871c",
|
|
58
|
+
}
|
|
59
|
+
: {
|
|
60
|
+
version: "1.2.0",
|
|
61
|
+
expectedSize: 23970052,
|
|
62
|
+
expectedChecksum: "2ca17e4009a9ebae0f7c983bafff2ee6",
|
|
63
|
+
},
|
|
47
64
|
};
|
|
48
65
|
exports.DownloadDetails = {
|
|
49
66
|
database: {
|
|
@@ -107,6 +124,24 @@ exports.DownloadDetails = {
|
|
|
107
124
|
namePrefix: "pubsub-emulator",
|
|
108
125
|
},
|
|
109
126
|
},
|
|
127
|
+
dataconnect: {
|
|
128
|
+
downloadPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}${process.platform === "win32" ? ".exe" : ""}`),
|
|
129
|
+
version: EMULATOR_UPDATE_DETAILS.dataconnect.version,
|
|
130
|
+
binaryPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}${process.platform === "win32" ? ".exe" : ""}`),
|
|
131
|
+
opts: {
|
|
132
|
+
cacheDir: CACHE_DIR,
|
|
133
|
+
remoteUrl: process.platform === "darwin"
|
|
134
|
+
? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
|
|
135
|
+
: process.platform === "win32"
|
|
136
|
+
? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-windows-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
|
|
137
|
+
: `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
|
|
138
|
+
expectedSize: EMULATOR_UPDATE_DETAILS.dataconnect.expectedSize,
|
|
139
|
+
expectedChecksum: EMULATOR_UPDATE_DETAILS.dataconnect.expectedChecksum,
|
|
140
|
+
skipChecksumAndSize: false,
|
|
141
|
+
namePrefix: "dataconnect-emulator",
|
|
142
|
+
auth: true,
|
|
143
|
+
},
|
|
144
|
+
},
|
|
110
145
|
};
|
|
111
146
|
const EmulatorDetails = {
|
|
112
147
|
database: {
|
|
@@ -134,6 +169,11 @@ const EmulatorDetails = {
|
|
|
134
169
|
instance: null,
|
|
135
170
|
stdout: null,
|
|
136
171
|
},
|
|
172
|
+
dataconnect: {
|
|
173
|
+
name: types_1.Emulators.DATACONNECT,
|
|
174
|
+
instance: null,
|
|
175
|
+
stdout: null,
|
|
176
|
+
},
|
|
137
177
|
};
|
|
138
178
|
const Commands = {
|
|
139
179
|
database: {
|
|
@@ -147,6 +187,7 @@ const Commands = {
|
|
|
147
187
|
"single_project_mode",
|
|
148
188
|
],
|
|
149
189
|
joinArgs: false,
|
|
190
|
+
shell: false,
|
|
150
191
|
},
|
|
151
192
|
firestore: {
|
|
152
193
|
binary: "java",
|
|
@@ -168,6 +209,7 @@ const Commands = {
|
|
|
168
209
|
"single_project_mode",
|
|
169
210
|
],
|
|
170
211
|
joinArgs: false,
|
|
212
|
+
shell: false,
|
|
171
213
|
},
|
|
172
214
|
storage: {
|
|
173
215
|
binary: "java",
|
|
@@ -179,18 +221,37 @@ const Commands = {
|
|
|
179
221
|
],
|
|
180
222
|
optionalArgs: [],
|
|
181
223
|
joinArgs: false,
|
|
224
|
+
shell: false,
|
|
182
225
|
},
|
|
183
226
|
pubsub: {
|
|
184
227
|
binary: getExecPath(types_1.Emulators.PUBSUB),
|
|
185
228
|
args: [],
|
|
186
229
|
optionalArgs: ["port", "host"],
|
|
187
230
|
joinArgs: true,
|
|
231
|
+
shell: true,
|
|
188
232
|
},
|
|
189
233
|
ui: {
|
|
190
234
|
binary: "node",
|
|
191
235
|
args: [getExecPath(types_1.Emulators.UI)],
|
|
192
236
|
optionalArgs: [],
|
|
193
237
|
joinArgs: false,
|
|
238
|
+
shell: false,
|
|
239
|
+
},
|
|
240
|
+
dataconnect: {
|
|
241
|
+
binary: getExecPath(types_1.Emulators.DATACONNECT),
|
|
242
|
+
args: ["dev"],
|
|
243
|
+
optionalArgs: [
|
|
244
|
+
"listen",
|
|
245
|
+
"config_dir",
|
|
246
|
+
"project_id",
|
|
247
|
+
"service_location",
|
|
248
|
+
"disable_sdk_generation",
|
|
249
|
+
"resolvers_emulator",
|
|
250
|
+
"vertex_location",
|
|
251
|
+
"rpc_retry_count",
|
|
252
|
+
],
|
|
253
|
+
joinArgs: true,
|
|
254
|
+
shell: false,
|
|
194
255
|
},
|
|
195
256
|
};
|
|
196
257
|
function getExecPath(name) {
|
|
@@ -237,6 +298,7 @@ function _getCommand(emulator, args) {
|
|
|
237
298
|
args: cmdLineArgs,
|
|
238
299
|
optionalArgs: baseCmd.optionalArgs,
|
|
239
300
|
joinArgs: baseCmd.joinArgs,
|
|
301
|
+
shell: baseCmd.shell,
|
|
240
302
|
};
|
|
241
303
|
}
|
|
242
304
|
exports._getCommand = _getCommand;
|
|
@@ -272,11 +334,15 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
272
334
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator.name);
|
|
273
335
|
emulator.stdout = fs.createWriteStream(getLogFileName(emulator.name));
|
|
274
336
|
try {
|
|
275
|
-
|
|
337
|
+
const opts = {
|
|
276
338
|
env: { ...process.env, ...extraEnv },
|
|
277
339
|
detached: true,
|
|
278
340
|
stdio: ["inherit", "pipe", "pipe"],
|
|
279
|
-
}
|
|
341
|
+
};
|
|
342
|
+
if (command.shell && utils.IS_WINDOWS) {
|
|
343
|
+
opts.shell = true;
|
|
344
|
+
}
|
|
345
|
+
emulator.instance = childProcess.spawn(command.binary, command.args, opts);
|
|
280
346
|
}
|
|
281
347
|
catch (e) {
|
|
282
348
|
if (e.code === "EACCES") {
|
|
@@ -316,7 +382,17 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
316
382
|
});
|
|
317
383
|
}
|
|
318
384
|
function getDownloadDetails(emulator) {
|
|
319
|
-
|
|
385
|
+
const details = exports.DownloadDetails[emulator];
|
|
386
|
+
const pathOverride = process.env[`${emulator.toUpperCase()}_EMULATOR_BINARY_PATH`];
|
|
387
|
+
if (pathOverride) {
|
|
388
|
+
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator);
|
|
389
|
+
logger.logLabeled("WARN", emulator, `Env variable override detected. Using ${emulator} emulator at ${pathOverride}`);
|
|
390
|
+
details.downloadPath = pathOverride;
|
|
391
|
+
details.binaryPath = pathOverride;
|
|
392
|
+
details.localOnly = true;
|
|
393
|
+
fs.chmodSync(pathOverride, 0o755);
|
|
394
|
+
}
|
|
395
|
+
return details;
|
|
320
396
|
}
|
|
321
397
|
exports.getDownloadDetails = getDownloadDetails;
|
|
322
398
|
function get(emulator) {
|
|
@@ -353,14 +429,14 @@ async function stop(targetName) {
|
|
|
353
429
|
exports.stop = stop;
|
|
354
430
|
async function downloadIfNecessary(targetName) {
|
|
355
431
|
const hasEmulator = fs.existsSync(getExecPath(targetName));
|
|
356
|
-
if (hasEmulator) {
|
|
357
|
-
|
|
432
|
+
if (!hasEmulator) {
|
|
433
|
+
await (0, download_1.downloadEmulator)(targetName);
|
|
358
434
|
}
|
|
359
|
-
|
|
435
|
+
return Commands[targetName];
|
|
360
436
|
}
|
|
361
437
|
exports.downloadIfNecessary = downloadIfNecessary;
|
|
362
438
|
async function start(targetName, args, extraEnv = {}) {
|
|
363
|
-
const downloadDetails =
|
|
439
|
+
const downloadDetails = getDownloadDetails(targetName);
|
|
364
440
|
const emulator = get(targetName);
|
|
365
441
|
const hasEmulator = fs.existsSync(getExecPath(targetName));
|
|
366
442
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(targetName);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.resolveHostAndAssignPorts = exports.waitForPortUsed = exports.checkListenable = void 0;
|
|
3
|
+
exports.listenSpecsToString = exports.resolveHostAndAssignPorts = exports.waitForPortUsed = exports.checkListenable = void 0;
|
|
4
4
|
const clc = require("colorette");
|
|
5
5
|
const tcpport = require("tcp-port-used");
|
|
6
6
|
const node_net_1 = require("node:net");
|
|
@@ -131,9 +131,8 @@ async function checkListenable(arg1, port) {
|
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
133
|
exports.checkListenable = checkListenable;
|
|
134
|
-
async function waitForPortUsed(port, host) {
|
|
135
|
-
const interval =
|
|
136
|
-
const timeout = 60000;
|
|
134
|
+
async function waitForPortUsed(port, host, timeout = 60000) {
|
|
135
|
+
const interval = 200;
|
|
137
136
|
try {
|
|
138
137
|
await tcpport.waitUntilUsedOnHost(port, host, interval, timeout);
|
|
139
138
|
}
|
|
@@ -147,6 +146,7 @@ const EMULATOR_CAN_LISTEN_ON_PRIMARY_ONLY = {
|
|
|
147
146
|
firestore: true,
|
|
148
147
|
"firestore.websocket": true,
|
|
149
148
|
pubsub: true,
|
|
149
|
+
dataconnect: false,
|
|
150
150
|
hub: false,
|
|
151
151
|
ui: false,
|
|
152
152
|
auth: true,
|
|
@@ -321,3 +321,12 @@ function listenSpec(lookup, port) {
|
|
|
321
321
|
port: port,
|
|
322
322
|
};
|
|
323
323
|
}
|
|
324
|
+
function listenSpecsToString(specs) {
|
|
325
|
+
return specs
|
|
326
|
+
.map((spec) => {
|
|
327
|
+
const host = spec.family === "IPv4" ? spec.address : `[${spec.address}]`;
|
|
328
|
+
return `${host}:${spec.port}`;
|
|
329
|
+
})
|
|
330
|
+
.join(",");
|
|
331
|
+
}
|
|
332
|
+
exports.listenSpecsToString = listenSpecsToString;
|
package/lib/emulator/registry.js
CHANGED
|
@@ -8,6 +8,7 @@ const constants_1 = require("./constants");
|
|
|
8
8
|
const emulatorLogger_1 = require("./emulatorLogger");
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const apiv2_1 = require("../apiv2");
|
|
11
|
+
const downloadableEmulators_1 = require("./downloadableEmulators");
|
|
11
12
|
class EmulatorRegistry {
|
|
12
13
|
static async start(instance) {
|
|
13
14
|
const description = constants_1.Constants.description(instance.getName());
|
|
@@ -18,7 +19,7 @@ class EmulatorRegistry {
|
|
|
18
19
|
await instance.start();
|
|
19
20
|
if (instance.getName() !== types_1.Emulators.EXTENSIONS) {
|
|
20
21
|
const info = instance.getInfo();
|
|
21
|
-
await portUtils.waitForPortUsed(info.port, (0, utils_1.connectableHostname)(info.host));
|
|
22
|
+
await portUtils.waitForPortUsed(info.port, (0, utils_1.connectableHostname)(info.host), info.timeout);
|
|
22
23
|
}
|
|
23
24
|
}
|
|
24
25
|
static async stop(name) {
|
|
@@ -47,6 +48,7 @@ class EmulatorRegistry {
|
|
|
47
48
|
auth: 3.3,
|
|
48
49
|
storage: 3.5,
|
|
49
50
|
eventarc: 3.6,
|
|
51
|
+
dataconnect: 3.7,
|
|
50
52
|
hub: 4,
|
|
51
53
|
logging: 5,
|
|
52
54
|
};
|
|
@@ -85,6 +87,9 @@ class EmulatorRegistry {
|
|
|
85
87
|
host: (0, utils_1.connectableHostname)(info.host),
|
|
86
88
|
};
|
|
87
89
|
}
|
|
90
|
+
static getDetails(emulator) {
|
|
91
|
+
return (0, downloadableEmulators_1.get)(emulator);
|
|
92
|
+
}
|
|
88
93
|
static url(emulator, req) {
|
|
89
94
|
const url = new URL("http://unknown/");
|
|
90
95
|
if (req) {
|
|
@@ -73,7 +73,7 @@ class StorageRulesRuntime {
|
|
|
73
73
|
if (this.alive) {
|
|
74
74
|
return;
|
|
75
75
|
}
|
|
76
|
-
const downloadDetails = downloadableEmulators_1.
|
|
76
|
+
const downloadDetails = (0, downloadableEmulators_1.getDownloadDetails)(types_2.Emulators.STORAGE);
|
|
77
77
|
const hasEmulator = fs.existsSync(downloadDetails.downloadPath);
|
|
78
78
|
if (!hasEmulator) {
|
|
79
79
|
if (autoDownload) {
|
package/lib/emulator/types.js
CHANGED
|
@@ -15,6 +15,7 @@ var Emulators;
|
|
|
15
15
|
Emulators["STORAGE"] = "storage";
|
|
16
16
|
Emulators["EXTENSIONS"] = "extensions";
|
|
17
17
|
Emulators["EVENTARC"] = "eventarc";
|
|
18
|
+
Emulators["DATACONNECT"] = "dataconnect";
|
|
18
19
|
})(Emulators = exports.Emulators || (exports.Emulators = {}));
|
|
19
20
|
exports.DOWNLOADABLE_EMULATORS = [
|
|
20
21
|
Emulators.FIRESTORE,
|
|
@@ -22,6 +23,7 @@ exports.DOWNLOADABLE_EMULATORS = [
|
|
|
22
23
|
Emulators.PUBSUB,
|
|
23
24
|
Emulators.UI,
|
|
24
25
|
Emulators.STORAGE,
|
|
26
|
+
Emulators.DATACONNECT,
|
|
25
27
|
];
|
|
26
28
|
exports.IMPORT_EXPORT_EMULATORS = [
|
|
27
29
|
Emulators.FIRESTORE,
|
|
@@ -38,6 +40,7 @@ exports.ALL_SERVICE_EMULATORS = [
|
|
|
38
40
|
Emulators.PUBSUB,
|
|
39
41
|
Emulators.STORAGE,
|
|
40
42
|
Emulators.EVENTARC,
|
|
43
|
+
Emulators.DATACONNECT,
|
|
41
44
|
].filter((v) => v);
|
|
42
45
|
exports.EMULATORS_SUPPORTED_BY_FUNCTIONS = [
|
|
43
46
|
Emulators.FIRESTORE,
|
package/lib/experiments.js
CHANGED
|
@@ -20,11 +20,13 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
20
20
|
rtdbmanagement: {
|
|
21
21
|
shortDescription: "Use new endpoint to administer realtime database instances",
|
|
22
22
|
},
|
|
23
|
-
|
|
24
|
-
shortDescription: "
|
|
25
|
-
fullDescription: "
|
|
26
|
-
"
|
|
27
|
-
"
|
|
23
|
+
functionsv2deployoptimizations: {
|
|
24
|
+
shortDescription: "Optimize deployments of v2 firebase functions",
|
|
25
|
+
fullDescription: "Reuse build images across funtions to increase performance and reliaibility " +
|
|
26
|
+
"of deploys. This has been made an experiment due to backend bugs that are " +
|
|
27
|
+
"temporarily causing failures in some regions with this optimization enabled",
|
|
28
|
+
public: true,
|
|
29
|
+
default: false,
|
|
28
30
|
},
|
|
29
31
|
deletegcfartifacts: {
|
|
30
32
|
shortDescription: `Add the ${(0, colorette_1.bold)("functions:deletegcfartifacts")} command to purge docker build images`,
|
|
@@ -86,7 +88,18 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
86
88
|
},
|
|
87
89
|
apphosting: {
|
|
88
90
|
shortDescription: "Allow CLI option for Frameworks",
|
|
89
|
-
default:
|
|
91
|
+
default: true,
|
|
92
|
+
public: false,
|
|
93
|
+
},
|
|
94
|
+
dataconnect: {
|
|
95
|
+
shortDescription: "Enable Data Connect related features.",
|
|
96
|
+
fullDescription: "Enable Data Connect related features.",
|
|
97
|
+
public: false,
|
|
98
|
+
},
|
|
99
|
+
genkit: {
|
|
100
|
+
shortDescription: "Enable Genkit related features.",
|
|
101
|
+
fullDescription: "Enable Genkit related features.",
|
|
102
|
+
default: true,
|
|
90
103
|
public: false,
|
|
91
104
|
},
|
|
92
105
|
});
|