desktop-auto-update-environment.d.mts 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /** Environment variable that selects the Desktop update deployment. */
  2. export const DESKTOP_AUTO_UPDATE_ENV: 'DSH_DESKTOP_AUTO_UPDATE_ENV'
  3. /** Supported Desktop update deployment. */
  4. export type DesktopAutoUpdateEnvironment = 'test' | 'production'
  5. /** Directory name of one supported Desktop release target. */
  6. export type DesktopAutoUpdateTarget = 'mac-arm64' | 'mac-x64' | 'win-x64'
  7. /** Public updater URL for one release target. */
  8. export interface DesktopAutoUpdateConfig {
  9. readonly environment: DesktopAutoUpdateEnvironment
  10. readonly target: DesktopAutoUpdateTarget
  11. readonly origin: string
  12. readonly publicUrl: string
  13. readonly keyPrefix: string
  14. }
  15. /** Public updater URL and private COS destination for one upload target. */
  16. export interface DesktopUploadConfig extends DesktopAutoUpdateConfig {
  17. readonly bucket: string
  18. readonly secretIdEnvName: string
  19. readonly secretKeyEnvName: string
  20. }
  21. /**
  22. * Resolve the update deployment, defaulting local release work to test.
  23. * @param env - Packaging or upload environment.
  24. * @returns Validated deployment name.
  25. */
  26. export function resolveDesktopAutoUpdateEnvironment(
  27. env: NodeJS.ProcessEnv,
  28. ): DesktopAutoUpdateEnvironment
  29. /**
  30. * Resolve one supported platform and architecture to its update directory.
  31. * @param platform - Target Node.js platform.
  32. * @param arch - Target Node.js architecture.
  33. * @returns Update target directory.
  34. */
  35. export function resolveDesktopAutoUpdateTarget(
  36. platform: NodeJS.Platform,
  37. arch: string,
  38. ): DesktopAutoUpdateTarget
  39. /**
  40. * Return the local completion record filename for one packaged target.
  41. * @param target - Supported release target.
  42. * @returns Filename stored beside electron-builder artifacts.
  43. */
  44. export function desktopBuildRecordFilename(target: DesktopAutoUpdateTarget): string
  45. /**
  46. * Return the electron-builder channel metadata filename for an application version.
  47. * @param version - Desktop semantic version.
  48. * @param platform - Target platform.
  49. * @returns Channel metadata filename emitted for the target.
  50. */
  51. export function desktopUpdateMetadataFilename(
  52. version: string,
  53. platform: NodeJS.Platform,
  54. ): string
  55. /**
  56. * Resolve the public updater URL for one release target.
  57. * @param env - Packaging or upload environment.
  58. * @param platform - Target Node.js platform.
  59. * @param arch - Target Node.js architecture.
  60. * @returns Resolved updater configuration.
  61. * @throws When the test deployment lacks a valid HTTPS origin.
  62. */
  63. export function resolveDesktopAutoUpdateConfig(
  64. env: NodeJS.ProcessEnv,
  65. platform: NodeJS.Platform,
  66. arch: string,
  67. ): DesktopAutoUpdateConfig
  68. /**
  69. * Resolve the public updater URL and private COS destination for one upload target.
  70. * @param env - Upload environment.
  71. * @param platform - Target Node.js platform.
  72. * @param arch - Target Node.js architecture.
  73. * @returns Resolved upload configuration.
  74. * @throws When the selected deployment lacks a required origin or bucket, or the test origin is not HTTPS.
  75. */
  76. export function resolveDesktopUploadConfig(
  77. env: NodeJS.ProcessEnv,
  78. platform: NodeJS.Platform,
  79. arch: string,
  80. ): DesktopUploadConfig