|
1 | 1 | import BluebirdPromise from "bluebird-lst" |
2 | 2 | import { Arch, AsyncTaskManager, exec, InvalidConfigurationError, log } from "builder-util" |
3 | 3 | import { signAsync, SignOptions } from "electron-osx-sign" |
4 | | -import { ensureDir } from "fs-extra-p" |
| 4 | +import { ensureDir, readdir, remove } from "fs-extra-p" |
5 | 5 | import { Lazy } from "lazy-val" |
6 | 6 | import * as path from "path" |
7 | 7 | import { deepAssign } from "read-config-file/out/deepAssign" |
8 | 8 | import * as semver from "semver" |
| 9 | +import { AsarIntegrity } from "asar-integrity" |
| 10 | +import { asArray } from "builder-util-runtime/out" |
9 | 11 | import { AppInfo } from "./appInfo" |
10 | 12 | import { appleCertificatePrefixes, CertType, CodeSigningInfo, createKeychain, findIdentity, Identity, isSignAllowed, reportError } from "./codeSign" |
11 | 13 | import { DIR_TARGET, Platform, Target } from "./core" |
12 | 14 | import { MacConfiguration, MasConfiguration } from "./options/macOptions" |
13 | 15 | import { Packager } from "./packager" |
| 16 | +import { createMacApp } from "./packager/mac" |
14 | 17 | import { PlatformPackager } from "./platformPackager" |
15 | 18 | import { ArchiveTarget } from "./targets/ArchiveTarget" |
16 | 19 | import { DmgTarget } from "./targets/dmg" |
17 | 20 | import { PkgTarget, prepareProductBuildArgs } from "./targets/pkg" |
18 | 21 | import { createCommonTarget, NoOpTarget } from "./targets/targetFactory" |
| 22 | +import { CONCURRENCY } from "builder-util/out/fs" |
19 | 23 |
|
20 | 24 | export default class MacPackager extends PlatformPackager<MacConfiguration> { |
21 | 25 | readonly codeSigningInfo: Promise<CodeSigningInfo> |
@@ -255,6 +259,30 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> { |
255 | 259 | public getElectronDestinationDir(appOutDir: string) { |
256 | 260 | return path.join(appOutDir, this.electronDistMacOsAppName) |
257 | 261 | } |
| 262 | + |
| 263 | + protected async beforeCopyExtraFiles(appOutDir: string, asarIntegrity: AsarIntegrity | null): Promise<any> { |
| 264 | + await createMacApp(this, appOutDir, asarIntegrity) |
| 265 | + |
| 266 | + const wantedLanguages = asArray(this.platformSpecificBuildOptions.electronLanguages) |
| 267 | + if (wantedLanguages == null) { |
| 268 | + return |
| 269 | + } |
| 270 | + |
| 271 | + // noinspection SpellCheckingInspection |
| 272 | + const langFileExt = ".lproj" |
| 273 | + const resourcesDir = this.getResourcesDir(appOutDir) |
| 274 | + await BluebirdPromise.map(readdir(resourcesDir), file => { |
| 275 | + if (!file.endsWith(langFileExt)) { |
| 276 | + return |
| 277 | + } |
| 278 | + |
| 279 | + const language = file.substring(0, file.length - langFileExt.length) |
| 280 | + if (!wantedLanguages.includes(language)) { |
| 281 | + return remove(path.join(resourcesDir, file)) |
| 282 | + } |
| 283 | + return |
| 284 | + }, CONCURRENCY) |
| 285 | + } |
258 | 286 | } |
259 | 287 |
|
260 | 288 | function getCertificateType(isMas: boolean, isDevelopment: boolean): CertType { |
|
0 commit comments