firebase-tools-with-isolate 13.7.3 → 13.9.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 +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 +37 -0
- package/lib/commands/dataconnect-services-list.js +80 -0
- package/lib/commands/dataconnect-sql-diff.js +25 -0
- package/lib/commands/dataconnect-sql-migrate.js +45 -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/dataconnect/build.js +22 -0
- package/lib/dataconnect/checkIam.js +30 -0
- package/lib/dataconnect/client.js +112 -0
- package/lib/dataconnect/dataplaneClient.js +16 -0
- package/lib/dataconnect/ensureApis.js +12 -0
- package/lib/dataconnect/errors.js +29 -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 +12 -0
- package/lib/dataconnect/load.js +40 -0
- package/lib/dataconnect/names.js +46 -0
- package/lib/dataconnect/prompts.js +20 -0
- package/lib/dataconnect/provisionCloudSql.js +74 -0
- package/lib/dataconnect/schemaMigration.js +246 -0
- package/lib/dataconnect/types.js +22 -0
- package/lib/deploy/dataconnect/deploy.js +75 -0
- package/lib/deploy/dataconnect/index.js +9 -0
- package/lib/deploy/dataconnect/prepare.js +33 -0
- package/lib/deploy/dataconnect/release.js +65 -0
- package/lib/deploy/functions/checkIam.js +4 -34
- package/lib/deploy/functions/release/fabricator.js +7 -2
- 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 +39 -12
- package/lib/emulator/dataconnectEmulator.js +95 -0
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/downloadableEmulators.js +57 -8
- package/lib/emulator/portUtils.js +3 -3
- package/lib/emulator/registry.js +6 -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/next/index.js +6 -4
- package/lib/frameworks/next/utils.js +2 -1
- package/lib/functions/python.js +4 -3
- package/lib/gcp/apphosting.js +11 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +174 -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 +166 -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 +9 -1
- package/lib/requireAuth.js +1 -8
- package/lib/requireTosAcceptance.js +22 -0
- package/lib/utils.js +55 -4
- package/package.json +9 -3
- package/schema/connector-yaml.json +54 -0
- package/schema/dataconnect-yaml.json +72 -0
- package/schema/firebase-config.json +103 -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
|
@@ -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,31 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
519
521
|
});
|
|
520
522
|
await startEmulator(pubsubEmulator);
|
|
521
523
|
}
|
|
524
|
+
if (listenForEmulator.dataconnect) {
|
|
525
|
+
const dataConnectAddr = legacyGetFirstAddr(types_1.Emulators.DATACONNECT);
|
|
526
|
+
const config = (0, fileUtils_1.readFirebaseJson)(options.config);
|
|
527
|
+
if (!config.length) {
|
|
528
|
+
throw new error_1.FirebaseError("No Data Connect service found in firebase.json");
|
|
529
|
+
}
|
|
530
|
+
else if (config.length > 1) {
|
|
531
|
+
logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
532
|
+
}
|
|
533
|
+
let configDir = config[0].source;
|
|
534
|
+
if (!path.isAbsolute(configDir)) {
|
|
535
|
+
const cwd = options.cwd || process.cwd();
|
|
536
|
+
configDir = path.resolve(path.join(cwd), configDir);
|
|
537
|
+
}
|
|
538
|
+
const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
|
|
539
|
+
host: dataConnectAddr.host,
|
|
540
|
+
port: dataConnectAddr.port,
|
|
541
|
+
projectId,
|
|
542
|
+
auto_download: true,
|
|
543
|
+
configDir,
|
|
544
|
+
locationId: config[0].location,
|
|
545
|
+
rc: options.rc,
|
|
546
|
+
});
|
|
547
|
+
await startEmulator(dataConnectEmulator);
|
|
548
|
+
}
|
|
522
549
|
if (listenForEmulator.storage) {
|
|
523
550
|
const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
|
|
524
551
|
const storageEmulator = new storage_1.StorageEmulator({
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
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 grpcDefaultPort = 9510;
|
|
13
|
+
class DataConnectEmulator {
|
|
14
|
+
constructor(args) {
|
|
15
|
+
this.args = args;
|
|
16
|
+
this.logger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.DATACONNECT);
|
|
17
|
+
}
|
|
18
|
+
async start() {
|
|
19
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
|
|
20
|
+
this.logger.log("DEBUG", `Using Postgres connection string: ${this.getLocalConectionString()}`);
|
|
21
|
+
const info = await this.build();
|
|
22
|
+
if ((0, types_2.requiresVector)(info.metadata)) {
|
|
23
|
+
if (constants_1.Constants.isDemoProject(this.args.projectId)) {
|
|
24
|
+
this.logger.logLabeled("WARN", "Data Connect", "Detected a 'demo-' project, but vector embeddings require a real project. Operations that use vector_embed will fail.");
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
this.logger.logLabeled("WARN", "Data Connect", "Operations that use vector_embed will make calls to production Vertex AI");
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return (0, downloadableEmulators_1.start)(types_1.Emulators.DATACONNECT, {
|
|
31
|
+
...this.args,
|
|
32
|
+
http_port: port,
|
|
33
|
+
grpc_port: grpcDefaultPort,
|
|
34
|
+
config_dir: this.args.configDir,
|
|
35
|
+
local_connection_string: this.getLocalConectionString(),
|
|
36
|
+
project_id: this.args.projectId,
|
|
37
|
+
service_location: this.args.locationId,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
connect() {
|
|
41
|
+
return Promise.resolve();
|
|
42
|
+
}
|
|
43
|
+
stop() {
|
|
44
|
+
return (0, downloadableEmulators_1.stop)(types_1.Emulators.DATACONNECT);
|
|
45
|
+
}
|
|
46
|
+
getInfo() {
|
|
47
|
+
const host = this.args.host || constants_1.Constants.getDefaultHost();
|
|
48
|
+
const port = this.args.port || constants_1.Constants.getDefaultPort(types_1.Emulators.DATACONNECT);
|
|
49
|
+
return {
|
|
50
|
+
name: this.getName(),
|
|
51
|
+
host,
|
|
52
|
+
port,
|
|
53
|
+
pid: (0, downloadableEmulators_1.getPID)(types_1.Emulators.DATACONNECT),
|
|
54
|
+
timeout: 10000,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
getName() {
|
|
58
|
+
return types_1.Emulators.DATACONNECT;
|
|
59
|
+
}
|
|
60
|
+
async generate(connectorId) {
|
|
61
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
62
|
+
const cmd = [
|
|
63
|
+
"generate",
|
|
64
|
+
`--service_location=${this.args.locationId}`,
|
|
65
|
+
`--config_dir=${this.args.configDir}`,
|
|
66
|
+
`--connector_id=${connectorId}`,
|
|
67
|
+
];
|
|
68
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
69
|
+
if (res.error) {
|
|
70
|
+
throw new error_1.FirebaseError(`Error starting up Data Connect emulator: ${res.error}`);
|
|
71
|
+
}
|
|
72
|
+
return res.stdout;
|
|
73
|
+
}
|
|
74
|
+
async build() {
|
|
75
|
+
const commandInfo = await (0, downloadableEmulators_1.downloadIfNecessary)(types_1.Emulators.DATACONNECT);
|
|
76
|
+
const cmd = ["build", `--config_dir=${this.args.configDir}`];
|
|
77
|
+
const res = childProcess.spawnSync(commandInfo.binary, cmd, { encoding: "utf-8" });
|
|
78
|
+
if (res.stderr) {
|
|
79
|
+
throw new error_1.FirebaseError(`Unable to build your Data Connect schema and connectors: ${res.stderr}`);
|
|
80
|
+
}
|
|
81
|
+
try {
|
|
82
|
+
return JSON.parse(res.stdout);
|
|
83
|
+
}
|
|
84
|
+
catch (err) {
|
|
85
|
+
throw new error_1.FirebaseError(`Unable to parse 'fdc build' output: ${res.stdout ?? res.stderr}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
getLocalConectionString() {
|
|
89
|
+
if ((0, api_1.dataConnectLocalConnString)()) {
|
|
90
|
+
return (0, api_1.dataConnectLocalConnString)();
|
|
91
|
+
}
|
|
92
|
+
return this.args.rc.getDataconnect()?.postgres?.localConnectionString;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.DataConnectEmulator = DataConnectEmulator;
|
package/lib/emulator/download.js
CHANGED
|
@@ -15,7 +15,7 @@ async function downloadEmulator(name) {
|
|
|
15
15
|
const emulator = downloadableEmulators.getDownloadDetails(name);
|
|
16
16
|
emulatorLogger_1.EmulatorLogger.forEmulator(name).logLabeled("BULLET", name, `downloading ${path.basename(emulator.downloadPath)}...`);
|
|
17
17
|
fs.ensureDirSync(emulator.opts.cacheDir);
|
|
18
|
-
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl);
|
|
18
|
+
const tmpfile = await downloadUtils.downloadToTmp(emulator.opts.remoteUrl, !!emulator.opts.auth);
|
|
19
19
|
if (!emulator.opts.skipChecksumAndSize) {
|
|
20
20
|
await validateSize(tmpfile, emulator.opts.expectedSize);
|
|
21
21
|
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.6",
|
|
27
|
+
expectedSize: 66349770,
|
|
28
|
+
expectedChecksum: "2eaabbe3cdb4867df585b7ec5505bad7",
|
|
29
29
|
},
|
|
30
30
|
storage: {
|
|
31
31
|
version: "1.1.3",
|
|
@@ -44,6 +44,17 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
44
44
|
expectedSize: 65611398,
|
|
45
45
|
expectedChecksum: "70bb840321423e6ae621a3ae2f314903",
|
|
46
46
|
},
|
|
47
|
+
dataconnect: process.platform === "darwin"
|
|
48
|
+
? {
|
|
49
|
+
version: "1.1.17",
|
|
50
|
+
expectedSize: 25602224,
|
|
51
|
+
expectedChecksum: "1f9e3dd040a0ac4d1cb4d9dde4a3c0b0",
|
|
52
|
+
}
|
|
53
|
+
: {
|
|
54
|
+
version: "1.1.17",
|
|
55
|
+
expectedSize: 23036912,
|
|
56
|
+
expectedChecksum: "a0ec0517108f842ed06fea14fe7c7e56",
|
|
57
|
+
},
|
|
47
58
|
};
|
|
48
59
|
exports.DownloadDetails = {
|
|
49
60
|
database: {
|
|
@@ -107,6 +118,22 @@ exports.DownloadDetails = {
|
|
|
107
118
|
namePrefix: "pubsub-emulator",
|
|
108
119
|
},
|
|
109
120
|
},
|
|
121
|
+
dataconnect: {
|
|
122
|
+
downloadPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
|
|
123
|
+
version: EMULATOR_UPDATE_DETAILS.dataconnect.version,
|
|
124
|
+
binaryPath: path.join(CACHE_DIR, `dataconnect-emulator-${EMULATOR_UPDATE_DETAILS.dataconnect.version}`),
|
|
125
|
+
opts: {
|
|
126
|
+
cacheDir: CACHE_DIR,
|
|
127
|
+
remoteUrl: process.platform === "darwin"
|
|
128
|
+
? `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-macos-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`
|
|
129
|
+
: `https://storage.googleapis.com/firemat-preview-drop/emulator/dataconnect-emulator-linux-v${EMULATOR_UPDATE_DETAILS.dataconnect.version}`,
|
|
130
|
+
expectedSize: EMULATOR_UPDATE_DETAILS.dataconnect.expectedSize,
|
|
131
|
+
expectedChecksum: EMULATOR_UPDATE_DETAILS.dataconnect.expectedChecksum,
|
|
132
|
+
skipChecksumAndSize: false,
|
|
133
|
+
namePrefix: "dataconnect-emulator",
|
|
134
|
+
auth: true,
|
|
135
|
+
},
|
|
136
|
+
},
|
|
110
137
|
};
|
|
111
138
|
const EmulatorDetails = {
|
|
112
139
|
database: {
|
|
@@ -134,6 +161,11 @@ const EmulatorDetails = {
|
|
|
134
161
|
instance: null,
|
|
135
162
|
stdout: null,
|
|
136
163
|
},
|
|
164
|
+
dataconnect: {
|
|
165
|
+
name: types_1.Emulators.DATACONNECT,
|
|
166
|
+
instance: null,
|
|
167
|
+
stdout: null,
|
|
168
|
+
},
|
|
137
169
|
};
|
|
138
170
|
const Commands = {
|
|
139
171
|
database: {
|
|
@@ -147,6 +179,7 @@ const Commands = {
|
|
|
147
179
|
"single_project_mode",
|
|
148
180
|
],
|
|
149
181
|
joinArgs: false,
|
|
182
|
+
shell: false,
|
|
150
183
|
},
|
|
151
184
|
firestore: {
|
|
152
185
|
binary: "java",
|
|
@@ -168,6 +201,7 @@ const Commands = {
|
|
|
168
201
|
"single_project_mode",
|
|
169
202
|
],
|
|
170
203
|
joinArgs: false,
|
|
204
|
+
shell: false,
|
|
171
205
|
},
|
|
172
206
|
storage: {
|
|
173
207
|
binary: "java",
|
|
@@ -179,18 +213,28 @@ const Commands = {
|
|
|
179
213
|
],
|
|
180
214
|
optionalArgs: [],
|
|
181
215
|
joinArgs: false,
|
|
216
|
+
shell: false,
|
|
182
217
|
},
|
|
183
218
|
pubsub: {
|
|
184
219
|
binary: getExecPath(types_1.Emulators.PUBSUB),
|
|
185
220
|
args: [],
|
|
186
221
|
optionalArgs: ["port", "host"],
|
|
187
222
|
joinArgs: true,
|
|
223
|
+
shell: true,
|
|
188
224
|
},
|
|
189
225
|
ui: {
|
|
190
226
|
binary: "node",
|
|
191
227
|
args: [getExecPath(types_1.Emulators.UI)],
|
|
192
228
|
optionalArgs: [],
|
|
193
229
|
joinArgs: false,
|
|
230
|
+
shell: false,
|
|
231
|
+
},
|
|
232
|
+
dataconnect: {
|
|
233
|
+
binary: getExecPath(types_1.Emulators.DATACONNECT),
|
|
234
|
+
args: ["dev"],
|
|
235
|
+
optionalArgs: ["http_port", "grpc_port", "config_dir", "local_connection_string", "project_id"],
|
|
236
|
+
joinArgs: true,
|
|
237
|
+
shell: true,
|
|
194
238
|
},
|
|
195
239
|
};
|
|
196
240
|
function getExecPath(name) {
|
|
@@ -237,6 +281,7 @@ function _getCommand(emulator, args) {
|
|
|
237
281
|
args: cmdLineArgs,
|
|
238
282
|
optionalArgs: baseCmd.optionalArgs,
|
|
239
283
|
joinArgs: baseCmd.joinArgs,
|
|
284
|
+
shell: baseCmd.shell,
|
|
240
285
|
};
|
|
241
286
|
}
|
|
242
287
|
exports._getCommand = _getCommand;
|
|
@@ -272,11 +317,15 @@ async function _runBinary(emulator, command, extraEnv) {
|
|
|
272
317
|
const logger = emulatorLogger_1.EmulatorLogger.forEmulator(emulator.name);
|
|
273
318
|
emulator.stdout = fs.createWriteStream(getLogFileName(emulator.name));
|
|
274
319
|
try {
|
|
275
|
-
|
|
320
|
+
const opts = {
|
|
276
321
|
env: { ...process.env, ...extraEnv },
|
|
277
322
|
detached: true,
|
|
278
323
|
stdio: ["inherit", "pipe", "pipe"],
|
|
279
|
-
}
|
|
324
|
+
};
|
|
325
|
+
if (command.shell && utils.IS_WINDOWS) {
|
|
326
|
+
opts.shell = true;
|
|
327
|
+
}
|
|
328
|
+
emulator.instance = childProcess.spawn(command.binary, command.args, opts);
|
|
280
329
|
}
|
|
281
330
|
catch (e) {
|
|
282
331
|
if (e.code === "EACCES") {
|
|
@@ -353,10 +402,10 @@ async function stop(targetName) {
|
|
|
353
402
|
exports.stop = stop;
|
|
354
403
|
async function downloadIfNecessary(targetName) {
|
|
355
404
|
const hasEmulator = fs.existsSync(getExecPath(targetName));
|
|
356
|
-
if (hasEmulator) {
|
|
357
|
-
|
|
405
|
+
if (!hasEmulator) {
|
|
406
|
+
await (0, download_1.downloadEmulator)(targetName);
|
|
358
407
|
}
|
|
359
|
-
|
|
408
|
+
return Commands[targetName];
|
|
360
409
|
}
|
|
361
410
|
exports.downloadIfNecessary = downloadIfNecessary;
|
|
362
411
|
async function start(targetName, args, extraEnv = {}) {
|
|
@@ -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: true,
|
|
150
150
|
hub: false,
|
|
151
151
|
ui: false,
|
|
152
152
|
auth: true,
|
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) {
|
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
|
});
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRuntime = exports.DEFAULT_RUNTIME = exports.getFunctionProperties = exports.getFunctionResourcesWithParamSubstitution = exports.
|
|
4
|
-
const yaml = require("yaml");
|
|
5
|
-
const path = require("path");
|
|
6
|
-
const fs = require("fs-extra");
|
|
3
|
+
exports.getRuntime = exports.DEFAULT_RUNTIME = exports.getFunctionProperties = exports.getFunctionResourcesWithParamSubstitution = exports.readPostinstall = exports.readExtensionYaml = void 0;
|
|
7
4
|
const supported = require("../../deploy/functions/runtimes/supported");
|
|
8
5
|
const error_1 = require("../../error");
|
|
9
6
|
const extensionsHelper_1 = require("../extensionsHelper");
|
|
10
7
|
const utils_1 = require("../utils");
|
|
8
|
+
const utils_2 = require("../../utils");
|
|
11
9
|
const SPEC_FILE = "extension.yaml";
|
|
12
10
|
const POSTINSTALL_FILE = "POSTINSTALL.md";
|
|
13
11
|
const validFunctionTypes = [
|
|
@@ -15,21 +13,10 @@ const validFunctionTypes = [
|
|
|
15
13
|
"firebaseextensions.v1beta.v2function",
|
|
16
14
|
"firebaseextensions.v1beta.scheduledFunction",
|
|
17
15
|
];
|
|
18
|
-
function wrappedSafeLoad(source) {
|
|
19
|
-
try {
|
|
20
|
-
return yaml.parse(source);
|
|
21
|
-
}
|
|
22
|
-
catch (err) {
|
|
23
|
-
if (err instanceof yaml.YAMLParseError) {
|
|
24
|
-
throw new error_1.FirebaseError(`YAML Error: ${err.message}`, { original: err });
|
|
25
|
-
}
|
|
26
|
-
throw err;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
16
|
async function readExtensionYaml(directory) {
|
|
30
|
-
const extensionYaml = await readFileFromDirectory(directory, SPEC_FILE);
|
|
17
|
+
const extensionYaml = await (0, utils_2.readFileFromDirectory)(directory, SPEC_FILE);
|
|
31
18
|
const source = extensionYaml.source;
|
|
32
|
-
const spec = wrappedSafeLoad(source);
|
|
19
|
+
const spec = (0, utils_2.wrappedSafeLoad)(source);
|
|
33
20
|
spec.params = spec.params ?? [];
|
|
34
21
|
spec.systemParams = spec.systemParams ?? [];
|
|
35
22
|
spec.resources = spec.resources ?? [];
|
|
@@ -43,31 +30,10 @@ async function readExtensionYaml(directory) {
|
|
|
43
30
|
}
|
|
44
31
|
exports.readExtensionYaml = readExtensionYaml;
|
|
45
32
|
async function readPostinstall(directory) {
|
|
46
|
-
const content = await readFileFromDirectory(directory, POSTINSTALL_FILE);
|
|
33
|
+
const content = await (0, utils_2.readFileFromDirectory)(directory, POSTINSTALL_FILE);
|
|
47
34
|
return content.source;
|
|
48
35
|
}
|
|
49
36
|
exports.readPostinstall = readPostinstall;
|
|
50
|
-
function readFileFromDirectory(directory, file) {
|
|
51
|
-
return new Promise((resolve, reject) => {
|
|
52
|
-
fs.readFile(path.resolve(directory, file), "utf8", (err, data) => {
|
|
53
|
-
if (err) {
|
|
54
|
-
if (err.code === "ENOENT") {
|
|
55
|
-
return reject(new error_1.FirebaseError(`Could not find "${file}" in "${directory}"`, { original: err }));
|
|
56
|
-
}
|
|
57
|
-
reject(new error_1.FirebaseError(`Failed to read file "${file}" in "${directory}"`, { original: err }));
|
|
58
|
-
}
|
|
59
|
-
else {
|
|
60
|
-
resolve(data);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
}).then((source) => {
|
|
64
|
-
return {
|
|
65
|
-
source,
|
|
66
|
-
sourceDirectory: directory,
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
}
|
|
70
|
-
exports.readFileFromDirectory = readFileFromDirectory;
|
|
71
37
|
function getFunctionResourcesWithParamSubstitution(extensionSpec, params) {
|
|
72
38
|
const rawResources = extensionSpec.resources.filter((resource) => validFunctionTypes.includes(resource.type));
|
|
73
39
|
return (0, extensionsHelper_1.substituteParams)(rawResources, params);
|
|
@@ -120,9 +120,9 @@ async function build(dir, target, context) {
|
|
|
120
120
|
headers.push(...headersFromMetaFiles);
|
|
121
121
|
if (appPathsManifest) {
|
|
122
122
|
const unrenderedServerComponents = (0, utils_2.getNonStaticServerComponents)(appPathsManifest, appPathRoutesManifest, prerenderedRoutes, dynamicRoutes);
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
unrenderedServerComponents.delete(
|
|
123
|
+
const notFoundPageKey = ["/_not-found", "/_not-found/page"].find((key) => unrenderedServerComponents.has(key));
|
|
124
|
+
if (notFoundPageKey && (await (0, utils_2.hasStaticAppNotFoundComponent)(dir, distDir))) {
|
|
125
|
+
unrenderedServerComponents.delete(notFoundPageKey);
|
|
126
126
|
}
|
|
127
127
|
for (const key of unrenderedServerComponents) {
|
|
128
128
|
reasonsForBackend.add(`non-static component ${key}`);
|
|
@@ -399,7 +399,9 @@ async function ɵcodegenFunctionsDirectory(sourceDir, destDir, target, context)
|
|
|
399
399
|
(0, utils_2.getProductionDistDirFiles)(sourceDir, distDir),
|
|
400
400
|
(0, fs_extra_1.mkdirp)((0, path_1.join)(destDir, distDir)),
|
|
401
401
|
]);
|
|
402
|
-
await Promise.all(productionDistDirfiles.map((file) => (0, fs_extra_1.copy)(
|
|
402
|
+
await Promise.all(productionDistDirfiles.map((file) => (0, fs_extra_1.copy)((0, path_1.join)(sourceDir, distDir, file), (0, path_1.join)(destDir, distDir, file), {
|
|
403
|
+
recursive: true,
|
|
404
|
+
})));
|
|
403
405
|
return { packageJson, frameworksEntry: "next.js", dotEnv };
|
|
404
406
|
}
|
|
405
407
|
exports.ɵcodegenFunctionsDirectory = ɵcodegenFunctionsDirectory;
|
|
@@ -233,7 +233,8 @@ async function getProductionDistDirFiles(sourceDir, distDir) {
|
|
|
233
233
|
ignore: [(0, path_1.join)("cache", "webpack", "*-development", "**"), (0, path_1.join)("cache", "eslint", "**")],
|
|
234
234
|
cwd: (0, path_1.join)(sourceDir, distDir),
|
|
235
235
|
nodir: true,
|
|
236
|
-
absolute:
|
|
236
|
+
absolute: false,
|
|
237
|
+
realpath: utils_2.IS_WINDOWS,
|
|
237
238
|
}, (err, matches) => {
|
|
238
239
|
if (err)
|
|
239
240
|
reject(err);
|
package/lib/functions/python.js
CHANGED
|
@@ -4,13 +4,14 @@ exports.runWithVirtualEnv = exports.virtualEnvCmd = exports.DEFAULT_VENV_DIR = v
|
|
|
4
4
|
const path = require("path");
|
|
5
5
|
const spawn = require("cross-spawn");
|
|
6
6
|
const logger_1 = require("../logger");
|
|
7
|
+
const utils_1 = require("../utils");
|
|
7
8
|
exports.DEFAULT_VENV_DIR = "venv";
|
|
8
9
|
function virtualEnvCmd(cwd, venvDir) {
|
|
9
|
-
const activateScriptPath =
|
|
10
|
+
const activateScriptPath = utils_1.IS_WINDOWS ? ["Scripts", "activate.bat"] : ["bin", "activate"];
|
|
10
11
|
const venvActivate = `"${path.join(cwd, venvDir, ...activateScriptPath)}"`;
|
|
11
12
|
return {
|
|
12
|
-
command:
|
|
13
|
-
args: [
|
|
13
|
+
command: utils_1.IS_WINDOWS ? venvActivate : ".",
|
|
14
|
+
args: [utils_1.IS_WINDOWS ? "" : venvActivate],
|
|
14
15
|
};
|
|
15
16
|
}
|
|
16
17
|
exports.virtualEnvCmd = virtualEnvCmd;
|
package/lib/gcp/apphosting.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getNextRolloutId = exports.ensureApiEnabled = exports.listLocations = exports.updateTraffic = exports.listRollouts = exports.createRollout = exports.createBuild = exports.listBuilds = exports.getBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.client = exports.API_VERSION = void 0;
|
|
3
|
+
exports.getNextRolloutId = exports.ensureApiEnabled = exports.listLocations = exports.updateTraffic = exports.listRollouts = exports.createRollout = exports.createBuild = exports.listBuilds = exports.getBuild = exports.deleteBackend = exports.listBackends = exports.getBackend = exports.createBackend = exports.parseBackendName = exports.serviceAgentEmail = exports.client = exports.API_VERSION = void 0;
|
|
4
4
|
const proto = require("../gcp/proto");
|
|
5
5
|
const apiv2_1 = require("../apiv2");
|
|
6
6
|
const projectUtils_1 = require("../projectUtils");
|
|
@@ -19,6 +19,16 @@ exports.client = new apiv2_1.Client({
|
|
|
19
19
|
(0, metaprogramming_1.assertImplements)();
|
|
20
20
|
(0, metaprogramming_1.assertImplements)();
|
|
21
21
|
(0, metaprogramming_1.assertImplements)();
|
|
22
|
+
const P4SA_DOMAIN = (0, api_1.apphostingP4SADomain)();
|
|
23
|
+
function serviceAgentEmail(projectNumber) {
|
|
24
|
+
return `service-${projectNumber}@${P4SA_DOMAIN}`;
|
|
25
|
+
}
|
|
26
|
+
exports.serviceAgentEmail = serviceAgentEmail;
|
|
27
|
+
function parseBackendName(backendName) {
|
|
28
|
+
const [, projectName, , location, , id] = backendName.split("/");
|
|
29
|
+
return { projectName, location, id };
|
|
30
|
+
}
|
|
31
|
+
exports.parseBackendName = parseBackendName;
|
|
22
32
|
async function createBackend(projectId, location, backendReqBoby, backendId) {
|
|
23
33
|
const res = await exports.client.post(`projects/${projectId}/locations/${location}/backends`, {
|
|
24
34
|
...backendReqBoby,
|