firebase-tools-with-isolate 15.26.0 → 15.28.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/appcheck/api.js +19 -0
- package/lib/appcheck/providers.js +240 -0
- package/lib/commands/appcheck-apps-list.js +78 -0
- package/lib/commands/appcheck-debugtokens-create.js +2 -2
- package/lib/commands/appcheck-debugtokens-delete.js +2 -2
- package/lib/commands/appcheck-debugtokens-list.js +2 -2
- package/lib/commands/appcheck-prompts.js +55 -0
- package/lib/commands/appcheck-providers-get.js +73 -0
- package/lib/commands/appcheck-providers-list.js +67 -0
- package/lib/commands/appcheck-providers-set.js +96 -0
- package/lib/commands/ext-export.js +140 -3
- package/lib/commands/ext-uninstall.js +35 -1
- package/lib/commands/functions-delete.js +19 -5
- package/lib/commands/functions-kits-install.js +417 -0
- package/lib/commands/functions-kits-list.js +27 -0
- package/lib/commands/index.js +11 -0
- package/lib/crashlytics/filters.js +12 -4
- package/lib/crashlytics/reports.js +2 -0
- package/lib/crashlytics/types.js +8 -1
- package/lib/dataconnect/client.js +11 -0
- package/lib/dataconnect/schemaMigration.js +16 -5
- package/lib/deploy/extensions/secrets.js +18 -0
- package/lib/deploy/functions/backend.js +11 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/functionsDeployHelper.js +39 -15
- package/lib/deploy/functions/params.js +5 -1
- package/lib/deploy/functions/prepare.js +69 -22
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/lifecycle.js +11 -0
- package/lib/deploy/functions/release/planner.js +5 -2
- package/lib/deploy/functions/runtimes/dart/features.js +51 -0
- package/lib/deploy/functions/runtimes/dart/index.js +60 -16
- package/lib/emulator/controller.js +1 -0
- package/lib/emulator/downloadableEmulatorInfo.json +31 -31
- package/lib/emulator/functionsEmulator.js +7 -2
- package/lib/experiments.js +17 -5
- package/lib/extensions/export.js +73 -0
- package/lib/extensions/replacementRegistry.js +30 -0
- package/lib/extensions/replacements.json +464 -0
- package/lib/fetchMOTD.js +3 -0
- package/lib/functions/env.js +31 -7
- package/lib/functions/iac/export.js +16 -1
- package/lib/functions/kits/config.js +8 -0
- package/lib/functions/projectConfig.js +19 -11
- package/lib/functions/python.js +1 -1
- package/lib/gcp/runv2.js +1 -0
- package/lib/gcp/secretManager.js +3 -3
- package/lib/init/features/functions/dart.js +1 -1
- package/lib/mcp/onemcp/index.js +2 -1
- package/lib/mcp/onemcp/onemcp_server.js +38 -11
- package/lib/mcp/prompts/crashlytics/connect.js +1 -1
- package/lib/mcp/resources/guides/crashlytics_issues.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +32 -11
- package/lib/mcp/tool.js +5 -0
- package/lib/mcp/tools/core/deploy.js +2 -0
- package/lib/mcp/tools/core/login.js +59 -4
- package/lib/mcp/tools/crashlytics/notes.js +3 -3
- package/lib/mcp/tools/crashlytics/reports.js +2 -0
- package/lib/mcp/tools/dataconnect/compile.js +23 -2
- package/lib/mcp/tools/dataconnect/list_services.js +3 -4
- package/lib/mcp/util/crashlytics/availability.js +54 -1
- package/lib/serve/functions.js +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/unzip.js +12 -2
- package/package.json +2 -1
- package/schema/firebase-config.json +3 -3
- package/templates/init/functions/dart/_gitignore +1 -0
- package/templates/init/functions/typescript/index-kit-migration.ts +49 -0
- package/templates/init/functions/typescript/index-kit.ts +35 -0
- package/templates/init/functions/typescript/index.ts +3 -3
- package/templates/init/functions/typescript/package-ongraphrequest.lint.json +3 -3
- package/templates/init/functions/typescript/package.lint.json +3 -3
- package/templates/init/functions/typescript/tsconfig.dev.json +4 -0
- package/lib/appcheck/prompts.js +0 -41
|
@@ -246,10 +246,20 @@ async function loadExistingBackend(ctx) {
|
|
|
246
246
|
}
|
|
247
247
|
async function loadCloudRunServices(ctx, existingBackend, unreachableRegions, onlyMissing) {
|
|
248
248
|
try {
|
|
249
|
+
const runServiceIdsByRegion = {};
|
|
250
|
+
for (const [region, endpoints] of Object.entries(existingBackend.endpoints)) {
|
|
251
|
+
const ids = Object.values(endpoints)
|
|
252
|
+
.map((e) => e.runServiceId)
|
|
253
|
+
.filter((id) => !!id);
|
|
254
|
+
runServiceIdsByRegion[region] = new Set(ids);
|
|
255
|
+
}
|
|
249
256
|
const runServices = await run.listServices(ctx.projectId);
|
|
250
257
|
for (const service of runServices) {
|
|
251
258
|
const endpoint = run.endpointFromService(service);
|
|
252
|
-
|
|
259
|
+
const hasMatchingId = !!existingBackend.endpoints[endpoint.region]?.[endpoint.id];
|
|
260
|
+
const hasMatchingServiceId = !!(endpoint.runServiceId && runServiceIdsByRegion[endpoint.region]?.has(endpoint.runServiceId));
|
|
261
|
+
const alreadyLoaded = hasMatchingId || hasMatchingServiceId;
|
|
262
|
+
if (!onlyMissing || !alreadyLoaded) {
|
|
253
263
|
existingBackend.endpoints[endpoint.region] =
|
|
254
264
|
existingBackend.endpoints[endpoint.region] || {};
|
|
255
265
|
existingBackend.endpoints[endpoint.region][endpoint.id] = endpoint;
|
|
@@ -82,7 +82,7 @@ exports.AllIngressSettings = [
|
|
|
82
82
|
"ALLOW_INTERNAL_AND_GCLB",
|
|
83
83
|
];
|
|
84
84
|
async function resolveBackend(opts) {
|
|
85
|
-
const { paramValues: paramValues, secretRefs: secretRefs } = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.force, opts.isEmulator);
|
|
85
|
+
const { paramValues: paramValues, secretRefs: secretRefs } = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.codebase, opts.nonInteractive, opts.force, opts.isEmulator);
|
|
86
86
|
return { backend: toBackend(opts.build, paramValues), envs: paramValues, secretRefs: secretRefs };
|
|
87
87
|
}
|
|
88
88
|
function envWithTypes(definedParams, rawEnvs) {
|
|
@@ -11,6 +11,8 @@ exports.targetCodebases = targetCodebases;
|
|
|
11
11
|
exports.groupEndpointsByCodebase = groupEndpointsByCodebase;
|
|
12
12
|
exports.isCodebaseFiltered = isCodebaseFiltered;
|
|
13
13
|
exports.isEndpointFiltered = isEndpointFiltered;
|
|
14
|
+
exports.parseDeleteFilters = parseDeleteFilters;
|
|
15
|
+
exports.detectCodebaseAndIdCollisions = detectCodebaseAndIdCollisions;
|
|
14
16
|
const backend = require("./backend");
|
|
15
17
|
const projectConfig_1 = require("../../functions/projectConfig");
|
|
16
18
|
const functional_1 = require("../../functional");
|
|
@@ -21,31 +23,24 @@ function endpointMatchesAnyFilter(endpoint, filters) {
|
|
|
21
23
|
return filters.some((filter) => endpointMatchesFilter(endpoint, filter));
|
|
22
24
|
}
|
|
23
25
|
function endpointMatchesFilter(endpoint, filter) {
|
|
24
|
-
if (
|
|
25
|
-
|
|
26
|
+
if (filter.codebase) {
|
|
27
|
+
const endpointCodebase = endpoint.codebase || projectConfig_1.DEFAULT_CODEBASE;
|
|
28
|
+
if (endpointCodebase !== filter.codebase) {
|
|
26
29
|
return false;
|
|
27
30
|
}
|
|
28
31
|
}
|
|
29
|
-
if (!filter.idChunks) {
|
|
32
|
+
if (!filter.idChunks || filter.idChunks.length === 0) {
|
|
30
33
|
return true;
|
|
31
34
|
}
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
return false;
|
|
35
|
-
}
|
|
36
|
-
for (let i = 0; i < filter.idChunks.length; i += 1) {
|
|
37
|
-
if (idChunks[i] !== filter.idChunks[i]) {
|
|
38
|
-
return false;
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
return true;
|
|
35
|
+
const filterPrefix = filter.idChunks.join("-");
|
|
36
|
+
return endpoint.id === filterPrefix || endpoint.id.startsWith(`${filterPrefix}-`);
|
|
42
37
|
}
|
|
43
|
-
function getCodebasesFromConfig(config) {
|
|
38
|
+
function getCodebasesFromConfig(config = []) {
|
|
44
39
|
return [
|
|
45
40
|
...new Set(config.flatMap((c) => ((0, projectConfig_1.isKitConfig)(c) ? Object.keys(c.instances) : [c.codebase]))),
|
|
46
41
|
];
|
|
47
42
|
}
|
|
48
|
-
function parseFunctionSelector(selector, config) {
|
|
43
|
+
function parseFunctionSelector(selector, config = []) {
|
|
49
44
|
const fragments = selector.split(":");
|
|
50
45
|
const target = fragments[0];
|
|
51
46
|
const codebaseNames = getCodebasesFromConfig(config);
|
|
@@ -145,3 +140,32 @@ function isCodebaseFiltered(codebase, filters) {
|
|
|
145
140
|
function isEndpointFiltered(endpoint, filters) {
|
|
146
141
|
return filters.some((filter) => endpointMatchesFilter(endpoint, filter));
|
|
147
142
|
}
|
|
143
|
+
function parseDeleteFilters(filters, activeCodebases) {
|
|
144
|
+
const liveCodebasesConfig = activeCodebases.map((codebase) => ({ source: "", codebase }));
|
|
145
|
+
return filters.flatMap((f) => {
|
|
146
|
+
const parsed = parseFunctionSelector(f, liveCodebasesConfig);
|
|
147
|
+
return parsed.map((filter) => !f.includes(":") && filter.codebase === projectConfig_1.DEFAULT_CODEBASE && filter.idChunks
|
|
148
|
+
? { idChunks: filter.idChunks }
|
|
149
|
+
: filter);
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function detectCodebaseAndIdCollisions(filters, activeCodebases, allEndpoints, defaultCodebase = projectConfig_1.DEFAULT_CODEBASE) {
|
|
153
|
+
const collisions = [];
|
|
154
|
+
for (const f of filters) {
|
|
155
|
+
if (f.includes(":") || !activeCodebases.includes(f)) {
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
const matchingEndpoints = allEndpoints.filter((ep) => ep.id === f || ep.id.startsWith(`${f}-`));
|
|
159
|
+
if (matchingEndpoints.length > 0) {
|
|
160
|
+
const ep = matchingEndpoints[0];
|
|
161
|
+
const prefix = ep.codebase || defaultCodebase;
|
|
162
|
+
collisions.push({
|
|
163
|
+
filter: f,
|
|
164
|
+
codebase: prefix,
|
|
165
|
+
functionLabel: getFunctionLabel(ep),
|
|
166
|
+
workaroundCommand: `firebase functions:delete ${prefix}:${f}`,
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
return collisions;
|
|
171
|
+
}
|
|
@@ -10,6 +10,7 @@ exports.isSelectInput = isSelectInput;
|
|
|
10
10
|
exports.isResourceInput = isResourceInput;
|
|
11
11
|
exports.isMultiSelectInput = isMultiSelectInput;
|
|
12
12
|
exports.resolveParams = resolveParams;
|
|
13
|
+
const clc = require("colorette");
|
|
13
14
|
const logger_1 = require("../../logger");
|
|
14
15
|
const error_1 = require("../../error");
|
|
15
16
|
const prompt_1 = require("../../prompt");
|
|
@@ -162,7 +163,7 @@ function canSatisfyParam(param, value) {
|
|
|
162
163
|
}
|
|
163
164
|
(0, functional_1.assertExhaustive)(param);
|
|
164
165
|
}
|
|
165
|
-
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, force, isEmulator = false) {
|
|
166
|
+
async function resolveParams(params, firebaseConfig, userEnvs, codebase, nonInteractive, force, isEmulator = false) {
|
|
166
167
|
const paramValues = populateDefaultParams(firebaseConfig);
|
|
167
168
|
const secretRefs = {};
|
|
168
169
|
const [resolved, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
@@ -183,6 +184,9 @@ async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, f
|
|
|
183
184
|
"To continue, either run `firebase deploy` with an interactive terminal, or add values to a dotenv file. " +
|
|
184
185
|
"For information regarding how to use dotenv files, see https://firebase.google.com/docs/functions/config-env");
|
|
185
186
|
}
|
|
187
|
+
if (needPrompt.length > 0) {
|
|
188
|
+
logger_1.logger.info(`Prompting for parameters for codebase ${clc.bold(codebase)}:`);
|
|
189
|
+
}
|
|
186
190
|
for (const param of needPrompt) {
|
|
187
191
|
const promptable = param;
|
|
188
192
|
let paramDefault = promptable.default;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVENTARC_SOURCE_ENV = void 0;
|
|
3
|
+
exports.DECLARATIVE_SECURITY_ETAG_LABEL = exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
4
|
exports.discoverSecurityDetails = discoverSecurityDetails;
|
|
5
5
|
exports.prepare = prepare;
|
|
6
6
|
exports.resolveDefaultRegionsForBuild = resolveDefaultRegionsForBuild;
|
|
@@ -10,11 +10,13 @@ exports.inferBlockingDetails = inferBlockingDetails;
|
|
|
10
10
|
exports.resolveCpuAndConcurrency = resolveCpuAndConcurrency;
|
|
11
11
|
exports.resolveDefaultTimeout = resolveDefaultTimeout;
|
|
12
12
|
exports.loadCodebases = loadCodebases;
|
|
13
|
+
exports.getExecutablePaths = getExecutablePaths;
|
|
14
|
+
exports.stripStaleDartBuildIgnore = stripStaleDartBuildIgnore;
|
|
13
15
|
exports.warnIfNewGenkitFunctionIsMissingSecrets = warnIfNewGenkitFunctionIsMissingSecrets;
|
|
14
16
|
exports.ensureAllRequiredAPIsEnabled = ensureAllRequiredAPIsEnabled;
|
|
15
17
|
exports.partitionUserEnvs = partitionUserEnvs;
|
|
18
|
+
exports.checkKitForGen1 = checkKitForGen1;
|
|
16
19
|
const clc = require("colorette");
|
|
17
|
-
const proto = require("../../gcp/proto");
|
|
18
20
|
const backend = require("./backend");
|
|
19
21
|
const build = require("./build");
|
|
20
22
|
const experiments = require("../../experiments");
|
|
@@ -30,6 +32,8 @@ const api_1 = require("../../api");
|
|
|
30
32
|
const functionsDeployHelper_1 = require("./functionsDeployHelper");
|
|
31
33
|
const utils_1 = require("../../utils");
|
|
32
34
|
const triggerSupport_1 = require("./runtimes/dart/triggerSupport");
|
|
35
|
+
const dart_1 = require("./runtimes/dart");
|
|
36
|
+
const features_1 = require("./runtimes/dart/features");
|
|
33
37
|
const prepareFunctionsUpload_1 = require("./prepareFunctionsUpload");
|
|
34
38
|
const prompts_1 = require("./prompts");
|
|
35
39
|
const projectUtils_1 = require("../../projectUtils");
|
|
@@ -48,17 +52,11 @@ const prompt = require("../../prompt");
|
|
|
48
52
|
const iam = require("../../gcp/iam");
|
|
49
53
|
const resourcemanager = require("../../gcp/resourceManager");
|
|
50
54
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
55
|
+
exports.DECLARATIVE_SECURITY_ETAG_LABEL = "firebase-declarative-security-etag";
|
|
51
56
|
async function discoverSecurityDetails(codebase, want, have, projectId, filters) {
|
|
52
57
|
const requiredRoles = want.requiredRoles;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
let haveRolesEtag;
|
|
56
|
-
if (firstHave) {
|
|
57
|
-
haveRolesEtag = firstHave.labels?.["firebase-declarative-security-etag"];
|
|
58
|
-
existingManagedSA = firstHave.serviceAccount?.startsWith("firebase-fn-")
|
|
59
|
-
? firstHave.serviceAccount
|
|
60
|
-
: undefined;
|
|
61
|
-
}
|
|
58
|
+
const existingManagedSA = backend.findEndpoint(have, (e) => typeof e.serviceAccount === "string" && e.serviceAccount.startsWith("firebase-fn-"))?.serviceAccount ?? undefined;
|
|
59
|
+
const haveRolesEtag = backend.findEndpoint(have, (e) => !!e.labels?.[exports.DECLARATIVE_SECURITY_ETAG_LABEL])?.labels?.[exports.DECLARATIVE_SECURITY_ETAG_LABEL];
|
|
62
60
|
const isPartiallyFiltered = !!(filters &&
|
|
63
61
|
filters.some((f) => (!f.codebase || f.codebase === codebase) && f.idChunks && f.idChunks.length > 0));
|
|
64
62
|
const isEnrolling = !!requiredRoles && !existingManagedSA;
|
|
@@ -67,6 +65,15 @@ async function discoverSecurityDetails(codebase, want, have, projectId, filters)
|
|
|
67
65
|
throw new error_1.FirebaseError("To ensure a whole codebase is migrated cleanly, you may not deploy only part of a " +
|
|
68
66
|
"codebase when opting into or out of declarative security (starting or no longer using `requireRoles`)");
|
|
69
67
|
}
|
|
68
|
+
if (!backend.someEndpoint(want, () => true)) {
|
|
69
|
+
if (existingManagedSA) {
|
|
70
|
+
return {
|
|
71
|
+
existingManagedSA,
|
|
72
|
+
...(haveRolesEtag ? { haveRolesEtag } : {}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return {};
|
|
76
|
+
}
|
|
70
77
|
if (!requiredRoles && (!existingManagedSA || !haveRolesEtag)) {
|
|
71
78
|
return {};
|
|
72
79
|
}
|
|
@@ -98,7 +105,7 @@ async function discoverSecurityDetails(codebase, want, have, projectId, filters)
|
|
|
98
105
|
for (const endpoint of backend.allEndpoints(want)) {
|
|
99
106
|
endpoint.serviceAccount = managedSA;
|
|
100
107
|
endpoint.labels = endpoint.labels || {};
|
|
101
|
-
endpoint.labels[
|
|
108
|
+
endpoint.labels[exports.DECLARATIVE_SECURITY_ETAG_LABEL] = newEtag;
|
|
102
109
|
}
|
|
103
110
|
if (haveRolesEtag && haveRolesEtag === newEtag) {
|
|
104
111
|
return {
|
|
@@ -184,18 +191,18 @@ async function prepare(context, options, payload) {
|
|
|
184
191
|
const wantBackends = {};
|
|
185
192
|
for (const [codebase, wantBuild] of Object.entries(wantBuilds)) {
|
|
186
193
|
const config = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
187
|
-
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
194
|
+
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId, (0, projectConfig_1.isKitConfig)(config) ? codebase : undefined);
|
|
188
195
|
const localCfg = (0, projectConfig_1.requireLocal)(config, "Remote sources are not supported.");
|
|
196
|
+
checkKitForGen1(localCfg, wantBuild);
|
|
189
197
|
const userEnvOpt = {
|
|
190
198
|
functionsSource: options.config.path(localCfg.source),
|
|
191
199
|
projectId: projectId,
|
|
192
200
|
projectAlias: options.projectAlias,
|
|
201
|
+
projectDir: options.config.projectDir,
|
|
193
202
|
};
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
else {
|
|
198
|
-
proto.convertIfPresent(userEnvOpt, localCfg, "configDir", (cd) => options.config.path(cd));
|
|
203
|
+
const configDir = (0, projectConfig_1.resolveConfigDir)(localCfg, codebase);
|
|
204
|
+
if (configDir) {
|
|
205
|
+
userEnvOpt.configDir = options.config.path(configDir);
|
|
199
206
|
}
|
|
200
207
|
const rawUserEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
201
208
|
const { userEnvs: userEnvs, secretRefs: secretRefs } = partitionUserEnvs(rawUserEnvs);
|
|
@@ -210,6 +217,7 @@ async function prepare(context, options, payload) {
|
|
|
210
217
|
build: wantBuild,
|
|
211
218
|
firebaseConfig,
|
|
212
219
|
userEnvs,
|
|
220
|
+
codebase,
|
|
213
221
|
nonInteractive: options.nonInteractive,
|
|
214
222
|
force: options.force,
|
|
215
223
|
isEmulator: false,
|
|
@@ -296,9 +304,9 @@ async function prepare(context, options, payload) {
|
|
|
296
304
|
const exportType = backend.someEndpoint(wantBackend, (e) => e.platform === "run")
|
|
297
305
|
? "tar.gz"
|
|
298
306
|
: "zip";
|
|
299
|
-
const
|
|
300
|
-
const
|
|
301
|
-
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(options.config.projectDir, sourceDir,
|
|
307
|
+
const executablePaths = await getExecutablePaths(wantBuilds[codebase].runtime, sourceDir);
|
|
308
|
+
const uploadCfg = await stripStaleDartBuildIgnore(wantBuilds[codebase].runtime, sourceDir, localCfg);
|
|
309
|
+
const packagedSource = await (0, prepareFunctionsUpload_1.prepareFunctionsUpload)(options.config.projectDir, sourceDir, uploadCfg, [...schPathSet], undefined, { exportType, executablePaths });
|
|
302
310
|
source.functionsSourceV2 = packagedSource?.pathToSource;
|
|
303
311
|
source.functionsSourceV2Hash = packagedSource?.hash;
|
|
304
312
|
}
|
|
@@ -504,12 +512,24 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
504
512
|
await runtimeDelegate.validate();
|
|
505
513
|
logger_1.logger.debug(`Building ${runtimeDelegate.language} source`);
|
|
506
514
|
await runtimeDelegate.build();
|
|
507
|
-
const
|
|
515
|
+
const userEnvOpt = {
|
|
516
|
+
functionsSource: sourceDir,
|
|
517
|
+
projectId: projectId,
|
|
518
|
+
projectAlias: options.projectAlias,
|
|
519
|
+
projectDir: options.config.projectDir,
|
|
520
|
+
};
|
|
521
|
+
const configDir = (0, projectConfig_1.resolveConfigDir)(codebaseConfig, codebase);
|
|
522
|
+
if (configDir) {
|
|
523
|
+
userEnvOpt.configDir = options.config.path(configDir);
|
|
524
|
+
}
|
|
525
|
+
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
526
|
+
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId, (0, projectConfig_1.isKitConfig)(codebaseConfig) ? codebase : undefined);
|
|
508
527
|
(0, utils_1.logLabeledBullet)("functions", `Loading and analyzing source code for codebase ${codebase} to determine what to deploy`);
|
|
509
528
|
const codebaseRuntimeConfig = (0, projectConfig_1.shouldUseRuntimeConfig)(codebaseConfig)
|
|
510
529
|
? runtimeConfig
|
|
511
530
|
: { firebase: firebaseConfig };
|
|
512
531
|
const discoveredBuild = await runtimeDelegate.discoverBuild(codebaseRuntimeConfig, {
|
|
532
|
+
...userEnvs,
|
|
513
533
|
...firebaseEnvs,
|
|
514
534
|
GOOGLE_CLOUD_QUOTA_PROJECT: projectId,
|
|
515
535
|
});
|
|
@@ -535,6 +555,27 @@ function warnIfDartBackendHasUnsupportedTriggers(want) {
|
|
|
535
555
|
"See https://github.com/firebase/firebase-functions-dart for current trigger support.");
|
|
536
556
|
}
|
|
537
557
|
}
|
|
558
|
+
async function getExecutablePaths(runtime, sourceDir) {
|
|
559
|
+
if (!supported.runtimeIsLanguage(runtime, "dart")) {
|
|
560
|
+
return [];
|
|
561
|
+
}
|
|
562
|
+
const features = await features_1.DartVersionFeatures.detect(sourceDir);
|
|
563
|
+
return features.isNativeAssetsAvailable ? [dart_1.DART_BUNDLE_EXECUTABLE_PATH] : [dart_1.DART_COMPILE_EXE_PATH];
|
|
564
|
+
}
|
|
565
|
+
async function stripStaleDartBuildIgnore(runtime, sourceDir, localCfg) {
|
|
566
|
+
if (!supported.runtimeIsLanguage(runtime, "dart") ||
|
|
567
|
+
!localCfg.ignore?.some((i) => i === "build" || i === "build/")) {
|
|
568
|
+
return localCfg;
|
|
569
|
+
}
|
|
570
|
+
const features = await features_1.DartVersionFeatures.detect(sourceDir);
|
|
571
|
+
if (!features.isNativeAssetsAvailable) {
|
|
572
|
+
return localCfg;
|
|
573
|
+
}
|
|
574
|
+
return {
|
|
575
|
+
...localCfg,
|
|
576
|
+
ignore: localCfg.ignore.filter((i) => i !== "build" && i !== "build/"),
|
|
577
|
+
};
|
|
578
|
+
}
|
|
538
579
|
async function warnIfNewGenkitFunctionIsMissingSecrets(have, want, options) {
|
|
539
580
|
if (options.force) {
|
|
540
581
|
return;
|
|
@@ -625,3 +666,9 @@ function partitionUserEnvs(allEnvs) {
|
|
|
625
666
|
}, [{}, {}]);
|
|
626
667
|
return { userEnvs: userEnvs, secretRefs: secretRefs };
|
|
627
668
|
}
|
|
669
|
+
function checkKitForGen1(localCfg, wantBuild) {
|
|
670
|
+
if ((0, projectConfig_1.isKitConfig)(localCfg) &&
|
|
671
|
+
Object.values(wantBuild.endpoints).some((e) => e.platform === "gcfv1")) {
|
|
672
|
+
throw new error_1.FirebaseError(`Function kit "${localCfg.kit}" contains gen1 functions, which are not supported in kits. Please remove this kit or upgrade these functions to gen2.`);
|
|
673
|
+
}
|
|
674
|
+
}
|
|
@@ -265,7 +265,7 @@ async function promptForLifecycleEvent(codebase, wantBackend, options) {
|
|
|
265
265
|
}
|
|
266
266
|
choices.push({ name: "skip (default)", value: "skip" });
|
|
267
267
|
const selection = await (0, prompt_1.select)({
|
|
268
|
-
message: `
|
|
268
|
+
message: `Cannot determine if this is a first deploy or a redeploy for codebase "${codebase}" because the last deployment was partial (either due to a failure or a filtered deploy).`,
|
|
269
269
|
choices,
|
|
270
270
|
default: "skip",
|
|
271
271
|
nonInteractive: options?.nonInteractive,
|
|
@@ -42,6 +42,17 @@ async function executeLifecycleHooks(wantBackend, haveBackend, plan, codebase, o
|
|
|
42
42
|
if (!hasLifecycleHooks(wantBackend)) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
+
const codebasePlan = plan && codebase ? plan[codebase] : undefined;
|
|
46
|
+
if (codebasePlan && codebase) {
|
|
47
|
+
const allWantEndpoints = backend.allEndpoints(wantBackend);
|
|
48
|
+
const isFiltered = allWantEndpoints.some(backend.missingEndpoint(codebasePlan.plannedBackend));
|
|
49
|
+
if (isFiltered) {
|
|
50
|
+
const event = determineLifecycleEvent(haveBackend);
|
|
51
|
+
(0, utils_1.logLabeledWarning)("functions", `Lifecycle hook "${event}" for codebase "${codebase}" was configured but not executed because this was a partial deployment (filtered).`);
|
|
52
|
+
(0, utils_1.logLabeledBullet)("functions", `You can run the lifecycle hook in isolation by running: firebase functions:lifecycle:run ${event} ${codebase}`);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
45
56
|
let event;
|
|
46
57
|
if (isRecoveryDeployment(wantBackend, haveBackend)) {
|
|
47
58
|
event = await prompts.promptForLifecycleEvent(codebase ?? "default", wantBackend, options);
|
|
@@ -86,7 +86,8 @@ async function createDeploymentPlan(args) {
|
|
|
86
86
|
const isFiltered = !!(filters &&
|
|
87
87
|
filters.some((f) => f.idChunks && f.idChunks.length > 0) &&
|
|
88
88
|
!deleteAll);
|
|
89
|
-
|
|
89
|
+
const hasWantEndpoints = backend.someEndpoint(wantBackend, () => true);
|
|
90
|
+
if (requiredRoles && hasWantEndpoints) {
|
|
90
91
|
rolesToAdd = requiredRoles.filter((r) => !roles.includes(r));
|
|
91
92
|
rolesToRemove = roles.filter((r) => !requiredRoles.includes(r));
|
|
92
93
|
if (!existingManagedSA && managedSA) {
|
|
@@ -118,7 +119,7 @@ async function createDeploymentPlan(args) {
|
|
|
118
119
|
"default to 80 concurrent executions, but existing functions keep the " +
|
|
119
120
|
"old default of 1. You can change this with the 'concurrency' option.");
|
|
120
121
|
}
|
|
121
|
-
if (requiredRoles) {
|
|
122
|
+
if (requiredRoles && hasWantEndpoints) {
|
|
122
123
|
if (!managedSA) {
|
|
123
124
|
throw new error_1.FirebaseError("managedServiceAccount is required when requiredRoles is defined.", {
|
|
124
125
|
exit: 1,
|
|
@@ -126,6 +127,7 @@ async function createDeploymentPlan(args) {
|
|
|
126
127
|
}
|
|
127
128
|
return {
|
|
128
129
|
regionalChangesets,
|
|
130
|
+
plannedBackend: wantBackend,
|
|
129
131
|
rolesToAdd,
|
|
130
132
|
rolesToRemove,
|
|
131
133
|
serviceAccountToCreate,
|
|
@@ -135,6 +137,7 @@ async function createDeploymentPlan(args) {
|
|
|
135
137
|
else {
|
|
136
138
|
return {
|
|
137
139
|
regionalChangesets,
|
|
140
|
+
plannedBackend: wantBackend,
|
|
138
141
|
serviceAccountToDelete,
|
|
139
142
|
};
|
|
140
143
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DartVersionFeatures = void 0;
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const MIN_DART_SDK_VERSION = "3.9.0";
|
|
7
|
+
const MIN_DART_SDK_VERSION_NATIVE_ASSETS = "3.13.0";
|
|
8
|
+
class DartVersionFeatures {
|
|
9
|
+
constructor(languageVersion) {
|
|
10
|
+
this.languageVersion = languageVersion;
|
|
11
|
+
}
|
|
12
|
+
static async detect(sourceDir) {
|
|
13
|
+
return new DartVersionFeatures(await readRootLanguageVersion(sourceDir));
|
|
14
|
+
}
|
|
15
|
+
get isNativeAssetsAvailable() {
|
|
16
|
+
return this.atLeast(3, 13);
|
|
17
|
+
}
|
|
18
|
+
get minDartSdkVersion() {
|
|
19
|
+
return this.isNativeAssetsAvailable ? MIN_DART_SDK_VERSION_NATIVE_ASSETS : MIN_DART_SDK_VERSION;
|
|
20
|
+
}
|
|
21
|
+
atLeast(major, minor) {
|
|
22
|
+
if (!this.languageVersion) {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
const [actualMajor, actualMinor] = this.languageVersion;
|
|
26
|
+
return actualMajor > major || (actualMajor === major && actualMinor >= minor);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
exports.DartVersionFeatures = DartVersionFeatures;
|
|
30
|
+
async function readRootLanguageVersion(sourceDir) {
|
|
31
|
+
const packageConfigPath = path.join(sourceDir, ".dart_tool", "package_config.json");
|
|
32
|
+
let raw;
|
|
33
|
+
try {
|
|
34
|
+
raw = await fs.promises.readFile(packageConfigPath, "utf8");
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
try {
|
|
40
|
+
const parsed = JSON.parse(raw);
|
|
41
|
+
const root = parsed?.packages?.find((p) => p.rootUri === "../");
|
|
42
|
+
const match = root?.languageVersion ? /^(\d+)\.(\d+)$/.exec(root.languageVersion) : null;
|
|
43
|
+
if (!match) {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
return [Number(match[1]), Number(match[2])];
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Delegate = exports.DART_ENTRY_POINT = void 0;
|
|
3
|
+
exports.Delegate = exports.DART_BUNDLE_EXECUTABLE_PATH = exports.DART_COMPILE_EXE_PATH = exports.DART_ENTRY_POINT = void 0;
|
|
4
4
|
exports.tryCreateDelegate = tryCreateDelegate;
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
const path = require("path");
|
|
@@ -14,6 +14,7 @@ const utils_1 = require("../../../../utils");
|
|
|
14
14
|
const registry_1 = require("../../../../emulator/registry");
|
|
15
15
|
const types_1 = require("../../../../emulator/types");
|
|
16
16
|
const experiments = require("../../../../experiments");
|
|
17
|
+
const features_1 = require("./features");
|
|
17
18
|
async function tryCreateDelegate(context) {
|
|
18
19
|
const pubspecYamlPath = path.join(context.sourceDir, "pubspec.yaml");
|
|
19
20
|
if (!(await (0, util_1.promisify)(fs.exists)(pubspecYamlPath))) {
|
|
@@ -30,8 +31,9 @@ async function tryCreateDelegate(context) {
|
|
|
30
31
|
}
|
|
31
32
|
return Promise.resolve(new Delegate(context.projectId, context.sourceDir, runtime));
|
|
32
33
|
}
|
|
33
|
-
const MIN_DART_SDK_VERSION = "3.9.0";
|
|
34
34
|
exports.DART_ENTRY_POINT = "bin/server.dart";
|
|
35
|
+
exports.DART_COMPILE_EXE_PATH = "bin/server";
|
|
36
|
+
exports.DART_BUNDLE_EXECUTABLE_PATH = "build/cli/linux_x64/bundle/bin/server";
|
|
35
37
|
class Delegate {
|
|
36
38
|
constructor(projectId, sourceDir, runtime) {
|
|
37
39
|
this.projectId = projectId;
|
|
@@ -51,18 +53,6 @@ class Delegate {
|
|
|
51
53
|
throw new error_1.FirebaseError(`Could not find a Dart SDK. Make sure the '${this.bin}' command is available on your PATH.`);
|
|
52
54
|
}
|
|
53
55
|
const versionOutput = (result.stdout || result.stderr || "").toString();
|
|
54
|
-
const match = /Dart SDK version:\s*(\d+\.\d+\.\d+)/.exec(versionOutput);
|
|
55
|
-
if (match) {
|
|
56
|
-
const installedVersion = match[1];
|
|
57
|
-
if (installedVersion.localeCompare(MIN_DART_SDK_VERSION, undefined, { numeric: true }) < 0) {
|
|
58
|
-
throw new error_1.FirebaseError(`Dart SDK version ${installedVersion} is not supported. ` +
|
|
59
|
-
`Firebase Functions for Dart requires Dart ${MIN_DART_SDK_VERSION} or later. ` +
|
|
60
|
-
`Please upgrade your Dart SDK.`);
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
logger_1.logger.debug(`Could not parse Dart SDK version from: ${versionOutput}`);
|
|
65
|
-
}
|
|
66
56
|
const pubspecYamlPath = path.join(this.sourceDir, "pubspec.yaml");
|
|
67
57
|
try {
|
|
68
58
|
await fs.promises.access(pubspecYamlPath, fs.constants.R_OK);
|
|
@@ -107,6 +97,20 @@ class Delegate {
|
|
|
107
97
|
pubGetProcess.on("error", reject);
|
|
108
98
|
});
|
|
109
99
|
}
|
|
100
|
+
const match = /Dart SDK version:\s*(\d+\.\d+\.\d+)/.exec(versionOutput);
|
|
101
|
+
if (match) {
|
|
102
|
+
const installedVersion = match[1];
|
|
103
|
+
const features = await features_1.DartVersionFeatures.detect(this.sourceDir);
|
|
104
|
+
const minVersion = features.minDartSdkVersion;
|
|
105
|
+
if (installedVersion.localeCompare(minVersion, undefined, { numeric: true }) < 0) {
|
|
106
|
+
throw new error_1.FirebaseError(`Dart SDK version ${installedVersion} is not supported. ` +
|
|
107
|
+
`Firebase Functions for Dart requires Dart ${minVersion} or later. ` +
|
|
108
|
+
`Please upgrade your Dart SDK.`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
logger_1.logger.debug(`Could not parse Dart SDK version from: ${versionOutput}`);
|
|
113
|
+
}
|
|
110
114
|
}
|
|
111
115
|
async build() {
|
|
112
116
|
if (Delegate.watchModeActive) {
|
|
@@ -139,6 +143,15 @@ class Delegate {
|
|
|
139
143
|
logger_1.logger.debug("Skipping Dart compilation in emulator mode.");
|
|
140
144
|
return;
|
|
141
145
|
}
|
|
146
|
+
const features = await features_1.DartVersionFeatures.detect(this.sourceDir);
|
|
147
|
+
if (features.isNativeAssetsAvailable) {
|
|
148
|
+
await this.buildCli();
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
await this.compileExe();
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
async compileExe() {
|
|
142
155
|
const binDir = path.join(this.sourceDir, "bin");
|
|
143
156
|
await fs.promises.mkdir(binDir, { recursive: true });
|
|
144
157
|
(0, utils_1.logLabeledBullet)("functions", "compiling Dart to linux-x64 executable...");
|
|
@@ -147,7 +160,7 @@ class Delegate {
|
|
|
147
160
|
"exe",
|
|
148
161
|
this.entryPoint,
|
|
149
162
|
"-o",
|
|
150
|
-
|
|
163
|
+
exports.DART_COMPILE_EXE_PATH,
|
|
151
164
|
"--target-os=linux",
|
|
152
165
|
"--target-arch=x64",
|
|
153
166
|
], {
|
|
@@ -168,13 +181,43 @@ class Delegate {
|
|
|
168
181
|
else {
|
|
169
182
|
reject(new error_1.FirebaseError(`Dart compilation failed with exit code ${code}. ` +
|
|
170
183
|
`Make sure your Dart project compiles successfully with: ` +
|
|
171
|
-
`dart compile exe ${this.entryPoint} --target-os=linux --target-arch=x64`
|
|
184
|
+
`dart compile exe ${this.entryPoint} --target-os=linux --target-arch=x64\n` +
|
|
185
|
+
`If your dependencies require native build hooks (e.g. sqlite3), bump the ` +
|
|
186
|
+
`SDK constraint in your pubspec.yaml's "environment" section to "^3.13.0" or ` +
|
|
187
|
+
`later to use dart build cli instead.`));
|
|
172
188
|
}
|
|
173
189
|
});
|
|
174
190
|
compileProcess.on("error", reject);
|
|
175
191
|
});
|
|
176
192
|
(0, utils_1.logLabeledBullet)("functions", "Dart compilation complete.");
|
|
177
193
|
}
|
|
194
|
+
async buildCli() {
|
|
195
|
+
(0, utils_1.logLabeledBullet)("functions", "building Dart linux-x64 bundle...");
|
|
196
|
+
const buildProcess = spawn(this.bin, ["build", "cli", "--target", this.entryPoint, "--target-os", "linux", "--target-arch", "x64"], {
|
|
197
|
+
cwd: this.sourceDir,
|
|
198
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
199
|
+
});
|
|
200
|
+
buildProcess.stdout?.on("data", (chunk) => {
|
|
201
|
+
logger_1.logger.debug(`[dart build cli] ${chunk.toString("utf8").trim()}`);
|
|
202
|
+
});
|
|
203
|
+
buildProcess.stderr?.on("data", (chunk) => {
|
|
204
|
+
logger_1.logger.debug(`[dart build cli] ${chunk.toString("utf8").trim()}`);
|
|
205
|
+
});
|
|
206
|
+
await new Promise((resolve, reject) => {
|
|
207
|
+
buildProcess.on("exit", (code) => {
|
|
208
|
+
if (code === 0 || code === null) {
|
|
209
|
+
resolve();
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
reject(new error_1.FirebaseError(`Dart build failed with exit code ${code}. ` +
|
|
213
|
+
`Make sure your Dart project builds successfully with: ` +
|
|
214
|
+
`dart build cli --target ${this.entryPoint} --target-os linux --target-arch x64`));
|
|
215
|
+
}
|
|
216
|
+
});
|
|
217
|
+
buildProcess.on("error", reject);
|
|
218
|
+
});
|
|
219
|
+
(0, utils_1.logLabeledBullet)("functions", "Dart build complete.");
|
|
220
|
+
}
|
|
178
221
|
async watch(onRebuild) {
|
|
179
222
|
Delegate.watchModeActive = true;
|
|
180
223
|
logger_1.logger.debug("Starting build_runner watch for Dart functions...");
|
|
@@ -245,6 +288,7 @@ class Delegate {
|
|
|
245
288
|
const buildRunnerProcess = spawn(this.bin, ["run", "build_runner", "build"], {
|
|
246
289
|
cwd: this.sourceDir,
|
|
247
290
|
stdio: ["ignore", "pipe", "pipe"],
|
|
291
|
+
env: { ...process.env, ...envs },
|
|
248
292
|
});
|
|
249
293
|
buildRunnerProcess.stdout?.on("data", (chunk) => {
|
|
250
294
|
logger_1.logger.debug(`[build_runner] ${chunk.toString("utf8")}`);
|
|
@@ -355,6 +355,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
355
355
|
configDir: path.join(projectDir, configDir),
|
|
356
356
|
env: {
|
|
357
357
|
...options.extDevEnv,
|
|
358
|
+
FIREBASE_KIT_INSTANCE_ID: instanceId,
|
|
358
359
|
},
|
|
359
360
|
secretEnv: [],
|
|
360
361
|
predefinedTriggers: options.extDevTriggers,
|