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
  • Loading branch information
develar committed May 23, 2017
1 parent eb181b9 commit d47c37a
Show file tree
Hide file tree
Showing 11 changed files with 64 additions and 101 deletions.
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
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"
81 changes: 32 additions & 49 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@
version "3.5.30"
resolved "https://registry.yarnpkg.com/@types/js-yaml/-/js-yaml-3.5.30.tgz#f555118c022318e57e36d803379cb8ee38ee20a7"

"@types/node-forge@^0.6.8":
version "0.6.8"
resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-0.6.8.tgz#fb38ae420be9c9b679bed3f974201120947b920f"
"@types/node-forge@^0.6.9":
version "0.6.9"
resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-0.6.9.tgz#38e0e00de8e6f3ff0bb1f4cddcad43e7b580733a"

"@types/node@*":
version "7.0.21"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.21.tgz#22a890f19b26cff9b6699b493dea1bcee4410da1"
version "7.0.22"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.22.tgz#4593f4d828bdd612929478ea40c67b4f403ca255"

"@types/source-map-support@^0.2.28":
version "0.2.28"
Expand Down Expand Up @@ -258,8 +258,8 @@ async@^1.4.0:
resolved "https://registry.yarnpkg.com/async/-/async-1.5.2.tgz#ec6a61ae56480c0c3cb241c95618e20892f9672a"

async@^2.0.0, async@^2.1.4:
version "2.4.0"
resolved "https://registry.yarnpkg.com/async/-/async-2.4.0.tgz#4990200f18ea5b837c2cc4f8c031a6985c385611"
version "2.4.1"
resolved "https://registry.yarnpkg.com/async/-/async-2.4.1.tgz#62a56b279c98a11d0987096a01cc3eeb8eb7bbd7"
dependencies:
lodash "^4.14.0"

Expand All @@ -271,9 +271,9 @@ asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"

aws-sdk@^2.54.0:
version "2.54.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.54.0.tgz#de97bdc82a975a71ad9f63192c8c75f623992c18"
aws-sdk@^2.55.0:
version "2.55.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.55.0.tgz#7528f3729ecbc8e5aea42ac89e1ff2537086f7c2"
dependencies:
buffer "5.0.6"
crypto-browserify "1.0.9"
Expand Down Expand Up @@ -785,12 +785,12 @@ combined-stream@^1.0.5, combined-stream@~1.0.5:
delayed-stream "~1.0.0"

command-line-args@^4.0.1:
version "4.0.4"
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-4.0.4.tgz#6b9ab497cfe82d2c1ce1e47d6c18a85382f5d9fe"
version "4.0.5"
resolved "https://registry.yarnpkg.com/command-line-args/-/command-line-args-4.0.5.tgz#c7beccd6641f525ed6f292e17084ab3231b301be"
dependencies:
array-back "^1.0.4"
find-replace "^1.0.3"
typical "^2.6.0"
typical "^2.6.1"

command-line-tool@^0.7.0:
version "0.7.0"
Expand Down Expand Up @@ -1088,9 +1088,9 @@ electron-is-dev@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/electron-is-dev/-/electron-is-dev-0.1.2.tgz#8a1043e32b3a1da1c3f553dce28ce764246167e3"

[email protected].4:
version "0.4.4"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.4.tgz#afdf38450ccaebe6dabeca71fb0fad6294a8c57c"
[email protected].5:
version "0.4.5"
resolved "https://registry.yarnpkg.com/electron-osx-sign/-/electron-osx-sign-0.4.5.tgz#59037cae6ac05ba9e802f76d9bb772b31a8c75c7"
dependencies:
bluebird "^3.4.7"
compare-version "^0.1.2"
Expand Down Expand Up @@ -1285,12 +1285,6 @@ find-up@^2.0.0, find-up@^2.1.0:
dependencies:
locate-path "^2.0.0"

findup-sync@~0.3.0:
version "0.3.0"
resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-0.3.0.tgz#37930aa5d816b777c03445e1966cc6790a4c0b16"
dependencies:
glob "~5.0.0"

for-in@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"
Expand Down Expand Up @@ -1385,16 +1379,6 @@ glob@^7.0.0, glob@^7.0.3, glob@^7.0.5, glob@^7.1.0, glob@^7.1.1, glob@~7.1.1:
once "^1.3.0"
path-is-absolute "^1.0.0"

glob@~5.0.0:
version "5.0.15"
resolved "https://registry.yarnpkg.com/glob/-/glob-5.0.15.tgz#1bc936b9e02f4a603fcc222ecf7633d30b8b93b1"
dependencies:
inflight "^1.0.4"
inherits "2"
minimatch "2 || 3"
once "^1.3.0"
path-is-absolute "^1.0.0"

globals@^9.0.0:
version "9.17.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-9.17.0.tgz#0c0ca696d9b9bb694d2e5470bd37777caad50286"
Expand Down Expand Up @@ -1443,8 +1427,8 @@ [email protected]:
uglify-js "~2.3"

handlebars@^4.0.3:
version "4.0.8"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.8.tgz#22b875cd3f0e6cbea30314f144e82bc7a72ff420"
version "4.0.10"
resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.10.tgz#3d30c718b09a3d96f23ea4cc1f403c4d3ba9ff4f"
dependencies:
async "^1.4.0"
optimist "^0.6.1"
Expand Down Expand Up @@ -2324,7 +2308,7 @@ mimic-fn@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-1.1.0.tgz#e667783d92e89dbd342818b5230b9d62a672ad18"

"minimatch@2 || 3", minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
minimatch@^3.0.2, minimatch@^3.0.3, minimatch@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083"
dependencies:
Expand Down Expand Up @@ -2443,8 +2427,8 @@ number-is-nan@^1.0.0:
resolved "https://registry.yarnpkg.com/number-is-nan/-/number-is-nan-1.0.1.tgz#097b602b53422a522c1afb8790318336941a011d"

"nwmatcher@>= 1.3.9 < 2.0.0":
version "1.3.9"
resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.3.9.tgz#8bab486ff7fa3dfd086656bbe8b17116d3692d2a"
version "1.4.0"
resolved "https://registry.yarnpkg.com/nwmatcher/-/nwmatcher-1.4.0.tgz#b4389362170e7ef9798c3c7716d80ebc0106fccf"

oauth-sign@~0.8.1:
version "0.8.2"
Expand Down Expand Up @@ -3321,24 +3305,23 @@ tslib@^1.6.0:
version "1.7.1"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.7.1.tgz#bc8004164691923a79fe8378bbeb3da2017538ec"

tslint@^5.2.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.2.0.tgz#16a2addf20cb748385f544e9a0edab086bc34114"
tslint@^5.3.2:
version "5.3.2"
resolved "https://registry.yarnpkg.com/tslint/-/tslint-5.3.2.tgz#e56459fb095a7307f103b84052174f5e3bbef6ed"
dependencies:
babel-code-frame "^6.22.0"
colors "^1.1.2"
diff "^3.2.0"
findup-sync "~0.3.0"
glob "^7.1.1"
optimist "~0.6.0"
resolve "^1.3.2"
semver "^5.3.0"
tslib "^1.6.0"
tsutils "^1.8.0"
tsutils "^2.0.0"

tsutils@^1.8.0:
version "1.9.1"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-1.9.1.tgz#b9f9ab44e55af9681831d5f28d0aeeaf5c750cb0"
tsutils@^2.0.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/tsutils/-/tsutils-2.1.0.tgz#5be8376c929528f65b302de9e17b0004e4c1eb20"

tunnel-agent@^0.6.0:
version "0.6.0"
Expand All @@ -3356,15 +3339,15 @@ type-check@~0.3.2:
dependencies:
prelude-ls "~1.1.2"

typescript@^2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.2.tgz#f0f045e196f69a72f06b25fd3bd39d01c3ce9984"
typescript@^2.3.3:
version "2.3.3"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.3.tgz#9639f3c3b40148e8ca97fe08a51dd1891bb6be22"

typescript@~2.1.5:
version "2.1.6"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.1.6.tgz#40c7e6e9e5da7961b7718b55505f9cac9487a607"

typical@^2.4.2, typical@^2.6.0:
typical@^2.4.2, typical@^2.6.0, typical@^2.6.1:
version "2.6.1"
resolved "https://registry.yarnpkg.com/typical/-/typical-2.6.1.tgz#5c080e5d661cbbe38259d2e70a3c7253e873881d"

Expand Down

0 comments on commit d47c37a

Please sign in to comment.