dmg-builder 26.15.2 → 27.0.0-alpha.0

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.
@@ -1,7 +1,6 @@
1
- import { DmgOptions, Target } from "app-builder-lib";
2
- import { MacPackager } from "app-builder-lib/out/macPackager";
1
+ import { DmgOptions, MacPackager, Target } from "app-builder-lib";
3
2
  import { Arch } from "builder-util";
4
- import type { DmgBuildLicenseConfig } from "./dmgLicense";
3
+ import type { DmgBuildLicenseConfig } from "./dmgLicense.js";
5
4
  export interface DmgBuildConfig {
6
5
  title: string;
7
6
  icon?: string | null;
@@ -47,3 +46,4 @@ export declare class DmgTarget extends Target {
47
46
  computeVolumeName(arch: Arch, custom?: string | null): string;
48
47
  computeDmgOptions(appPath: string): Promise<DmgOptions>;
49
48
  }
49
+ //# sourceMappingURL=dmg.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmg.d.ts","sourceRoot":"","sources":["../src/dmg.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAEjE,OAAO,EAAE,IAAI,EAAmE,MAAM,cAAc,CAAA;AAIpG,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAK5D,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,MAAM,CAAC,EAAE;QACP,QAAQ,CAAC,EAAE;YACT,CAAC,C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
@@ -1,17 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DmgTarget = void 0;
4
- const app_builder_lib_1 = require("app-builder-lib");
5
- const macCodeSign_1 = require("app-builder-lib/out/codeSign/macCodeSign");
6
- const differentialUpdateInfoBuilder_1 = require("app-builder-lib/out/targets/differentialUpdateInfoBuilder");
7
- const builder_util_1 = require("builder-util");
8
- const filename_1 = require("builder-util/out/filename");
9
- const os_1 = require("os");
10
- const path = require("path");
11
- const dmgLicense_1 = require("./dmgLicense");
12
- const dmgUtil_1 = require("./dmgUtil");
13
- const hdiuil_1 = require("./hdiuil");
14
- class DmgTarget extends app_builder_lib_1.Target {
1
+ import { Target } from "app-builder-lib";
2
+ import { createBlockmap, findIdentity, isSignAllowed } from "app-builder-lib/internal";
3
+ import { exec, getArchSuffix, InvalidConfigurationError, isEmptyOrSpaces } from "builder-util";
4
+ import { sanitizeFileName } from "builder-util/internal";
5
+ import { release as getOsRelease } from "os";
6
+ import * as path from "path";
7
+ import { addLicenseToDmg } from "./dmgLicense.js";
8
+ import { computeBackground, customizeDmg } from "./dmgUtil.js";
9
+ import { hdiUtil } from "./hdiuil.js";
10
+ export class DmgTarget extends Target {
15
11
  constructor(packager, outDir) {
16
12
  super("dmg");
17
13
  this.packager = packager;
@@ -22,21 +18,21 @@ class DmgTarget extends app_builder_lib_1.Target {
22
18
  async build(appPath, arch) {
23
19
  const packager = this.packager;
24
20
  // tslint:disable-next-line:no-invalid-template-strings
25
- const artifactName = packager.expandArtifactNamePattern(this.options, "dmg", arch, "${productName}-" + (packager.platformSpecificBuildOptions.bundleShortVersion || "${version}") + "-${arch}.${ext}", true, packager.platformSpecificBuildOptions.defaultArch);
21
+ const artifactName = packager.expandArtifactNamePattern(this.options, "dmg", arch, "${productName}-" + (packager.platformOptions.bundleShortVersion || "${version}") + "-${arch}.${ext}", true, packager.platformOptions.defaultArch);
26
22
  const artifactPath = path.join(this.outDir, artifactName);
27
- await packager.info.emitArtifactBuildStarted({
23
+ await packager.emitArtifactBuildStarted({
28
24
  targetPresentableName: "DMG",
29
25
  file: artifactPath,
30
26
  arch,
31
27
  });
32
- const volumeName = (0, filename_1.sanitizeFileName)(this.computeVolumeName(arch, this.options.title));
28
+ const volumeName = sanitizeFileName(this.computeVolumeName(arch, this.options.title));
33
29
  const specification = await this.computeDmgOptions(appPath);
34
- const licenseData = await (0, dmgLicense_1.addLicenseToDmg)(packager, this.options.license);
35
- if (!(await (0, dmgUtil_1.customizeDmg)({ appPath, artifactPath, volumeName, specification, packager, licenseData }))) {
30
+ const licenseData = await addLicenseToDmg(packager, this.options.license);
31
+ if (!(await customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }))) {
36
32
  return;
37
33
  }
38
- if (this.options.internetEnabled && parseInt((0, os_1.release)().split(".")[0], 10) < 19) {
39
- await (0, hdiuil_1.hdiUtil)(addLogLevel(["internet-enable"]).concat(artifactPath));
34
+ if (this.options.internetEnabled && parseInt(getOsRelease().split(".")[0], 10) < 19) {
35
+ await hdiUtil(addLogLevel(["internet-enable"]).concat(artifactPath));
40
36
  }
41
37
  if (packager.packagerOptions.effectiveOptionComputed != null) {
42
38
  await packager.packagerOptions.effectiveOptionComputed({ licenseData });
@@ -45,8 +41,8 @@ class DmgTarget extends app_builder_lib_1.Target {
45
41
  await this.signDmg(artifactPath);
46
42
  }
47
43
  const safeArtifactName = packager.computeSafeArtifactName(artifactName, "dmg");
48
- const updateInfo = this.options.writeUpdateInfo === false ? null : await (0, differentialUpdateInfoBuilder_1.createBlockmap)(artifactPath, this, packager, safeArtifactName);
49
- await packager.info.emitArtifactBuildCompleted({
44
+ const updateInfo = this.options.writeUpdateInfo === false ? null : await createBlockmap(artifactPath, this, packager, safeArtifactName);
45
+ await packager.emitArtifactBuildCompleted({
50
46
  file: artifactPath,
51
47
  safeArtifactName,
52
48
  target: this,
@@ -57,11 +53,11 @@ class DmgTarget extends app_builder_lib_1.Target {
57
53
  });
58
54
  }
59
55
  async signDmg(artifactPath) {
60
- if (!(0, macCodeSign_1.isSignAllowed)(false)) {
56
+ if (!isSignAllowed(false)) {
61
57
  return;
62
58
  }
63
59
  const packager = this.packager;
64
- const qualifier = packager.platformSpecificBuildOptions.identity;
60
+ const qualifier = packager.platformOptions.identity;
65
61
  // explicitly disabled if set to null
66
62
  if (qualifier === null) {
67
63
  // macPackager already somehow handle this situation, so, here just return
@@ -69,9 +65,9 @@ class DmgTarget extends app_builder_lib_1.Target {
69
65
  }
70
66
  const keychainFile = (await packager.codeSigningInfo.value).keychainFile;
71
67
  const certificateType = "Developer ID Application";
72
- let identity = await (0, macCodeSign_1.findIdentity)(certificateType, qualifier, keychainFile);
68
+ let identity = await findIdentity(certificateType, qualifier, keychainFile);
73
69
  if (identity == null) {
74
- identity = await (0, macCodeSign_1.findIdentity)("Mac Developer", qualifier, keychainFile);
70
+ identity = await findIdentity("Mac Developer", qualifier, keychainFile);
75
71
  if (identity == null) {
76
72
  return;
77
73
  }
@@ -81,12 +77,12 @@ class DmgTarget extends app_builder_lib_1.Target {
81
77
  args.push("--keychain", keychainFile);
82
78
  }
83
79
  args.push(artifactPath);
84
- await (0, builder_util_1.exec)("codesign", args);
80
+ await exec("codesign", args);
85
81
  }
86
82
  computeVolumeName(arch, custom) {
87
83
  const appInfo = this.packager.appInfo;
88
- const shortVersion = this.packager.platformSpecificBuildOptions.bundleShortVersion || appInfo.version;
89
- const archString = (0, builder_util_1.getArchSuffix)(arch, this.packager.platformSpecificBuildOptions.defaultArch);
84
+ const shortVersion = this.packager.platformOptions.bundleShortVersion || appInfo.version;
85
+ const archString = getArchSuffix(arch, this.packager.platformOptions.defaultArch);
90
86
  if (custom == null) {
91
87
  return `${appInfo.productFilename} ${shortVersion}${archString}`;
92
88
  }
@@ -104,17 +100,17 @@ class DmgTarget extends app_builder_lib_1.Target {
104
100
  if (specification.icon == null && specification.icon !== null) {
105
101
  specification.icon = await packager.getIconPath();
106
102
  }
107
- if (specification.icon != null && (0, builder_util_1.isEmptyOrSpaces)(specification.icon)) {
108
- throw new builder_util_1.InvalidConfigurationError("dmg.icon cannot be specified as empty string");
103
+ if (specification.icon != null && isEmptyOrSpaces(specification.icon)) {
104
+ throw new InvalidConfigurationError("dmg.icon cannot be specified as empty string");
109
105
  }
110
106
  const background = specification.background;
111
107
  if (specification.backgroundColor != null) {
112
108
  if (background != null) {
113
- throw new builder_util_1.InvalidConfigurationError("Both dmg.backgroundColor and dmg.background are specified — please set the only one");
109
+ throw new InvalidConfigurationError("Both dmg.backgroundColor and dmg.background are specified — please set the only one");
114
110
  }
115
111
  }
116
112
  else if (background == null) {
117
- specification.background = await (0, dmgUtil_1.computeBackground)(packager);
113
+ specification.background = await computeBackground(packager);
118
114
  }
119
115
  else {
120
116
  specification.background = await packager.getResource(background);
@@ -150,7 +146,6 @@ class DmgTarget extends app_builder_lib_1.Target {
150
146
  return specification;
151
147
  }
152
148
  }
153
- exports.DmgTarget = DmgTarget;
154
149
  function addLogLevel(args, isVerbose = process.env.DEBUG_DMG === "true") {
155
150
  args.push(isVerbose ? "-verbose" : "-quiet");
156
151
  return args;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmg.js","sourceRoot":"","sources":["../src/dmg.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,iBAAiB,CAAA;AACjE,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACtF,OAAO,EAAQ,IAAI,EAAE,aAAa,EAAE,yBAAyB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AACpG,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAA;AACxD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,IAAI,CAAA;AAC5C,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAE5B,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACjD,OAAO,EAAE,iBAAiB,EAAE,YAAY,E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AK,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, MacPackager, Target } from \"app-builder-lib\"\nimport { createBlockmap, findIdentity, isSignAllowed } from \"app-builder-lib/internal\"\nimport { Arch, exec, getArchSuffix, InvalidConfigurationError, isEmptyOrSpaces } from \"builder-util\"\nimport { sanitizeFileName } from \"builder-util/internal\"\nimport { release as getOsRelease } from \"os\"\nimport * as path from \"path\"\nimport type { DmgBuildLicenseConfig } from \"./dmgLicense.js\"\nimport { addLicenseToDmg } from \"./dmgLicense.js\"\nimport { computeBackground, customizeDmg } from \"./dmgUtil.js\"\nimport { hdiUtil } from \"./hdiuil.js\"\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 size?: string | null\n shrink?: boolean\n filesystem?: string\n \"compression-level\"?: number | null\n license?: DmgBuildLicenseConfig | 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.platformOptions.bundleShortVersion || \"${version}\") + \"-${arch}.${ext}\",\n true,\n packager.platformOptions.defaultArch\n )\n const artifactPath = path.join(this.outDir, artifactName)\n await packager.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 const licenseData = await addLicenseToDmg(packager, this.options.license)\n\n if (!(await customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }))) {\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 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.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.platformOptions.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.platformOptions.bundleShortVersion || appInfo.version\n const archString = getArchSuffix(arch, this.packager.platformOptions.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"]}
@@ -12,3 +12,4 @@ export type DmgBuildLicenseConfig = {
12
12
  }>;
13
13
  };
14
14
  export declare function addLicenseToDmg(packager: PlatformPackager<any>, explicitLicense?: string | Record<string, string> | null): Promise<DmgBuildLicenseConfig | null>;
15
+ //# sourceMappingURL=dmgLicense.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmgLicense.d.ts","sourceRoot":"","sources":["../src/dmgLicense.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AASlD,MAAM,MAAM,qBAAqB,GAAG;IAClC,kBAAkB,EAAE,MAAM,CAAA;IAC1B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAChC,OAAO,CAAC,EAAE,MAAM,CACd,MAAM,EACN;QACE,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,IAAI,CAAC,EAAE,MAAM,CAAA;QACb,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB,CACF,CAAA;CACF,CAAA;AAED,wBAAsB,eAAe,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC,CAatK"}
@@ -1,12 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.addLicenseToDmg = addLicenseToDmg;
4
- const license_1 = require("app-builder-lib/out/util/license");
5
- const builder_util_1 = require("builder-util");
6
- const fs_extra_1 = require("fs-extra");
7
- const js_yaml_1 = require("js-yaml");
8
- const licenseButtons_1 = require("./licenseButtons");
9
- async function addLicenseToDmg(packager, explicitLicense) {
1
+ import { getLicenseFiles } from "app-builder-lib/internal";
2
+ import { InvalidConfigurationError } from "builder-util";
3
+ import { CORE_SCHEMA, load } from "js-yaml";
4
+ import { getLicenseButtonsFile } from "./licenseButtons.js";
5
+ import _fsExtra from "fs-extra";
6
+ const { readFile, readJson } = _fsExtra;
7
+ export async function addLicenseToDmg(packager, explicitLicense) {
10
8
  // null = explicitly disabled; skip both explicit and convention paths
11
9
  if (explicitLicense === null) {
12
10
  return null;
@@ -22,7 +20,7 @@ async function buildExplicitLicenseConfig(packager, license) {
22
20
  if (typeof license === "string") {
23
21
  const resolvedPath = await packager.getResource(license);
24
22
  if (resolvedPath == null) {
25
- throw new builder_util_1.InvalidConfigurationError(`dmg.license file not found: "${license}"`);
23
+ throw new InvalidConfigurationError(`dmg.license file not found: "${license}"`);
26
24
  }
27
25
  return { "default-language": "en_US", licenses: { en_US: resolvedPath } };
28
26
  }
@@ -31,7 +29,7 @@ async function buildExplicitLicenseConfig(packager, license) {
31
29
  for (const [lang, filePath] of Object.entries(license)) {
32
30
  const resolvedPath = await packager.getResource(filePath);
33
31
  if (resolvedPath == null) {
34
- throw new builder_util_1.InvalidConfigurationError(`dmg.license file not found for language "${lang}": "${filePath}"`);
32
+ throw new InvalidConfigurationError(`dmg.license file not found for language "${lang}": "${filePath}"`);
35
33
  }
36
34
  licenses[lang] = resolvedPath;
37
35
  }
@@ -44,18 +42,17 @@ async function buildExplicitLicenseConfig(packager, license) {
44
42
  };
45
43
  }
46
44
  async function buildConventionLicenseConfig(packager) {
47
- var _a;
48
- const licenseFiles = await (0, license_1.getLicenseFiles)(packager);
45
+ const licenseFiles = await getLicenseFiles(packager);
49
46
  if (licenseFiles.length === 0) {
50
47
  return null;
51
48
  }
52
- const licenseButtonFiles = await (0, licenseButtons_1.getLicenseButtonsFile)(packager);
49
+ const licenseButtonFiles = await getLicenseButtonsFile(packager);
53
50
  packager.debugLogger.add("dmg.licenseFiles", licenseFiles);
54
51
  packager.debugLogger.add("dmg.licenseButtons", licenseButtonFiles);
55
52
  const licenses = {};
56
53
  for (const file of licenseFiles) {
57
54
  if (licenses[file.langWithRegion] != null) {
58
- throw new builder_util_1.InvalidConfigurationError(`Multiple license files found for language "${file.langWithRegion}": "${licenses[file.langWithRegion]}" and "${file.file}". Only one license file per language is supported.`);
55
+ throw new InvalidConfigurationError(`Multiple license files found for language "${file.langWithRegion}": "${licenses[file.langWithRegion]}" and "${file.file}". Only one license file per language is supported.`);
59
56
  }
60
57
  licenses[file.langWithRegion] = file.file;
61
58
  }
@@ -67,7 +64,7 @@ async function buildConventionLicenseConfig(packager) {
67
64
  const buttons = {};
68
65
  for (const button of licenseButtonFiles) {
69
66
  const filepath = button.file;
70
- const raw = filepath.endsWith(".yml") ? (0, js_yaml_1.load)(await (0, fs_extra_1.readFile)(filepath, "utf-8"), { schema: js_yaml_1.CORE_SCHEMA }) : await (0, fs_extra_1.readJson)(filepath);
67
+ const raw = filepath.endsWith(".yml") ? load(await readFile(filepath, "utf-8"), { schema: CORE_SCHEMA }) : await readJson(filepath);
71
68
  const entry = {};
72
69
  if (raw.languageName != null) {
73
70
  entry.language = raw.languageName;
@@ -85,7 +82,7 @@ async function buildConventionLicenseConfig(packager) {
85
82
  entry.save = raw.save;
86
83
  }
87
84
  // support legacy `description` field as well as `message`
88
- const msg = (_a = raw.message) !== null && _a !== void 0 ? _a : raw.description;
85
+ const msg = raw.message ?? raw.description;
89
86
  if (msg != null) {
90
87
  entry.message = msg;
91
88
  }
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmgLicense.js","sourceRoot":"","sources":["../src/dmgLicense.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAC3C,OAAO,EAAE,qBAAqB,EAAE,MAAM,qBAAqB,CAAA;AAC3D,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAA;AAkBvC,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,QAA+B,EAAE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AM,CAAA;AACf,CAAC","sourcesContent":["import { PlatformPackager } from \"app-builder-lib\"\nimport { getLicenseFiles } from \"app-builder-lib/internal\"\nimport { InvalidConfigurationError } from \"builder-util\"\n\nimport { CORE_SCHEMA, load } from \"js-yaml\"\nimport { getLicenseButtonsFile } from \"./licenseButtons.js\"\nimport _fsExtra from \"fs-extra\"\nconst { readFile, readJson } = _fsExtra\n\nexport type DmgBuildLicenseConfig = {\n \"default-language\": string\n licenses: Record<string, string>\n buttons?: Record<\n string,\n {\n language?: string\n agree?: string\n disagree?: string\n print?: string\n save?: string\n message?: string\n }\n >\n}\n\nexport async function addLicenseToDmg(packager: PlatformPackager<any>, explicitLicense?: string | Record<string, string> | null): Promise<DmgBuildLicenseConfig | null> {\n // null = explicitly disabled; skip both explicit and convention paths\n if (explicitLicense === null) {\n return null\n }\n\n // Explicit config overrides file-naming convention\n if (explicitLicense !== undefined) {\n return buildExplicitLicenseConfig(packager, explicitLicense)\n }\n\n // File-naming convention: license_LANG.{rtf,txt,html}\n return buildConventionLicenseConfig(packager)\n}\n\nasync function buildExplicitLicenseConfig(packager: PlatformPackager<any>, license: string | Record<string, string>): Promise<DmgBuildLicenseConfig | null> {\n if (typeof license === \"string\") {\n const resolvedPath = await packager.getResource(license)\n if (resolvedPath == null) {\n throw new InvalidConfigurationError(`dmg.license file not found: \"${license}\"`)\n }\n return { \"default-language\": \"en_US\", licenses: { en_US: resolvedPath } }\n }\n\n // Record<langCode, filePath>\n const licenses: Record<string, string> = {}\n for (const [lang, filePath] of Object.entries(license)) {\n const resolvedPath = await packager.getResource(filePath)\n if (resolvedPath == null) {\n throw new InvalidConfigurationError(`dmg.license file not found for language \"${lang}\": \"${filePath}\"`)\n }\n licenses[lang] = resolvedPath\n }\n\n if (Object.keys(licenses).length === 0) {\n return null\n }\n\n return {\n \"default-language\": Object.keys(licenses)[0],\n licenses,\n }\n}\n\nasync function buildConventionLicenseConfig(packager: PlatformPackager<any>): Promise<DmgBuildLicenseConfig | null> {\n const licenseFiles = await getLicenseFiles(packager)\n if (licenseFiles.length === 0) {\n return null\n }\n\n const licenseButtonFiles = await getLicenseButtonsFile(packager)\n packager.debugLogger.add(\"dmg.licenseFiles\", licenseFiles)\n packager.debugLogger.add(\"dmg.licenseButtons\", licenseButtonFiles)\n\n const licenses: Record<string, string> = {}\n for (const file of licenseFiles) {\n if (licenses[file.langWithRegion] != null) {\n throw new InvalidConfigurationError(\n `Multiple license files found for language \"${file.langWithRegion}\": \"${licenses[file.langWithRegion]}\" and \"${file.file}\". Only one license file per language is supported.`\n )\n }\n licenses[file.langWithRegion] = file.file\n }\n\n const result: DmgBuildLicenseConfig = {\n \"default-language\": licenseFiles[0].langWithRegion,\n licenses,\n }\n\n if (licenseButtonFiles.length > 0) {\n const buttons: DmgBuildLicenseConfig[\"buttons\"] = {}\n for (const button of licenseButtonFiles) {\n const filepath = button.file\n const raw: any = filepath.endsWith(\".yml\") ? load(await readFile(filepath, \"utf-8\"), { schema: CORE_SCHEMA }) : await readJson(filepath)\n\n const entry: Record<string, string> = {}\n if (raw.languageName != null) {\n entry.language = raw.languageName\n }\n if (raw.agree != null) {\n entry.agree = raw.agree\n }\n if (raw.disagree != null) {\n entry.disagree = raw.disagree\n }\n if (raw.print != null) {\n entry.print = raw.print\n }\n if (raw.save != null) {\n entry.save = raw.save\n }\n // support legacy `description` field as well as `message`\n const msg = raw.message ?? raw.description\n if (msg != null) {\n entry.message = msg\n }\n\n buttons[button.langWithRegion] = entry\n }\n result.buttons = buttons\n }\n\n return result\n}\n"]}
@@ -1,7 +1,7 @@
1
1
  import { DmgOptions, MacPackager, PlatformPackager } from "app-builder-lib";
2
2
  import { TmpDir } from "builder-util";
3
- import type { DmgBuildLicenseConfig } from "./dmgLicense";
4
- export { DmgTarget } from "./dmg";
3
+ import type { DmgBuildLicenseConfig } from "./dmgLicense.js";
4
+ export { DmgTarget } from "./dmg.js";
5
5
  export declare function getDmgTemplatePath(): string;
6
6
  export declare function attachAndExecute(dmgPath: string, readWrite: boolean, forceDetach: boolean, task: (devicePath: string) => Promise<any>): Promise<any>;
7
7
  export declare function detach(name: string, alwaysForce: boolean): Promise<string | null>;
@@ -20,3 +20,4 @@ export declare function getImageSizeUsingSips(background: string): Promise<{
20
20
  width: number;
21
21
  height: number;
22
22
  }>;
23
+ //# sourceMappingURL=dmgUtil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmgUtil.d.ts","sourceRoot":"","sources":["../src/dmgUtil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,UAAU,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAEvF,OAAO,EAAiF,MAAM,EAAE,MAAM,cAAc,CAAA;AAMpH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAA;AAK5D,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAIpC,wBAAgB,kBAAkB,WAEjC;AAmCD,wBAAsB,gBAAgB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,OAAO,CAAC,GAAG,CAAC,gBAkC3I;AAED,wBAAsB,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,0BAS9D;AAED,wBAAsB,iBAAiB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,MAAM,CAAC,CASxF;AAcD,KAAK,gBAAgB,GAAG;IACtB,OAAO,EAAE,MAAM,CAAA;IACf,YAAY,EAAE,MAAM,CAAA;IACpB,UAAU,EAAE,MAAM,CAAA;IAClB,aAAa,EAAE,UAAU,CAAA;IACzB,QAAQ,EAAE,WAAW,CAAA;IACrB,WAAW,CAAC,EAAE,qBAAqB,GAAG,IAAI,CAAA;CAC3C,CAAA;AAED,wBAAsB,YAAY,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,UAAU,EAAE,aAAa,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC,CA2GlJ;AAED,wBAAsB,6BAA6B,CAAC,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAajG;AAED,wBAAsB,qBAAqB,CAAC,UAAU,EAAE,MAAM;;;GA8B7D"}
@@ -1,35 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DmgTarget = void 0;
4
- exports.getDmgTemplatePath = getDmgTemplatePath;
5
- exports.attachAndExecute = attachAndExecute;
6
- exports.detach = detach;
7
- exports.computeBackground = computeBackground;
8
- exports.serializeString = serializeString;
9
- exports.customizeDmg = customizeDmg;
10
- exports.transformBackgroundFileIfNeed = transformBackgroundFileIfNeed;
11
- exports.getImageSizeUsingSips = getImageSizeUsingSips;
12
- const electronGet_1 = require("app-builder-lib/out/util/electronGet");
13
- const toolsetLock_1 = require("app-builder-lib/out/util/toolsetLock");
14
- const builder_util_1 = require("builder-util");
15
- const promises_1 = require("fs/promises");
16
- const fs_extra_1 = require("fs-extra");
17
- const path = require("path");
18
- const hdiuil_1 = require("./hdiuil");
19
- var dmg_1 = require("./dmg");
20
- Object.defineProperty(exports, "DmgTarget", { enumerable: true, get: function () { return dmg_1.DmgTarget; } });
21
- const root = path.join(__dirname, "..");
22
- function getDmgTemplatePath() {
1
+ import { downloadBuilderToolset, withToolsetLock } from "app-builder-lib/internal";
2
+ import { exec, executeFinally, exists, InvalidConfigurationError, isEmptyOrSpaces, log } from "builder-util";
3
+ import { sleep } from "builder-util-runtime";
4
+ import { stat } from "fs/promises";
5
+ import * as path from "path";
6
+ import { hdiUtil, hdiUtilWithStdin, hdiutilTransientExitCodes } from "./hdiuil.js";
7
+ import _fsExtra from "fs-extra";
8
+ const { writeFile } = _fsExtra;
9
+ export { DmgTarget } from "./dmg.js";
10
+ const root = path.join(import.meta.dirname, "..");
11
+ export function getDmgTemplatePath() {
23
12
  return path.join(root, "templates");
24
13
  }
25
14
  async function getDmgVendorPath() {
26
- var _a;
27
- const customDmgbuildPath = (_a = process.env.CUSTOM_DMGBUILD_PATH) === null || _a === void 0 ? void 0 : _a.trim();
15
+ const customDmgbuildPath = process.env.CUSTOM_DMGBUILD_PATH?.trim();
28
16
  if (customDmgbuildPath) {
29
17
  const resolvedPath = path.resolve(customDmgbuildPath);
30
18
  let dmgbuildStat;
31
19
  try {
32
- dmgbuildStat = await (0, promises_1.stat)(resolvedPath);
20
+ dmgbuildStat = await stat(resolvedPath);
33
21
  }
34
22
  catch (e) {
35
23
  if (e.code === "ENOENT") {
@@ -40,12 +28,12 @@ async function getDmgVendorPath() {
40
28
  if (!dmgbuildStat.isFile()) {
41
29
  throw new Error(`CUSTOM_DMGBUILD_PATH "${resolvedPath}" is not a regular file`);
42
30
  }
43
- builder_util_1.log.warn({ path: resolvedPath }, "using CUSTOM_DMGBUILD_PATH override for dmgbuild binary");
31
+ log.warn({ path: resolvedPath }, "using CUSTOM_DMGBUILD_PATH override for dmgbuild binary");
44
32
  return resolvedPath;
45
33
  }
46
34
  const arch = process.arch === "arm64" ? "arm64" : "x86_64";
47
35
  // https://github.com/electron-userland/electron-builder-binaries/releases?q=dmg-builder&expanded=true
48
- const file = await (0, electronGet_1.downloadBuilderToolset)({
36
+ const file = await downloadBuilderToolset({
49
37
  releaseName: "dmg-builder@1.2.5",
50
38
  filenameWithExt: `dmgbuild-bundle-${arch}-75c8a6c.tar.gz`,
51
39
  checksums: {
@@ -55,7 +43,7 @@ async function getDmgVendorPath() {
55
43
  });
56
44
  return path.resolve(file, "dmgbuild");
57
45
  }
58
- async function attachAndExecute(dmgPath, readWrite, forceDetach, task) {
46
+ export async function attachAndExecute(dmgPath, readWrite, forceDetach, task) {
59
47
  //noinspection SpellCheckingInspection
60
48
  const args = ["attach", "-noverify", "-noautoopen"];
61
49
  if (readWrite) {
@@ -64,7 +52,7 @@ async function attachAndExecute(dmgPath, readWrite, forceDetach, task) {
64
52
  args.push(dmgPath);
65
53
  // Pipe "y\n" to stdin so that hdiutil auto-accepts any SLA/EULA dialog
66
54
  // embedded in the DMG instead of blocking on a terminal prompt.
67
- const attachResult = await (0, hdiuil_1.hdiUtilWithStdin)(args, "y\n");
55
+ const attachResult = await hdiUtilWithStdin(args, "y\n");
68
56
  // Use multiline flag so ^ matches any line start — the EULA text (if any)
69
57
  // precedes the /dev/... device lines in hdiutil's stdout output.
70
58
  const deviceResult = attachResult == null ? null : /^(\/dev\/\w+)/m.exec(attachResult);
@@ -86,19 +74,19 @@ async function attachAndExecute(dmgPath, readWrite, forceDetach, task) {
86
74
  if (volumePath == null) {
87
75
  throw new Error(`Cannot find volume mount path for device: ${device}`);
88
76
  }
89
- return await (0, builder_util_1.executeFinally)(task(volumePath), () => detach(device, forceDetach));
77
+ return await executeFinally(task(volumePath), () => detach(device, forceDetach));
90
78
  }
91
- async function detach(name, alwaysForce) {
92
- return (0, hdiuil_1.hdiUtil)(["detach", "-quiet", name]).catch(async (e) => {
93
- if (hdiuil_1.hdiutilTransientExitCodes.has(e.code) || alwaysForce) {
79
+ export async function detach(name, alwaysForce) {
80
+ return hdiUtil(["detach", "-quiet", name]).catch(async (e) => {
81
+ if (hdiutilTransientExitCodes.has(e.code) || alwaysForce) {
94
82
  // Delay then force unmount with verbose output
95
- await new Promise(resolve => setTimeout(resolve, 3000));
96
- return (0, hdiuil_1.hdiUtil)(["detach", "-force", name]);
83
+ await sleep(3000);
84
+ return hdiUtil(["detach", "-force", name]);
97
85
  }
98
86
  throw e;
99
87
  });
100
88
  }
101
- async function computeBackground(packager) {
89
+ export async function computeBackground(packager) {
102
90
  const resourceList = await packager.resourceList;
103
91
  if (resourceList.includes("background.tiff")) {
104
92
  return path.join(packager.buildResourcesDir, "background.tiff");
@@ -111,7 +99,7 @@ async function computeBackground(packager) {
111
99
  }
112
100
  }
113
101
  /** @internal */
114
- function serializeString(data) {
102
+ export function serializeString(data) {
115
103
  return (' $"' +
116
104
  data
117
105
  .match(/.{1,32}/g)
@@ -119,8 +107,7 @@ function serializeString(data) {
119
107
  .join('"\n $"') +
120
108
  '"');
121
109
  }
122
- async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }) {
123
- var _a, _b, _c, _d, _e, _f;
110
+ export async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }) {
124
111
  const isValidIconTextSize = !!specification.iconTextSize && specification.iconTextSize >= 10 && specification.iconTextSize <= 16;
125
112
  const iconTextSize = isValidIconTextSize ? specification.iconTextSize : 12;
126
113
  const volumePath = path.join("/Volumes", volumeName);
@@ -134,14 +121,14 @@ async function customizeDmg({ appPath, artifactPath, volumeName, specification,
134
121
  format: specification.format,
135
122
  size: specification.size,
136
123
  shrink: specification.shrink,
137
- contents: ((_a = specification.contents) === null || _a === void 0 ? void 0 : _a.map(c => ({
124
+ contents: specification.contents?.map((c) => ({
138
125
  path: c.path || appPath, // path is required, when ommitted, appPath is used (backward compatibility
139
126
  x: c.x,
140
127
  y: c.y,
141
128
  name: c.name,
142
129
  type: c.type === "dir" ? "file" : c.type, // appdmg expects "file" for directories
143
130
  // hide_extension: c.hideExtension,
144
- }))) || [],
131
+ })) || [],
145
132
  };
146
133
  if (specification.badgeIcon) {
147
134
  let badgeIcon = await packager.getResource(specification.badgeIcon);
@@ -159,29 +146,29 @@ async function customizeDmg({ appPath, artifactPath, volumeName, specification,
159
146
  if (window != null) {
160
147
  settings.window = {
161
148
  position: {
162
- x: (_b = window.x) !== null && _b !== void 0 ? _b : 100,
163
- y: (_c = window.y) !== null && _c !== void 0 ? _c : 400,
149
+ x: window.x ?? 100,
150
+ y: window.y ?? 400,
164
151
  },
165
152
  size: {
166
- width: (_d = window.width) !== null && _d !== void 0 ? _d : 540,
167
- height: (_e = window.height) !== null && _e !== void 0 ? _e : 300,
153
+ width: window.width ?? 540,
154
+ height: window.height ?? 300,
168
155
  },
169
156
  };
170
157
  }
171
158
  }
172
159
  else {
173
- settings.background = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager);
160
+ settings.background = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.tempDirManager);
174
161
  }
175
- if (!(0, builder_util_1.isEmptyOrSpaces)(settings.background)) {
162
+ if (!isEmptyOrSpaces(settings.background)) {
176
163
  const size = await getImageSizeUsingSips(settings.background);
177
164
  settings.window = { position: { x: 400, y: Math.round((1440 - size.height) / 2) }, size, ...settings.window };
178
165
  }
179
- const workspaceRoot = await packager.info.getWorkspaceRoot();
180
- for (const item of (_f = settings.contents) !== null && _f !== void 0 ? _f : []) {
166
+ const workspaceRoot = await packager.getWorkspaceRoot();
167
+ for (const item of settings.contents ?? []) {
181
168
  if (item.type === "file" && item.path && path.isAbsolute(item.path)) {
182
169
  if (!item.path.startsWith(workspaceRoot + path.sep) && item.path !== appPath) {
183
- builder_util_1.log.error({ contentPath: item.path }, "dmg.contents path is outside the workspace root — verify this is intentional");
184
- throw new builder_util_1.InvalidConfigurationError(`dmg.contents path "${item.path}" is outside the workspace root`);
170
+ log.error({ contentPath: item.path }, "dmg.contents path is outside the workspace root — verify this is intentional");
171
+ throw new InvalidConfigurationError(`dmg.contents path "${item.path}" is outside the workspace root`);
185
172
  }
186
173
  }
187
174
  }
@@ -189,9 +176,9 @@ async function customizeDmg({ appPath, artifactPath, volumeName, specification,
189
176
  settings.license = licenseData;
190
177
  }
191
178
  const settingsFile = await packager.getTempFile(".json");
192
- await (0, fs_extra_1.writeFile)(settingsFile, JSON.stringify(settings, null, 2));
179
+ await writeFile(settingsFile, JSON.stringify(settings, null, 2));
193
180
  const dmgbuild = await getDmgVendorPath();
194
- await (0, toolsetLock_1.withToolsetLock)(() => (0, builder_util_1.exec)(dmgbuild, ["-s", settingsFile, path.basename(volumePath), artifactPath], {
181
+ await withToolsetLock(() => exec(dmgbuild, ["-s", settingsFile, path.basename(volumePath), artifactPath], {
195
182
  env: {
196
183
  ...process.env,
197
184
  PYTHONIOENCODING: "utf8",
@@ -200,38 +187,34 @@ async function customizeDmg({ appPath, artifactPath, volumeName, specification,
200
187
  // effectiveOptionComputed, when present, is purely for verifying result during test execution
201
188
  return (packager.packagerOptions.effectiveOptionComputed == null ||
202
189
  (await attachAndExecute(artifactPath, false, true, async (volumePath) => {
203
- var _a;
204
190
  return !(await packager.packagerOptions.effectiveOptionComputed({
205
191
  volumePath,
206
192
  specification: {
207
193
  ...specification,
208
194
  // clean up `contents` for test snapshot verification since app path is absolute to a unique tmp dir
209
- contents: (_a = specification.contents) === null || _a === void 0 ? void 0 : _a.map((c) => {
210
- var _a;
211
- return ({
212
- ...c,
213
- path: path.extname((_a = c.path) !== null && _a !== void 0 ? _a : "") === ".app" ? path.relative(packager.projectDir, c.path) : c.path,
214
- });
215
- }),
195
+ contents: specification.contents?.map((c) => ({
196
+ ...c,
197
+ path: path.extname(c.path ?? "") === ".app" ? path.relative(packager.projectDir, c.path) : c.path,
198
+ })),
216
199
  },
217
200
  packager,
218
201
  }));
219
202
  })));
220
203
  }
221
- async function transformBackgroundFileIfNeed(file, tmpDir) {
204
+ export async function transformBackgroundFileIfNeed(file, tmpDir) {
222
205
  if (path.extname(file.toLowerCase()) === ".tiff") {
223
206
  return file;
224
207
  }
225
208
  const retinaFile = file.replace(/\.([a-z]+)$/, "@2x.$1");
226
- if (await (0, builder_util_1.exists)(retinaFile)) {
209
+ if (await exists(retinaFile)) {
227
210
  const tiffFile = await tmpDir.getTempFile({ suffix: ".tiff" });
228
- await (0, builder_util_1.exec)("tiffutil", ["-cathidpicheck", file, retinaFile, "-out", tiffFile]);
211
+ await exec("tiffutil", ["-cathidpicheck", file, retinaFile, "-out", tiffFile]);
229
212
  return tiffFile;
230
213
  }
231
214
  return file;
232
215
  }
233
- async function getImageSizeUsingSips(background) {
234
- const stdout = await (0, builder_util_1.exec)("sips", ["-g", "pixelHeight", "-g", "pixelWidth", background]);
216
+ export async function getImageSizeUsingSips(background) {
217
+ const stdout = await exec("sips", ["-g", "pixelHeight", "-g", "pixelWidth", background]);
235
218
  let width = 0;
236
219
  let height = 0;
237
220
  const re = /([a-zA-Z]+):\s*(\d+)/;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dmgUtil.js","sourceRoot":"","sources":["../src/dmgUtil.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAClF,OAAO,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,yBAAyB,EAAE,eAAe,EAAE,GAAG,EAAU,MAAM,cAAc,CAAA;AACpH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAA;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AAElC,OAAO,KAAK,IAAI,MAAM,MAAM,CAAA;AAG5B,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAClF,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,MAAM,EAAE,SAAS,EAAE,GAAG,QAAQ,CAAA;AAE9B,OAAO,EAAE,SAAS,EAAE,MAAM,UAAU,CAAA;AAEpC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,CAAA;AAEjD,MAAM,UAAU,kBAAkB;IAChC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,WAAW,CAAC,CAAA;AACrC,CAAC;AAED,KAAK,UAAU,gBAAgB;IAC7B,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAAE,IAAI,EAAE,CAAA;IACnE,IAAI,kBAAkB,EAAE,CAAC;QACvB,MAAM,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAA;QACrD,IAAI,YAA8C,CAAA;QAClD,IAAI,CAAC;YACH,YAAY,GAAG,MAAM,IAA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AK,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 { DmgContent, DmgOptions, MacPackager, PlatformPackager } from \"app-builder-lib\"\nimport { downloadBuilderToolset, withToolsetLock } from \"app-builder-lib/internal\"\nimport { exec, executeFinally, exists, InvalidConfigurationError, isEmptyOrSpaces, log, TmpDir } from \"builder-util\"\nimport { sleep } from \"builder-util-runtime\"\nimport { stat } from \"fs/promises\"\n\nimport * as path from \"path\"\nimport { DmgBuildConfig } from \"./dmg.js\"\nimport type { DmgBuildLicenseConfig } from \"./dmgLicense.js\"\nimport { hdiUtil, hdiUtilWithStdin, hdiutilTransientExitCodes } from \"./hdiuil.js\"\nimport _fsExtra from \"fs-extra\"\nconst { writeFile } = _fsExtra\n\nexport { DmgTarget } from \"./dmg.js\"\n\nconst root = path.join(import.meta.dirname, \"..\")\n\nexport function getDmgTemplatePath() {\n return path.join(root, \"templates\")\n}\n\nasync function getDmgVendorPath(): Promise<string> {\n const customDmgbuildPath = process.env.CUSTOM_DMGBUILD_PATH?.trim()\n if (customDmgbuildPath) {\n const resolvedPath = path.resolve(customDmgbuildPath)\n let dmgbuildStat: Awaited<ReturnType<typeof stat>>\n try {\n dmgbuildStat = await stat(resolvedPath)\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n throw new Error(`CUSTOM_DMGBUILD_PATH \"${resolvedPath}\" does not exist`)\n }\n throw e\n }\n if (!dmgbuildStat.isFile()) {\n throw new Error(`CUSTOM_DMGBUILD_PATH \"${resolvedPath}\" is not a regular file`)\n }\n log.warn({ path: resolvedPath }, \"using CUSTOM_DMGBUILD_PATH override for dmgbuild binary\")\n return resolvedPath\n }\n\n const arch = process.arch === \"arm64\" ? \"arm64\" : \"x86_64\"\n // https://github.com/electron-userland/electron-builder-binaries/releases?q=dmg-builder&expanded=true\n const file = await downloadBuilderToolset({\n releaseName: \"dmg-builder@1.2.5\",\n filenameWithExt: `dmgbuild-bundle-${arch}-75c8a6c.tar.gz`,\n checksums: {\n \"dmgbuild-bundle-arm64-75c8a6c.tar.gz\": \"793404d0c96687e27d5ee40a668d498c92e36a64d6c2906df511031adb33cbeb\",\n \"dmgbuild-bundle-x86_64-75c8a6c.tar.gz\": \"1664972f9cc2d6e8fce3b63e42cd30078aff602669c5856939c4519921200433\",\n },\n })\n return path.resolve(file, \"dmgbuild\")\n}\n\nexport async function attachAndExecute(dmgPath: string, readWrite: boolean, forceDetach: 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 // Pipe \"y\\n\" to stdin so that hdiutil auto-accepts any SLA/EULA dialog\n // embedded in the DMG instead of blocking on a terminal prompt.\n const attachResult = await hdiUtilWithStdin(args, \"y\\n\")\n // Use multiline flag so ^ matches any line start — the EULA text (if any)\n // precedes the /dev/... device lines in hdiutil's stdout output.\n const deviceResult = attachResult == null ? null : /^(\\/dev\\/\\w+)/m.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 // Find the volume mount path directly from hdiutil attach output.\n // APFS images synthesize a new disk device (e.g. disk9) separate from the container disk\n // (e.g. disk8), so device-name matching via hdiutil info misses the APFS volume.\n let volumePath: string | null = null\n for (const line of attachResult!.split(\"\\n\")) {\n const match = /\\s+(\\/Volumes\\/.+?)\\s*$/.exec(line)\n if (match) {\n volumePath = match[1].trim()\n break\n }\n }\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, forceDetach))\n}\n\nexport async function detach(name: string, alwaysForce: boolean) {\n return hdiUtil([\"detach\", \"-quiet\", name]).catch(async e => {\n if (hdiutilTransientExitCodes.has(e.code) || alwaysForce) {\n // Delay then force unmount with verbose output\n await sleep(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 licenseData?: DmgBuildLicenseConfig | null\n}\n\nexport async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }: 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\n const settings: DmgBuildConfig = {\n title: path.basename(volumePath),\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 size: specification.size,\n shrink: specification.shrink,\n contents:\n specification.contents?.map((c: DmgContent) => ({\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.badgeIcon) {\n let badgeIcon = await packager.getResource(specification.badgeIcon)\n if (badgeIcon && badgeIcon.toLowerCase().endsWith(\".icon\")) {\n badgeIcon = await packager.generateIcnsFromIcon(badgeIcon)\n }\n settings[\"badge-icon\"] = badgeIcon\n } else {\n settings.icon = await packager.getResource(specification.icon)\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 = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.tempDirManager)\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 workspaceRoot = await packager.getWorkspaceRoot()\n for (const item of settings.contents ?? []) {\n if (item.type === \"file\" && item.path && path.isAbsolute(item.path)) {\n if (!item.path.startsWith(workspaceRoot + path.sep) && item.path !== appPath) {\n log.error({ contentPath: item.path }, \"dmg.contents path is outside the workspace root — verify this is intentional\")\n throw new InvalidConfigurationError(`dmg.contents path \"${item.path}\" is outside the workspace root`)\n }\n }\n }\n\n if (licenseData) {\n settings.license = licenseData\n }\n\n const settingsFile = await packager.getTempFile(\".json\")\n await writeFile(settingsFile, JSON.stringify(settings, null, 2))\n\n const dmgbuild = await getDmgVendorPath()\n await withToolsetLock(() =>\n exec(dmgbuild, [\"-s\", settingsFile, path.basename(volumePath), artifactPath], {\n env: {\n ...process.env,\n PYTHONIOENCODING: \"utf8\",\n },\n })\n )\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, true, 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"]}
@@ -17,3 +17,4 @@ export declare const hdiutilTransientExitCodes: Set<number>;
17
17
  export declare function explainHdiutilError(errorCode: number): string;
18
18
  export declare function hdiUtil(args: string[]): Promise<string | null>;
19
19
  export declare function hdiUtilWithStdin(args: string[], stdin: string): Promise<string | null>;
20
+ //# sourceMappingURL=hdiuil.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hdiuil.d.ts","sourceRoot":"","sources":["../src/hdiuil.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,yBAAyB,aAAmC,CAAA;AAEzE,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAoB7D;AAcD,wBAAsB,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAOpE;AAID,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAO5F"}
@@ -1,10 +1,4 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hdiutilTransientExitCodes = void 0;
4
- exports.explainHdiutilError = explainHdiutilError;
5
- exports.hdiUtil = hdiUtil;
6
- exports.hdiUtilWithStdin = hdiUtilWithStdin;
7
- const builder_util_1 = require("builder-util");
1
+ import { exec, log, retry, spawnAndWriteWithOutput } from "builder-util";
8
2
  /**
9
3
  * Table of hdiutil error codes that are transient and can be retried.
10
4
  * These codes are typically related to resource availability or temporary issues.
@@ -20,9 +14,8 @@ const builder_util_1 = require("builder-util");
20
14
  | `-5342` | Specified size too small | Same as above — retry if size is corrected. |
21
15
  *
22
16
  */
23
- exports.hdiutilTransientExitCodes = new Set([1, 16, 35, 256, 49153]);
24
- function explainHdiutilError(errorCode) {
25
- var _a;
17
+ export const hdiutilTransientExitCodes = new Set([1, 16, 35, 256, 49153]);
18
+ export function explainHdiutilError(errorCode) {
26
19
  const code = errorCode.toString();
27
20
  const messages = {
28
21
  "0": "Success: The hdiutil command completed without error.",
@@ -40,20 +33,19 @@ function explainHdiutilError(errorCode) {
40
33
  "-5341": "Disk image too small: hdiutil could not fit the contents. Increase the image size.",
41
34
  "-5342": "Specified size too small: Disk image creation failed due to insufficient size.",
42
35
  };
43
- return (_a = messages[code]) !== null && _a !== void 0 ? _a : `Unknown error (code ${code}): Refer to hdiutil documentation or run with -verbose for details by rerunning with env var DEBUG_DEMB=true.`;
36
+ return messages[code] ?? `Unknown error (code ${code}): Refer to hdiutil documentation or run with -verbose for details by rerunning with env var DEBUG_DEMB=true.`;
44
37
  }
45
38
  const shouldRetry = (args) => (error) => {
46
- var _a, _b, _c;
47
- const code = (_a = error.code) !== null && _a !== void 0 ? _a : -1;
48
- const stderr = ((_b = error.stderr) === null || _b === void 0 ? void 0 : _b.toString()) || "";
49
- const stdout = ((_c = error.stdout) === null || _c === void 0 ? void 0 : _c.toString()) || "";
39
+ const code = error.code ?? -1;
40
+ const stderr = error.stderr?.toString() || "";
41
+ const stdout = error.stdout?.toString() || "";
50
42
  const output = `${stdout} ${stderr}`.trim();
51
- const willRetry = exports.hdiutilTransientExitCodes.has(code.toString());
52
- builder_util_1.log.warn({ willRetry, args, code, output }, `hdiutil error: ${explainHdiutilError(code)}`);
43
+ const willRetry = hdiutilTransientExitCodes.has(code.toString());
44
+ log.warn({ willRetry, args, code, output }, `hdiutil error: ${explainHdiutilError(code)}`);
53
45
  return willRetry;
54
46
  };
55
- async function hdiUtil(args) {
56
- return (0, builder_util_1.retry)(() => (0, builder_util_1.exec)("hdiutil", args), {
47
+ export async function hdiUtil(args) {
48
+ return await retry(() => exec("hdiutil", args), {
57
49
  retries: 5,
58
50
  interval: 5000,
59
51
  backoff: 2000,
@@ -62,8 +54,8 @@ async function hdiUtil(args) {
62
54
  }
63
55
  // Like hdiUtil but pipes `stdin` to the process — used for `hdiutil attach` on
64
56
  // DMGs that have an embedded SLA so the prompt is auto-accepted without blocking.
65
- async function hdiUtilWithStdin(args, stdin) {
66
- return (0, builder_util_1.retry)(() => (0, builder_util_1.spawnAndWriteWithOutput)("hdiutil", args, stdin).then(({ stdout }) => stdout || null), {
57
+ export async function hdiUtilWithStdin(args, stdin) {
58
+ return retry(() => spawnAndWriteWithOutput("hdiutil", args, stdin).then(({ stdout }) => stdout || null), {
67
59
  retries: 5,
68
60
  interval: 5000,
69
61
  backoff: 2000,
@@ -1 +1 @@
1
- {"version":3,"file":"hdiuil.js","sourceRoot":"","sources":["../src/hdiuil.ts"],"names":[],"mappings":";;;AAmBA,kDAoBC;AAcD,0BAOC;AAID,4CAOC;AAvED,+CAAwE;AAExE;;;;;;;;;;;;;;GAcG;AACU,QAAA,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAEzE,SAAgB,mBAAmB,CAAC,SAAiB;;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAA;IACjC,MAAM,QAAQ,GAA2B;QACvC,GAAG,EAAE,uDAAuD;QAC5D,GAAG,EAAE,2GAA2G;QAChH,GAAG,EAAE,gEAAgE;QACrE,GAAG,EAAE,oGAAoG;QACzG,GAAG,EAAE,8DAA8D;QACnE,IAAI,EAAE,gFAAgF;QACtF,IAAI,EAAE,0EAA0E;QAChF,IAAI,EAAE,0EAA0E;QAChF,IAAI,EAAE,+EAA+E;QACrF,KAAK,EAAE,kEAAkE;QACzE,KAAK,EAAE,0EAA0E;QACjF,OAAO,EAAE,qEAAqE;QAC9E,OAAO,EAAE,oFAAoF;QAC7F,OAAO,EAAE,gFAAgF;KAC1F,CAAA;IAED,OAAO,MAAA,QAAQ,CAAC,IAAI,CAAC,mCAAI,uBAAuB,IAAI,+GAA+G,CAAA;AACrK,CAAC;AAED,MAAM,WAAW,GAAG,CAAC,IAAc,EAAE,EAAE,CAAC,CAAC,KAAU,EAAE,EAAE;;IACrD,MAAM,IAAI,GAAG,MAAA,KAAK,CAAC,IAAI,mCAAI,CAAC,CAAC,CAAA;IAC7B,MAAM,MAAM,GAAG,CAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,QAAQ,EAAE,KAAI,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codes that are transient and can be retried.\n * These codes are typically related to resource availability or temporary issues.\n *\n| Code | Meaning | Why Retry? |\n| ------- | -------------------------------- | ---------------------------------------------------- |\n| `1` | Generic error | Can occur from brief race conditions or temp issues. |\n| `16` | **Resource busy** | Volume is in use — wait and retry often works. |\n| `35` | **Operation timed out** | System delay or timeout — retry after a short delay. |\n| `256` | Volume in use or unmount failure | Same as 16 — usually resolves after retry. |\n| `49153` | Volume not mounted yet | Attach may be too fast — retry after delay. |\n| `-5341` | Disk image too small | Retry *after fixing* with a larger `-size`. |\n| `-5342` | Specified size too small | Same as above — retry if size is corrected. |\n *\n */\nexport const hdiutilTransientExitCodes = new Set([1, 16, 35, 256, 49153])\n\nexport function explainHdiutilError(errorCode: number): string {\n const code = errorCode.toString()\n const messages: Record<string, string> = {\n \"0\": \"Success: The hdiutil command completed without error.\",\n \"1\": \"Generic error: The operation failed, but the reason is not specific. Check command syntax or permissions.\",\n \"2\": \"No such file or directory: Check if the specified path exists.\",\n \"6\": \"Disk image to resize is not currently attached or not recognized as a valid block device by macOS.\",\n \"8\": \"Exec format error: The file might not be a valid disk image.\",\n \"16\": \"Resource busy: The volume is in use. Try closing files or processes and retry.\",\n \"22\": \"Invalid argument: One or more arguments passed to hdiutil are incorrect.\",\n \"35\": \"Operation timed out: The system was too slow or unresponsive. Try again.\",\n \"36\": \"I/O error: There was a problem reading or writing to disk. Check disk health.\",\n \"100\": \"Image-related error: The disk image may be corrupted or invalid.\",\n \"256\": \"Volume is busy or could not be unmounted. Try again after closing files.\",\n \"49153\": \"Volume not mounted yet: The image may not have been fully attached.\",\n \"-5341\": \"Disk image too small: hdiutil could not fit the contents. Increase the image size.\",\n \"-5342\": \"Specified size too small: Disk image creation failed due to insufficient size.\",\n }\n\n return messages[code] ?? `Unknown error (code ${code}): Refer to hdiutil documentation or run with -verbose for details by rerunning with env var DEBUG_DEMB=true.`\n}\n\nconst shouldRetry = (args: string[]) => (error: any) => {\n const code = error.code ?? -1\n const stderr = error.stderr?.toString() || \"\"\n const stdout = error.stdout?.toString() || \"\"\n const output = `${stdout} ${stderr}`.trim()\n\n const willRetry = hdiutilTransientExitCodes.has(code.toString())\n log.warn({ willRetry, args, code, output }, `hdiutil error: ${explainHdiutilError(code)}`)\n\n return willRetry\n}\n\nexport async function hdiUtil(args: string[]): Promise<string | null> {\n return retry(() => exec(\"hdiutil\", args), {\n retries: 5,\n interval: 5000,\n backoff: 2000,\n shouldRetry: shouldRetry(args),\n })\n}\n\n// Like hdiUtil but pipes `stdin` to the process — used for `hdiutil attach` on\n// DMGs that have an embedded SLA so the prompt is auto-accepted without blocking.\nexport async function hdiUtilWithStdin(args: string[], stdin: string): Promise<string | null> {\n return retry(() => spawnAndWriteWithOutput(\"hdiutil\", args, stdin).then(({ stdout }) => stdout || null), {\n retries: 5,\n interval: 5000,\n backoff: 2000,\n shouldRetry: shouldRetry(args),\n })\n}\n"]}
1
+ {"version":3,"file":"hdiuil.js","sourceRoot":"","sources":["../src/hdiuil.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAA;AAExE;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,IAAI,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC,CAAA;AAEzE,MAAM,UAAU,mBAAmB,CAAC,SAAiB;IACnD,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAA;IACjC,MAAM,QAAQ,GAA2B;QACvC,GAAG,EAAE,uDAAuD;QAC5D,GAAG,EAAE,2GAA2G;QAChH,GAAG,EAAE,gEAAgE;QACrE,GAAG,EAAE,oGAAoG;QACzG,GAAG,EAAE,8DAA8D;QACnE,IAAI,EAAE,gFAAgF;QACtF,IAAI,EAAE,0EAA0E;QAChF,IAAI,EAAE,0EAA0E;QAChF,IAAI,EAAE,+E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UAAU,gBAAgB,CAAC,IAAc,EAAE,KAAa;IAClE,OAAO,KAAK,CAAC,GAAG,EAAE,CAAC,uBAAuB,CAAC,SAAS,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,MAAM,IAAI,IAAI,CAAC,EAAE;QACvG,OAAO,EAAE,CAAC;QACV,QAAQ,EAAE,IAAI;QACd,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,WAAW,CAAC,IAAI,CAAC;KAC/B,CAAC,CAAA;AACJ,CAAC","sourcesContent":["import { exec, log, retry, spawnAndWriteWithOutput } from \"builder-util\"\n\n/**\n * Table of hdiutil error codes that are transient and can be retried.\n * These codes are typically related to resource availability or temporary issues.\n *\n| Code | Meaning | Why Retry? |\n| ------- | -------------------------------- | ---------------------------------------------------- |\n| `1` | Generic error | Can occur from brief race conditions or temp issues. |\n| `16` | **Resource busy** | Volume is in use — wait and retry often works. |\n| `35` | **Operation timed out** | System delay or timeout — retry after a short delay. |\n| `256` | Volume in use or unmount failure | Same as 16 — usually resolves after retry. |\n| `49153` | Volume not mounted yet | Attach may be too fast — retry after delay. |\n| `-5341` | Disk image too small | Retry *after fixing* with a larger `-size`. |\n| `-5342` | Specified size too small | Same as above — retry if size is corrected. |\n *\n */\nexport const hdiutilTransientExitCodes = new Set([1, 16, 35, 256, 49153])\n\nexport function explainHdiutilError(errorCode: number): string {\n const code = errorCode.toString()\n const messages: Record<string, string> = {\n \"0\": \"Success: The hdiutil command completed without error.\",\n \"1\": \"Generic error: The operation failed, but the reason is not specific. Check command syntax or permissions.\",\n \"2\": \"No such file or directory: Check if the specified path exists.\",\n \"6\": \"Disk image to resize is not currently attached or not recognized as a valid block device by macOS.\",\n \"8\": \"Exec format error: The file might not be a valid disk image.\",\n \"16\": \"Resource busy: The volume is in use. Try closing files or processes and retry.\",\n \"22\": \"Invalid argument: One or more arguments passed to hdiutil are incorrect.\",\n \"35\": \"Operation timed out: The system was too slow or unresponsive. Try again.\",\n \"36\": \"I/O error: There was a problem reading or writing to disk. Check disk health.\",\n \"100\": \"Image-related error: The disk image may be corrupted or invalid.\",\n \"256\": \"Volume is busy or could not be unmounted. Try again after closing files.\",\n \"49153\": \"Volume not mounted yet: The image may not have been fully attached.\",\n \"-5341\": \"Disk image too small: hdiutil could not fit the contents. Increase the image size.\",\n \"-5342\": \"Specified size too small: Disk image creation failed due to insufficient size.\",\n }\n\n return messages[code] ?? `Unknown error (code ${code}): Refer to hdiutil documentation or run with -verbose for details by rerunning with env var DEBUG_DEMB=true.`\n}\n\nconst shouldRetry = (args: string[]) => (error: any) => {\n const code = error.code ?? -1\n const stderr = error.stderr?.toString() || \"\"\n const stdout = error.stdout?.toString() || \"\"\n const output = `${stdout} ${stderr}`.trim()\n\n const willRetry = hdiutilTransientExitCodes.has(code.toString())\n log.warn({ willRetry, args, code, output }, `hdiutil error: ${explainHdiutilError(code)}`)\n\n return willRetry\n}\n\nexport async function hdiUtil(args: string[]): Promise<string | null> {\n return await retry(() => exec(\"hdiutil\", args), {\n retries: 5,\n interval: 5000,\n backoff: 2000,\n shouldRetry: shouldRetry(args),\n })\n}\n\n// Like hdiUtil but pipes `stdin` to the process — used for `hdiutil attach` on\n// DMGs that have an embedded SLA so the prompt is auto-accepted without blocking.\nexport async function hdiUtilWithStdin(args: string[], stdin: string): Promise<string | null> {\n return retry(() => spawnAndWriteWithOutput(\"hdiutil\", args, stdin).then(({ stdout }) => stdout || null), {\n retries: 5,\n interval: 5000,\n backoff: 2000,\n shouldRetry: shouldRetry(args),\n })\n}\n"]}
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=indexInternal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexInternal.d.ts","sourceRoot":"","sources":["../src/indexInternal.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // No production cross-package internals yet.
3
+ //# sourceMappingURL=indexInternal.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexInternal.js","sourceRoot":"","sources":["../src/indexInternal.ts"],"names":[],"mappings":";AAAA,6CAA6C","sourcesContent":["// No production cross-package internals yet.\n"]}
@@ -6,3 +6,4 @@ export interface LicenseButtonsFile {
6
6
  langName: string;
7
7
  }
8
8
  export declare function getLicenseButtonsFile(packager: PlatformPackager<any>): Promise<Array<LicenseButtonsFile>>;
9
+ //# sourceMappingURL=licenseButtons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"licenseButtons.d.ts","sourceRoot":"","sources":["../src/licenseButtons.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAGlD,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;CACjB;AAED,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,GAAG,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAS/G"}
@@ -0,0 +1,9 @@
1
+ import { getLicenseAssets } from "app-builder-lib/internal";
2
+ export async function getLicenseButtonsFile(packager) {
3
+ return getLicenseAssets((await packager.resourceList).filter(it => {
4
+ const name = it.toLowerCase();
5
+ // noinspection SpellCheckingInspection
6
+ return name.startsWith("licensebuttons_") && (name.endsWith(".json") || name.endsWith(".yml"));
7
+ }), packager);
8
+ }
9
+ //# sourceMappingURL=licenseButtons.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"licenseButtons.js","sourceRoot":"","sources":["../src/licenseButtons.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAA;AAS3D,MAAM,CAAC,KAAK,UAAU,qBAAqB,CAAC,QAA+B;IACzE,OAAO,gBAAgB,CACrB,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QACxC,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;QAC7B,uCAAuC;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAChG,CAAC,CAAC,EACF,QAAQ,CACT,CAAA;AACH,CAAC","sourcesContent":["import { PlatformPackager } from \"app-builder-lib\"\nimport { getLicenseAssets } from \"app-builder-lib/internal\"\n\nexport interface LicenseButtonsFile {\n file: string\n lang: string\n langWithRegion: string\n langName: string\n}\n\nexport async function getLicenseButtonsFile(packager: PlatformPackager<any>): Promise<Array<LicenseButtonsFile>> {\n return getLicenseAssets(\n (await packager.resourceList).filter(it => {\n const name = it.toLowerCase()\n // noinspection SpellCheckingInspection\n return name.startsWith(\"licensebuttons_\") && (name.endsWith(\".json\") || name.endsWith(\".yml\"))\n }),\n packager\n )\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,20 @@
1
1
  {
2
2
  "name": "dmg-builder",
3
- "version": "26.15.2",
4
- "main": "out/dmgUtil.js",
3
+ "version": "27.0.0-alpha.0",
4
+ "type": "module",
5
+ "main": "./dist/dmgUtil.js",
6
+ "exports": {
7
+ ".": {
8
+ "types": "./dist/dmgUtil.d.ts",
9
+ "import": "./dist/dmgUtil.js",
10
+ "require": "./dist/dmgUtil.js"
11
+ },
12
+ "./internal": {
13
+ "types": "./dist/indexInternal.d.ts",
14
+ "import": "./dist/indexInternal.js",
15
+ "require": "./dist/indexInternal.js"
16
+ }
17
+ },
5
18
  "author": "Vladimir Krivosheev",
6
19
  "license": "MIT",
7
20
  "repository": {
@@ -12,19 +25,27 @@
12
25
  "bugs": "https://github.com/electron-userland/electron-builder/issues",
13
26
  "homepage": "https://github.com/electron-userland/electron-builder",
14
27
  "files": [
15
- "out",
28
+ "dist",
16
29
  "templates"
17
30
  ],
31
+ "engines": {
32
+ "node": ">=22.12.0"
33
+ },
18
34
  "dependencies": {
19
- "fs-extra": "^10.1.0",
35
+ "fs-extra": "^11.3.0",
20
36
  "js-yaml": "^4.1.0",
21
- "app-builder-lib": "26.15.2",
22
- "builder-util": "26.15.0"
37
+ "builder-util-runtime": "10.0.0-alpha.0",
38
+ "app-builder-lib": "27.0.0-alpha.0",
39
+ "builder-util": "27.0.0-alpha.0"
23
40
  },
24
41
  "devDependencies": {
25
42
  "@types/fs-extra": "9.0.13",
26
43
  "@types/js-yaml": "4.0.3",
27
44
  "temp-file": "3.4.0"
28
45
  },
29
- "typings": "./out/dmg.d.ts"
46
+ "types": "./dist/dmgUtil.d.ts",
47
+ "scripts": {
48
+ "build": "tsc --build tsconfig.build.json --force",
49
+ "watch": "tsc --build tsconfig.build.json --watch"
50
+ }
30
51
  }
package/out/dmg.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"dmg.js","sourceRoot":"","sources":["../src/dmg.ts"],"names":[],"mappings":";;;AAAA,qDAAoD;AACpD,0EAAsF;AAEtF,6GAA0F;AAC1F,+CAAoG;AACpG,wDAA4D;AAC5D,2BAA4C;AAC5C,6BAA4B;AAE5B,6CAA8C;AAC9C,uCAA2D;AAC3D,qCAAkC;AAoClC,MAAa,SAAU,SAAQ,wBAAM;IAKnC,YACmB,QAAqB,EAC7B,MAAc;QAEvB,KAAK,CAAC,KAAK,CAAC,CAAA;QAHK,aAAQ,GAAR,QAAQ,CAAa;QAC7B,WAAM,GAAN,MAAM,CAAQ;QANhB,YAAO,GAAe,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;QAE9E,qBAAgB,GAAG,KAAK,CAAA;IAOxB,CAAC;IAED,KAAK,CAAC,KAAK,CAAC,OAAe,EAAE,IAAU;QACrC,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ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CAAkC,IAAI,IAAI,EAAE,CAAC;gBAC3D,aAAa,CAAC,MAAM,GAAG,MAAM,CAAA;YAC/B,CAAC;iBAAM,IAAI,QAAQ,CAAC,WAAW,KAAK,OAAO,EAAE,CAAC;gBAC5C,aAAa,CAAC,MAAM,GAAG,MAAM,CAAA;YAC/B,CAAC;iBAAM,CAAC;gBACN,aAAa,CAAC,MAAM,GAAG,QAAQ,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;YAC7E,CAAC;QACH,CAAC;QAED,IAAI,aAAa,CAAC,QAAQ,IAAI,IAAI,EAAE,CAAC;YACnC,aAAa,CAAC,QAAQ,GAAG;gBACvB;oBACE,CAAC,EAAE,GAAG;oBACN,CAAC,EAAE,GAAG;oBACN,IAAI,EAAE,OAAO;oBACb,IAAI,EAAE,MAAM;oBACZ,IAAI,EAAE,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;AArKD,8BAqKC;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 type { DmgBuildLicenseConfig } from \"./dmgLicense\"\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 size?: string | null\n shrink?: boolean\n filesystem?: string\n \"compression-level\"?: number | null\n license?: DmgBuildLicenseConfig | 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 const licenseData = await addLicenseToDmg(packager, this.options.license)\n\n if (!(await customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }))) {\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 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"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dmgLicense.js","sourceRoot":"","sources":["../src/dmgLicense.ts"],"names":[],"mappings":";;AAuBA,0CAaC;AAnCD,8DAAkE;AAClE,+CAAwD;AACxD,uCAA6C;AAC7C,qCAA2C;AAC3C,qDAAwD;AAkBjD,KAAK,UAAU,eAAe,CAAC,QAA+B,EAAE,eAAwD;IAC7H,sEAAsE;IACtE,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,mDAAmD;IACnD,IAAI,eAA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/util/license\"\nimport { InvalidConfigurationError } from \"builder-util\"\nimport { readFile, readJson } from \"fs-extra\"\nimport { CORE_SCHEMA, load } from \"js-yaml\"\nimport { getLicenseButtonsFile } from \"./licenseButtons\"\n\nexport type DmgBuildLicenseConfig = {\n \"default-language\": string\n licenses: Record<string, string>\n buttons?: Record<\n string,\n {\n language?: string\n agree?: string\n disagree?: string\n print?: string\n save?: string\n message?: string\n }\n >\n}\n\nexport async function addLicenseToDmg(packager: PlatformPackager<any>, explicitLicense?: string | Record<string, string> | null): Promise<DmgBuildLicenseConfig | null> {\n // null = explicitly disabled; skip both explicit and convention paths\n if (explicitLicense === null) {\n return null\n }\n\n // Explicit config overrides file-naming convention\n if (explicitLicense !== undefined) {\n return buildExplicitLicenseConfig(packager, explicitLicense)\n }\n\n // File-naming convention: license_LANG.{rtf,txt,html}\n return buildConventionLicenseConfig(packager)\n}\n\nasync function buildExplicitLicenseConfig(packager: PlatformPackager<any>, license: string | Record<string, string>): Promise<DmgBuildLicenseConfig | null> {\n if (typeof license === \"string\") {\n const resolvedPath = await packager.getResource(license)\n if (resolvedPath == null) {\n throw new InvalidConfigurationError(`dmg.license file not found: \"${license}\"`)\n }\n return { \"default-language\": \"en_US\", licenses: { en_US: resolvedPath } }\n }\n\n // Record<langCode, filePath>\n const licenses: Record<string, string> = {}\n for (const [lang, filePath] of Object.entries(license)) {\n const resolvedPath = await packager.getResource(filePath)\n if (resolvedPath == null) {\n throw new InvalidConfigurationError(`dmg.license file not found for language \"${lang}\": \"${filePath}\"`)\n }\n licenses[lang] = resolvedPath\n }\n\n if (Object.keys(licenses).length === 0) {\n return null\n }\n\n return {\n \"default-language\": Object.keys(licenses)[0],\n licenses,\n }\n}\n\nasync function buildConventionLicenseConfig(packager: PlatformPackager<any>): Promise<DmgBuildLicenseConfig | null> {\n const licenseFiles = await getLicenseFiles(packager)\n if (licenseFiles.length === 0) {\n return null\n }\n\n const licenseButtonFiles = await getLicenseButtonsFile(packager)\n packager.debugLogger.add(\"dmg.licenseFiles\", licenseFiles)\n packager.debugLogger.add(\"dmg.licenseButtons\", licenseButtonFiles)\n\n const licenses: Record<string, string> = {}\n for (const file of licenseFiles) {\n if (licenses[file.langWithRegion] != null) {\n throw new InvalidConfigurationError(\n `Multiple license files found for language \"${file.langWithRegion}\": \"${licenses[file.langWithRegion]}\" and \"${file.file}\". Only one license file per language is supported.`\n )\n }\n licenses[file.langWithRegion] = file.file\n }\n\n const result: DmgBuildLicenseConfig = {\n \"default-language\": licenseFiles[0].langWithRegion,\n licenses,\n }\n\n if (licenseButtonFiles.length > 0) {\n const buttons: DmgBuildLicenseConfig[\"buttons\"] = {}\n for (const button of licenseButtonFiles) {\n const filepath = button.file\n const raw: any = filepath.endsWith(\".yml\") ? load(await readFile(filepath, \"utf-8\"), { schema: CORE_SCHEMA }) : await readJson(filepath)\n\n const entry: Record<string, string> = {}\n if (raw.languageName != null) {\n entry.language = raw.languageName\n }\n if (raw.agree != null) {\n entry.agree = raw.agree\n }\n if (raw.disagree != null) {\n entry.disagree = raw.disagree\n }\n if (raw.print != null) {\n entry.print = raw.print\n }\n if (raw.save != null) {\n entry.save = raw.save\n }\n // support legacy `description` field as well as `message`\n const msg = raw.message ?? raw.description\n if (msg != null) {\n entry.message = msg\n }\n\n buttons[button.langWithRegion] = entry\n }\n result.buttons = buttons\n }\n\n return result\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"dmgUtil.js","sourceRoot":"","sources":["../src/dmgUtil.ts"],"names":[],"mappings":";;;AAeA,gDAEC;AAmCD,4CAkCC;AAED,wBASC;AAED,8CASC;AAGD,0CASC;AAWD,oCA2GC;AAED,sEAaC;AAED,sDA8BC;AA5RD,sEAA6E;AAC7E,sEAAsE;AACtE,+CAAoH;AACpH,0CAAkC;AAClC,uCAAoC;AACpC,6BAA4B;AAG5B,qCAA+E;AAE/E,6BAAiC;AAAxB,gGAAA,SAAS,OAAA;AAElB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC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mBAAI,EAAC,MAAM,EAAE,CAAC,IAAI,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC,CAAA;IAExF,IAAI,KAAK,GAAG,CAAC,CAAA;IACb,IAAI,MAAM,GAAG,CAAC,CAAA;IAEd,MAAM,EAAE,GAAG,sBAAsB,CAAA;IACjC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAEhC,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,KAAK,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;QAC3B,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,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 { downloadBuilderToolset } from \"app-builder-lib/out/util/electronGet\"\nimport { withToolsetLock } from \"app-builder-lib/out/util/toolsetLock\"\nimport { exec, executeFinally, exists, InvalidConfigurationError, isEmptyOrSpaces, log, TmpDir } from \"builder-util\"\nimport { stat } from \"fs/promises\"\nimport { writeFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { DmgBuildConfig } from \"./dmg\"\nimport type { DmgBuildLicenseConfig } from \"./dmgLicense\"\nimport { hdiUtil, hdiUtilWithStdin, 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\nasync function getDmgVendorPath(): Promise<string> {\n const customDmgbuildPath = process.env.CUSTOM_DMGBUILD_PATH?.trim()\n if (customDmgbuildPath) {\n const resolvedPath = path.resolve(customDmgbuildPath)\n let dmgbuildStat: Awaited<ReturnType<typeof stat>>\n try {\n dmgbuildStat = await stat(resolvedPath)\n } catch (e: any) {\n if (e.code === \"ENOENT\") {\n throw new Error(`CUSTOM_DMGBUILD_PATH \"${resolvedPath}\" does not exist`)\n }\n throw e\n }\n if (!dmgbuildStat.isFile()) {\n throw new Error(`CUSTOM_DMGBUILD_PATH \"${resolvedPath}\" is not a regular file`)\n }\n log.warn({ path: resolvedPath }, \"using CUSTOM_DMGBUILD_PATH override for dmgbuild binary\")\n return resolvedPath\n }\n\n const arch = process.arch === \"arm64\" ? \"arm64\" : \"x86_64\"\n // https://github.com/electron-userland/electron-builder-binaries/releases?q=dmg-builder&expanded=true\n const file = await downloadBuilderToolset({\n releaseName: \"dmg-builder@1.2.5\",\n filenameWithExt: `dmgbuild-bundle-${arch}-75c8a6c.tar.gz`,\n checksums: {\n \"dmgbuild-bundle-arm64-75c8a6c.tar.gz\": \"793404d0c96687e27d5ee40a668d498c92e36a64d6c2906df511031adb33cbeb\",\n \"dmgbuild-bundle-x86_64-75c8a6c.tar.gz\": \"1664972f9cc2d6e8fce3b63e42cd30078aff602669c5856939c4519921200433\",\n },\n })\n return path.resolve(file, \"dmgbuild\")\n}\n\nexport async function attachAndExecute(dmgPath: string, readWrite: boolean, forceDetach: 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 // Pipe \"y\\n\" to stdin so that hdiutil auto-accepts any SLA/EULA dialog\n // embedded in the DMG instead of blocking on a terminal prompt.\n const attachResult = await hdiUtilWithStdin(args, \"y\\n\")\n // Use multiline flag so ^ matches any line start — the EULA text (if any)\n // precedes the /dev/... device lines in hdiutil's stdout output.\n const deviceResult = attachResult == null ? null : /^(\\/dev\\/\\w+)/m.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 // Find the volume mount path directly from hdiutil attach output.\n // APFS images synthesize a new disk device (e.g. disk9) separate from the container disk\n // (e.g. disk8), so device-name matching via hdiutil info misses the APFS volume.\n let volumePath: string | null = null\n for (const line of attachResult!.split(\"\\n\")) {\n const match = /\\s+(\\/Volumes\\/.+?)\\s*$/.exec(line)\n if (match) {\n volumePath = match[1].trim()\n break\n }\n }\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, forceDetach))\n}\n\nexport async function detach(name: string, alwaysForce: boolean) {\n return hdiUtil([\"detach\", \"-quiet\", name]).catch(async e => {\n if (hdiutilTransientExitCodes.has(e.code) || alwaysForce) {\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 licenseData?: DmgBuildLicenseConfig | null\n}\n\nexport async function customizeDmg({ appPath, artifactPath, volumeName, specification, packager, licenseData }: 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\n const settings: DmgBuildConfig = {\n title: path.basename(volumePath),\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 size: specification.size,\n shrink: specification.shrink,\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.badgeIcon) {\n let badgeIcon = await packager.getResource(specification.badgeIcon)\n if (badgeIcon && badgeIcon.toLowerCase().endsWith(\".icon\")) {\n badgeIcon = await packager.generateIcnsFromIcon(badgeIcon)\n }\n settings[\"badge-icon\"] = badgeIcon\n } else {\n settings.icon = await packager.getResource(specification.icon)\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 = specification.background == null ? null : await transformBackgroundFileIfNeed(specification.background, packager.info.tempDirManager)\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 workspaceRoot = await packager.info.getWorkspaceRoot()\n for (const item of settings.contents ?? []) {\n if (item.type === \"file\" && item.path && path.isAbsolute(item.path)) {\n if (!item.path.startsWith(workspaceRoot + path.sep) && item.path !== appPath) {\n log.error({ contentPath: item.path }, \"dmg.contents path is outside the workspace root — verify this is intentional\")\n throw new InvalidConfigurationError(`dmg.contents path \"${item.path}\" is outside the workspace root`)\n }\n }\n }\n\n if (licenseData) {\n settings.license = licenseData\n }\n\n const settingsFile = await packager.getTempFile(\".json\")\n await writeFile(settingsFile, JSON.stringify(settings, null, 2))\n\n const dmgbuild = await getDmgVendorPath()\n await withToolsetLock(() =>\n exec(dmgbuild, [\"-s\", settingsFile, path.basename(volumePath), artifactPath], {\n env: {\n ...process.env,\n PYTHONIOENCODING: \"utf8\",\n },\n })\n )\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, true, 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"]}
@@ -1,12 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getLicenseButtonsFile = getLicenseButtonsFile;
4
- const license_1 = require("app-builder-lib/out/util/license");
5
- async function getLicenseButtonsFile(packager) {
6
- return (0, license_1.getLicenseAssets)((await packager.resourceList).filter(it => {
7
- const name = it.toLowerCase();
8
- // noinspection SpellCheckingInspection
9
- return name.startsWith("licensebuttons_") && (name.endsWith(".json") || name.endsWith(".yml"));
10
- }), packager);
11
- }
12
- //# sourceMappingURL=licenseButtons.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"licenseButtons.js","sourceRoot":"","sources":["../src/licenseButtons.ts"],"names":[],"mappings":";;AAUA,sDASC;AAlBD,8DAAmE;AAS5D,KAAK,UAAU,qBAAqB,CAAC,QAA+B;IACzE,OAAO,IAAA,0BAAgB,EACrB,CAAC,MAAM,QAAQ,CAAC,YAAY,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE;QACxC,MAAM,IAAI,GAAG,EAAE,CAAC,WAAW,EAAE,CAAA;QAC7B,uCAAuC;QACvC,OAAO,IAAI,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAA;IAChG,CAAC,CAAC,EACF,QAAQ,CACT,CAAA;AACH,CAAC","sourcesContent":["import { PlatformPackager } from \"app-builder-lib\"\nimport { getLicenseAssets } from \"app-builder-lib/out/util/license\"\n\nexport interface LicenseButtonsFile {\n file: string\n lang: string\n langWithRegion: string\n langName: string\n}\n\nexport async function getLicenseButtonsFile(packager: PlatformPackager<any>): Promise<Array<LicenseButtonsFile>> {\n return getLicenseAssets(\n (await packager.resourceList).filter(it => {\n const name = it.toLowerCase()\n // noinspection SpellCheckingInspection\n return name.startsWith(\"licensebuttons_\") && (name.endsWith(\".json\") || name.endsWith(\".yml\"))\n }),\n packager\n )\n}\n"]}