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