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 | * Use `legacy` app-builder binary for installing native dependencies, or `@electron/rebuild` in `sequential` or `parallel` compilation modes.
|
126 | * @default sequential
|
127 | */
|
128 | readonly nativeRebuilder?: "legacy" | "sequential" | "parallel" | null;
|
129 | /**
|
130 | * The build number. Maps to the `--iteration` flag for builds using FPM on Linux.
|
131 | * 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.
|
132 | */
|
133 | readonly buildNumber?: string | null;
|
134 | /**
|
135 | * The build version. Maps to the `CFBundleVersion` on macOS, and `FileVersion` metadata property on Windows. Defaults to the `version`.
|
136 | * 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`).
|
137 | */
|
138 | readonly buildVersion?: string | null;
|
139 | /**
|
140 | * Whether to download the alternate FFmpeg library from Electron's release assets and replace the default FFmpeg library prior to signing
|
141 | */
|
142 | readonly downloadAlternateFFmpeg?: boolean;
|
143 | /**
|
144 | * 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.
|
145 | */
|
146 | readonly electronCompile?: boolean;
|
147 | /**
|
148 | * 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
|
149 | */
|
150 | readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string);
|
151 | /**
|
152 | * The [electron-download](https://github.com/electron-userland/electron-download#usage) options.
|
153 | */
|
154 | readonly electronDownload?: ElectronDownloadOptions;
|
155 | /**
|
156 | * The branding used by Electron's distributables. This is needed if a fork has modified Electron's BRANDING.json file.
|
157 | */
|
158 | readonly electronBranding?: ElectronBrandingOptions;
|
159 | /**
|
160 | * The version of electron you are packaging for. Defaults to version of `electron`, `electron-prebuilt` or `electron-prebuilt-compile` dependency.
|
161 | */
|
162 | electronVersion?: string | null;
|
163 | /**
|
164 | * 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).
|
165 | *
|
166 | * The latter allows to mixin a config from multiple other configs, as if you `Object.assign` them, but properly combine `files` glob patterns.
|
167 | *
|
168 | * If `react-scripts` in the app dependencies, `react-cra` will be set automatically. Set to `null` to disable automatic detection.
|
169 | */
|
170 | extends?: Array<string> | string | null;
|
171 | /**
|
172 | * Inject properties to `package.json`.
|
173 | */
|
174 | readonly extraMetadata?: any;
|
175 | /**
|
176 | * Whether to fail if the application is not signed (to prevent unsigned app if code signing configuration is not correct).
|
177 | * @default false
|
178 | */
|
179 | readonly forceCodeSigning?: boolean;
|
180 | /**
|
181 | * *libui-based frameworks only* The version of NodeJS you are packaging for.
|
182 | * You can set it to `current` to set the Node.js version that you use to run.
|
183 | */
|
184 | readonly nodeVersion?: string | null;
|
185 | /**
|
186 | * *libui-based frameworks only* The version of LaunchUI you are packaging for. Applicable for Windows only. Defaults to version suitable for used framework version.
|
187 | */
|
188 | readonly launchUiVersion?: boolean | string | null;
|
189 | /**
|
190 | * The framework name. One of `electron`, `proton`, `libui`. Defaults to `electron`.
|
191 | */
|
192 | readonly framework?: string | null;
|
193 | /**
|
194 | * The function (or path to file or module id) to be [run before pack](#beforepack)
|
195 | */
|
196 | readonly beforePack?: ((context: BeforePackContext) => Promise<any> | any) | string | null;
|
197 | /**
|
198 | * The function (or path to file or module id) to be [run after the prebuilt Electron binary has been extracted to the output directory](#afterextract)
|
199 | */
|
200 | readonly afterExtract?: ((context: AfterExtractContext) => Promise<any> | any) | string | null;
|
201 | /**
|
202 | * The function (or path to file or module id) to be [run after pack](#afterpack) (but before pack into distributable format and sign).
|
203 | */
|
204 | readonly afterPack?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
|
205 | /**
|
206 | * The function (or path to file or module id) to be [run after pack and sign](#aftersign) (but before pack into distributable format).
|
207 | */
|
208 | readonly afterSign?: ((context: AfterPackContext) => Promise<any> | any) | string | null;
|
209 | /**
|
210 | * The function (or path to file or module id) to be run on artifact build start.
|
211 | */
|
212 | readonly artifactBuildStarted?: ((context: ArtifactBuildStarted) => Promise<any> | any) | string | null;
|
213 | /**
|
214 | * The function (or path to file or module id) to be run on artifact build completed.
|
215 | */
|
216 | readonly artifactBuildCompleted?: ((context: ArtifactCreated) => Promise<any> | any) | string | null;
|
217 | /**
|
218 | * The function (or path to file or module id) to be [run after all artifacts are build](#afterAllArtifactBuild).
|
219 | */
|
220 | readonly afterAllArtifactBuild?: ((context: BuildResult) => Promise<Array<string>> | Array<string>) | string | null;
|
221 | /**
|
222 | * MSI project created on disk - not packed into .msi package yet.
|
223 | */
|
224 | readonly msiProjectCreated?: ((path: string) => Promise<any> | any) | string | null;
|
225 | /**
|
226 | * Appx manifest created on disk - not packed into .appx package yet.
|
227 | */
|
228 | readonly appxManifestCreated?: ((path: string) => Promise<any> | any) | string | null;
|
229 | /**
|
230 | * The function (or path to file or module id) to be [run on each node module](#onnodemodulefile) file. Returning `true`/`false` will determine whether to force include or to use the default copier logic
|
231 | */
|
232 | readonly onNodeModuleFile?: ((path: string) => void | boolean) | string | null;
|
233 | /**
|
234 | * 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.
|
235 | *
|
236 | * If provided and `node_modules` are missing, it will not invoke production dependencies check.
|
237 | */
|
238 | readonly beforeBuild?: ((context: BeforeBuildContext) => Promise<any>) | string | null;
|
239 | /**
|
240 | * Whether to include PDB files.
|
241 | * @default false
|
242 | */
|
243 | readonly includePdb?: boolean;
|
244 | /**
|
245 | * Whether to remove `scripts` field from `package.json` files.
|
246 | *
|
247 | * @default true
|
248 | */
|
249 | readonly removePackageScripts?: boolean;
|
250 | /**
|
251 | * Whether to remove `keywords` field from `package.json` files.
|
252 | *
|
253 | * @default true
|
254 | */
|
255 | readonly removePackageKeywords?: boolean;
|
256 | /**
|
257 | * Whether to disable sanity check asar package (useful for custom electron forks that implement their own encrypted integrity validation)
|
258 | * @default false
|
259 | */
|
260 | readonly disableSanityCheckAsar?: boolean;
|
261 | }
|
262 | interface PackContext {
|
263 | readonly outDir: string;
|
264 | readonly appOutDir: string;
|
265 | readonly packager: PlatformPackager<any>;
|
266 | readonly electronPlatformName: string;
|
267 | readonly arch: Arch;
|
268 | readonly targets: Array<Target>;
|
269 | }
|
270 | export type AfterPackContext = PackContext;
|
271 | export type BeforePackContext = PackContext;
|
272 | export type AfterExtractContext = PackContext;
|
273 | export interface MetadataDirectories {
|
274 | /**
|
275 | * The path to build resources.
|
276 | *
|
277 | * 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.*"]`
|
278 | * @default build
|
279 | */
|
280 | readonly buildResources?: string | null;
|
281 | /**
|
282 | * The output directory. [File macros](/file-patterns#file-macros) are supported.
|
283 | * @default dist
|
284 | */
|
285 | readonly output?: string | null;
|
286 | /**
|
287 | * The application directory (containing the application package.json), defaults to `app`, `www` or working directory.
|
288 | */
|
289 | readonly app?: string | null;
|
290 | }
|
291 | export {};
|
292 |
|
\ | No newline at end of file |