firebase-tools-with-isolate 13.11.2 → 13.16.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 +4 -2
- package/lib/apphosting/githubConnections.js +125 -37
- package/lib/apphosting/index.js +3 -8
- package/lib/auth.js +14 -15
- package/lib/bin/firebase.js +7 -5
- package/lib/commands/dataconnect-sdk-generate.js +5 -9
- package/lib/commands/dataconnect-services-list.js +1 -1
- package/lib/commands/deploy.js +10 -2
- package/lib/commands/ext-configure.js +1 -6
- package/lib/commands/ext-dev-init.js +27 -30
- package/lib/commands/ext-dev-upload.js +4 -6
- package/lib/commands/ext-info.js +3 -5
- package/lib/commands/ext-install.js +0 -5
- package/lib/commands/ext-uninstall.js +0 -5
- package/lib/commands/ext-update.js +0 -5
- package/lib/commands/firestore-backups-schedules-create.js +11 -14
- package/lib/commands/firestore-backups-schedules-list.js +1 -1
- package/lib/commands/firestore-backups-schedules-update.js +4 -3
- package/lib/commands/firestore-databases-create.js +24 -7
- package/lib/commands/firestore-databases-restore.js +4 -4
- package/lib/commands/firestore-databases-update.js +5 -6
- package/lib/commands/functions-secrets-set.js +9 -6
- package/lib/commands/help.js +2 -0
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +1 -1
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -2
- package/lib/commands/index.js +9 -11
- package/lib/commands/init.js +16 -12
- package/lib/commands/login.js +1 -2
- package/lib/commands/setup-emulators-dataconnect.js +22 -3
- package/lib/config.js +5 -0
- package/lib/crashlytics/buildToolsJarHelper.js +1 -1
- package/lib/dataconnect/client.js +57 -9
- package/lib/dataconnect/fileUtils.js +71 -7
- package/lib/dataconnect/filters.js +12 -1
- package/lib/dataconnect/load.js +9 -7
- package/lib/dataconnect/provisionCloudSql.js +5 -1
- package/lib/dataconnect/schemaMigration.js +21 -0
- package/lib/dataconnect/types.js +8 -1
- package/lib/deploy/dataconnect/prepare.js +16 -2
- package/lib/deploy/extensions/planner.js +52 -1
- package/lib/deploy/extensions/prepare.js +98 -23
- package/lib/deploy/extensions/release.js +6 -0
- package/lib/deploy/functions/build.js +15 -6
- package/lib/deploy/functions/deploy.js +12 -12
- package/lib/deploy/functions/params.js +5 -3
- package/lib/deploy/functions/prepare.js +8 -1
- package/lib/deploy/functions/release/index.js +4 -0
- package/lib/deploy/functions/runtimes/discovery/parsing.js +1 -1
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +46 -0
- package/lib/emulator/adminSdkConfig.test.js +16 -0
- package/lib/emulator/constants.js +8 -0
- package/lib/emulator/controller.js +14 -10
- package/lib/emulator/dataconnectEmulator.js +122 -18
- package/lib/emulator/downloadableEmulators.js +24 -25
- package/lib/emulator/env.js +3 -0
- package/lib/emulator/eventarcEmulator.js +68 -18
- package/lib/emulator/functionsEmulator.js +119 -1
- package/lib/emulator/functionsEmulatorShared.js +20 -0
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/portUtils.js +10 -0
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/registry.js +2 -1
- package/lib/emulator/storage/apis/shared.js +2 -1
- package/lib/emulator/storage/persistence.js +5 -13
- package/lib/emulator/storage/rfc.js +9 -0
- package/lib/emulator/storage/rules/config.js +4 -2
- package/lib/emulator/taskQueue.js +348 -0
- package/lib/emulator/tasksEmulator.js +237 -0
- package/lib/emulator/types.js +3 -0
- package/lib/experiments.js +8 -3
- package/lib/extensions/askUserForEventsConfig.js +18 -8
- package/lib/extensions/askUserForParam.js +3 -2
- package/lib/extensions/change-log.js +2 -4
- package/lib/extensions/displayExtensionInfo.js +5 -10
- package/lib/extensions/extensionsApi.js +1 -1
- package/lib/extensions/extensionsHelper.js +30 -10
- package/lib/extensions/localHelper.js +1 -1
- package/lib/extensions/provisioningHelper.js +1 -1
- package/lib/extensions/refs.js +26 -11
- package/lib/extensions/runtimes/common.js +75 -0
- package/lib/extensions/types.js +56 -1
- package/lib/extensions/updateHelper.js +1 -2
- package/lib/extensions/warnings.js +2 -7
- package/lib/firestore/api-sort.test.js +74 -0
- package/lib/firestore/api.js +8 -7
- package/lib/firestore/backupUtils.test.js +18 -0
- package/lib/firestore/pretty-print.js +21 -1
- package/lib/firestore/pretty-print.test.js +61 -0
- package/lib/firestore/util.test.js +42 -0
- package/lib/frameworks/angular/utils.js +13 -5
- package/lib/frameworks/compose/discover/mockFileSystem.js +36 -0
- package/lib/frameworks/constants.js +1 -1
- package/lib/frameworks/index.js +2 -6
- package/lib/frameworks/next/constants.js +1 -1
- package/lib/frameworks/next/index.js +35 -15
- package/lib/frameworks/next/utils.js +53 -9
- package/lib/frameworks/nuxt/index.js +3 -3
- package/lib/functions/events/v2.js +2 -1
- package/lib/gcp/cloudsql/cloudsqladmin.js +6 -1
- package/lib/gcp/devConnect.js +36 -1
- package/lib/hosting/implicitInit.js +2 -2
- package/lib/init/features/dataconnect/index.js +104 -32
- package/lib/init/features/dataconnect/sdk.js +147 -0
- package/lib/init/features/firestore/indexes.js +2 -2
- package/lib/init/features/firestore/rules.js +2 -2
- package/lib/init/features/functions/javascript.js +6 -8
- package/lib/init/features/functions/python.js +4 -6
- package/lib/init/features/functions/typescript.js +8 -10
- package/lib/init/features/hosting/github.js +43 -21
- package/lib/init/features/hosting/index.js +3 -3
- package/lib/init/features/index.js +3 -1
- package/lib/init/features/storage.js +2 -2
- package/lib/init/index.js +1 -0
- package/lib/listFiles.js +1 -1
- package/lib/management/apps.js +2 -2
- package/lib/prompt.js +22 -1
- package/lib/rc.js +1 -0
- package/lib/requireAuth.js +8 -3
- package/lib/rulesDeploy.js +14 -12
- package/lib/templates.js +23 -0
- package/lib/utils.js +2 -2
- package/package.json +25 -24
- package/schema/connector-yaml.json +36 -4
- package/schema/dataconnect-yaml.json +4 -0
- package/schema/firebase-config.json +12 -8
- package/templates/_gitignore +3 -0
- package/templates/init/dataconnect/connector.yaml +15 -2
- package/templates/init/dataconnect/dataconnect.yaml +5 -4
- package/templates/init/dataconnect/mutations.gql +45 -25
- package/templates/init/dataconnect/queries.gql +69 -36
- package/templates/init/dataconnect/schema.gql +38 -21
- package/lib/extensions/billingMigrationHelper.js +0 -61
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepare = void 0;
|
|
3
|
+
exports.prepare = exports.prepareDynamicExtensions = void 0;
|
|
4
4
|
const planner = require("./planner");
|
|
5
5
|
const deploymentSummary = require("./deploymentSummary");
|
|
6
6
|
const prompt = require("../../prompt");
|
|
@@ -16,31 +16,28 @@ const warnings_1 = require("../../extensions/warnings");
|
|
|
16
16
|
const etags_1 = require("../../extensions/etags");
|
|
17
17
|
const v2FunctionHelper_1 = require("./v2FunctionHelper");
|
|
18
18
|
const tos_1 = require("../../extensions/tos");
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const common_1 = require("../../extensions/runtimes/common");
|
|
20
|
+
const projectConfig_1 = require("../../functions/projectConfig");
|
|
21
|
+
const functionsDeployHelper_1 = require("../functions/functionsDeployHelper");
|
|
22
|
+
async function prepareHelper(context, options, payload, wantExtensions, noDeleteExtensions, isPrimaryCall) {
|
|
21
23
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
22
|
-
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
23
|
-
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
24
|
-
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
25
|
-
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
26
24
|
context.have = await planner.have(projectId);
|
|
27
|
-
context.want =
|
|
28
|
-
projectId,
|
|
29
|
-
projectNumber,
|
|
30
|
-
aliases,
|
|
31
|
-
projectDir: options.config.projectDir,
|
|
32
|
-
extensions: options.config.get("extensions"),
|
|
33
|
-
});
|
|
25
|
+
context.want = wantExtensions;
|
|
34
26
|
const etagsChanged = (0, etags_1.detectEtagChanges)(options.rc, projectId, context.have);
|
|
35
27
|
if (etagsChanged.length) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
28
|
+
const wantChangedIds = wantExtensions
|
|
29
|
+
.map((e) => e.instanceId)
|
|
30
|
+
.filter((id) => etagsChanged.includes(id));
|
|
31
|
+
if (wantChangedIds.length) {
|
|
32
|
+
(0, warnings_1.outOfBandChangesWarning)(wantChangedIds);
|
|
33
|
+
if (!(await prompt.confirm({
|
|
34
|
+
message: `Do you wish to continue deploying these extension instances?`,
|
|
35
|
+
default: false,
|
|
36
|
+
nonInteractive: options.nonInteractive,
|
|
37
|
+
force: options.force,
|
|
38
|
+
}))) {
|
|
39
|
+
throw new error_1.FirebaseError("Deployment cancelled");
|
|
40
|
+
}
|
|
44
41
|
}
|
|
45
42
|
}
|
|
46
43
|
const usingSecrets = await Promise.all(context.want?.map(secrets_1.checkSpecForSecrets));
|
|
@@ -54,7 +51,7 @@ async function prepare(context, options, payload) {
|
|
|
54
51
|
payload.instancesToCreate = context.want.filter((i) => !context.have?.some(matchesInstanceId(i)));
|
|
55
52
|
payload.instancesToConfigure = context.want.filter((i) => context.have?.some(isConfigure(i)));
|
|
56
53
|
payload.instancesToUpdate = context.want.filter((i) => context.have?.some(isUpdate(i)));
|
|
57
|
-
payload.instancesToDelete = context.have.filter((i) => !context.want?.some(matchesInstanceId(i)));
|
|
54
|
+
payload.instancesToDelete = context.have.filter((i) => !context.want?.some(matchesInstanceId(i)) && !noDeleteExtensions?.some(matchesInstanceId(i)));
|
|
58
55
|
if (await (0, warnings_1.displayWarningsForDeploy)(payload.instancesToCreate)) {
|
|
59
56
|
if (!(await prompt.confirm({
|
|
60
57
|
message: `Do you wish to continue deploying these extension instances?`,
|
|
@@ -66,6 +63,9 @@ async function prepare(context, options, payload) {
|
|
|
66
63
|
}
|
|
67
64
|
}
|
|
68
65
|
const permissionsNeeded = [];
|
|
66
|
+
if (!isPrimaryCall) {
|
|
67
|
+
payload.instancesToDelete = [];
|
|
68
|
+
}
|
|
69
69
|
if (payload.instancesToCreate.length) {
|
|
70
70
|
permissionsNeeded.push("firebaseextensions.instances.create");
|
|
71
71
|
logger_1.logger.info(deploymentSummary.createsSummary(payload.instancesToCreate));
|
|
@@ -97,6 +97,81 @@ async function prepare(context, options, payload) {
|
|
|
97
97
|
await (0, requirePermissions_1.requirePermissions)(options, permissionsNeeded);
|
|
98
98
|
await (0, tos_1.acceptLatestAppDeveloperTOS)(options, projectId, context.want.map((i) => i.instanceId));
|
|
99
99
|
}
|
|
100
|
+
async function prepareDynamicExtensions(context, options, payload, builds) {
|
|
101
|
+
const filters = (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
102
|
+
const extensions = (0, common_1.extractExtensionsFromBuilds)(builds, filters);
|
|
103
|
+
const isApiEnabled = await (0, extensionsHelper_1.checkExtensionsApiEnabled)(options);
|
|
104
|
+
if (Object.keys(extensions).length === 0 && !isApiEnabled) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
108
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
109
|
+
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
110
|
+
const projectDir = options.config.projectDir;
|
|
111
|
+
const isPrimaryCall = !!options.only && !options.only.split(",").includes("extensions");
|
|
112
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
113
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
114
|
+
const dynamicWant = await planner.wantDynamic({
|
|
115
|
+
projectId,
|
|
116
|
+
projectNumber,
|
|
117
|
+
extensions,
|
|
118
|
+
});
|
|
119
|
+
let noDeleteExtensions = [];
|
|
120
|
+
if (isPrimaryCall) {
|
|
121
|
+
const firebaseJsonWant = await planner.want({
|
|
122
|
+
projectId,
|
|
123
|
+
projectNumber,
|
|
124
|
+
aliases,
|
|
125
|
+
projectDir,
|
|
126
|
+
extensions: options.config.get("extensions", {}),
|
|
127
|
+
});
|
|
128
|
+
noDeleteExtensions = noDeleteExtensions.concat(firebaseJsonWant);
|
|
129
|
+
if (hasNonDeployingCodebases(options)) {
|
|
130
|
+
const dynamicAll = await planner.wantDynamic({
|
|
131
|
+
projectId,
|
|
132
|
+
projectNumber,
|
|
133
|
+
extensions: await (0, common_1.extractAllDynamicExtensions)(options),
|
|
134
|
+
});
|
|
135
|
+
noDeleteExtensions = noDeleteExtensions.concat(dynamicAll);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return prepareHelper(context, options, payload, dynamicWant, noDeleteExtensions, isPrimaryCall);
|
|
139
|
+
}
|
|
140
|
+
exports.prepareDynamicExtensions = prepareDynamicExtensions;
|
|
141
|
+
function hasNonDeployingCodebases(options) {
|
|
142
|
+
const functionFilters = (0, functionsDeployHelper_1.getEndpointFilters)(options);
|
|
143
|
+
if (functionFilters?.length) {
|
|
144
|
+
return true;
|
|
145
|
+
}
|
|
146
|
+
const functionsConfig = (0, projectConfig_1.normalizeAndValidate)(options.config.src.functions);
|
|
147
|
+
const allCodebases = (0, functionsDeployHelper_1.targetCodebases)(functionsConfig);
|
|
148
|
+
const deployingCodebases = (0, functionsDeployHelper_1.targetCodebases)(functionsConfig, functionFilters);
|
|
149
|
+
if (allCodebases.length > deployingCodebases.length) {
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
async function prepare(context, options, payload) {
|
|
154
|
+
context.extensionsStartTime = Date.now();
|
|
155
|
+
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
156
|
+
const projectNumber = await (0, projectUtils_1.needProjectNumber)(options);
|
|
157
|
+
const aliases = (0, projectUtils_1.getAliases)(options, projectId);
|
|
158
|
+
const projectDir = options.config.projectDir;
|
|
159
|
+
await (0, extensionsHelper_1.ensureExtensionsApiEnabled)(options);
|
|
160
|
+
await (0, requirePermissions_1.requirePermissions)(options, ["firebaseextensions.instances.list"]);
|
|
161
|
+
const firebaseJsonWant = await planner.want({
|
|
162
|
+
projectId,
|
|
163
|
+
projectNumber,
|
|
164
|
+
aliases,
|
|
165
|
+
projectDir,
|
|
166
|
+
extensions: options.config.get("extensions", {}),
|
|
167
|
+
});
|
|
168
|
+
const dynamicWant = await planner.wantDynamic({
|
|
169
|
+
projectId,
|
|
170
|
+
projectNumber,
|
|
171
|
+
extensions: await (0, common_1.extractAllDynamicExtensions)(options),
|
|
172
|
+
});
|
|
173
|
+
return prepareHelper(context, options, payload, firebaseJsonWant, dynamicWant, true);
|
|
174
|
+
}
|
|
100
175
|
exports.prepare = prepare;
|
|
101
176
|
const matchesInstanceId = (dep) => (test) => {
|
|
102
177
|
return dep.instanceId === test.instanceId;
|
|
@@ -10,6 +10,12 @@ const projectUtils_1 = require("../../projectUtils");
|
|
|
10
10
|
const etags_1 = require("../../extensions/etags");
|
|
11
11
|
const track_1 = require("../../track");
|
|
12
12
|
async function release(context, options, payload) {
|
|
13
|
+
if (!payload.instancesToCreate &&
|
|
14
|
+
!payload.instancesToUpdate &&
|
|
15
|
+
!payload.instancesToConfigure &&
|
|
16
|
+
!payload.instancesToDelete) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
13
19
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
14
20
|
const errorHandler = new errors_1.ErrorHandler();
|
|
15
21
|
const deploymentQueue = new queue_1.default({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBackend = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
3
|
+
exports.toBackend = exports.envWithTypes = exports.resolveBackend = exports.AllIngressSettings = exports.AllVpcEgressSettings = exports.AllFunctionsPlatforms = exports.isBlockingTriggered = exports.isTaskQueueTriggered = exports.isScheduleTriggered = exports.isEventTriggered = exports.isCallableTriggered = exports.isHttpsTriggered = exports.of = exports.empty = void 0;
|
|
4
4
|
const backend = require("./backend");
|
|
5
5
|
const proto = require("../../gcp/proto");
|
|
6
6
|
const api = require("../../.../../api");
|
|
@@ -55,19 +55,19 @@ exports.AllIngressSettings = [
|
|
|
55
55
|
"ALLOW_INTERNAL_ONLY",
|
|
56
56
|
"ALLOW_INTERNAL_AND_GCLB",
|
|
57
57
|
];
|
|
58
|
-
async function resolveBackend(
|
|
58
|
+
async function resolveBackend(opts) {
|
|
59
59
|
let paramValues = {};
|
|
60
|
-
paramValues = await params.resolveParams(build.params, firebaseConfig, envWithTypes(build.params, userEnvs), nonInteractive);
|
|
60
|
+
paramValues = await params.resolveParams(opts.build.params, opts.firebaseConfig, envWithTypes(opts.build.params, opts.userEnvs), opts.nonInteractive, opts.isEmulator);
|
|
61
61
|
const toWrite = {};
|
|
62
62
|
for (const paramName of Object.keys(paramValues)) {
|
|
63
63
|
const paramValue = paramValues[paramName];
|
|
64
|
-
if (Object.prototype.hasOwnProperty.call(userEnvs, paramName) || paramValue.internal) {
|
|
64
|
+
if (Object.prototype.hasOwnProperty.call(opts.userEnvs, paramName) || paramValue.internal) {
|
|
65
65
|
continue;
|
|
66
66
|
}
|
|
67
67
|
toWrite[paramName] = paramValue.toString();
|
|
68
68
|
}
|
|
69
|
-
(0, env_1.writeUserEnvs)(toWrite, userEnvOpt);
|
|
70
|
-
return { backend: toBackend(build, paramValues), envs: paramValues };
|
|
69
|
+
(0, env_1.writeUserEnvs)(toWrite, opts.userEnvOpt);
|
|
70
|
+
return { backend: toBackend(opts.build, paramValues), envs: paramValues };
|
|
71
71
|
}
|
|
72
72
|
exports.resolveBackend = resolveBackend;
|
|
73
73
|
function envWithTypes(definedParams, rawEnvs) {
|
|
@@ -114,12 +114,21 @@ function envWithTypes(definedParams, rawEnvs) {
|
|
|
114
114
|
list: true,
|
|
115
115
|
};
|
|
116
116
|
}
|
|
117
|
+
else if (param.type === "secret") {
|
|
118
|
+
providedType = {
|
|
119
|
+
string: true,
|
|
120
|
+
boolean: false,
|
|
121
|
+
number: false,
|
|
122
|
+
list: false,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
117
125
|
}
|
|
118
126
|
}
|
|
119
127
|
out[envName] = new params.ParamValue(value, false, providedType);
|
|
120
128
|
}
|
|
121
129
|
return out;
|
|
122
130
|
}
|
|
131
|
+
exports.envWithTypes = envWithTypes;
|
|
123
132
|
class Resolver {
|
|
124
133
|
constructor(paramValues) {
|
|
125
134
|
this.paramValues = paramValues;
|
|
@@ -12,6 +12,7 @@ const gcf = require("../../gcp/cloudfunctions");
|
|
|
12
12
|
const gcfv2 = require("../../gcp/cloudfunctionsv2");
|
|
13
13
|
const backend = require("./backend");
|
|
14
14
|
const backend_1 = require("./backend");
|
|
15
|
+
const extensions_1 = require("../extensions");
|
|
15
16
|
(0, tmp_1.setGracefulCleanup)();
|
|
16
17
|
async function uploadSourceV1(projectId, source, wantBackend) {
|
|
17
18
|
const v1Endpoints = backend.allEndpoints(wantBackend).filter((e) => e.platform === "gcfv1");
|
|
@@ -76,21 +77,20 @@ async function uploadCodebase(context, codebase, wantBackend) {
|
|
|
76
77
|
}
|
|
77
78
|
}
|
|
78
79
|
async function deploy(context, options, payload) {
|
|
79
|
-
if (
|
|
80
|
-
|
|
81
|
-
}
|
|
82
|
-
if (!payload.functions) {
|
|
83
|
-
return;
|
|
80
|
+
if (payload.extensions && context.extensions) {
|
|
81
|
+
await (0, extensions_1.deploy)(context.extensions, options, payload.extensions);
|
|
84
82
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
83
|
+
if (payload.functions && context.config) {
|
|
84
|
+
await (0, checkIam_1.checkHttpIam)(context, options, payload);
|
|
85
|
+
const uploads = [];
|
|
86
|
+
for (const [codebase, { wantBackend, haveBackend }] of Object.entries(payload.functions)) {
|
|
87
|
+
if (shouldUploadBeSkipped(context, wantBackend, haveBackend)) {
|
|
88
|
+
continue;
|
|
89
|
+
}
|
|
90
|
+
uploads.push(uploadCodebase(context, codebase, wantBackend));
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
await Promise.all(uploads);
|
|
92
93
|
}
|
|
93
|
-
await Promise.all(uploads);
|
|
94
94
|
}
|
|
95
95
|
exports.deploy = deploy;
|
|
96
96
|
function shouldUploadBeSkipped(context, wantBackend, haveBackend) {
|
|
@@ -154,7 +154,7 @@ function canSatisfyParam(param, value) {
|
|
|
154
154
|
}
|
|
155
155
|
(0, functional_1.assertExhaustive)(param);
|
|
156
156
|
}
|
|
157
|
-
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive) {
|
|
157
|
+
async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive, isEmulator = false) {
|
|
158
158
|
const paramValues = populateDefaultParams(firebaseConfig);
|
|
159
159
|
const [resolved, outstanding] = (0, functional_1.partition)(params, (param) => {
|
|
160
160
|
return {}.hasOwnProperty.call(userEnvs, param.name);
|
|
@@ -163,8 +163,10 @@ async function resolveParams(params, firebaseConfig, userEnvs, nonInteractive) {
|
|
|
163
163
|
paramValues[param.name] = userEnvs[param.name];
|
|
164
164
|
}
|
|
165
165
|
const [needSecret, needPrompt] = (0, functional_1.partition)(outstanding, (param) => param.type === "secret");
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
if (!isEmulator) {
|
|
167
|
+
for (const param of needSecret) {
|
|
168
|
+
await handleSecret(param, firebaseConfig.projectId);
|
|
169
|
+
}
|
|
168
170
|
}
|
|
169
171
|
if (nonInteractive && needPrompt.length > 0) {
|
|
170
172
|
const envNames = outstanding.map((p) => p.name).join(", ");
|
|
@@ -66,7 +66,14 @@ async function prepare(context, options, payload) {
|
|
|
66
66
|
};
|
|
67
67
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
68
68
|
const envs = { ...userEnvs, ...firebaseEnvs };
|
|
69
|
-
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend(
|
|
69
|
+
const { backend: wantBackend, envs: resolvedEnvs } = await build.resolveBackend({
|
|
70
|
+
build: wantBuild,
|
|
71
|
+
firebaseConfig,
|
|
72
|
+
userEnvOpt,
|
|
73
|
+
userEnvs,
|
|
74
|
+
nonInteractive: options.nonInteractive,
|
|
75
|
+
isEmulator: false,
|
|
76
|
+
});
|
|
70
77
|
let hasEnvsFromParams = false;
|
|
71
78
|
wantBackend.environmentVariables = envs;
|
|
72
79
|
for (const envName of Object.keys(resolvedEnvs)) {
|
|
@@ -16,7 +16,11 @@ const functionsConfig_1 = require("../../../functionsConfig");
|
|
|
16
16
|
const functionsDeployHelper_1 = require("../functionsDeployHelper");
|
|
17
17
|
const error_1 = require("../../../error");
|
|
18
18
|
const getProjectNumber_1 = require("../../../getProjectNumber");
|
|
19
|
+
const extensions_1 = require("../../extensions");
|
|
19
20
|
async function release(context, options, payload) {
|
|
21
|
+
if (context.extensions && payload.extensions) {
|
|
22
|
+
await (0, extensions_1.release)(context.extensions, options, payload.extensions);
|
|
23
|
+
}
|
|
20
24
|
if (!context.config) {
|
|
21
25
|
return;
|
|
22
26
|
}
|
|
@@ -21,7 +21,7 @@ function assertKeyTypes(prefix, yaml, schema) {
|
|
|
21
21
|
const key = keyAsString;
|
|
22
22
|
const fullKey = prefix ? `${prefix}.${keyAsString}` : keyAsString;
|
|
23
23
|
if (!schema[key] || schema[key] === "omit") {
|
|
24
|
-
throw new error_1.FirebaseError(`Unexpected key ${fullKey}. You may need to install a newer version of the Firebase CLI.`);
|
|
24
|
+
throw new error_1.FirebaseError(`Unexpected key '${fullKey}'. You may need to install a newer version of the Firebase CLI.`);
|
|
25
25
|
}
|
|
26
26
|
let schemaType = schema[key];
|
|
27
27
|
if (typeof schemaType === "function") {
|
|
@@ -21,6 +21,7 @@ function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
|
21
21
|
params: "array",
|
|
22
22
|
requiredAPIs: "array",
|
|
23
23
|
endpoints: "object",
|
|
24
|
+
extensions: "object",
|
|
24
25
|
});
|
|
25
26
|
const bd = build.empty();
|
|
26
27
|
bd.params = manifest.params || [];
|
|
@@ -31,6 +32,15 @@ function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
|
31
32
|
const be = parseEndpointForBuild(id, me, project, region, runtime);
|
|
32
33
|
bd.endpoints[id] = be;
|
|
33
34
|
}
|
|
35
|
+
if (manifest.extensions) {
|
|
36
|
+
bd.extensions = {};
|
|
37
|
+
for (const id of Object.keys(manifest.extensions)) {
|
|
38
|
+
const me = manifest.extensions[id];
|
|
39
|
+
assertBuildExtension(me, id);
|
|
40
|
+
const be = parseExtensionForBuild(me);
|
|
41
|
+
bd.extensions[id] = be;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
34
44
|
return bd;
|
|
35
45
|
}
|
|
36
46
|
exports.buildFromV1Alpha1 = buildFromV1Alpha1;
|
|
@@ -277,6 +287,42 @@ function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
|
|
|
277
287
|
});
|
|
278
288
|
return parsed;
|
|
279
289
|
}
|
|
290
|
+
function assertBuildExtension(ex, id) {
|
|
291
|
+
const prefix = `extensions[${id}]`;
|
|
292
|
+
(0, parsing_1.assertKeyTypes)(prefix, ex, {
|
|
293
|
+
params: "object",
|
|
294
|
+
ref: "string?",
|
|
295
|
+
localPath: "string?",
|
|
296
|
+
events: "array",
|
|
297
|
+
});
|
|
298
|
+
let refOrPath = 0;
|
|
299
|
+
if (ex.ref) {
|
|
300
|
+
refOrPath++;
|
|
301
|
+
}
|
|
302
|
+
if (ex.localPath) {
|
|
303
|
+
refOrPath++;
|
|
304
|
+
}
|
|
305
|
+
if (refOrPath === 0) {
|
|
306
|
+
throw new error_1.FirebaseError(`Expected either extension reference or local path in extension: ${id}`);
|
|
307
|
+
}
|
|
308
|
+
if (refOrPath > 1) {
|
|
309
|
+
throw new error_1.FirebaseError(`Multiple definitions for extension ${id}. Do not specify both reference and local path.`);
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
function parseExtensionForBuild(ex) {
|
|
313
|
+
const parsed = {
|
|
314
|
+
params: {},
|
|
315
|
+
events: [],
|
|
316
|
+
};
|
|
317
|
+
if (ex.localPath) {
|
|
318
|
+
parsed.localPath = ex.localPath;
|
|
319
|
+
}
|
|
320
|
+
else {
|
|
321
|
+
parsed.ref = ex.ref;
|
|
322
|
+
}
|
|
323
|
+
(0, proto_1.copyIfPresent)(parsed, ex, "params", "events");
|
|
324
|
+
return parsed;
|
|
325
|
+
}
|
|
280
326
|
function resolveChannelName(projectId, channel, defaultRegion) {
|
|
281
327
|
if (!channel.includes("/")) {
|
|
282
328
|
const location = defaultRegion;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const adminSdkConfig_1 = require("./adminSdkConfig");
|
|
5
|
+
describe("adminSdkConfig", () => {
|
|
6
|
+
describe("getProjectAdminSdkConfigOrCached", () => {
|
|
7
|
+
it("should return a fake config for a demo project id", async () => {
|
|
8
|
+
const projectId = "demo-project-1234";
|
|
9
|
+
await (0, chai_1.expect)((0, adminSdkConfig_1.getProjectAdminSdkConfigOrCached)(projectId)).to.eventually.deep.equal({
|
|
10
|
+
projectId: "demo-project-1234",
|
|
11
|
+
databaseURL: "https://demo-project-1234.firebaseio.com",
|
|
12
|
+
storageBucket: "demo-project-1234.appspot.com",
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
@@ -15,6 +15,7 @@ exports.DEFAULT_PORTS = {
|
|
|
15
15
|
storage: 9199,
|
|
16
16
|
eventarc: 9299,
|
|
17
17
|
dataconnect: 9399,
|
|
18
|
+
tasks: 9499,
|
|
18
19
|
};
|
|
19
20
|
exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
20
21
|
ui: true,
|
|
@@ -30,6 +31,7 @@ exports.FIND_AVAILBLE_PORT_BY_DEFAULT = {
|
|
|
30
31
|
extensions: false,
|
|
31
32
|
eventarc: true,
|
|
32
33
|
dataconnect: true,
|
|
34
|
+
tasks: true,
|
|
33
35
|
};
|
|
34
36
|
exports.EMULATOR_DESCRIPTION = {
|
|
35
37
|
ui: "Emulator UI",
|
|
@@ -45,6 +47,7 @@ exports.EMULATOR_DESCRIPTION = {
|
|
|
45
47
|
extensions: "Extensions Emulator",
|
|
46
48
|
eventarc: "Eventarc Emulator",
|
|
47
49
|
dataconnect: "Data Connect Emulator",
|
|
50
|
+
tasks: "Cloud Tasks Emulator",
|
|
48
51
|
};
|
|
49
52
|
exports.DEFAULT_HOST = "localhost";
|
|
50
53
|
class Constants {
|
|
@@ -70,6 +73,8 @@ class Constants {
|
|
|
70
73
|
return "test lab";
|
|
71
74
|
case this.SERVICE_EVENTARC:
|
|
72
75
|
return "eventarc";
|
|
76
|
+
case this.SERVICE_CLOUD_TASKS:
|
|
77
|
+
return "tasks";
|
|
73
78
|
default:
|
|
74
79
|
return service;
|
|
75
80
|
}
|
|
@@ -100,12 +105,15 @@ Constants.FIREBASE_STORAGE_EMULATOR_HOST = "FIREBASE_STORAGE_EMULATOR_HOST";
|
|
|
100
105
|
Constants.CLOUD_STORAGE_EMULATOR_HOST = "STORAGE_EMULATOR_HOST";
|
|
101
106
|
Constants.PUBSUB_EMULATOR_HOST = "PUBSUB_EMULATOR_HOST";
|
|
102
107
|
Constants.CLOUD_EVENTARC_EMULATOR_HOST = "CLOUD_EVENTARC_EMULATOR_HOST";
|
|
108
|
+
Constants.CLOUD_TASKS_EMULATOR_HOST = "CLOUD_TASKS_EMULATOR_HOST";
|
|
103
109
|
Constants.FIREBASE_EMULATOR_HUB = "FIREBASE_EMULATOR_HUB";
|
|
104
110
|
Constants.FIREBASE_GA_SESSION = "FIREBASE_GA_SESSION";
|
|
105
111
|
Constants.SERVICE_FIRESTORE = "firestore.googleapis.com";
|
|
106
112
|
Constants.SERVICE_REALTIME_DATABASE = "firebaseio.com";
|
|
107
113
|
Constants.SERVICE_PUBSUB = "pubsub.googleapis.com";
|
|
108
114
|
Constants.SERVICE_EVENTARC = "eventarc.googleapis.com";
|
|
115
|
+
Constants.SERVICE_CLOUD_TASKS = "cloudtasks.googleapis.com";
|
|
116
|
+
Constants.SERVICE_FIREALERTS = "firebasealerts.googleapis.com";
|
|
109
117
|
Constants.SERVICE_ANALYTICS = "app-measurement.com";
|
|
110
118
|
Constants.SERVICE_AUTH = "firebaseauth.googleapis.com";
|
|
111
119
|
Constants.SERVICE_CRASHLYTICS = "fabric.io";
|
|
@@ -44,6 +44,7 @@ const hostingEmulator_1 = require("./hostingEmulator");
|
|
|
44
44
|
const pubsubEmulator_1 = require("./pubsubEmulator");
|
|
45
45
|
const storage_1 = require("./storage");
|
|
46
46
|
const fileUtils_1 = require("../dataconnect/fileUtils");
|
|
47
|
+
const tasksEmulator_1 = require("./tasksEmulator");
|
|
47
48
|
const START_LOGGING_EMULATOR = utils.envOverride("START_LOGGING_EMULATOR", "false", (val) => val === "true");
|
|
48
49
|
async function exportOnExit(options) {
|
|
49
50
|
const exportOnExitDir = options.exportOnExit;
|
|
@@ -222,10 +223,12 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
222
223
|
if (emulatableBackends.length) {
|
|
223
224
|
listenConfig[types_1.Emulators.FUNCTIONS] = getListenConfig(options, types_1.Emulators.FUNCTIONS);
|
|
224
225
|
listenConfig[types_1.Emulators.EVENTARC] = getListenConfig(options, types_1.Emulators.EVENTARC);
|
|
226
|
+
listenConfig[types_1.Emulators.TASKS] = getListenConfig(options, types_1.Emulators.TASKS);
|
|
225
227
|
}
|
|
226
228
|
for (const emulator of types_1.ALL_EMULATORS) {
|
|
227
229
|
if (emulator === types_1.Emulators.FUNCTIONS ||
|
|
228
230
|
emulator === types_1.Emulators.EVENTARC ||
|
|
231
|
+
emulator === types_1.Emulators.TASKS ||
|
|
229
232
|
emulator === types_1.Emulators.EXTENSIONS ||
|
|
230
233
|
(emulator === types_1.Emulators.UI && !showUI)) {
|
|
231
234
|
continue;
|
|
@@ -322,6 +325,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
322
325
|
},
|
|
323
326
|
secretEnv: [],
|
|
324
327
|
predefinedTriggers: options.extDevTriggers,
|
|
328
|
+
ignore: cfg.ignore,
|
|
325
329
|
});
|
|
326
330
|
}
|
|
327
331
|
}
|
|
@@ -329,11 +333,12 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
329
333
|
await startEmulator(extensionEmulator);
|
|
330
334
|
}
|
|
331
335
|
if (emulatableBackends.length) {
|
|
332
|
-
if (!listenForEmulator.functions || !listenForEmulator.eventarc) {
|
|
336
|
+
if (!listenForEmulator.functions || !listenForEmulator.eventarc || !listenForEmulator.tasks) {
|
|
333
337
|
listenForEmulator = await (0, portUtils_1.resolveHostAndAssignPorts)({
|
|
334
338
|
...listenForEmulator,
|
|
335
339
|
functions: listenForEmulator.functions ?? getListenConfig(options, types_1.Emulators.FUNCTIONS),
|
|
336
340
|
eventarc: listenForEmulator.eventarc ?? getListenConfig(options, types_1.Emulators.EVENTARC),
|
|
341
|
+
tasks: listenForEmulator.eventarc ?? getListenConfig(options, types_1.Emulators.TASKS),
|
|
337
342
|
});
|
|
338
343
|
hubLogger.log("DEBUG", "late-assigned ports for functions and eventarc emulators", {
|
|
339
344
|
user: listenForEmulator,
|
|
@@ -371,6 +376,12 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
371
376
|
port: eventarcAddr.port,
|
|
372
377
|
});
|
|
373
378
|
await startEmulator(eventarcEmulator);
|
|
379
|
+
const tasksAddr = legacyGetFirstAddr(types_1.Emulators.TASKS);
|
|
380
|
+
const tasksEmulator = new tasksEmulator_1.TasksEmulator({
|
|
381
|
+
host: tasksAddr.host,
|
|
382
|
+
port: tasksAddr.port,
|
|
383
|
+
});
|
|
384
|
+
await startEmulator(tasksEmulator);
|
|
374
385
|
}
|
|
375
386
|
if (listenForEmulator.firestore) {
|
|
376
387
|
const firestoreLogger = emulatorLogger_1.EmulatorLogger.forEmulator(types_1.Emulators.FIRESTORE);
|
|
@@ -529,23 +540,16 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
529
540
|
else if (config.length > 1) {
|
|
530
541
|
logger_1.logger.warn(`TODO: Add support for multiple services in the Data Connect emulator. Currently emulating first service ${config[0].source}`);
|
|
531
542
|
}
|
|
532
|
-
|
|
533
|
-
if (!path.isAbsolute(configDir)) {
|
|
534
|
-
const cwd = options.cwd || process.cwd();
|
|
535
|
-
configDir = path.resolve(path.join(cwd), configDir);
|
|
536
|
-
}
|
|
543
|
+
const configDir = config[0].source;
|
|
537
544
|
const dataConnectEmulator = new dataconnectEmulator_1.DataConnectEmulator({
|
|
538
545
|
listen: listenForEmulator.dataconnect,
|
|
539
546
|
projectId,
|
|
540
547
|
auto_download: true,
|
|
541
548
|
configDir,
|
|
542
|
-
locationId: config[0].location,
|
|
543
549
|
rc: options.rc,
|
|
550
|
+
config: options.config,
|
|
544
551
|
});
|
|
545
552
|
await startEmulator(dataConnectEmulator);
|
|
546
|
-
if (!utils.isVSCodeExtension()) {
|
|
547
|
-
await dataConnectEmulator.connectToPostgres();
|
|
548
|
-
}
|
|
549
553
|
}
|
|
550
554
|
if (listenForEmulator.storage) {
|
|
551
555
|
const storageAddr = legacyGetFirstAddr(types_1.Emulators.STORAGE);
|