firebase-tools 14.2.0 → 14.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/dataconnect/build.js +1 -9
- package/lib/emulator/downloadableEmulators.js +9 -9
- package/lib/emulator/env.js +28 -1
- package/lib/emulator/functionsEmulator.js +4 -4
- package/lib/emulator/ui.js +4 -7
- package/lib/experiments.js +0 -6
- package/lib/init/features/genkit/index.js +59 -55
- package/package.json +1 -1
package/lib/dataconnect/build.js
CHANGED
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.handleBuildErrors = exports.build = void 0;
|
|
4
4
|
const dataconnectEmulator_1 = require("../emulator/dataconnectEmulator");
|
|
5
5
|
const error_1 = require("../error");
|
|
6
|
-
const experiments = require("../experiments");
|
|
7
6
|
const prompt_1 = require("../prompt");
|
|
8
7
|
const utils = require("../utils");
|
|
9
8
|
const graphqlError_1 = require("./graphqlError");
|
|
@@ -12,14 +11,7 @@ async function build(options, configDir, dryRun) {
|
|
|
12
11
|
var _a, _b;
|
|
13
12
|
const account = (0, auth_1.getProjectDefaultAccount)(options.projectRoot);
|
|
14
13
|
const args = { configDir, account };
|
|
15
|
-
if (
|
|
16
|
-
const flags = process.env["DATA_CONNECT_PREVIEW"];
|
|
17
|
-
if (flags) {
|
|
18
|
-
process.env["DATA_CONNECT_PREVIEW"] = flags + ",conn_evolution";
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
process.env["DATA_CONNECT_PREVIEW"] = "conn_evolution";
|
|
22
|
-
}
|
|
14
|
+
if (options.projectId) {
|
|
23
15
|
args.projectId = options.projectId;
|
|
24
16
|
}
|
|
25
17
|
const buildResult = await dataconnectEmulator_1.DataConnectEmulator.build(args);
|
|
@@ -48,20 +48,20 @@ const EMULATOR_UPDATE_DETAILS = {
|
|
|
48
48
|
},
|
|
49
49
|
dataconnect: process.platform === "darwin"
|
|
50
50
|
? {
|
|
51
|
-
version: "2.
|
|
52
|
-
expectedSize:
|
|
53
|
-
expectedChecksum: "
|
|
51
|
+
version: "2.3.1",
|
|
52
|
+
expectedSize: 27271936,
|
|
53
|
+
expectedChecksum: "5ffcfe584c5af818477a00eb6450dd66",
|
|
54
54
|
}
|
|
55
55
|
: process.platform === "win32"
|
|
56
56
|
? {
|
|
57
|
-
version: "2.
|
|
58
|
-
expectedSize:
|
|
59
|
-
expectedChecksum: "
|
|
57
|
+
version: "2.3.1",
|
|
58
|
+
expectedSize: 27729408,
|
|
59
|
+
expectedChecksum: "b71f1686724e8e051810b3a2e14c6d08",
|
|
60
60
|
}
|
|
61
61
|
: {
|
|
62
|
-
version: "2.
|
|
63
|
-
expectedSize:
|
|
64
|
-
expectedChecksum: "
|
|
62
|
+
version: "2.3.1",
|
|
63
|
+
expectedSize: 27185304,
|
|
64
|
+
expectedChecksum: "54c40731f4563073404591ef1ffcdc20",
|
|
65
65
|
},
|
|
66
66
|
};
|
|
67
67
|
exports.DownloadDetails = {
|
package/lib/emulator/env.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCredentialsEnvironment = exports.setEnvVarsForEmulators = void 0;
|
|
3
|
+
exports.maybeUsePortForwarding = exports.getCredentialsEnvironment = exports.setEnvVarsForEmulators = void 0;
|
|
4
4
|
const constants_1 = require("./constants");
|
|
5
5
|
const types_1 = require("./types");
|
|
6
6
|
const functionsEmulatorShared_1 = require("./functionsEmulatorShared");
|
|
7
7
|
const defaultCredentials_1 = require("../defaultCredentials");
|
|
8
8
|
function setEnvVarsForEmulators(env, emulators) {
|
|
9
|
+
maybeUsePortForwarding(emulators);
|
|
9
10
|
for (const emu of emulators) {
|
|
10
11
|
const host = (0, functionsEmulatorShared_1.formatHost)(emu);
|
|
11
12
|
switch (emu.name) {
|
|
@@ -59,3 +60,29 @@ async function getCredentialsEnvironment(account, logger, logLabel, silent = fal
|
|
|
59
60
|
return credentialEnv;
|
|
60
61
|
}
|
|
61
62
|
exports.getCredentialsEnvironment = getCredentialsEnvironment;
|
|
63
|
+
function maybeUsePortForwarding(emulatorInfos) {
|
|
64
|
+
var _a;
|
|
65
|
+
const portForwardingHost = process.env.WEB_HOST;
|
|
66
|
+
if (portForwardingHost) {
|
|
67
|
+
for (const info of emulatorInfos) {
|
|
68
|
+
if (info.host.includes(portForwardingHost)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
const url = `${info.port}-${portForwardingHost}`;
|
|
72
|
+
info.host = url;
|
|
73
|
+
info.listen = (_a = info.listen) === null || _a === void 0 ? void 0 : _a.map((l) => {
|
|
74
|
+
l.address = url;
|
|
75
|
+
l.port = 443;
|
|
76
|
+
return l;
|
|
77
|
+
});
|
|
78
|
+
info.port = 443;
|
|
79
|
+
const fsInfo = info;
|
|
80
|
+
if (fsInfo.webSocketPort) {
|
|
81
|
+
fsInfo.webSocketHost = `${fsInfo.webSocketPort}-${portForwardingHost}`;
|
|
82
|
+
fsInfo.webSocketPort = 443;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return emulatorInfos;
|
|
87
|
+
}
|
|
88
|
+
exports.maybeUsePortForwarding = maybeUsePortForwarding;
|
|
@@ -912,6 +912,7 @@ class FunctionsEmulator {
|
|
|
912
912
|
if (this.args.remoteEmulators) {
|
|
913
913
|
emulatorInfos = emulatorInfos.concat(Object.values(this.args.remoteEmulators));
|
|
914
914
|
}
|
|
915
|
+
(0, env_1.maybeUsePortForwarding)(emulatorInfos);
|
|
915
916
|
(0, env_1.setEnvVarsForEmulators)(envs, emulatorInfos);
|
|
916
917
|
if (this.debugMode) {
|
|
917
918
|
envs["FUNCTION_DEBUG_MODE"] = "true";
|
|
@@ -1082,10 +1083,9 @@ class FunctionsEmulator {
|
|
|
1082
1083
|
return;
|
|
1083
1084
|
}
|
|
1084
1085
|
getEmulatorInfo(emulator) {
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
}
|
|
1086
|
+
var _a;
|
|
1087
|
+
if ((_a = this.args.remoteEmulators) === null || _a === void 0 ? void 0 : _a[emulator]) {
|
|
1088
|
+
return this.args.remoteEmulators[emulator];
|
|
1089
1089
|
}
|
|
1090
1090
|
return registry_1.EmulatorRegistry.getInfo(emulator);
|
|
1091
1091
|
}
|
package/lib/emulator/ui.js
CHANGED
|
@@ -12,6 +12,7 @@ const constants_1 = require("./constants");
|
|
|
12
12
|
const track_1 = require("../track");
|
|
13
13
|
const ExpressBasedEmulator_1 = require("./ExpressBasedEmulator");
|
|
14
14
|
const experiments_1 = require("../experiments");
|
|
15
|
+
const env_1 = require("./env");
|
|
15
16
|
class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
16
17
|
constructor(args) {
|
|
17
18
|
super({
|
|
@@ -35,13 +36,9 @@ class EmulatorUI extends ExpressBasedEmulator_1.ExpressBasedEmulator {
|
|
|
35
36
|
const downloadDetails = downloadableEmulators.getDownloadDetails(types_1.Emulators.UI);
|
|
36
37
|
const webDir = path.join(downloadDetails.unzipDir, "client");
|
|
37
38
|
app.get("/api/config", this.jsonHandler(() => {
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
if (enabledExperiments) {
|
|
43
|
-
json.experiments = enabledExperiments;
|
|
44
|
-
}
|
|
39
|
+
const emulatorInfos = hub.getRunningEmulatorsMapping();
|
|
40
|
+
(0, env_1.maybeUsePortForwarding)(Object.values(emulatorInfos));
|
|
41
|
+
const json = Object.assign({ projectId, experiments: enabledExperiments !== null && enabledExperiments !== void 0 ? enabledExperiments : [], analytics: emulatorGaSession }, emulatorInfos);
|
|
45
42
|
return Promise.resolve(json);
|
|
46
43
|
}));
|
|
47
44
|
app.use(express.static(webDir));
|
package/lib/experiments.js
CHANGED
|
@@ -100,12 +100,6 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
100
100
|
default: false,
|
|
101
101
|
public: true,
|
|
102
102
|
},
|
|
103
|
-
fdcconnectorevolution: {
|
|
104
|
-
shortDescription: "Enable Data Connect connector evolution warnings.",
|
|
105
|
-
fullDescription: "Enable Data Connect connector evolution warnings.",
|
|
106
|
-
default: true,
|
|
107
|
-
public: false,
|
|
108
|
-
},
|
|
109
103
|
});
|
|
110
104
|
function isValidExperiment(name) {
|
|
111
105
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
|
@@ -15,32 +15,43 @@ const logger_1 = require("../../../logger");
|
|
|
15
15
|
const error_1 = require("../../../error");
|
|
16
16
|
const utils_1 = require("../../../utils");
|
|
17
17
|
const UNKNOWN_VERSION_TOO_HIGH = "2.0.0";
|
|
18
|
+
const MIN_VERSION = "0.6.0";
|
|
18
19
|
const LATEST_TEMPLATE = "1.0.0";
|
|
19
|
-
async function
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (process.env.GENKIT_DEV_VERSION && typeof process.env.GENKIT_DEV_VERSION === "string") {
|
|
25
|
-
semver.parse(process.env.GENKIT_DEV_VERSION);
|
|
26
|
-
genkitVersion = process.env.GENKIT_DEV_VERSION;
|
|
27
|
-
}
|
|
28
|
-
else {
|
|
29
|
-
try {
|
|
30
|
-
genkitVersion = await (0, spawn_1.spawnWithOutput)("npm", ["view", "genkit", "version"]);
|
|
20
|
+
async function getPackageVersion(packageName, envVariable) {
|
|
21
|
+
const envVal = process.env[envVariable];
|
|
22
|
+
if (envVal && typeof envVal === "string") {
|
|
23
|
+
if (semver.parse(envVal)) {
|
|
24
|
+
return envVal;
|
|
31
25
|
}
|
|
32
|
-
|
|
33
|
-
throw new error_1.FirebaseError(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
26
|
+
else {
|
|
27
|
+
throw new error_1.FirebaseError(`Invalid version string '${envVal}' specified in ${envVariable}`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const output = await (0, spawn_1.spawnWithOutput)("npm", ["view", packageName, "version"]);
|
|
32
|
+
if (!output) {
|
|
33
|
+
throw new error_1.FirebaseError(`Unable to determine ${packageName} version to install`);
|
|
39
34
|
}
|
|
35
|
+
return output;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
throw new error_1.FirebaseError(
|
|
37
|
+
catch (err) {
|
|
38
|
+
throw new error_1.FirebaseError(`Unable to determine which version of ${packageName} to install.\n` +
|
|
39
|
+
`npm Error: ${(0, error_1.getErrMsg)(err)}\n\n` +
|
|
40
|
+
"For a possible workaround run\n npm view " +
|
|
41
|
+
packageName +
|
|
42
|
+
" version\n" +
|
|
43
|
+
"and then set an environment variable:\n" +
|
|
44
|
+
` export ${envVariable}=<output from previous command>\n` +
|
|
45
|
+
"and run `firebase init genkit` again");
|
|
43
46
|
}
|
|
47
|
+
}
|
|
48
|
+
async function getGenkitInfo() {
|
|
49
|
+
let templateVersion = LATEST_TEMPLATE;
|
|
50
|
+
let stopInstall = false;
|
|
51
|
+
const genkitVersion = await getPackageVersion("genkit", "GENKIT_DEV_VERSION");
|
|
52
|
+
const cliVersion = await getPackageVersion("genkit-cli", "GENKIT_CLI_DEV_VERSION");
|
|
53
|
+
const vertexVersion = await getPackageVersion("@genkit-ai/vertexai", "GENKIT_VERTEX_VERSION");
|
|
54
|
+
const googleAiVersion = await getPackageVersion("@genkit-ai/googleai", "GENKIT_GOOGLEAI_VERSION");
|
|
44
55
|
if (semver.gte(genkitVersion, UNKNOWN_VERSION_TOO_HIGH)) {
|
|
45
56
|
const continueInstall = await (0, prompt_1.confirm)({
|
|
46
57
|
message: clc.yellow(`WARNING: The latest version of Genkit (${genkitVersion}) isn't supported by this\n` +
|
|
@@ -56,24 +67,32 @@ async function getGenkitVersion() {
|
|
|
56
67
|
else if (semver.gte(genkitVersion, "1.0.0-rc.1")) {
|
|
57
68
|
templateVersion = "1.0.0";
|
|
58
69
|
}
|
|
59
|
-
else if (semver.gte(genkitVersion,
|
|
70
|
+
else if (semver.gte(genkitVersion, MIN_VERSION)) {
|
|
60
71
|
templateVersion = "0.9.0";
|
|
61
72
|
}
|
|
62
73
|
else {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
return {
|
|
74
|
+
throw new error_1.FirebaseError(`The requested version of Genkit (${genkitVersion}) is no ` +
|
|
75
|
+
`longer supported. Please specify a newer version.`);
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
genkitVersion,
|
|
79
|
+
cliVersion,
|
|
80
|
+
vertexVersion,
|
|
81
|
+
googleAiVersion,
|
|
82
|
+
templateVersion,
|
|
83
|
+
stopInstall,
|
|
84
|
+
};
|
|
67
85
|
}
|
|
68
|
-
function showStartMessage(
|
|
86
|
+
function showStartMessage(setup, command) {
|
|
87
|
+
logger_1.logger.info();
|
|
69
88
|
logger_1.logger.info("\nLogin to Google Cloud using:");
|
|
70
|
-
logger_1.logger.info(clc.bold(clc.green(` gcloud auth application-default login --project ${
|
|
89
|
+
logger_1.logger.info(clc.bold(clc.green(` gcloud auth application-default login --project ${setup.projectId || "your-project-id"}\n`)));
|
|
71
90
|
logger_1.logger.info("Then start the Genkit developer experience by running:");
|
|
72
91
|
logger_1.logger.info(clc.bold(clc.green(` ${command}`)));
|
|
73
92
|
}
|
|
74
93
|
async function doSetup(setup, config, options) {
|
|
75
94
|
var _a;
|
|
76
|
-
const genkitInfo = await
|
|
95
|
+
const genkitInfo = await getGenkitInfo();
|
|
77
96
|
if (genkitInfo.stopInstall) {
|
|
78
97
|
(0, utils_1.logLabeledWarning)("genkit", "Stopped Genkit initialization");
|
|
79
98
|
return;
|
|
@@ -108,31 +127,16 @@ async function doSetup(setup, config, options) {
|
|
|
108
127
|
},
|
|
109
128
|
])).choice;
|
|
110
129
|
try {
|
|
111
|
-
(0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.
|
|
130
|
+
(0, utils_1.logLabeledBullet)("genkit", `Installing Genkit CLI version ${genkitInfo.cliVersion}`);
|
|
112
131
|
if (installType === "globally") {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
logger_1.logger.info("Start the Genkit developer experience by running:");
|
|
117
|
-
logger_1.logger.info(` cd ${setup.functions.source} && genkit start`);
|
|
118
|
-
}
|
|
119
|
-
else {
|
|
120
|
-
await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.genkitVersion}`], projectDir);
|
|
121
|
-
await genkitSetup(options, genkitInfo, projectDir);
|
|
122
|
-
showStartMessage(config, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
123
|
-
}
|
|
132
|
+
await (0, spawn_1.wrapSpawn)("npm", ["install", "-g", `genkit-cli@${genkitInfo.cliVersion}`], projectDir);
|
|
133
|
+
await genkitSetup(options, genkitInfo, projectDir);
|
|
134
|
+
showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
124
135
|
}
|
|
125
136
|
else {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
showStartMessage(config, `cd ${setup.functions.source} && npx genkit start`);
|
|
130
|
-
}
|
|
131
|
-
else {
|
|
132
|
-
await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.genkitVersion}`, "--save-dev"], projectDir);
|
|
133
|
-
await genkitSetup(options, genkitInfo, projectDir);
|
|
134
|
-
showStartMessage(config, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
135
|
-
}
|
|
137
|
+
await (0, spawn_1.wrapSpawn)("npm", ["install", `genkit-cli@${genkitInfo.cliVersion}`, "--save-dev"], projectDir);
|
|
138
|
+
await genkitSetup(options, genkitInfo, projectDir);
|
|
139
|
+
showStartMessage(setup, `cd ${setup.functions.source} && npm run genkit:start`);
|
|
136
140
|
}
|
|
137
141
|
}
|
|
138
142
|
catch (err) {
|
|
@@ -151,17 +155,17 @@ async function ensureVertexApiEnabled(options) {
|
|
|
151
155
|
return await (0, ensureApiEnabled_1.ensure)(projectId, VERTEX_AI_URL, "aiplatform", silently);
|
|
152
156
|
}
|
|
153
157
|
exports.ensureVertexApiEnabled = ensureVertexApiEnabled;
|
|
154
|
-
function getModelOptions(
|
|
158
|
+
function getModelOptions(genkitInfo) {
|
|
155
159
|
const modelOptions = {
|
|
156
160
|
vertexai: {
|
|
157
161
|
label: "Google Cloud Vertex AI",
|
|
158
162
|
plugin: "@genkit-ai/vertexai",
|
|
159
|
-
package: `@genkit-ai/vertexai@${
|
|
163
|
+
package: `@genkit-ai/vertexai@${genkitInfo.vertexVersion}`,
|
|
160
164
|
},
|
|
161
165
|
googleai: {
|
|
162
166
|
label: "Google AI",
|
|
163
167
|
plugin: "@genkit-ai/googleai",
|
|
164
|
-
package: `@genkit-ai/googleai@${
|
|
168
|
+
package: `@genkit-ai/googleai@${genkitInfo.googleAiVersion}`,
|
|
165
169
|
},
|
|
166
170
|
none: { label: "None", plugin: undefined, package: undefined },
|
|
167
171
|
};
|
|
@@ -208,7 +212,7 @@ function getBasePackages(genkitVersion) {
|
|
|
208
212
|
const externalDevPackages = ["typescript", "tsx"];
|
|
209
213
|
async function genkitSetup(options, genkitInfo, projectDir) {
|
|
210
214
|
var _a, _b;
|
|
211
|
-
const modelOptions = getModelOptions(genkitInfo
|
|
215
|
+
const modelOptions = getModelOptions(genkitInfo);
|
|
212
216
|
const supportedModels = Object.keys(modelOptions);
|
|
213
217
|
const answer = await inquirer.prompt([
|
|
214
218
|
{
|