Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function computeDmgEntries(specification: DmgOptions, volumePath: string, packager: MacPackager, asyncTaskManager: AsyncTaskManager): Promise {
let result = ""
for (const c of specification.contents!!) {
if (c.path != null && c.path.endsWith(".app") && c.type !== "link") {
log.warn({path: c.path, reason: "actual path to app will be used instead"}, "do not specify path for application")
}
const entryPath = c.path || `${packager.appInfo.productFilename}.app`
const entryName = c.name || path.basename(entryPath)
if (result.length !== 0) {
result += ",\n"
}
result += `'${entryName}': (${c.x}, ${c.y})`
if (c.type === "link") {
asyncTaskManager.addTask(exec("ln", ["-s", `/${entryPath.startsWith("/") ? entryPath.substring(1) : entryPath}`, `${volumePath}/${entryName}`]))
}
// use c.path instead of entryPath (to be sure that this logic is not applied to .app bundle) https://github.com/electron-userland/electron-builder/issues/2147
else if (!isEmptyOrSpaces(c.path) && (c.type === "file" || c.type === "dir")) {
const source = await packager.getResource(c.path)
if (source == null) {
desktopMeta.MimeType = mimeTypes.join(";") + ";"
}
let category = targetSpecificOptions.category
if (isEmptyOrSpaces(category)) {
const macCategory = (packager.config.mac || {}).category
if (macCategory != null) {
category = macToLinuxCategory[macCategory]
}
if (category == null) {
// https://github.com/develar/onshape-desktop-shell/issues/48
if (macCategory != null) {
log.warn({macCategory}, "cannot map macOS category to Linux. If possible mapping is known for you, please file issue to add it.")
}
log.warn({
reason: "linux.category is not set and cannot map from macOS",
docs: "https://www.electron.build/configuration/linux",
}, "application Linux category is set to default \"Utility\"")
category = "Utility"
}
}
desktopMeta.Categories = `${category}${category.endsWith(";") ? "" : ";"}`
let data = `[Desktop Entry]`
for (const name of Object.keys(desktopMeta)) {
data += `\n${name}=${desktopMeta[name]}`
}
data += "\n"
return data
}
}
if (mimeTypes.length !== 0) {
desktopMeta.MimeType = mimeTypes.join(";") + ";"
}
let category = targetSpecificOptions.category
if (isEmptyOrSpaces(category)) {
const macCategory = (packager.config.mac || {}).category
if (macCategory != null) {
category = macToLinuxCategory[macCategory]
}
if (category == null) {
// https://github.com/develar/onshape-desktop-shell/issues/48
if (macCategory != null) {
log.warn({macCategory}, "cannot map macOS category to Linux. If possible mapping is known for you, please file issue to add it.")
}
log.warn({
reason: "linux.category is not set and cannot map from macOS",
docs: "https://www.electron.build/configuration/linux",
}, "application Linux category is set to default \"Utility\"")
category = "Utility"
}
}
desktopMeta.Categories = `${category}${category.endsWith(";") ? "" : ";"}`
let data = `[Desktop Entry]`
for (const name of Object.keys(desktopMeta)) {
data += `\n${name}=${desktopMeta[name]}`
}
data += "\n"
return data
const helperEHPlist = plistContent[2]
const helperNPPlist = plistContent[3]
const helperRendererPlist = plistContent[4]
const helperPluginPlist = plistContent[5]
const helperGPUPlist = plistContent[6]
const helperLoginPlist = plistContent[7]
// if an extend-info file was supplied, copy its contents in first
if (plistContent[8] != null) {
Object.assign(appPlist, plistContent[8])
}
const buildMetadata = packager.config!!
const oldHelperBundleId = (buildMetadata as any)["helper-bundle-id"]
if (oldHelperBundleId != null) {
log.warn("build.helper-bundle-id is deprecated, please set as build.mac.helperBundleId")
}
const helperBundleIdentifier = filterCFBundleIdentifier(packager.platformSpecificBuildOptions.helperBundleId || oldHelperBundleId || `${appInfo.macBundleIdentifier}.helper`)
await packager.applyCommonInfo(appPlist, contentsPath)
// required for electron-updater proxy
if (!isMas) {
configureLocalhostAts(appPlist)
}
helperPlist.CFBundleExecutable = `${appFilename} Helper`
helperPlist.CFBundleDisplayName = `${appInfo.productName} Helper`
helperPlist.CFBundleIdentifier = helperBundleIdentifier
helperPlist.CFBundleVersion = appPlist.CFBundleVersion
function configureHelper(helper: any, postfix: string) {
export function signed(packagerOptions: PackagerOptions): PackagerOptions {
if (process.env.CSC_KEY_PASSWORD == null) {
log.warn({reason: "CSC_KEY_PASSWORD is not defined"}, "macOS code signing is not tested")
}
else {
if (packagerOptions.config == null) {
(packagerOptions as any).config = {}
}
(packagerOptions.config as any).cscLink = CSC_LINK
}
return packagerOptions
}
private async init(): Promise {
try {
return await this.client.getVersion(this.version)
}
catch (e) {
if (e instanceof HttpError && e.statusCode === 404) {
if (this.options.publish !== "onTagOrDraft") {
log.info({version: this.version}, "version doesn't exist, creating one")
return await this.client.createVersion(this.version)
}
else {
log.warn({reason: "version doesn't exist", version: this.version}, "skipped publishing")
}
}
throw e
}
}
throw new Error("call copyIfValid before")
}
if (this.cacheInfo == null) {
this.cacheInfo = {executableDigest: this.newDigest}
}
else {
this.cacheInfo.executableDigest = this.newDigest
}
try {
await ensureDir(this.cacheDir)
await Promise.all([writeJson(this.cacheInfoFile, this.cacheInfo), copyFile(this.executableFile, this.cacheFile, false)])
}
catch (e) {
log.warn({error: e.stack || e}, `cannot save build cache`)
}
}
}
function checkConflictingOptions(options: any) {
for (const name of ["outputDirectory", "appDirectory", "exe", "fixUpPaths", "usePackageJson", "extraFileSpecs", "extraMetadataSpecs", "skipUpdateIcon", "setupExe"]) {
if (name in options) {
throw new InvalidConfigurationError(`Option ${name} is ignored, do not specify it.`)
}
}
if ("noMsi" in options) {
log.warn(`noMsi is deprecated, please specify as "msi": true if you want to create an MSI installer`)
options.msi = !options.noMsi
}
const msi = options.msi
if (msi != null && typeof msi !== "boolean") {
throw new InvalidConfigurationError(`msi expected to be boolean value, but string '"${msi}"' was specified`)
}
}
protected async doUpload(fileName: string, arch: Arch, dataLength: number, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void): Promise {
const release = await this._release.value
if (release == null) {
log.warn({file: fileName, ...this.releaseLogFields}, "skipped publishing")
return
}
const parsedUrl = parseUrl(release.upload_url.substring(0, release.upload_url.indexOf("{")) + "?name=" + fileName)
return await this.doUploadFile(0, parsedUrl, fileName, dataLength, requestProcessor, release)
}
const info = await getInfo()
if (info == null) {
return null
}
if (!owner) {
owner = info.user
}
if (!project) {
project = info.project
}
}
if (isGithub) {
if ((options as GithubOptions).token != null && !(options as GithubOptions).private) {
log.warn('"token" specified in the github publish options. It should be used only for [setFeedURL](module:electron-updater/out/AppUpdater.AppUpdater+setFeedURL).')
}
//tslint:disable-next-line:no-object-literal-type-assertion
return {owner, repo: project, ...options} as GithubOptions
}
else {
//tslint:disable-next-line:no-object-literal-type-assertion
return {owner, package: project, ...options} as BintrayOptions
}
}