firebase-tools 10.1.4 → 10.1.5

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/apiv2.js CHANGED
@@ -254,6 +254,7 @@ class Client {
254
254
  body = JSON.parse(text);
255
255
  }
256
256
  catch (err) {
257
+ this.logResponse(res, text, options);
257
258
  throw new error_1.FirebaseError(`Unable to parse JSON: ${err}`);
258
259
  }
259
260
  }
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.confirm = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.promptForOfficialExtension = exports.displayReleaseNotes = exports.getPublisherProjectFromName = exports.getExtensionSourceFromName = exports.createSourceFromLocation = exports.publishExtensionVersionFromLocalSource = exports.ensureExtensionsApiEnabled = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
3
+ exports.confirm = exports.getSourceOrigin = exports.isLocalOrURLPath = exports.isLocalPath = exports.isUrlPath = exports.instanceIdExists = exports.promptForRepeatInstance = exports.promptForOfficialExtension = exports.displayReleaseNotes = exports.getPublisherProjectFromName = exports.createSourceFromLocation = exports.publishExtensionVersionFromLocalSource = exports.ensureExtensionsApiEnabled = exports.promptForValidInstanceId = exports.validateSpec = exports.validateCommandLineParams = exports.populateDefaultParams = exports.substituteParams = exports.getFirebaseProjectParams = exports.getDBInstanceFromURL = exports.resourceTypeToNiceName = exports.AUTOPOULATED_PARAM_PLACEHOLDERS = exports.EXTENSIONS_BUCKET_NAME = exports.URL_REGEX = exports.logPrefix = exports.SourceOrigin = exports.SpecParamType = void 0;
4
4
  const _ = require("lodash");
5
5
  const clc = require("cli-color");
6
6
  const ora = require("ora");
@@ -382,22 +382,6 @@ async function deleteUploadedSource(objectPath) {
382
382
  }
383
383
  }
384
384
  }
385
- async function getExtensionSourceFromName(extensionName) {
386
- const officialExtensionRegex = /^[a-zA-Z\-]+[0-9@.]*$/;
387
- const existingSourceRegex = /projects\/.+\/sources\/.+/;
388
- if (officialExtensionRegex.test(extensionName)) {
389
- const [name, version] = extensionName.split("@");
390
- const registryEntry = await (0, resolveSource_1.resolveRegistryEntry)(name);
391
- const sourceUrl = (0, resolveSource_1.resolveSourceUrl)(registryEntry, name, version);
392
- return await (0, extensionsApi_1.getSource)(sourceUrl);
393
- }
394
- else if (existingSourceRegex.test(extensionName)) {
395
- logger_1.logger.info(`Fetching the source "${extensionName}"...`);
396
- return await (0, extensionsApi_1.getSource)(extensionName);
397
- }
398
- throw new error_1.FirebaseError(`Could not find an extension named '${extensionName}'. `);
399
- }
400
- exports.getExtensionSourceFromName = getExtensionSourceFromName;
401
385
  function getPublisherProjectFromName(publisherName) {
402
386
  const publisherNameRegex = /projects\/.+\/publisherProfile/;
403
387
  if (publisherNameRegex.test(publisherName)) {
@@ -1,63 +1,11 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTrustedPublishers = exports.getExtensionRegistry = exports.getMinRequiredVersion = exports.getTargetVersion = exports.resolveRegistryEntry = exports.isOfficialSource = exports.resolveSourceUrl = exports.confirmUpdateWarning = void 0;
3
+ exports.getTrustedPublishers = exports.getExtensionRegistry = void 0;
4
4
  const _ = require("lodash");
5
- const clc = require("cli-color");
6
- const { marked } = require("marked");
7
- const error_1 = require("../error");
8
5
  const logger_1 = require("../logger");
9
- const prompt_1 = require("../prompt");
10
6
  const apiv2_1 = require("../apiv2");
11
7
  const api_1 = require("../api");
12
8
  const EXTENSIONS_REGISTRY_ENDPOINT = "/extensions.json";
13
- async function confirmUpdateWarning(updateWarning) {
14
- logger_1.logger.info(marked(updateWarning.description));
15
- if (updateWarning.action) {
16
- logger_1.logger.info(marked(updateWarning.action));
17
- }
18
- const continueUpdate = await (0, prompt_1.promptOnce)({
19
- type: "confirm",
20
- message: "Do you wish to continue with this update?",
21
- default: false,
22
- });
23
- if (!continueUpdate) {
24
- throw new error_1.FirebaseError(`Update cancelled.`, { exit: 2 });
25
- }
26
- }
27
- exports.confirmUpdateWarning = confirmUpdateWarning;
28
- function resolveSourceUrl(registryEntry, name, version) {
29
- const targetVersion = getTargetVersion(registryEntry, version);
30
- const sourceUrl = _.get(registryEntry, ["versions", targetVersion]);
31
- if (!sourceUrl) {
32
- throw new error_1.FirebaseError(`Could not find version ${clc.bold(version)} of extension ${clc.bold(name)}.`);
33
- }
34
- return sourceUrl;
35
- }
36
- exports.resolveSourceUrl = resolveSourceUrl;
37
- function isOfficialSource(registryEntry, sourceUrl) {
38
- const versions = _.get(registryEntry, "versions");
39
- return _.includes(versions, sourceUrl);
40
- }
41
- exports.isOfficialSource = isOfficialSource;
42
- async function resolveRegistryEntry(name) {
43
- const extensionsRegistry = await getExtensionRegistry();
44
- const registryEntry = _.get(extensionsRegistry, name);
45
- if (!registryEntry) {
46
- throw new error_1.FirebaseError(`Unable to find extension source named ${clc.bold(name)}.`);
47
- }
48
- return registryEntry;
49
- }
50
- exports.resolveRegistryEntry = resolveRegistryEntry;
51
- function getTargetVersion(registryEntry, versionOrLabel) {
52
- const seekVersion = versionOrLabel || "latest";
53
- const versionFromLabel = _.get(registryEntry, ["labels", seekVersion]);
54
- return versionFromLabel || seekVersion;
55
- }
56
- exports.getTargetVersion = getTargetVersion;
57
- function getMinRequiredVersion(registryEntry) {
58
- return _.get(registryEntry, ["labels", "minRequired"]);
59
- }
60
- exports.getMinRequiredVersion = getMinRequiredVersion;
61
9
  async function getExtensionRegistry(onlyFeatured) {
62
10
  const client = new apiv2_1.Client({ urlPrefix: api_1.firebaseExtensionsRegistryOrigin });
63
11
  const res = await client.get(EXTENSIONS_REGISTRY_ENDPOINT);
@@ -6,7 +6,6 @@ const semver = require("semver");
6
6
  const { marked } = require("marked");
7
7
  const error_1 = require("../error");
8
8
  const logger_1 = require("../logger");
9
- const resolveSource = require("./resolveSource");
10
9
  const extensionsApi = require("./extensionsApi");
11
10
  const refs = require("./refs");
12
11
  const extensionsHelper_1 = require("./extensionsHelper");
@@ -123,19 +122,6 @@ async function updateToVersionFromPublisherSource(projectId, instanceId, extVers
123
122
  catch (err) {
124
123
  throw new error_1.FirebaseError(`Could not find source '${clc.bold(extVersionRef)}' because (${clc.bold(version)}) is not a published version. To update, use the latest version of this extension (${clc.bold(extension.latestVersion)}).`);
125
124
  }
126
- let registryEntry;
127
- try {
128
- registryEntry = await resolveSource.resolveRegistryEntry(existingSpec.name);
129
- }
130
- catch (err) {
131
- logger_1.logger.debug(`Unable to fetch registry.json entry for ${existingSpec.name}`);
132
- }
133
- if (registryEntry) {
134
- const minVer = resolveSource.getMinRequiredVersion(registryEntry);
135
- if (minVer && semver.gt(minVer, source.spec.version)) {
136
- throw new error_1.FirebaseError(`The version you are trying to update to (${clc.bold(source.spec.version)}) is less than the minimum version required (${clc.bold(minVer)}) to use this extension.`);
137
- }
138
- }
139
125
  showUpdateVersionInfo(instanceId, existingSpec.version, source.spec.version, extVersionRef);
140
126
  warningUpdateToOtherSource(extensionsHelper_1.SourceOrigin.PUBLISHED_EXTENSION);
141
127
  const releaseNotes = await changelog.getReleaseNotesForUpdate({
@@ -22,12 +22,14 @@ function convertExtensionOptionToLabeledList(options) {
22
22
  }
23
23
  exports.convertExtensionOptionToLabeledList = convertExtensionOptionToLabeledList;
24
24
  function convertOfficialExtensionsToList(officialExts) {
25
- return _.map(officialExts, (entry, key) => {
25
+ const l = _.map(officialExts, (entry, key) => {
26
26
  return {
27
27
  checked: false,
28
- value: key,
28
+ value: `${entry.publisher}/${key}`,
29
29
  };
30
30
  });
31
+ l.sort((a, b) => a.value.localeCompare(b.value));
32
+ return l;
31
33
  }
32
34
  exports.convertOfficialExtensionsToList = convertOfficialExtensionsToList;
33
35
  function getRandomString(length) {
@@ -42,9 +42,9 @@ async function uploadObject(source, bucketName) {
42
42
  if (path.extname(source.file) !== ".zip") {
43
43
  throw new error_1.FirebaseError(`Expected a file name ending in .zip, got ${source.file}`);
44
44
  }
45
- const storageAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin, apiVersion: "v1" });
45
+ const localAPIClient = new apiv2_1.Client({ urlPrefix: api_1.storageOrigin });
46
46
  const location = `/${bucketName}/${path.basename(source.file)}`;
47
- const res = await storageAPIClient.request({
47
+ const res = await localAPIClient.request({
48
48
  method: "PUT",
49
49
  path: location,
50
50
  headers: {
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "10.1.4",
3
+ "version": "10.1.5",
4
4
  "lockfileVersion": 2,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "firebase-tools",
9
- "version": "10.1.4",
9
+ "version": "10.1.5",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "@google-cloud/pubsub": "^2.18.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "firebase-tools",
3
- "version": "10.1.4",
3
+ "version": "10.1.5",
4
4
  "description": "Command-Line Interface for Firebase",
5
5
  "main": "./lib/index.js",
6
6
  "bin": {