Skip to content

Commit a41936b

Browse files
committed
refactor(updater): prepare to support private github repo, nuts and so on on macOS
BREAKING CHANGE: remove compatibility with very old electron-updater version (< 0.10.0) Close #1575, Close #1571, Close #1577
1 parent 22b5ba5 commit a41936b

File tree

19 files changed

+80
-110
lines changed

19 files changed

+80
-110
lines changed

CONTRIBUTING.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ If you get strange compilation errors, try to remove all `node_modules` in the p
1313
### Git Commit Guidelines
1414
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.
1515

16-
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)).
17-
To use the wizard, run `npm run commit` in your terminal after staging your changes in git.
18-
1916
### Commit Message Format
2017
Each commit message consists of a **header**, a **body** and a **footer**. The header has a special
2118
format that includes a **type**, a **scope** and a **subject**:

docs/Options.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,6 +508,7 @@ See [NSIS target notes](https://github.com/electron-userland/electron-builder/wi
508508
| runAfterFinish = <code>true</code>| <code>boolean</code> | <a name="NsisOptions-runAfterFinish"></a>*one-click installer only.* Run application after finish. |
509509
| 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). |
510510
| 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. |
511+
| 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. |
511512
| 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. |
512513
| 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` |
513514
| 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` |

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
"test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11",
1818
"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",
1919
"set-versions": "node test/out/helpers/setVersions.js",
20-
"npm-publish": "yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
20+
"npm-publish": "yarn set-versions && yarn compile && ./packages/npm-publish.sh && conventional-changelog -p angular -i CHANGELOG.md -s",
2121
"schema": "typescript-json-schema packages/electron-builder/tsconfig.json Config --out packages/electron-builder/scheme.json --noExtraProps --useTypeOfKeyword --strictNullChecks --titles",
2222
"jsdoc": "ts2jsdoc packages/electron-builder-http packages/electron-updater packages/electron-builder-util packages/electron-builder packages/electron-builder-core packages/electron-publish",
2323
"jsdoc2md": "node packages/jsdoc2md.js",
@@ -31,15 +31,15 @@
3131
"ajv": "^5.1.3",
3232
"ajv-keywords": "^2.0.0",
3333
"archiver": "^1.3.0",
34-
"aws-sdk": "^2.54.0",
34+
"aws-sdk": "^2.55.0",
3535
"bluebird-lst": "^1.0.2",
3636
"chalk": "^1.1.3",
3737
"chromium-pickle-js": "^0.2.0",
3838
"cuint": "^0.2.2",
3939
"debug": "^2.6.8",
4040
"electron-download-tf": "4.3.1",
4141
"electron-is-dev": "^0.1.2",
42-
"electron-osx-sign": "0.4.4",
42+
"electron-osx-sign": "0.4.5",
4343
"fs-extra-p": "^4.3.0",
4444
"hosted-git-info": "^2.4.2",
4545
"ini": "^1.3.4",
@@ -68,7 +68,7 @@
6868
"@types/ini": "^1.3.29",
6969
"@types/jest": "^19.2.3",
7070
"@types/js-yaml": "^3.5.30",
71-
"@types/node-forge": "^0.6.8",
71+
"@types/node-forge": "^0.6.9",
7272
"@types/source-map-support": "^0.2.28",
7373
"@types/xml2js": "^0.0.33",
7474
"babel-plugin-array-includes": "^2.0.3",
@@ -91,8 +91,8 @@
9191
"path-sort": "^0.1.0",
9292
"source-map-support": "^0.4.15",
9393
"ts-babel": "^3.0.1",
94-
"tslint": "^5.2.0",
95-
"typescript": "^2.3.2",
94+
"tslint": "^5.3.2",
95+
"typescript": "^2.3.3",
9696
"whitespace": "^2.1.0",
9797
"xml2js": "^0.4.17"
9898
},

packages/electron-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
"electron-builder-http": "0.0.0-semantic-release",
5656
"electron-builder-util": "0.0.0-semantic-release",
5757
"electron-download-tf": "4.3.1",
58-
"electron-osx-sign": "0.4.4",
58+
"electron-osx-sign": "0.4.5",
5959
"electron-publish": "0.0.0-semantic-release",
6060
"fs-extra-p": "^4.3.0",
6161
"hosted-git-info": "^2.4.2",

packages/electron-builder/src/publish/PublishManager.ts

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -221,14 +221,16 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
221221
}
222222

223223
for (const publishConfig of publishConfigs) {
224-
const isGitHub = publishConfig.provider === "github"
225-
if (!(publishConfig.provider === "generic" || publishConfig.provider === "s3" || isGitHub)) {
224+
if (publishConfig.provider === "bintray") {
226225
continue
227226
}
228227

229228
const version = packager.appInfo.version
230229
const channel = (<GenericServerOptions>publishConfig).channel || "latest"
230+
231231
if (packager.platform === Platform.MAC) {
232+
const isGitHub = publishConfig.provider === "github"
233+
// backward compatibility - write json file
232234
const updateInfoFile = isGitHub ? path.join(outDir, "github", `${channel}-mac.json`) : path.join(outDir, `${channel}-mac.json`)
233235
await (<any>outputJson)(updateInfoFile, <VersionInfo>{
234236
version: version,
@@ -243,52 +245,29 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
243245
target: null,
244246
publishConfig: publishConfig,
245247
})
248+
249+
continue
246250
}
247-
else {
248-
await writeWindowsUpdateInfo(event, version, outDir, channel, publishConfigs)
249-
break
250-
}
251-
}
252-
}
253251

254-
async function writeWindowsUpdateInfo(event: ArtifactCreated, version: string, outDir: any, channel: string, publishConfigs: Array<PublishConfiguration>): Promise<void> {
255-
const packager = event.packager
256-
const sha2 = await sha256(event.file!)
257-
const updateInfoFile = path.join(outDir, `${channel}.yml`)
258-
await writeFile(updateInfoFile, safeDump(<UpdateInfo>{
259-
version: version,
260-
releaseDate: new Date().toISOString(),
261-
githubArtifactName: event.safeArtifactName,
262-
path: path.basename(event.file!),
263-
sha2: sha2,
264-
}))
265-
266-
const githubPublishConfig = publishConfigs.find(it => it.provider === "github")
267-
if (githubPublishConfig != null) {
268-
// to preserve compatibility with old electron-updater (< 0.10.0), we upload file with path specific for GitHub
269-
packager.info.dispatchArtifactCreated({
270-
data: new Buffer(safeDump(<UpdateInfo>{
271-
version: version,
272-
path: event.safeArtifactName,
273-
sha2: sha2,
274-
})),
275-
safeArtifactName: `${channel}.yml`,
276-
packager: packager,
277-
target: null,
278-
publishConfig: githubPublishConfig,
279-
arch: null,
280-
})
281-
}
252+
const sha2 = await sha256(event.file!)
253+
const updateInfoFile = path.join(outDir, `${channel}${packager.platform === Platform.MAC ? "-mac" : ""}.yml`)
254+
await writeFile(updateInfoFile, safeDump(<UpdateInfo>{
255+
version: version,
256+
releaseDate: new Date().toISOString(),
257+
githubArtifactName: event.safeArtifactName,
258+
path: path.basename(event.file!),
259+
sha2: sha2,
260+
}))
282261

283-
const genericPublishConfig = publishConfigs.find(it => it.provider === "generic" || it.provider === "s3")
284-
if (genericPublishConfig != null) {
285262
packager.info.dispatchArtifactCreated({
286263
file: updateInfoFile,
287264
arch: null,
288265
packager: packager,
289266
target: null,
290-
publishConfig: genericPublishConfig,
267+
publishConfig: publishConfig,
291268
})
269+
270+
break
292271
}
293272
}
294273

packages/electron-publisher-s3/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
],
1313
"dependencies": {
1414
"fs-extra-p": "^4.3.0",
15-
"aws-sdk": "^2.54.0",
15+
"aws-sdk": "^2.55.0",
1616
"mime": "^1.3.6",
1717
"electron-publish": "~0.0.0-semantic-release",
1818
"electron-builder-util": "~0.0.0-semantic-release"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"build": {
3-
"electronVersion": "1.6.6",
3+
"electronVersion": "1.7.1",
44
"category": "public.app-category.business"
55
}
66
}

test/fixtures/test-app-build-sub/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "true",
55
"name": "Foo",
66
"build": {
7-
"electronVersion": "1.6.6",
7+
"electronVersion": "1.7.1",
88
"appId": "org.electron-builder.testApp",
99
"compression": "store",
1010
"npmRebuild": false,

test/fixtures/test-app-one/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": "Foo Bar <foo@example.com>",
99
"license": "MIT",
1010
"build": {
11-
"electronVersion": "1.6.6",
11+
"electronVersion": "1.7.1",
1212
"appId": "org.electron-builder.testApp",
1313
"compression": "store",
1414
"npmRebuild": false,

test/fixtures/test-app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"private": true,
33
"build": {
4-
"electronVersion": "1.6.6",
4+
"electronVersion": "1.7.1",
55
"appId": "org.electron-builder.testApp",
66
"compression": "store",
77
"npmRebuild": false,

0 commit comments

Comments
 (0)