dmg-builder 26.0.17 → 26.0.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/dmg.d.ts +33 -1
- package/out/dmg.js +7 -170
- package/out/dmg.js.map +1 -1
- package/out/dmgUtil.d.ts +16 -2
- package/out/dmgUtil.js +152 -1
- package/out/dmgUtil.js.map +1 -1
- package/out/hdiuil.js +1 -1
- package/out/hdiuil.js.map +1 -1
- package/package.json +3 -4
- package/vendor/biplist/__init__.py +75 -75
- package/vendor/dmgbuild/__init__.py +5 -0
- package/vendor/dmgbuild/__main__.py +67 -0
- package/vendor/dmgbuild/badge.py +104 -78
- package/vendor/dmgbuild/colors.py +239 -229
- package/vendor/dmgbuild/core.py +945 -274
- package/vendor/dmgbuild/licensing.py +329 -0
- package/vendor/dmgbuild/resources/builtin-arrow.tiff +0 -0
- package/vendor/ds_store/__init__.py +3 -1
- package/vendor/ds_store/__main__.py +102 -0
- package/vendor/ds_store/buddy.py +142 -134
- package/vendor/ds_store/store.py +333 -322
- package/vendor/mac_alias/__init__.py +43 -23
- package/vendor/mac_alias/alias.py +334 -224
- package/vendor/mac_alias/bookmark.py +283 -278
- package/vendor/mac_alias/osx.py +406 -302
- package/vendor/mac_alias/utils.py +10 -8
- package/vendor/run_dmgbuild.py +14 -0
package/out/dmg.d.ts
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
import { DmgOptions, Target } from "app-builder-lib";
|
|
2
2
|
import { MacPackager } from "app-builder-lib/out/macPackager";
|
|
3
3
|
import { Arch } from "builder-util";
|
|
4
|
+
export interface DmgBuildConfig {
|
|
5
|
+
title: string;
|
|
6
|
+
icon?: string | null;
|
|
7
|
+
"badge-icon"?: string | null;
|
|
8
|
+
background?: string | null;
|
|
9
|
+
"background-color"?: string | null;
|
|
10
|
+
"icon-size"?: number | null;
|
|
11
|
+
"text-size"?: number | null;
|
|
12
|
+
window?: {
|
|
13
|
+
position?: {
|
|
14
|
+
x?: number;
|
|
15
|
+
y?: number;
|
|
16
|
+
};
|
|
17
|
+
size?: {
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
format?: string;
|
|
23
|
+
filesystem?: string;
|
|
24
|
+
"compression-level"?: number | null;
|
|
25
|
+
license?: string | null;
|
|
26
|
+
contents?: Array<{
|
|
27
|
+
path: string;
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
name?: string;
|
|
31
|
+
type?: "file" | "link" | "position";
|
|
32
|
+
hide_extension?: boolean;
|
|
33
|
+
hidden?: boolean;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
4
36
|
export declare class DmgTarget extends Target {
|
|
5
37
|
private readonly packager;
|
|
6
38
|
readonly outDir: string;
|
|
@@ -10,5 +42,5 @@ export declare class DmgTarget extends Target {
|
|
|
10
42
|
build(appPath: string, arch: Arch): Promise<void>;
|
|
11
43
|
private signDmg;
|
|
12
44
|
computeVolumeName(arch: Arch, custom?: string | null): string;
|
|
13
|
-
computeDmgOptions(): Promise<DmgOptions>;
|
|
45
|
+
computeDmgOptions(appPath: string): Promise<DmgOptions>;
|
|
14
46
|
}
|
package/out/dmg.js
CHANGED
|
@@ -4,10 +4,8 @@ exports.DmgTarget = void 0;
|
|
|
4
4
|
const app_builder_lib_1 = require("app-builder-lib");
|
|
5
5
|
const macCodeSign_1 = require("app-builder-lib/out/codeSign/macCodeSign");
|
|
6
6
|
const differentialUpdateInfoBuilder_1 = require("app-builder-lib/out/targets/differentialUpdateInfoBuilder");
|
|
7
|
-
const appBuilder_1 = require("app-builder-lib/out/util/appBuilder");
|
|
8
7
|
const builder_util_1 = require("builder-util");
|
|
9
8
|
const filename_1 = require("builder-util/out/filename");
|
|
10
|
-
const fs_extra_1 = require("fs-extra");
|
|
11
9
|
const os_1 = require("os");
|
|
12
10
|
const path = require("path");
|
|
13
11
|
const dmgLicense_1 = require("./dmgLicense");
|
|
@@ -32,27 +30,10 @@ class DmgTarget extends app_builder_lib_1.Target {
|
|
|
32
30
|
arch,
|
|
33
31
|
});
|
|
34
32
|
const volumeName = (0, filename_1.sanitizeFileName)(this.computeVolumeName(arch, this.options.title));
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
// https://github.com/electron-userland/electron-builder/issues/2115
|
|
38
|
-
const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager);
|
|
39
|
-
const finalSize = await computeAssetSize(packager.info.cancellationToken, tempDmg, specification, backgroundFile);
|
|
40
|
-
const expandingFinalSize = Math.ceil(finalSize * 0.1 + finalSize);
|
|
41
|
-
await (0, hdiuil_1.hdiUtil)(["resize", "-size", expandingFinalSize.toString(), tempDmg]);
|
|
42
|
-
const volumePath = path.join("/Volumes", volumeName);
|
|
43
|
-
if (await (0, builder_util_1.exists)(volumePath)) {
|
|
44
|
-
builder_util_1.log.debug({ volumePath }, "unmounting previous disk image");
|
|
45
|
-
await (0, dmgUtil_1.detach)(volumePath);
|
|
46
|
-
}
|
|
47
|
-
if (!(await (0, dmgUtil_1.attachAndExecute)(tempDmg, true, () => customizeDmg(volumePath, specification, packager, backgroundFile)))) {
|
|
33
|
+
const specification = await this.computeDmgOptions(appPath);
|
|
34
|
+
if (!(await (0, dmgUtil_1.customizeDmg)({ appPath, artifactPath, volumeName, specification, packager }))) {
|
|
48
35
|
return;
|
|
49
36
|
}
|
|
50
|
-
// dmg file must not exist otherwise hdiutil failed (https://github.com/electron-userland/electron-builder/issues/1308#issuecomment-282847594), so, -ov must be specified
|
|
51
|
-
const args = ["convert", tempDmg, "-ov", "-format", specification.format, "-o", artifactPath];
|
|
52
|
-
if (specification.format === "UDZO") {
|
|
53
|
-
args.push("-imagekey", `zlib-level=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || "9"}`);
|
|
54
|
-
}
|
|
55
|
-
await (0, hdiuil_1.hdiUtil)(addLogLevel(args));
|
|
56
37
|
if (this.options.internetEnabled && parseInt((0, os_1.release)().split(".")[0], 10) < 19) {
|
|
57
38
|
await (0, hdiuil_1.hdiUtil)(addLogLevel(["internet-enable"]).concat(artifactPath));
|
|
58
39
|
}
|
|
@@ -117,7 +98,7 @@ class DmgTarget extends app_builder_lib_1.Target {
|
|
|
117
98
|
.replace(/\${productName}/g, appInfo.productName);
|
|
118
99
|
}
|
|
119
100
|
// public to test
|
|
120
|
-
async computeDmgOptions() {
|
|
101
|
+
async computeDmgOptions(appPath) {
|
|
121
102
|
const packager = this.packager;
|
|
122
103
|
const specification = { ...this.options };
|
|
123
104
|
if (specification.icon == null && specification.icon !== null) {
|
|
@@ -136,11 +117,10 @@ class DmgTarget extends app_builder_lib_1.Target {
|
|
|
136
117
|
specification.background = await (0, dmgUtil_1.computeBackground)(packager);
|
|
137
118
|
}
|
|
138
119
|
else {
|
|
139
|
-
specification.background =
|
|
120
|
+
specification.background = await packager.getResource(background);
|
|
140
121
|
}
|
|
141
122
|
if (specification.format == null) {
|
|
142
123
|
if (process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL != null) {
|
|
143
|
-
;
|
|
144
124
|
specification.format = "UDZO";
|
|
145
125
|
}
|
|
146
126
|
else if (packager.compression === "store") {
|
|
@@ -155,6 +135,9 @@ class DmgTarget extends app_builder_lib_1.Target {
|
|
|
155
135
|
{
|
|
156
136
|
x: 130,
|
|
157
137
|
y: 220,
|
|
138
|
+
path: appPath,
|
|
139
|
+
type: "file",
|
|
140
|
+
name: `${packager.appInfo.productFilename}.app`,
|
|
158
141
|
},
|
|
159
142
|
{
|
|
160
143
|
x: 410,
|
|
@@ -168,154 +151,8 @@ class DmgTarget extends app_builder_lib_1.Target {
|
|
|
168
151
|
}
|
|
169
152
|
}
|
|
170
153
|
exports.DmgTarget = DmgTarget;
|
|
171
|
-
async function createStageDmg(tempDmg, appPath, volumeName) {
|
|
172
|
-
const createArgs = ["create", "-srcfolder", appPath, "-volname", volumeName, "-anyowners", "-nospotlight", "-format", "UDRW"];
|
|
173
|
-
const imageArgs = addLogLevel(createArgs);
|
|
174
|
-
if (builder_util_1.log.isDebugEnabled) {
|
|
175
|
-
imageArgs.push("-debug");
|
|
176
|
-
}
|
|
177
|
-
imageArgs.push("-fs", "APFS");
|
|
178
|
-
imageArgs.push(tempDmg);
|
|
179
|
-
await (0, hdiuil_1.hdiUtil)(imageArgs).catch(async (e) => {
|
|
180
|
-
if (hdiuil_1.hdiutilTransientExitCodes.has(e.code)) {
|
|
181
|
-
// Delay then create, then retry with verbose output
|
|
182
|
-
await new Promise(resolve => setTimeout(resolve, 3000));
|
|
183
|
-
return (0, hdiuil_1.hdiUtil)(addLogLevel(createArgs, true));
|
|
184
|
-
}
|
|
185
|
-
throw e;
|
|
186
|
-
});
|
|
187
|
-
return tempDmg;
|
|
188
|
-
}
|
|
189
154
|
function addLogLevel(args, isVerbose = process.env.DEBUG_DMG === "true") {
|
|
190
155
|
args.push(isVerbose ? "-verbose" : "-quiet");
|
|
191
156
|
return args;
|
|
192
157
|
}
|
|
193
|
-
async function computeAssetSize(cancellationToken, dmgFile, specification, backgroundFile) {
|
|
194
|
-
const asyncTaskManager = new builder_util_1.AsyncTaskManager(cancellationToken);
|
|
195
|
-
asyncTaskManager.addTask((0, fs_extra_1.stat)(dmgFile));
|
|
196
|
-
if (specification.icon != null) {
|
|
197
|
-
asyncTaskManager.addTask((0, builder_util_1.statOrNull)(specification.icon));
|
|
198
|
-
}
|
|
199
|
-
if (backgroundFile != null) {
|
|
200
|
-
asyncTaskManager.addTask((0, fs_extra_1.stat)(backgroundFile));
|
|
201
|
-
}
|
|
202
|
-
let result = 32 * 1024;
|
|
203
|
-
for (const stat of await asyncTaskManager.awaitTasks()) {
|
|
204
|
-
if (stat != null) {
|
|
205
|
-
result += stat.size;
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return result;
|
|
209
|
-
}
|
|
210
|
-
async function customizeDmg(volumePath, specification, packager, backgroundFile) {
|
|
211
|
-
const window = specification.window;
|
|
212
|
-
const isValidIconTextSize = !!specification.iconTextSize && specification.iconTextSize >= 10 && specification.iconTextSize <= 16;
|
|
213
|
-
const iconTextSize = isValidIconTextSize ? specification.iconTextSize : 12;
|
|
214
|
-
const env = {
|
|
215
|
-
...process.env,
|
|
216
|
-
volumePath,
|
|
217
|
-
appFileName: `${packager.appInfo.productFilename}.app`,
|
|
218
|
-
iconSize: specification.iconSize || 80,
|
|
219
|
-
iconTextSize,
|
|
220
|
-
PYTHONIOENCODING: "utf8",
|
|
221
|
-
};
|
|
222
|
-
if (specification.backgroundColor != null || specification.background == null) {
|
|
223
|
-
env.backgroundColor = specification.backgroundColor || "#ffffff";
|
|
224
|
-
if (window != null) {
|
|
225
|
-
env.windowX = (window.x == null ? 100 : window.x).toString();
|
|
226
|
-
env.windowY = (window.y == null ? 400 : window.y).toString();
|
|
227
|
-
env.windowWidth = (window.width || 540).toString();
|
|
228
|
-
env.windowHeight = (window.height || 380).toString();
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
else {
|
|
232
|
-
delete env.backgroundColor;
|
|
233
|
-
}
|
|
234
|
-
const args = ["dmg", "--volume", volumePath];
|
|
235
|
-
if (specification.icon != null) {
|
|
236
|
-
args.push("--icon", (await packager.getResource(specification.icon)));
|
|
237
|
-
}
|
|
238
|
-
if (backgroundFile != null) {
|
|
239
|
-
args.push("--background", backgroundFile);
|
|
240
|
-
}
|
|
241
|
-
const data = await (0, appBuilder_1.executeAppBuilderAsJson)(args);
|
|
242
|
-
if (data.backgroundWidth != null) {
|
|
243
|
-
env.windowWidth = window == null ? null : window.width;
|
|
244
|
-
env.windowHeight = window == null ? null : window.height;
|
|
245
|
-
if (env.windowWidth == null) {
|
|
246
|
-
env.windowWidth = data.backgroundWidth.toString();
|
|
247
|
-
}
|
|
248
|
-
if (env.windowHeight == null) {
|
|
249
|
-
env.windowHeight = data.backgroundHeight.toString();
|
|
250
|
-
}
|
|
251
|
-
if (env.windowX == null) {
|
|
252
|
-
env.windowX = 400;
|
|
253
|
-
}
|
|
254
|
-
if (env.windowY == null) {
|
|
255
|
-
env.windowY = Math.round((1440 - env.windowHeight) / 2).toString();
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
Object.assign(env, data);
|
|
259
|
-
const asyncTaskManager = new builder_util_1.AsyncTaskManager(packager.info.cancellationToken);
|
|
260
|
-
env.iconLocations = await computeDmgEntries(specification, volumePath, packager, asyncTaskManager);
|
|
261
|
-
await asyncTaskManager.awaitTasks();
|
|
262
|
-
const executePython = async (execName) => {
|
|
263
|
-
let pythonPath = process.env.PYTHON_PATH;
|
|
264
|
-
if (!pythonPath) {
|
|
265
|
-
pythonPath = (await (0, builder_util_1.exec)("which", [execName])).trim();
|
|
266
|
-
}
|
|
267
|
-
await (0, builder_util_1.exec)(pythonPath, [path.join((0, dmgUtil_1.getDmgVendorPath)(), "dmgbuild/core.py")], {
|
|
268
|
-
cwd: (0, dmgUtil_1.getDmgVendorPath)(),
|
|
269
|
-
env,
|
|
270
|
-
});
|
|
271
|
-
};
|
|
272
|
-
try {
|
|
273
|
-
await executePython("python3");
|
|
274
|
-
}
|
|
275
|
-
catch (_error) {
|
|
276
|
-
await executePython("python");
|
|
277
|
-
}
|
|
278
|
-
return packager.packagerOptions.effectiveOptionComputed == null || !(await packager.packagerOptions.effectiveOptionComputed({ volumePath, specification, packager }));
|
|
279
|
-
}
|
|
280
|
-
async function computeDmgEntries(specification, volumePath, packager, asyncTaskManager) {
|
|
281
|
-
let result = "";
|
|
282
|
-
for (const c of specification.contents) {
|
|
283
|
-
if (c.path != null && c.path.endsWith(".app") && c.type !== "link") {
|
|
284
|
-
builder_util_1.log.warn({ path: c.path, reason: "actual path to app will be used instead" }, "do not specify path for application");
|
|
285
|
-
}
|
|
286
|
-
const entryPath = c.path || `${packager.appInfo.productFilename}.app`;
|
|
287
|
-
const entryName = c.name || path.basename(entryPath);
|
|
288
|
-
const escapedEntryName = entryName.replace(/['\\]/g, match => `\\${match}`);
|
|
289
|
-
if (result.length !== 0) {
|
|
290
|
-
result += ",\n";
|
|
291
|
-
}
|
|
292
|
-
result += `'${escapedEntryName}': (${c.x}, ${c.y})`;
|
|
293
|
-
if (c.type === "link") {
|
|
294
|
-
asyncTaskManager.addTask((0, builder_util_1.exec)("ln", ["-s", `/${entryPath.startsWith("/") ? entryPath.substring(1) : entryPath}`, `${volumePath}/${entryName}`]));
|
|
295
|
-
}
|
|
296
|
-
// use c.path instead of entryPath (to be sure that this logic is not applied to .app bundle) https://github.com/electron-userland/electron-builder/issues/2147
|
|
297
|
-
else if (!(0, builder_util_1.isEmptyOrSpaces)(c.path) && (c.type === "file" || c.type === "dir")) {
|
|
298
|
-
const source = await packager.getResource(c.path);
|
|
299
|
-
if (source == null) {
|
|
300
|
-
builder_util_1.log.warn({ entryPath, reason: "doesn't exist" }, "skipped DMG item copying");
|
|
301
|
-
continue;
|
|
302
|
-
}
|
|
303
|
-
const destination = `${volumePath}/${entryName}`;
|
|
304
|
-
asyncTaskManager.addTask(c.type === "dir" || (await (0, fs_extra_1.stat)(source)).isDirectory() ? (0, builder_util_1.copyDir)(source, destination) : (0, builder_util_1.copyFile)(source, destination));
|
|
305
|
-
}
|
|
306
|
-
}
|
|
307
|
-
return result;
|
|
308
|
-
}
|
|
309
|
-
async function transformBackgroundFileIfNeed(file, tmpDir) {
|
|
310
|
-
if (file.endsWith(".tiff") || file.endsWith(".TIFF")) {
|
|
311
|
-
return file;
|
|
312
|
-
}
|
|
313
|
-
const retinaFile = file.replace(/\.([a-z]+)$/, "@2x.$1");
|
|
314
|
-
if (await (0, builder_util_1.exists)(retinaFile)) {
|
|
315
|
-
const tiffFile = await tmpDir.getTempFile({ suffix: ".tiff" });
|
|
316
|
-
await (0, builder_util_1.exec)("tiffutil", ["-cathidpicheck", file, retinaFile, "-out", tiffFile]);
|
|
317
|
-
return tiffFile;
|
|
318
|
-
}
|
|
319
|
-
return file;
|
|
320
|
-
}
|
|
321
158
|
//# sourceMappingURL=dmg.js.map
|
package/out/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M,IAAA,mBAAI,EAAC,UAAU,EAAE,CAAC,gBAAgB,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAA;QAC9E,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { DmgOptions, Target } from \"app-builder-lib\"\nimport { findIdentity, isSignAllowed } from \"app-builder-lib/out/codeSign/macCodeSign\"\nimport { MacPackager } from \"app-builder-lib/out/macPackager\"\nimport { createBlockmap } from \"app-builder-lib/out/targets/differentialUpdateInfoBuilder\"\nimport { executeAppBuilderAsJson } from \"app-builder-lib/out/util/appBuilder\"\nimport { Arch, AsyncTaskManager, copyDir, copyFile, exec, exists, getArchSuffix, InvalidConfigurationError, isEmptyOrSpaces, log, statOrNull } from \"builder-util\"\nimport { CancellationToken, Nullish } from \"builder-util-runtime\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { stat } from \"fs-extra\"\nimport { release as getOsRelease } from \"os\"\nimport * as path from \"path\"\nimport { TmpDir } from \"temp-file\"\nimport { addLicenseToDmg } from \"./dmgLicense\"\nimport { attachAndExecute, computeBackground, detach, getDmgVendorPath } from \"./dmgUtil\"\nimport { hdiUtil, hdiutilTransientExitCodes } from \"./hdiuil\"\n\nexport class DmgTarget extends Target {\n readonly options: DmgOptions = this.packager.config.dmg || Object.create(null)\n\n isAsyncSupported = false\n\n constructor(\n private readonly packager: MacPackager,\n readonly outDir: string\n ) {\n super(\"dmg\")\n }\n\n async build(appPath: string, arch: Arch) {\n const packager = this.packager\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(\n this.options,\n \"dmg\",\n arch,\n \"${productName}-\" + (packager.platformSpecificBuildOptions.bundleShortVersion || \"${version}\") + \"-${arch}.${ext}\",\n true,\n packager.platformSpecificBuildOptions.defaultArch\n )\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"DMG\",\n file: artifactPath,\n arch,\n })\n\n const volumeName = sanitizeFileName(this.computeVolumeName(arch, this.options.title))\n\n const tempDmg = await createStageDmg(await packager.getTempFile(\".dmg\"), appPath, volumeName)\n\n const specification = await this.computeDmgOptions()\n // https://github.com/electron-userland/electron-builder/issues/2115\n const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager)\n const finalSize = await computeAssetSize(packager.info.cancellationToken, tempDmg, specification, backgroundFile)\n const expandingFinalSize = Math.ceil(finalSize * 0.1 + finalSize)\n await hdiUtil([\"resize\", \"-size\", expandingFinalSize.toString(), tempDmg])\n\n const volumePath = path.join(\"/Volumes\", volumeName)\n if (await exists(volumePath)) {\n log.debug({ volumePath }, \"unmounting previous disk image\")\n await detach(volumePath)\n }\n\n if (!(await attachAndExecute(tempDmg, true, () => customizeDmg(volumePath, specification, packager, backgroundFile)))) {\n return\n }\n\n // dmg file must not exist otherwise hdiutil failed (https://github.com/electron-userland/electron-builder/issues/1308#issuecomment-282847594), so, -ov must be specified\n const args = [\"convert\", tempDmg, \"-ov\", \"-format\", specification.format!, \"-o\", artifactPath]\n if (specification.format === \"UDZO\") {\n args.push(\"-imagekey\", `zlib-level=${process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || \"9\"}`)\n }\n await hdiUtil(addLogLevel(args))\n if (this.options.internetEnabled && parseInt(getOsRelease().split(\".\")[0], 10) < 19) {\n await hdiUtil(addLogLevel([\"internet-enable\"]).concat(artifactPath))\n }\n\n const licenseData = await addLicenseToDmg(packager, artifactPath)\n if (packager.packagerOptions.effectiveOptionComputed != null) {\n await packager.packagerOptions.effectiveOptionComputed({ licenseData })\n }\n\n if (this.options.sign === true) {\n await this.signDmg(artifactPath)\n }\n\n const safeArtifactName = packager.computeSafeArtifactName(artifactName, \"dmg\")\n const updateInfo = this.options.writeUpdateInfo === false ? null : await createBlockmap(artifactPath, this, packager, safeArtifactName)\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName,\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: updateInfo != null,\n updateInfo,\n })\n }\n\n private async signDmg(artifactPath: string) {\n if (!isSignAllowed(false)) {\n return\n }\n\n const packager = this.packager\n const qualifier = packager.platformSpecificBuildOptions.identity\n // explicitly disabled if set to null\n if (qualifier === null) {\n // macPackager already somehow handle this situation, so, here just return\n return\n }\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n const certificateType = \"Developer ID Application\"\n let identity = await findIdentity(certificateType, qualifier, keychainFile)\n if (identity == null) {\n identity = await findIdentity(\"Mac Developer\", qualifier, keychainFile)\n if (identity == null) {\n return\n }\n }\n\n const args = [\"--sign\", identity.hash!]\n if (keychainFile != null) {\n args.push(\"--keychain\", keychainFile)\n }\n args.push(artifactPath)\n await exec(\"codesign\", args)\n }\n\n computeVolumeName(arch: Arch, custom?: string | null): string {\n const appInfo = this.packager.appInfo\n const shortVersion = this.packager.platformSpecificBuildOptions.bundleShortVersion || appInfo.version\n const archString = getArchSuffix(arch, this.packager.platformSpecificBuildOptions.defaultArch)\n\n if (custom == null) {\n return `${appInfo.productFilename} ${shortVersion}${archString}`\n }\n\n return custom\n .replace(/\\${arch}/g, archString)\n .replace(/\\${shortVersion}/g, shortVersion)\n .replace(/\\${version}/g, appInfo.version)\n .replace(/\\${name}/g, appInfo.name)\n .replace(/\\${productName}/g, appInfo.productName)\n }\n\n // public to test\n async computeDmgOptions(): Promise<DmgOptions> {\n const packager = this.packager\n const specification: DmgOptions = { ...this.options }\n if (specification.icon == null && specification.icon !== null) {\n specification.icon = await packager.getIconPath()\n }\n\n if (specification.icon != null && isEmptyOrSpaces(specification.icon)) {\n throw new InvalidConfigurationError(\"dmg.icon cannot be specified as empty string\")\n }\n\n const background = specification.background\n if (specification.backgroundColor != null) {\n if (background != null) {\n throw new InvalidConfigurationError(\"Both dmg.backgroundColor and dmg.background are specified — please set the only one\")\n }\n } else if (background == null) {\n specification.background = await computeBackground(packager)\n } else {\n specification.background = path.resolve(packager.info.projectDir, background)\n }\n\n if (specification.format == null) {\n if (process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL != null) {\n ;(specification as any).format = \"UDZO\"\n } else if (packager.compression === \"store\") {\n specification.format = \"UDRO\"\n } else {\n specification.format = packager.compression === \"maximum\" ? \"UDBZ\" : \"UDZO\"\n }\n }\n\n if (specification.contents == null) {\n specification.contents = [\n {\n x: 130,\n y: 220,\n },\n {\n x: 410,\n y: 220,\n type: \"link\",\n path: \"/Applications\",\n },\n ]\n }\n return specification\n }\n}\n\nasync function createStageDmg(tempDmg: string, appPath: string, volumeName: string) {\n const createArgs = [\"create\", \"-srcfolder\", appPath, \"-volname\", volumeName, \"-anyowners\", \"-nospotlight\", \"-format\", \"UDRW\"]\n const imageArgs = addLogLevel(createArgs)\n if (log.isDebugEnabled) {\n imageArgs.push(\"-debug\")\n }\n\n imageArgs.push(\"-fs\", \"APFS\")\n imageArgs.push(tempDmg)\n await hdiUtil(imageArgs).catch(async e => {\n if (hdiutilTransientExitCodes.has(e.code)) {\n // Delay then create, then retry with verbose output\n await new Promise(resolve => setTimeout(resolve, 3000))\n return hdiUtil(addLogLevel(createArgs, true))\n }\n throw e\n })\n return tempDmg\n}\n\nfunction addLogLevel(args: Array<string>, isVerbose = process.env.DEBUG_DMG === \"true\"): Array<string> {\n args.push(isVerbose ? \"-verbose\" : \"-quiet\")\n return args\n}\n\nasync function computeAssetSize(cancellationToken: CancellationToken, dmgFile: string, specification: DmgOptions, backgroundFile: string | Nullish) {\n const asyncTaskManager = new AsyncTaskManager(cancellationToken)\n asyncTaskManager.addTask(stat(dmgFile))\n\n if (specification.icon != null) {\n asyncTaskManager.addTask(statOrNull(specification.icon))\n }\n\n if (backgroundFile != null) {\n asyncTaskManager.addTask(stat(backgroundFile))\n }\n\n let result = 32 * 1024\n for (const stat of await asyncTaskManager.awaitTasks()) {\n if (stat != null) {\n result += stat.size\n }\n }\n return result\n}\n\nasync function customizeDmg(volumePath: string, specification: DmgOptions, packager: MacPackager, backgroundFile: string | Nullish) {\n const window = specification.window\n const isValidIconTextSize = !!specification.iconTextSize && specification.iconTextSize >= 10 && specification.iconTextSize <= 16\n const iconTextSize = isValidIconTextSize ? specification.iconTextSize : 12\n const env: any = {\n ...process.env,\n volumePath,\n appFileName: `${packager.appInfo.productFilename}.app`,\n iconSize: specification.iconSize || 80,\n iconTextSize,\n\n PYTHONIOENCODING: \"utf8\",\n }\n\n if (specification.backgroundColor != null || specification.background == null) {\n env.backgroundColor = specification.backgroundColor || \"#ffffff\"\n\n if (window != null) {\n env.windowX = (window.x == null ? 100 : window.x).toString()\n env.windowY = (window.y == null ? 400 : window.y).toString()\n env.windowWidth = (window.width || 540).toString()\n env.windowHeight = (window.height || 380).toString()\n }\n } else {\n delete env.backgroundColor\n }\n\n const args = [\"dmg\", \"--volume\", volumePath]\n if (specification.icon != null) {\n args.push(\"--icon\", (await packager.getResource(specification.icon))!)\n }\n if (backgroundFile != null) {\n args.push(\"--background\", backgroundFile)\n }\n\n const data: any = await executeAppBuilderAsJson(args)\n if (data.backgroundWidth != null) {\n env.windowWidth = window == null ? null : window.width\n env.windowHeight = window == null ? null : window.height\n\n if (env.windowWidth == null) {\n env.windowWidth = data.backgroundWidth.toString()\n }\n if (env.windowHeight == null) {\n env.windowHeight = data.backgroundHeight.toString()\n }\n\n if (env.windowX == null) {\n env.windowX = 400\n }\n if (env.windowY == null) {\n env.windowY = Math.round((1440 - env.windowHeight) / 2).toString()\n }\n }\n\n Object.assign(env, data)\n\n const asyncTaskManager = new AsyncTaskManager(packager.info.cancellationToken)\n env.iconLocations = await computeDmgEntries(specification, volumePath, packager, asyncTaskManager)\n await asyncTaskManager.awaitTasks()\n const executePython = async (execName: string) => {\n let pythonPath = process.env.PYTHON_PATH\n if (!pythonPath) {\n pythonPath = (await exec(\"which\", [execName])).trim()\n }\n await exec(pythonPath, [path.join(getDmgVendorPath(), \"dmgbuild/core.py\")], {\n cwd: getDmgVendorPath(),\n env,\n })\n }\n try {\n await executePython(\"python3\")\n } catch (_error: any) {\n await executePython(\"python\")\n }\n return packager.packagerOptions.effectiveOptionComputed == null || !(await packager.packagerOptions.effectiveOptionComputed({ volumePath, specification, packager }))\n}\n\nasync function computeDmgEntries(specification: DmgOptions, volumePath: string, packager: MacPackager, asyncTaskManager: AsyncTaskManager): Promise<string> {\n let result = \"\"\n for (const c of specification.contents!) {\n if (c.path != null && c.path.endsWith(\".app\") && c.type !== \"link\") {\n log.warn({ path: c.path, reason: \"actual path to app will be used instead\" }, \"do not specify path for application\")\n }\n\n const entryPath = c.path || `${packager.appInfo.productFilename}.app`\n const entryName = c.name || path.basename(entryPath)\n const escapedEntryName = entryName.replace(/['\\\\]/g, match => `\\\\${match}`)\n if (result.length !== 0) {\n result += \",\\n\"\n }\n result += `'${escapedEntryName}': (${c.x}, ${c.y})`\n\n if (c.type === \"link\") {\n asyncTaskManager.addTask(exec(\"ln\", [\"-s\", `/${entryPath.startsWith(\"/\") ? entryPath.substring(1) : entryPath}`, `${volumePath}/${entryName}`]))\n }\n // use c.path instead of entryPath (to be sure that this logic is not applied to .app bundle) https://github.com/electron-userland/electron-builder/issues/2147\n else if (!isEmptyOrSpaces(c.path) && (c.type === \"file\" || c.type === \"dir\")) {\n const source = await packager.getResource(c.path)\n if (source == null) {\n log.warn({ entryPath, reason: \"doesn't exist\" }, \"skipped DMG item copying\")\n continue\n }\n\n const destination = `${volumePath}/${entryName}`\n asyncTaskManager.addTask(c.type === \"dir\" || (await stat(source)).isDirectory() ? copyDir(source, destination) : copyFile(source, destination))\n }\n }\n return result\n}\n\nasync function transformBackgroundFileIfNeed(file: string, tmpDir: TmpDir): Promise<string> {\n if (file.endsWith(\".tiff\") || file.endsWith(\".TIFF\")) {\n return file\n }\n\n const retinaFile = file.replace(/\\.([a-z]+)$/, \"@2x.$1\")\n if (await exists(retinaFile)) {\n const tiffFile = await tmpDir.getTempFile({ suffix: \".tiff\" })\n await exec(\"tiffutil\", [\"-cathid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E,GAAG,QAAQ,CAAC,OAAO,CAAC,eAAe,MAAM;iBAChD;gBACD;oBACE,CAAC,EAAE,GAAG;oBACN,CAAC,EAAE,GAAG;oBACN,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,eAAe;iBACtB;aACF,CAAA;QACH,CAAC;QACD,OAAO,aAAa,CAAA;IACtB,CAAC;CACF;AApKD,8BAoKC;AAED,SAAS,WAAW,CAAC,IAAmB,EAAE,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM;IACpF,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAA;IAC5C,OAAO,IAAI,CAAA;AACb,CAAC","sourcesContent":["import { DmgOptions, Target } from \"app-builder-lib\"\nimport { findIdentity, isSignAllowed } from \"app-builder-lib/out/codeSign/macCodeSign\"\nimport { MacPackager } from \"app-builder-lib/out/macPackager\"\nimport { createBlockmap } from \"app-builder-lib/out/targets/differentialUpdateInfoBuilder\"\nimport { Arch, exec, getArchSuffix, InvalidConfigurationError, isEmptyOrSpaces } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/out/filename\"\nimport { release as getOsRelease } from \"os\"\nimport * as path from \"path\"\nimport { addLicenseToDmg } from \"./dmgLicense\"\nimport { computeBackground, customizeDmg } from \"./dmgUtil\"\nimport { hdiUtil } from \"./hdiuil\"\n\nexport interface DmgBuildConfig {\n title: string\n icon?: string | null\n \"badge-icon\"?: string | null\n background?: string | null\n \"background-color\"?: string | null\n \"icon-size\"?: number | null\n \"text-size\"?: number | null\n window?: {\n position?: {\n x?: number\n y?: number\n }\n size?: {\n width?: number\n height?: number\n }\n }\n format?: string\n filesystem?: string\n \"compression-level\"?: number | null\n license?: string | null\n contents?: Array<{\n path: string\n x: number\n y: number\n name?: string\n type?: \"file\" | \"link\" | \"position\"\n hide_extension?: boolean\n hidden?: boolean\n }>\n}\nexport class DmgTarget extends Target {\n readonly options: DmgOptions = this.packager.config.dmg || Object.create(null)\n\n isAsyncSupported = false\n\n constructor(\n private readonly packager: MacPackager,\n readonly outDir: string\n ) {\n super(\"dmg\")\n }\n\n async build(appPath: string, arch: Arch) {\n const packager = this.packager\n // tslint:disable-next-line:no-invalid-template-strings\n const artifactName = packager.expandArtifactNamePattern(\n this.options,\n \"dmg\",\n arch,\n \"${productName}-\" + (packager.platformSpecificBuildOptions.bundleShortVersion || \"${version}\") + \"-${arch}.${ext}\",\n true,\n packager.platformSpecificBuildOptions.defaultArch\n )\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.info.emitArtifactBuildStarted({\n targetPresentableName: \"DMG\",\n file: artifactPath,\n arch,\n })\n\n const volumeName = sanitizeFileName(this.computeVolumeName(arch, this.options.title))\n\n const specification = await this.computeDmgOptions(appPath)\n\n if (!(await customizeDmg({ appPath, artifactPath, volumeName, specification, packager }))) {\n return\n }\n\n if (this.options.internetEnabled && parseInt(getOsRelease().split(\".\")[0], 10) < 19) {\n await hdiUtil(addLogLevel([\"internet-enable\"]).concat(artifactPath))\n }\n\n const licenseData = await addLicenseToDmg(packager, artifactPath)\n if (packager.packagerOptions.effectiveOptionComputed != null) {\n await packager.packagerOptions.effectiveOptionComputed({ licenseData })\n }\n\n if (this.options.sign === true) {\n await this.signDmg(artifactPath)\n }\n\n const safeArtifactName = packager.computeSafeArtifactName(artifactName, \"dmg\")\n const updateInfo = this.options.writeUpdateInfo === false ? null : await createBlockmap(artifactPath, this, packager, safeArtifactName)\n await packager.info.emitArtifactBuildCompleted({\n file: artifactPath,\n safeArtifactName,\n target: this,\n arch,\n packager,\n isWriteUpdateInfo: updateInfo != null,\n updateInfo,\n })\n }\n\n private async signDmg(artifactPath: string) {\n if (!isSignAllowed(false)) {\n return\n }\n\n const packager = this.packager\n const qualifier = packager.platformSpecificBuildOptions.identity\n // explicitly disabled if set to null\n if (qualifier === null) {\n // macPackager already somehow handle this situation, so, here just return\n return\n }\n\n const keychainFile = (await packager.codeSigningInfo.value).keychainFile\n const certificateType = \"Developer ID Application\"\n let identity = await findIdentity(certificateType, qualifier, keychainFile)\n if (identity == null) {\n identity = await findIdentity(\"Mac Developer\", qualifier, keychainFile)\n if (identity == null) {\n return\n }\n }\n\n const args = [\"--sign\", identity.hash!]\n if (keychainFile != null) {\n args.push(\"--keychain\", keychainFile)\n }\n args.push(artifactPath)\n await exec(\"codesign\", args)\n }\n\n computeVolumeName(arch: Arch, custom?: string | null): string {\n const appInfo = this.packager.appInfo\n const shortVersion = this.packager.platformSpecificBuildOptions.bundleShortVersion || appInfo.version\n const archString = getArchSuffix(arch, this.packager.platformSpecificBuildOptions.defaultArch)\n\n if (custom == null) {\n return `${appInfo.productFilename} ${shortVersion}${archString}`\n }\n\n return custom\n .replace(/\\${arch}/g, archString)\n .replace(/\\${shortVersion}/g, shortVersion)\n .replace(/\\${version}/g, appInfo.version)\n .replace(/\\${name}/g, appInfo.name)\n .replace(/\\${productName}/g, appInfo.productName)\n }\n\n // public to test\n async computeDmgOptions(appPath: string): Promise<DmgOptions> {\n const packager = this.packager\n const specification: DmgOptions = { ...this.options }\n if (specification.icon == null && specification.icon !== null) {\n specification.icon = await packager.getIconPath()\n }\n\n if (specification.icon != null && isEmptyOrSpaces(specification.icon)) {\n throw new InvalidConfigurationError(\"dmg.icon cannot be specified as empty string\")\n }\n\n const background = specification.background\n if (specification.backgroundColor != null) {\n if (background != null) {\n throw new InvalidConfigurationError(\"Both dmg.backgroundColor and dmg.background are specified — please set the only one\")\n }\n } else if (background == null) {\n specification.background = await computeBackground(packager)\n } else {\n specification.background = await packager.getResource(background)\n }\n\n if (specification.format == null) {\n if (process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL != null) {\n specification.format = \"UDZO\"\n } else if (packager.compression === \"store\") {\n specification.format = \"UDRO\"\n } else {\n specification.format = packager.compression === \"maximum\" ? \"UDBZ\" : \"UDZO\"\n }\n }\n\n if (specification.contents == null) {\n specification.contents = [\n {\n x: 130,\n y: 220,\n path: appPath,\n type: \"file\",\n name: `${packager.appInfo.productFilename}.app`,\n },\n {\n x: 410,\n y: 220,\n type: \"link\",\n path: \"/Applications\",\n },\n ]\n }\n return specification\n }\n}\n\nfunction addLogLevel(args: Array<string>, isVerbose = process.env.DEBUG_DMG === \"true\"): Array<string> {\n args.push(isVerbose ? \"-verbose\" : \"-quiet\")\n return args\n}\n"]}
|
package/out/dmgUtil.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import { PlatformPackager } from "app-builder-lib";
|
|
1
|
+
import { DmgOptions, MacPackager, PlatformPackager } from "app-builder-lib";
|
|
2
|
+
import { TmpDir } from "builder-util";
|
|
2
3
|
export { DmgTarget } from "./dmg";
|
|
3
4
|
export declare function getDmgTemplatePath(): string;
|
|
4
5
|
export declare function getDmgVendorPath(): string;
|
|
5
|
-
export declare function attachAndExecute(dmgPath: string, readWrite: boolean, task: () => Promise<any>): Promise<any>;
|
|
6
|
+
export declare function attachAndExecute(dmgPath: string, readWrite: boolean, task: (devicePath: string) => Promise<any>): Promise<any>;
|
|
6
7
|
export declare function detach(name: string): Promise<string | null>;
|
|
7
8
|
export declare function computeBackground(packager: PlatformPackager<any>): Promise<string>;
|
|
9
|
+
type DmgBuilderConfig = {
|
|
10
|
+
appPath: string;
|
|
11
|
+
artifactPath: string;
|
|
12
|
+
volumeName: string;
|
|
13
|
+
specification: DmgOptions;
|
|
14
|
+
packager: MacPackager;
|
|
15
|
+
};
|
|
16
|
+
export declare function customizeDmg({ appPath, artifactPath, volumeName, specification, packager }: DmgBuilderConfig): Promise<boolean>;
|
|
17
|
+
export declare function transformBackgroundFileIfNeed(file: string, tmpDir: TmpDir): Promise<string>;
|
|
18
|
+
export declare function getImageSizeUsingSips(background: string): Promise<{
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
}>;
|
package/out/dmgUtil.js
CHANGED
|
@@ -7,9 +7,13 @@ exports.attachAndExecute = attachAndExecute;
|
|
|
7
7
|
exports.detach = detach;
|
|
8
8
|
exports.computeBackground = computeBackground;
|
|
9
9
|
exports.serializeString = serializeString;
|
|
10
|
+
exports.customizeDmg = customizeDmg;
|
|
11
|
+
exports.transformBackgroundFileIfNeed = transformBackgroundFileIfNeed;
|
|
12
|
+
exports.getImageSizeUsingSips = getImageSizeUsingSips;
|
|
10
13
|
const builder_util_1 = require("builder-util");
|
|
11
14
|
const path = require("path");
|
|
12
15
|
const hdiuil_1 = require("./hdiuil");
|
|
16
|
+
const fs_extra_1 = require("fs-extra");
|
|
13
17
|
var dmg_1 = require("./dmg");
|
|
14
18
|
Object.defineProperty(exports, "DmgTarget", { enumerable: true, get: function () { return dmg_1.DmgTarget; } });
|
|
15
19
|
const root = path.join(__dirname, "..");
|
|
@@ -32,7 +36,27 @@ async function attachAndExecute(dmgPath, readWrite, task) {
|
|
|
32
36
|
if (device == null) {
|
|
33
37
|
throw new Error(`Cannot mount: ${attachResult}`);
|
|
34
38
|
}
|
|
35
|
-
|
|
39
|
+
const volumePath = await findMountPath(path.basename(device));
|
|
40
|
+
if (volumePath == null) {
|
|
41
|
+
throw new Error(`Cannot find volume mount path for device: ${device}`);
|
|
42
|
+
}
|
|
43
|
+
return await (0, builder_util_1.executeFinally)(task(volumePath), () => detach(device));
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Find the mount path for a specific device from `hdiutil info`.
|
|
47
|
+
*/
|
|
48
|
+
async function findMountPath(devName, index = 1) {
|
|
49
|
+
const info = await (0, hdiuil_1.hdiUtil)(["info"]);
|
|
50
|
+
const lines = info.split("\n");
|
|
51
|
+
const regex = new RegExp(`^/dev/${devName}(s\\d+)?\\s+\\S+\\s+(/Volumes/.+)$`);
|
|
52
|
+
const matches = [];
|
|
53
|
+
for (const line of lines) {
|
|
54
|
+
const result = regex.exec(line);
|
|
55
|
+
if (result && result.length >= 3) {
|
|
56
|
+
matches.push(result[2]);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
return matches.length >= index ? matches[index - 1] : null;
|
|
36
60
|
}
|
|
37
61
|
async function detach(name) {
|
|
38
62
|
return (0, hdiuil_1.hdiUtil)(["detach", "-quiet", name]).catch(async (e) => {
|
|
@@ -65,4 +89,131 @@ function serializeString(data) {
|
|
|
65
89
|
.join('"\n $"') +
|
|
66
90
|
'"');
|
|
67
91
|
}
|
|
92
|
+
async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager }) {
|
|
93
|
+
var _a, _b, _c, _d, _e;
|
|
94
|
+
const isValidIconTextSize = !!specification.iconTextSize && specification.iconTextSize >= 10 && specification.iconTextSize <= 16;
|
|
95
|
+
const iconTextSize = isValidIconTextSize ? specification.iconTextSize : 12;
|
|
96
|
+
const volumePath = path.join("/Volumes", volumeName);
|
|
97
|
+
// https://github.com/electron-userland/electron-builder/issues/2115
|
|
98
|
+
const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager);
|
|
99
|
+
const settings = {
|
|
100
|
+
title: path.basename(volumePath),
|
|
101
|
+
icon: await packager.getResource(specification.icon),
|
|
102
|
+
"icon-size": specification.iconSize,
|
|
103
|
+
"text-size": iconTextSize,
|
|
104
|
+
"compression-level": Number(process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || "9"),
|
|
105
|
+
// filesystem: specification.filesystem || "HFS+",
|
|
106
|
+
format: specification.format,
|
|
107
|
+
contents: ((_a = specification.contents) === null || _a === void 0 ? void 0 : _a.map(c => ({
|
|
108
|
+
path: c.path || appPath, // path is required, when ommitted, appPath is used (backward compatibility
|
|
109
|
+
x: c.x,
|
|
110
|
+
y: c.y,
|
|
111
|
+
name: c.name,
|
|
112
|
+
type: c.type === "dir" ? "file" : c.type, // appdmg expects "file" for directories
|
|
113
|
+
// hide_extension: c.hideExtension,
|
|
114
|
+
}))) || [],
|
|
115
|
+
};
|
|
116
|
+
if (specification.backgroundColor != null || specification.background == null) {
|
|
117
|
+
settings["background-color"] = specification.backgroundColor || "#ffffff";
|
|
118
|
+
const window = specification.window;
|
|
119
|
+
if (window != null) {
|
|
120
|
+
settings.window = {
|
|
121
|
+
position: {
|
|
122
|
+
x: (_b = window.x) !== null && _b !== void 0 ? _b : 100,
|
|
123
|
+
y: (_c = window.y) !== null && _c !== void 0 ? _c : 400,
|
|
124
|
+
},
|
|
125
|
+
size: {
|
|
126
|
+
width: (_d = window.width) !== null && _d !== void 0 ? _d : 540,
|
|
127
|
+
height: (_e = window.height) !== null && _e !== void 0 ? _e : 300,
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
settings.background = backgroundFile;
|
|
134
|
+
delete settings["background-color"];
|
|
135
|
+
}
|
|
136
|
+
if (!(0, builder_util_1.isEmptyOrSpaces)(settings.background)) {
|
|
137
|
+
const size = await getImageSizeUsingSips(settings.background);
|
|
138
|
+
settings.window = { position: { x: 400, y: Math.round((1440 - size.height) / 2) }, size, ...settings.window };
|
|
139
|
+
}
|
|
140
|
+
const settingsFile = await packager.getTempFile(".json");
|
|
141
|
+
await (0, fs_extra_1.writeFile)(settingsFile, JSON.stringify(settings, null, 2));
|
|
142
|
+
const executePython = async (execName) => {
|
|
143
|
+
let pythonPath = process.env.PYTHON_PATH;
|
|
144
|
+
if (!pythonPath) {
|
|
145
|
+
pythonPath = (await (0, builder_util_1.exec)("which", [execName])).trim();
|
|
146
|
+
}
|
|
147
|
+
await (0, builder_util_1.exec)(pythonPath, [path.join(getDmgVendorPath(), "run_dmgbuild.py"), "-s", settingsFile, path.basename(volumePath), artifactPath], {
|
|
148
|
+
cwd: getDmgVendorPath(),
|
|
149
|
+
env: {
|
|
150
|
+
...process.env,
|
|
151
|
+
PYTHONIOENCODING: "utf8",
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
};
|
|
155
|
+
try {
|
|
156
|
+
await executePython("python3");
|
|
157
|
+
}
|
|
158
|
+
catch (_error) {
|
|
159
|
+
await executePython("python");
|
|
160
|
+
}
|
|
161
|
+
// effectiveOptionComputed, when present, is purely for verifying result during test execution
|
|
162
|
+
return (packager.packagerOptions.effectiveOptionComputed == null ||
|
|
163
|
+
(await attachAndExecute(artifactPath, false, async (volumePath) => {
|
|
164
|
+
var _a;
|
|
165
|
+
return !(await packager.packagerOptions.effectiveOptionComputed({
|
|
166
|
+
volumePath,
|
|
167
|
+
specification: {
|
|
168
|
+
...specification,
|
|
169
|
+
// clean up `contents` for test snapshot verification since app path is absolute to a unique tmp dir
|
|
170
|
+
contents: (_a = specification.contents) === null || _a === void 0 ? void 0 : _a.map((c) => {
|
|
171
|
+
var _a;
|
|
172
|
+
return ({
|
|
173
|
+
...c,
|
|
174
|
+
path: path.extname((_a = c.path) !== null && _a !== void 0 ? _a : "") === ".app" ? path.relative(packager.projectDir, c.path) : c.path,
|
|
175
|
+
});
|
|
176
|
+
}),
|
|
177
|
+
},
|
|
178
|
+
packager,
|
|
179
|
+
}));
|
|
180
|
+
})));
|
|
181
|
+
}
|
|
182
|
+
async function transformBackgroundFileIfNeed(file, tmpDir) {
|
|
183
|
+
if (path.extname(file.toLowerCase()) === ".tiff") {
|
|
184
|
+
return file;
|
|
185
|
+
}
|
|
186
|
+
const retinaFile = file.replace(/\.([a-z]+)$/, "@2x.$1");
|
|
187
|
+
if (await (0, builder_util_1.exists)(retinaFile)) {
|
|
188
|
+
const tiffFile = await tmpDir.getTempFile({ suffix: ".tiff" });
|
|
189
|
+
await (0, builder_util_1.exec)("tiffutil", ["-cathidpicheck", file, retinaFile, "-out", tiffFile]);
|
|
190
|
+
return tiffFile;
|
|
191
|
+
}
|
|
192
|
+
return file;
|
|
193
|
+
}
|
|
194
|
+
async function getImageSizeUsingSips(background) {
|
|
195
|
+
const stdout = await (0, builder_util_1.exec)("sips", ["-g", "pixelHeight", "-g", "pixelWidth", background]);
|
|
196
|
+
let width = 0;
|
|
197
|
+
let height = 0;
|
|
198
|
+
const re = /([a-zA-Z]+):\s*(\d+)/;
|
|
199
|
+
const lines = stdout.split("\n");
|
|
200
|
+
for (const line of lines) {
|
|
201
|
+
const match = re.exec(line);
|
|
202
|
+
if (!match) {
|
|
203
|
+
continue;
|
|
204
|
+
}
|
|
205
|
+
const key = match[1];
|
|
206
|
+
const value = parseInt(match[2], 10);
|
|
207
|
+
if (isNaN(value)) {
|
|
208
|
+
throw new Error(`Failed to parse number from line: "${line}"`);
|
|
209
|
+
}
|
|
210
|
+
if (key === "pixelWidth") {
|
|
211
|
+
width = value;
|
|
212
|
+
}
|
|
213
|
+
else if (key === "pixelHeight") {
|
|
214
|
+
height = value;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return { width, height };
|
|
218
|
+
}
|
|
68
219
|
//# sourceMappingURL=dmgUtil.js.map
|
package/out/dmgUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dmgUtil.js","sourceRoot":"","sources":["../src/dmgUtil.ts"],"names":[],"mappings":";;;AASA,gDAEC;AAED,4CAEC;AAED,4CAgBC;AAED,wBASC;AAED,8CASC;AAGD,0CASC;AAlED,+CAA6C;AAC7C,6BAA4B;AAC5B,qCAA6D;AAE7D,6BAAiC;AAAxB,gGAAA,SAAS,OAAA;AAElB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAEvC,SAAgB,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AACrC,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAA;AAClC,CAAC;AAEM,KAAK,UAAU,gBAAgB,CAAC,OAAe,EAAE,SAAkB,EAAE,IAAwB;IAClG,sCAAsC;IACtC,MAAM,IAAI,GAAG,CAAC,QAAQ,EAAE,WAAW,EAAE,aAAa,CAAC,CAAA;IACnD,IAAI,SAAS,EAAE,CAAC;QACd,IAAI,CAAC,IAAI,CAAC,YAA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GAAG,MAAM,QAAQ,CAAC,YAAY,CAAA;IAChD,IAAI,YAAY,CAAC,QAAQ,CAAC,iBAAiB,CAAC,EAAE,CAAC;QAC7C,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC,CAAA;IACjE,CAAC;SAAM,IAAI,YAAY,CAAC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC;QACnD,OAAO,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,iBAAiB,EAAE,gBAAgB,CAAC,CAAA;IAChE,CAAC;SAAM,CAAC;QACN,OAAO,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,EAAE,iBAAiB,CAAC,CAAA;IAC3D,CAAC;AACH,CAAC;AAED,gBAAgB;AAChB,SAAgB,eAAe,CAAC,IAAY;IAC1C,OAAO,CACL,MAAM;QACN,IAAI;aACD,KAAK,CAAC,UAAU,CAAE;aAClB,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,SAAS,CAAE,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aACzC,IAAI,CAAC,SAAS,CAAC;QAClB,GAAG,CACJ,CAAA;AACH,CAAC","sourcesContent":["import { PlatformPackager } from \"app-builder-lib\"\nimport { executeFinally } from \"builder-util\"\nimport * as path from \"path\"\nimport { hdiUtil, hdiutilTransientExitCodes } from \"./hdiuil\"\n\nexport { DmgTarget } from \"./dmg\"\n\nconst root = path.join(__dirname, \"..\")\n\nexport function getDmgTemplatePath() {\n return path.join(root, \"templates\")\n}\n\nexport function getDmgVendorPath() {\n return path.join(root, \"vendor\")\n}\n\nexport async function attachAndExecute(dmgPath: string, readWrite: boolean, task: () => Promise<any>) {\n //noinspection SpellCheckingInspection\n const args = [\"attach\", \"-noverify\", \"-noautoopen\"]\n if (readWrite) {\n args.push(\"-readwrite\")\n }\n\n args.push(dmgPath)\n const attachResult = await hdiUtil(args)\n const deviceResult = attachResult == null ? null : /^(\\/dev\\/\\w+)/.exec(attachResult)\n const device = deviceResult == null || deviceResult.length !== 2 ? null : deviceResult[1]\n if (device == null) {\n throw new Error(`Cannot mount: ${attachResult}`)\n }\n\n return await executeFinally(task(), () => detach(device))\n}\n\nexport async function detach(name: string) {\n return hdiUtil([\"detach\", \"-quiet\", name]).catch(async e => {\n if (hdiutilTransientExitCodes.has(e.code)) {\n // Delay then force unmount with verbose output\n await new Promise(resolve => setTimeout(resolve, 3000))\n return hdiUtil([\"detach\", \"-force\", name])\n }\n throw e\n })\n}\n\nexport async function computeBackground(packager: PlatformPackager<any>): Promise<string> {\n const resourceList = await packager.resourceList\n if (resourceList.includes(\"background.tiff\")) {\n return path.join(packager.buildResourcesDir, \"background.tiff\")\n } else if (resourceList.includes(\"background.png\")) {\n return path.join(packager.buildResourcesDir, \"background.png\")\n } else {\n return path.join(getDmgTemplatePath(), \"background.tiff\")\n }\n}\n\n/** @internal */\nexport function serializeString(data: string) {\n return (\n ' $\"' +\n data\n .match(/.{1,32}/g)!\n .map(it => it.match(/.{1,4}/g)!.join(\" \"))\n .join('\"\\n $\"') +\n '\"'\n )\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dmgUtil.js","sourceRoot":"","sources":["../src/dmgUtil.ts"],"names":[],"mappings":";;;AAWA,gDAEC;AAED,4CAEC;AAED,4CAoBC;AAqBD,wBASC;AAED,8CASC;AAGD,0CASC;AAUD,oCA4FC;AAED,sEAaC;AAED,sDA8BC;AAhPD,+CAAoF;AACpF,6BAA4B;AAC5B,qCAA6D;AAC7D,uCAAoC;AAGpC,6BAAiC;AAAxB,gGAAA,SAAS,OAAA;AAElB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAA;AAEvC,SAAgB,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AACrC,CAAC;AAED,SAAgB,gBAAgB;IAC9B,OAAO,IAAI,CAAC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ACX,SAAQ;QACV,CAAC;QAED,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,CAAA;QACpB,MAAM,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAA;QAEpC,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;YACjB,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,GAAG,CAAC,CAAA;QAChE,CAAC;QAED,IAAI,GAAG,KAAK,YAAY,EAAE,CAAC;YACzB,KAAK,GAAG,KAAK,CAAA;QACf,CAAC;aAAM,IAAI,GAAG,KAAK,aAAa,EAAE,CAAC;YACjC,MAAM,GAAG,KAAK,CAAA;QAChB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,CAAA;AAC1B,CAAC","sourcesContent":["import { DmgOptions, MacPackager, PlatformPackager } from \"app-builder-lib\"\nimport { exec, executeFinally, exists, isEmptyOrSpaces, TmpDir } from \"builder-util\"\nimport * as path from \"path\"\nimport { hdiUtil, hdiutilTransientExitCodes } from \"./hdiuil\"\nimport { writeFile } from \"fs-extra\"\nimport { DmgBuildConfig } from \"./dmg\"\n\nexport { DmgTarget } from \"./dmg\"\n\nconst root = path.join(__dirname, \"..\")\n\nexport function getDmgTemplatePath() {\n return path.join(root, \"templates\")\n}\n\nexport function getDmgVendorPath() {\n return path.join(root, \"vendor\")\n}\n\nexport async function attachAndExecute(dmgPath: string, readWrite: boolean, task: (devicePath: string) => Promise<any>) {\n //noinspection SpellCheckingInspection\n const args = [\"attach\", \"-noverify\", \"-noautoopen\"]\n if (readWrite) {\n args.push(\"-readwrite\")\n }\n\n args.push(dmgPath)\n const attachResult = await hdiUtil(args)\n const deviceResult = attachResult == null ? null : /^(\\/dev\\/\\w+)/.exec(attachResult)\n const device = deviceResult == null || deviceResult.length !== 2 ? null : deviceResult[1]\n if (device == null) {\n throw new Error(`Cannot mount: ${attachResult}`)\n }\n const volumePath = await findMountPath(path.basename(device))\n if (volumePath == null) {\n throw new Error(`Cannot find volume mount path for device: ${device}`)\n }\n\n return await executeFinally(task(volumePath), () => detach(device))\n}\n\n/**\n * Find the mount path for a specific device from `hdiutil info`.\n */\nasync function findMountPath(devName: string, index: number = 1): Promise<string | null> {\n const info = await hdiUtil([\"info\"])\n const lines = info!.split(\"\\n\")\n const regex = new RegExp(`^/dev/${devName}(s\\\\d+)?\\\\s+\\\\S+\\\\s+(/Volumes/.+)$`)\n const matches: string[] = []\n\n for (const line of lines) {\n const result = regex.exec(line)\n if (result && result.length >= 3) {\n matches.push(result[2])\n }\n }\n\n return matches.length >= index ? matches[index - 1] : null\n}\n\nexport async function detach(name: string) {\n return hdiUtil([\"detach\", \"-quiet\", name]).catch(async e => {\n if (hdiutilTransientExitCodes.has(e.code)) {\n // Delay then force unmount with verbose output\n await new Promise(resolve => setTimeout(resolve, 3000))\n return hdiUtil([\"detach\", \"-force\", name])\n }\n throw e\n })\n}\n\nexport async function computeBackground(packager: PlatformPackager<any>): Promise<string> {\n const resourceList = await packager.resourceList\n if (resourceList.includes(\"background.tiff\")) {\n return path.join(packager.buildResourcesDir, \"background.tiff\")\n } else if (resourceList.includes(\"background.png\")) {\n return path.join(packager.buildResourcesDir, \"background.png\")\n } else {\n return path.join(getDmgTemplatePath(), \"background.tiff\")\n }\n}\n\n/** @internal */\nexport function serializeString(data: string) {\n return (\n ' $\"' +\n data\n .match(/.{1,32}/g)!\n .map(it => it.match(/.{1,4}/g)!.join(\" \"))\n .join('\"\\n $\"') +\n '\"'\n )\n}\n\ntype DmgBuilderConfig = {\n appPath: string\n artifactPath: string\n volumeName: string\n specification: DmgOptions\n packager: MacPackager\n}\n\nexport async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager }: DmgBuilderConfig): Promise<boolean> {\n const isValidIconTextSize = !!specification.iconTextSize && specification.iconTextSize >= 10 && specification.iconTextSize <= 16\n const iconTextSize = isValidIconTextSize ? specification.iconTextSize : 12\n const volumePath = path.join(\"/Volumes\", volumeName)\n // https://github.com/electron-userland/electron-builder/issues/2115\n const backgroundFile = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager)\n\n const settings: DmgBuildConfig = {\n title: path.basename(volumePath),\n icon: await packager.getResource(specification.icon),\n \"icon-size\": specification.iconSize,\n \"text-size\": iconTextSize,\n\n \"compression-level\": Number(process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || \"9\"),\n // filesystem: specification.filesystem || \"HFS+\",\n format: specification.format,\n contents:\n specification.contents?.map(c => ({\n path: c.path || appPath, // path is required, when ommitted, appPath is used (backward compatibility\n x: c.x,\n y: c.y,\n name: c.name,\n type: c.type === \"dir\" ? \"file\" : c.type, // appdmg expects \"file\" for directories\n // hide_extension: c.hideExtension,\n })) || [],\n }\n\n if (specification.backgroundColor != null || specification.background == null) {\n settings[\"background-color\"] = specification.backgroundColor || \"#ffffff\"\n\n const window = specification.window\n if (window != null) {\n settings.window = {\n position: {\n x: window.x ?? 100,\n y: window.y ?? 400,\n },\n size: {\n width: window.width ?? 540,\n height: window.height ?? 300,\n },\n }\n }\n } else {\n settings.background = backgroundFile\n delete settings[\"background-color\"]\n }\n\n if (!isEmptyOrSpaces(settings.background)) {\n const size = await getImageSizeUsingSips(settings.background)\n settings.window = { position: { x: 400, y: Math.round((1440 - size.height) / 2) }, size, ...settings.window }\n }\n\n const settingsFile = await packager.getTempFile(\".json\")\n await writeFile(settingsFile, JSON.stringify(settings, null, 2))\n\n const executePython = async (execName: string) => {\n let pythonPath = process.env.PYTHON_PATH\n if (!pythonPath) {\n pythonPath = (await exec(\"which\", [execName])).trim()\n }\n await exec(pythonPath, [path.join(getDmgVendorPath(), \"run_dmgbuild.py\"), \"-s\", settingsFile, path.basename(volumePath), artifactPath], {\n cwd: getDmgVendorPath(),\n env: {\n ...process.env,\n PYTHONIOENCODING: \"utf8\",\n },\n })\n }\n try {\n await executePython(\"python3\")\n } catch (_error: any) {\n await executePython(\"python\")\n }\n // effectiveOptionComputed, when present, is purely for verifying result during test execution\n return (\n packager.packagerOptions.effectiveOptionComputed == null ||\n (await attachAndExecute(artifactPath, false, async volumePath => {\n return !(await packager.packagerOptions.effectiveOptionComputed!({\n volumePath,\n specification: {\n ...specification,\n // clean up `contents` for test snapshot verification since app path is absolute to a unique tmp dir\n contents: specification.contents?.map((c: any) => ({\n ...c,\n path: path.extname(c.path ?? \"\") === \".app\" ? path.relative(packager.projectDir, c.path) : c.path,\n })),\n },\n packager,\n }))\n }))\n )\n}\n\nexport async function transformBackgroundFileIfNeed(file: string, tmpDir: TmpDir): Promise<string> {\n if (path.extname(file.toLowerCase()) === \".tiff\") {\n return file\n }\n\n const retinaFile = file.replace(/\\.([a-z]+)$/, \"@2x.$1\")\n if (await exists(retinaFile)) {\n const tiffFile = await tmpDir.getTempFile({ suffix: \".tiff\" })\n await exec(\"tiffutil\", [\"-cathidpicheck\", file, retinaFile, \"-out\", tiffFile])\n return tiffFile\n }\n\n return file\n}\n\nexport async function getImageSizeUsingSips(background: string) {\n const stdout = await exec(\"sips\", [\"-g\", \"pixelHeight\", \"-g\", \"pixelWidth\", background])\n\n let width = 0\n let height = 0\n\n const re = /([a-zA-Z]+):\\s*(\\d+)/\n const lines = stdout.split(\"\\n\")\n\n for (const line of lines) {\n const match = re.exec(line)\n if (!match) {\n continue\n }\n\n const key = match[1]\n const value = parseInt(match[2], 10)\n\n if (isNaN(value)) {\n throw new Error(`Failed to parse number from line: \"${line}\"`)\n }\n\n if (key === \"pixelWidth\") {\n width = value\n } else if (key === \"pixelHeight\") {\n height = value\n }\n }\n\n return { width, height }\n}\n"]}
|
package/out/hdiuil.js
CHANGED
|
@@ -47,7 +47,7 @@ const shouldRetry = (args) => (error) => {
|
|
|
47
47
|
const stderr = ((_b = error.stderr) === null || _b === void 0 ? void 0 : _b.toString()) || "";
|
|
48
48
|
const stdout = ((_c = error.stdout) === null || _c === void 0 ? void 0 : _c.toString()) || "";
|
|
49
49
|
const output = `${stdout} ${stderr}`.trim();
|
|
50
|
-
const willRetry = exports.hdiutilTransientExitCodes.has(code);
|
|
50
|
+
const willRetry = exports.hdiutilTransientExitCodes.has(code.toString());
|
|
51
51
|
builder_util_1.log.warn({ willRetry, args, code, output }, `hdiutil error: ${explainHdiutilError(code)}`);
|
|
52
52
|
return willRetry;
|
|
53
53
|
};
|