configuration.d.ts 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. import { Arch } from "builder-util";
  2. import { BeforeBuildContext, Target } from "./core";
  3. import { ElectronBrandingOptions, ElectronDownloadOptions } from "./electron/ElectronFramework";
  4. import { PrepareApplicationStageDirectoryOptions } from "./Framework";
  5. import { AppXOptions } from "./options/AppXOptions";
  6. import { AppImageOptions, DebOptions, FlatpakOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from "./options/linuxOptions";
  7. import { DmgOptions, MacConfiguration, MasConfiguration } from "./options/macOptions";
  8. import { MsiOptions } from "./options/MsiOptions";
  9. import { MsiWrappedOptions } from "./options/MsiWrappedOptions";
  10. import { PkgOptions } from "./options/pkgOptions";
  11. import { PlatformSpecificBuildOptions } from "./options/PlatformSpecificBuildOptions";
  12. import { SnapOptions } from "./options/SnapOptions";
  13. import { SquirrelWindowsOptions } from "./options/SquirrelWindowsOptions";
  14. import { WindowsConfiguration } from "./options/winOptions";
  15. import { BuildResult } from "./packager";
  16. import { ArtifactBuildStarted, ArtifactCreated } from "./packagerApi";
  17. import { PlatformPackager } from "./platformPackager";
  18. import { NsisOptions, NsisWebOptions, PortableOptions } from "./targets/nsis/nsisOptions";
  19. /**
  20. * Configuration Options
  21. */
  22. export interface Configuration extends PlatformSpecificBuildOptions {
  23. /**
  24. * The application id. Used as [CFBundleIdentifier](https://developer.apple.com/library/ios/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070) for MacOS and as
  25. * [Application User Model ID](https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx) for Windows (NSIS target only, Squirrel.Windows not supported). It is strongly recommended that an explicit ID is set.
  26. * @default com.electron.${name}
  27. */
  28. readonly appId?: string | null;
  29. /**
  30. * As [name](#Metadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name).
  31. * If not specified inside of the `build` configuration, `productName` property defined at the top level of `package.json` is used. If not specified at the top level of `package.json`, [name property](https://docs.npmjs.com/files/package.json#name) is used.
  32. */
  33. readonly productName?: string | null;
  34. /**
  35. * The human-readable copyright line for the app.
  36. * @default Copyright © year ${author}
  37. */
  38. readonly copyright?: string | null;
  39. readonly directories?: MetadataDirectories | null;
  40. /**
  41. * Options related to how build macOS targets.
  42. */
  43. readonly mac?: MacConfiguration | null;
  44. /**
  45. * MAS (Mac Application Store) options.
  46. */
  47. readonly mas?: MasConfiguration | null;
  48. /**
  49. * MAS (Mac Application Store) development options (`mas-dev` target).
  50. */
  51. readonly masDev?: MasConfiguration | null;
  52. /**
  53. * macOS DMG options.
  54. */
  55. readonly dmg?: DmgOptions | null;
  56. /**
  57. * macOS PKG options.
  58. */
  59. readonly pkg?: PkgOptions | null;
  60. /**
  61. * Options related to how build Windows targets.
  62. */
  63. readonly win?: WindowsConfiguration | null;
  64. readonly nsis?: NsisOptions | null;
  65. readonly nsisWeb?: NsisWebOptions | null;
  66. readonly portable?: PortableOptions | null;
  67. readonly appx?: AppXOptions | null;
  68. /** @private */
  69. readonly msi?: MsiOptions | null;
  70. /** @private */
  71. readonly msiWrapped?: MsiWrappedOptions | null;
  72. readonly squirrelWindows?: SquirrelWindowsOptions | null;
  73. /**
  74. * Options related to how build Linux targets.
  75. */
  76. readonly linux?: LinuxConfiguration | null;
  77. /**
  78. * Debian package options.
  79. */
  80. readonly deb?: DebOptions | null;
  81. /**
  82. * Snap options.
  83. */
  84. readonly snap?: SnapOptions | null;
  85. /**
  86. * AppImage options.
  87. */
  88. readonly appImage?: AppImageOptions | null;
  89. /**
  90. * Flatpak options.
  91. */
  92. readonly flatpak?: FlatpakOptions | null;
  93. readonly pacman?: LinuxTargetSpecificOptions | null;
  94. readonly rpm?: LinuxTargetSpecificOptions | null;
  95. readonly freebsd?: LinuxTargetSpecificOptions | null;
  96. readonly p5p?: LinuxTargetSpecificOptions | null;
  97. readonly apk?: LinuxTargetSpecificOptions | null;
  98. /**
  99. * Whether to include *all* of the submodules node_modules directories
  100. * @default false
  101. */
  102. includeSubNodeModules?: boolean;
  103. /**
  104. * Whether to build the application native dependencies from source.
  105. * @default false
  106. */
  107. buildDependenciesFromSource?: boolean;
  108. /**
  109. * Whether to execute `node-gyp rebuild` before starting to package the app.
  110. *
  111. * Don't [use](https://github.com/electron-userland/electron-builder/issues/683#issuecomment-241214075) [npm](http://electron.atom.io/docs/tutorial/using-native-node-modules/#using-npm) (neither `.npmrc`) for configuring electron headers. Use `electron-builder node-gyp-rebuild` instead.
  112. * @default false
  113. */
  114. readonly nodeGypRebuild?: boolean;
  115. /**
  116. * Additional command line arguments to use when installing app native deps.
  117. */
  118. readonly npmArgs?: Array<string> | string | null;
  119. /**
  120. * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.
  121. * @default true
  122. */
  123. readonly npmRebuild?: boolean;
  124. /**
  125. * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.
  126. * If not defined, then it will fallback to `BUILD_NUMBER` or `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_BUILDNUMBER` or `CI_PIPELINE_IID` env.
  127. */
  128. readonly buildNumber?: string | null;
  129. /**
  130. * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.
  131. * If `buildVersion` is not defined and `buildNumber` (or one of the `buildNumber` envs) is defined, it will be used as a build version (`version.buildNumber`).
  132. */
  133. readonly buildVersion?: string | null;
  134. /**
  135. * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing
  136. */
  137. readonly downloadAlternateFFmpeg?: boolean;
  138. /**
  139. * Whether to use [electron-compile](http://github.com/electron/electron-compile) to compile app. Defaults to `true` if `electron-compile` in the dependencies. And `false` if in the `devDependencies` or doesn't specified.
  140. */
  141. readonly electronCompile?: boolean;
  142. /**
  143. * Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory
  144. */
  145. readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string);
  146. /**
  147. * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.
  148. */
  149. readonly electronDownload?: ElectronDownloadOptions;
  150. /**
  151. * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.
  152. */
  153. readonly electronBranding?: ElectronBrandingOptions;
  154. /**
  155. * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.
  156. */
  157. electronVersion?: string | null;
  158. /**
  159. * The name of a built-in configuration preset (currently, only `react-cra` is supported) or any number of paths to config files (relative to project dir).
  160. *
  161. * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.
  162. *
  163. * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.
  164. */
  165. extends?: Array<string> | string | null;
  166. /**
  167. * Inject properties to `package.json`.
  168. */
  169. readonly extraMetadata?: any;
  170. /**
  171. * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).
  172. * @default false
  173. */
  174. readonly forceCodeSigning?: boolean;
  175. /**
  176. * *libui-based frameworks only* The version of NodeJS you are packaging for.
  177. * You can set it to `current` to set the Node.js version that you use to run.
  178. */
  179. readonly nodeVersion?: string | null;
  180. /**
  181. * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.
  182. */
  183. readonly launchUiVersion?: boolean | string | null;
  184. /**
  185. * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.
  186. */
  187. readonly framework?: string | null;
  188. /**
  189. * The function (or path to file or module id) to be [run before pack](#beforepack)
  190. */
  191. readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null;
  192. /**
  193. * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
  194. */
  195. readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
  196. /**
  197. * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).
  198. */
  199. readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
  200. /**
  201. * The function (or path to file or module id) to be run on artifact build start.
  202. */
  203. readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null;
  204. /**
  205. * The function (or path to file or module id) to be run on artifact build completed.
  206. */
  207. readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null;
  208. /**
  209. * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).
  210. */
  211. readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null;
  212. /**
  213. * MSI project created on disk - not packed into .msi package yet.
  214. */
  215. readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null;
  216. /**
  217. * Appx manifest created on disk - not packed into .appx package yet.
  218. */
  219. readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null;
  220. /**
  221. * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file.
  222. */
  223. readonly onNodeModuleFile?: ((file: string) => void) | string | null;
  224. /**
  225. * The function (or path to file or module id) to be run before dependencies are installed or rebuilt. Works when `npmRebuild` is set to `true`. Resolving to `false` will skip dependencies install or rebuild.
  226. *
  227. * If provided and `node_modules` are missing, it will not invoke production dependencies check.
  228. */
  229. readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null;
  230. /**
  231. * Whether to include PDB files.
  232. * @default false
  233. */
  234. readonly includePdb?: boolean;
  235. /**
  236. * Whether to remove `scripts` field from `package.json` files.
  237. *
  238. * @default true
  239. */
  240. readonly removePackageScripts?: boolean;
  241. /**
  242. * Whether to remove `keywords` field from `package.json` files.
  243. *
  244. * @default true
  245. */
  246. readonly removePackageKeywords?: boolean;
  247. }
  248. interface PackContext {
  249. readonly outDir: string;
  250. readonly appOutDir: string;
  251. readonly packager: PlatformPackager<any>;
  252. readonly electronPlatformName: string;
  253. readonly arch: Arch;
  254. readonly targets: Array<Target>;
  255. }
  256. export declare type AfterPackContext = PackContext;
  257. export declare type BeforePackContext = PackContext;
  258. export interface MetadataDirectories {
  259. /**
  260. * The path to build resources.
  261. *
  262. * Please note — build resources are not packed into the app. If you need to use some files, e.g. as tray icon, please include required files explicitly: `"files": ["**\/*", "build/icon.*"]`
  263. * @default build
  264. */
  265. readonly buildResources?: string | null;
  266. /**
  267. * The output directory. [File macros](/file-patterns#file-macros) are supported.
  268. * @default dist
  269. */
  270. readonly output?: string | null;
  271. /**
  272. * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.
  273. */
  274. readonly app?: string | null;
  275. }
  276. export {};