Skip to content

Commit

Permalink
refactor: extract electron-builder-http
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Dec 29, 2016
1 parent 920c230 commit 23b4fe4
Show file tree
Hide file tree
Showing 39 changed files with 358 additions and 268 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ dist/
/test/typings/electron-builder.d.ts
/test/typings/electron-auto-updater.d.ts

/nsis-auto-updater/out/
/packages/*/out/
/out/
# to not exclude .js.snap (jest snapshots)
/test/out/**/*.js
Expand Down
1 change: 1 addition & 0 deletions .idea/dictionaries/develar.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 0 additions & 44 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,6 @@ Don't customize paths to background and icon, — just follow conventions.
* [.build.mas](#MasBuildOptions)
* [.build.nsis](#NsisOptions)
* [.build.protocols](#Protocol)
* [.build.publish](#PublishConfiguration)
* [.build.publish Bintray](#BintrayOptions)
* [.build.publish Generic (any https server)](#GenericServerOptions)
* [.build.publish GitHub](#GithubOptions)
* [.build.snap](#SnapOptions)
* [.build.squirrelWindows](#SquirrelWindowsOptions)
* [.build.win](#WinBuildOptions)
Expand Down Expand Up @@ -231,46 +227,6 @@ Please note — on macOS [you need to register an `open-url` event handler](http
| role | <a name="Protocol-role"></a>*macOS-only* The app’s role with respect to the type. The value can be `Editor`, `Viewer`, `Shell`, or `None`. Defaults to `Editor`.
| **schemes** | <a name="Protocol-schemes"></a>The schemes. e.g. `["irc", "ircs"]`.

<a name="PublishConfiguration"></a>
### `.build.publish`

Can be specified in the [build](https://github.com/electron-userland/electron-builder/wiki/Options#build) or any platform- or target- specific options.
Please see [Publishing Artifacts](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts).

If `GH_TOKEN` is set — defaults to `[{provider: "github"}]`.
If `BT_TOKEN` is set and `GH_TOKEN` is not set — defaults to `[{provider: "bintray"}]`.

Array of option objects. Order is important — first item will be used as a default auto-update server on Windows (NSIS).

Amazon S3 — `https` must be used, so, if you use direct Amazon S3 endpoints, format `https://s3.amazonaws.com/bucket_name` [must be used](http://stackoverflow.com/a/11203685/1910191). And do not forget to make files/directories public.

| Name | Description
| --- | ---
| **provider** | <a name="PublishConfiguration-provider"></a>The provider, one of `github`, `bintray`, `generic`.
| owner | <a name="PublishConfiguration-owner"></a>The owner.

<a name="BintrayOptions"></a>
### `.build.publish` Bintray
| Name | Description
| --- | ---
| package | <a name="BintrayOptions-package"></a>The Bintray package name.
| repo | <a name="BintrayOptions-repo"></a>The Bintray repository name. Defaults to `generic`.
| user | <a name="BintrayOptions-user"></a>The Bintray user account. Used in cases where the owner is an organization.

<a name="GenericServerOptions"></a>
### `.build.publish` Generic (any https server)
| Name | Description
| --- | ---
| **url** | <a name="GenericServerOptions-url"></a>The base url. e.g. `https://s3.amazonaws.com/bucket_name`
| channel | <a name="GenericServerOptions-channel"></a>The channel. Defaults to `latest`.

<a name="GithubOptions"></a>
### `.build.publish` GitHub
| Name | Description
| --- | ---
| repo | <a name="GithubOptions-repo"></a>The repository name. [Detected automatically](https://github.com/electron-userland/electron-builder/wiki/Publishing-Artifacts#github-repository).
| vPrefixedTagName | <a name="GithubOptions-vPrefixedTagName"></a>Whether to use `v`-prefixed tag name. Defaults to `true`.

<a name="SnapOptions"></a>
### `.build.snap`

Expand Down
7 changes: 7 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"lerna": "2.0.0-beta.31",
"packages": [
"packages/*"
],
"version": "independent"
}
165 changes: 0 additions & 165 deletions nsis-auto-updater/yarn.lock

This file was deleted.

13 changes: 8 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@
"node-gyp-rebuild": "./out/cli/node-gyp-rebuild.js"
},
"scripts": {
"compile": "ts-babel . nsis-auto-updater test",
"compile": "ts-babel packages/electron-builder-http . packages/nsis-auto-updater test",
"lint": "node ./test/lint.js",
"pretest": "node ./test/vendor/yarn.js run compile && node ./test/vendor/yarn.js run lint",
"check-deps": "node ./test/out/helpers/checkDeps.js",
"test": "node ./test/out/helpers/runTests.js",
"test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh",
"pack-updater": "cd nsis-auto-updater && node ./test/vendor/yarn.js --production && cd ..",
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
"//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)",
"update-wiki": "git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master",
"whitespace": "whitespace 'src/**/*.ts'",
"docker-images": "docker/build.sh",
"test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11"
"test-deps-mac": "brew install rpm dpkg mono lzip gnu-tar graphicsmagick xz && brew install wine --without-x11",
"postinstall": "lerna bootstrap"
},
"repository": "electron-userland/electron-builder",
"engines": {
Expand Down Expand Up @@ -94,7 +94,8 @@
"tunnel-agent": "^0.4.3",
"update-notifier": "^1.0.3",
"uuid-1345": "^0.99.6",
"yargs": "^6.5.0"
"yargs": "^6.5.0",
"electron-builder-http": "1.0.0"
},
"devDependencies": {
"@develar/semantic-release": "^6.3.26",
Expand All @@ -113,6 +114,7 @@
"depcheck": "^0.6.7",
"jest-cli": "^18.0.0",
"jest-environment-node-debug": "^0.0.2",
"lerna": "2.0.0-beta.31",
"path-sort": "^0.1.0",
"ts-babel": "^1.2.2",
"tslint": "^4.2.0",
Expand All @@ -129,7 +131,8 @@
],
"testRegex": "\\.js$",
"modulePaths": [
"<rootDir>"
"<rootDir>",
"<rootDir>/packages"
],
"setupTestFrameworkScriptFile": "<rootDir>/test/jestSetup.js"
},
Expand Down
16 changes: 16 additions & 0 deletions packages/electron-builder-http/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "electron-builder-http",
"version": "1.0.0",
"main": "out/main.js",
"author": "Vladimir Krivosheev",
"license": "MIT",
"repository": "electron-userland/electron-builder",
"bugs": "https://github.com/electron-userland/electron-builder/issues",
"homepage": "https://github.com/electron-userland/electron-builder",
"files": [
"out"
],
"dependencies": {
},
"typings": "./out/electron-builder-http.d.ts"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BintrayOptions } from "../options/publishOptions"
import { request } from "../util/httpExecutor"
export { HttpError, request } from "../util/httpExecutor"
import { BintrayOptions } from "./publishOptions"
import { request } from "./httpExecutor"
export { HttpError, request } from "./httpExecutor"

export function bintrayRequest<T>(path: string, auth: string | null, data: {[name: string]: any; } | null = null, method: string = "GET"): Promise<T> {
return request<T>({hostname: "api.bintray.com", path: path}, auth, data, method)
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { DownloadOptions, executorHolder } from "./httpExecutor"


export function download(url: string, destination: string, options?: DownloadOptions | null): Promise<string> {
return executorHolder.httpExecutor.download(url, destination, options)
}
File renamed without changes.
24 changes: 24 additions & 0 deletions packages/electron-builder-http/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "es2015",
"target": "es2017",
"noImplicitAny": true,
"outDir": "out",
"newLine": "LF",
"noEmitOnError": true,
"inlineSources": true,
"sourceMap": true,
"noImplicitReturns": true,
"strictNullChecks": true,
"noEmitHelpers": true,
"noFallthroughCasesInSwitch": true,
"noUnusedLocals": true,
"skipLibCheck": true
},
"declaration": {
"electron-builder-http": "out/electron-builder-http.d.ts"
},
"include": [
"src/**/*.ts"
]
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"fs-extra-p": "^3.0.3",
"js-yaml": "^3.7.0",
"semver": "^5.3.0",
"source-map-support": "^0.4.8"
"source-map-support": "^0.4.8",
"electron-builder-http": "1.0.0"
},
"typings": "./out/electron-auto-updater.d.ts"
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Provider, FileInfo } from "./api"
import { BintrayClient, HttpError } from "../../src/publish/bintray"
import { BintrayOptions, VersionInfo } from "../../src/options/publishOptions"
import { BintrayClient, HttpError } from "electron-builder-http/out/bintray"
import { BintrayOptions, VersionInfo } from "electron-builder-http/out/publishOptions"

export class BintrayProvider implements Provider<VersionInfo> {
private client: BintrayClient
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Provider, FileInfo } from "./api"
import { GenericServerOptions, UpdateInfo } from "../../src/options/publishOptions"
import { GenericServerOptions, UpdateInfo } from "electron-builder-http/out/publishOptions"
import * as url from "url"
import * as path from "path"
import { HttpError, request } from "../../src/util/httpExecutor"
import { HttpError, request } from "electron-builder-http/out/httpExecutor"

export class GenericProvider implements Provider<UpdateInfo> {
private readonly baseUrl = url.parse(this.configuration.url)
Expand Down
Loading

0 comments on commit 23b4fe4

Please sign in to comment.