spacesPublisher.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. const builder_util_1 = require("builder-util");
  4. const BaseS3Publisher_1 = require("./BaseS3Publisher");
  5. class SpacesPublisher extends BaseS3Publisher_1.BaseS3Publisher {
  6. constructor(context, info) {
  7. super(context, info);
  8. this.info = info;
  9. this.providerName = "spaces";
  10. }
  11. // eslint-disable-next-line @typescript-eslint/no-unused-vars
  12. static checkAndResolveOptions(options, channelFromAppVersion, errorIfCannot) {
  13. if (options.name == null) {
  14. throw new builder_util_1.InvalidConfigurationError(`Please specify "name" for "spaces" publish provider (see https://www.electron.build/configuration/publish#spacesoptions)`);
  15. }
  16. if (options.region == null) {
  17. throw new builder_util_1.InvalidConfigurationError(`Please specify "region" for "spaces" publish provider (see https://www.electron.build/configuration/publish#spacesoptions)`);
  18. }
  19. if (options.channel == null && channelFromAppVersion != null) {
  20. options.channel = channelFromAppVersion;
  21. }
  22. return Promise.resolve();
  23. }
  24. getBucketName() {
  25. return this.info.name;
  26. }
  27. configureS3Options(args) {
  28. super.configureS3Options(args);
  29. args.push("--endpoint", `${this.info.region}.digitaloceanspaces.com`);
  30. args.push("--region", this.info.region);
  31. const accessKey = process.env.DO_KEY_ID;
  32. const secretKey = process.env.DO_SECRET_KEY;
  33. if ((0, builder_util_1.isEmptyOrSpaces)(accessKey)) {
  34. throw new builder_util_1.InvalidConfigurationError("Please set env DO_KEY_ID (see https://www.electron.build/configuration/publish#spacesoptions)");
  35. }
  36. if ((0, builder_util_1.isEmptyOrSpaces)(secretKey)) {
  37. throw new builder_util_1.InvalidConfigurationError("Please set env DO_SECRET_KEY (see https://www.electron.build/configuration/publish#spacesoptions)");
  38. }
  39. args.push("--accessKey", accessKey);
  40. args.push("--secretKey", secretKey);
  41. }
  42. }
  43. exports.default = SpacesPublisher;
  44. //# sourceMappingURL=spacesPublisher.js.map