Skip to content

Commit

Permalink
WIP: Delta updates for NSIS #1523
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 22, 2017
1 parent e79a28c commit af77da8
Show file tree
Hide file tree
Showing 35 changed files with 421 additions and 169 deletions.
2 changes: 2 additions & 0 deletions .idea/dictionaries/develar.xml

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

1 change: 1 addition & 0 deletions .idea/electron-builder.iml

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

50 changes: 43 additions & 7 deletions docs/api/electron-builder.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
<dd></dd>
<dt><a href="#module_electron-builder/out/publish/PublishManager">electron-builder/out/publish/PublishManager</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/flags">electron-builder/out/util/flags</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/util/timer">electron-builder/out/util/timer</a></dt>
<dd></dd>
<dt><a href="#module_electron-builder/out/windowsCodeSign">electron-builder/out/windowsCodeSign</a></dt>
<dd></dd>
</dl>
Expand Down Expand Up @@ -96,15 +100,13 @@
| **config**| <code>[Config](Options#Config)</code> |
| **projectDir**| <code>String</code> |
| **appDir**| <code>String</code> |
| **electronVersion**| <code>String</code> |
| muonVersion| <code>String</code> \| <code>null</code> |
| **isTwoPackageJsonProjectLayoutUsed**| <code>Boolean</code> |
| **appInfo**| <code>[AppInfo](#AppInfo)</code> |
| **tempDirManager**| <code>module:electron-builder-util/out/tmp.TmpDir</code> |
| **repositoryInfo**| <code>Promise&lt; \| [SourceRepositoryInfo](#SourceRepositoryInfo)&gt;</code> |
| **isPrepackedAppAsar**| <code>Boolean</code> |
| prepackaged| <code>String</code> \| <code>null</code> |
| **cancellationToken**| <code>[CancellationToken](electron-builder-http#CancellationToken)</code> |
| **outDir**| <code>String</code> |


* [`.BuildInfo`](#BuildInfo)
Expand Down Expand Up @@ -217,13 +219,12 @@
| **isPrepackedAppAsar**| <code>Boolean</code> |
| **config**| <code>[Config](Options#Config)</code> |
| isTwoPackageJsonProjectLayoutUsed = <code>true</code>| <code>Boolean</code> |
| **electronVersion**| <code>String</code> |
| muonVersion| <code>String</code> \| <code>null</code> |
| eventEmitter = <code>new EventEmitter()</code>| <code>internal:EventEmitter</code> |
| **appInfo**| <code>[AppInfo](#AppInfo)</code> |
| tempDirManager = <code>new TmpDir()</code>| <code>module:electron-builder-util/out/tmp.TmpDir</code> |
| options| <code>[PackagerOptions](Options#PackagerOptions)</code> |
| **repositoryInfo**| <code>Promise&lt; \| [SourceRepositoryInfo](#SourceRepositoryInfo)&gt;</code> |
| prepackaged| <code>String</code> \| <code>null</code> |
| **outDir**| <code>String</code> |


* [.Packager](#Packager) ⇐ <code>[BuildInfo](#BuildInfo)</code>
Expand Down Expand Up @@ -407,7 +408,7 @@

| Name | Type |
| --- | --- |
| description = <code>&quot;smarten(this.metadata.description || \&quot;\&quot;)&quot;</code>| <code>String</code> |
| description = <code>&quot;smarten(this.info.metadata.description || \&quot;\&quot;)&quot;</code>| <code>String</code> |
| version| <code>String</code> |
| buildNumber| <code>String</code> |
| buildVersion| <code>String</code> |
Expand Down Expand Up @@ -788,6 +789,41 @@
| publishConfigs | <code>Array&lt;[PublishConfiguration](Publishing-Artifacts#PublishConfiguration)&gt;</code> \| <code>null</code> |
| arch | <code>[Arch](#Arch)</code> \| <code>null</code> |

<a name="module_electron-builder/out/util/flags"></a>
## electron-builder/out/util/flags

* [electron-builder/out/util/flags](#module_electron-builder/out/util/flags)
* [`.isUseSystemSigncode()`](#module_electron-builder/out/util/flags.isUseSystemSigncode) ⇒ <code>Boolean</code>
* [`.isUseSystemWine()`](#module_electron-builder/out/util/flags.isUseSystemWine) ⇒ <code>Boolean</code>

<a name="module_electron-builder/out/util/flags.isUseSystemSigncode"></a>
### `electron-builder/out/util/flags.isUseSystemSigncode()` ⇒ <code>Boolean</code>
**Kind**: method of [<code>electron-builder/out/util/flags</code>](#module_electron-builder/out/util/flags)
<a name="module_electron-builder/out/util/flags.isUseSystemWine"></a>
### `electron-builder/out/util/flags.isUseSystemWine()` ⇒ <code>Boolean</code>
**Kind**: method of [<code>electron-builder/out/util/flags</code>](#module_electron-builder/out/util/flags)
<a name="module_electron-builder/out/util/timer"></a>
## electron-builder/out/util/timer

* [electron-builder/out/util/timer](#module_electron-builder/out/util/timer)
* [`.Timer`](#Timer)
* [`.end()`](#module_electron-builder/out/util/timer.Timer+end)
* [`.time(label)`](#module_electron-builder/out/util/timer.time) ⇒ <code>[Timer](#Timer)</code>

<a name="Timer"></a>
### `Timer`
**Kind**: interface of [<code>electron-builder/out/util/timer</code>](#module_electron-builder/out/util/timer)
<a name="module_electron-builder/out/util/timer.Timer+end"></a>
#### `timer.end()`
**Kind**: instance method of [<code>Timer</code>](#Timer)
<a name="module_electron-builder/out/util/timer.time"></a>
### `electron-builder/out/util/timer.time(label)` ⇒ <code>[Timer](#Timer)</code>
**Kind**: method of [<code>electron-builder/out/util/timer</code>](#module_electron-builder/out/util/timer)

| Param | Type |
| --- | --- |
| label | <code>String</code> |

<a name="module_electron-builder/out/windowsCodeSign"></a>
## electron-builder/out/windowsCodeSign
<a name="SignOptions"></a>
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"ajv": "^5.2.0",
"ajv-keywords": "^2.1.0",
"archiver": "^1.3.0",
"aws-sdk": "^2.73.0",
"aws-sdk": "^2.75.0",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
Expand All @@ -55,6 +55,7 @@
"plist": "^2.1.0",
"sanitize-filename": "^1.6.1",
"semver": "^5.3.0",
"source-map-support": "^0.4.15",
"stat-mode": "^0.2.2",
"ts-jsdoc": "^2.0.3",
"tunnel-agent": "^0.6.0",
Expand Down Expand Up @@ -86,7 +87,6 @@
"jest-junit": "^1.5.1",
"jsdoc-to-markdown": "^3.0.0",
"path-sort": "^0.1.0",
"source-map-support": "^0.4.15",
"ts-babel": "^3.0.1",
"tslint": "^5.4.3",
"typescript": "2.5.0-dev.20170614",
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-http/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"//": "client can also install js-yaml to load yaml",
"dependencies": {
"debug": "2.6.8",
"debug": "^2.6.8",
"fs-extra-p": "^4.3.0"
},
"typings": "./out/electron-builder-http.d.ts"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import BluebirdPromise from "bluebird-lst"
import { Arch } from "electron-builder"
import { debug, exec, log, spawn } from "electron-builder-util"
import { copyFile, walk } from "electron-builder-util/out/fs"
import { execWine, prepareArgs } from "electron-builder/out/util/wine"
Expand Down Expand Up @@ -47,7 +48,7 @@ export interface SquirrelOptions {
copyright?: string
}

export async function buildInstaller(options: SquirrelOptions, outputDirectory: string, setupExe: string, packager: WinPackager, appOutDir: string) {
export async function buildInstaller(options: SquirrelOptions, outputDirectory: string, setupExe: string, packager: WinPackager, appOutDir: string, outDir: string, arch: Arch) {
const appUpdate = await packager.getTempFile("Update.exe")
await BluebirdPromise.all([
copyFile(path.join(options.vendorPath, "Update.exe"), appUpdate)
Expand Down Expand Up @@ -92,7 +93,7 @@ export async function buildInstaller(options: SquirrelOptions, outputDirectory:

await execWine(path.join(options.vendorPath, "WriteZipToSetup.exe"), [setupPath, embeddedArchiveFile])

await packager.signAndEditResources(setupPath)
await packager.signAndEditResources(setupPath, arch, outDir)
if (options.msi && process.platform === "win32") {
const outFile = setupExe.replace(".exe", ".msi")
await msi(options, nupkgPath, setupPath, outputDirectory, outFile)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class SquirrelWindowsTarget extends Target {

const distOptions = await this.computeEffectiveDistOptions()

await buildInstaller(<SquirrelOptions>distOptions, installerOutDir, setupFileName, packager, appOutDir)
await buildInstaller(<SquirrelOptions>distOptions, installerOutDir, setupFileName, packager, appOutDir, this.outDir, arch)

packager.dispatchArtifactCreated(path.join(installerOutDir, setupFileName), this, arch, `${appInfo.name}-Setup-${version}${archSuffix}.exe`)

Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder-util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"stat-mode": "^0.2.2",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"debug": "2.6.8",
"debug": "^2.6.8",
"node-emoji": "^1.5.1",
"electron-builder-http": "~0.0.0-semantic-release",
"source-map-support": "^0.4.15",
Expand Down
5 changes: 4 additions & 1 deletion packages/electron-builder-util/src/binDownload.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { path7za } from "7zip-bin"
import BluebirdPromise from "bluebird-lst"
import _debug from "debug"
import { CancellationToken, DownloadOptions } from "electron-builder-http"
import { emptyDir, rename, unlink } from "fs-extra-p"
import * as path from "path"
import { statOrNull } from "./fs"
import { log, warn } from "./log"
import { httpExecutor } from "./nodeHttpExecutor"
import { debug, debug7zArgs, getCacheDirectory, getTempName, spawn } from "./util"
import { debug7zArgs, getCacheDirectory, getTempName, spawn } from "./util"

const debug = _debug("electron-builder:binDownload")

const versionToPromise = new Map<string, BluebirdPromise<string>>()

Expand Down
66 changes: 22 additions & 44 deletions packages/electron-builder-util/src/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ import _debug from "debug"
import { homedir, tmpdir } from "os"
import * as path from "path"
import "source-map-support/register"
import { statOrNull } from "./fs"
import { log, warn } from "./log"

export { TmpDir } from "./tmp"
export { log, warn, task, subTask } from "./log"
Expand All @@ -16,8 +14,6 @@ export { Lazy } from "electron-builder-http"
export const debug = _debug("electron-builder")
export const debug7z = _debug("electron-builder:7z")

const DEFAULT_APP_DIR_NAMES = ["app", "www"]

export interface BaseExecOptions {
cwd?: string
env?: any
Expand All @@ -38,20 +34,20 @@ export function removePassword(input: string) {
})
}

export function exec(file: string, args?: Array<string> | null, options?: ExecOptions): Promise<string> {
export function exec(file: string, args?: Array<string> | null, options?: ExecOptions, isLogOutIfDebug = true): Promise<string> {
if (debug.enabled) {
debug(`Executing ${file} ${args == null ? "" : removePassword(args.join(" "))}`)
}

return new BluebirdPromise<string>((resolve, reject) => {
execFile(file, <any>args, options, function (error, stdout, stderr) {
if (error == null) {
if (debug.enabled) {
if (isLogOutIfDebug && debug.enabled) {
if (stderr.length !== 0) {
log(stderr)
debug(stderr)
}
if (stdout.length !== 0) {
log(stdout)
debug(stdout)
}
}
resolve(stdout)
Expand All @@ -71,12 +67,19 @@ export function exec(file: string, args?: Array<string> | null, options?: ExecOp
})
}

export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions, pipeInput?: Boolean, isDebugEnabled = debug.enabled): ChildProcess {
export interface ExtraSpawnOptions {
isDebugEnabled?: boolean
isPipeInput?: boolean
}

export function doSpawn(command: string, args: Array<string>, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): ChildProcess {
if (options == null) {
options = {}
}

const isDebugEnabled = extraOptions == null || extraOptions.isDebugEnabled == null ? debug.enabled : extraOptions.isDebugEnabled
if (options.stdio == null) {
options.stdio = [pipeInput ? "pipe" : "ignore", debug.enabled ? "inherit" : "pipe", debug.enabled ? "inherit" : "pipe"]
options.stdio = [extraOptions != null && extraOptions.isPipeInput ? "pipe" : "ignore", isDebugEnabled ? "inherit" : "ignore", isDebugEnabled ? "inherit" : "ignore"]
}

if (isDebugEnabled) {
Expand All @@ -92,9 +95,9 @@ export function doSpawn(command: string, args: Array<string>, options?: SpawnOpt
}
}

export function spawn(command: string, args?: Array<string> | null, options?: SpawnOptions): Promise<any> {
export function spawn(command: string, args?: Array<string> | null, options?: SpawnOptions, extraOptions?: ExtraSpawnOptions): Promise<any> {
return new BluebirdPromise<any>((resolve, reject) => {
handleProcess("close", doSpawn(command, args || [], options), command, resolve, reject)
handleProcess("close", doSpawn(command, args || [], options, extraOptions), command, resolve, reject)
})
}

Expand All @@ -117,49 +120,24 @@ export function handleProcess(event: string, childProcess: ChildProcess, command

childProcess.once(event, (code: number) => {
if (code === 0 && debug.enabled) {
debug(`${command} (${childProcess.pid}) exited with code ${code}`)
debug(`${command} (${childProcess.pid}) exited with exit code 0`)
}

if (code !== 0) {
if (code === 0) {
if (resolve != null) {
resolve()
}
}
else {
function formatOut(text: string, title: string) {
return text.length === 0 ? "" : `\n${title}:\n${text}`
}

reject(new Error(`${command} exited with code ${code}${formatOut(out, "Output")}${formatOut(errorOut, "Error output")}`))
}
else if (resolve != null) {
resolve()
}
})
}

export async function computeDefaultAppDirectory(projectDir: string, userAppDir: string | null | undefined): Promise<string> {
if (userAppDir != null) {
const absolutePath = path.resolve(projectDir, userAppDir)
const stat = await statOrNull(absolutePath)
if (stat == null) {
throw new Error(`Application directory ${userAppDir} doesn't exists`)
}
else if (!stat.isDirectory()) {
throw new Error(`Application directory ${userAppDir} is not a directory`)
}
else if (projectDir === absolutePath) {
warn(`Specified application directory "${userAppDir}" equals to project dir — superfluous or wrong configuration`)
}
return absolutePath
}

for (const dir of DEFAULT_APP_DIR_NAMES) {
const absolutePath = path.join(projectDir, dir)
const packageJson = path.join(absolutePath, "package.json")
const stat = await statOrNull(packageJson)
if (stat != null && stat.isFile()) {
return absolutePath
}
}
return projectDir
}

export function use<T, R>(value: T | null, task: (it: T) => R): R | null {
return value == null ? null : task(value)
}
Expand Down
6 changes: 4 additions & 2 deletions packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@
"portable"
],
"author": "Vladimir Krivosheev",
"contributors": ["Stefan Judis"],
"contributors": [
"Stefan Judis"
],
"license": "MIT",
"bugs": "https://github.com/electron-userland/electron-builder/issues",
"homepage": "https://github.com/electron-userland/electron-builder",
Expand Down Expand Up @@ -76,7 +78,7 @@
"update-notifier": "^2.2.0",
"uuid-1345": "^0.99.6",
"yargs": "^8.0.2",
"debug": "2.6.8",
"debug": "^2.6.8",
"asar-integrity": "0.0.0-semantic-release"
},
"typings": "./out/electron-builder.d.ts",
Expand Down
Loading

0 comments on commit af77da8

Please sign in to comment.