firebase-tools 10.1.1 → 10.1.2
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/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-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/defaultCredentials.js +3 -3
- package/lib/deploy/functions/runtimes/golang/index.js +2 -1
- package/lib/emulator/downloadableEmulators.js +3 -2
- package/lib/emulator/functionsEmulator.js +6 -0
- package/lib/emulator/functionsEmulatorRuntime.js +4 -4
- 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 +58 -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/rules.js +18 -41
- 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 +1225 -2019
- package/package.json +12 -9
- package/lib/commands/functions-config-legacy.js +0 -45
- package/lib/prepareFirebaseRules.js +0 -58
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseChangelog = exports.getLocalChangelog = exports.breakingChangesInUpdate = exports.displayReleaseNotes = exports.getReleaseNotesForUpdate = void 0;
|
|
4
4
|
const clc = require("cli-color");
|
|
5
|
-
const marked = require("marked");
|
|
5
|
+
const { marked } = require("marked");
|
|
6
6
|
const path = require("path");
|
|
7
7
|
const semver = require("semver");
|
|
8
8
|
const TerminalRenderer = require("marked-terminal");
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.printSourceDownloadLink = exports.displayUpdateChangesRequiringConfirmation = exports.displayUpdateChangesNoInput = exports.displayExtInfo = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const clc = require("cli-color");
|
|
6
|
-
const marked = require("marked");
|
|
6
|
+
const { marked } = require("marked");
|
|
7
7
|
const TerminalRenderer = require("marked-terminal");
|
|
8
8
|
const utils = require("../utils");
|
|
9
9
|
const extensionsHelper_1 = require("./extensionsHelper");
|
|
@@ -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,10 @@ 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
|
-
|
|
287
|
-
showUnpublished: false,
|
|
288
|
-
query: {
|
|
256
|
+
const getNextPage = async (pageToken = "") => {
|
|
257
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions`, {
|
|
258
|
+
queryParams: {
|
|
259
|
+
showUnpublished: "false",
|
|
289
260
|
pageSize: PAGE_SIZE_MAX,
|
|
290
261
|
pageToken,
|
|
291
262
|
},
|
|
@@ -301,14 +272,12 @@ async function listExtensions(publisherId) {
|
|
|
301
272
|
return extensions;
|
|
302
273
|
}
|
|
303
274
|
exports.listExtensions = listExtensions;
|
|
304
|
-
async function listExtensionVersions(ref, filter) {
|
|
275
|
+
async function listExtensionVersions(ref, filter = "") {
|
|
305
276
|
const { publisherId, extensionId } = refs.parse(ref);
|
|
306
277
|
const extensionVersions = [];
|
|
307
|
-
const getNextPage = async (pageToken) => {
|
|
308
|
-
const res = await
|
|
309
|
-
|
|
310
|
-
origin: api.extensionsOrigin,
|
|
311
|
-
query: {
|
|
278
|
+
const getNextPage = async (pageToken = "") => {
|
|
279
|
+
const res = await apiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
|
|
280
|
+
queryParams: {
|
|
312
281
|
filter,
|
|
313
282
|
pageSize: PAGE_SIZE_MAX,
|
|
314
283
|
pageToken,
|
|
@@ -326,8 +295,7 @@ async function listExtensionVersions(ref, filter) {
|
|
|
326
295
|
}
|
|
327
296
|
exports.listExtensionVersions = listExtensionVersions;
|
|
328
297
|
async function getPublisherProfile(projectId, publisherId) {
|
|
329
|
-
const
|
|
330
|
-
const res = await client.get(`/${VERSION}/projects/${projectId}/publisherProfile`, {
|
|
298
|
+
const res = await apiClient.get(`/projects/${projectId}/publisherProfile`, {
|
|
331
299
|
queryParams: publisherId == undefined
|
|
332
300
|
? undefined
|
|
333
301
|
: {
|
|
@@ -338,10 +306,8 @@ async function getPublisherProfile(projectId, publisherId) {
|
|
|
338
306
|
}
|
|
339
307
|
exports.getPublisherProfile = getPublisherProfile;
|
|
340
308
|
async function registerPublisherProfile(projectId, publisherId) {
|
|
341
|
-
const res = await
|
|
342
|
-
|
|
343
|
-
origin: api.extensionsOrigin,
|
|
344
|
-
data: { publisherId },
|
|
309
|
+
const res = await apiClient.post(`/projects/${projectId}/publisherProfile:register`, {
|
|
310
|
+
publisherId,
|
|
345
311
|
});
|
|
346
312
|
return res.body;
|
|
347
313
|
}
|
|
@@ -349,10 +315,8 @@ exports.registerPublisherProfile = registerPublisherProfile;
|
|
|
349
315
|
async function deprecateExtensionVersion(extensionRef, deprecationMessage) {
|
|
350
316
|
const ref = refs.parse(extensionRef);
|
|
351
317
|
try {
|
|
352
|
-
const res = await
|
|
353
|
-
|
|
354
|
-
origin: api.extensionsOrigin,
|
|
355
|
-
data: { deprecationMessage },
|
|
318
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:deprecate`, {
|
|
319
|
+
deprecationMessage,
|
|
356
320
|
});
|
|
357
321
|
return res.body;
|
|
358
322
|
}
|
|
@@ -375,10 +339,7 @@ exports.deprecateExtensionVersion = deprecateExtensionVersion;
|
|
|
375
339
|
async function undeprecateExtensionVersion(extensionRef) {
|
|
376
340
|
const ref = refs.parse(extensionRef);
|
|
377
341
|
try {
|
|
378
|
-
const res = await
|
|
379
|
-
auth: true,
|
|
380
|
-
origin: api.extensionsOrigin,
|
|
381
|
-
});
|
|
342
|
+
const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:undeprecate`);
|
|
382
343
|
return res.body;
|
|
383
344
|
}
|
|
384
345
|
catch (err) {
|
|
@@ -402,17 +363,13 @@ async function publishExtensionVersion(extensionVersionRef, packageUri, extensio
|
|
|
402
363
|
if (!ref.version) {
|
|
403
364
|
throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
|
|
404
365
|
}
|
|
405
|
-
const publishRes = await
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
versionId: ref.version,
|
|
410
|
-
packageUri,
|
|
411
|
-
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
412
|
-
},
|
|
366
|
+
const publishRes = await apiClient.post(`/${refs.toExtensionName(ref)}/versions:publish`, {
|
|
367
|
+
versionId: ref.version,
|
|
368
|
+
packageUri,
|
|
369
|
+
extensionRoot: extensionRoot !== null && extensionRoot !== void 0 ? extensionRoot : "/",
|
|
413
370
|
});
|
|
414
371
|
const pollRes = await operationPoller.pollOperation({
|
|
415
|
-
apiOrigin:
|
|
372
|
+
apiOrigin: api_1.extensionsOrigin,
|
|
416
373
|
apiVersion: VERSION,
|
|
417
374
|
operationResourceName: publishRes.body.name,
|
|
418
375
|
masterTimeout: 600000,
|
|
@@ -425,12 +382,8 @@ async function unpublishExtension(extensionRef) {
|
|
|
425
382
|
if (ref.version) {
|
|
426
383
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
427
384
|
}
|
|
428
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}:unpublish`;
|
|
429
385
|
try {
|
|
430
|
-
await
|
|
431
|
-
auth: true,
|
|
432
|
-
origin: api.extensionsOrigin,
|
|
433
|
-
});
|
|
386
|
+
await apiClient.post(`/${refs.toExtensionName(ref)}:unpublish`);
|
|
434
387
|
}
|
|
435
388
|
catch (err) {
|
|
436
389
|
if (err.status === 403) {
|
|
@@ -450,12 +403,8 @@ async function deleteExtension(extensionRef) {
|
|
|
450
403
|
if (ref.version) {
|
|
451
404
|
throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
|
|
452
405
|
}
|
|
453
|
-
const url = `/${VERSION}/${refs.toExtensionName(ref)}`;
|
|
454
406
|
try {
|
|
455
|
-
await
|
|
456
|
-
auth: true,
|
|
457
|
-
origin: api.extensionsOrigin,
|
|
458
|
-
});
|
|
407
|
+
await apiClient.delete(`/${refs.toExtensionName(ref)}`);
|
|
459
408
|
}
|
|
460
409
|
catch (err) {
|
|
461
410
|
if (err.status === 403) {
|
|
@@ -476,10 +425,7 @@ exports.deleteExtension = deleteExtension;
|
|
|
476
425
|
async function getExtension(extensionRef) {
|
|
477
426
|
const ref = refs.parse(extensionRef);
|
|
478
427
|
try {
|
|
479
|
-
const res = await
|
|
480
|
-
auth: true,
|
|
481
|
-
origin: api.extensionsOrigin,
|
|
482
|
-
});
|
|
428
|
+
const res = await apiClient.get(`/${refs.toExtensionName(ref)}`);
|
|
483
429
|
return res.body;
|
|
484
430
|
}
|
|
485
431
|
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/rules.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.testRuleset = exports.updateOrCreateRelease = exports.updateRelease = exports.createRelease = exports.createRuleset = exports.deleteRuleset = exports.getRulesetId = exports.listAllRulesets = exports.listRulesets = exports.getRulesetContent = exports.listAllReleases = exports.listReleases = exports.getLatestRulesetName = void 0;
|
|
4
4
|
const _ = require("lodash");
|
|
5
|
-
const
|
|
5
|
+
const api_1 = require("../api");
|
|
6
|
+
const apiv2_1 = require("../apiv2");
|
|
6
7
|
const logger_1 = require("../logger");
|
|
7
8
|
const utils = require("../utils");
|
|
8
9
|
const API_VERSION = "v1";
|
|
10
|
+
const apiClient = new apiv2_1.Client({ urlPrefix: api_1.rulesOrigin, apiVersion: API_VERSION });
|
|
9
11
|
function _handleErrorResponse(response) {
|
|
10
12
|
if (response.body && response.body.error) {
|
|
11
13
|
return utils.reject(response.body.error, { code: 2 });
|
|
@@ -18,7 +20,7 @@ function _handleErrorResponse(response) {
|
|
|
18
20
|
async function getLatestRulesetName(projectId, service) {
|
|
19
21
|
const releases = await listAllReleases(projectId);
|
|
20
22
|
const prefix = `projects/${projectId}/releases/${service}`;
|
|
21
|
-
const release = _.find(releases, (r) => r.name.
|
|
23
|
+
const release = _.find(releases, (r) => r.name.startsWith(prefix));
|
|
22
24
|
if (!release) {
|
|
23
25
|
return null;
|
|
24
26
|
}
|
|
@@ -26,11 +28,9 @@ async function getLatestRulesetName(projectId, service) {
|
|
|
26
28
|
}
|
|
27
29
|
exports.getLatestRulesetName = getLatestRulesetName;
|
|
28
30
|
const MAX_RELEASES_PAGE_SIZE = 10;
|
|
29
|
-
async function listReleases(projectId, pageToken) {
|
|
30
|
-
const response = await
|
|
31
|
-
|
|
32
|
-
origin: api.rulesOrigin,
|
|
33
|
-
query: {
|
|
31
|
+
async function listReleases(projectId, pageToken = "") {
|
|
32
|
+
const response = await apiClient.get(`/projects/${projectId}/releases`, {
|
|
33
|
+
queryParams: {
|
|
34
34
|
pageSize: MAX_RELEASES_PAGE_SIZE,
|
|
35
35
|
pageToken,
|
|
36
36
|
},
|
|
@@ -55,9 +55,8 @@ async function listAllReleases(projectId) {
|
|
|
55
55
|
}
|
|
56
56
|
exports.listAllReleases = listAllReleases;
|
|
57
57
|
async function getRulesetContent(name) {
|
|
58
|
-
const response = await
|
|
59
|
-
|
|
60
|
-
origin: api.rulesOrigin,
|
|
58
|
+
const response = await apiClient.get(`/${name}`, {
|
|
59
|
+
skipLog: { resBody: true },
|
|
61
60
|
});
|
|
62
61
|
if (response.status === 200) {
|
|
63
62
|
const source = response.body.source;
|
|
@@ -67,14 +66,13 @@ async function getRulesetContent(name) {
|
|
|
67
66
|
}
|
|
68
67
|
exports.getRulesetContent = getRulesetContent;
|
|
69
68
|
const MAX_RULESET_PAGE_SIZE = 100;
|
|
70
|
-
async function listRulesets(projectId, pageToken) {
|
|
71
|
-
const response = await
|
|
72
|
-
|
|
73
|
-
origin: api.rulesOrigin,
|
|
74
|
-
query: {
|
|
69
|
+
async function listRulesets(projectId, pageToken = "") {
|
|
70
|
+
const response = await apiClient.get(`/projects/${projectId}/rulesets`, {
|
|
71
|
+
queryParams: {
|
|
75
72
|
pageSize: MAX_RULESET_PAGE_SIZE,
|
|
76
73
|
pageToken,
|
|
77
74
|
},
|
|
75
|
+
skipLog: { resBody: true },
|
|
78
76
|
});
|
|
79
77
|
if (response.status === 200) {
|
|
80
78
|
return response.body;
|
|
@@ -100,10 +98,7 @@ function getRulesetId(ruleset) {
|
|
|
100
98
|
}
|
|
101
99
|
exports.getRulesetId = getRulesetId;
|
|
102
100
|
async function deleteRuleset(projectId, id) {
|
|
103
|
-
const response = await
|
|
104
|
-
auth: true,
|
|
105
|
-
origin: api.rulesOrigin,
|
|
106
|
-
});
|
|
101
|
+
const response = await apiClient.delete(`/projects/${projectId}/rulesets/${id}`);
|
|
107
102
|
if (response.status === 200) {
|
|
108
103
|
return;
|
|
109
104
|
}
|
|
@@ -112,11 +107,7 @@ async function deleteRuleset(projectId, id) {
|
|
|
112
107
|
exports.deleteRuleset = deleteRuleset;
|
|
113
108
|
async function createRuleset(projectId, files) {
|
|
114
109
|
const payload = { source: { files } };
|
|
115
|
-
const response = await
|
|
116
|
-
auth: true,
|
|
117
|
-
data: payload,
|
|
118
|
-
origin: api.rulesOrigin,
|
|
119
|
-
});
|
|
110
|
+
const response = await apiClient.post(`/projects/${projectId}/rulesets`, payload, { skipLog: { body: true } });
|
|
120
111
|
if (response.status === 200) {
|
|
121
112
|
logger_1.logger.debug("[rules] created ruleset", response.body.name);
|
|
122
113
|
return response.body.name;
|
|
@@ -129,11 +120,7 @@ async function createRelease(projectId, rulesetName, releaseName) {
|
|
|
129
120
|
name: `projects/${projectId}/releases/${releaseName}`,
|
|
130
121
|
rulesetName,
|
|
131
122
|
};
|
|
132
|
-
const response = await
|
|
133
|
-
auth: true,
|
|
134
|
-
data: payload,
|
|
135
|
-
origin: api.rulesOrigin,
|
|
136
|
-
});
|
|
123
|
+
const response = await apiClient.post(`/projects/${projectId}/releases`, payload);
|
|
137
124
|
if (response.status === 200) {
|
|
138
125
|
logger_1.logger.debug("[rules] created release", response.body.name);
|
|
139
126
|
return response.body.name;
|
|
@@ -148,11 +135,7 @@ async function updateRelease(projectId, rulesetName, releaseName) {
|
|
|
148
135
|
rulesetName,
|
|
149
136
|
},
|
|
150
137
|
};
|
|
151
|
-
const response = await
|
|
152
|
-
auth: true,
|
|
153
|
-
data: payload,
|
|
154
|
-
origin: api.rulesOrigin,
|
|
155
|
-
});
|
|
138
|
+
const response = await apiClient.patch(`/projects/${projectId}/releases/${releaseName}`, payload);
|
|
156
139
|
if (response.status === 200) {
|
|
157
140
|
logger_1.logger.debug("[rules] updated release", response.body.name);
|
|
158
141
|
return response.body.name;
|
|
@@ -169,12 +152,6 @@ async function updateOrCreateRelease(projectId, rulesetName, releaseName) {
|
|
|
169
152
|
}
|
|
170
153
|
exports.updateOrCreateRelease = updateOrCreateRelease;
|
|
171
154
|
function testRuleset(projectId, files) {
|
|
172
|
-
return
|
|
173
|
-
origin: api.rulesOrigin,
|
|
174
|
-
data: {
|
|
175
|
-
source: { files },
|
|
176
|
-
},
|
|
177
|
-
auth: true,
|
|
178
|
-
});
|
|
155
|
+
return apiClient.post(`/projects/${encodeURIComponent(projectId)}:test`, { source: { files } }, { skipLog: { body: true } });
|
|
179
156
|
}
|
|
180
157
|
exports.testRuleset = testRuleset;
|