Skip to content

Commit 079989a

Browse files
committed
feat: revert "Releases file for Windows not uploaded to Github #190"
1 parent 05121df commit 079989a

File tree

10 files changed

+57
-74
lines changed

10 files changed

+57
-74
lines changed

.idea/dictionaries/develar.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/Code Signing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,4 @@ travis encrypt 'CSC_KEY_PASSWORD=beAwareAboutBashEscaping!!!' --add
3030
# Where to buy certificate
3131

3232
[StartSSL](https://startssl.com/Support?v=34) is recommended.
33-
It can be used to sign OS X app also, so, you don't need to buy Apple Certificate in addition (please note, it works, but we are waiting official confirmation).
33+
It can be used to sign OS X app also, so, you don't need to buy Apple Certificate in addition.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
"globby": "^4.0.0",
7272
"hosted-git-info": "^2.1.4",
7373
"image-size": "^0.5.0",
74-
"lodash.template": "^4.2.4",
74+
"lodash.template": "^4.2.5",
7575
"mime": "^1.3.4",
7676
"progress": "^1.1.8",
7777
"progress-stream": "^1.2.0",

src/osxPackager.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { PlatformPackager, BuildInfo, normalizeTargets } from "./platformPackage
22
import { Platform, OsXBuildOptions, MasBuildOptions } from "./metadata"
33
import * as path from "path"
44
import { Promise as BluebirdPromise } from "bluebird"
5-
import { log, debug, debug7z, spawn, statOrNull } from "./util"
5+
import { log, debug, debug7z, spawn, statOrNull, warn } from "./util"
66
import { createKeychain, deleteKeychain, CodeSigningInfo, generateKeychainName } from "./codeSign"
77
import { path7za } from "7zip-bin"
88
import deepAssign = require("deep-assign")
@@ -82,11 +82,15 @@ export default class OsXPackager extends PlatformPackager<OsXBuildOptions> {
8282

8383
const identity = codeSigningInfo.name
8484
if (<string | null>identity == null) {
85-
log("App is not signed: CSC_LINK or CSC_NAME are not specified")
85+
const message = "App is not signed: CSC_LINK or CSC_NAME are not specified, see https://github.com/electron-userland/electron-builder/wiki/Code-Signing"
86+
if (masOptions != null) {
87+
throw new Error(message)
88+
}
89+
warn(message)
8690
return
8791
}
8892

89-
log(`Signing app (${identity})`)
93+
log(`Signing app (identity: ${identity})`)
9094

9195
const baseSignOptions: BaseSignOptions = {
9296
app: path.join(appOutDir, this.appName + ".app"),

src/util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ export const debug: Debugger = debugFactory("electron-builder")
1717
export const debug7z: Debugger = debugFactory("electron-builder:7z")
1818

1919
export function warn(message: string) {
20-
console.warn(yellow(message))
20+
console.warn(yellow(`Warning: ${message}`))
2121
}
2222

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

src/winPackager.ts

Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ import { Promise as BluebirdPromise } from "bluebird"
33
import { PlatformPackager, BuildInfo } from "./platformPackager"
44
import { Platform, WinBuildOptions } from "./metadata"
55
import * as path from "path"
6-
import { log, statOrNull } from "./util"
7-
import { readFile, deleteFile, rename, copy, emptyDir, writeFile, open, close, read, move } from "fs-extra-p"
6+
import { log, statOrNull, warn } from "./util"
7+
import { deleteFile, rename, emptyDir, open, close, read, move } from "fs-extra-p"
88
import { sign } from "signcode-tf"
99
import ElectronPackagerOptions = ElectronPackager.ElectronPackagerOptions
1010

@@ -52,6 +52,10 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
5252
}
5353

5454
async pack(outDir: string, arch: string, postAsyncTasks: Array<Promise<any>>): Promise<any> {
55+
if (arch === "ia32") {
56+
warn("For windows consider only distributing 64-bit, see https://github.com/electron-userland/electron-builder/issues/359#issuecomment-214851130")
57+
}
58+
5559
// we must check icon before pack because electron-packager uses icon and it leads to cryptic error message "spawn wine ENOENT"
5660
await this.iconPath
5761

@@ -64,7 +68,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
6468
}
6569

6670
const unpackedDir = path.join(outDir, `win${arch === "x64" ? "" : `-${arch}`}-unpacked`)
67-
const finalAppOut = path.join(outDir, `win${arch === "x64" ? "" : `-${arch}`}-unpacked`, "lib", "net45")
71+
const finalAppOut = path.join(unpackedDir, "lib", "net45")
6872
const installerOut = computeDistOut(outDir, arch)
6973
log("Removing %s and %s", path.relative(this.projectDir, installerOut), path.relative(this.projectDir, unpackedDir))
7074
await BluebirdPromise.all([
@@ -166,38 +170,13 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
166170

167171
const version = this.metadata.version
168172
const archSuffix = arch === "x64" ? "" : ("-" + arch)
169-
const releasesFile = path.join(installerOutDir, "RELEASES")
170-
const nupkgVersion = winstaller.convertVersion(version)
171-
const nupkgPathOriginal = `${this.metadata.name}-${nupkgVersion}-full.nupkg`
172-
const nupkgPathWithArch = `${this.metadata.name}-${nupkgVersion}${archSuffix}-full.nupkg`
173-
174-
async function changeFileNameInTheReleasesFile(): Promise<void> {
175-
const data = (await readFile(releasesFile, "utf8")).replace(new RegExp(" " + nupkgPathOriginal + " ", "g"), " " + nupkgPathWithArch + " ")
176-
await writeFile(releasesFile, data)
177-
}
178-
179-
const promises: Array<Promise<any>> = [
180-
rename(path.join(installerOutDir, "Setup.exe"), path.join(installerOutDir, `${this.appName} Setup ${version}${archSuffix}.exe`))
181-
.then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}-Setup-${version}${archSuffix}.exe`)),
182-
]
173+
const nupkgPath = `${this.metadata.name}-${winstaller.convertVersion(version)}-full.nupkg`
183174

184-
if (archSuffix === "") {
185-
this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPathOriginal))
186-
this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
187-
}
188-
else {
189-
promises.push(
190-
rename(path.join(installerOutDir, nupkgPathOriginal), path.join(installerOutDir, nupkgPathWithArch))
191-
.then(it => this.dispatchArtifactCreated(it))
192-
)
193-
promises.push(
194-
changeFileNameInTheReleasesFile()
195-
.then(() => copy(releasesFile, path.join(installerOutDir, "RELEASES-ia32")))
196-
.then(it => this.dispatchArtifactCreated(it))
197-
)
198-
}
175+
this.dispatchArtifactCreated(path.join(installerOutDir, nupkgPath))
176+
this.dispatchArtifactCreated(path.join(installerOutDir, "RELEASES"))
199177

200-
await BluebirdPromise.all(promises)
178+
await rename(path.join(installerOutDir, "Setup.exe"), path.join(installerOutDir, `${this.appName} Setup ${version}${archSuffix}.exe`))
179+
.then(it => this.dispatchArtifactCreated(it, `${this.metadata.name}-Setup-${version}${archSuffix}.exe`))
201180
}
202181
}
203182

test/src/helpers/avaEx.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ declare module "ava-tf" {
66
export const ifOsx: typeof test;
77
export const ifNotCi: typeof test;
88
export const ifNotCiOsx: typeof test;
9+
export const ifDevOrWinCi: typeof test;
910
export const ifNotTravis: typeof test;
1011
}
1112

@@ -39,6 +40,11 @@ Object.defineProperties(test, {
3940
get: function () {
4041
return process.platform === "darwin" ? this : this.skip
4142
}
43+
},
44+
"ifDevOrWinCi": {
45+
get: function () {
46+
return !process.env.CI || process.platform === "win32" ? this : this.skip
47+
}
4248
}
4349
})
4450

test/src/helpers/packTester.ts

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,6 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO
6060

6161
await packAndCheck(projectDir, Object.assign({
6262
projectDir: projectDir,
63-
cscLink: CSC_LINK,
64-
cscKeyPassword: CSC_KEY_PASSWORD,
65-
cscInstallerLink: CSC_INSTALLER_LINK,
66-
cscInstallerKeyPassword: CSC_INSTALLER_KEY_PASSWORD,
6763
dist: true,
6864
}, packagerOptions), checkOptions)
6965

@@ -206,7 +202,7 @@ async function checkWindowsResult(packager: Packager, packagerOptions: PackagerO
206202

207203
function getWinExpected(archSuffix: string) {
208204
return [
209-
`RELEASES${archSuffix}`,
205+
`RELEASES`,
210206
`${productName} Setup 1.1.0${archSuffix}.exe`,
211207
`TestApp-1.1.0${archSuffix}-full.nupkg`,
212208
]
@@ -221,16 +217,9 @@ async function checkWindowsResult(packager: Packager, packagerOptions: PackagerO
221217
return
222218
}
223219

224-
let i = filenames.indexOf("RELEASES-ia32")
225-
if (i !== -1) {
226-
assertThat((await readFile(artifacts[i].file, "utf8")).indexOf("ia32")).not.equal(-1)
227-
}
228-
229-
if (archSuffix == "") {
230-
const expectedArtifactNames = expected.slice()
231-
expectedArtifactNames[1] = `TestAppSetup-1.1.0${archSuffix}.exe`
232-
assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestApp-Setup-1.1.0${archSuffix}.exe`])
233-
}
220+
const expectedArtifactNames = expected.slice()
221+
expectedArtifactNames[1] = `TestAppSetup-1.1.0${archSuffix}.exe`
222+
assertThat(artifacts.map(it => it.artifactName).filter(it => it != null)).deepEqual([`TestApp-Setup-1.1.0${archSuffix}.exe`])
234223

235224
const packageFile = path.join(path.dirname(artifacts[0].file), `TestApp-1.1.0${archSuffix}-full.nupkg`)
236225
const unZipper = new DecompressZip(packageFile)
@@ -292,4 +281,12 @@ export function platform(platform: Platform): PackagerOptions {
292281
return {
293282
platform: [platform]
294283
}
284+
}
285+
286+
export function signed(packagerOptions: PackagerOptions): PackagerOptions {
287+
packagerOptions.cscLink = CSC_LINK
288+
packagerOptions.cscKeyPassword = CSC_KEY_PASSWORD
289+
packagerOptions.cscInstallerLink = CSC_INSTALLER_LINK
290+
packagerOptions.cscInstallerKeyPassword = CSC_INSTALLER_KEY_PASSWORD
291+
return packagerOptions
295292
}

test/src/osxPackagerTest.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import test from "./helpers/avaEx"
2-
import { assertPack, platform, modifyPackageJson } from "./helpers/packTester"
2+
import { assertPack, platform, modifyPackageJson, signed } from "./helpers/packTester"
33
import { Platform } from "out"
44
import OsXPackager from "out/osxPackager"
55
import { move, writeFile } from "fs-extra-p"
66
import * as path from "path"
7-
import { BuildInfo } from "out/platformPackager"
7+
import { BuildInfo, PackagerOptions } from "out/platformPackager"
88
import { Promise as BluebirdPromise } from "bluebird"
99
import * as assertThat from "should/as-function"
1010
import ElectronPackagerOptions = ElectronPackager.ElectronPackagerOptions
@@ -14,15 +14,15 @@ import { SignOptions, FlatOptions } from "electron-osx-sign-tf"
1414
//noinspection JSUnusedLocalSymbols
1515
const __awaiter = require("out/awaiter")
1616

17-
test.ifOsx("two-package", () => assertPack("test-app", {
17+
test.ifOsx("two-package", () => assertPack("test-app", signed({
1818
platform: [Platform.OSX],
1919
arch: "all",
20-
}))
20+
})))
2121

22-
test.ifOsx("one-package", () => assertPack("test-app-one", platform(Platform.OSX)))
22+
test.ifOsx("one-package", () => assertPack("test-app-one", signed(platform(Platform.OSX))))
2323

2424
function createTargetTest(target: Array<string>, expectedContents: Array<string>) {
25-
const options = {
25+
let options: PackagerOptions = {
2626
platform: [Platform.OSX],
2727
devMetadata: {
2828
build: {
@@ -32,6 +32,10 @@ function createTargetTest(target: Array<string>, expectedContents: Array<string>
3232
}
3333
}
3434
}
35+
if (target.includes("mas")) {
36+
options = signed(options)
37+
}
38+
3539
return () => assertPack("test-app-one", options, {
3640
expectedContents: expectedContents
3741
})
@@ -49,8 +53,6 @@ test.ifOsx("custom mas", () => {
4953
return assertPack("test-app-one", {
5054
platform: [Platform.OSX],
5155
platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingOsXPackager(packager, cleanupTasks),
52-
cscLink: null,
53-
cscInstallerLink: null,
5456
devMetadata: {
5557
build: {
5658
osx: {
@@ -84,8 +86,6 @@ test.ifOsx("identity in package.json", () => {
8486
return assertPack("test-app-one", {
8587
platform: [Platform.OSX],
8688
platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingOsXPackager(packager, cleanupTasks),
87-
cscLink: null,
88-
cscInstallerLink: null,
8989
devMetadata: {
9090
build: {
9191
osx: {
@@ -112,8 +112,6 @@ test.ifOsx("entitlements in build dir", () => {
112112
return assertPack("test-app-one", {
113113
platform: [Platform.OSX],
114114
platformPackagerFactory: (packager, platform, cleanupTasks) => platformPackager = new CheckingOsXPackager(packager, cleanupTasks),
115-
cscLink: null,
116-
cscInstallerLink: null,
117115
devMetadata: {
118116
build: {
119117
osx: {

test/src/winPackagerTest.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Platform } from "out"
22
import test from "./helpers/avaEx"
3-
import { assertPack, platform, modifyPackageJson } from "./helpers/packTester"
3+
import { assertPack, platform, modifyPackageJson, signed } from "./helpers/packTester"
44
import { move, outputFile } from "fs-extra-p"
55
import * as path from "path"
66
import { WinPackager, computeDistOut } from "out/winPackager"
@@ -12,7 +12,7 @@ import ElectronPackagerOptions = ElectronPackager.ElectronPackagerOptions
1212
//noinspection JSUnusedLocalSymbols
1313
const __awaiter = require("out/awaiter")
1414

15-
test.ifNotCiOsx("win", () => assertPack("test-app-one", platform(Platform.WINDOWS),
15+
test.ifNotCiOsx("win", () => assertPack("test-app-one", signed(platform(Platform.WINDOWS)),
1616
{
1717
tempDirCreated: process.env.TEST_DELTA ? it => modifyPackageJson(it, data => {
1818
data.build.win = {
@@ -22,17 +22,15 @@ test.ifNotCiOsx("win", () => assertPack("test-app-one", platform(Platform.WINDOW
2222
}
2323
))
2424

25-
test.ifNotCiOsx("win f", () => {
25+
test.ifDevOrWinCi("win f", () => {
2626
const metadata: any = {
2727
version: "3.0.0-beta.2"
2828
}
2929

3030
return assertPack("test-app-one", {
31-
platform: [Platform.WINDOWS],
32-
cscLink: null,
33-
cscInstallerLink: null,
34-
devMetadata: metadata
35-
}, {
31+
platform: [Platform.WINDOWS],
32+
devMetadata: metadata
33+
}, {
3634
expectedArtifacts: [
3735
"RELEASES",
3836
"TestApp Setup 3.0.0-beta.2.exe",

0 commit comments

Comments
 (0)