Skip to content

Commit 9f4fba9

Browse files
committed
fix(windows): Releases file for Windows not uploaded to Github
Closes #190
1 parent 9c87ffd commit 9f4fba9

File tree

10 files changed

+107
-58
lines changed

10 files changed

+107
-58
lines changed

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"bluebird": "^3.3.3",
5353
"command-line-args": "^2.1.6",
5454
"electron-packager-tf": "^5.2.3",
55-
"electron-winstaller-temp-fork": "^2.0.5-beta.2",
55+
"electron-winstaller-temp-fork": "^2.0.5-beta.3",
5656
"fs-extra": "^0.26.5",
5757
"gm": "^1.21.1",
5858
"hosted-git-info": "^2.1.4",
@@ -105,16 +105,16 @@
105105
],
106106
"env": {
107107
"test": {
108-
"ignore": "**/out/*.js",
108+
"ignore": ["**/out/*.js"],
109109
"plugins": [
110110
[
111-
"babel-plugin-transform-async-to-module-method",
111+
"transform-async-to-module-method",
112112
{
113113
"module": "bluebird",
114114
"method": "coroutine"
115115
}
116116
],
117-
"babel-plugin-transform-es2015-modules-commonjs",
117+
"transform-es2015-modules-commonjs",
118118
"transform-strict-mode"
119119
]
120120
}

src/linuxPackager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ export class LinuxPackager extends PlatformPackager<DebOptions> {
6363
return "linux"
6464
}
6565

66-
async packageInDistributableFormat(outDir: string, appOutDir: string): Promise<any> {
66+
async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any> {
6767
const specification: DebOptions = {
6868
version: this.metadata.version,
6969
title: this.metadata.name,
7070
comment: this.metadata.description,
7171
maintainer: `${this.metadata.author.name} <${this.metadata.author.email}>`,
72-
arch: this.currentArch === "ia32" ? 32 : 64,
72+
arch: arch === "ia32" ? 32 : 64,
7373
target: "deb",
7474
executable: this.metadata.name,
7575
desktop: `[Desktop Entry]

src/macPackager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ export default class MacPackager extends PlatformPackager<appdmg.Specification>
2828
return "osx"
2929
}
3030

31-
async pack(platform: string, outDir: string, appOutDir: string): Promise<any> {
32-
await super.pack(platform, outDir, appOutDir)
31+
async pack(platform: string, outDir: string, appOutDir: string, arch: string): Promise<any> {
32+
await super.pack(platform, outDir, appOutDir, arch)
3333
let codeSigningInfo = await this.codeSigningInfo
3434
return await this.signMac(path.join(appOutDir, this.metadata.name + ".app"), codeSigningInfo)
3535
}

src/packager.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,11 @@ export class Packager implements BuildInfo {
7272
for (let arch of normalizeArchs(platform, this.options.arch)) {
7373
await this.installAppDependencies(arch)
7474

75-
helper.currentArch = arch
7675
const outDir = path.join(this.projectDir, "dist")
7776
const appOutDir = path.join(outDir, this.metadata.name + "-" + platform + "-" + arch)
78-
await helper.pack(platform, outDir, appOutDir)
77+
await helper.pack(platform, outDir, appOutDir, arch)
7978
if (this.options.dist) {
80-
distTasks.push(helper.packageInDistributableFormat(outDir, appOutDir))
79+
distTasks.push(helper.packageInDistributableFormat(outDir, appOutDir, arch))
8180
}
8281
}
8382
}

src/platformPackager.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ export abstract class PlatformPackager<DC> implements ProjectMetadataProvider {
7070

7171
customDistOptions: DC
7272

73-
currentArch: string
74-
7573
protected abstract getBuildConfigurationKey(): string
7674

7775
constructor(protected info: BuildInfo) {
@@ -97,7 +95,7 @@ export abstract class PlatformPackager<DC> implements ProjectMetadataProvider {
9795
this.info.eventEmitter.emit("artifactCreated", path)
9896
}
9997

100-
pack(platform: string, outDir: string, appOutDir: string): Promise<any> {
98+
pack(platform: string, outDir: string, appOutDir: string, arch: string): Promise<any> {
10199
const version = this.metadata.version
102100
let buildVersion = version
103101
const buildNumber = process.env.TRAVIS_BUILD_NUMBER || process.env.APPVEYOR_BUILD_NUMBER || process.env.CIRCLE_BUILD_NUM
@@ -110,7 +108,7 @@ export abstract class PlatformPackager<DC> implements ProjectMetadataProvider {
110108
out: outDir,
111109
name: this.metadata.name,
112110
platform: platform,
113-
arch: this.currentArch,
111+
arch: arch,
114112
version: this.info.electronVersion,
115113
icon: path.join(this.buildResourcesDir, "icon"),
116114
asar: true,
@@ -132,5 +130,5 @@ export abstract class PlatformPackager<DC> implements ProjectMetadataProvider {
132130
return pack(options)
133131
}
134132

135-
abstract packageInDistributableFormat(outDir: string, appOutDir: string): Promise<any>
133+
abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any>
136134
}

src/promisifed-fs.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import * as fs from "fs"
1+
import * as fs from "fs-extra"
22
import { Promise as BluebirdPromise } from "bluebird"
33

44
const readFileAsync: ((filename: string, encoding?: string) => Promise<string | Buffer>) = BluebirdPromise.promisify(fs.readFile)
@@ -20,6 +20,13 @@ export function renameFile(oldPath: string, newPath: string): BluebirdPromise<st
2020
})
2121
}
2222

23+
// returns copied name
24+
export function copyFile(src: string, dest: string): BluebirdPromise<string> {
25+
return new BluebirdPromise<any>((resolve, reject) => {
26+
fs.copy(src, dest, error => error == null ? resolve(dest) : reject(error))
27+
})
28+
}
29+
2330
const statFileAsync = BluebirdPromise.promisify(fs.stat)
2431

2532
export function stat(path: string): BluebirdPromise<fs.Stats> {

src/winPackager.ts

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { PlatformPackager, BuildInfo } from "./platformPackager"
55
import * as path from "path"
66
import { Stats } from "fs"
77
import { log } from "./util"
8-
import { deleteFile, stat, renameFile } from "./promisifed-fs"
8+
import { deleteFile, stat, renameFile, copyFile } from "./promisifed-fs"
99
import * as fse from "fs-extra"
1010

1111
const __awaiter = tsAwaiter
@@ -49,25 +49,25 @@ export default class WinPackager extends PlatformPackager<any> {
4949
return "win"
5050
}
5151

52-
pack(platform: string, outDir: string, appOutDir: string): Promise<any> {
52+
pack(platform: string, outDir: string, appOutDir: string, arch: string): Promise<any> {
5353
if (this.options.dist && !this.isNsis) {
54-
const installerOut = this.computeDistOut(outDir)
54+
const installerOut = this.computeDistOut(outDir, arch)
5555
log("Removing %s", installerOut)
5656
return BluebirdPromise.all([
57-
super.pack(platform, outDir, appOutDir),
57+
super.pack(platform, outDir, appOutDir, arch),
5858
emptyDir(installerOut)
5959
])
6060
}
6161
else {
62-
return super.pack(platform, outDir, appOutDir)
62+
return super.pack(platform, outDir, appOutDir, arch)
6363
}
6464
}
6565

66-
private computeDistOut(outDir: string): string {
67-
return path.join(outDir, (this.isNsis ? "nsis" : "win") + (this.currentArch === "x64" ? "-x64" : ""))
66+
private computeDistOut(outDir: string, arch: string): string {
67+
return path.join(outDir, (this.isNsis ? "nsis" : "win") + (arch === "x64" ? "-x64" : ""))
6868
}
6969

70-
async packageInDistributableFormat(outDir: string, appOutDir: string): Promise<any> {
70+
async packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any> {
7171
let iconUrl = this.metadata.build.iconUrl
7272
if (!iconUrl) {
7373
if (this.customDistOptions != null) {
@@ -89,9 +89,9 @@ export default class WinPackager extends PlatformPackager<any> {
8989

9090
const certificateFile = await this.certFilePromise
9191
const version = this.metadata.version
92-
const installerOutDir = this.computeDistOut(outDir)
92+
const installerOutDir = this.computeDistOut(outDir, arch)
9393
const appName = this.metadata.name
94-
const archSuffix = this.currentArch === "x64" ? "-x64" : ""
94+
const archSuffix = arch === "x64" ? "-x64" : ""
9595
const installerExePath = path.join(installerOutDir, appName + "Setup-" + version + archSuffix + ".exe")
9696
const options = Object.assign({
9797
name: this.metadata.name,
@@ -134,12 +134,22 @@ export default class WinPackager extends PlatformPackager<any> {
134134
}
135135
}
136136

137-
return await BluebirdPromise.all([
137+
const promises = [
138138
renameFile(path.join(installerOutDir, "Setup.exe"), installerExePath)
139139
.then(it => this.dispatchArtifactCreated(it)),
140140
renameFile(path.join(installerOutDir, appName + "-" + version + "-full.nupkg"), path.join(installerOutDir, appName + "-" + version + archSuffix + "-full.nupkg"))
141141
.then(it => this.dispatchArtifactCreated(it))
142-
])
142+
]
143+
144+
if (arch === "x64") {
145+
this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
146+
}
147+
else {
148+
promises.push(copyFile(path.join(installerOutDir, "RELEASES"), path.join(installerOutDir, "RELEASES-ia32"))
149+
.then(it => this.dispatchArtifactCreated(it)))
150+
}
151+
152+
return await BluebirdPromise.all(promises)
143153
}
144154

145155
private async nsis(options: any, installerFile: string) {

test/helpers/packTester.js

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { CSC_LINK, CSC_KEY_PASSWORD } from "./codeSignData"
88
import { expectedLinuxContents } from "./expectedContents"
99
import { readText } from "out/promisifed-fs"
1010
import { Packager } from "out/index"
11+
import { normalizePlatforms } from "out/packager"
1112
import { exec } from "out/util"
1213
import pathSorter from "path-sort"
1314

@@ -36,16 +37,26 @@ export async function assertPack(projectDir, platform, packagerOptions, useTempD
3637
}
3738
}
3839

40+
const platforms = Array.isArray(platform) ? platform : [platform]
3941
const packager = new Packager(Object.assign({
4042
projectDir: projectDir,
4143
cscLink: CSC_LINK,
4244
cscKeyPassword: CSC_KEY_PASSWORD,
4345
dist: true,
44-
platform: Array.isArray(platform) ? platform : [platform],
46+
platform: platforms,
4547
}, packagerOptions))
4648

49+
let artifacts = []
50+
packager.artifactCreated(it => {
51+
artifacts.push(path.basename(it))
52+
})
53+
4754
await packager.build()
48-
if (platform === "darwin" || (platform === "all" && process.platform === "darwin")) {
55+
56+
artifacts = pathSorter(artifacts)
57+
const expandedPlatforms = normalizePlatforms(platforms)
58+
59+
if (expandedPlatforms.includes("darwin")) {
4960
const packedAppDir = projectDir + "/dist/TestApp-darwin-x64/TestApp.app"
5061
const info = parsePlist(await readText(packedAppDir + "/Contents/Info.plist"))
5162
assertThat(info).has.properties({
@@ -58,12 +69,34 @@ export async function assertPack(projectDir, platform, packagerOptions, useTempD
5869
const result = await exec("codesign", ["--verify", packedAppDir])
5970
assertThat(result[0].toString()).not.match(/is not signed at all/)
6071
}
61-
else if (platform === "linux" || (platform === "all" && process.platform !== "win32")) {
72+
else if (expandedPlatforms.includes("linux")) {
6273
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb")).deepEqual(expectedLinuxContents)
63-
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb")).deepEqual(expectedLinuxContents)
74+
if (packagerOptions == null || packagerOptions.arch === null || packagerOptions.arch === "ia32") {
75+
assertThat(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb")).deepEqual(expectedLinuxContents)
76+
}
6477
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-amd64.deb"), null, 2))
6578
// console.log(JSON.stringify(await getContents(projectDir + "/dist/TestApp-1.0.0-i386.deb"), null, 2))
6679
}
80+
else if (expandedPlatforms.includes("win32") && (packagerOptions == null || packagerOptions.target == null)) {
81+
const expected32 = [
82+
"RELEASES-ia32",
83+
"TestApp-1.0.0-full.nupkg",
84+
"TestAppSetup-1.0.0.exe"
85+
]
86+
const expected64 = [
87+
"RELEASES",
88+
"TestAppSetup-1.0.0-x64.exe",
89+
"TestApp-1.0.0-x64-full.nupkg"
90+
]
91+
let expected
92+
if (packagerOptions != null && packagerOptions.arch === "x64") {
93+
expected = expected64
94+
}
95+
else {
96+
expected = expected32.concat(expected64)
97+
}
98+
assertThat(artifacts).deepEqual(pathSorter(expected))
99+
}
67100
}
68101

69102
async function getContents(path) {

test/winPackagerTest.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ test.ifNotTravis("win", async function () {
88
// nsis is deprecated and not thread-safe - just do not run on CI to avoid failures
99
test.ifNotCi.serial("win: nsis", async function () {
1010
await assertPack("test-app-one", "win32", {
11-
target: ["nsis"]
11+
target: ["nsis"],
12+
arch: process.arch
1213
}, true)
1314
})

typings/main/ambient/fs-extra/fs-extra.d.ts

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,29 @@
1111
declare module "fs-extra" {
1212
import stream = require("stream");
1313

14-
export interface Stats {
15-
isFile(): boolean;
16-
isDirectory(): boolean;
17-
isBlockDevice(): boolean;
18-
isCharacterDevice(): boolean;
19-
isSymbolicLink(): boolean;
20-
isFIFO(): boolean;
21-
isSocket(): boolean;
22-
dev: number;
23-
ino: number;
24-
mode: number;
25-
nlink: number;
26-
uid: number;
27-
gid: number;
28-
rdev: number;
29-
size: number;
30-
blksize: number;
31-
blocks: number;
32-
atime: Date;
33-
mtime: Date;
34-
ctime: Date;
35-
}
14+
interface Stats {
15+
isFile(): boolean;
16+
isDirectory(): boolean;
17+
isBlockDevice(): boolean;
18+
isCharacterDevice(): boolean;
19+
isSymbolicLink(): boolean;
20+
isFIFO(): boolean;
21+
isSocket(): boolean;
22+
dev: number;
23+
ino: number;
24+
mode: number;
25+
nlink: number;
26+
uid: number;
27+
gid: number;
28+
rdev: number;
29+
size: number;
30+
blksize: number;
31+
blocks: number;
32+
atime: Date;
33+
mtime: Date;
34+
ctime: Date;
35+
birthtime: Date;
36+
}
3637

3738
export interface FSWatcher {
3839
close(): void;
@@ -87,7 +88,7 @@ declare module "fs-extra" {
8788
export function writeJsonSync(file: string, object: any, options?: OpenOptions): void;
8889
export function writeJSONSync(file: string, object: any, options?: OpenOptions): void;
8990

90-
export function rename(oldPath: string, newPath: string, callback?: (err: Error) => void): void;
91+
export function rename(oldPath: string, newPath: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
9192
export function renameSync(oldPath: string, newPath: string): void;
9293
export function truncate(fd: number, len: number, callback?: (err: Error) => void): void;
9394
export function truncateSync(fd: number, len: number): void;
@@ -123,7 +124,7 @@ declare module "fs-extra" {
123124
export function realpath(path: string, callback?: (err: Error, resolvedPath: string) => void): void;
124125
export function realpath(path: string, cache: string, callback: (err: Error, resolvedPath: string) => void): void;
125126
export function realpathSync(path: string, cache?: boolean): string;
126-
export function unlink(path: string, callback?: (err: Error) => void): void;
127+
export function unlink(path: string, callback?: (err?: NodeJS.ErrnoException) => void): void;
127128
export function unlinkSync(path: string): void;
128129
export function rmdir(path: string, callback?: (err: Error) => void): void;
129130
export function rmdirSync(path: string): void;

0 commit comments

Comments
 (0)