firebase-tools 11.0.0 → 11.2.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/accountExporter.js +11 -4
- package/lib/accountImporter.js +93 -95
- package/lib/api.js +77 -218
- package/lib/apiv2.js +5 -4
- package/lib/appdistribution/client.js +23 -34
- package/lib/auth.js +72 -52
- package/lib/bin/firebase.js +42 -47
- package/lib/checkValidTargetFilters.js +36 -25
- package/lib/commands/appdistribution-distribute.js +2 -1
- package/lib/commands/appdistribution-testers-add.js +2 -1
- package/lib/commands/appdistribution-testers-remove.js +2 -1
- package/lib/commands/apps-android-sha-create.js +2 -1
- package/lib/commands/apps-android-sha-delete.js +2 -1
- package/lib/commands/apps-android-sha-list.js +2 -1
- package/lib/commands/apps-create.js +2 -1
- package/lib/commands/apps-list.js +2 -1
- package/lib/commands/apps-sdkconfig.js +2 -1
- package/lib/commands/auth-export.js +2 -1
- package/lib/commands/auth-import.js +7 -10
- package/lib/commands/crashlytics-symbols-upload.js +2 -1
- package/lib/commands/database-get.js +4 -3
- package/lib/commands/database-instances-create.js +2 -1
- package/lib/commands/database-instances-list.js +3 -3
- package/lib/commands/database-profile.js +4 -4
- package/lib/commands/database-push.js +4 -4
- package/lib/commands/database-remove.js +3 -3
- package/lib/commands/database-rules-canary.js +2 -1
- package/lib/commands/database-rules-get.js +2 -1
- package/lib/commands/database-rules-list.js +2 -1
- package/lib/commands/database-rules-release.js +2 -1
- package/lib/commands/database-rules-stage.js +2 -1
- package/lib/commands/database-set.js +3 -3
- package/lib/commands/database-settings-get.js +2 -1
- package/lib/commands/database-settings-set.js +2 -1
- package/lib/commands/database-update.js +2 -1
- package/lib/commands/deploy.js +26 -25
- package/lib/commands/emulators-exec.js +2 -1
- package/lib/commands/emulators-export.js +2 -1
- package/lib/commands/emulators-start.js +2 -1
- package/lib/commands/experimental-functions-shell.js +10 -8
- package/lib/commands/ext-configure.js +6 -1
- package/lib/commands/ext-dev-deprecate.js +2 -1
- package/lib/commands/ext-dev-emulators-exec.js +3 -2
- package/lib/commands/ext-dev-emulators-start.js +3 -2
- package/lib/commands/ext-dev-extension-delete.js +2 -1
- package/lib/commands/ext-dev-init.js +2 -1
- package/lib/commands/ext-dev-list.js +8 -8
- package/lib/commands/ext-dev-publish.js +2 -1
- package/lib/commands/ext-dev-register.js +2 -1
- package/lib/commands/ext-dev-undeprecate.js +2 -1
- package/lib/commands/ext-dev-unpublish.js +2 -1
- package/lib/commands/ext-dev-usage.js +2 -1
- package/lib/commands/ext-export.js +2 -1
- package/lib/commands/ext-info.js +14 -14
- package/lib/commands/ext-install.js +6 -1
- package/lib/commands/ext-list.js +2 -1
- package/lib/commands/ext-sources-create.js +2 -1
- package/lib/commands/ext-uninstall.js +7 -1
- package/lib/commands/ext-update.js +6 -1
- package/lib/commands/ext.js +4 -4
- package/lib/commands/firestore-delete.js +2 -1
- package/lib/commands/firestore-indexes-list.js +2 -1
- package/lib/commands/functions-config-clone.js +4 -3
- package/lib/commands/functions-config-export.js +2 -1
- package/lib/commands/functions-config-get.js +2 -1
- package/lib/commands/functions-config-set.js +2 -1
- package/lib/commands/functions-config-unset.js +2 -1
- package/lib/commands/functions-delete.js +3 -8
- package/lib/commands/functions-deletegcfartifacts.js +2 -1
- package/lib/commands/functions-list.js +2 -1
- package/lib/commands/functions-log.js +2 -1
- package/lib/commands/functions-secrets-access.js +2 -1
- package/lib/commands/functions-secrets-destroy.js +2 -1
- package/lib/commands/functions-secrets-get.js +2 -1
- package/lib/commands/functions-secrets-prune.js +2 -1
- package/lib/commands/functions-secrets-set.js +2 -1
- package/lib/commands/functions-shell.js +12 -10
- package/lib/commands/help.js +2 -1
- package/lib/commands/hosting-channel-create.js +2 -1
- package/lib/commands/hosting-channel-delete.js +2 -1
- package/lib/commands/hosting-channel-deploy.js +2 -1
- package/lib/commands/hosting-channel-list.js +2 -1
- package/lib/commands/hosting-channel-open.js +2 -1
- package/lib/commands/hosting-clone.js +2 -1
- package/lib/commands/hosting-disable.js +2 -1
- package/lib/commands/hosting-sites-create.js +2 -1
- package/lib/commands/hosting-sites-delete.js +2 -1
- package/lib/commands/hosting-sites-get.js +2 -1
- package/lib/commands/hosting-sites-list.js +2 -1
- package/lib/commands/index.js +23 -13
- package/lib/commands/init.js +47 -43
- package/lib/commands/login-add.js +2 -1
- package/lib/commands/login-ci.js +2 -1
- package/lib/commands/login-list.js +2 -1
- package/lib/commands/login-use.js +2 -1
- package/lib/commands/login.js +2 -1
- package/lib/commands/logout.js +2 -1
- package/lib/commands/open.js +7 -7
- package/lib/commands/projects-addfirebase.js +2 -1
- package/lib/commands/projects-create.js +2 -1
- package/lib/commands/projects-list.js +2 -1
- package/lib/commands/remoteconfig-get.js +2 -1
- package/lib/commands/remoteconfig-rollback.js +2 -1
- package/lib/commands/remoteconfig-versions-list.js +2 -1
- package/lib/commands/serve.js +30 -30
- package/lib/commands/setup-emulators-database.js +2 -1
- package/lib/commands/setup-emulators-firestore.js +2 -1
- package/lib/commands/setup-emulators-pubsub.js +2 -1
- package/lib/commands/setup-emulators-storage.js +2 -1
- package/lib/commands/setup-emulators-ui.js +2 -1
- package/lib/commands/target-apply.js +2 -1
- package/lib/commands/target-clear.js +2 -1
- package/lib/commands/target-remove.js +2 -1
- package/lib/commands/target.js +2 -1
- package/lib/commands/use.js +54 -53
- package/lib/config.js +7 -6
- package/lib/deploy/database/deploy.js +3 -2
- package/lib/deploy/database/index.js +8 -5
- package/lib/deploy/database/prepare.js +22 -20
- package/lib/deploy/database/release.js +12 -9
- package/lib/deploy/extensions/secrets.js +3 -3
- package/lib/deploy/firestore/prepare.js +2 -2
- package/lib/deploy/functions/build.js +33 -20
- package/lib/deploy/functions/ensure.js +1 -11
- package/lib/deploy/functions/prepare.js +3 -13
- package/lib/deploy/functions/prepareFunctionsUpload.js +2 -3
- package/lib/deploy/functions/release/fabricator.js +0 -1
- package/lib/deploy/functions/release/index.js +1 -5
- package/lib/deploy/functions/runtimes/discovery/index.js +18 -3
- package/lib/deploy/functions/runtimes/discovery/v1alpha1.js +188 -54
- package/lib/deploy/functions/runtimes/golang/index.js +2 -22
- package/lib/deploy/functions/runtimes/node/index.js +3 -7
- package/lib/deploy/functions/runtimes/node/parseTriggers.js +15 -3
- package/lib/deploy/functions/services/database.js +14 -0
- package/lib/deploy/functions/services/index.js +14 -0
- package/lib/deploy/index.js +3 -3
- package/lib/deploy/lifecycleHooks.js +27 -27
- package/lib/deploy/remoteconfig/functions.js +18 -14
- package/lib/deploy/remoteconfig/prepare.js +2 -2
- package/lib/deploy/storage/prepare.js +1 -1
- package/lib/emulator/auth/apiSpec.js +14 -46
- package/lib/emulator/auth/index.js +1 -1
- package/lib/emulator/auth/operations.js +342 -93
- package/lib/emulator/auth/server.js +2 -2
- package/lib/emulator/auth/state.js +34 -32
- package/lib/emulator/commandUtils.js +1 -1
- package/lib/emulator/constants.js +1 -1
- package/lib/emulator/controller.js +7 -6
- package/lib/emulator/databaseEmulator.js +11 -9
- package/lib/emulator/download.js +1 -1
- package/lib/emulator/events/types.js +2 -3
- package/lib/emulator/firestoreEmulator.js +12 -14
- package/lib/emulator/functionsEmulator.js +65 -77
- package/lib/emulator/functionsEmulatorRuntime.js +7 -7
- package/lib/emulator/hostingEmulator.js +1 -1
- package/lib/emulator/hub.js +1 -1
- package/lib/emulator/hubClient.js +11 -22
- package/lib/emulator/hubExport.js +26 -16
- package/lib/emulator/loggingEmulator.js +1 -1
- package/lib/emulator/pubsubEmulator.js +1 -1
- package/lib/emulator/storage/crc.js +4 -4
- package/lib/emulator/storage/index.js +1 -1
- package/lib/emulator/types.js +1 -1
- package/lib/errorOut.js +2 -2
- package/lib/extensions/askUserForConsent.js +1 -2
- package/lib/extensions/askUserForParam.js +15 -18
- package/lib/extensions/emulator/optionsHelper.js +4 -4
- package/lib/extensions/extensionsApi.js +1 -22
- package/lib/extensions/extensionsHelper.js +6 -6
- package/lib/extensions/listExtensions.js +9 -10
- package/lib/extensions/manifest.js +2 -2
- package/lib/extensions/resolveSource.js +11 -7
- package/lib/extensions/secretsUtils.js +3 -3
- package/lib/extensions/types.js +24 -0
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/utils.js +1 -2
- package/lib/extensions/warnings.js +3 -3
- package/lib/firestore/checkDatabaseType.js +4 -5
- package/lib/firestore/encodeFirestoreValue.js +11 -8
- package/lib/firestore/indexes.js +17 -34
- package/lib/fsAsync.js +3 -3
- package/lib/functions/events/v2.js +7 -1
- package/lib/functionsConfig.js +17 -14
- package/lib/functionsConfigClone.js +46 -46
- package/lib/gcp/cloudfunctions.js +2 -15
- package/lib/gcp/cloudfunctionsv2.js +17 -2
- package/lib/gcp/iam.js +1 -1
- package/lib/gcp/index.js +10 -10
- package/lib/gcp/rules.js +1 -1
- package/lib/gcp/runtimeconfig.js +45 -47
- package/lib/gcp/storage.js +2 -4
- package/lib/hosting/cloudRunProxy.js +19 -15
- package/lib/hosting/proxy.js +1 -1
- package/lib/index.js +29 -28
- package/lib/init/features/database.js +11 -5
- package/lib/init/features/functions/index.js +1 -1
- package/lib/init/features/functions/javascript.js +23 -20
- package/lib/init/features/functions/npm-dependencies.js +17 -14
- package/lib/init/features/functions/typescript.js +27 -24
- package/lib/init/features/hosting/github.js +6 -5
- package/lib/init/features/hosting/index.js +2 -2
- package/lib/loadCJSON.js +9 -6
- package/lib/localFunction.js +4 -4
- package/lib/logError.js +15 -12
- package/lib/management/apps.js +47 -43
- package/lib/management/database.js +33 -31
- package/lib/management/projects.js +13 -7
- package/lib/parseBoltRules.js +15 -14
- package/lib/previews.js +1 -1
- package/lib/profileReport.js +504 -512
- package/lib/profiler.js +4 -4
- package/lib/prompt.js +1 -2
- package/lib/rc.js +1 -1
- package/lib/requireAuth.js +0 -1
- package/lib/responseToError.js +8 -5
- package/lib/rtdb.js +31 -29
- package/lib/rulesDeploy.js +2 -2
- package/lib/scopes.js +9 -9
- package/lib/serve/index.js +4 -5
- package/lib/utils.js +30 -6
- package/npm-shrinkwrap.json +877 -279
- package/package.json +19 -16
- package/standalone/package.json +1 -1
|
@@ -1,7 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
3
|
+
var t = {};
|
|
4
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
5
|
+
t[p] = s[p];
|
|
6
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
7
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
8
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
9
|
+
t[p[i]] = s[p[i]];
|
|
10
|
+
}
|
|
11
|
+
return t;
|
|
12
|
+
};
|
|
2
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.backendFromV1Alpha1 = void 0;
|
|
14
|
+
exports.backendFromV1Alpha1 = exports.buildFromV1Alpha1 = void 0;
|
|
4
15
|
const backend = require("../../backend");
|
|
16
|
+
const build = require("../../build");
|
|
5
17
|
const proto_1 = require("../../../../gcp/proto");
|
|
6
18
|
const parsing_1 = require("./parsing");
|
|
7
19
|
const error_1 = require("../../../../error");
|
|
@@ -11,6 +23,25 @@ const CHANNEL_NAME_REGEX = new RegExp("(projects\\/" +
|
|
|
11
23
|
"(?<location>[A-Za-z\\d\\-_]+)\\/" +
|
|
12
24
|
"channels\\/" +
|
|
13
25
|
"(?<channel>[A-Za-z\\d\\-_]+)");
|
|
26
|
+
function buildFromV1Alpha1(yaml, project, region, runtime) {
|
|
27
|
+
const manifest = JSON.parse(JSON.stringify(yaml));
|
|
28
|
+
(0, parsing_1.requireKeys)("", manifest, "endpoints");
|
|
29
|
+
(0, parsing_1.assertKeyTypes)("", manifest, {
|
|
30
|
+
specVersion: "string",
|
|
31
|
+
requiredAPIs: "array",
|
|
32
|
+
endpoints: "object",
|
|
33
|
+
});
|
|
34
|
+
const bd = build.empty();
|
|
35
|
+
bd.requiredAPIs = parseRequiredAPIs(manifest);
|
|
36
|
+
for (const id of Object.keys(manifest.endpoints)) {
|
|
37
|
+
const me = manifest.endpoints[id];
|
|
38
|
+
assertManifestEndpoint(me, id);
|
|
39
|
+
const be = parseEndpointForBuild(id, me, project, region, runtime);
|
|
40
|
+
bd.endpoints[id] = be;
|
|
41
|
+
}
|
|
42
|
+
return bd;
|
|
43
|
+
}
|
|
44
|
+
exports.buildFromV1Alpha1 = buildFromV1Alpha1;
|
|
14
45
|
function backendFromV1Alpha1(yaml, project, region, runtime) {
|
|
15
46
|
const manifest = JSON.parse(JSON.stringify(yaml));
|
|
16
47
|
const bkend = backend.empty();
|
|
@@ -42,10 +73,8 @@ function parseRequiredAPIs(manifest) {
|
|
|
42
73
|
}
|
|
43
74
|
return requiredAPIs;
|
|
44
75
|
}
|
|
45
|
-
function
|
|
46
|
-
const allParsed = [];
|
|
76
|
+
function assertManifestEndpoint(ep, id) {
|
|
47
77
|
const prefix = `endpoints[${id}]`;
|
|
48
|
-
const ep = manifest.endpoints[id];
|
|
49
78
|
(0, parsing_1.assertKeyTypes)(prefix, ep, {
|
|
50
79
|
region: "array",
|
|
51
80
|
platform: (platform) => backend.AllFunctionsPlatforms.includes(platform),
|
|
@@ -101,19 +130,164 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
101
130
|
if (triggerCount > 1) {
|
|
102
131
|
throw new error_1.FirebaseError("Multiple triggers defined for endpoint" + id);
|
|
103
132
|
}
|
|
133
|
+
if (backend.isEventTriggered(ep)) {
|
|
134
|
+
(0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
135
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
136
|
+
eventFilters: "object",
|
|
137
|
+
eventFilterPathPatterns: "object",
|
|
138
|
+
eventType: "string",
|
|
139
|
+
retry: "boolean",
|
|
140
|
+
region: "string",
|
|
141
|
+
serviceAccountEmail: "string",
|
|
142
|
+
channel: "string",
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else if (backend.isHttpsTriggered(ep)) {
|
|
146
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
147
|
+
invoker: "array",
|
|
148
|
+
});
|
|
149
|
+
}
|
|
150
|
+
else if (backend.isCallableTriggered(ep)) {
|
|
151
|
+
}
|
|
152
|
+
else if (backend.isScheduleTriggered(ep)) {
|
|
153
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
154
|
+
schedule: "string",
|
|
155
|
+
timeZone: "string",
|
|
156
|
+
retryConfig: "object",
|
|
157
|
+
});
|
|
158
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
159
|
+
retryCount: "number",
|
|
160
|
+
maxDoublings: "number",
|
|
161
|
+
minBackoffDuration: "string",
|
|
162
|
+
maxBackoffDuration: "string",
|
|
163
|
+
maxRetryDuration: "string",
|
|
164
|
+
});
|
|
165
|
+
}
|
|
166
|
+
else if (backend.isTaskQueueTriggered(ep)) {
|
|
167
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
168
|
+
rateLimits: "object",
|
|
169
|
+
retryConfig: "object",
|
|
170
|
+
invoker: "array",
|
|
171
|
+
});
|
|
172
|
+
if (ep.taskQueueTrigger.rateLimits) {
|
|
173
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
174
|
+
maxConcurrentDispatches: "number",
|
|
175
|
+
maxDispatchesPerSecond: "number",
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
if (ep.taskQueueTrigger.retryConfig) {
|
|
179
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
180
|
+
maxAttempts: "number",
|
|
181
|
+
maxRetrySeconds: "number",
|
|
182
|
+
minBackoffSeconds: "number",
|
|
183
|
+
maxBackoffSeconds: "number",
|
|
184
|
+
maxDoublings: "number",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
else if (backend.isBlockingTriggered(ep)) {
|
|
189
|
+
(0, parsing_1.requireKeys)(prefix + ".blockingTrigger", ep.blockingTrigger, "eventType");
|
|
190
|
+
(0, parsing_1.assertKeyTypes)(prefix + ".blockingTrigger", ep.blockingTrigger, {
|
|
191
|
+
eventType: "string",
|
|
192
|
+
options: "object",
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
|
|
197
|
+
"firebase-tools with npm install -g firebase-tools@latest");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function parseEndpointForBuild(id, ep, project, defaultRegion, runtime) {
|
|
201
|
+
let triggered;
|
|
202
|
+
if (backend.isEventTriggered(ep)) {
|
|
203
|
+
const newTrigger = __rest(ep.eventTrigger, []);
|
|
204
|
+
delete newTrigger.serviceAccountEmail;
|
|
205
|
+
triggered = { eventTrigger: newTrigger };
|
|
206
|
+
triggered.eventTrigger.serviceAccount = ep.eventTrigger.serviceAccountEmail;
|
|
207
|
+
(0, proto_1.renameIfPresent)(triggered.eventTrigger, ep.eventTrigger, "channel", "channel", (c) => resolveChannelName(project, c, defaultRegion));
|
|
208
|
+
for (const [k, v] of Object.entries(triggered.eventTrigger.eventFilters)) {
|
|
209
|
+
if (k === "topic" && !v.startsWith("projects/")) {
|
|
210
|
+
triggered.eventTrigger.eventFilters[k] = `projects/${project}/topics/${v}`;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
else if (backend.isHttpsTriggered(ep)) {
|
|
215
|
+
triggered = { httpsTrigger: {} };
|
|
216
|
+
(0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
217
|
+
}
|
|
218
|
+
else if (backend.isCallableTriggered(ep)) {
|
|
219
|
+
triggered = { callableTrigger: {} };
|
|
220
|
+
}
|
|
221
|
+
else if (backend.isScheduleTriggered(ep)) {
|
|
222
|
+
const st = {
|
|
223
|
+
schedule: ep.scheduleTrigger.schedule || "",
|
|
224
|
+
timeZone: ep.scheduleTrigger.timeZone || "",
|
|
225
|
+
retryConfig: {},
|
|
226
|
+
};
|
|
227
|
+
if (ep.scheduleTrigger.retryConfig) {
|
|
228
|
+
st.retryConfig = {
|
|
229
|
+
retryCount: ep.scheduleTrigger.retryConfig.retryCount,
|
|
230
|
+
maxDoublings: ep.scheduleTrigger.retryConfig.maxDoublings,
|
|
231
|
+
};
|
|
232
|
+
if (ep.scheduleTrigger.retryConfig.maxRetryDuration) {
|
|
233
|
+
st.retryConfig.maxRetrySeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.maxRetryDuration);
|
|
234
|
+
}
|
|
235
|
+
if (ep.scheduleTrigger.retryConfig.maxBackoffDuration) {
|
|
236
|
+
st.retryConfig.maxBackoffSeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.maxBackoffDuration);
|
|
237
|
+
}
|
|
238
|
+
if (ep.scheduleTrigger.retryConfig.minBackoffDuration) {
|
|
239
|
+
st.retryConfig.minBackoffSeconds = (0, proto_1.secondsFromDuration)(ep.scheduleTrigger.retryConfig.minBackoffDuration);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
triggered = { scheduleTrigger: st };
|
|
243
|
+
}
|
|
244
|
+
else if (backend.isTaskQueueTriggered(ep)) {
|
|
245
|
+
const tq = {
|
|
246
|
+
invoker: ep.taskQueueTrigger.invoker,
|
|
247
|
+
rateLimits: ep.taskQueueTrigger.rateLimits,
|
|
248
|
+
};
|
|
249
|
+
if (ep.taskQueueTrigger.retryConfig) {
|
|
250
|
+
tq.retryConfig = {
|
|
251
|
+
maxRetryDurationSeconds: ep.taskQueueTrigger.retryConfig.maxRetrySeconds,
|
|
252
|
+
maxBackoffSeconds: ep.taskQueueTrigger.retryConfig.maxBackoffSeconds,
|
|
253
|
+
minBackoffSeconds: ep.taskQueueTrigger.retryConfig.minBackoffSeconds,
|
|
254
|
+
maxDoublings: ep.taskQueueTrigger.retryConfig.maxDoublings,
|
|
255
|
+
maxAttempts: ep.taskQueueTrigger.retryConfig.maxAttempts,
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
triggered = { taskQueueTrigger: tq };
|
|
259
|
+
}
|
|
260
|
+
else if (backend.isBlockingTriggered(ep)) {
|
|
261
|
+
triggered = { blockingTrigger: ep.blockingTrigger };
|
|
262
|
+
}
|
|
263
|
+
else {
|
|
264
|
+
throw new error_1.FirebaseError(`Do not recognize trigger type for endpoint ${id}. Try upgrading ` +
|
|
265
|
+
"firebase-tools with npm install -g firebase-tools@latest");
|
|
266
|
+
}
|
|
267
|
+
const parsed = Object.assign({ platform: ep.platform || "gcfv2", region: ep.region || [defaultRegion], project,
|
|
268
|
+
runtime, entryPoint: ep.entryPoint, serviceAccount: ep.serviceAccountEmail || null }, triggered);
|
|
269
|
+
(0, proto_1.copyIfPresent)(parsed, ep, "availableMemoryMb", "maxInstances", "minInstances", "concurrency", "timeoutSeconds", "vpc", "labels", "ingressSettings", "environmentVariables");
|
|
270
|
+
(0, proto_1.renameIfPresent)(parsed, ep, "secretEnvironmentVariables", "secretEnvironmentVariables", (senvs) => {
|
|
271
|
+
const secretEnvironmentVariables = [];
|
|
272
|
+
for (const { key, secret } of senvs) {
|
|
273
|
+
secretEnvironmentVariables.push({
|
|
274
|
+
key,
|
|
275
|
+
secret: secret || key,
|
|
276
|
+
projectId: project,
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
return secretEnvironmentVariables;
|
|
280
|
+
});
|
|
281
|
+
return parsed;
|
|
282
|
+
}
|
|
283
|
+
function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
284
|
+
const allParsed = [];
|
|
285
|
+
const prefix = `endpoints[${id}]`;
|
|
286
|
+
const ep = manifest.endpoints[id];
|
|
287
|
+
assertManifestEndpoint(ep, prefix);
|
|
104
288
|
for (const region of ep.region || [defaultRegion]) {
|
|
105
289
|
let triggered;
|
|
106
290
|
if (backend.isEventTriggered(ep)) {
|
|
107
|
-
(0, parsing_1.requireKeys)(prefix + ".eventTrigger", ep.eventTrigger, "eventType", "eventFilters");
|
|
108
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".eventTrigger", ep.eventTrigger, {
|
|
109
|
-
eventFilters: "object",
|
|
110
|
-
eventFilterPathPatterns: "object",
|
|
111
|
-
eventType: "string",
|
|
112
|
-
retry: "boolean",
|
|
113
|
-
region: "string",
|
|
114
|
-
serviceAccountEmail: "string",
|
|
115
|
-
channel: "string",
|
|
116
|
-
});
|
|
117
291
|
triggered = { eventTrigger: ep.eventTrigger };
|
|
118
292
|
(0, proto_1.renameIfPresent)(triggered.eventTrigger, ep.eventTrigger, "channel", "channel", (c) => resolveChannelName(project, c, defaultRegion));
|
|
119
293
|
for (const [k, v] of Object.entries(triggered.eventTrigger.eventFilters)) {
|
|
@@ -123,9 +297,6 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
123
297
|
}
|
|
124
298
|
}
|
|
125
299
|
else if (backend.isHttpsTriggered(ep)) {
|
|
126
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".httpsTrigger", ep.httpsTrigger, {
|
|
127
|
-
invoker: "array",
|
|
128
|
-
});
|
|
129
300
|
triggered = { httpsTrigger: {} };
|
|
130
301
|
(0, proto_1.copyIfPresent)(triggered.httpsTrigger, ep.httpsTrigger, "invoker");
|
|
131
302
|
}
|
|
@@ -133,49 +304,12 @@ function parseEndpoints(manifest, id, project, defaultRegion, runtime) {
|
|
|
133
304
|
triggered = { callableTrigger: {} };
|
|
134
305
|
}
|
|
135
306
|
else if (backend.isScheduleTriggered(ep)) {
|
|
136
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger", ep.scheduleTrigger, {
|
|
137
|
-
schedule: "string",
|
|
138
|
-
timeZone: "string",
|
|
139
|
-
retryConfig: "object",
|
|
140
|
-
});
|
|
141
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".scheduleTrigger.retryConfig", ep.scheduleTrigger.retryConfig, {
|
|
142
|
-
retryCount: "number",
|
|
143
|
-
maxDoublings: "number",
|
|
144
|
-
minBackoffDuration: "string",
|
|
145
|
-
maxBackoffDuration: "string",
|
|
146
|
-
maxRetryDuration: "string",
|
|
147
|
-
});
|
|
148
307
|
triggered = { scheduleTrigger: ep.scheduleTrigger };
|
|
149
308
|
}
|
|
150
309
|
else if (backend.isTaskQueueTriggered(ep)) {
|
|
151
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger", ep.taskQueueTrigger, {
|
|
152
|
-
rateLimits: "object",
|
|
153
|
-
retryConfig: "object",
|
|
154
|
-
invoker: "array",
|
|
155
|
-
});
|
|
156
|
-
if (ep.taskQueueTrigger.rateLimits) {
|
|
157
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.rateLimits", ep.taskQueueTrigger.rateLimits, {
|
|
158
|
-
maxConcurrentDispatches: "number",
|
|
159
|
-
maxDispatchesPerSecond: "number",
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
if (ep.taskQueueTrigger.retryConfig) {
|
|
163
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".taskQueueTrigger.retryConfig", ep.taskQueueTrigger.retryConfig, {
|
|
164
|
-
maxAttempts: "number",
|
|
165
|
-
maxRetrySeconds: "number",
|
|
166
|
-
minBackoffSeconds: "number",
|
|
167
|
-
maxBackoffSeconds: "number",
|
|
168
|
-
maxDoublings: "number",
|
|
169
|
-
});
|
|
170
|
-
}
|
|
171
310
|
triggered = { taskQueueTrigger: ep.taskQueueTrigger };
|
|
172
311
|
}
|
|
173
312
|
else if (backend.isBlockingTriggered(ep)) {
|
|
174
|
-
(0, parsing_1.requireKeys)(prefix + ".blockingTrigger", ep.blockingTrigger, "eventType");
|
|
175
|
-
(0, parsing_1.assertKeyTypes)(prefix + ".blockingTrigger", ep.blockingTrigger, {
|
|
176
|
-
eventType: "string",
|
|
177
|
-
options: "object",
|
|
178
|
-
});
|
|
179
313
|
triggered = { blockingTrigger: ep.blockingTrigger };
|
|
180
314
|
}
|
|
181
315
|
else {
|
|
@@ -5,11 +5,9 @@ const util_1 = require("util");
|
|
|
5
5
|
const node_fetch_1 = require("node-fetch");
|
|
6
6
|
const fs = require("fs");
|
|
7
7
|
const path = require("path");
|
|
8
|
-
const portfinder = require("portfinder");
|
|
9
8
|
const spawn = require("cross-spawn");
|
|
10
9
|
const error_1 = require("../../../../error");
|
|
11
10
|
const logger_1 = require("../../../../logger");
|
|
12
|
-
const discovery = require("../discovery");
|
|
13
11
|
const gomod = require("./gomod");
|
|
14
12
|
const VERSION_TO_RUNTIME = {
|
|
15
13
|
"1.13": "go113",
|
|
@@ -105,26 +103,8 @@ class Delegate {
|
|
|
105
103
|
return p;
|
|
106
104
|
});
|
|
107
105
|
}
|
|
108
|
-
async discoverBuild(
|
|
109
|
-
return { requiredAPIs: [], endpoints: {}, params: [] };
|
|
110
|
-
}
|
|
111
|
-
async discoverSpec(configValues, envs) {
|
|
112
|
-
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
113
|
-
if (!discovered) {
|
|
114
|
-
const getPort = (0, util_1.promisify)(portfinder.getPort);
|
|
115
|
-
const port = await getPort();
|
|
116
|
-
portfinder.basePort = port + 1;
|
|
117
|
-
const adminPort = await getPort();
|
|
118
|
-
const kill = await this.serve(port, adminPort, envs);
|
|
119
|
-
try {
|
|
120
|
-
discovered = await discovery.detectFromPort(adminPort, this.projectId, this.runtime);
|
|
121
|
-
}
|
|
122
|
-
finally {
|
|
123
|
-
await kill();
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
discovered.environmentVariables = envs;
|
|
127
|
-
return discovered;
|
|
106
|
+
async discoverBuild() {
|
|
107
|
+
return Promise.resolve({ requiredAPIs: [], endpoints: {}, params: [] });
|
|
128
108
|
}
|
|
129
109
|
}
|
|
130
110
|
exports.Delegate = Delegate;
|
|
@@ -85,15 +85,15 @@ class Delegate {
|
|
|
85
85
|
return p;
|
|
86
86
|
});
|
|
87
87
|
}
|
|
88
|
-
async
|
|
88
|
+
async discoverBuild(config, env) {
|
|
89
89
|
if (!semver.valid(this.sdkVersion)) {
|
|
90
90
|
logger_1.logger.debug(`Could not parse firebase-functions version '${this.sdkVersion}' into semver. Falling back to parseTriggers.`);
|
|
91
|
-
return parseTriggers.
|
|
91
|
+
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
92
92
|
}
|
|
93
93
|
if (semver.lt(this.sdkVersion, MIN_FUNCTIONS_SDK_VERSION)) {
|
|
94
94
|
(0, utils_1.logLabeledWarning)("functions", `You are using an old version of firebase-functions SDK (${this.sdkVersion}). ` +
|
|
95
95
|
`Please update firebase-functions SDK to >=${MIN_FUNCTIONS_SDK_VERSION}`);
|
|
96
|
-
return parseTriggers.
|
|
96
|
+
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
97
97
|
}
|
|
98
98
|
let discovered = await discovery.detectFromYaml(this.sourceDir, this.projectId, this.runtime);
|
|
99
99
|
if (!discovered) {
|
|
@@ -107,11 +107,7 @@ class Delegate {
|
|
|
107
107
|
await kill();
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
discovered.environmentVariables = env;
|
|
111
110
|
return discovered;
|
|
112
111
|
}
|
|
113
|
-
async discoverBuild(config, env) {
|
|
114
|
-
return parseTriggers.discoverBuild(this.projectId, this.sourceDir, this.runtime, config, env);
|
|
115
|
-
}
|
|
116
112
|
}
|
|
117
113
|
exports.Delegate = Delegate;
|
|
@@ -45,7 +45,7 @@ function parseTriggers(projectId, sourceDir, configValues, envs) {
|
|
|
45
45
|
});
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
function useStrategy(
|
|
48
|
+
function useStrategy() {
|
|
49
49
|
return Promise.resolve(true);
|
|
50
50
|
}
|
|
51
51
|
exports.useStrategy = useStrategy;
|
|
@@ -139,10 +139,22 @@ function addResourcesToBuild(projectId, runtime, annotation, want) {
|
|
|
139
139
|
triggered = {
|
|
140
140
|
scheduleTrigger: {
|
|
141
141
|
schedule: annotation.schedule.schedule,
|
|
142
|
-
timeZone: annotation.schedule.timeZone || "
|
|
143
|
-
retryConfig:
|
|
142
|
+
timeZone: annotation.schedule.timeZone || "America/Los_Angeles",
|
|
143
|
+
retryConfig: {},
|
|
144
144
|
},
|
|
145
145
|
};
|
|
146
|
+
if (annotation.schedule.retryConfig) {
|
|
147
|
+
if (annotation.schedule.retryConfig.maxBackoffDuration) {
|
|
148
|
+
triggered.scheduleTrigger.retryConfig.maxBackoffSeconds = proto.secondsFromDuration(annotation.schedule.retryConfig.maxBackoffDuration);
|
|
149
|
+
}
|
|
150
|
+
if (annotation.schedule.retryConfig.minBackoffDuration) {
|
|
151
|
+
triggered.scheduleTrigger.retryConfig.minBackoffSeconds = proto.secondsFromDuration(annotation.schedule.retryConfig.minBackoffDuration);
|
|
152
|
+
}
|
|
153
|
+
if (annotation.schedule.retryConfig.maxRetryDuration) {
|
|
154
|
+
triggered.scheduleTrigger.retryConfig.maxRetrySeconds = proto.secondsFromDuration(annotation.schedule.retryConfig.maxRetryDuration);
|
|
155
|
+
}
|
|
156
|
+
proto.copyIfPresent(triggered.scheduleTrigger.retryConfig, annotation.schedule.retryConfig, "maxDoublings", "retryCount");
|
|
157
|
+
}
|
|
146
158
|
}
|
|
147
159
|
else if (annotation.blockingTrigger) {
|
|
148
160
|
if (events.v1.AUTH_BLOCKING_EVENTS.includes(annotation.blockingTrigger.eventType)) {
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ensureDatabaseTriggerRegion = void 0;
|
|
4
|
+
const error_1 = require("../../../error");
|
|
5
|
+
function ensureDatabaseTriggerRegion(endpoint) {
|
|
6
|
+
if (!endpoint.eventTrigger.region) {
|
|
7
|
+
endpoint.eventTrigger.region = endpoint.region;
|
|
8
|
+
}
|
|
9
|
+
if (endpoint.eventTrigger.region !== endpoint.region) {
|
|
10
|
+
throw new error_1.FirebaseError("A database trigger location must match the function region.");
|
|
11
|
+
}
|
|
12
|
+
return Promise.resolve();
|
|
13
|
+
}
|
|
14
|
+
exports.ensureDatabaseTriggerRegion = ensureDatabaseTriggerRegion;
|
|
@@ -5,6 +5,7 @@ const backend = require("../backend");
|
|
|
5
5
|
const auth_1 = require("./auth");
|
|
6
6
|
const storage_1 = require("./storage");
|
|
7
7
|
const firebaseAlerts_1 = require("./firebaseAlerts");
|
|
8
|
+
const database_1 = require("./database");
|
|
8
9
|
const noop = () => Promise.resolve();
|
|
9
10
|
exports.noop = noop;
|
|
10
11
|
const noopProjectBindings = () => Promise.resolve([]);
|
|
@@ -45,6 +46,15 @@ const firebaseAlertsService = {
|
|
|
45
46
|
unregisterTrigger: exports.noop,
|
|
46
47
|
};
|
|
47
48
|
const authBlockingService = new auth_1.AuthBlockingService();
|
|
49
|
+
const databaseService = {
|
|
50
|
+
name: "database",
|
|
51
|
+
api: "firebasedatabase.googleapis.com",
|
|
52
|
+
requiredProjectBindings: exports.noopProjectBindings,
|
|
53
|
+
ensureTriggerRegion: database_1.ensureDatabaseTriggerRegion,
|
|
54
|
+
validateTrigger: exports.noop,
|
|
55
|
+
registerTrigger: exports.noop,
|
|
56
|
+
unregisterTrigger: exports.noop,
|
|
57
|
+
};
|
|
48
58
|
const EVENT_SERVICE_MAPPING = {
|
|
49
59
|
"google.cloud.pubsub.topic.v1.messagePublished": pubSubService,
|
|
50
60
|
"google.cloud.storage.object.v1.finalized": storageService,
|
|
@@ -54,6 +64,10 @@ const EVENT_SERVICE_MAPPING = {
|
|
|
54
64
|
"google.firebase.firebasealerts.alerts.v1.published": firebaseAlertsService,
|
|
55
65
|
"providers/cloud.auth/eventTypes/user.beforeCreate": authBlockingService,
|
|
56
66
|
"providers/cloud.auth/eventTypes/user.beforeSignIn": authBlockingService,
|
|
67
|
+
"google.firebase.database.ref.v1.written": databaseService,
|
|
68
|
+
"google.firebase.database.ref.v1.created": databaseService,
|
|
69
|
+
"google.firebase.database.ref.v1.updated": databaseService,
|
|
70
|
+
"google.firebase.database.ref.v1.deleted": databaseService,
|
|
57
71
|
};
|
|
58
72
|
function serviceForEndpoint(endpoint) {
|
|
59
73
|
if (backend.isEventTriggered(endpoint)) {
|
package/lib/deploy/index.js
CHANGED
|
@@ -9,7 +9,7 @@ const projectUtils_1 = require("../projectUtils");
|
|
|
9
9
|
const utils_1 = require("../utils");
|
|
10
10
|
const error_1 = require("../error");
|
|
11
11
|
const track_1 = require("../track");
|
|
12
|
-
const
|
|
12
|
+
const lifecycleHooks_1 = require("./lifecycleHooks");
|
|
13
13
|
const previews_1 = require("../previews");
|
|
14
14
|
const HostingTarget = require("./hosting");
|
|
15
15
|
const DatabaseTarget = require("./database");
|
|
@@ -54,11 +54,11 @@ const deploy = async function (targetNames, options, customContext = {}) {
|
|
|
54
54
|
if (!target) {
|
|
55
55
|
return Promise.reject(new error_1.FirebaseError((0, cli_color_1.bold)(targetName) + " is not a valid deploy target", { exit: 1 }));
|
|
56
56
|
}
|
|
57
|
-
predeploys.push(lifecycleHooks(targetName, "predeploy"));
|
|
57
|
+
predeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "predeploy"));
|
|
58
58
|
prepares.push(target.prepare);
|
|
59
59
|
deploys.push(target.deploy);
|
|
60
60
|
releases.push(target.release);
|
|
61
|
-
postdeploys.push(lifecycleHooks(targetName, "postdeploy"));
|
|
61
|
+
postdeploys.push((0, lifecycleHooks_1.lifecycleHooks)(targetName, "postdeploy"));
|
|
62
62
|
}
|
|
63
63
|
logger_1.logger.info();
|
|
64
64
|
logger_1.logger.info((0, cli_color_1.bold)((0, cli_color_1.white)("===") + " Deploying to '" + projectId + "'..."));
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.lifecycleHooks = void 0;
|
|
3
4
|
const utils = require("../utils");
|
|
4
5
|
const clc = require("cli-color");
|
|
5
6
|
const childProcess = require("child_process");
|
|
6
|
-
const
|
|
7
|
+
const error_1 = require("../error");
|
|
7
8
|
const needProjectId = require("../projectUtils").needProjectId;
|
|
8
|
-
const
|
|
9
|
+
const logger_1 = require("../logger");
|
|
9
10
|
const path = require("path");
|
|
10
11
|
function runCommand(command, childOptions) {
|
|
11
12
|
const escapedCommand = command.replace(/\"/g, '\\"');
|
|
@@ -16,16 +17,16 @@ function runCommand(command, childOptions) {
|
|
|
16
17
|
'" "' +
|
|
17
18
|
escapedCommand +
|
|
18
19
|
'"';
|
|
19
|
-
return new Promise(
|
|
20
|
-
logger.info("Running command: " + command);
|
|
20
|
+
return new Promise((resolve, reject) => {
|
|
21
|
+
logger_1.logger.info("Running command: " + command);
|
|
21
22
|
if (translatedCommand === "") {
|
|
22
|
-
resolve();
|
|
23
|
+
return resolve();
|
|
23
24
|
}
|
|
24
25
|
const child = childProcess.spawn(translatedCommand, [], childOptions);
|
|
25
|
-
child.on("error",
|
|
26
|
+
child.on("error", (err) => {
|
|
26
27
|
reject(err);
|
|
27
28
|
});
|
|
28
|
-
child.on("exit",
|
|
29
|
+
child.on("exit", (code, signal) => {
|
|
29
30
|
if (signal) {
|
|
30
31
|
reject(new Error("Command terminated with signal " + signal));
|
|
31
32
|
}
|
|
@@ -52,7 +53,7 @@ function getChildEnvironment(target, overallOptions, config) {
|
|
|
52
53
|
default:
|
|
53
54
|
resourceDir = overallOptions.config.path(overallOptions.config.projectDir);
|
|
54
55
|
}
|
|
55
|
-
return
|
|
56
|
+
return Object.assign({}, process.env, {
|
|
56
57
|
GCLOUD_PROJECT: projectId,
|
|
57
58
|
PROJECT_DIR: projectDir,
|
|
58
59
|
RESOURCE_DIR: resourceDir,
|
|
@@ -72,21 +73,19 @@ function runTargetCommands(target, hook, overallOptions, config) {
|
|
|
72
73
|
shell: true,
|
|
73
74
|
stdio: [0, 1, 2],
|
|
74
75
|
};
|
|
75
|
-
const runAllCommands =
|
|
76
|
-
return soFar.then(
|
|
77
|
-
return runCommand(command, childOptions);
|
|
78
|
-
});
|
|
76
|
+
const runAllCommands = commands.reduce((soFar, command) => {
|
|
77
|
+
return soFar.then(() => runCommand(command, childOptions));
|
|
79
78
|
}, Promise.resolve());
|
|
80
79
|
let logIdentifier = target;
|
|
81
80
|
if (config.target) {
|
|
82
81
|
logIdentifier += `[${config.target}]`;
|
|
83
82
|
}
|
|
84
83
|
return runAllCommands
|
|
85
|
-
.then(
|
|
84
|
+
.then(() => {
|
|
86
85
|
utils.logSuccess(clc.green.bold(logIdentifier + ":") + " Finished running " + clc.bold(hook) + " script.");
|
|
87
86
|
})
|
|
88
|
-
.catch(
|
|
89
|
-
throw new FirebaseError(logIdentifier + " " + hook + " error: " + err.message);
|
|
87
|
+
.catch((err) => {
|
|
88
|
+
throw new error_1.FirebaseError(logIdentifier + " " + hook + " error: " + err.message);
|
|
90
89
|
});
|
|
91
90
|
}
|
|
92
91
|
function getReleventConfigs(target, options) {
|
|
@@ -94,33 +93,34 @@ function getReleventConfigs(target, options) {
|
|
|
94
93
|
if (!targetConfigs) {
|
|
95
94
|
return [];
|
|
96
95
|
}
|
|
97
|
-
if (!
|
|
96
|
+
if (!Array.isArray(targetConfigs)) {
|
|
98
97
|
targetConfigs = [targetConfigs];
|
|
99
98
|
}
|
|
100
99
|
if (!options.only) {
|
|
101
100
|
return targetConfigs;
|
|
102
101
|
}
|
|
103
|
-
|
|
104
|
-
if (
|
|
102
|
+
let onlyTargets = options.only.split(",");
|
|
103
|
+
if (onlyTargets.includes(target)) {
|
|
105
104
|
return targetConfigs;
|
|
106
105
|
}
|
|
107
106
|
onlyTargets = onlyTargets
|
|
108
|
-
.filter(
|
|
107
|
+
.filter((individualOnly) => {
|
|
109
108
|
return individualOnly.indexOf(`${target}:`) === 0;
|
|
110
109
|
})
|
|
111
|
-
.map(
|
|
110
|
+
.map((individualOnly) => {
|
|
112
111
|
return individualOnly.replace(`${target}:`, "");
|
|
113
112
|
});
|
|
114
|
-
return targetConfigs.filter(
|
|
115
|
-
return !config.target ||
|
|
113
|
+
return targetConfigs.filter((config) => {
|
|
114
|
+
return !config.target || onlyTargets.includes(config.target);
|
|
116
115
|
});
|
|
117
116
|
}
|
|
118
|
-
|
|
117
|
+
function lifecycleHooks(target, hook) {
|
|
119
118
|
return function (context, options) {
|
|
120
|
-
return
|
|
121
|
-
return previousCommands.then(
|
|
119
|
+
return getReleventConfigs(target, options).reduce((previousCommands, individualConfig) => {
|
|
120
|
+
return previousCommands.then(() => {
|
|
122
121
|
return runTargetCommands(target, hook, options, individualConfig);
|
|
123
122
|
});
|
|
124
123
|
}, Promise.resolve());
|
|
125
124
|
};
|
|
126
|
-
}
|
|
125
|
+
}
|
|
126
|
+
exports.lifecycleHooks = lifecycleHooks;
|
|
@@ -1,21 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.publishTemplate = exports.deployTemplate = exports.validateInputRemoteConfigTemplate = exports.getEtag = void 0;
|
|
4
|
+
const api_1 = require("../../api");
|
|
5
|
+
const apiv2_1 = require("../../apiv2");
|
|
4
6
|
const error_1 = require("../../error");
|
|
5
|
-
const api = require("../../api");
|
|
6
7
|
const TIMEOUT = 30000;
|
|
8
|
+
const client = new apiv2_1.Client({ urlPrefix: api_1.remoteConfigApiOrigin, apiVersion: "v1" });
|
|
7
9
|
async function getEtag(projectNumber, versionNumber) {
|
|
8
|
-
|
|
10
|
+
const reqPath = `/projects/${projectNumber}/remoteConfig`;
|
|
11
|
+
const queryParams = {};
|
|
9
12
|
if (versionNumber) {
|
|
10
|
-
|
|
13
|
+
queryParams.versionNumber = versionNumber;
|
|
11
14
|
}
|
|
12
|
-
const response = await
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
const response = await client.request({
|
|
16
|
+
method: "GET",
|
|
17
|
+
path: reqPath,
|
|
18
|
+
queryParams,
|
|
16
19
|
headers: { "Accept-Encoding": "gzip" },
|
|
20
|
+
timeout: TIMEOUT,
|
|
17
21
|
});
|
|
18
|
-
return response.response.headers.etag;
|
|
22
|
+
return response.response.headers.get("etag") || "";
|
|
19
23
|
}
|
|
20
24
|
exports.getEtag = getEtag;
|
|
21
25
|
function validateInputRemoteConfigTemplate(template) {
|
|
@@ -33,20 +37,20 @@ function validateInputRemoteConfigTemplate(template) {
|
|
|
33
37
|
}
|
|
34
38
|
exports.validateInputRemoteConfigTemplate = validateInputRemoteConfigTemplate;
|
|
35
39
|
async function deployTemplate(projectNumber, template, etag, options) {
|
|
36
|
-
const reqPath = `/
|
|
40
|
+
const reqPath = `/projects/${projectNumber}/remoteConfig`;
|
|
37
41
|
if (options === null || options === void 0 ? void 0 : options.force) {
|
|
38
42
|
etag = "*";
|
|
39
43
|
}
|
|
40
|
-
const response = await
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
timeout: TIMEOUT,
|
|
44
|
+
const response = await client.request({
|
|
45
|
+
method: "PUT",
|
|
46
|
+
path: reqPath,
|
|
44
47
|
headers: { "If-Match": etag },
|
|
45
|
-
|
|
48
|
+
body: {
|
|
46
49
|
conditions: template.conditions,
|
|
47
50
|
parameters: template.parameters,
|
|
48
51
|
parameterGroups: template.parameterGroups,
|
|
49
52
|
},
|
|
53
|
+
timeout: TIMEOUT,
|
|
50
54
|
});
|
|
51
55
|
return response.body;
|
|
52
56
|
}
|