Skip to content

Commit

Permalink
refactor(updater): prepare to support private github repo, nuts and s…
Browse files Browse the repository at this point in the history
…o on on macOS

BREAKING CHANGE: remove compatibility with very old electron-updater version (< 0.10.0)

Close electron-userland#1575, Close electron-userland#1571, Close electron-userland#1577
  • Loading branch information
develar committed May 23, 2017
1 parent eb181b9 commit 3aae466
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 110 deletions.
3 changes: 0 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ If you get strange compilation errors, try to remove all `node_modules` in the p
### Git Commit Guidelines
We use [semantic-release](https://github.com/semantic-release/semantic-release), so we have very precise rules over how our git commit messages can be formatted.

The commit message formatting can be added using a typical git workflow or through the use of a CLI wizard ([Commitizen](https://github.com/commitizen/cz-cli)).
To use the wizard, run `npm run commit` in your terminal after staging your changes in git.

### Commit Message Format
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
format that includes a **type**, a **scope** and a **subject**:
Expand Down
1 change: 1 addition & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,6 +508,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
| runAfterFinish = <code>true</code>| <code>boolean</code> | <a name="NsisOptions-runAfterFinish"></a>*one-click installer only.* Run application after finish. |
| guid| <code>string</code> \| <code>null</code> | <a name="NsisOptions-guid"></a>See [GUID vs Application Name](https://github.com/electron-userland/electron-builder/wiki/NSIS#guid-vs-application-name). |
| installerIcon| <code>string</code> \| <code>null</code> | <a name="NsisOptions-installerIcon"></a>The path to installer icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `build/installerIcon.ico` or application icon. |
| uninstallerIcon| <code>string</code> \| <code>null</code> | <a name="NsisOptions-uninstallerIcon"></a>The path to uninstaller icon, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `build/uninstallerIcon.ico` or application icon. |
| installerHeader = <code>&quot;build/installerHeader.bmp&quot;</code>| <code>string</code> \| <code>null</code> | <a name="NsisOptions-installerHeader"></a>*boring installer only.* `MUI_HEADERIMAGE`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. |
| installerSidebar| <code>string</code> \| <code>null</code> | <a name="NsisOptions-installerSidebar"></a>*boring installer only.* `MUI_WELCOMEFINISHPAGE_BITMAP`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp` |
| uninstallerSidebar| <code>string</code> \| <code>null</code> | <a name="NsisOptions-uninstallerSidebar"></a>*boring installer only.* `MUI_UNWELCOMEFINISHPAGE_BITMAP`, relative to the the [build resources](https://github.com/electron-userland/electron-builder/wiki/Options#MetadataDirectories-buildResources) or to the project directory. Defaults to `installerSidebar` option or `build/uninstallerSidebar.bmp` or `build/installerSidebar.bmp` or `${NSISDIR}\\Contrib\\Graphics\\Wizard\\nsis3-metro.bmp` |
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11",
"update-deps": "lerna exec -- npm-check-updates --reject 'electron-builder-http,electron-builder-util,electron-builder-core,electron-publish,electron-forge-maker-appimage,electron-forge-maker-nsis,electron-forge-maker-snap' -a",
"set-versions": "node test/out/helpers/setVersions.js",
"npm-publish": "yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
"npm-publish": "yarn set-versions && yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
"schema": "typescript-json-schema packages/electron-builder/tsconfig.json Config --out packages/electron-builder/scheme.json --noExtraProps --useTypeOfKeyword --strictNullChecks --titles",
"jsdoc": "ts2jsdoc packages/electron-builder-http packages/electron-updater packages/electron-builder-util packages/electron-builder packages/electron-builder-core packages/electron-publish",
"jsdoc2md": "node packages/jsdoc2md.js",
Expand All @@ -31,15 +31,15 @@
"ajv": "^5.1.3",
"ajv-keywords": "^2.0.0",
"archiver": "^1.3.0",
"aws-sdk": "^2.54.0",
"aws-sdk": "^2.55.0",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
"cuint": "^0.2.2",
"debug": "^2.6.8",
"electron-download-tf": "4.3.1",
"electron-is-dev": "^0.1.2",
"electron-osx-sign": "0.4.4",
"electron-osx-sign": "0.4.5",
"fs-extra-p": "^4.3.0",
"hosted-git-info": "^2.4.2",
"ini": "^1.3.4",
Expand Down Expand Up @@ -68,7 +68,7 @@
"@types/ini": "^1.3.29",
"@types/jest": "^19.2.3",
"@types/js-yaml": "^3.5.30",
"@types/node-forge": "^0.6.8",
"@types/node-forge": "^0.6.9",
"@types/source-map-support": "^0.2.28",
"@types/xml2js": "^0.0.33",
"babel-plugin-array-includes": "^2.0.3",
Expand All @@ -91,8 +91,8 @@
"path-sort": "^0.1.0",
"source-map-support": "^0.4.15",
"ts-babel": "^3.0.1",
"tslint": "^5.2.0",
"typescript": "^2.3.2",
"tslint": "^5.3.2",
"typescript": "^2.3.3",
"whitespace": "^2.1.0",
"xml2js": "^0.4.17"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
"electron-builder-http": "0.0.0-semantic-release",
"electron-builder-util": "0.0.0-semantic-release",
"electron-download-tf": "4.3.1",
"electron-osx-sign": "0.4.4",
"electron-osx-sign": "0.4.5",
"electron-publish": "0.0.0-semantic-release",
"fs-extra-p": "^4.3.0",
"hosted-git-info": "^2.4.2",
Expand Down
57 changes: 18 additions & 39 deletions packages/electron-builder/src/publish/PublishManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,14 +221,16 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
}

for (const publishConfig of publishConfigs) {
const isGitHub = publishConfig.provider === "github"
if (!(publishConfig.provider === "generic" || publishConfig.provider === "s3" || isGitHub)) {
if (publishConfig.provider === "bintray") {
continue
}

const version = packager.appInfo.version
const channel = (<GenericServerOptions>publishConfig).channel || "latest"

if (packager.platform === Platform.MAC) {
const isGitHub = publishConfig.provider === "github"
// backward compatibility - write json file
const updateInfoFile = isGitHub ? path.join(outDir, "github", `${channel}-mac.json`) : path.join(outDir, `${channel}-mac.json`)
await (<any>outputJson)(updateInfoFile, <VersionInfo>{
version: version,
Expand All @@ -243,52 +245,29 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
target: null,
publishConfig: publishConfig,
})

continue
}
else {
await writeWindowsUpdateInfo(event, version, outDir, channel, publishConfigs)
break
}
}
}

async function writeWindowsUpdateInfo(event: ArtifactCreated, version: string, outDir: any, channel: string, publishConfigs: Array<PublishConfiguration>): Promise<void> {
const packager = event.packager
const sha2 = await sha256(event.file!)
const updateInfoFile = path.join(outDir, `${channel}.yml`)
await writeFile(updateInfoFile, safeDump(<UpdateInfo>{
version: version,
releaseDate: new Date().toISOString(),
githubArtifactName: event.safeArtifactName,
path: path.basename(event.file!),
sha2: sha2,
}))

const githubPublishConfig = publishConfigs.find(it => it.provider === "github")
if (githubPublishConfig != null) {
// to preserve compatibility with old electron-updater (< 0.10.0), we upload file with path specific for GitHub
packager.info.dispatchArtifactCreated({
data: new Buffer(safeDump(<UpdateInfo>{
version: version,
path: event.safeArtifactName,
sha2: sha2,
})),
safeArtifactName: `${channel}.yml`,
packager: packager,
target: null,
publishConfig: githubPublishConfig,
arch: null,
})
}
const sha2 = await sha256(event.file!)
const updateInfoFile = path.join(outDir, `${channel}${packager.platform === Platform.MAC ? "-mac" : ""}.yml`)
await writeFile(updateInfoFile, safeDump(<UpdateInfo>{
version: version,
releaseDate: new Date().toISOString(),
githubArtifactName: event.safeArtifactName,
path: path.basename(event.file!),
sha2: sha2,
}))

const genericPublishConfig = publishConfigs.find(it => it.provider === "generic" || it.provider === "s3")
if (genericPublishConfig != null) {
packager.info.dispatchArtifactCreated({
file: updateInfoFile,
arch: null,
packager: packager,
target: null,
publishConfig: genericPublishConfig,
publishConfig: publishConfig,
})

break
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-publisher-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"fs-extra-p": "^4.3.0",
"aws-sdk": "^2.54.0",
"aws-sdk": "^2.55.0",
"mime": "^1.3.6",
"electron-publish": "~0.0.0-semantic-release",
"electron-builder-util": "~0.0.0-semantic-release"
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/app-executable-deps/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"build": {
"electronVersion": "1.6.6",
"electronVersion": "1.7.1",
"category": "public.app-category.business"
}
}
2 changes: 1 addition & 1 deletion test/fixtures/test-app-build-sub/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"author": "true",
"name": "Foo",
"build": {
"electronVersion": "1.6.6",
"electronVersion": "1.7.1",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app-one/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"author": "Foo Bar <[email protected]>",
"license": "MIT",
"build": {
"electronVersion": "1.6.6",
"electronVersion": "1.7.1",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures/test-app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"build": {
"electronVersion": "1.6.6",
"electronVersion": "1.7.1",
"appId": "org.electron-builder.testApp",
"compression": "store",
"npmRebuild": false,
Expand Down
1 change: 0 additions & 1 deletion test/out/__snapshots__/filesTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ Array [
"lib/net45/ui_resources_200_percent.pak",
"lib/net45/Update.exe",
"lib/net45/views_resources_200_percent.pak",
"lib/net45/xinput1_3.dll",
"lib/net45/locales/en-US.pak",
"lib/net45/resources/app.asar",
"lib/net45/resources/electron.asar",
Expand Down
6 changes: 3 additions & 3 deletions test/out/linux/__snapshots__/debTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ Object {
"Package": "testapp",
"Priority": "extra",
"Section": "devel",
"Size": "91139",
"Size": "95691",
"Vendor": "Foo Bar <[email protected]>",
}
`;
Expand Down Expand Up @@ -185,7 +185,7 @@ Object {
"Package": "testapp",
"Priority": "extra",
"Section": "devel",
"Size": "124968",
"Size": "130781",
"Vendor": "Foo Bar <[email protected]>",
}
`;
Expand Down Expand Up @@ -274,7 +274,7 @@ Object {
"Package": "testapp",
"Priority": "extra",
"Section": "devel",
"Size": "124968",
"Size": "130781",
"Vendor": "Foo Bar <[email protected]>",
}
`;
2 changes: 1 addition & 1 deletion test/out/mac/__snapshots__/macPackagerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Object {
exports[`one-package 2`] = `
Object {
"BuildMachineOSBuild": "15G31",
"BuildMachineOSBuild": "16E195",
"CFBundleDisplayName": "Test App ßW",
"CFBundleDocumentTypes": Array [
Object {
Expand Down
4 changes: 4 additions & 0 deletions test/out/windows/__snapshots__/installerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
exports[`allowToChangeInstallationDirectory 1`] = `
Object {
"win": Array [
Object {
"arch": null,
"file": "latest.yml",
},
Object {
"arch": 1,
"file": "Test Custom Installation Dir Setup 1.1.0.exe",
Expand Down
4 changes: 4 additions & 0 deletions test/out/windows/__snapshots__/oneClickInstallerTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,10 @@ Object {
exports[`web installer (default github) 1`] = `
Object {
"win": Array [
Object {
"arch": null,
"file": "latest.yml",
},
Object {
"arch": null,
"file": "Test App ßW Web Setup 1.1.0.exe",
Expand Down
4 changes: 4 additions & 0 deletions test/out/windows/__snapshots__/portableTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ Object {
exports[`portable 1`] = `
Object {
"win": Array [
Object {
"arch": null,
"file": "latest.yml",
},
Object {
"arch": 1,
"file": "Test App ßW Setup 1.1.0.exe",
Expand Down
1 change: 0 additions & 1 deletion test/out/windows/__snapshots__/squirrelWindowsTest.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ Array [
"lib/net45/ui_resources_200_percent.pak",
"lib/net45/Update.exe",
"lib/net45/views_resources_200_percent.pak",
"lib/net45/xinput1_3.dll",
"lib/net45/locales/en-US.pak",
"lib/net45/resources/app.asar",
"lib/net45/resources/electron.asar",
Expand Down
2 changes: 1 addition & 1 deletion test/src/helpers/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ docker: Error response from daemon: Mounts denied: o Docker.
*/
const baseDir = process.env.ELECTRON_BUILDER_TEST_DIR || (process.platform === "darwin" && !require("is-ci") ? "/tmp" : tmpdir())
export const TEST_DIR = path.join(baseDir, `et-${createHash("md5").update(__dirname).digest("hex")}`)
export const ELECTRON_VERSION = "1.6.6"
export const ELECTRON_VERSION = "1.7.1"
Loading

0 comments on commit 3aae466

Please sign in to comment.