BintrayProvider.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.BintrayProvider = void 0;
  6. function _bluebirdLst() {
  7. const data = require("bluebird-lst");
  8. _bluebirdLst = function () {
  9. return data;
  10. };
  11. return data;
  12. }
  13. function _builderUtilRuntime() {
  14. const data = require("builder-util-runtime");
  15. _builderUtilRuntime = function () {
  16. return data;
  17. };
  18. return data;
  19. }
  20. function _bintray() {
  21. const data = require("builder-util-runtime/out/bintray");
  22. _bintray = function () {
  23. return data;
  24. };
  25. return data;
  26. }
  27. function _url() {
  28. const data = require("url");
  29. _url = function () {
  30. return data;
  31. };
  32. return data;
  33. }
  34. function _main() {
  35. const data = require("./main");
  36. _main = function () {
  37. return data;
  38. };
  39. return data;
  40. }
  41. function _Provider() {
  42. const data = require("./Provider");
  43. _Provider = function () {
  44. return data;
  45. };
  46. return data;
  47. }
  48. class BintrayProvider extends _main().Provider {
  49. constructor(configuration, httpExecutor) {
  50. super(httpExecutor);
  51. this.client = new (_bintray().BintrayClient)(configuration, httpExecutor, new (_builderUtilRuntime().CancellationToken)());
  52. this.baseUrl = (0, _main().newBaseUrl)(`https://dl.bintray.com/${this.client.owner}/${this.client.repo}`);
  53. }
  54. setRequestHeaders(value) {
  55. super.setRequestHeaders(value);
  56. this.client.setRequestHeaders(value);
  57. }
  58. getLatestVersion() {
  59. var _this = this;
  60. return (0, _bluebirdLst().coroutine)(function* () {
  61. try {
  62. const data = yield _this.client.getVersion("_latest");
  63. const channelFilename = (0, _main().getChannelFilename)((0, _main().getDefaultChannelName)());
  64. const files = yield _this.client.getVersionFiles(data.name);
  65. const channelFile = files.find(it => it.name.endsWith(`_${channelFilename}`) || it.name.endsWith(`-${channelFilename}`));
  66. if (channelFile == null) {
  67. // noinspection ExceptionCaughtLocallyJS
  68. throw (0, _builderUtilRuntime().newError)(`Cannot find channel file "${channelFilename}", existing files:\n${files.map(it => JSON.stringify(it, null, 2)).join(",\n")}`, "ERR_UPDATER_CHANNEL_FILE_NOT_FOUND");
  69. }
  70. const channelFileUrl = new (_url().URL)(`https://dl.bintray.com/${_this.client.owner}/${_this.client.repo}/${channelFile.name}`);
  71. return (0, _Provider().parseUpdateInfo)((yield _this.httpRequest(channelFileUrl)), channelFilename, channelFileUrl);
  72. } catch (e) {
  73. if ("statusCode" in e && e.statusCode === 404) {
  74. throw (0, _builderUtilRuntime().newError)(`No latest version, please ensure that user, package and repository correctly configured. Or at least one version is published. ${e.stack || e.message}`, "ERR_UPDATER_LATEST_VERSION_NOT_FOUND");
  75. }
  76. throw e;
  77. }
  78. })();
  79. }
  80. resolveFiles(updateInfo) {
  81. return (0, _Provider().resolveFiles)(updateInfo, this.baseUrl);
  82. }
  83. } exports.BintrayProvider = BintrayProvider;
  84. //# sourceMappingURL=BintrayProvider.js.map