Skip to content

Commit d6aa555

Browse files
committed
feat(Squirrel.Windows): Automatic remoteReleases configuration
Closes #561
1 parent 50039ea commit d6aa555

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

docs/Options.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ Windows specific build options.
113113
| iconUrl | <a name="WinBuildOptions-iconUrl"></a><p>*Squirrel.Windows-only.* A URL to an ICO file to use as the application icon (displayed in Control Panel &gt; Programs and Features). Defaults to the Electron icon.</p> <p>Please note — [local icon file url is not accepted](https://github.com/atom/grunt-electron-installer/issues/73), must be https/http.</p> <ul> <li>If you don’t plan to build windows installer, you can omit it.</li> <li>If your project repository is public on GitHub, it will be <code>https://github.com/${u}/${p}/blob/master/build/icon.ico?raw=true</code> by default.</li> </ul>
114114
| loadingGif | <a name="WinBuildOptions-loadingGif"></a><p>*Squirrel.Windows-only.* The path to a .gif file to display during install. <code>build/install-spinner.gif</code> 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)).</p>
115115
| msi | <a name="WinBuildOptions-msi"></a>*Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created).
116-
| remoteReleases | <a name="WinBuildOptions-remoteReleases"></a>*Squirrel.Windows-only.* A URL to your existing updates. If given, these will be downloaded to create delta updates.
116+
| remoteReleases | <a name="WinBuildOptions-remoteReleases"></a>*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.
117117
| remoteToken | <a name="WinBuildOptions-remoteToken"></a>*Squirrel.Windows-only.* Authentication token for remote updates
118118
| signingHashAlgorithms | <a name="WinBuildOptions-signingHashAlgorithms"></a>Array of signing algorithms used. Defaults to `['sha1', 'sha256']`
119119
| icon | <a name="WinBuildOptions-icon"></a>The path to application icon. Defaults to `build/icon.ico` (consider using this convention instead of complicating your configuration).

src/metadata.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ export interface WinBuildOptions extends PlatformSpecificBuildOptions {
328328
readonly msi?: boolean
329329

330330
/*
331-
*Squirrel.Windows-only.* A URL to your existing updates. If given, these will be downloaded to create delta updates.
331+
*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.
332332
*/
333-
readonly remoteReleases?: string | null
333+
readonly remoteReleases?: string | boolean | null
334334

335335
/*
336336
*Squirrel.Windows-only.* Authentication token for remote updates

src/targets/squirrelWindows.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { getArchSuffix, Target } from "../platformPackager"
33
import { Arch, WinBuildOptions } from "../metadata"
44
import { createWindowsInstaller, convertVersion } from "electron-winstaller-fixed"
55
import * as path from "path"
6-
import { warn } from "../util/log"
6+
import { warn, log } from "../util/log"
77
import { getRepositoryInfo } from "../repositoryInfo"
88

99
//noinspection JSUnusedLocalSymbols
@@ -102,6 +102,17 @@ export default class SquirrelWindowsTarget extends Target {
102102
}
103103
}
104104

105+
if (options.remoteReleases === true) {
106+
const info = await getRepositoryInfo(packager.appInfo.metadata, packager.devMetadata)
107+
if (info == null) {
108+
warn("remoteReleases set to true, but cannot get repository info")
109+
}
110+
else {
111+
options.remoteReleases = `https://github.com/${info.user}/${info.project}`
112+
log(`remoteReleases is set to ${options.remoteReleases}`)
113+
}
114+
}
115+
105116
return options
106117
}
107118
}

0 commit comments

Comments
 (0)