Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Exec: exec,
Terminal: "false",
Type: "Application",
Icon: packager.executableName,
// https://askubuntu.com/questions/367396/what-represent-the-startupwmclass-field-of-a-desktop-file
// must be set to package.json name (because it is Electron set WM_CLASS)
// to get WM_CLASS of running window: xprop WM_CLASS
// StartupWMClass doesn't work for unicode
// https://github.com/electron/electron/blob/2-0-x/atom/browser/native_window_views.cc#L226
StartupWMClass: appInfo.productName,
...extra,
...targetSpecificOptions.desktop,
}
const description = this.getDescription(targetSpecificOptions)
if (!isEmptyOrSpaces(description)) {
desktopMeta.Comment = description
}
const mimeTypes: Array = asArray(targetSpecificOptions.mimeTypes)
for (const fileAssociation of packager.fileAssociations) {
if (fileAssociation.mimeType != null) {
mimeTypes.push(fileAssociation.mimeType)
}
}
for (const protocol of asArray(packager.config.protocols).concat(asArray(packager.platformSpecificBuildOptions.protocols))) {
for (const scheme of asArray(protocol.schemes)) {
mimeTypes.push(`x-scheme-handler/${scheme}`)
}
}
name: appName,
productName: this.options.name || appInfo.productName,
appId: this.options.useAppIdAsId ? appInfo.id : appName,
version: appInfo.version,
description: appInfo.description,
// better to explicitly set to empty string, to avoid any nugget errors
authors: appInfo.companyName || "",
iconUrl,
extraMetadataSpecs: projectUrl == null ? null : `\n ${projectUrl}`,
copyright: appInfo.copyright,
packageCompressionLevel: parseInt((process.env.ELECTRON_BUILDER_COMPRESSION_LEVEL || packager.compression === "store" ? 0 : 9) as any, 10),
vendorPath: await getBinFromUrl("Squirrel.Windows", "1.9.0", "zJHk4CMATM7jHJ2ojRH1n3LkOnaIezDk5FAzJmlSEQSiEdRuB4GGLCegLDtsRCakfHIVfKh3ysJHLjynPkXwhQ=="),
...this.options as any,
}
if (isEmptyOrSpaces(options.description)) {
options.description = options.productName
}
if (options.remoteToken == null) {
options.remoteToken = process.env.GH_TOKEN || process.env.GITHUB_TOKEN
}
if (!("loadingGif" in options)) {
const resourceList = await packager.resourceList
if (resourceList.includes("install-spinner.gif")) {
options.loadingGif = path.join(packager.buildResourcesDir, "install-spinner.gif")
}
}
if (this.options.remoteReleases === true) {
const info = await packager.info.repositoryInfo
constructor(context: PublishContext, info: BintrayOptions, private readonly version: string, private readonly options: PublishOptions = {}) {
super(context)
let token = info.token
if (isEmptyOrSpaces(token)) {
token = process.env.BT_TOKEN
if (isEmptyOrSpaces(token)) {
throw new InvalidConfigurationError(`Bintray token is not set, neither programmatically, nor using env "BT_TOKEN" (see https://www.electron.build/configuration/publish#bintrayoptions)`)
}
token = token.trim()
if (!isTokenCharValid(token)) {
throw new InvalidConfigurationError(`Bintray token (${JSON.stringify(token)}) contains invalid characters, please check env "BT_TOKEN"`)
}
}
this.client = new BintrayClient(info, httpExecutor, this.context.cancellationToken, token)
}
async function resolvePublishConfigurations(publishers: any, platformPackager: PlatformPackager | null, packager: Packager, arch: Arch | null, errorIfCannot: boolean): Promise | null> {
if (publishers == null) {
let serviceName: PublishProvider | null = null
if (!isEmptyOrSpaces(process.env.GH_TOKEN) || !isEmptyOrSpaces(process.env.GITHUB_TOKEN)) {
serviceName = "github"
}
else if (!isEmptyOrSpaces(process.env.BT_TOKEN)) {
serviceName = "bintray"
}
if (serviceName != null) {
log.debug(null, `detect ${serviceName} as publish provider`)
return [(await getResolvedPublishConfig(platformPackager, packager, {provider: serviceName}, arch, errorIfCannot))!]
}
}
if (publishers == null) {
return []
}
constructor(context: PublishContext, info: BintrayOptions, private readonly version: string, private readonly options: PublishOptions = {}) {
super(context)
let token = info.token
if (isEmptyOrSpaces(token)) {
token = process.env.BT_TOKEN
if (isEmptyOrSpaces(token)) {
throw new InvalidConfigurationError(`Bintray token is not set, neither programmatically, nor using env "BT_TOKEN" (see https://www.electron.build/configuration/publish#bintrayoptions)`)
}
token = token.trim()
if (!isTokenCharValid(token)) {
throw new InvalidConfigurationError(`Bintray token (${JSON.stringify(token)}) contains invalid characters, please check env "BT_TOKEN"`)
}
}
this.client = new BintrayClient(info, httpExecutor, this.context.cancellationToken, token)
}
async function resolvePublishConfigurations(publishers: any, platformPackager: PlatformPackager | null, packager: Packager, arch: Arch | null, errorIfCannot: boolean): Promise | null> {
if (publishers == null) {
let serviceName: PublishProvider | null = null
if (!isEmptyOrSpaces(process.env.GH_TOKEN) || !isEmptyOrSpaces(process.env.GITHUB_TOKEN)) {
serviceName = "github"
}
else if (!isEmptyOrSpaces(process.env.BT_TOKEN)) {
serviceName = "bintray"
}
if (serviceName != null) {
log.debug(null, `detect ${serviceName} as publish provider`)
return [(await getResolvedPublishConfig(platformPackager, packager, {provider: serviceName}, arch, errorIfCannot))!]
}
}
if (publishers == null) {
return []
}
debug(`Explicit publish provider: ${safeStringifyJson(publishers)}`)
return await (BluebirdPromise.map(asArray(publishers), it => getResolvedPublishConfig(platformPackager, packager, typeof it === "string" ? {provider: it} : it, arch, errorIfCannot)) as Promise>)
}
protected configureS3Options(args: Array): void {
super.configureS3Options(args)
args.push("--endpoint", `${this.info.region}.digitaloceanspaces.com`)
args.push("--region", this.info.region)
const accessKey = process.env.DO_KEY_ID
const secretKey = process.env.DO_SECRET_KEY
if (isEmptyOrSpaces(accessKey)) {
throw new InvalidConfigurationError("Please set env DO_KEY_ID (see https://www.electron.build/configuration/publish#spacesoptions)")
}
if (isEmptyOrSpaces(secretKey)) {
throw new InvalidConfigurationError("Please set env DO_SECRET_KEY (see https://www.electron.build/configuration/publish#spacesoptions)")
}
args.push("--accessKey", accessKey)
args.push("--secretKey", secretKey)
}
}
protected configureS3Options(args: Array): void {
super.configureS3Options(args)
args.push("--endpoint", `${this.info.region}.digitaloceanspaces.com`)
args.push("--region", this.info.region)
const accessKey = process.env.DO_KEY_ID
const secretKey = process.env.DO_SECRET_KEY
if (isEmptyOrSpaces(accessKey)) {
throw new InvalidConfigurationError("Please set env DO_KEY_ID (see https://www.electron.build/configuration/publish#spacesoptions)")
}
if (isEmptyOrSpaces(secretKey)) {
throw new InvalidConfigurationError("Please set env DO_SECRET_KEY (see https://www.electron.build/configuration/publish#spacesoptions)")
}
args.push("--accessKey", accessKey)
args.push("--secretKey", secretKey)
}
}