From d6aa555812fe47c01c4295f200b0fe044f646842 Mon Sep 17 00:00:00 2001 From: develar Date: Wed, 13 Jul 2016 08:11:46 +0200 Subject: [PATCH] feat(Squirrel.Windows): Automatic remoteReleases configuration Closes #561 --- docs/Options.md | 2 +- src/metadata.ts | 4 ++-- src/targets/squirrelWindows.ts | 13 ++++++++++++- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/Options.md b/docs/Options.md index 92d8ba1207e..be2080e2093 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -113,7 +113,7 @@ Windows specific build options. | iconUrl |

*Squirrel.Windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel > Programs and Features). Defaults to the Electron icon.

Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.

| loadingGif |

*Squirrel.Windows-only.* The path to a .gif file to display during install. build/install-spinner.gif will be used if exists (it is a recommended way to set) (otherwise [default](https://github.com/electron/windows-installer/blob/master/resources/install-spinner.gif)).

| msi | *Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created). -| remoteReleases | *Squirrel.Windows-only.* A URL to your existing updates. If given, these will be downloaded to create delta updates. +| remoteReleases | *Squirrel.Windows-only.* A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. | remoteToken | *Squirrel.Windows-only.* Authentication token for remote updates | signingHashAlgorithms | Array of signing algorithms used. Defaults to `['sha1', 'sha256']` | icon | The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration). diff --git a/src/metadata.ts b/src/metadata.ts index d4bab38c82c..5bc924920ec 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -328,9 +328,9 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions { readonly msi?: boolean /* - *Squirrel.Windows-only.* A URL to your existing updates. If given, these will be downloaded to create delta updates. + *Squirrel.Windows-only.* A URL to your existing updates. Or `true` to automatically set to your GitHub repository. If given, these will be downloaded to create delta updates. */ - readonly remoteReleases?: string | null + readonly remoteReleases?: string | boolean | null /* *Squirrel.Windows-only.* Authentication token for remote updates diff --git a/src/targets/squirrelWindows.ts b/src/targets/squirrelWindows.ts index 4996f020a46..e3508eb430d 100644 --- a/src/targets/squirrelWindows.ts +++ b/src/targets/squirrelWindows.ts @@ -3,7 +3,7 @@ import { getArchSuffix, Target } from "../platformPackager" import { Arch, WinBuildOptions } from "../metadata" import { createWindowsInstaller, convertVersion } from "electron-winstaller-fixed" import * as path from "path" -import { warn } from "../util/log" +import { warn, log } from "../util/log" import { getRepositoryInfo } from "../repositoryInfo" //noinspection JSUnusedLocalSymbols @@ -102,6 +102,17 @@ export default class SquirrelWindowsTarget extends Target { } } + if (options.remoteReleases === true) { + const info = await getRepositoryInfo(packager.appInfo.metadata, packager.devMetadata) + if (info == null) { + warn("remoteReleases set to true, but cannot get repository info") + } + else { + options.remoteReleases = `https://github.com/${info.user}/${info.project}` + log(`remoteReleases is set to ${options.remoteReleases}`) + } + } + return options } }