Skip to content

Commit

Permalink
fix: NSIS LZMA compression is slower and worse then external 7z compr…
Browse files Browse the repository at this point in the history
…ession

before: 36.3
after: 32.8

Compression speed is also reduced (25 sec vs 1+ minutes) because 7za is multi-threaded
  • Loading branch information
develar committed Jun 17, 2016
1 parent df096f0 commit e1e6d67
Show file tree
Hide file tree
Showing 35 changed files with 600 additions and 297 deletions.
5 changes: 5 additions & 0 deletions .idea/dictionaries/develar.xml

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

4 changes: 4 additions & 0 deletions .idea/runConfigurations/linuxPackagerTest.xml

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

2 changes: 1 addition & 1 deletion docker/6/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM electronuserland/electron-builder:base

ENV NODE_VERSION 6.2.0
ENV NODE_VERSION 6.2.1

# https://github.com/npm/npm/issues/4531
RUN curl -SLO "https://nodejs.org/dist/v$NODE_VERSION/node-v$NODE_VERSION-linux-x64.tar.xz" \
Expand Down
2 changes: 2 additions & 0 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ MAS (Mac Application Store) specific options (in addition to `build.osx`).

NSIS target support in progress — not polished and not fully tested and checked.

See [NSIS target notes](https://github.com/electron-userland/electron-builder/wiki/NSIS).

| Name | Description
| --- | ---
| perMachine | <a name="NsisOptions-perMachine"></a>Mark "all users" (per-machine) as default. Not recommended. Defaults to `false`.
Expand Down
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,16 @@
"homepage": "https://github.com/electron-userland/electron-builder",
"dependencies": {
"7zip-bin": "^1.0.5",
"ansi-escapes": "^1.4.0",
"asar": "^0.11.0",
"bluebird": "^3.4.0",
"chalk": "^1.1.3",
"cli-cursor": "^1.0.2",
"compare-versions": "^2.0.2",
"debug": "^2.2.0",
"deep-assign": "^2.0.0",
"electron-osx-sign-tf": "0.6.0",
"electron-packager-tf": "~7.3.2",
"electron-packager-tf": "~7.3.3",
"electron-winstaller-fixed": "~2.10.1",
"fs-extra-p": "^1.0.2",
"glob": "^7.0.3",
Expand All @@ -74,9 +76,12 @@
"lodash.template": "^4.2.5",
"mime": "^1.3.4",
"minimatch": "^3.0.0",
"pretty-ms": "^2.1.0",
"progress": "^1.1.8",
"progress-stream": "^1.2.0",
"read-package-json": "^2.0.4",
"sanitize-filename": "^1.6.0",
"semver": "^5.1.0",
"signcode-tf": "~0.7.3",
"source-map-support": "^0.4.0",
"uuid-1345": "^0.99.6",
Expand All @@ -94,6 +99,7 @@
]
},
"devDependencies": {
"@types/semver": "^4.3.20-alpha",
"ava-tf": "^0.15",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
Expand All @@ -111,7 +117,7 @@
"ts-babel": "^1.0.2",
"tsconfig-glob": "^0.4.3",
"tslint": "3.11.0-dev.0",
"typescript": "^1.9.0-dev.20160611-1.0",
"typescript": "^1.9.0-dev.20160617-1.0",
"whitespace": "^2.0.0"
},
"babel": {
Expand Down
93 changes: 93 additions & 0 deletions src/appInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
import { ElectronPackagerOptions } from "electron-packager-tf"
import { DevMetadata, AppMetadata } from "./metadata"
import { warn } from "./log"
import { smarten } from "./platformPackager"
import { isEmptyOrSpaces } from "./util"
import { getRepositoryInfo } from "./repositoryInfo"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

export class AppInfo {
readonly description = smarten(this.metadata.description)

// windows-only
versionString = {
CompanyName: this.companyName,
FileDescription: this.description,
ProductName: this.productName,
InternalName: this.productName,
LegalCopyright: this.copyright,
}

readonly version: string
readonly buildVersion: string

constructor(public metadata: AppMetadata, private devMetadata: DevMetadata) {
let buildVersion = metadata.version
this.version = buildVersion

const buildNumber = this.buildNumber
if (!isEmptyOrSpaces(buildNumber)) {
buildVersion += `.${buildNumber}`
}
this.buildVersion = buildVersion
}

get companyName() {
return this.metadata.author.name
}

get buildNumber(): string | null {
return this.devMetadata.build["build-version"] || process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM || process.env.BUILD_NUMBER
}

get id(): string {
const appId = this.devMetadata.build["app-bundle-id"]
if (appId != null) {
warn("app-bundle-id is deprecated, please use appId")
}

if (this.devMetadata.build.appId != null) {
return this.devMetadata.build.appId
}

if (appId == null) {
return `com.electron.${this.metadata.name.toLowerCase()}`
}
return appId
}

get name(): string {
return this.metadata.name
}

get productName(): string {
return getProductName(this.metadata, this.devMetadata)
}

get copyright(): string {
const copyright = (<ElectronPackagerOptions>this.devMetadata.build)["app-copyright"]
if (copyright != null) {
return copyright
}
return `Copyright © ${new Date().getFullYear()} ${this.metadata.author.name || this.productName}`
}

async computePackageUrl(): Promise<string | null> {
const url = this.metadata.homepage || this.devMetadata.homepage
if (url != null) {
return url
}

const info = await getRepositoryInfo(this.metadata, this.devMetadata)
if (info != null) {
return `https://github.com/${info.user}/${info.project}`
}
return null
}
}

function getProductName(metadata: AppMetadata, devMetadata: DevMetadata) {
return devMetadata.build.productName || metadata.productName || metadata.name
}
16 changes: 8 additions & 8 deletions src/builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import { PackagerOptions } from "./platformPackager"
import { PublishOptions, Publisher, GitHubPublisher } from "./gitHubPublisher"
import { executeFinally } from "./promise"
import { Promise as BluebirdPromise } from "bluebird"
import { InfoRetriever } from "./repositoryInfo"
import { log, warn, isEmptyOrSpaces } from "./util"
import { isEmptyOrSpaces } from "./util"
import { log, warn } from "./log"
import { Platform, Arch, archFromString } from "./metadata"
import { getRepositoryInfo } from "./repositoryInfo"

//noinspection JSUnusedLocalSymbols
const __awaiter = require("./awaiter")

export async function createPublisher(packager: Packager, options: PublishOptions, repoSlug: InfoRetriever, isPublishOptionGuessed: boolean = false): Promise<Publisher | null> {
const info = await repoSlug.getInfo(packager)
export async function createPublisher(packager: Packager, options: PublishOptions, isPublishOptionGuessed: boolean = false): Promise<Publisher | null> {
const info = await getRepositoryInfo(packager.metadata, packager.devMetadata)
if (info == null) {
if (isPublishOptionGuessed) {
return null
Expand Down Expand Up @@ -207,7 +208,7 @@ export async function build(rawOptions?: CliOptions): Promise<void> {
else if (options.githubToken != null) {
const tag = process.env.TRAVIS_TAG || process.env.APPVEYOR_REPO_TAG_NAME || process.env.CIRCLE_TAG
if (tag != null && tag.length !== 0) {
log("Tag %s is defined, so artifacts will be published", tag)
log(`Tag ${tag} is defined, so artifacts will be published`)
options.publish = "onTag"
isPublishOptionGuessed = true
}
Expand All @@ -220,13 +221,12 @@ export async function build(rawOptions?: CliOptions): Promise<void> {
}

const publishTasks: Array<BluebirdPromise<any>> = []
const repositoryInfo = new InfoRetriever()
const packager = new Packager(options, repositoryInfo)
const packager = new Packager(options)
if (options.publish != null && options.publish !== "never") {
let publisher: Promise<Publisher> | null = null
packager.artifactCreated(event => {
if (publisher == null) {
publisher = createPublisher(packager, options, repositoryInfo, isPublishOptionGuessed)
publisher = createPublisher(packager, options, isPublishOptionGuessed)
}

if (publisher) {
Expand Down
15 changes: 10 additions & 5 deletions src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Release, Asset } from "gh-release"
import { log, warn, isEmptyOrSpaces } from "./util"
import { isEmptyOrSpaces } from "./util"
import { log, warn } from "./log"
import { basename } from "path"
import { parse as parseUrl } from "url"
import * as mime from "mime"
Expand Down Expand Up @@ -73,7 +74,7 @@ export class GitHubPublisher implements Publisher {
}

if (createReleaseIfNotExists) {
log("Release %s doesn't exists, creating one", this.tag)
log(`Release this.tag doesn't exists, creating one`)
return this.createRelease()
}
else {
Expand Down Expand Up @@ -117,15 +118,19 @@ export class GitHubPublisher implements Publisher {
.pipe(progressStream({
length: fileStat.size,
time: 1000
}, progress => progressBar == null ? console.log(".") : progressBar.tick(progress.delta)))
}, progress => {
if (progressBar != null) {
progressBar.tick(progress.delta)
}
}))
.pipe(request)
})
}
catch (e) {
if (e instanceof HttpError) {
if (e.response.statusCode === 422 && e.description != null && e.description.errors != null && e.description.errors[0].code === "already_exists") {
// delete old artifact and re-upload
log("Artifact %s already exists, overwrite one", fileName)
log(`Artifact ${fileName} already exists, overwrite one`)
const assets = await gitHubRequest<Array<Asset>>(`/repos/${this.owner}/${this.repo}/releases/${release.id}/assets`, this.token)
for (let asset of assets) {
if (asset!.name === fileName) {
Expand All @@ -134,7 +139,7 @@ export class GitHubPublisher implements Publisher {
}
}

log("Artifact %s not found, trying to upload again", fileName)
log(`Artifact ${fileName} not found, trying to upload again`)
continue
}
else if (e.response.statusCode === 502 && badGatewayCount++ < 3) {
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export { Packager } from "./packager"
export { PackagerOptions, ArtifactCreated, DIR_TARGET, BuildInfo } from "./platformPackager"
export { BuildOptions, build, createPublisher, CliOptions, createTargets } from "./builder"
export { PublishOptions, Publisher } from "./gitHubPublisher"
export { AppMetadata, DevMetadata, Platform, Arch, archFromString, getProductName, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions, CompressionLevel } from "./metadata"
export { AppMetadata, DevMetadata, Platform, Arch, archFromString, BuildMetadata, OsXBuildOptions, WinBuildOptions, LinuxBuildOptions, CompressionLevel } from "./metadata"
Loading

0 comments on commit e1e6d67

Please sign in to comment.