firebase-tools 11.29.1 → 12.0.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.
Files changed (95) hide show
  1. package/lib/api.js +4 -2
  2. package/lib/commands/database-import.js +2 -2
  3. package/lib/commands/ext-configure.js +2 -1
  4. package/lib/commands/ext-dev-deprecate.js +24 -20
  5. package/lib/commands/ext-dev-list.js +12 -11
  6. package/lib/commands/ext-dev-publish.js +13 -47
  7. package/lib/commands/ext-dev-register.js +8 -5
  8. package/lib/commands/ext-dev-undeprecate.js +4 -4
  9. package/lib/commands/ext-dev-upload.js +88 -0
  10. package/lib/commands/ext-dev-usage.js +3 -3
  11. package/lib/commands/ext-install.js +5 -10
  12. package/lib/commands/ext-uninstall.js +0 -1
  13. package/lib/commands/ext-update.js +4 -10
  14. package/lib/commands/hosting-channel-deploy.js +3 -0
  15. package/lib/commands/index.js +9 -19
  16. package/lib/database/import.js +113 -18
  17. package/lib/deploy/extensions/planner.js +13 -7
  18. package/lib/deploy/extensions/prepare.js +16 -32
  19. package/lib/deploy/functions/ensure.js +7 -1
  20. package/lib/deploy/functions/release/fabricator.js +2 -0
  21. package/lib/deploy/functions/runtimes/discovery/index.js +1 -1
  22. package/lib/deploy/functions/runtimes/index.js +11 -3
  23. package/lib/deploy/functions/runtimes/node/parseRuntimeAndValidateSDK.js +3 -3
  24. package/lib/deploy/functions/runtimes/python/index.js +41 -13
  25. package/lib/deploy/hosting/convertConfig.js +8 -4
  26. package/lib/deploy/hosting/prepare.js +64 -6
  27. package/lib/deploy/index.js +24 -8
  28. package/lib/emulator/adminSdkConfig.js +8 -0
  29. package/lib/emulator/controller.js +7 -9
  30. package/lib/emulator/download.js +3 -12
  31. package/lib/emulator/downloadableEmulators.js +5 -5
  32. package/lib/emulator/functionsEmulator.js +57 -7
  33. package/lib/emulator/functionsEmulatorRuntime.js +4 -1
  34. package/lib/emulator/functionsEmulatorShared.js +1 -0
  35. package/lib/emulator/functionsRuntimeWorker.js +12 -4
  36. package/lib/emulator/storage/rules/config.js +17 -7
  37. package/lib/experiments.js +22 -8
  38. package/lib/extensions/extensionsApi.js +24 -151
  39. package/lib/extensions/extensionsHelper.js +283 -146
  40. package/lib/extensions/manifest.js +1 -8
  41. package/lib/extensions/publisherApi.js +215 -0
  42. package/lib/extensions/refs.js +1 -1
  43. package/lib/extensions/resolveSource.js +1 -18
  44. package/lib/extensions/tos.js +78 -0
  45. package/lib/extensions/warnings.js +21 -41
  46. package/lib/frameworks/angular/index.js +74 -192
  47. package/lib/frameworks/angular/interfaces.js +2 -0
  48. package/lib/frameworks/angular/utils.js +274 -0
  49. package/lib/frameworks/astro/index.js +3 -4
  50. package/lib/frameworks/constants.js +45 -0
  51. package/lib/frameworks/express/index.js +3 -2
  52. package/lib/frameworks/flutter/index.js +39 -0
  53. package/lib/frameworks/flutter/utils.js +11 -0
  54. package/lib/frameworks/index.js +104 -145
  55. package/lib/frameworks/interfaces.js +2 -0
  56. package/lib/frameworks/next/constants.js +2 -1
  57. package/lib/frameworks/next/index.js +197 -114
  58. package/lib/frameworks/next/utils.js +97 -15
  59. package/lib/frameworks/nuxt/index.js +4 -5
  60. package/lib/frameworks/nuxt/utils.js +2 -2
  61. package/lib/frameworks/nuxt2/index.js +5 -5
  62. package/lib/frameworks/utils.js +108 -1
  63. package/lib/frameworks/vite/index.js +5 -6
  64. package/lib/functions/ensureTargeted.js +4 -4
  65. package/lib/functions/python.js +12 -5
  66. package/lib/gcp/resourceManager.js +1 -0
  67. package/lib/hosting/api.js +32 -1
  68. package/lib/hosting/config.js +4 -8
  69. package/lib/init/features/functions/index.js +4 -7
  70. package/lib/init/features/hosting/github.js +7 -2
  71. package/lib/init/features/hosting/index.js +3 -2
  72. package/lib/serve/index.js +2 -1
  73. package/lib/unzip.js +126 -0
  74. package/package.json +2 -3
  75. package/schema/firebase-config.json +1 -1
  76. package/templates/extensions/POSTINSTALL.md +2 -2
  77. package/templates/extensions/PREINSTALL.md +1 -1
  78. package/templates/extensions/extension.yaml +10 -6
  79. package/templates/extensions/javascript/WELCOME.md +1 -1
  80. package/templates/extensions/typescript/WELCOME.md +1 -1
  81. package/templates/extensions/typescript/index.ts +1 -1
  82. package/templates/init/functions/javascript/index.js +16 -6
  83. package/templates/init/functions/javascript/package.lint.json +4 -4
  84. package/templates/init/functions/javascript/package.nolint.json +4 -4
  85. package/templates/init/functions/python/requirements.txt +1 -1
  86. package/templates/init/functions/typescript/index.ts +16 -6
  87. package/templates/init/functions/typescript/package.lint.json +4 -4
  88. package/templates/init/functions/typescript/package.nolint.json +4 -4
  89. package/lib/commands/ext-dev-emulators-exec.js +0 -27
  90. package/lib/commands/ext-dev-emulators-start.js +0 -24
  91. package/lib/commands/ext-dev-extension-delete.js +0 -45
  92. package/lib/commands/ext-dev-unpublish.js +0 -49
  93. package/lib/commands/ext-sources-create.js +0 -24
  94. package/lib/extensions/askUserForConsent.js +0 -33
  95. package/npm-shrinkwrap.json +0 -12649
@@ -1,20 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
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 = void 0;
3
+ exports.refNotFoundError = exports.getExtension = exports.listExtensionVersions = exports.listExtensions = exports.getExtensionVersion = exports.getSource = exports.createSource = exports.populateSpec = exports.updateInstanceFromRegistry = exports.updateInstance = exports.configureInstance = exports.listInstances = exports.getInstance = exports.deleteInstance = exports.createInstance = void 0;
4
4
  const yaml = require("js-yaml");
5
5
  const clc = require("colorette");
6
- const marked_1 = require("marked");
7
6
  const apiv2_1 = require("../apiv2");
8
7
  const api_1 = require("../api");
9
8
  const error_1 = require("../error");
10
9
  const logger_1 = require("../logger");
11
10
  const operationPoller = require("../operation-poller");
12
11
  const refs = require("./refs");
13
- const VERSION = "v1beta";
12
+ const EXTENSIONS_API_VERSION = "v1beta";
14
13
  const PAGE_SIZE_MAX = 100;
15
- const apiClient = new apiv2_1.Client({ urlPrefix: api_1.extensionsOrigin, apiVersion: VERSION });
14
+ const extensionsApiClient = new apiv2_1.Client({
15
+ urlPrefix: api_1.extensionsOrigin,
16
+ apiVersion: EXTENSIONS_API_VERSION,
17
+ });
16
18
  async function createInstanceHelper(projectId, instanceId, config, validateOnly = false) {
17
- const createRes = await apiClient.post(`/projects/${projectId}/instances/`, {
19
+ const createRes = await extensionsApiClient.post(`/projects/${projectId}/instances/`, {
18
20
  name: `projects/${projectId}/instances/${instanceId}`,
19
21
  config,
20
22
  }, {
@@ -27,7 +29,7 @@ async function createInstanceHelper(projectId, instanceId, config, validateOnly
27
29
  }
28
30
  const pollRes = await operationPoller.pollOperation({
29
31
  apiOrigin: api_1.extensionsOrigin,
30
- apiVersion: VERSION,
32
+ apiVersion: EXTENSIONS_API_VERSION,
31
33
  operationResourceName: createRes.body.name,
32
34
  masterTimeout: 600000,
33
35
  });
@@ -65,10 +67,10 @@ async function createInstance(args) {
65
67
  }
66
68
  exports.createInstance = createInstance;
67
69
  async function deleteInstance(projectId, instanceId) {
68
- const deleteRes = await apiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
70
+ const deleteRes = await extensionsApiClient.delete(`/projects/${projectId}/instances/${instanceId}`);
69
71
  const pollRes = await operationPoller.pollOperation({
70
72
  apiOrigin: api_1.extensionsOrigin,
71
- apiVersion: VERSION,
73
+ apiVersion: EXTENSIONS_API_VERSION,
72
74
  operationResourceName: deleteRes.body.name,
73
75
  masterTimeout: 600000,
74
76
  });
@@ -77,7 +79,7 @@ async function deleteInstance(projectId, instanceId) {
77
79
  exports.deleteInstance = deleteInstance;
78
80
  async function getInstance(projectId, instanceId) {
79
81
  try {
80
- const res = await apiClient.get(`/projects/${projectId}/instances/${instanceId}`);
82
+ const res = await extensionsApiClient.get(`/projects/${projectId}/instances/${instanceId}`);
81
83
  return res.body;
82
84
  }
83
85
  catch (err) {
@@ -91,7 +93,7 @@ exports.getInstance = getInstance;
91
93
  async function listInstances(projectId) {
92
94
  const instances = [];
93
95
  const getNextPage = async (pageToken = "") => {
94
- const res = await apiClient.get(`/projects/${projectId}/instances`, {
96
+ const res = await extensionsApiClient.get(`/projects/${projectId}/instances`, {
95
97
  queryParams: {
96
98
  pageSize: PAGE_SIZE_MAX,
97
99
  pageToken,
@@ -205,7 +207,7 @@ async function updateInstanceFromRegistry(args) {
205
207
  }
206
208
  exports.updateInstanceFromRegistry = updateInstanceFromRegistry;
207
209
  async function patchInstance(args) {
208
- const updateRes = await apiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
210
+ const updateRes = await extensionsApiClient.patch(`/projects/${args.projectId}/instances/${args.instanceId}`, args.data, {
209
211
  queryParams: {
210
212
  updateMask: args.updateMask,
211
213
  validateOnly: args.validateOnly ? "true" : "false",
@@ -216,7 +218,7 @@ async function patchInstance(args) {
216
218
  }
217
219
  const pollRes = await operationPoller.pollOperation({
218
220
  apiOrigin: api_1.extensionsOrigin,
219
- apiVersion: VERSION,
221
+ apiVersion: EXTENSIONS_API_VERSION,
220
222
  operationResourceName: updateRes.body.name,
221
223
  masterTimeout: 600000,
222
224
  });
@@ -239,14 +241,15 @@ function populateSpec(spec) {
239
241
  spec.systemParams = (_b = spec.systemParams) !== null && _b !== void 0 ? _b : [];
240
242
  }
241
243
  }
244
+ exports.populateSpec = populateSpec;
242
245
  async function createSource(projectId, packageUri, extensionRoot) {
243
- const createRes = await apiClient.post(`/projects/${projectId}/sources/`, {
246
+ const createRes = await extensionsApiClient.post(`/projects/${projectId}/sources/`, {
244
247
  packageUri,
245
248
  extensionRoot,
246
249
  });
247
250
  const pollRes = await operationPoller.pollOperation({
248
251
  apiOrigin: api_1.extensionsOrigin,
249
- apiVersion: VERSION,
252
+ apiVersion: EXTENSIONS_API_VERSION,
250
253
  operationResourceName: createRes.body.name,
251
254
  masterTimeout: 600000,
252
255
  });
@@ -257,7 +260,7 @@ async function createSource(projectId, packageUri, extensionRoot) {
257
260
  }
258
261
  exports.createSource = createSource;
259
262
  async function getSource(sourceName) {
260
- const res = await apiClient.get(`/${sourceName}`);
263
+ const res = await extensionsApiClient.get(`/${sourceName}`);
261
264
  if (res.body.spec) {
262
265
  populateSpec(res.body.spec);
263
266
  }
@@ -270,7 +273,7 @@ async function getExtensionVersion(extensionVersionRef) {
270
273
  throw new error_1.FirebaseError(`ExtensionVersion ref "${extensionVersionRef}" must supply a version.`);
271
274
  }
272
275
  try {
273
- const res = await apiClient.get(`/${refs.toExtensionVersionName(ref)}`);
276
+ const res = await extensionsApiClient.get(`/${refs.toExtensionVersionName(ref)}`);
274
277
  if (res.body.spec) {
275
278
  populateSpec(res.body.spec);
276
279
  }
@@ -290,7 +293,7 @@ exports.getExtensionVersion = getExtensionVersion;
290
293
  async function listExtensions(publisherId) {
291
294
  const extensions = [];
292
295
  const getNextPage = async (pageToken = "") => {
293
- const res = await apiClient.get(`/publishers/${publisherId}/extensions`, {
296
+ const res = await extensionsApiClient.get(`/publishers/${publisherId}/extensions`, {
294
297
  queryParams: {
295
298
  pageSize: PAGE_SIZE_MAX,
296
299
  pageToken,
@@ -311,7 +314,7 @@ async function listExtensionVersions(ref, filter = "", showPrereleases = false)
311
314
  const { publisherId, extensionId } = refs.parse(ref);
312
315
  const extensionVersions = [];
313
316
  const getNextPage = async (pageToken = "") => {
314
- const res = await apiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
317
+ const res = await extensionsApiClient.get(`/publishers/${publisherId}/extensions/${extensionId}/versions`, {
315
318
  queryParams: {
316
319
  filter,
317
320
  showPrereleases: String(showPrereleases),
@@ -330,141 +333,10 @@ async function listExtensionVersions(ref, filter = "", showPrereleases = false)
330
333
  return extensionVersions;
331
334
  }
332
335
  exports.listExtensionVersions = listExtensionVersions;
333
- async function getPublisherProfile(projectId, publisherId) {
334
- const res = await apiClient.get(`/projects/${projectId}/publisherProfile`, {
335
- queryParams: publisherId === undefined
336
- ? undefined
337
- : {
338
- publisherId,
339
- },
340
- });
341
- return res.body;
342
- }
343
- exports.getPublisherProfile = getPublisherProfile;
344
- async function registerPublisherProfile(projectId, publisherId) {
345
- const res = await apiClient.post(`/projects/${projectId}/publisherProfile:register`, {
346
- publisherId,
347
- });
348
- return res.body;
349
- }
350
- exports.registerPublisherProfile = registerPublisherProfile;
351
- async function deprecateExtensionVersion(extensionRef, deprecationMessage) {
352
- const ref = refs.parse(extensionRef);
353
- try {
354
- const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:deprecate`, {
355
- deprecationMessage,
356
- });
357
- return res.body;
358
- }
359
- catch (err) {
360
- if (err.status === 403) {
361
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to deprecate this extension version.` + err, { status: err.status });
362
- }
363
- else if (err.status === 404) {
364
- throw new error_1.FirebaseError(`Extension version ${clc.bold(extensionRef)} was not found.`);
365
- }
366
- else if (err instanceof error_1.FirebaseError) {
367
- throw err;
368
- }
369
- throw new error_1.FirebaseError(`Error occurred deprecating extension version '${extensionRef}': ${err}`, {
370
- status: err.status,
371
- });
372
- }
373
- }
374
- exports.deprecateExtensionVersion = deprecateExtensionVersion;
375
- async function undeprecateExtensionVersion(extensionRef) {
376
- const ref = refs.parse(extensionRef);
377
- try {
378
- const res = await apiClient.post(`/${refs.toExtensionVersionName(ref)}:undeprecate`);
379
- return res.body;
380
- }
381
- catch (err) {
382
- if (err.status === 403) {
383
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to undeprecate this extension version.`, { status: err.status });
384
- }
385
- else if (err.status === 404) {
386
- throw new error_1.FirebaseError(`Extension version ${clc.bold(extensionRef)} was not found.`);
387
- }
388
- else if (err instanceof error_1.FirebaseError) {
389
- throw err;
390
- }
391
- throw new error_1.FirebaseError(`Error occurred undeprecating extension version '${extensionRef}': ${err}`, {
392
- status: err.status,
393
- });
394
- }
395
- }
396
- exports.undeprecateExtensionVersion = undeprecateExtensionVersion;
397
- async function publishExtensionVersion(args) {
398
- var _a, _b, _c, _d;
399
- const ref = refs.parse(args.extensionVersionRef);
400
- if (!ref.version) {
401
- throw new error_1.FirebaseError(`ExtensionVersion ref "${args.extensionVersionRef}" must supply a version.`);
402
- }
403
- const publishRes = await apiClient.post(`/${refs.toExtensionName(ref)}/versions:publish`, {
404
- versionId: ref.version,
405
- packageUri: (_a = args.packageUri) !== null && _a !== void 0 ? _a : "",
406
- extensionRoot: (_b = args.extensionRoot) !== null && _b !== void 0 ? _b : "/",
407
- repoUri: (_c = args.repoUri) !== null && _c !== void 0 ? _c : "",
408
- sourceRef: (_d = args.sourceRef) !== null && _d !== void 0 ? _d : "",
409
- });
410
- const pollRes = await operationPoller.pollOperation({
411
- apiOrigin: api_1.extensionsOrigin,
412
- apiVersion: VERSION,
413
- operationResourceName: publishRes.body.name,
414
- masterTimeout: 600000,
415
- });
416
- return pollRes;
417
- }
418
- exports.publishExtensionVersion = publishExtensionVersion;
419
- async function unpublishExtension(extensionRef) {
420
- const ref = refs.parse(extensionRef);
421
- if (ref.version) {
422
- throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
423
- }
424
- try {
425
- await apiClient.post(`/${refs.toExtensionName(ref)}:unpublish`);
426
- }
427
- catch (err) {
428
- if (err.status === 403) {
429
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to unpublish this extension.`, { status: err.status });
430
- }
431
- else if (err instanceof error_1.FirebaseError) {
432
- throw err;
433
- }
434
- throw new error_1.FirebaseError(`Error occurred unpublishing extension '${extensionRef}': ${err}`, {
435
- status: err.status,
436
- });
437
- }
438
- }
439
- exports.unpublishExtension = unpublishExtension;
440
- async function deleteExtension(extensionRef) {
441
- const ref = refs.parse(extensionRef);
442
- if (ref.version) {
443
- throw new error_1.FirebaseError(`Extension reference "${extensionRef}" must not contain a version.`);
444
- }
445
- try {
446
- await apiClient.delete(`/${refs.toExtensionName(ref)}`);
447
- }
448
- catch (err) {
449
- if (err.status === 403) {
450
- throw new error_1.FirebaseError(`You are not the owner of extension '${clc.bold(extensionRef)}' and don’t have the correct permissions to delete this extension.`, { status: err.status });
451
- }
452
- else if (err.status === 404) {
453
- throw new error_1.FirebaseError(`Extension ${clc.bold(extensionRef)} was not found.`);
454
- }
455
- else if (err instanceof error_1.FirebaseError) {
456
- throw err;
457
- }
458
- throw new error_1.FirebaseError(`Error occurred delete extension '${extensionRef}': ${err}`, {
459
- status: err.status,
460
- });
461
- }
462
- }
463
- exports.deleteExtension = deleteExtension;
464
336
  async function getExtension(extensionRef) {
465
337
  const ref = refs.parse(extensionRef);
466
338
  try {
467
- const res = await apiClient.get(`/${refs.toExtensionName(ref)}`);
339
+ const res = await extensionsApiClient.get(`/${refs.toExtensionName(ref)}`);
468
340
  return res.body;
469
341
  }
470
342
  catch (err) {
@@ -484,5 +356,6 @@ function refNotFoundError(ref) {
484
356
  return new error_1.FirebaseError(`The extension reference '${clc.bold(ref.version ? refs.toExtensionVersionRef(ref) : refs.toExtensionRef(ref))}' doesn't exist. This could happen for two reasons:\n` +
485
357
  ` -The publisher ID '${clc.bold(ref.publisherId)}' doesn't exist or could be misspelled\n` +
486
358
  ` -The name of the ${ref.version ? "extension version" : "extension"} '${clc.bold(ref.version ? `${ref.extensionId}@${ref.version}` : ref.extensionId)}' doesn't exist or could be misspelled\n\n` +
487
- `Please correct the extension reference and try again. If you meant to install an extension from a local source, please provide a relative path prefixed with '${clc.bold("./")}', '${clc.bold("../")}', or '${clc.bold("~/")}'. Learn more about local extension installation at ${(0, marked_1.marked)("[https://firebase.google.com/docs/extensions/alpha/install-extensions_community#install](https://firebase.google.com/docs/extensions/alpha/install-extensions_community#install).")}`, { status: 404 });
359
+ `Please correct the extension reference and try again. If you meant to install an extension from a local source, please provide a relative path prefixed with '${clc.bold("./")}', '${clc.bold("../")}', or '${clc.bold("~/")}'.}`, { status: 404 });
488
360
  }
361
+ exports.refNotFoundError = refNotFoundError;