firebase-tools 10.1.0 → 10.1.4
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 +9 -8
- package/lib/accountImporter.js +10 -8
- package/lib/apiv2.js +91 -48
- package/lib/archiveDirectory.js +63 -73
- package/lib/bin/firebase.js +1 -1
- package/lib/commands/auth-export.js +26 -25
- package/lib/commands/auth-import.js +88 -78
- package/lib/commands/ext-configure.js +1 -1
- package/lib/commands/ext-dev-init.js +1 -1
- package/lib/commands/ext-dev-publish.js +1 -1
- package/lib/commands/ext-dev-register.js +1 -1
- package/lib/commands/ext-dev-usage.js +3 -8
- package/lib/commands/ext-info.js +1 -1
- package/lib/commands/ext-install.js +1 -1
- package/lib/commands/ext-uninstall.js +1 -1
- package/lib/commands/ext-update.js +1 -1
- package/lib/commands/functions-config-clone.js +22 -23
- package/lib/commands/functions-config-get.js +22 -22
- package/lib/commands/functions-config-set.js +24 -22
- package/lib/commands/functions-config-unset.js +20 -22
- package/lib/commands/help.js +12 -12
- package/lib/commands/hosting-channel-create.js +1 -1
- package/lib/commands/hosting-channel-delete.js +2 -2
- package/lib/commands/hosting-channel-deploy.js +1 -1
- package/lib/commands/hosting-clone.js +1 -1
- package/lib/commands/login-ci.js +10 -10
- package/lib/commands/remoteconfig-versions-list.js +6 -1
- package/lib/commands/setup-emulators-database.js +8 -7
- package/lib/commands/setup-emulators-firestore.js +8 -7
- package/lib/commands/setup-emulators-pubsub.js +5 -4
- package/lib/commands/setup-emulators-storage.js +3 -2
- package/lib/commands/setup-emulators-ui.js +8 -7
- package/lib/commands/target-apply.js +17 -16
- package/lib/commands/target-clear.js +11 -10
- package/lib/commands/target-remove.js +10 -9
- package/lib/commands/target.js +20 -20
- package/lib/database/metadata.js +16 -24
- package/lib/defaultCredentials.js +3 -3
- package/lib/deploy/functions/backend.js +3 -1
- package/lib/deploy/functions/prepare.js +17 -11
- package/lib/deploy/functions/release/fabricator.js +4 -1
- package/lib/deploy/functions/runtimes/golang/index.js +6 -9
- package/lib/deploy/functions/runtimes/index.js +6 -10
- package/lib/deploy/functions/runtimes/node/index.js +5 -9
- package/lib/deploy/functions/runtimes/node/validate.js +2 -1
- package/lib/deploy/functions/validate.js +32 -4
- package/lib/deploy/hosting/convertConfig.js +45 -24
- package/lib/deploy/hosting/prepare.js +1 -1
- package/lib/emulator/auth/widget_ui.js +1 -1
- package/lib/emulator/downloadableEmulators.js +3 -2
- package/lib/emulator/functionsEmulator.js +9 -1
- package/lib/emulator/functionsEmulatorRuntime.js +4 -4
- package/lib/emulator/storage/apis/gcloud.js +2 -2
- package/lib/emulator/storage/files.js +8 -3
- package/lib/emulator/storage/rules/runtime.js +5 -4
- package/lib/extensions/askUserForConsent.js +1 -1
- package/lib/extensions/askUserForParam.js +1 -1
- package/lib/extensions/billingMigrationHelper.js +1 -1
- package/lib/extensions/changelog.js +1 -1
- package/lib/extensions/displayExtensionInfo.js +1 -1
- package/lib/extensions/extensionsApi.js +57 -112
- package/lib/extensions/extensionsHelper.js +19 -15
- package/lib/extensions/provisioningHelper.js +7 -10
- package/lib/extensions/resolveSource.js +5 -5
- package/lib/extensions/updateHelper.js +1 -1
- package/lib/extensions/warnings.js +1 -1
- package/lib/functionsConfig.js +4 -5
- package/lib/gcp/cloudbilling.js +8 -19
- package/lib/gcp/cloudfunctions.js +22 -46
- package/lib/gcp/cloudlogging.js +8 -11
- package/lib/gcp/cloudmonitoring.js +8 -5
- package/lib/gcp/cloudscheduler.js +7 -18
- package/lib/gcp/firedata.js +5 -4
- package/lib/gcp/firestore.js +5 -5
- package/lib/gcp/iam.js +18 -33
- package/lib/gcp/resourceManager.js +8 -13
- package/lib/gcp/rules.js +18 -41
- package/lib/gcp/runtimeconfig.js +31 -53
- package/lib/gcp/secretManager.js +21 -43
- package/lib/gcp/storage.js +25 -29
- package/lib/projectUtils.js +1 -1
- package/lib/remoteconfig/get.js +14 -8
- package/lib/remoteconfig/rollback.js +13 -6
- package/lib/remoteconfig/versionslist.js +13 -7
- package/npm-shrinkwrap.json +1439 -2295
- package/package.json +16 -11
- package/schema/firebase-config.json +387 -12
- package/standalone/firepit.js +4 -4
- package/templates/init/hosting/index.html +1 -1
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getExtension = exports.deleteExtension = exports.unpublishExtension = exports.publishExtensionVersion = exports.undeprecateExtensionVersion = exports.deprecateExtensionVersion = exports.registerPublisherProfile = exports.getPublisherProfile = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = exports.ParamType = exports.Visibility = exports.RegistryLaunchStage = void 0;
|
|
4
4
|
const yaml = require("js-yaml");
|
|
5
|
-
const _ = require("lodash");
|
|
6
5
|
const clc = require("cli-color");
|
|
7
|
-
const marked = require("marked");
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
const
|
|
6
|
+
const { marked } = require("marked");
|
|
7
|
+
const apiv2_1 = require("../apiv2");
|
|
8
|
+
const api_1 = require("../api");
|
|
9
|
+
const error_1 = require("../error");
|
|
11
10
|
const logger_1 = require("../logger");
|
|
12
11
|
const operationPoller = require("../operation-poller");
|
|
13
|
-
const
|
|
12
|
+
const refs = require("./refs");
|
|
14
13
|
const VERSION = "v1beta";
|
|
15
14
|
const PAGE_SIZE_MAX = 100;
|
|
15
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsOrigin, apiVersion: VERSION });
|
|
16
16
|
var RegistryLaunchStage;
|
|
17
17
|
(function (RegistryLaunchStage) {
|
|
18
18
|
RegistryLaunchStage["EXPERIMENTAL"] = "EXPERIMENTAL";
|
|
@@ -34,22 +34,19 @@ var ParamType;
|
|
|
34
34
|
ParamType["SECRET"] = "SECRET";
|
|
35
35
|
})(ParamType = exports.ParamType || (exports.ParamType = {}));
|
|
36
36
|
async function createInstanceHelper(projectId, instanceId, config, validateOnly = false) {
|
|
37
|
-
const createRes = await
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
},
|
|
44
|
-
query: {
|
|
45
|
-
validateOnly,
|
|
37
|
+
const createRes = await apiClient.post(`/projects/${projectId}/instances/`, {
|
|
38
|
+
name: `projects/${projectId}/instances/${instanceId}`,
|
|
39
|
+
config,
|
|
40
|
+
}, {
|
|
41
|
+
queryParams: {
|
|
42
|
+
validateOnly: validateOnly ? "true" : "false",
|
|
46
43
|
},
|
|
47
44
|
});
|
|
48
45
|
if (validateOnly) {
|
|
49
|
-
return createRes;
|
|
46
|
+
return createRes.body;
|
|
50
47
|
}
|
|
51
48
|
const pollRes = await operationPoller.pollOperation({
|
|
52
|
-
apiOrigin:
|
|
49
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
53
50
|
apiVersion: VERSION,
|
|
54
51
|
operationResourceName: createRes.body.name,
|
|
55
52
|
masterTimeout: 600000,
|
|
@@ -79,12 +76,9 @@ async function createInstance(args) {
|
|
|
79
76
|
}
|
|
80
77
|
exports.createInstance = createInstance;
|
|
81
78
|
async function deleteInstance(projectId, instanceId) {
|
|
82
|
-
const deleteRes = await
|
|
83
|
-
auth: true,
|
|
84
|
-
origin: api.extensionsOrigin,
|
|
85
|
-
});
|
|
79
|
+
const deleteRes = await apiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
|
|
86
80
|
const pollRes = await operationPoller.pollOperation({
|
|
87
|
-
apiOrigin:
|
|
81
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
88
82
|
apiVersion: VERSION,
|
|
89
83
|
operationResourceName: deleteRes.body.name,
|
|
90
84
|
masterTimeout: 600000,
|
|
@@ -92,21 +86,16 @@ async function deleteInstance(projectId, instanceId) {
|
|
|
92
86
|
return pollRes;
|
|
93
87
|
}
|
|
94
88
|
exports.deleteInstance = deleteInstance;
|
|
95
|
-
async function getInstance(projectId, instanceId
|
|
96
|
-
const res = await
|
|
97
|
-
auth: true,
|
|
98
|
-
origin: api.extensionsOrigin,
|
|
99
|
-
}, options));
|
|
89
|
+
async function getInstance(projectId, instanceId) {
|
|
90
|
+
const res = await apiClient.get(`/projects/${projectId}/instances/${instanceId}`);
|
|
100
91
|
return res.body;
|
|
101
92
|
}
|
|
102
93
|
exports.getInstance = getInstance;
|
|
103
94
|
async function listInstances(projectId) {
|
|
104
95
|
const instances = [];
|
|
105
|
-
const getNextPage = async (pageToken) => {
|
|
106
|
-
const res = await
|
|
107
|
-
|
|
108
|
-
origin: api.extensionsOrigin,
|
|
109
|
-
query: {
|
|
96
|
+
const getNextPage = async (pageToken = "") => {
|
|
97
|
+
const res = await apiClient.get(`/projects/${projectId}/instances`, {
|
|
98
|
+
queryParams: {
|
|
110
99
|
pageSize: PAGE_SIZE_MAX,
|
|
111
100
|
pageToken,
|
|
112
101
|
},
|
|
@@ -183,20 +172,17 @@ async function updateInstanceFromRegistry(args) {
|
|
|
183
172
|
}
|
|
184
173
|
exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
|
|
185
174
|
async function patchInstance(args) {
|
|
186
|
-
const updateRes = await
|
|
187
|
-
|
|
188
|
-
origin: api.extensionsOrigin,
|
|
189
|
-
query: {
|
|
175
|
+
const updateRes = await apiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
|
|
176
|
+
queryParams: {
|
|
190
177
|
updateMask: args.updateMask,
|
|
191
|
-
validateOnly: args.validateOnly,
|
|
178
|
+
validateOnly: args.validateOnly ? "true" : "false",
|
|
192
179
|
},
|
|
193
|
-
data: args.data,
|
|
194
180
|
});
|
|
195
181
|
if (args.validateOnly) {
|
|
196
182
|
return updateRes;
|
|
197
183
|
}
|
|
198
184
|
const pollRes = await operationPoller.pollOperation({
|
|
199
|
-
apiOrigin:
|
|
185
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
200
186
|
apiVersion: VERSION,
|
|
201
187
|
operationResourceName: updateRes.body.name,
|
|
202
188
|
masterTimeout: 600000,
|
|
@@ -218,16 +204,12 @@ function populateResourceProperties(spec) {
|
|
|
218
204
|
}
|
|
219
205
|
}
|
|
220
206
|
async function createSource(projectId, packageUri, extensionRoot) {
|
|
221
|
-
const createRes = await
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
data: {
|
|
225
|
-
packageUri,
|
|
226
|
-
extensionRoot,
|
|
227
|
-
},
|
|
207
|
+
const createRes = await apiClient.post(`/projects/${projectId}/sources/`, {
|
|
208
|
+
packageUri,
|
|
209
|
+
extensionRoot,
|
|
228
210
|
});
|
|
229
211
|
const pollRes = await operationPoller.pollOperation({
|
|
230
|
-
apiOrigin:
|
|
212
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
231
213
|
apiVersion: VERSION,
|
|
232
214
|
operationResourceName: createRes.body.name,
|
|
233
215
|
masterTimeout: 600000,
|
|
@@ -238,18 +220,12 @@ async function createSource(projectId, packageUri, extensionRoot) {
|
|
|
238
220
|
return pollRes;
|
|
239
221
|
}
|
|
240
222
|
exports.createSource = createSource;
|
|
241
|
-
function getSource(sourceName) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
.then((res) => {
|
|
248
|
-
if (res.body.spec) {
|
|
249
|
-
populateResourceProperties(res.body.spec);
|
|
250
|
-
}
|
|
251
|
-
return res.body;
|
|
252
|
-
});
|
|
223
|
+
async function getSource(sourceName) {
|
|
224
|
+
const res = await apiClient.get(`/${sourceName}`);
|
|
225
|
+
if (res.body.spec) {
|
|
226
|
+
populateResourceProperties(res.body.spec);
|
|
227
|
+
}
|
|
228
|
+
return res.body;
|
|
253
229
|
}
|
|
254
230
|
exports.getSource = getSource;
|
|
255
231
|
async function getExtensionVersion(extensionVersionRef) {
|
|
@@ -258,10 +234,7 @@ async function getExtensionVersion(extensionVersionRef) {
|
|
|
258
234
|
throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
|
|
259
235
|
}
|
|
260
236
|
try {
|
|
261
|
-
const res = await
|
|
262
|
-
auth: true,
|
|
263
|
-
origin: api.extensionsOrigin,
|
|
264
|
-
});
|
|
237
|
+
const res = await apiClient.get(`/${refs.toExtensionVersionName(ref)}`);
|
|
265
238
|
if (res.body.spec) {
|
|
266
239
|
populateResourceProperties(res.body.spec);
|
|
267
240
|
}
|
|
@@ -280,12 +253,9 @@ async function getExtensionVersion(extensionVersionRef) {
|
|
|
280
253
|
exports.getExtensionVersion = getExtensionVersion;
|
|
281
254
|
async function listExtensions(publisherId) {
|
|
282
255
|
const extensions = [];
|
|
283
|
-
const getNextPage = async (pageToken) => {
|
|
284
|
-
const res = await
|
|
285
|
-
|
|
286
|
-
origin: api.extensionsOrigin,
|
|
287
|
-
showUnpublished: false,
|
|
288
|
-
query: {
|
|
256
|
+
const getNextPage = async (pageToken = "") => {
|
|
257
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions`, {
|
|
258
|
+
queryParams: {
|
|
289
259
|
pageSize: PAGE_SIZE_MAX,
|
|
290
260
|
pageToken,
|
|
291
261
|
},
|
|
@@ -301,14 +271,12 @@ async function listExtensions(publisherId) {
|
|
|
301
271
|
return extensions;
|
|
302
272
|
}
|
|
303
273
|
exports.listExtensions = listExtensions;
|
|
304
|
-
async function listExtensionVersions(ref, filter) {
|
|
274
|
+
async function listExtensionVersions(ref, filter = "") {
|
|
305
275
|
const { publisherId, extensionId } = refs.parse(ref);
|
|
306
276
|
const extensionVersions = [];
|
|
307
|
-
const getNextPage = async (pageToken) => {
|
|
308
|
-
const res = await
|
|
309
|
-
|
|
310
|
-
origin: api.extensionsOrigin,
|
|
311
|
-
query: {
|
|
277
|
+
const getNextPage = async (pageToken = "") => {
|
|
278
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
|
|
279
|
+
queryParams: {
|
|
312
280
|
filter,
|
|
313
281
|
pageSize: PAGE_SIZE_MAX,
|
|
314
282
|
pageToken,
|
|
@@ -326,8 +294,7 @@ async function listExtensionVersions(ref, filter) {
|
|
|
326
294
|
}
|
|
327
295
|
exports.listExtensionVersions = listExtensionVersions;
|
|
328
296
|
async function getPublisherProfile(projectId, publisherId) {
|
|
329
|
-
const
|
|
330
|
-
const res = await client.get(`/${VERSION}/projects/${projectId}/publisherProfile`, {
|
|
297
|
+
const res = await apiClient.get(`/projects/${projectId}/publisherProfile`, {
|
|
331
298
|
queryParams: publisherId == undefined
|
|
332
299
|
? undefined
|
|
333
300
|
: {
|
|
@@ -338,10 +305,8 @@ async function getPublisherProfile(projectId, publisherId) {
|
|
|
338
305
|
}
|
|
339
306
|
exports.getPublisherProfile = getPublisherProfile;
|
|
340
307
|
async function registerPublisherProfile(projectId, publisherId) {
|
|
341
|
-
const res = await
|
|
342
|
-
|
|
343
|
-
origin: api.extensionsOrigin,
|
|
344
|
-
data: { publisherId },
|
|
308
|
+
const res = await apiClient.post(`/projects/${projectId}/publisherProfile:register`, {
|
|
309
|
+
publisherId,
|
|
345
310
|
});
|
|
346
311
|
return res.body;
|
|
347
312
|
}
|
|
@@ -349,10 +314,8 @@ exports.registerPublisherProfile = registerPublisherProfile;
|
|
|
349
314
|
async function deprecateExtensionVersion(extensionRef, deprecationMessage) {
|
|
350
315
|
const ref = refs.parse(extensionRef);
|
|
351
316
|
try {
|
|
352
|
-
const res = await
|
|
353
|
-
|
|
354
|
-
origin: api.extensionsOrigin,
|
|
355
|
-
data: { deprecationMessage },
|
|
317
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:deprecate`, {
|
|
318
|
+
deprecationMessage,
|
|
356
319
|
});
|
|
357
320
|
return res.body;
|
|
358
321
|
}
|
|
@@ -375,10 +338,7 @@ exports.deprecateExtensionVersion = deprecateExtensionVersion;
|
|
|
375
338
|
async function undeprecateExtensionVersion(extensionRef) {
|
|
376
339
|
const ref = refs.parse(extensionRef);
|
|
377
340
|
try {
|
|
378
|
-
const res = await
|
|
379
|
-
auth: true,
|
|
380
|
-
origin: api.extensionsOrigin,
|
|
381
|
-
});
|
|
341
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:undeprecate`);
|
|
382
342
|
return res.body;
|
|
383
343
|
}
|
|
384
344
|
catch (err) {
|
|
@@ -402,17 +362,13 @@ async function publishExtensionVersion(extensionVersionRef, packageUri, extensio
|
|
|
402
362
|
if (!ref.version) {
|
|
403
363
|
throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
|
|
404
364
|
}
|
|
405
|
-
const publishRes = await
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
versionId: ref.version,
|
|
410
|
-
packageUri,
|
|
411
|
-
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
412
|
-
},
|
|
365
|
+
const publishRes = await apiClient.post(`/${refs.toExtensionName(ref)}/versions:publish`, {
|
|
366
|
+
versionId: ref.version,
|
|
367
|
+
packageUri,
|
|
368
|
+
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
413
369
|
});
|
|
414
370
|
const pollRes = await operationPoller.pollOperation({
|
|
415
|
-
apiOrigin:
|
|
371
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
416
372
|
apiVersion: VERSION,
|
|
417
373
|
operationResourceName: publishRes.body.name,
|
|
418
374
|
masterTimeout: 600000,
|
|
@@ -425,12 +381,8 @@ async function unpublishExtension(extensionRef) {
|
|
|
425
381
|
if (ref.version) {
|
|
426
382
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
427
383
|
}
|
|
428
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}:unpublish`;
|
|
429
384
|
try {
|
|
430
|
-
await
|
|
431
|
-
auth: true,
|
|
432
|
-
origin: api.extensionsOrigin,
|
|
433
|
-
});
|
|
385
|
+
await apiClient.post(`/${refs.toExtensionName(ref)}:unpublish`);
|
|
434
386
|
}
|
|
435
387
|
catch (err) {
|
|
436
388
|
if (err.status === 403) {
|
|
@@ -450,12 +402,8 @@ async function deleteExtension(extensionRef) {
|
|
|
450
402
|
if (ref.version) {
|
|
451
403
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
452
404
|
}
|
|
453
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}`;
|
|
454
405
|
try {
|
|
455
|
-
await
|
|
456
|
-
auth: true,
|
|
457
|
-
origin: api.extensionsOrigin,
|
|
458
|
-
});
|
|
406
|
+
await apiClient.delete(`/${refs.toExtensionName(ref)}`);
|
|
459
407
|
}
|
|
460
408
|
catch (err) {
|
|
461
409
|
if (err.status === 403) {
|
|
@@ -476,10 +424,7 @@ exports.deleteExtension = deleteExtension;
|
|
|
476
424
|
async function getExtension(extensionRef) {
|
|
477
425
|
const ref = refs.parse(extensionRef);
|
|
478
426
|
try {
|
|
479
|
-
const res = await
|
|
480
|
-
auth: true,
|
|
481
|
-
origin: api.extensionsOrigin,
|
|
482
|
-
});
|
|
427
|
+
const res = await apiClient.get(`/${refs.toExtensionName(ref)}`);
|
|
483
428
|
return res.body;
|
|
484
429
|
}
|
|
485
430
|
catch (err) {
|
|
@@ -5,7 +5,7 @@ const _ = require("lodash");
|
|
|
5
5
|
const clc = require("cli-color");
|
|
6
6
|
const ora = require("ora");
|
|
7
7
|
const semver = require("semver");
|
|
8
|
-
const marked = require("marked");
|
|
8
|
+
const { marked } = require("marked");
|
|
9
9
|
const TerminalRenderer = require("marked-terminal");
|
|
10
10
|
marked.setOptions({
|
|
11
11
|
renderer: new TerminalRenderer(),
|
|
@@ -68,7 +68,7 @@ exports.resourceTypeToNiceName = {
|
|
|
68
68
|
};
|
|
69
69
|
function getDBInstanceFromURL(databaseUrl = "") {
|
|
70
70
|
const instanceRegex = new RegExp("(?:https://)(.*)(?:.firebaseio.com)");
|
|
71
|
-
const matches =
|
|
71
|
+
const matches = instanceRegex.exec(databaseUrl);
|
|
72
72
|
if (matches && matches.length > 1) {
|
|
73
73
|
return matches[1];
|
|
74
74
|
}
|
|
@@ -348,7 +348,7 @@ async function createSourceFromLocation(projectId, sourceUri) {
|
|
|
348
348
|
let packageUri;
|
|
349
349
|
let extensionRoot;
|
|
350
350
|
let objectPath = "";
|
|
351
|
-
if (!
|
|
351
|
+
if (!sourceUri.startsWith("https:")) {
|
|
352
352
|
const uploadSpinner = ora(" Archiving and uploading extension source code");
|
|
353
353
|
try {
|
|
354
354
|
uploadSpinner.start();
|
|
@@ -442,24 +442,28 @@ async function promptForRepeatInstance(projectName, extensionName) {
|
|
|
442
442
|
}
|
|
443
443
|
exports.promptForRepeatInstance = promptForRepeatInstance;
|
|
444
444
|
async function instanceIdExists(projectId, instanceId) {
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
|
|
449
|
-
if (
|
|
450
|
-
|
|
445
|
+
try {
|
|
446
|
+
await (0, extensionsApi_1.getInstance)(projectId, instanceId);
|
|
447
|
+
}
|
|
448
|
+
catch (err) {
|
|
449
|
+
if (err instanceof error_1.FirebaseError) {
|
|
450
|
+
if (err.status === 404) {
|
|
451
|
+
return false;
|
|
452
|
+
}
|
|
453
|
+
const msg = `Unexpected error when checking if instance ID exists: ${err}`;
|
|
454
|
+
throw new error_1.FirebaseError(msg, {
|
|
455
|
+
original: err,
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
else {
|
|
459
|
+
throw err;
|
|
451
460
|
}
|
|
452
|
-
const msg = "Unexpected error when checking if instance ID exists: " +
|
|
453
|
-
_.get(instanceRes, "error.message");
|
|
454
|
-
throw new error_1.FirebaseError(msg, {
|
|
455
|
-
original: instanceRes.error,
|
|
456
|
-
});
|
|
457
461
|
}
|
|
458
462
|
return true;
|
|
459
463
|
}
|
|
460
464
|
exports.instanceIdExists = instanceIdExists;
|
|
461
465
|
function isUrlPath(extInstallPath) {
|
|
462
|
-
return
|
|
466
|
+
return extInstallPath.startsWith("https:");
|
|
463
467
|
}
|
|
464
468
|
exports.isUrlPath = isUrlPath;
|
|
465
469
|
function isLocalPath(extInstallPath) {
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getUsedProducts = exports.bulkCheckProductsProvisioned = exports.checkProductsProvisioned = exports.DeferredProduct = void 0;
|
|
4
|
-
const marked = require("marked");
|
|
5
|
-
const
|
|
4
|
+
const { marked } = require("marked");
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const apiv2_1 = require("../apiv2");
|
|
6
7
|
const functional_1 = require("../functional");
|
|
7
8
|
const error_1 = require("../error");
|
|
8
9
|
const planner_1 = require("../deploy/extensions/planner");
|
|
@@ -85,10 +86,8 @@ function getTriggerType(propertiesYaml) {
|
|
|
85
86
|
}
|
|
86
87
|
async function isStorageProvisioned(projectId) {
|
|
87
88
|
var _a, _b;
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
origin: api.firebaseStorageOrigin,
|
|
91
|
-
});
|
|
89
|
+
const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseStorageOrigin, apiVersion: "v1beta" });
|
|
90
|
+
const resp = await client.get(`/projects/${projectId}/buckets`);
|
|
92
91
|
return !!((_b = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.buckets) === null || _b === void 0 ? void 0 : _b.find((bucket) => {
|
|
93
92
|
const bucketResourceName = bucket.name;
|
|
94
93
|
const bucketResourceNameTokens = bucketResourceName.split("/");
|
|
@@ -98,9 +97,7 @@ async function isStorageProvisioned(projectId) {
|
|
|
98
97
|
}
|
|
99
98
|
async function isAuthProvisioned(projectId) {
|
|
100
99
|
var _a, _b;
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
origin: api.firedataOrigin,
|
|
104
|
-
});
|
|
100
|
+
const client = new apiv2_1.Client({ urlPrefix: api_1.firedataOrigin, apiVersion: "v1" });
|
|
101
|
+
const resp = await client.get(`/projects/${projectId}/products`);
|
|
105
102
|
return !!((_b = (_a = resp.body) === null || _a === void 0 ? void 0 : _a.activation) === null || _b === void 0 ? void 0 : _b.map((a) => a.service).includes("FIREBASE_AUTH"));
|
|
106
103
|
}
|
|
@@ -3,11 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getTrustedPublishers = exports.getExtensionRegistry = exports.getMinRequiredVersion = exports.getTargetVersion = exports.resolveRegistryEntry = exports.isOfficialSource = exports.resolveSourceUrl = exports.confirmUpdateWarning = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
7
|
-
const api = require("../api");
|
|
6
|
+
const { marked } = require("marked");
|
|
8
7
|
const error_1 = require("../error");
|
|
9
8
|
const logger_1 = require("../logger");
|
|
10
9
|
const prompt_1 = require("../prompt");
|
|
10
|
+
const apiv2_1 = require("../apiv2");
|
|
11
|
+
const api_1 = require("../api");
|
|
11
12
|
const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
|
|
12
13
|
async function confirmUpdateWarning(updateWarning) {
|
|
13
14
|
logger_1.logger.info(marked(updateWarning.description));
|
|
@@ -58,9 +59,8 @@ function getMinRequiredVersion(registryEntry) {
|
|
|
58
59
|
}
|
|
59
60
|
exports.getMinRequiredVersion = getMinRequiredVersion;
|
|
60
61
|
async function getExtensionRegistry(onlyFeatured) {
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
});
|
|
62
|
+
const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
|
|
63
|
+
const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
|
|
64
64
|
const extensions = _.get(res, "body.mods");
|
|
65
65
|
if (onlyFeatured) {
|
|
66
66
|
const featuredList = _.get(res, "body.featured.discover");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.inferUpdateSource = exports.updateFromPublisherSource = exports.updateToVersionFromPublisherSource = exports.updateFromUrlSource = exports.updateFromLocalSource = exports.update = exports.displayChanges = exports.warningUpdateToOtherSource = exports.getExistingSourceOrigin = void 0;
|
|
4
4
|
const clc = require("cli-color");
|
|
5
5
|
const semver = require("semver");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const error_1 = require("../error");
|
|
8
8
|
const logger_1 = require("../logger");
|
|
9
9
|
const resolveSource = require("./resolveSource");
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.displayWarningsForDeploy = exports.displayWarningPrompts = void 0;
|
|
4
|
-
const marked = require("marked");
|
|
4
|
+
const { marked } = require("marked");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
6
|
const extensionsApi_1 = require("./extensionsApi");
|
|
7
7
|
const displayExtensionInfo_1 = require("./displayExtensionInfo");
|
package/lib/functionsConfig.js
CHANGED
|
@@ -3,12 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseUnsetArgs = exports.parseSetArgs = exports.materializeAll = exports.materializeConfig = exports.setVariablesRecursive = exports.getFirebaseConfig = exports.getAppEngineLocation = exports.idsToVarName = exports.varNameToIds = exports.ensureApi = exports.RESERVED_NAMESPACES = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const
|
|
6
|
+
const api_1 = require("./api");
|
|
7
|
+
const apiv2_1 = require("./apiv2");
|
|
7
8
|
const ensureApiEnabled_1 = require("./ensureApiEnabled");
|
|
8
9
|
const error_1 = require("./error");
|
|
9
10
|
const projectUtils_1 = require("./projectUtils");
|
|
10
11
|
const runtimeconfig = require("./gcp/runtimeconfig");
|
|
11
12
|
exports.RESERVED_NAMESPACES = ["firebase"];
|
|
13
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.firebaseApiOrigin });
|
|
12
14
|
function keyToIds(key) {
|
|
13
15
|
const keyParts = key.split(".");
|
|
14
16
|
const variable = keyParts.slice(1).join("/");
|
|
@@ -55,10 +57,7 @@ function getAppEngineLocation(config) {
|
|
|
55
57
|
exports.getAppEngineLocation = getAppEngineLocation;
|
|
56
58
|
async function getFirebaseConfig(options) {
|
|
57
59
|
const projectId = (0, projectUtils_1.needProjectId)(options);
|
|
58
|
-
const response = await
|
|
59
|
-
auth: true,
|
|
60
|
-
origin: api.firebaseApiOrigin,
|
|
61
|
-
});
|
|
60
|
+
const response = await apiClient.get(`/v1beta1/projects/${projectId}/adminSdkConfig`);
|
|
62
61
|
return response.body;
|
|
63
62
|
}
|
|
64
63
|
exports.getFirebaseConfig = getFirebaseConfig;
|
package/lib/gcp/cloudbilling.js
CHANGED
|
@@ -1,36 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.listBillingAccounts = exports.setBillingAccount = exports.checkBillingEnabled = void 0;
|
|
4
|
-
const
|
|
4
|
+
const api_1 = require("../api");
|
|
5
|
+
const apiv2_1 = require("../apiv2");
|
|
5
6
|
const utils = require("../utils");
|
|
6
7
|
const API_VERSION = "v1";
|
|
8
|
+
const client = new apiv2_1.Client({ urlPrefix: api_1.cloudbillingOrigin, apiVersion: API_VERSION });
|
|
7
9
|
async function checkBillingEnabled(projectId) {
|
|
8
|
-
const res = await
|
|
9
|
-
auth: true,
|
|
10
|
-
origin: api.cloudbillingOrigin,
|
|
11
|
-
retryCodes: [500, 503],
|
|
12
|
-
});
|
|
10
|
+
const res = await client.get(utils.endpoint(["projects", projectId, "billingInfo"]), { retryCodes: [500, 503] });
|
|
13
11
|
return res.body.billingEnabled;
|
|
14
12
|
}
|
|
15
13
|
exports.checkBillingEnabled = checkBillingEnabled;
|
|
16
14
|
async function setBillingAccount(projectId, billingAccountName) {
|
|
17
|
-
const res = await
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
retryCodes: [500, 503],
|
|
21
|
-
data: {
|
|
22
|
-
billingAccountName: billingAccountName,
|
|
23
|
-
},
|
|
24
|
-
});
|
|
15
|
+
const res = await client.put(utils.endpoint(["projects", projectId, "billingInfo"]), {
|
|
16
|
+
billingAccountName: billingAccountName,
|
|
17
|
+
}, { retryCodes: [500, 503] });
|
|
25
18
|
return res.body.billingEnabled;
|
|
26
19
|
}
|
|
27
20
|
exports.setBillingAccount = setBillingAccount;
|
|
28
21
|
async function listBillingAccounts() {
|
|
29
|
-
const res = await
|
|
30
|
-
auth: true,
|
|
31
|
-
origin: api.cloudbillingOrigin,
|
|
32
|
-
retryCodes: [500, 503],
|
|
33
|
-
});
|
|
22
|
+
const res = await client.get(utils.endpoint(["billingAccounts"]), { retryCodes: [500, 503] });
|
|
34
23
|
return res.body.billingAccounts || [];
|
|
35
24
|
}
|
|
36
25
|
exports.listBillingAccounts = listBillingAccounts;
|