Skip to content

Commit

Permalink
fix(electron-updater): fix missed path in the log messages
Browse files Browse the repository at this point in the history
url.format doesn't correctly use path and requires explicit pathname
  • Loading branch information
develar committed Feb 13, 2017
1 parent c732db2 commit 8a75cbb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 29 deletions.
53 changes: 29 additions & 24 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,16 @@
You decided to contribute to this project? Great, thanks a lot for pushing it.

## Issues

When filing an issue please make sure, that you give all information needed.

This includes:
## Pull Requests
To check that your contributions match the project coding style make sure `npm test` passes.

- description of what you're trying to do
- package.json
- log of the terminal output
- node version
- npm version
- on which system do you want to create installers (macOS, Linux or Windows).
1. [yarn](https://yarnpkg.com) is required because NPM is not reliable.
2. [git-lfs](https://git-lfs.github.com) is required (use `git lfs pull` to download files when git-lfs was installed after git clone).

# Pull Requests
To check that your contributions match the project coding style make sure `npm test` passes.
To build project: `yarn && yarn compile`

[git-lfs](https://git-lfs.github.com) is required (use `git lfs pull` to download files when git-lfs was installed after git clone).
If you get strange compilation errors, try to remove all `node_modules` in the project (especially under `packages/*`).

## Git Commit Guidelines
### 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)).
Expand All @@ -42,7 +34,7 @@ Example — `fix: remove unused dependency lodash.camelcase`

Any line of the commit message cannot be longer 100 characters. This allows the message to be easier to read on GitHub as well as in various git tools.

### Type
#### Type
Must be one of the following:

* **feat**: A new feature.
Expand All @@ -54,34 +46,34 @@ Must be one of the following:
* **test**: Adding missing tests.
* **chore**: Changes to the build process or auxiliary tools and libraries such as documentation generation.

### Scope
#### Scope
The scope is optional and could be anything specifying place of the commit change. For example `nsis`, `mac`, `linux`, etc...

### Subject
#### Subject
The subject contains succinct description of the change:

* use the imperative, present tense: `change` not `changed` nor `changes`,
* don't capitalize first letter,
* no dot (.) at the end.

### Body
#### Body
Just as in the **subject**, use the imperative, present tense: "change" not "changed" nor "changes".
The body should include the motivation for the change and contrast this with previous behavior.

### Footer
#### Footer
The footer should contain any information about **Breaking Changes** and is also the place to reference GitHub issues that this commit **Closes**.

**Breaking Changes** should start with the word `BREAKING CHANGE:` with a space or two newlines. The rest of the commit message is then used for this.

A detailed explanation can be found in this [document](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#).

# Documentation
## Documentation

Don't edit wiki directly. Instead, edit files in the `/docs`.

`/docs` is synced to wiki using git subtree merge when `next` release is marked as `latest` and available for all users.

# Debug Tests
## Debug Tests

Only IntelliJ Platform IDEs ([IntelliJ IDEA](https://confluence.jetbrains.com/display/IDEADEV/IDEA+2017.1+EAP), [WebStorm](https://confluence.jetbrains.com/display/WI/WebStorm+EAP)) support debug. Please prefer to use 2017.1.

Expand All @@ -97,11 +89,24 @@ Or you can create Node.js run configuration manually:
* Set `Environment Variables`:
* Optionally, `TEST_APP_TMP_DIR` to some directory (e.g. `/tmp/electron-builder-test`) to inspect output if test uses temporary directory (only if `--match` is used). Specified directory will be used instead of random temporary directory and *cleared* on each run.

## Run Test using CLI
### Run Test using CLI
```sh
TEST_APP_TMP_DIR=/tmp/electron-builder-test ./node_modules/.bin/jest --env jest-environment-node-debug -t 'boring' '/TestFileName\.\w+$'
```

where `TEST_APP_TMP_DIR` is specified to easily inspect and use test build, `boring` is the test name and `test/out/nsisTest.js` is the path to test file.

Do not forget to execute `yarn compile` before run.
Do not forget to execute `yarn compile` before run.

## Issues

When filing an issue please make sure, that you give all information needed.

This includes:

- description of what you're trying to do
- package.json
- log of the terminal output
- node version
- npm version
- on which system do you want to create installers (macOS, Linux or Windows).
18 changes: 13 additions & 5 deletions packages/electron-updater/src/GitHubProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { validateUpdateInfo } from "./GenericProvider"
import * as path from "path"
import { HttpError, request } from "electron-builder-http"
import { CancellationToken } from "electron-builder-http/out/CancellationToken"
import * as url from "url"
import { Url, parse as parseUrl, format as buggyFormat } from "url"
import { RequestOptions } from "http"

export class GitHubProvider extends Provider<VersionInfo> {
Expand All @@ -14,7 +14,7 @@ export class GitHubProvider extends Provider<VersionInfo> {
constructor(private readonly options: GithubOptions) {
super()

const baseUrl = url.parse(`${options.protocol || "https:"}//${options.host || "github.com"}`)
const baseUrl = parseUrl(`${options.protocol || "https"}://${options.host || "github.com"}`)
this.baseUrl = {
protocol: baseUrl.protocol,
hostname: baseUrl.hostname,
Expand All @@ -34,7 +34,7 @@ export class GitHubProvider extends Provider<VersionInfo> {
}
catch (e) {
if (e instanceof HttpError && e.response.statusCode === 404) {
throw new Error(`Cannot find ${channelFile} in the latest release artifacts (${url.format(<any>requestOptions)}): ${e.stack || e.message}`)
throw new Error(`Cannot find ${channelFile} in the latest release artifacts (${formatUrl(<any>requestOptions)}): ${e.stack || e.message}`)
}
throw e
}
Expand All @@ -57,7 +57,7 @@ export class GitHubProvider extends Provider<VersionInfo> {
return (releaseInfo.tag_name.startsWith("v")) ? releaseInfo.tag_name.substring(1) : releaseInfo.tag_name
}
catch (e) {
throw new Error(`Unable to find latest version on GitHub (${url.format(<any>requestOptions)}), please ensure a production release exists: ${e.stack || e.message}`)
throw new Error(`Unable to find latest version on GitHub (${formatUrl(<any>requestOptions)}), please ensure a production release exists: ${e.stack || e.message}`)
}
}

Expand All @@ -75,12 +75,20 @@ export class GitHubProvider extends Provider<VersionInfo> {
const name = versionInfo.githubArtifactName || path.posix.basename(versionInfo.path).replace(/ /g, "-")
return {
name: name,
url: url.format(Object.assign({pathname: `${basePath}/download/v${versionInfo.version}/${name}`}, this.baseUrl)),
url: formatUrl(Object.assign({path: `${basePath}/download/v${versionInfo.version}/${name}`}, this.baseUrl)),
sha2: versionInfo.sha2,
}
}
}

interface GithubReleaseInfo {
readonly tag_name: string
}

// url.format doesn't correctly use path and requires explicit pathname
function formatUrl(url: Url) {
if (url.path != null && url.pathname == null) {
url.pathname = url.path
}
return buggyFormat(url)
}

0 comments on commit 8a75cbb

Please sign in to comment.