Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private computeVersionKey() {
// Error: invalid VIProductVersion format, should be X.X.X.X
// so, we must strip beta
const localeId = this.options.language || "1033"
const appInfo = this.packager.appInfo
const versionKey = [
`/LANG=${localeId} ProductName "${appInfo.productName}"`,
`/LANG=${localeId} ProductVersion "${appInfo.version}"`,
`/LANG=${localeId} LegalCopyright "${appInfo.copyright}"`,
`/LANG=${localeId} FileDescription "${appInfo.description}"`,
`/LANG=${localeId} FileVersion "${appInfo.buildVersion}"`,
]
use(this.packager.platformSpecificBuildOptions.legalTrademarks, it => versionKey.push(`/LANG=${localeId} LegalTrademarks "${it}"`))
use(appInfo.companyName, it => versionKey.push(`/LANG=${localeId} CompanyName "${it}"`))
return versionKey
}
export async function installAppDeps(args: any) {
try {
log.info({version: PACKAGE_VERSION}, "electron-builder")
}
catch (e) {
// error in dev mode without babel
if (!(e instanceof ReferenceError)) {
throw e
}
}
const projectDir = process.cwd()
const packageMetadata = new Lazy(() => orNullIfFileNotExist(readJson(path.join(projectDir, "package.json"))))
const config = await getConfig(projectDir, null, null, packageMetadata)
const results = await Promise.all([
computeDefaultAppDirectory(projectDir, use(config.directories, it => it!.app)),
getElectronVersion(projectDir, config, packageMetadata),
])
// if two package.json — force full install (user wants to install/update app deps in addition to dev)
await installOrRebuild(config, results[0], {
frameworkInfo: {version: results[1], useCustomDist: true},
platform: args.platform,
arch: args.arch,
productionDeps: createLazyProductionDeps(results[0], null),
}, results[0] !== projectDir)
}
}
if (options.overwriteAction != null) {
packageInfo.BundleOverwriteAction = options.overwriteAction
}
await executeAppBuilderAndWriteJson(["encode-plist"], {[propertyListOutputFile]: plistInfo})
}
// now build the package
const args = [
"--root", rootPath,
"--component-plist", propertyListOutputFile,
]
use(this.options.installLocation || "/Applications", it => args.push("--install-location", it!))
if (options.scripts != null) {
args.push("--scripts", path.resolve(this.packager.info.buildResourcesDir, options.scripts))
}
else if (options.scripts !== null) {
const dir = path.join(this.packager.info.buildResourcesDir, "pkg-scripts")
const stat = await statOrNull(dir)
if (stat != null && stat.isDirectory()) {
args.push("--scripts", dir)
}
}
args.push(packageOutputFile)
await exec("pkgbuild", args)
}
}
if (depends != null) {
if (Array.isArray(depends)) {
fpmConfiguration.customDepends = depends
}
else {
// noinspection SuspiciousTypeOfGuard
if (typeof depends === "string") {
fpmConfiguration.customDepends = [depends as string]
}
else {
throw new Error(`depends must be Array or String, but specified as: ${depends}`)
}
}
}
use(packager.info.metadata.license, it => args.push("--license", it!))
use(appInfo.buildNumber, it => args.push("--iteration", it!))
use(options.fpm, it => args.push(...it as any))
args.push(`${appOutDir}/=${installPrefix}/${appInfo.productFilename}`)
for (const icon of (await this.helper.icons)) {
const extWithDot = path.extname(icon.file)
const sizeName = extWithDot === ".svg" ? "scalable" : `${icon.size}x${icon.size}`
args.push(`${icon.file}=/usr/share/icons/hicolor/${sizeName}/apps/${packager.executableName}${extWithDot}`)
}
const mimeTypeFilePath = await this.helper.mimeTypeFiles
if (mimeTypeFilePath != null) {
args.push(`${mimeTypeFilePath}=/usr/share/mime/packages/${packager.executableName}.xml`)
}
"--set-product-version", appInfo.getVersionInWeirdWindowsForm(),
]
if (internalName != null) {
args.push(
"--set-version-string", "InternalName", internalName,
"--set-version-string", "OriginalFilename", "",
)
}
if (requestedExecutionLevel != null && requestedExecutionLevel !== "asInvoker") {
args.push("--set-requested-execution-level", requestedExecutionLevel)
}
use(appInfo.companyName, it => args.push("--set-version-string", "CompanyName", it!))
use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it!))
const iconPath = await this.getIconPath()
use(iconPath, it => {
files.push(it)
args.push("--set-icon", it)
})
const config = this.config
const cscInfoForCacheDigest = !isBuildCacheEnabled() || isCI || config.electronDist != null ? null : await this.cscInfo.value
let buildCacheManager: BuildCacheManager | null = null
// resources editing doesn't change executable for the same input and executed quickly - no need to complicate
if (cscInfoForCacheDigest != null) {
const cscFile = (cscInfoForCacheDigest as FileCodeSigningInfo).file
if (cscFile != null) {
files.push(cscFile)
}
"--set-file-version", appInfo.buildVersion,
"--set-product-version", appInfo.getVersionInWeirdWindowsForm(),
]
if (internalName != null) {
args.push(
"--set-version-string", "InternalName", internalName,
"--set-version-string", "OriginalFilename", "",
)
}
if (requestedExecutionLevel != null && requestedExecutionLevel !== "asInvoker") {
args.push("--set-requested-execution-level", requestedExecutionLevel)
}
use(appInfo.companyName, it => args.push("--set-version-string", "CompanyName", it!))
use(this.platformSpecificBuildOptions.legalTrademarks, it => args.push("--set-version-string", "LegalTrademarks", it!))
const iconPath = await this.getIconPath()
use(iconPath, it => {
files.push(it)
args.push("--set-icon", it)
})
const config = this.config
const cscInfoForCacheDigest = !isBuildCacheEnabled() || isCI || config.electronDist != null ? null : await this.cscInfo.value
let buildCacheManager: BuildCacheManager | null = null
// resources editing doesn't change executable for the same input and executed quickly - no need to complicate
if (cscInfoForCacheDigest != null) {
const cscFile = (cscInfoForCacheDigest as FileCodeSigningInfo).file
if (cscFile != null) {
files.push(cscFile)
}