UNPKG

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