app-builder-lib 22.10.4 → 22.10.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/electron-osx-sign/index.d.ts +2 -0
- package/electron-osx-sign/index.js +10 -1
- package/electron-osx-sign/sign.js +22 -14
- package/electron-osx-sign/util.js +32 -25
- package/out/appInfo.d.ts +1 -0
- package/out/appInfo.js +3 -2
- package/out/appInfo.js.map +1 -1
- package/out/asar/asarUtil.js +4 -2
- package/out/asar/asarUtil.js.map +1 -1
- package/out/asar/unpackDetector.js +12 -12
- package/out/asar/unpackDetector.js.map +1 -1
- package/out/configuration.d.ts +3 -2
- package/out/electron/ElectronFramework.js +21 -8
- package/out/electron/ElectronFramework.js.map +1 -1
- package/out/electron/electronMac.js +1 -1
- package/out/electron/electronMac.js.map +1 -1
- package/out/macPackager.js +6 -6
- package/out/macPackager.js.map +1 -1
- package/out/options/CommonWindowsInstallerConfiguration.js +1 -1
- package/out/options/CommonWindowsInstallerConfiguration.js.map +1 -1
- package/out/options/PlatformSpecificBuildOptions.d.ts +5 -0
- package/out/options/linuxOptions.d.ts +0 -5
- package/out/packager.js +1 -1
- package/out/platformPackager.d.ts +3 -3
- package/out/platformPackager.js +8 -8
- package/out/platformPackager.js.map +1 -1
- package/out/targets/ArchiveTarget.js +4 -3
- package/out/targets/ArchiveTarget.js.map +1 -1
- package/out/targets/LinuxTargetHelper.js +1 -2
- package/out/targets/LinuxTargetHelper.js.map +1 -1
- package/out/targets/fpm.js +1 -1
- package/out/targets/fpm.js.map +1 -1
- package/out/targets/nsis/nsisLang.js +1 -1
- package/out/targets/nsis/nsisLang.js.map +1 -1
- package/out/targets/snap.js +1 -1
- package/out/targets/snap.js.map +1 -1
- package/out/util/config.js +1 -1
- package/out/util/macroExpander.js +1 -1
- package/out/util/macroExpander.js.map +1 -1
- package/package.json +30 -30
- package/scheme.json +63 -6
- package/templates/nsis/include/extractAppPackage.nsh +48 -49
|
@@ -37,3 +37,5 @@ interface FlatOptions extends BaseSignOptions {
|
|
|
37
37
|
export function flat(opts: FlatOptions, callback: (error: Error) => void): void;
|
|
38
38
|
|
|
39
39
|
export function flatAsync(opts: FlatOptions): Promise<any>;
|
|
40
|
+
|
|
41
|
+
export function getFilePathIfBinarySync(filePath: string): string | undefined
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
|
|
7
7
|
const sign = require('./sign')
|
|
8
8
|
const flat = require('./flat')
|
|
9
|
+
const util = require('./util')
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* This function is a normal callback implementation.
|
|
@@ -42,6 +43,14 @@ module.exports.flat = flat.flat
|
|
|
42
43
|
* This function is exported and returns a promise flattening the application.
|
|
43
44
|
* @function
|
|
44
45
|
* @param {Object} opts - Options.
|
|
45
|
-
* @returns {Promise} Promise.
|
|
46
|
+
* @returns {Promise} - Promise.
|
|
46
47
|
*/
|
|
47
48
|
module.exports.flatAsync = flat.flatAsync
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* This function is exported and returns a filepath if detected to be a binary (sync).
|
|
52
|
+
* @function
|
|
53
|
+
* @param {string} filepath - Filepath
|
|
54
|
+
* @returns {string | undefined} - Filepath if binary, otherwise undefined
|
|
55
|
+
*/
|
|
56
|
+
module.exports.getFilePathIfBinarySync = util.getFilePathIfBinarySync
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
'use strict'
|
|
6
6
|
|
|
7
7
|
const path = require('path')
|
|
8
|
-
|
|
8
|
+
const fs = require('fs')
|
|
9
9
|
const semver = require('semver')
|
|
10
10
|
|
|
11
11
|
const util = require('./util')
|
|
@@ -117,19 +117,9 @@ async function verifySignApplicationAsync (opts) {
|
|
|
117
117
|
* @returns {Promise} Promise.
|
|
118
118
|
*/
|
|
119
119
|
function signApplicationAsync (opts) {
|
|
120
|
-
|
|
120
|
+
const appContentsPath = getAppContentsPath(opts)
|
|
121
|
+
return walkAsync(appContentsPath)
|
|
121
122
|
.then(async function (childPaths) {
|
|
122
|
-
/**
|
|
123
|
-
* Sort the child paths by how deep they are in the file tree. Some arcane apple
|
|
124
|
-
* logic expects the deeper files to be signed first otherwise strange errors get
|
|
125
|
-
* thrown our way
|
|
126
|
-
*/
|
|
127
|
-
childPaths = childPaths.sort((a, b) => {
|
|
128
|
-
const aDepth = a.split(path.sep).length
|
|
129
|
-
const bDepth = b.split(path.sep).length
|
|
130
|
-
return bDepth - aDepth
|
|
131
|
-
})
|
|
132
|
-
|
|
133
123
|
function ignoreFilePath (opts, filePath) {
|
|
134
124
|
if (opts.ignore) {
|
|
135
125
|
return opts.ignore.some(function (ignore) {
|
|
@@ -142,7 +132,25 @@ function signApplicationAsync (opts) {
|
|
|
142
132
|
return false
|
|
143
133
|
}
|
|
144
134
|
|
|
145
|
-
if (opts.binaries)
|
|
135
|
+
if (opts.binaries) {
|
|
136
|
+
// Accept absolute paths for external binaries, else resolve relative paths from the artifact's app Contents path.
|
|
137
|
+
const userDefinedBinaries = opts.binaries.map(function (destination) { return fs.existsSync(destination) ? destination : path.resolve(appContentsPath, destination)})
|
|
138
|
+
// Insert at front to prioritize signing. We still sort by depth next
|
|
139
|
+
childPaths = userDefinedBinaries.concat(childPaths)
|
|
140
|
+
debuglog('Signing addtional user-defined binaries: ' + JSON.stringify(userDefinedBinaries, null, 1))
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Sort the child paths by how deep they are in the file tree. Some arcane apple
|
|
145
|
+
* logic expects the deeper files to be signed first otherwise strange errors get
|
|
146
|
+
* thrown our way
|
|
147
|
+
*/
|
|
148
|
+
childPaths = childPaths.sort((a, b) => {
|
|
149
|
+
const aDepth = a.split(path.sep).length
|
|
150
|
+
const bDepth = b.split(path.sep).length
|
|
151
|
+
return bDepth - aDepth
|
|
152
|
+
})
|
|
153
|
+
|
|
146
154
|
|
|
147
155
|
const args = [
|
|
148
156
|
'--sign', opts.identity.hash || opts.identity.name,
|
|
@@ -132,19 +132,33 @@ var detectElectronPlatformAsync = module.exports.detectElectronPlatformAsync = f
|
|
|
132
132
|
})
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
const isBinaryFile = require("
|
|
135
|
+
const isBinaryFile = require("istextorbinary").isBinary;
|
|
136
136
|
|
|
137
137
|
/**
|
|
138
|
-
* This function returns a promise resolving the file path if file binary.
|
|
138
|
+
* This function returns a promise resolving the file path if file binary. We check filepath extension first to reduce overhead of reading the file to a buffer for it to scan start/mid/end encoding of the file
|
|
139
139
|
* @function
|
|
140
140
|
* @param {string} filePath - Path to file.
|
|
141
141
|
* @returns {Promise} Promise resolving file path or undefined.
|
|
142
142
|
*/
|
|
143
|
-
const
|
|
144
|
-
|
|
145
|
-
.
|
|
146
|
-
|
|
147
|
-
|
|
143
|
+
const getFilePathIfBinarySync = module.exports.getFilePathIfBinarySync = function (filePath) {
|
|
144
|
+
const forceAllowedExts = [
|
|
145
|
+
'.dylib', // Dynamic library
|
|
146
|
+
'.node' // Native node addon
|
|
147
|
+
]
|
|
148
|
+
const name = path.basename(filePath)
|
|
149
|
+
const ext = path.extname(filePath)
|
|
150
|
+
|
|
151
|
+
// Sometimes .node is the base name, not as a file extension
|
|
152
|
+
// https://github.com/electron/electron-osx-sign/pull/169
|
|
153
|
+
if (forceAllowedExts.includes(ext) || forceAllowedExts.includes(name)) {
|
|
154
|
+
return filePath
|
|
155
|
+
}
|
|
156
|
+
// Still consider the file as binary if extension is empty or seems invalid
|
|
157
|
+
// https://github.com/electron-userland/electron-builder/issues/5465
|
|
158
|
+
if ((ext === '' || ext.indexOf(' ') >= 0) && name[0] !== '.') {
|
|
159
|
+
return (isBinaryFile(filePath, null) || isBinaryFile(null, fs.readFileSync(filePath))) ? filePath : undefined
|
|
160
|
+
}
|
|
161
|
+
return undefined
|
|
148
162
|
}
|
|
149
163
|
|
|
150
164
|
/**
|
|
@@ -201,24 +215,17 @@ module.exports.walkAsync = async function (dirPath) {
|
|
|
201
215
|
let filePath = path.join(dirPath, name)
|
|
202
216
|
const stat = await fs.lstat(filePath)
|
|
203
217
|
if (stat.isFile()) {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
await fs.unlink(filePath)
|
|
216
|
-
return
|
|
217
|
-
default:
|
|
218
|
-
if (path.extname(filePath).indexOf(' ') >= 0) {
|
|
219
|
-
// Still consider the file as binary if extension seems invalid
|
|
220
|
-
return getFilePathIfBinaryAsync(filePath)
|
|
221
|
-
}
|
|
218
|
+
const forceRemoveExts = [
|
|
219
|
+
'.cstemp' // Temporary file generated from past codesign
|
|
220
|
+
]
|
|
221
|
+
if (forceRemoveExts.includes(path.extname(filePath))) {
|
|
222
|
+
debuglog('Removing... ' + filePath)
|
|
223
|
+
await fs.unlink(filePath)
|
|
224
|
+
return
|
|
225
|
+
}
|
|
226
|
+
const binaryPath = getFilePathIfBinarySync(filePath)
|
|
227
|
+
if (binaryPath) {
|
|
228
|
+
return binaryPath
|
|
222
229
|
}
|
|
223
230
|
} else if (stat.isDirectory() && !stat.isSymbolicLink()) {
|
|
224
231
|
const result = await _walkAsync(filePath)
|
package/out/appInfo.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare class AppInfo {
|
|
|
11
11
|
readonly buildNumber: string | undefined;
|
|
12
12
|
readonly buildVersion: string;
|
|
13
13
|
readonly productName: string;
|
|
14
|
+
readonly sanitizedProductName: string;
|
|
14
15
|
readonly productFilename: string;
|
|
15
16
|
constructor(info: Packager, buildVersion: string | null | undefined, platformSpecificOptions?: PlatformSpecificBuildOptions | null);
|
|
16
17
|
get channel(): string | null;
|
package/out/appInfo.js
CHANGED
|
@@ -95,7 +95,8 @@ class AppInfo {
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
this.productName = info.config.productName || info.metadata.productName || info.metadata.name;
|
|
98
|
-
this.
|
|
98
|
+
this.sanitizedProductName = (0, _sanitizeFilename().default)(this.productName);
|
|
99
|
+
this.productFilename = (platformSpecificOptions === null || platformSpecificOptions === void 0 ? void 0 : platformSpecificOptions.executableName) != null ? (0, _sanitizeFilename().default)(platformSpecificOptions.executableName) : this.sanitizedProductName;
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
get channel() {
|
|
@@ -164,7 +165,7 @@ class AppInfo {
|
|
|
164
165
|
get linuxPackageName() {
|
|
165
166
|
const name = this.name; // https://github.com/electron-userland/electron-builder/issues/2963
|
|
166
167
|
|
|
167
|
-
return name.startsWith("@") ? this.
|
|
168
|
+
return name.startsWith("@") ? this.sanitizedProductName : name;
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
get sanitizedName() {
|
package/out/appInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/appInfo.ts"],"names":[],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;AAEA;AACA;AACM,SAAU,OAAV,CAAkB,CAAlB,EAA2B;AAC/B;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,sBAAV,EAAkC,UAAlC,CAAJ,CAF+B,CAG/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,IAAV,EAAgB,QAAhB,CAAJ,CAJ+B,CAK/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,4BAAV,EAAwC,UAAxC,CAAJ,CAN+B,CAO/B;;AACA,EAAA,CAAC,GAAG,CAAC,CAAC,OAAF,CAAU,IAAV,EAAgB,QAAhB,CAAJ;AACA,SAAO,CAAP;AACD;;AAEK,MAAO,OAAP,CAAc;AAYlB,EAAA,WAAA,CAA6B,IAA7B,EAA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,EAAtF;AACD;;AAED,QAAM,iBAAN,GAAuB;AACrB,UAAM,GAAG,GAAG,KAAK,IAAL,CAAU,QAAV,CAAmB,QAAnB,IAA+B,KAAK,kBAAL,CAAwB,QAAnE;;AACA,QAAI,GAAG,IAAI,IAAX,EAAiB;AACf,aAAO,GAAP;AACD;;AAED,UAAM,IAAI,GAAG,MAAM,KAAK,IAAL,CAAU,cAA7B;AACA,WAAO,IAAI,IAAI,IAAR,IAAgB,IAAI,CAAC,IAAL,KAAc,QAA9B,GAAyC,IAAzC,GAAgD,WAAW,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,OAAO,EAA1G;AACD;;AA9HiB;AAiIpB;;;;;AACM,SAAU,wBAAV,CAAmC,UAAnC,EAAqD;AACzD;AACA;AACA,SAAO,UAAU,CAAC,OAAX,CAAmB,IAAnB,EAAyB,GAAzB,EAA8B,OAA9B,CAAsC,iBAAtC,EAAyD,EAAzD,CAAP;AACD,C","sourcesContent":["import { isEmptyOrSpaces, log } from \"builder-util\"\nimport sanitizeFileName from \"sanitize-filename\"\nimport { prerelease, SemVer } from \"semver\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"./packager\"\nimport { expandMacro } from \"./util/macroExpander\"\n\n// fpm bug - rpm build --description is not escaped, well... decided to replace quite to smart quote\n// http://leancrew.com/all-this/2010/11/smart-quotes-in-javascript/\nexport function smarten(s: string): string {\n // opening singles\n s = s.replace(/(^|[-\\u2014\\s([\"])'/g, \"$1\\u2018\")\n // closing singles & apostrophes\n s = s.replace(/'/g, \"\\u2019\")\n // opening doubles\n s = s.replace(/(^|[-\\u2014/[(\\u2018\\s])\"/g, \"$1\\u201c\")\n // closing doubles\n s = s.replace(/\"/g, \"\\u201d\")\n return s\n}\n\nexport class AppInfo {\n readonly description = smarten(this.info.metadata.description || \"\")\n readonly version: string\n readonly shortVersion: string | undefined\n readonly shortVersionWindows: string | undefined\n\n readonly buildNumber: string | undefined\n readonly buildVersion: string\n\n readonly productName: string\n readonly productFilename: string\n\n constructor(private readonly info: Packager, buildVersion: string | null | undefined, private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null) {\n this.version = info.metadata.version!!\n\n if (buildVersion == null) {\n buildVersion = info.config.buildVersion\n }\n\n this.buildNumber = process.env.BUILD_NUMBER || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_BUILDNUMBER || process.env.CI_PIPELINE_IID\n if (buildVersion == null) {\n buildVersion = this.version\n if (!isEmptyOrSpaces(this.buildNumber)) {\n buildVersion += `.${this.buildNumber}`\n }\n }\n this.buildVersion = buildVersion\n\n if (info.metadata.shortVersion) {\n this.shortVersion = info.metadata.shortVersion\n }\n if (info.metadata.shortVersionWindows) {\n this.shortVersionWindows = info.metadata.shortVersionWindows\n }\n\n this.productName = info.config.productName || info.metadata.productName || info.metadata.name!!\n this.productFilename = sanitizeFileName(this.productName)\n }\n\n get channel(): string | null {\n const prereleaseInfo = prerelease(this.version)\n if (prereleaseInfo != null && prereleaseInfo.length > 0) {\n return prereleaseInfo[0]\n }\n return null\n }\n\n getVersionInWeirdWindowsForm(isSetBuildNumber = true): string {\n const parsedVersion = new SemVer(this.version)\n // https://github.com/electron-userland/electron-builder/issues/2635#issuecomment-371792272\n let buildNumber = isSetBuildNumber ? this.buildNumber : null\n if (buildNumber == null || !/^\\d+$/.test(buildNumber)) {\n buildNumber = \"0\"\n }\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}.${buildNumber}`\n }\n\n private get notNullDevMetadata() {\n return this.info.devMetadata || {}\n }\n\n get companyName(): string | null {\n const author = this.info.metadata.author || this.notNullDevMetadata.author\n return author == null ? null : author.name\n }\n\n get id(): string {\n let appId: string | null | undefined = null\n for (const options of [this.platformSpecificOptions, this.info.config]) {\n if (options != null && appId == null) {\n appId = options.appId\n }\n }\n\n const generateDefaultAppId = () => {\n const info = this.info\n return `${info.framework.defaultAppIdPrefix}${info.metadata.name!.toLowerCase()}`\n }\n\n if (appId != null && (appId === \"your.id\" || isEmptyOrSpaces(appId))) {\n const incorrectAppId = appId\n appId = generateDefaultAppId()\n log.warn(`do not use \"${incorrectAppId}\" as appId, \"${appId}\" will be used instead`)\n }\n\n return appId == null ? generateDefaultAppId() : appId\n }\n\n get macBundleIdentifier(): string {\n return filterCFBundleIdentifier(this.id)\n }\n\n get name(): string {\n return this.info.metadata.name!!\n }\n\n get linuxPackageName(): string {\n const name = this.name\n // https://github.com/electron-userland/electron-builder/issues/2963\n return name.startsWith(\"@\") ? this.productFilename : name\n }\n\n get sanitizedName(): string {\n return sanitizeFileName(this.name)\n }\n\n get updaterCacheDirName(): string {\n return this.sanitizedName.toLowerCase() + \"-updater\"\n }\n\n get copyright(): string {\n const copyright = this.info.config.copyright\n if (copyright != null) {\n return expandMacro(copyright, null, this)\n }\n return `Copyright © ${new Date().getFullYear()} ${this.companyName || this.productName}`\n }\n\n async computePackageUrl(): Promise<string | null> {\n const url = this.info.metadata.homepage || this.notNullDevMetadata.homepage\n if (url != null) {\n return url\n }\n\n const info = await this.info.repositoryInfo\n return info == null || info.type !== \"github\" ? null : `https://${info.domain}/${info.user}/${info.project}`\n }\n}\n\n/** @internal */\nexport function filterCFBundleIdentifier(identifier: string) {\n // Remove special characters and allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)\n // Apple documentation: https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070\n return identifier.replace(/ /g, \"-\").replace(/[^a-zA-Z0-9.-]/g, \"\")\n}\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["../src/appInfo.ts"],"names":[],"mappings":";;;;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA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IpB;;;;;AACM,SAAU,wBAAV,CAAmC,UAAnC,EAAqD;AACzD;AACA;AACA,SAAO,UAAU,CAAC,OAAX,CAAmB,IAAnB,EAAyB,GAAzB,EAA8B,OAA9B,CAAsC,iBAAtC,EAAyD,EAAzD,CAAP;AACD,C","sourcesContent":["import { isEmptyOrSpaces, log } from \"builder-util\"\nimport sanitizeFileName from \"sanitize-filename\"\nimport { prerelease, SemVer } from \"semver\"\nimport { PlatformSpecificBuildOptions } from \"./options/PlatformSpecificBuildOptions\"\nimport { Packager } from \"./packager\"\nimport { expandMacro } from \"./util/macroExpander\"\n\n// fpm bug - rpm build --description is not escaped, well... decided to replace quite to smart quote\n// http://leancrew.com/all-this/2010/11/smart-quotes-in-javascript/\nexport function smarten(s: string): string {\n // opening singles\n s = s.replace(/(^|[-\\u2014\\s([\"])'/g, \"$1\\u2018\")\n // closing singles & apostrophes\n s = s.replace(/'/g, \"\\u2019\")\n // opening doubles\n s = s.replace(/(^|[-\\u2014/[(\\u2018\\s])\"/g, \"$1\\u201c\")\n // closing doubles\n s = s.replace(/\"/g, \"\\u201d\")\n return s\n}\n\nexport class AppInfo {\n readonly description = smarten(this.info.metadata.description || \"\")\n readonly version: string\n readonly shortVersion: string | undefined\n readonly shortVersionWindows: string | undefined\n\n readonly buildNumber: string | undefined\n readonly buildVersion: string\n\n readonly productName: string\n readonly sanitizedProductName: string\n readonly productFilename: string\n\n constructor(private readonly info: Packager, buildVersion: string | null | undefined, private readonly platformSpecificOptions: PlatformSpecificBuildOptions | null = null) {\n this.version = info.metadata.version!!\n\n if (buildVersion == null) {\n buildVersion = info.config.buildVersion\n }\n\n this.buildNumber = process.env.BUILD_NUMBER || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_BUILDNUMBER || process.env.CI_PIPELINE_IID\n if (buildVersion == null) {\n buildVersion = this.version\n if (!isEmptyOrSpaces(this.buildNumber)) {\n buildVersion += `.${this.buildNumber}`\n }\n }\n this.buildVersion = buildVersion\n\n if (info.metadata.shortVersion) {\n this.shortVersion = info.metadata.shortVersion\n }\n if (info.metadata.shortVersionWindows) {\n this.shortVersionWindows = info.metadata.shortVersionWindows\n }\n\n this.productName = info.config.productName || info.metadata.productName || info.metadata.name!!\n this.sanitizedProductName = sanitizeFileName(this.productName)\n this.productFilename = platformSpecificOptions?.executableName != null\n ? sanitizeFileName(platformSpecificOptions.executableName)\n : this.sanitizedProductName\n }\n\n get channel(): string | null {\n const prereleaseInfo = prerelease(this.version)\n if (prereleaseInfo != null && prereleaseInfo.length > 0) {\n return prereleaseInfo[0]\n }\n return null\n }\n\n getVersionInWeirdWindowsForm(isSetBuildNumber = true): string {\n const parsedVersion = new SemVer(this.version)\n // https://github.com/electron-userland/electron-builder/issues/2635#issuecomment-371792272\n let buildNumber = isSetBuildNumber ? this.buildNumber : null\n if (buildNumber == null || !/^\\d+$/.test(buildNumber)) {\n buildNumber = \"0\"\n }\n return `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}.${buildNumber}`\n }\n\n private get notNullDevMetadata() {\n return this.info.devMetadata || {}\n }\n\n get companyName(): string | null {\n const author = this.info.metadata.author || this.notNullDevMetadata.author\n return author == null ? null : author.name\n }\n\n get id(): string {\n let appId: string | null | undefined = null\n for (const options of [this.platformSpecificOptions, this.info.config]) {\n if (options != null && appId == null) {\n appId = options.appId\n }\n }\n\n const generateDefaultAppId = () => {\n const info = this.info\n return `${info.framework.defaultAppIdPrefix}${info.metadata.name!.toLowerCase()}`\n }\n\n if (appId != null && (appId === \"your.id\" || isEmptyOrSpaces(appId))) {\n const incorrectAppId = appId\n appId = generateDefaultAppId()\n log.warn(`do not use \"${incorrectAppId}\" as appId, \"${appId}\" will be used instead`)\n }\n\n return appId == null ? generateDefaultAppId() : appId\n }\n\n get macBundleIdentifier(): string {\n return filterCFBundleIdentifier(this.id)\n }\n\n get name(): string {\n return this.info.metadata.name!!\n }\n\n get linuxPackageName(): string {\n const name = this.name\n // https://github.com/electron-userland/electron-builder/issues/2963\n return name.startsWith(\"@\") ? this.sanitizedProductName : name\n }\n\n get sanitizedName(): string {\n return sanitizeFileName(this.name)\n }\n\n get updaterCacheDirName(): string {\n return this.sanitizedName.toLowerCase() + \"-updater\"\n }\n\n get copyright(): string {\n const copyright = this.info.config.copyright\n if (copyright != null) {\n return expandMacro(copyright, null, this)\n }\n return `Copyright © ${new Date().getFullYear()} ${this.companyName || this.productName}`\n }\n\n async computePackageUrl(): Promise<string | null> {\n const url = this.info.metadata.homepage || this.notNullDevMetadata.homepage\n if (url != null) {\n return url\n }\n\n const info = await this.info.repositoryInfo\n return info == null || info.type !== \"github\" ? null : `https://${info.domain}/${info.user}/${info.project}`\n }\n}\n\n/** @internal */\nexport function filterCFBundleIdentifier(identifier: string) {\n // Remove special characters and allow only alphanumeric (A-Z,a-z,0-9), hyphen (-), and period (.)\n // Apple documentation: https://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html#//apple_ref/doc/uid/20001431-102070\n return identifier.replace(/ /g, \"-\").replace(/[^a-zA-Z0-9.-]/g, \"\")\n}\n"],"sourceRoot":""}
|
package/out/asar/asarUtil.js
CHANGED
|
@@ -274,8 +274,10 @@ class AsarPackager {
|
|
|
274
274
|
const readStream = (0, _fsExtra().createReadStream)(file);
|
|
275
275
|
readStream.on("error", reject);
|
|
276
276
|
readStream.once("end", () => w(index + 1));
|
|
277
|
-
readStream.
|
|
278
|
-
|
|
277
|
+
readStream.on("open", () => {
|
|
278
|
+
readStream.pipe(writeStream, {
|
|
279
|
+
end: false
|
|
280
|
+
});
|
|
279
281
|
});
|
|
280
282
|
}
|
|
281
283
|
};
|
package/out/asar/asarUtil.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;A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;AACD;;AAED,SAAS,cAAT,CAAwB,UAAxB,EAAgD,IAAhD,EAA0F,MAA1F,EAA0G,WAA1G,EAA+H,KAA/H,EAA2I;AACzI,MAAI,IAAI,IAAI,IAAZ,EAAkB;AAChB,WAAO,UAAU,CAAC,IAAX,CAAgB,MAAhB,EAAwB,WAAxB,EAAqC,KAArC,CAAP;AACD,GAFD,MAGK;AACH,WAAO,0BAAU,WAAV,EAAuB,IAAvB,CAAP;AACD;AACF,C","sourcesContent":["import { AsyncTaskManager, log } from \"builder-util\"\nimport { FileCopier, Filter, MAX_FILE_REQUESTS } from \"builder-util/out/fs\"\nimport { symlink } from \"fs\"\nimport { createReadStream, createWriteStream, ensureDir, readFile, Stats, writeFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { AsarOptions } from \"..\"\nimport { Packager } from \"../packager\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { getDestinationPath, ResolvedFileSet } from \"../util/appFileCopier\"\nimport { AsarFilesystem, Node } from \"./asar\"\nimport { detectUnpackedDirs } from \"./unpackDetector\"\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pickle = require(\"chromium-pickle-js\")\n\n/** @internal */\nexport class AsarPackager {\n private readonly fs = new AsarFilesystem(this.src)\n private readonly outFile: string\n private readonly unpackedDest: string\n\n constructor(private readonly src: string, private readonly destination: string, private readonly options: AsarOptions, private readonly unpackPattern: Filter | null) {\n this.outFile = path.join(destination, \"app.asar\")\n this.unpackedDest = `${this.outFile}.unpacked`\n }\n\n // sort files to minimize file change (i.e. asar file is not changed dramatically on small change)\n async pack(fileSets: Array<ResolvedFileSet>, packager: PlatformPackager<any>) {\n if (this.options.ordering != null) {\n // ordering doesn't support transformed files, but ordering is not used functionality - wait user report to fix it\n await order(fileSets[0].files, this.options.ordering, fileSets[0].src)\n }\n await ensureDir(path.dirname(this.outFile))\n const unpackedFileIndexMap = new Map<ResolvedFileSet, Set<number>>()\n for (const fileSet of fileSets) {\n unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info))\n }\n await this.writeAsarFile(fileSets, unpackedFileIndexMap)\n }\n\n private async createPackageFromFiles(fileSet: ResolvedFileSet, packager: Packager) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const unpackedDirs = new Set<string>()\n const rootForAppFilesWithoutAsar = path.join(this.destination, \"app\")\n\n if (this.options.smartUnpack !== false) {\n await detectUnpackedDirs(fileSet, unpackedDirs, this.unpackedDest, rootForAppFilesWithoutAsar)\n }\n\n const dirToCreateForUnpackedFiles = new Set<string>(unpackedDirs)\n\n const correctDirNodeUnpackedFlag = async (filePathInArchive: string, dirNode: Node) => {\n for (const dir of unpackedDirs) {\n if (filePathInArchive.length > (dir.length + 2) && filePathInArchive[dir.length] === path.sep && filePathInArchive.startsWith(dir)) {\n dirNode.unpacked = true\n unpackedDirs.add(filePathInArchive)\n // not all dirs marked as unpacked after first iteration - because node module dir can be marked as unpacked after processing node module dir content\n // e.g. node-notifier/example/advanced.js processed, but only on process vendor/terminal-notifier.app module will be marked as unpacked\n await ensureDir(path.join(this.unpackedDest, filePathInArchive))\n break\n }\n }\n }\n\n const transformedFiles = fileSet.transformedFiles\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const fileCopier = new FileCopier()\n\n let currentDirNode: Node | null = null\n let currentDirPath: string | null = null\n\n const unpackedFileIndexSet = new Set<number>()\n\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const file = fileSet.files[i]\n const stat = metadata.get(file)\n if (stat == null) {\n continue\n }\n\n const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet))\n\n if (stat.isSymbolicLink()) {\n const s = (stat as any)\n this.fs.getOrCreateNode(pathInArchive).link = s.relativeLink\n s.pathInArchive = pathInArchive\n unpackedFileIndexSet.add(i)\n continue\n }\n\n let fileParent = path.dirname(pathInArchive)\n if (fileParent === \".\") {\n fileParent = \"\"\n }\n\n if (currentDirPath !== fileParent) {\n if (fileParent.startsWith(\"..\")) {\n throw new Error(`Internal error: path must not start with \"..\": ${fileParent}`)\n }\n\n currentDirPath = fileParent\n currentDirNode = this.fs.getOrCreateNode(fileParent)\n // do not check for root\n if (fileParent !== \"\" && !currentDirNode.unpacked) {\n if (unpackedDirs.has(fileParent)) {\n currentDirNode.unpacked = true\n }\n else {\n await correctDirNodeUnpackedFlag(fileParent, currentDirNode)\n }\n }\n }\n\n const dirNode = currentDirNode!\n const newData = transformedFiles == null ? null : transformedFiles.get(i)\n const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat))\n this.fs.addFileNode(file, dirNode, newData == null ? stat.size : Buffer.byteLength(newData), isUnpacked, stat)\n if (isUnpacked) {\n if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) {\n dirToCreateForUnpackedFiles.add(fileParent)\n await ensureDir(path.join(this.unpackedDest, fileParent))\n }\n\n const unpackedFile = path.join(this.unpackedDest, pathInArchive)\n taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n\n unpackedFileIndexSet.add(i)\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n return unpackedFileIndexSet\n }\n\n private writeAsarFile(fileSets: Array<ResolvedFileSet>, unpackedFileIndexMap: Map<ResolvedFileSet, Set<number>>): Promise<any> {\n return new Promise((resolve, reject) => {\n const headerPickle = pickle.createEmpty()\n headerPickle.writeString(JSON.stringify(this.fs.header))\n const headerBuf = headerPickle.toBuffer()\n\n const sizePickle = pickle.createEmpty()\n sizePickle.writeUInt32(headerBuf.length)\n\n const sizeBuf = sizePickle.toBuffer()\n const writeStream = createWriteStream(this.outFile)\n writeStream.on(\"error\", reject)\n writeStream.on(\"close\", resolve)\n writeStream.write(sizeBuf)\n\n let fileSetIndex = 0\n\n let files = fileSets[0].files\n let metadata = fileSets[0].metadata\n let transformedFiles = fileSets[0].transformedFiles\n let unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[0])!!\n const w = (index: number) => {\n while (true) {\n if (index >= files.length) {\n if (++fileSetIndex >= fileSets.length) {\n writeStream.end()\n return\n }\n else {\n files = fileSets[fileSetIndex].files\n metadata = fileSets[fileSetIndex].metadata\n transformedFiles = fileSets[fileSetIndex].transformedFiles\n unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[fileSetIndex])!!\n index = 0\n }\n }\n\n if (!unpackedFileIndexSet.has(index)) {\n break\n }\n else {\n const stat = metadata.get(files[index])\n if (stat != null && stat.isSymbolicLink()) {\n symlink((stat as any).linkRelativeToFile, path.join(this.unpackedDest, (stat as any).pathInArchive), () => w(index + 1))\n return\n }\n }\n index++\n }\n\n const data = transformedFiles == null ? null : transformedFiles.get(index)\n const file = files[index]\n if (data !== null && data !== undefined) {\n writeStream.write(data, () => w(index + 1))\n return\n }\n\n // https://github.com/yarnpkg/yarn/pull/3539\n const stat = metadata.get(file)\n if (stat != null && stat.size < (2 * 1024 * 1024)) {\n readFile(file)\n .then(it => {\n writeStream.write(it, () => w(index + 1))\n })\n .catch(e => reject(`Cannot read file ${file}: ${e.stack || e}`))\n }\n else {\n const readStream = createReadStream(file)\n readStream.on(\"error\", reject)\n readStream.once(\"end\", () => w(index + 1))\n readStream.pipe(writeStream, {\n end: false\n })\n }\n }\n\n writeStream.write(headerBuf, () => w(0))\n })\n }\n}\n\nasync function order(filenames: Array<string>, orderingFile: string, src: string) {\n const orderingFiles = (await readFile(orderingFile, \"utf8\")).split(\"\\n\").map(line => {\n if (line.indexOf(\":\") !== -1) {\n line = line.split(\":\").pop()!\n }\n line = line.trim()\n if (line[0] === \"/\") {\n line = line.slice(1)\n }\n return line\n })\n\n const ordering: Array<string> = []\n for (const file of orderingFiles) {\n const pathComponents = file.split(path.sep)\n for (const pathComponent of pathComponents) {\n ordering.push(path.join(src, pathComponent))\n }\n }\n\n const sortedFiles: Array<string> = []\n let missing = 0\n const total = filenames.length\n for (const file of ordering) {\n if (!sortedFiles.includes(file) && filenames.includes(file)) {\n sortedFiles.push(file)\n }\n }\n for (const file of filenames) {\n if (!sortedFiles.includes(file)) {\n sortedFiles.push(file)\n missing += 1\n }\n }\n log.info({coverage: ((total - missing) / total * 100)}, \"ordering files in ASAR archive\")\n return sortedFiles\n}\n\nfunction copyFileOrData(fileCopier: FileCopier, data: string | Buffer | undefined | null, source: string, destination: string, stats: Stats) {\n if (data == null) {\n return fileCopier.copy(source, destination, stats)\n }\n else {\n return writeFile(destination, data)\n }\n}"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["../../src/asar/asarUtil.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAIA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;AAEA;AACA,MAAM,MAAM,GAAG,OAAO,CAAC,oBAAD,CAAtB;AAEA;;;AACM,MAAO,YAAP,CAAmB;AAKvB,EAAA,WAAA,CAA6B,GAA7B,EAA2D,WAA3D,EAAiG,OAAjG,EAAwI,aAAxI,EAAoK;AAAvI,SAAA,GAAA,GAAA,GAAA;AAA8B,SAAA,WAAA,GAAA,WAAA;AAAsC,SAAA,OAAA,GAAA,OAAA;AAAuC,SAAA,aAAA,GAAA,aAAA;AAJvH,SAAA,EAAA,GAAK,KAAI,sBAAJ,EAAmB,KAAK,GAAxB,CAAL;AAKf,SAAK,OAAL,GAAe,IAAI,CAAC,IAAL,CAAU,WAAV,EAAuB,UAAvB,CAAf;AACA,SAAK,YAAL,GAAoB,GAAG,KAAK,OAAO,WAAnC;AACD,GARsB,CAUvB;;;AACA,QAAM,IAAN,CAAW,Q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,IAAmB,QAAnB,EAA6B;AAC3B,QAAI,CAAC,WAAW,CAAC,QAAZ,CAAqB,IAArB,CAAD,IAA+B,SAAS,CAAC,QAAV,CAAmB,IAAnB,CAAnC,EAA6D;AAC3D,MAAA,WAAW,CAAC,IAAZ,CAAiB,IAAjB;AACD;AACF;;AACD,OAAK,MAAM,IAAX,IAAmB,SAAnB,EAA8B;AAC5B,QAAI,CAAC,WAAW,CAAC,QAAZ,CAAqB,IAArB,CAAL,EAAiC;AAC/B,MAAA,WAAW,CAAC,IAAZ,CAAiB,IAAjB;AACA,MAAA,OAAO,IAAI,CAAX;AACD;AACF;;AACD,qBAAI,IAAJ,CAAS;AAAC,IAAA,QAAQ,EAAG,CAAC,KAAK,GAAG,OAAT,IAAoB,KAApB,GAA4B;AAAxC,GAAT,EAAwD,gCAAxD;;AACA,SAAO,WAAP;AACD;;AAED,SAAS,cAAT,CAAwB,UAAxB,EAAgD,IAAhD,EAA0F,MAA1F,EAA0G,WAA1G,EAA+H,KAA/H,EAA2I;AACzI,MAAI,IAAI,IAAI,IAAZ,EAAkB;AAChB,WAAO,UAAU,CAAC,IAAX,CAAgB,MAAhB,EAAwB,WAAxB,EAAqC,KAArC,CAAP;AACD,GAFD,MAGK;AACH,WAAO,0BAAU,WAAV,EAAuB,IAAvB,CAAP;AACD;AACF,C","sourcesContent":["import { AsyncTaskManager, log } from \"builder-util\"\nimport { FileCopier, Filter, MAX_FILE_REQUESTS } from \"builder-util/out/fs\"\nimport { symlink } from \"fs\"\nimport { createReadStream, createWriteStream, ensureDir, readFile, Stats, writeFile } from \"fs-extra\"\nimport * as path from \"path\"\nimport { AsarOptions } from \"..\"\nimport { Packager } from \"../packager\"\nimport { PlatformPackager } from \"../platformPackager\"\nimport { getDestinationPath, ResolvedFileSet } from \"../util/appFileCopier\"\nimport { AsarFilesystem, Node } from \"./asar\"\nimport { detectUnpackedDirs } from \"./unpackDetector\"\n\n// eslint-disable-next-line @typescript-eslint/no-var-requires\nconst pickle = require(\"chromium-pickle-js\")\n\n/** @internal */\nexport class AsarPackager {\n private readonly fs = new AsarFilesystem(this.src)\n private readonly outFile: string\n private readonly unpackedDest: string\n\n constructor(private readonly src: string, private readonly destination: string, private readonly options: AsarOptions, private readonly unpackPattern: Filter | null) {\n this.outFile = path.join(destination, \"app.asar\")\n this.unpackedDest = `${this.outFile}.unpacked`\n }\n\n // sort files to minimize file change (i.e. asar file is not changed dramatically on small change)\n async pack(fileSets: Array<ResolvedFileSet>, packager: PlatformPackager<any>) {\n if (this.options.ordering != null) {\n // ordering doesn't support transformed files, but ordering is not used functionality - wait user report to fix it\n await order(fileSets[0].files, this.options.ordering, fileSets[0].src)\n }\n await ensureDir(path.dirname(this.outFile))\n const unpackedFileIndexMap = new Map<ResolvedFileSet, Set<number>>()\n for (const fileSet of fileSets) {\n unpackedFileIndexMap.set(fileSet, await this.createPackageFromFiles(fileSet, packager.info))\n }\n await this.writeAsarFile(fileSets, unpackedFileIndexMap)\n }\n\n private async createPackageFromFiles(fileSet: ResolvedFileSet, packager: Packager) {\n const metadata = fileSet.metadata\n // search auto unpacked dir\n const unpackedDirs = new Set<string>()\n const rootForAppFilesWithoutAsar = path.join(this.destination, \"app\")\n\n if (this.options.smartUnpack !== false) {\n await detectUnpackedDirs(fileSet, unpackedDirs, this.unpackedDest, rootForAppFilesWithoutAsar)\n }\n\n const dirToCreateForUnpackedFiles = new Set<string>(unpackedDirs)\n\n const correctDirNodeUnpackedFlag = async (filePathInArchive: string, dirNode: Node) => {\n for (const dir of unpackedDirs) {\n if (filePathInArchive.length > (dir.length + 2) && filePathInArchive[dir.length] === path.sep && filePathInArchive.startsWith(dir)) {\n dirNode.unpacked = true\n unpackedDirs.add(filePathInArchive)\n // not all dirs marked as unpacked after first iteration - because node module dir can be marked as unpacked after processing node module dir content\n // e.g. node-notifier/example/advanced.js processed, but only on process vendor/terminal-notifier.app module will be marked as unpacked\n await ensureDir(path.join(this.unpackedDest, filePathInArchive))\n break\n }\n }\n }\n\n const transformedFiles = fileSet.transformedFiles\n const taskManager = new AsyncTaskManager(packager.cancellationToken)\n const fileCopier = new FileCopier()\n\n let currentDirNode: Node | null = null\n let currentDirPath: string | null = null\n\n const unpackedFileIndexSet = new Set<number>()\n\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const file = fileSet.files[i]\n const stat = metadata.get(file)\n if (stat == null) {\n continue\n }\n\n const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet))\n\n if (stat.isSymbolicLink()) {\n const s = (stat as any)\n this.fs.getOrCreateNode(pathInArchive).link = s.relativeLink\n s.pathInArchive = pathInArchive\n unpackedFileIndexSet.add(i)\n continue\n }\n\n let fileParent = path.dirname(pathInArchive)\n if (fileParent === \".\") {\n fileParent = \"\"\n }\n\n if (currentDirPath !== fileParent) {\n if (fileParent.startsWith(\"..\")) {\n throw new Error(`Internal error: path must not start with \"..\": ${fileParent}`)\n }\n\n currentDirPath = fileParent\n currentDirNode = this.fs.getOrCreateNode(fileParent)\n // do not check for root\n if (fileParent !== \"\" && !currentDirNode.unpacked) {\n if (unpackedDirs.has(fileParent)) {\n currentDirNode.unpacked = true\n }\n else {\n await correctDirNodeUnpackedFlag(fileParent, currentDirNode)\n }\n }\n }\n\n const dirNode = currentDirNode!\n const newData = transformedFiles == null ? null : transformedFiles.get(i)\n const isUnpacked = dirNode.unpacked || (this.unpackPattern != null && this.unpackPattern(file, stat))\n this.fs.addFileNode(file, dirNode, newData == null ? stat.size : Buffer.byteLength(newData), isUnpacked, stat)\n if (isUnpacked) {\n if (!dirNode.unpacked && !dirToCreateForUnpackedFiles.has(fileParent)) {\n dirToCreateForUnpackedFiles.add(fileParent)\n await ensureDir(path.join(this.unpackedDest, fileParent))\n }\n\n const unpackedFile = path.join(this.unpackedDest, pathInArchive)\n taskManager.addTask(copyFileOrData(fileCopier, newData, file, unpackedFile, stat))\n if (taskManager.tasks.length > MAX_FILE_REQUESTS) {\n await taskManager.awaitTasks()\n }\n\n unpackedFileIndexSet.add(i)\n }\n }\n\n if (taskManager.tasks.length > 0) {\n await taskManager.awaitTasks()\n }\n\n return unpackedFileIndexSet\n }\n\n private writeAsarFile(fileSets: Array<ResolvedFileSet>, unpackedFileIndexMap: Map<ResolvedFileSet, Set<number>>): Promise<any> {\n return new Promise((resolve, reject) => {\n const headerPickle = pickle.createEmpty()\n headerPickle.writeString(JSON.stringify(this.fs.header))\n const headerBuf = headerPickle.toBuffer()\n\n const sizePickle = pickle.createEmpty()\n sizePickle.writeUInt32(headerBuf.length)\n\n const sizeBuf = sizePickle.toBuffer()\n const writeStream = createWriteStream(this.outFile)\n writeStream.on(\"error\", reject)\n writeStream.on(\"close\", resolve)\n writeStream.write(sizeBuf)\n\n let fileSetIndex = 0\n\n let files = fileSets[0].files\n let metadata = fileSets[0].metadata\n let transformedFiles = fileSets[0].transformedFiles\n let unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[0])!!\n const w = (index: number) => {\n while (true) {\n if (index >= files.length) {\n if (++fileSetIndex >= fileSets.length) {\n writeStream.end()\n return\n }\n else {\n files = fileSets[fileSetIndex].files\n metadata = fileSets[fileSetIndex].metadata\n transformedFiles = fileSets[fileSetIndex].transformedFiles\n unpackedFileIndexSet = unpackedFileIndexMap.get(fileSets[fileSetIndex])!!\n index = 0\n }\n }\n\n if (!unpackedFileIndexSet.has(index)) {\n break\n }\n else {\n const stat = metadata.get(files[index])\n if (stat != null && stat.isSymbolicLink()) {\n symlink((stat as any).linkRelativeToFile, path.join(this.unpackedDest, (stat as any).pathInArchive), () => w(index + 1))\n return\n }\n }\n index++\n }\n\n const data = transformedFiles == null ? null : transformedFiles.get(index)\n const file = files[index]\n if (data !== null && data !== undefined) {\n writeStream.write(data, () => w(index + 1))\n return\n }\n\n // https://github.com/yarnpkg/yarn/pull/3539\n const stat = metadata.get(file)\n if (stat != null && stat.size < (2 * 1024 * 1024)) {\n readFile(file)\n .then(it => {\n writeStream.write(it, () => w(index + 1))\n })\n .catch(e => reject(`Cannot read file ${file}: ${e.stack || e}`))\n }\n else {\n const readStream = createReadStream(file)\n readStream.on(\"error\", reject)\n readStream.once(\"end\", () => w(index + 1))\n readStream.on(\"open\", () => {\n readStream.pipe(writeStream, {\n end: false\n })\n })\n }\n }\n\n writeStream.write(headerBuf, () => w(0))\n })\n }\n}\n\nasync function order(filenames: Array<string>, orderingFile: string, src: string) {\n const orderingFiles = (await readFile(orderingFile, \"utf8\")).split(\"\\n\").map(line => {\n if (line.indexOf(\":\") !== -1) {\n line = line.split(\":\").pop()!\n }\n line = line.trim()\n if (line[0] === \"/\") {\n line = line.slice(1)\n }\n return line\n })\n\n const ordering: Array<string> = []\n for (const file of orderingFiles) {\n const pathComponents = file.split(path.sep)\n for (const pathComponent of pathComponents) {\n ordering.push(path.join(src, pathComponent))\n }\n }\n\n const sortedFiles: Array<string> = []\n let missing = 0\n const total = filenames.length\n for (const file of ordering) {\n if (!sortedFiles.includes(file) && filenames.includes(file)) {\n sortedFiles.push(file)\n }\n }\n for (const file of filenames) {\n if (!sortedFiles.includes(file)) {\n sortedFiles.push(file)\n missing += 1\n }\n }\n log.info({coverage: ((total - missing) / total * 100)}, \"ordering files in ASAR archive\")\n return sortedFiles\n}\n\nfunction copyFileOrData(fileCopier: FileCopier, data: string | Buffer | undefined | null, source: string, destination: string, stats: Stats) {\n if (data == null) {\n return fileCopier.copy(source, destination, stats)\n }\n else {\n return writeFile(destination, data)\n }\n}"],"sourceRoot":""}
|
|
@@ -46,16 +46,6 @@ function _fsExtra() {
|
|
|
46
46
|
return data;
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
function _isbinaryfile() {
|
|
50
|
-
const data = require("isbinaryfile");
|
|
51
|
-
|
|
52
|
-
_isbinaryfile = function () {
|
|
53
|
-
return data;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return data;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
49
|
var path = _interopRequireWildcard(require("path"));
|
|
60
50
|
|
|
61
51
|
function _fileTransformer() {
|
|
@@ -78,6 +68,16 @@ function _appFileCopier() {
|
|
|
78
68
|
return data;
|
|
79
69
|
}
|
|
80
70
|
|
|
71
|
+
function _electronOsxSign() {
|
|
72
|
+
const data = require("../../electron-osx-sign");
|
|
73
|
+
|
|
74
|
+
_electronOsxSign = function () {
|
|
75
|
+
return data;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return data;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
81
|
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
|
|
82
82
|
|
|
83
83
|
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -167,8 +167,8 @@ async function detectUnpackedDirs(fileSet, autoUnpackDirs, unpackedDest, rootFor
|
|
|
167
167
|
|
|
168
168
|
if (moduleName === "ffprobe-static" || moduleName === "ffmpeg-static" || isLibOrExe(file)) {
|
|
169
169
|
shouldUnpack = true;
|
|
170
|
-
} else if (!file.includes(".", nextSlashIndex)
|
|
171
|
-
shouldUnpack =
|
|
170
|
+
} else if (!file.includes(".", nextSlashIndex)) {
|
|
171
|
+
shouldUnpack = !!(0, _electronOsxSign().getFilePathIfBinarySync)(file);
|
|
172
172
|
}
|
|
173
173
|
|
|
174
174
|
if (!shouldUnpack) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":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AAI,KAAJ,CAAU;AAAC,QAAA,IAAI,EAAE,aAAP;AAAsB,QAAA,MAAM,EAAE;AAA9B,OAAV,EAAqE,8BAArE;AACD;;AAED,IAAA,UAAU,CAAC,aAAD,EAAgB,uBAAhB,CAAV;AACD;;AAED,MAAI,WAAW,CAAC,IAAZ,GAAmB,CAAvB,EAA0B;AACxB,UAAM,0BAAU,YAAY,GAAG,IAAI,CAAC,GAApB,GAA0B,cAApC,CAAN,CADwB,CAExB;;AACA,UAAM,uBAAgB,GAAhB,CAAoB,WAAW,CAAC,IAAZ,EAApB,EAAwC,MAAM,SAAN,IAAkB;AAC9D,YAAM,IAAI,GAAG,YAAY,GAAG,IAAI,CAAC,GAApB,GAA0B,SAAvC;AACA,YAAM,0BAAU,IAAV,CAAN;AACA,YAAM,uBAAgB,IAAhB,CAAqB,WAAW,CAAC,GAAZ,CAAgB,SAAhB,CAArB,EAAmD,EAAD,IAAY;AAClE,YAAI,WAAW,CAAC,GAAZ,CAAgB,SAAS,GAAG,IAAI,CAAC,GAAjB,GAAuB,EAAvC,CAAJ,EAAgD;AAC9C;AACA,iBAAO,IAAP;AACD,SAHD,MAIK;AACH,iBAAO,0BAAU,IAAI,GAAG,IAAI,CAAC,GAAZ,GAAkB,EAA5B,CAAP;AACD;AACF,OARK,CAAN;AASD,KAZK,EAYH,iBAZG,CAAN;AAaD;AACF,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { log } from \"builder-util\"\nimport { CONCURRENCY } from \"builder-util/out/fs\"\nimport { ensureDir } from \"fs-extra\"\nimport * as path from \"path\"\nimport { NODE_MODULES_PATTERN } from \"../fileTransformer\"\nimport { getDestinationPath, ResolvedFileSet } from \"../util/appFileCopier\"\nimport { getFilePathIfBinarySync } from \"../../electron-osx-sign\";\n\nfunction addValue(map: Map<string, Array<string>>, key: string, value: string) {\n let list = map.get(key)\n if (list == null) {\n list = [value]\n map.set(key, list)\n }\n else {\n list.push(value)\n }\n}\n\nexport function isLibOrExe(file: string): boolean {\n return file.endsWith(\".dll\") || file.endsWith(\".exe\") || file.endsWith(\".dylib\") || file.endsWith(\".so\")\n}\n\n/** @internal */\nexport async function detectUnpackedDirs(fileSet: ResolvedFileSet, autoUnpackDirs: Set<string>, unpackedDest: string, rootForAppFilesWithoutAsar: string) {\n const dirToCreate = new Map<string, Array<string>>()\n const metadata = fileSet.metadata\n\n function addParents(child: string, root: string) {\n child = path.dirname(child)\n if (autoUnpackDirs.has(child)) {\n return\n }\n\n do {\n autoUnpackDirs.add(child)\n const p = path.dirname(child)\n // create parent dir to be able to copy file later without directory existence check\n addValue(dirToCreate, p, path.basename(child))\n\n if (child === root || p === root || autoUnpackDirs.has(p)) {\n break\n }\n child = p\n }\n while (true)\n\n autoUnpackDirs.add(root)\n }\n\n for (let i = 0, n = fileSet.files.length; i < n; i++) {\n const file = fileSet.files[i]\n const index = file.lastIndexOf(NODE_MODULES_PATTERN)\n if (index < 0) {\n continue\n }\n\n let nextSlashIndex = file.indexOf(path.sep, index + NODE_MODULES_PATTERN.length + 1)\n if (nextSlashIndex < 0) {\n continue\n }\n\n if (file[index + NODE_MODULES_PATTERN.length] === \"@\") {\n nextSlashIndex = file.indexOf(path.sep, nextSlashIndex + 1)\n }\n\n if (!metadata.get(file)!.isFile()) {\n continue\n }\n\n const packageDir = file.substring(0, nextSlashIndex)\n const packageDirPathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(packageDir, fileSet))\n const pathInArchive = path.relative(rootForAppFilesWithoutAsar, getDestinationPath(file, fileSet))\n if (autoUnpackDirs.has(packageDirPathInArchive)) {\n // if package dir is unpacked, any file also unpacked\n addParents(pathInArchive, packageDirPathInArchive)\n continue\n }\n\n // https://github.com/electron-userland/electron-builder/issues/2679\n let shouldUnpack = false\n // ffprobe-static and ffmpeg-static are known packages to always unpack\n const moduleName = path.basename(packageDir)\n if (moduleName === \"ffprobe-static\" || moduleName === \"ffmpeg-static\" || isLibOrExe(file)) {\n shouldUnpack = true\n }\n else if (!file.includes(\".\", nextSlashIndex)) {\n shouldUnpack = !!getFilePathIfBinarySync(file)\n }\n\n if (!shouldUnpack) {\n continue\n }\n\n if (log.isDebugEnabled) {\n log.debug({file: pathInArchive, reason: \"contains executable code\"}, \"not packed into asar archive\")\n }\n\n addParents(pathInArchive, packageDirPathInArchive)\n }\n\n if (dirToCreate.size > 0) {\n await ensureDir(unpackedDest + path.sep + \"node_modules\")\n // child directories should be not created asynchronously - parent directories should be created first\n await BluebirdPromise.map(dirToCreate.keys(), async parentDir => {\n const base = unpackedDest + path.sep + parentDir\n await ensureDir(base)\n await BluebirdPromise.each(dirToCreate.get(parentDir)!, (it): any => {\n if (dirToCreate.has(parentDir + path.sep + it)) {\n // already created\n return null\n }\n else {\n return ensureDir(base + path.sep + it)\n }\n })\n }, CONCURRENCY)\n }\n}"],"sourceRoot":""}
|
package/out/configuration.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Arch } from "builder-util";
|
|
2
2
|
import { BeforeBuildContext, Target } from "./core";
|
|
3
3
|
import { ElectronDownloadOptions } from "./electron/ElectronFramework";
|
|
4
|
+
import { PrepareApplicationStageDirectoryOptions } from "./Framework";
|
|
4
5
|
import { AppXOptions } from "./options/AppXOptions";
|
|
5
6
|
import { AppImageOptions, DebOptions, LinuxConfiguration, LinuxTargetSpecificOptions } from "./options/linuxOptions";
|
|
6
7
|
import { DmgOptions, MacConfiguration, MasConfiguration } from "./options/macOptions";
|
|
@@ -117,9 +118,9 @@ export interface Configuration extends PlatformSpecificBuildOptions {
|
|
|
117
118
|
*/
|
|
118
119
|
readonly electronCompile?: boolean;
|
|
119
120
|
/**
|
|
120
|
-
*
|
|
121
|
+
* Returns the path to custom Electron build (e.g. `~/electron/out/R`). Zip files must follow the pattern `electron-v${version}-${platformName}-${arch}.zip`, otherwise it will be assumed to be an unpacked Electron app directory
|
|
121
122
|
*/
|
|
122
|
-
readonly electronDist?: string;
|
|
123
|
+
readonly electronDist?: string | ((options: PrepareApplicationStageDirectoryOptions) => string);
|
|
123
124
|
/**
|
|
124
125
|
* The [electron-download](https://github.com/electron-userland/electron-download#usage) options.
|
|
125
126
|
*/
|
|
@@ -218,15 +218,24 @@ async function createElectronFrameworkSupport(configuration, packager) {
|
|
|
218
218
|
}
|
|
219
219
|
|
|
220
220
|
async function unpack(prepareOptions, options, distMacOsAppName) {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
221
|
+
const {
|
|
222
|
+
packager,
|
|
223
|
+
appOutDir,
|
|
224
|
+
platformName
|
|
225
|
+
} = prepareOptions;
|
|
226
|
+
const electronDist = packager.config.electronDist;
|
|
227
|
+
let dist = typeof electronDist === 'function' ? electronDist(prepareOptions) : electronDist;
|
|
224
228
|
|
|
225
229
|
if (dist != null) {
|
|
226
|
-
const zipFile = `electron-v${options.version}-${
|
|
227
|
-
const resolvedDist = path.resolve(packager.projectDir, dist);
|
|
230
|
+
const zipFile = `electron-v${options.version}-${platformName}-${options.arch}.zip`;
|
|
231
|
+
const resolvedDist = path.isAbsolute(dist) ? dist : path.resolve(packager.projectDir, dist);
|
|
228
232
|
|
|
229
233
|
if ((await (0, _fs().statOrNull)(path.join(resolvedDist, zipFile))) != null) {
|
|
234
|
+
_builderUtil().log.debug({
|
|
235
|
+
resolvedDist,
|
|
236
|
+
zipFile
|
|
237
|
+
}, "Resolved electronDist");
|
|
238
|
+
|
|
230
239
|
options.cache = resolvedDist;
|
|
231
240
|
dist = null;
|
|
232
241
|
}
|
|
@@ -239,18 +248,22 @@ async function unpack(prepareOptions, options, distMacOsAppName) {
|
|
|
239
248
|
return;
|
|
240
249
|
}
|
|
241
250
|
|
|
242
|
-
|
|
251
|
+
_builderUtil().log.info({
|
|
252
|
+
zipPath: options.cache
|
|
253
|
+
}, "Unpacking electron zip");
|
|
254
|
+
|
|
255
|
+
await (0, _builderUtil().executeAppBuilder)(["unpack-electron", "--configuration", JSON.stringify([options]), "--output", appOutDir, "--distMacOsAppName", distMacOsAppName]);
|
|
243
256
|
} else {
|
|
244
257
|
isFullCleanup = true;
|
|
245
258
|
const source = packager.getElectronSrcDir(dist);
|
|
246
|
-
const destination = packager.getElectronDestinationDir(
|
|
259
|
+
const destination = packager.getElectronDestinationDir(appOutDir);
|
|
247
260
|
|
|
248
261
|
_builderUtil().log.info({
|
|
249
262
|
source,
|
|
250
263
|
destination
|
|
251
264
|
}, "copying Electron");
|
|
252
265
|
|
|
253
|
-
await (0, _fsExtra().emptyDir)(
|
|
266
|
+
await (0, _fsExtra().emptyDir)(appOutDir);
|
|
254
267
|
await (0, _fs().copyDir)(source, destination, {
|
|
255
268
|
isUseHardLink: _fs().DO_NOT_USE_HARD_LINKS
|
|
256
269
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;AA+BA,SAAS,kBAAT,CAA4B,IAA5B,EAAiD,QAAjD,EAAiF,IAAjF,EAA+F,eAA/F,EAAsH;AACpH,SAAO;AACL,IAAA,QADK;AAEL,IAAA,IAFK;AAGL,IAAA,OAAO,EAAE,eAHJ;AAIL,OAAG,IAAI,CAAC;AAJH,GAAP;AAMD;;AAED,eAAe,oBAAf,CAAoC,OAApC,EA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,IAAI,CAAC,IAAL,CAAU,aAAV,EAAyB,kBAAzB,CAAf,CAAH,GAAkE,OAAO,CAAC,OAAR,EAD9D,EAEjB,aAAa,GAAG,0BAAe,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,SAAf,CAAf,CAAH,GAA+C,OAAO,CAAC,OAAR,EAF3C,EAGjB,KAAK,GAAG,OAAO,CAAC,OAAR,EAAH,GAAuB,uBAAO,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,SAAf,CAAP,EAAkC,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,sBAAf,CAAlC,EAA0E,KAA1E,CAAgF,MAAK,CAAe,CAApG,CAHX,CAAZ,CAAP;AAKD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { asArray, executeAppBuilder, log } from \"builder-util\"\nimport { CONCURRENCY, copyDir, DO_NOT_USE_HARD_LINKS, statOrNull, unlinkIfExists } from \"builder-util/out/fs\"\nimport { emptyDir, readdir, remove, rename } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport MacPackager from \"../macPackager\"\nimport { isSafeToUnpackElectronOnRemoteBuildServer } from \"../platformPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const packager = options.packager\n const appOutDir = options.appOutDir\n if (packager.platform === Platform.LINUX) {\n if (!isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n const linuxPackager = (packager as LinuxPackager)\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, \"electron\"), executable)\n }\n }\n else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, \"electron.exe\"), executable)\n }\n else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n\n const wantedLanguages = asArray(packager.platformSpecificBuildOptions.electronLanguages)\n if (wantedLanguages.length === 0) {\n return\n }\n\n // noinspection SpellCheckingInspection\n const langFileExt = \".lproj\"\n const resourcesDir = packager.getResourcesDir(appOutDir)\n await BluebirdPromise.map(readdir(resourcesDir), file => {\n if (!file.endsWith(langFileExt)) {\n return\n }\n\n const language = file.substring(0, file.length - langFileExt.length)\n if (!wantedLanguages.includes(language)) {\n return remove(path.join(resourcesDir, file))\n }\n return\n }, CONCURRENCY)\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(readonly name: string, readonly version: string, readonly distMacOsAppName: string) {\n }\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n }\n else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n return unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName)\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n }\n else {\n version = await computeElectronVersion(packager.projectDir, new Lazy(() => Promise.resolve(packager.metadata)))\n }\n configuration.electronVersion = version\n }\n\n return new ElectronFramework(\"electron\", version, \"Electron.app\")\n}\n\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, options: ElectronDownloadOptions, distMacOsAppName: string) {\n const packager = prepareOptions.packager\n const out = prepareOptions.appOutDir\n\n let dist: string | null | undefined = packager.config.electronDist\n if (dist != null) {\n const zipFile = `electron-v${options.version}-${prepareOptions.platformName}-${options.arch}.zip`\n const resolvedDist = path.resolve(packager.projectDir, dist)\n if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {\n options.cache = resolvedDist\n dist = null\n }\n }\n\n let isFullCleanup = false\n if (dist == null) {\n if (isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n return\n }\n\n await executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", out, \"--distMacOsAppName\", distMacOsAppName])\n }\n else {\n isFullCleanup = true\n const source = packager.getElectronSrcDir(dist)\n const destination = packager.getElectronDestinationDir(out)\n log.info({source, destination}, \"copying Electron\")\n await emptyDir(out)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n }\n\n await cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac ? Promise.resolve() : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {/* ignore */}),\n ])\n}\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["../../src/electron/ElectronFramework.ts"],"names":[],"mappings":";;;;;;;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAGA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;AACA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;;;;;;;;AA+BA,SAAS,kBAAT,CAA4B,IAA5B,EAAiD,QAAjD,EAAiF,IAAjF,EAA+F,eAA/F,EAAsH;AACpH,SAAO;AACL,IAAA,QADK;AAEL,IAAA,IAFK;AAGL,IAA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BAAT,CAA4B,cAA5B,EAAqF,gBAArF,EAA+G,aAA/G,EAAqI;AACnI,QAAM,GAAG,GAAG,cAAc,CAAC,SAA3B;;AACA,QAAM,KAAK,GAAG,cAAc,CAAC,QAAf,CAAwB,QAAxB,KAAqC,kBAAS,GAA5D;;AACA,QAAM,aAAa,GAAG,KAAK,GAAG,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,gBAAf,EAAiC,UAAjC,EAA6C,WAA7C,CAAH,GAA+D,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,WAAf,CAA1F;AAEA,SAAO,OAAO,CAAC,GAAR,CAAY,CACjB,aAAa,GAAG,0BAAe,IAAI,CAAC,IAAL,CAAU,aAAV,EAAyB,kBAAzB,CAAf,CAAH,GAAkE,OAAO,CAAC,OAAR,EAD9D,EAEjB,aAAa,GAAG,0BAAe,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,SAAf,CAAf,CAAH,GAA+C,OAAO,CAAC,OAAR,EAF3C,EAGjB,KAAK,GAAG,OAAO,CAAC,OAAR,EAAH,GAAuB,uBAAO,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,SAAf,CAAP,EAAkC,IAAI,CAAC,IAAL,CAAU,GAAV,EAAe,sBAAf,CAAlC,EAA0E,KAA1E,CAAgF,MAAK,CAAe,CAApG,CAHX,CAAZ,CAAP;AAKD,C","sourcesContent":["import BluebirdPromise from \"bluebird-lst\"\nimport { asArray, executeAppBuilder, log } from \"builder-util\"\nimport { CONCURRENCY, copyDir, DO_NOT_USE_HARD_LINKS, statOrNull, unlinkIfExists } from \"builder-util/out/fs\"\nimport { emptyDir, readdir, remove, rename } from \"fs-extra\"\nimport { Lazy } from \"lazy-val\"\nimport * as path from \"path\"\nimport { Configuration } from \"../configuration\"\nimport { BeforeCopyExtraFilesOptions, Framework, PrepareApplicationStageDirectoryOptions } from \"../Framework\"\nimport { Packager, Platform } from \"../index\"\nimport { LinuxPackager } from \"../linuxPackager\"\nimport MacPackager from \"../macPackager\"\nimport { isSafeToUnpackElectronOnRemoteBuildServer } from \"../platformPackager\"\nimport { getTemplatePath } from \"../util/pathManager\"\nimport { createMacApp } from \"./electronMac\"\nimport { computeElectronVersion, getElectronVersionFromInstalled } from \"./electronVersion\"\n\nexport type ElectronPlatformName = \"darwin\" | \"linux\" | \"win32\" | \"mas\"\n\nexport interface ElectronDownloadOptions {\n // https://github.com/electron-userland/electron-builder/issues/3077\n // must be optional\n version?: string\n\n /**\n * The [cache location](https://github.com/electron-userland/electron-download#cache-location).\n */\n cache?: string | null\n\n /**\n * The mirror.\n */\n mirror?: string | null\n\n /** @private */\n customDir?: string | null\n /** @private */\n customFilename?: string | null\n\n strictSSL?: boolean\n isVerifyChecksum?: boolean\n\n platform?: ElectronPlatformName\n arch?: string\n}\n\nfunction createDownloadOpts(opts: Configuration, platform: ElectronPlatformName, arch: string, electronVersion: string): ElectronDownloadOptions {\n return {\n platform,\n arch,\n version: electronVersion,\n ...opts.electronDownload,\n }\n}\n\nasync function beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n const packager = options.packager\n const appOutDir = options.appOutDir\n if (packager.platform === Platform.LINUX) {\n if (!isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n const linuxPackager = (packager as LinuxPackager)\n const executable = path.join(appOutDir, linuxPackager.executableName)\n await rename(path.join(appOutDir, \"electron\"), executable)\n }\n }\n else if (packager.platform === Platform.WINDOWS) {\n const executable = path.join(appOutDir, `${packager.appInfo.productFilename}.exe`)\n await rename(path.join(appOutDir, \"electron.exe\"), executable)\n }\n else {\n await createMacApp(packager as MacPackager, appOutDir, options.asarIntegrity, (options.platformName as ElectronPlatformName) === \"mas\")\n\n const wantedLanguages = asArray(packager.platformSpecificBuildOptions.electronLanguages)\n if (wantedLanguages.length === 0) {\n return\n }\n\n // noinspection SpellCheckingInspection\n const langFileExt = \".lproj\"\n const resourcesDir = packager.getResourcesDir(appOutDir)\n await BluebirdPromise.map(readdir(resourcesDir), file => {\n if (!file.endsWith(langFileExt)) {\n return\n }\n\n const language = file.substring(0, file.length - langFileExt.length)\n if (!wantedLanguages.includes(language)) {\n return remove(path.join(resourcesDir, file))\n }\n return\n }, CONCURRENCY)\n }\n}\n\nclass ElectronFramework implements Framework {\n // noinspection JSUnusedGlobalSymbols\n readonly macOsDefaultTargets = [\"zip\", \"dmg\"]\n // noinspection JSUnusedGlobalSymbols\n readonly defaultAppIdPrefix = \"com.electron.\"\n // noinspection JSUnusedGlobalSymbols\n readonly isCopyElevateHelper = true\n // noinspection JSUnusedGlobalSymbols\n readonly isNpmRebuildRequired = true\n\n constructor(readonly name: string, readonly version: string, readonly distMacOsAppName: string) {\n }\n\n getDefaultIcon(platform: Platform) {\n if (platform === Platform.LINUX) {\n return path.join(getTemplatePath(\"icons\"), \"electron-linux\")\n }\n else {\n // default icon is embedded into app skeleton\n return null\n }\n }\n\n prepareApplicationStageDirectory(options: PrepareApplicationStageDirectoryOptions) {\n return unpack(options, createDownloadOpts(options.packager.config, options.platformName, options.arch, this.version), this.distMacOsAppName)\n }\n\n beforeCopyExtraFiles(options: BeforeCopyExtraFilesOptions) {\n return beforeCopyExtraFiles(options)\n }\n}\n\nexport async function createElectronFrameworkSupport(configuration: Configuration, packager: Packager): Promise<Framework> {\n let version = configuration.electronVersion\n if (version == null) {\n // for prepacked app asar no dev deps in the app.asar\n if (packager.isPrepackedAppAsar) {\n version = await getElectronVersionFromInstalled(packager.projectDir)\n if (version == null) {\n throw new Error(`Cannot compute electron version for prepacked asar`)\n }\n }\n else {\n version = await computeElectronVersion(packager.projectDir, new Lazy(() => Promise.resolve(packager.metadata)))\n }\n configuration.electronVersion = version\n }\n\n return new ElectronFramework(\"electron\", version, \"Electron.app\")\n}\n\nasync function unpack(prepareOptions: PrepareApplicationStageDirectoryOptions, options: ElectronDownloadOptions, distMacOsAppName: string) {\n const { packager, appOutDir, platformName } = prepareOptions\n\n const electronDist = packager.config.electronDist\n let dist: string | undefined | null = (typeof electronDist === 'function') ? electronDist(prepareOptions) : electronDist\n if (dist != null) {\n const zipFile = `electron-v${options.version}-${platformName}-${options.arch}.zip`\n const resolvedDist = path.isAbsolute(dist) ? dist : path.resolve(packager.projectDir, dist)\n if ((await statOrNull(path.join(resolvedDist, zipFile))) != null) {\n log.debug({ resolvedDist, zipFile }, \"Resolved electronDist\")\n options.cache = resolvedDist\n dist = null\n }\n }\n\n let isFullCleanup = false\n if (dist == null) {\n if (isSafeToUnpackElectronOnRemoteBuildServer(packager)) {\n return\n }\n log.info({ zipPath: options.cache }, \"Unpacking electron zip\")\n await executeAppBuilder([\"unpack-electron\", \"--configuration\", JSON.stringify([options]), \"--output\", appOutDir, \"--distMacOsAppName\", distMacOsAppName])\n }\n else {\n isFullCleanup = true\n const source = packager.getElectronSrcDir(dist)\n const destination = packager.getElectronDestinationDir(appOutDir)\n log.info({source, destination}, \"copying Electron\")\n await emptyDir(appOutDir)\n await copyDir(source, destination, {\n isUseHardLink: DO_NOT_USE_HARD_LINKS,\n })\n }\n\n await cleanupAfterUnpack(prepareOptions, distMacOsAppName, isFullCleanup)\n}\n\nfunction cleanupAfterUnpack(prepareOptions: PrepareApplicationStageDirectoryOptions, distMacOsAppName: string, isFullCleanup: boolean) {\n const out = prepareOptions.appOutDir\n const isMac = prepareOptions.packager.platform === Platform.MAC\n const resourcesPath = isMac ? path.join(out, distMacOsAppName, \"Contents\", \"Resources\") : path.join(out, \"resources\")\n\n return Promise.all([\n isFullCleanup ? unlinkIfExists(path.join(resourcesPath, \"default_app.asar\")) : Promise.resolve(),\n isFullCleanup ? unlinkIfExists(path.join(out, \"version\")) : Promise.resolve(),\n isMac ? Promise.resolve() : rename(path.join(out, \"LICENSE\"), path.join(out, \"LICENSE.electron.txt\")).catch(() => {/* ignore */}),\n ])\n}\n"],"sourceRoot":""}
|
|
@@ -192,7 +192,7 @@ async function createMacApp(packager, appOutDir, asarIntegrity, isMas) {
|
|
|
192
192
|
function configureHelper(helper, postfix, userProvidedBundleIdentifier) {
|
|
193
193
|
helper.CFBundleExecutable = `${appFilename} Helper ${postfix}`;
|
|
194
194
|
helper.CFBundleDisplayName = `${appInfo.productName} Helper ${postfix}`;
|
|
195
|
-
helper.CFBundleIdentifier = userProvidedBundleIdentifier ? (0, _appInfo().filterCFBundleIdentifier)(userProvidedBundleIdentifier) : `${helperBundleIdentifier}.${postfix
|
|
195
|
+
helper.CFBundleIdentifier = userProvidedBundleIdentifier ? (0, _appInfo().filterCFBundleIdentifier)(userProvidedBundleIdentifier) : (0, _appInfo().filterCFBundleIdentifier)(`${helperBundleIdentifier}.${postfix}`);
|
|
196
196
|
helper.CFBundleVersion = appPlist.CFBundleVersion;
|
|
197
197
|
}
|
|
198
198
|
|