Skip to content

Commit 4c71fc0

Browse files
committed
fix(deployment): check for errors
1 parent d7c6eea commit 4c71fc0

File tree

13 files changed

+69
-28
lines changed

13 files changed

+69
-28
lines changed

.babelrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
excludeModules: ["path"]
2020
}
2121
],
22+
"./packages/babel-plugin-version-transform.js",
2223
],
2324
},
2425
test: {

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"repository": "electron-userland/electron-builder",
2828
"///": "all dependencies for all packages (hoisted)",
2929
"dependencies": {
30-
"7zip-bin": "^2.0.4",
30+
"7zip-bin": "^2.1.0",
3131
"ajv": "^5.1.5",
3232
"ajv-keywords": "^2.1.0",
3333
"archiver": "^1.3.0",
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
const path = require("path")
2+
const version = require(path.join(__dirname, "electron-builder/package.json")).version
3+
4+
Object.defineProperty(exports, "__esModule", {
5+
value: true
6+
});
7+
exports.default = function versionTransform() {
8+
return {
9+
visitor: {
10+
Identifier(path) {
11+
if (path.node.name === 'PACKAGE_VERSION') {
12+
path.replaceWithSourceString('"' + version + '"');
13+
}
14+
},
15+
},
16+
};
17+
};
18+

packages/electron-builder-util/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"node-emoji": "^1.5.1",
2121
"electron-builder-http": "~0.0.0-semantic-release",
2222
"source-map-support": "^0.4.15",
23-
"7zip-bin": "^2.0.4",
23+
"7zip-bin": "^2.1.0",
2424
"ini": "^1.3.4",
2525
"tunnel-agent": "^0.6.0"
2626
},

packages/electron-builder-util/src/nodeHttpExecutor.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { parse as parseIni } from "ini"
99
import { homedir } from "os"
1010
import * as path from "path"
1111
import { parse as parseUrl } from "url"
12+
import { safeStringifyJson } from "./util"
1213

1314
const debug = _debug("electron-builder")
1415

@@ -45,7 +46,7 @@ export class NodeHttpExecutor extends HttpExecutor<ClientRequest> {
4546

4647
doApiRequest<T>(options: RequestOptions, cancellationToken: CancellationToken, requestProcessor: (request: ClientRequest, reject: (error: Error) => void) => void, redirectCount: number = 0): Promise<T> {
4748
if (debug.enabled) {
48-
debug(`HTTPS request: ${JSON.stringify(options, null, 2)}`)
49+
debug(`HTTPS request: ${safeStringifyJson(options)}`)
4950
}
5051

5152
return cancellationToken.createPromise((resolve, reject, onCancel) => {

packages/electron-builder/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
"bugs": "https://github.com/electron-userland/electron-builder/issues",
4545
"homepage": "https://github.com/electron-userland/electron-builder",
4646
"dependencies": {
47-
"7zip-bin": "^2.0.4",
47+
"7zip-bin": "^2.1.0",
4848
"ajv": "^5.1.5",
4949
"ajv-keywords": "^2.1.0",
5050
"bluebird-lst": "^1.0.2",

packages/electron-builder/src/packager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function addHandler(emitter: EventEmitter, event: string, handler: Function) {
2626
emitter.on(event, handler)
2727
}
2828

29+
declare const PACKAGE_VERSION: string
30+
2931
export class Packager implements BuildInfo {
3032
readonly projectDir: string
3133
appDir: string
@@ -72,6 +74,8 @@ export class Packager implements BuildInfo {
7274
this.projectDir = options.projectDir == null ? process.cwd() : path.resolve(options.projectDir)
7375

7476
this.prepackaged = options.prepackaged == null ? null : path.resolve(this.projectDir, options.prepackaged)
77+
78+
log("electron-builder " + PACKAGE_VERSION)
7579
}
7680

7781
addAfterPackHandler(handler: (context: AfterPackContext) => Promise<any> | null) {
@@ -155,8 +159,11 @@ export class Packager implements BuildInfo {
155159
}
156160

157161
this.checkMetadata(appPackageFile, devPackageFile)
158-
159-
debug(`Effective config: ${safeStringifyJson(this.config)}`)
162+
163+
if (debug.enabled) {
164+
debug(`Effective config: ${safeStringifyJson(this.config)}`)
165+
}
166+
160167
checkConflictingOptions(this.config)
161168

162169
this.electronVersion = await getElectronVersion(this.config, projectDir, this.isPrepackedAppAsar ? this.metadata : null)

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

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,10 @@ export class PublishManager implements PublishContext {
156156
}
157157

158158
this.publishTasks.push(promise
159-
.catch(it => this.errors.push(it)))
159+
.catch(it => {
160+
debug(`Publish error: ${it.toString()}`)
161+
this.errors.push(it)
162+
}))
160163
}
161164

162165
private getOrCreatePublisher(publishConfig: PublishConfiguration, buildInfo: BuildInfo): Publisher | null {
@@ -180,17 +183,22 @@ export class PublishManager implements PublishContext {
180183
}
181184

182185
async awaitTasks() {
183-
if (this.errors.length > 0) {
184-
this.cancelTasks()
185-
throwError(this.errors)
186-
return
186+
const checkErrors = () => {
187+
if (this.errors.length > 0) {
188+
this.cancelTasks()
189+
throwError(this.errors)
190+
return
191+
}
187192
}
188193

194+
checkErrors()
195+
189196
const publishTasks = this.publishTasks
190197
let list = publishTasks.slice()
191198
publishTasks.length = 0
192199
while (list.length > 0) {
193200
await BluebirdPromise.all(list)
201+
checkErrors()
194202
if (publishTasks.length === 0) {
195203
break
196204
}
@@ -301,7 +309,7 @@ async function writeUpdateInfo(event: ArtifactCreated, _publishConfigs: Array<Pu
301309

302310
export function createPublisher(context: PublishContext, version: string, publishConfig: PublishConfiguration, options: PublishOptions): Publisher | null {
303311
if (debug.enabled) {
304-
debug(`create publisher: ${safeStringifyJson(publishConfig)} is not published: cancelled`)
312+
debug(`create publisher: ${safeStringifyJson(publishConfig)}`)
305313
}
306314

307315
const provider = publishConfig.provider

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.59.0",
15+
"aws-sdk": "^2.60.0",
1616
"mime": "^1.3.6",
1717
"electron-publish": "~0.0.0-semantic-release",
1818
"electron-builder-util": "~0.0.0-semantic-release"

test/src/ArtifactPublisherTest.ts

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,22 @@ function versionNumber() {
3434
const token = new Buffer("Y2Y5NDdhZDJhYzJlMzg1OGNiNzQzYzcwOWZhNGI0OTk2NWQ4ZDg3Yg==", "base64").toString()
3535
const iconPath = join(__dirname, "..", "fixtures", "test-app", "build", "icon.icns")
3636

37-
//test("GitHub unauthorized", async (t) => {
38-
// t.throws(await new GitHubPublisher("github-releases-test", "test-repo", versionNumber(), "incorrect token")
39-
// .releasePromise, /(Bad credentials|Unauthorized|API rate limit exceeded)/)
40-
//})
37+
const publishContext: PublishContext = {
38+
cancellationToken: new CancellationToken(),
39+
progress: null,
40+
}
41+
42+
test("GitHub unauthorized", async () => {
43+
try {
44+
await new GitHubPublisher(publishContext, {provider: "github", owner: "actperepo", repo: "ecb2", token: "incorrect token"}, versionNumber()).releasePromise
45+
}
46+
catch (e) {
47+
expect(e.message).toMatch(/(Bad credentials|Unauthorized|API rate limit exceeded)/)
48+
return
49+
}
50+
51+
throw new Error("must be error")
52+
})
4153

4254
function isApiRateError(e: Error): boolean {
4355
if (e.name === "HttpError") {
@@ -65,11 +77,6 @@ function testAndIgnoreApiRate(name: string, testFunction: () => Promise<any>) {
6577
})
6678
}
6779

68-
const publishContext: PublishContext = {
69-
cancellationToken: new CancellationToken(),
70-
progress: null,
71-
}
72-
7380
test("Bintray upload", async () => {
7481
const version = versionNumber()
7582

0 commit comments

Comments
 (0)