UNPKG

9.52 kBTypeScriptView Raw
1import { Arch } from "builder-util";
2import { BeforeBuildContext, Target } from "./core";
3import { ElectronDownloadOptions } from "./electron/electron-download";
4import { AppXOptions } from "./options/AppXOptions";
5import { AppImageOptions, DebOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from "./options/linuxOptions";
6import { DmgOptions, MacConfiguration, MasConfiguration, PkgOptions } from "./options/macOptions";
7import { MsiOptions } from "./options/MsiOptions";
8import { PlatformSpecificBuildOptions } from "./options/PlatformSpecificBuildOptions";
9import { SnapOptions } from "./options/SnapOptions";
10import { SquirrelWindowsOptions } from "./options/SquirrelWindowsOptions";
11import { WindowsConfiguration } from "./options/winOptions";
12import { BuildResult } from "./packager";
13import { PlatformPackager } from "./platformPackager";
14import { NsisOptions, NsisWebOptions, PortableOptions } from "./targets/nsis/nsisOptions";
15/**
16 * Configuration Options
17 */
18export interface Configuration extends PlatformSpecificBuildOptions {
19 /**
20 * 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
21 * [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.
22 * @default com.electron.${name}
23 */
24 readonly appId?: string | null;
25 /**
26 * 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).
27 */
28 readonly productName?: string | null;
29 /**
30 * The human-readable copyright line for the app.
31 * @default Copyright © year ${author}
32 */
33 readonly copyright?: string | null;
34 readonly directories?: MetadataDirectories | null;
35 /**
36 * Options related to how build macOS targets.
37 */
38 readonly mac?: MacConfiguration | null;
39 /**
40 * MAS (Mac Application Store) options.
41 */
42 readonly mas?: MasConfiguration | null;
43 /**
44 * macOS DMG options.
45 */
46 readonly dmg?: DmgOptions | null;
47 /**
48 * macOS PKG options.
49 */
50 readonly pkg?: PkgOptions | null;
51 /**
52 * Options related to how build Windows targets.
53 */
54 readonly win?: WindowsConfiguration | null;
55 readonly nsis?: NsisOptions | null;
56 readonly nsisWeb?: NsisWebOptions | null;
57 readonly portable?: PortableOptions | null;
58 readonly appx?: AppXOptions | null;
59 /** @private */
60 readonly msi?: MsiOptions | null;
61 readonly squirrelWindows?: SquirrelWindowsOptions | null;
62 /**
63 * Options related to how build Linux targets.
64 */
65 readonly linux?: LinuxConfiguration | null;
66 /**
67 * Debian package options.
68 */
69 readonly deb?: DebOptions | null;
70 /**
71 * Snap options.
72 */
73 readonly snap?: SnapOptions | null;
74 /**
75 * AppImage options.
76 */
77 readonly appImage?: AppImageOptions | null;
78 readonly pacman?: LinuxTargetSpecificOptions | null;
79 readonly rpm?: LinuxTargetSpecificOptions | null;
80 readonly freebsd?: LinuxTargetSpecificOptions | null;
81 readonly p5p?: LinuxTargetSpecificOptions | null;
82 readonly apk?: LinuxTargetSpecificOptions | null;
83 /**
84 * Whether to build the application native dependencies from source.
85 * @default false
86 */
87 buildDependenciesFromSource?: boolean;
88 /**
89 * Whether to execute `node-gyp rebuild` before starting to package the app.
90 *
91 * 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.
92 * @default false
93 */
94 readonly nodeGypRebuild?: boolean;
95 /**
96 * Additional command line arguments to use when installing app native deps.
97 */
98 readonly npmArgs?: Array<string> | string | null;
99 /**
100 * Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies before starting to package the app.
101 * @default true
102 */
103 readonly npmRebuild?: boolean;
104 /**
105 * @deprecated Please use npmBuildFromSource.
106 * @private
107 */
108 readonly npmSkipBuildFromSource?: boolean;
109 /**
110 * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.
111 * If `TRAVIS_BUILD_NUMBER` or `APPVEYOR_BUILD_NUMBER` or `CIRCLE_BUILD_NUM` or `BUILD_NUMBER` or `bamboo.buildNumber` env defined, it will be used as a build version (`version.build_number`).
112 */
113 readonly buildVersion?: string | null;
114 /**
115 * 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.
116 */
117 readonly electronCompile?: boolean;
118 /**
119 * The path to custom Electron build (e.g. `~/electron/out/R`).
120 */
121 readonly electronDist?: string;
122 /**
123 * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.
124 */
125 readonly electronDownload?: ElectronDownloadOptions;
126 /**
127 * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.
128 */
129 electronVersion?: string | null;
130 /**
131 * The name of a built-in configuration preset or path to config file (relative to project dir). Currently, only `react-cra` is supported.
132 *
133 * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.
134 */
135 extends?: string | null;
136 /**
137 * Inject properties to `package.json`.
138 */
139 readonly extraMetadata?: any;
140 /**
141 * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).
142 * @default false
143 */
144 readonly?: boolean;
145 /**
146 * The version of muon you are packaging for.
147 */
148 readonly muonVersion?: string | null;
149 /**
150 * *Proton Native only* The version of NodeJS you are packaging for.
151 * You can set it to `current` to set the Node.js version that you use to run electron-builder.
152 */
153 readonly protonNodeVersion?: string | null;
154 /**
155 * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
156 */
157 readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
158 /**
159 * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).
160 */
161 readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
162 /**
163 * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).
164 */
165 readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null;
166 /**
167 * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file.
168 */
169 readonly onNodeModuleFile?: ((file: string) => void) | string | null;
170 /**
171 * 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.
172 *
173 * If provided and `node_modules` are missing, it will not invoke production dependencies check.
174 */
175 readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null;
176 /**
177 * Whether to build using Electron Build Service if target not supported on current OS.
178 * @default true
179 */
180 readonly remoteBuild?: boolean;
181 /**
182 * Whether to include PDB files.
183 * @default false
184 */
185 readonly includePdb?: boolean;
186 /**
187 * Whether to remove `scripts` field from `package.json` files.
188 *
189 * @default true
190 */
191 readonly removePackageScripts?: boolean;
192}
193export interface AfterPackContext {
194 readonly outDir: string;
195 readonly appOutDir: string;
196 readonly packager: PlatformPackager<any>;
197 readonly electronPlatformName: string;
198 readonly arch: Arch;
199 readonly targets: Array<Target>;
200}
201export interface MetadataDirectories {
202 /**
203 * The path to build resources.
204 *
205 * Please notebuild resources is 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.*"]`
206 * @default build
207 */
208 readonly buildResources?: string | null;
209 /**
210 * The output directory. [File macros](/file-patterns.md#file-macros) are supported.
211 * @default dist
212 */
213 readonly output?: string | null;
214 /**
215 * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.
216 */
217 readonly app?: string | null;
218}
219
\No newline at end of file