Skip to content

Commit

Permalink
feat(Squirrel.Windows): Automatic remoteReleases configuration
Browse files Browse the repository at this point in the history
Closes #561
  • Loading branch information
develar committed Jul 13, 2016
1 parent 50039ea commit d6aa555
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ Windows specific build options.
| 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>
| 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>
| msi | <a name="WinBuildOptions-msi"></a>*Squirrel.Windows-only.* Whether to create an MSI installer. Defaults to `false` (MSI is not created).
| 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.
| 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.
| remoteToken | <a name="WinBuildOptions-remoteToken"></a>*Squirrel.Windows-only.* Authentication token for remote updates
| signingHashAlgorithms | <a name="WinBuildOptions-signingHashAlgorithms"></a>Array of signing algorithms used. Defaults to `['sha1', 'sha256']`
| 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).
Expand Down
4 changes: 2 additions & 2 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion src/targets/squirrelWindows.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
}
Expand Down

0 comments on commit d6aa555

Please sign in to comment.