Skip to content

Commit 5d404ea

Browse files
committed
fix: rename linux to linux-unpacked #670
1 parent bda802e commit 5d404ea

File tree

9 files changed

+74
-66
lines changed

9 files changed

+74
-66
lines changed

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@
6464
"archiver": "^1.0.1",
6565
"archiver-utils": "^1.2.0",
6666
"asar-electron-builder": "^0.13.2",
67-
"bluebird": "^3.4.1",
67+
"bluebird": "^3.4.3",
6868
"chalk": "^1.1.3",
6969
"chromium-pickle-js": "^0.1.0",
7070
"cli-cursor": "^1.0.2",
71-
"cuint": "^0.2.1",
71+
"cuint": "^0.2.2",
7272
"debug": "^2.2.0",
7373
"electron-download": "^2.1.2",
7474
"electron-osx-sign": "^0.4.0-beta4",
@@ -109,21 +109,21 @@
109109
"@types/debug": "0.0.28",
110110
"@types/mime": "0.0.28",
111111
"@types/progress": "^1.1.27",
112-
"@types/semver": "^5.3.28",
112+
"@types/semver": "^5.3.29",
113113
"@types/source-map-support": "^0.2.27",
114114
"ava-tf": "^0.16.0",
115115
"babel-plugin-array-includes": "^2.0.3",
116116
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
117117
"babel-plugin-transform-es2015-parameters": "^6.11.4",
118118
"babel-plugin-transform-es2015-spread": "^6.8.0",
119119
"decompress-zip": "^0.3.0",
120-
"diff": "^2.2.3",
120+
"diff": "^3.0.0",
121121
"json8": "^0.9.2",
122122
"path-sort": "^0.1.0",
123123
"pre-git": "^3.10.0",
124124
"ts-babel": "^1.0.4",
125-
"tslint": "^3.14.0-dev.1",
126-
"typescript": "^2.1.0-dev.20160802",
125+
"tslint": "^3.15.1",
126+
"typescript": "^2.1.0-dev.20160826",
127127
"whitespace": "^2.1.0"
128128
},
129129
"babel": {

src/platformPackager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
222222
}
223223

224224
protected computeAppOutDir(outDir: string, arch: Arch): string {
225-
return path.join(outDir, `${this.platform.buildConfigurationKey}${arch === Arch.x64 ? "" : `-${Arch[arch]}`}`)
225+
return path.join(outDir, `${this.platform.buildConfigurationKey}${getArchSuffix(arch)}${this.platform === Platform.MAC ? "" : "-unpacked"}`)
226226
}
227227

228228
dispatchArtifactCreated(file: string, artifactName?: string) {

src/util/filter.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ function flatDependencies(data: any, seen: Set<string>): any {
8888
return flatDependencies(deps[d], seen)
8989
})
9090
.filter(it => it !== null)
91-
.reduce(function FLAT(l, r) {
92-
return l.concat(Array.isArray(r) ? r.reduce(FLAT, []) : r)
91+
.reduce(function flat(l, r): Array<string> {
92+
return l.concat(Array.isArray(r) ? r.reduce(flat, []) : r)
9393
}, [])
9494

9595
}

test/src/BuildTest.ts

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ test("custom output dir", app(allPlatforms(false), {
8484
app: ".",
8585
}
8686
}),
87-
packed: async (projectDir) => {
88-
await assertThat(path.join(projectDir, "customDist")).isDirectory()
87+
packed: async context => {
88+
await assertThat(path.join(context.projectDir, "customDist")).isDirectory()
8989
}
9090
}))
9191

@@ -225,10 +225,9 @@ test.ifDevOrLinuxCi("extra metadata", () => {
225225
existingProp: 22,
226226
}
227227
}),
228-
packed: async (projectDir) => {
229-
const out = path.join(projectDir, "dist", "linux")
230-
await assertThat(path.join(out, "NewName")).isFile()
231-
assertThat(JSON.parse(extractFile(path.join(out, "resources", "app.asar"), "package.json").toString())).hasProperties({
228+
packed: async context => {
229+
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
230+
assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).hasProperties({
232231
foo: {
233232
bar: 12,
234233
existingProp: 22,
@@ -246,9 +245,8 @@ test.ifDevOrLinuxCi("extra metadata - two", () => {
246245
targets: Platform.LINUX.createTarget(DIR_TARGET),
247246
extraMetadata: extraMetadata,
248247
}, {
249-
packed: async (projectDir, outDir) => {
250-
const out = path.join(outDir, "linux")
251-
await assertThat(path.join(out, "NewName")).isFile()
248+
packed: async context => {
249+
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
252250
}
253251
})
254252
})
@@ -265,9 +263,8 @@ test.ifOsx("extra metadata - override icon", t => t.throws((() => {
265263
targets: Platform.OSX.createTarget(DIR_TARGET),
266264
extraMetadata: extraMetadata,
267265
}, {
268-
packed: async (projectDir, outDir) => {
269-
const out = path.join(outDir, "linux")
270-
await assertThat(path.join(out, "NewName")).isFile()
266+
packed: async context => {
267+
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
271268
}
272269
})
273270
})(), /ENOENT: no such file or directory/))
@@ -277,8 +274,8 @@ test.ifOsx("app-executable-deps", () => {
277274
targets: Platform.current().createTarget(DIR_TARGET),
278275
}, {
279276
useTempDir: false,
280-
packed: async (projectDir, outDir) => {
281-
const data = await readJson(path.join(outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json"))
277+
packed: async context => {
278+
const data = await readJson(path.join(context.outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json"))
282279
for (let name of Object.getOwnPropertyNames(data)) {
283280
if (name[0] === "_") {
284281
throw new Error("Property name starts with _")
@@ -299,8 +296,8 @@ test.ifDevOrLinuxCi("smart unpack", () => {
299296
"edge-cs": "^1.0.0"
300297
}
301298
}),
302-
packed: (projectDir, outDir) => {
303-
assertThat(JSON.parse(extractFile(path.join(outDir, "linux", "resources", "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
299+
packed: context => {
300+
assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
304301
name: "debug"
305302
})
306303
return BluebirdPromise.resolve()

test/src/globTest.ts

Lines changed: 17 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ test.ifDevOrLinuxCi("ignore build resources", app({
2222
projectDirCreated: projectDir => {
2323
return outputFile(path.join(projectDir, "one/build/foo.txt"), "data")
2424
},
25-
packed: (projectDir, outDir) => {
26-
return assertThat(path.join(outDir, "linux", "resources", "app", "one", "build", "foo.txt")).isFile()
25+
packed: context => {
26+
return assertThat(path.join(context.getResources(Platform.LINUX), "app", "one", "build", "foo.txt")).isFile()
2727
},
2828
}))
2929

@@ -39,8 +39,8 @@ test.ifDevOrLinuxCi("files", app({
3939
projectDirCreated: projectDir => {
4040
return outputFile(path.join(projectDir, "ignoreMe", "foo"), "data")
4141
},
42-
packed: (projectDir, outDir) => {
43-
return assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist()
42+
packed: context => {
43+
return assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist()
4444
},
4545
}))
4646

@@ -60,10 +60,10 @@ test.ifDevOrLinuxCi("unpackDir one", app({
6060
outputFile(path.join(projectDir, "b2", "file"), "data"),
6161
])
6262
},
63-
packed: (projectDir, outDir) => {
63+
packed: context => {
6464
return BluebirdPromise.all([
65-
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(),
66-
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(),
65+
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(),
66+
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(),
6767
])
6868
},
6969
}))
@@ -85,10 +85,10 @@ test.ifDevOrLinuxCi("unpackDir", () => {
8585
outputFile(path.join(projectDir, "app", "b2", "file"), "data"),
8686
])
8787
},
88-
packed: (projectDir, outDir) => {
88+
packed: context => {
8989
return BluebirdPromise.all([
90-
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(),
91-
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(),
90+
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(),
91+
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(),
9292
])
9393
},
9494
})
@@ -120,10 +120,10 @@ test.ifNotCiOsx("ignore node_modules known dev dep", () => {
120120
outputFile(path.join(projectDir, "ignoreMe"), ""),
121121
])
122122
},
123-
packed: (projectDir, outDir) => {
123+
packed: context => {
124124
return BluebirdPromise.all([
125-
assertThat(path.join(outDir, "linux", "resources", "app", "node_modules", "electron-osx-sign")).doesNotExist(),
126-
assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist(),
125+
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-osx-sign")).doesNotExist(),
126+
assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist(),
127127
])
128128
},
129129
})
@@ -185,15 +185,12 @@ test("extraResources", async () => {
185185
outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
186186
])
187187
},
188-
packed: async (projectDir, outDir) => {
189-
const base = path.join(outDir, platform.buildConfigurationKey)
188+
packed: async context => {
189+
const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`)
190190
let resourcesDir = path.join(base, "resources")
191191
if (platform === Platform.MAC) {
192192
resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources")
193193
}
194-
else if (platform === Platform.WINDOWS) {
195-
resourcesDir = path.join(base + "-unpacked", "resources")
196-
}
197194
await assertThat(path.join(resourcesDir, "foo")).isDirectory()
198195
await assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile()
199196
await assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile()
@@ -258,15 +255,12 @@ test("extraResources - one-package", async () => {
258255
outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
259256
])
260257
},
261-
packed: async (projectDir, outDir) => {
262-
const base = path.join(outDir, platform.buildConfigurationKey)
258+
packed: async context => {
259+
const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`)
263260
let resourcesDir = path.join(base, "resources")
264261
if (platform === Platform.MAC) {
265262
resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources")
266263
}
267-
else if (platform === Platform.WINDOWS) {
268-
resourcesDir = path.join(base + "-unpacked", "resources")
269-
}
270264
const appDir = path.join(resourcesDir, "app")
271265

272266
await assertThat(path.join(resourcesDir, "foo")).isDirectory()

test/src/helpers/packTester.ts

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const OUT_DIR_NAME = "dist"
2929

3030
interface AssertPackOptions {
3131
readonly projectDirCreated?: (projectDir: string) => Promise<any>
32-
readonly packed?: (projectDir: string, outDir: string) => Promise<any>
32+
readonly packed?: (context: PackedContext) => Promise<any>
3333
readonly expectedContents?: Array<string>
3434
readonly expectedArtifacts?: Array<string>
3535

@@ -41,6 +41,14 @@ interface AssertPackOptions {
4141
readonly npmInstallBefore?: boolean
4242
}
4343

44+
interface PackedContext {
45+
readonly projectDir: string,
46+
readonly outDir: string
47+
48+
readonly getResources: (platform: Platform) => string
49+
readonly getContent: (platform: Platform) => string
50+
}
51+
4452
let tmpDirCounter = 0
4553

4654
export function appThrows(error: RegExp, packagerOptions: PackagerOptions, checkOptions: AssertPackOptions = {}) {
@@ -106,7 +114,16 @@ export async function assertPack(fixtureName: string, packagerOptions: PackagerO
106114
}, packagerOptions), checkOptions)
107115

108116
if (checkOptions.packed != null) {
109-
await checkOptions.packed(projectDir, outDir)
117+
function base(platform: Platform): string {
118+
return path.join(outDir, `${platform.buildConfigurationKey}${platform === Platform.MAC ? "" : "-unpacked"}`)
119+
}
120+
121+
await checkOptions.packed({
122+
projectDir: projectDir,
123+
outDir: outDir,
124+
getResources: platform => path.join(base(platform), "resources"),
125+
getContent: platform => base(platform),
126+
})
110127
}
111128
}
112129
finally {

test/src/macPackagerTest.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,10 @@ else {
110110
writeFile(path.join(projectDir, "build", "entitlements.mac.plist"), ""),
111111
writeFile(path.join(projectDir, "build", "entitlements.mac.inherit.plist"), ""),
112112
]),
113-
packed: projectDir => {
113+
packed: context => {
114114
assertThat(platformPackager.effectiveSignOptions).hasProperties({
115-
entitlements: path.join(projectDir, "build", "entitlements.mac.plist"),
116-
"entitlements-inherit": path.join(projectDir, "build", "entitlements.mac.inherit.plist"),
115+
entitlements: path.join(context.projectDir, "build", "entitlements.mac.plist"),
116+
"entitlements-inherit": path.join(context.projectDir, "build", "entitlements.mac.inherit.plist"),
117117
})
118118
return BluebirdPromise.resolve()
119119
}
@@ -178,10 +178,10 @@ test.ifOsx("custom background - new way", () => {
178178
}
179179
})
180180
]),
181-
packed: async (projectDir) => {
181+
packed: async context => {
182182
assertThat(platformPackager.effectiveDistOptions.background).isEqualTo(customBackground)
183183
assertThat(platformPackager.effectiveDistOptions.icon).isEqualTo("foo.icns")
184-
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.icns"))
184+
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.icns"))
185185
},
186186
})
187187
})

test/src/nsisTest.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ test("one-click", app({
2626
}, {
2727
useTempDir: true,
2828
signed: true,
29-
packed: (projectDir, outDir) => {
30-
return doTest(outDir, true)
29+
packed: context => {
30+
return doTest(context.outDir, true)
3131
}
3232
}))
3333

@@ -54,8 +54,8 @@ test.ifDevOrLinuxCi("perMachine, no run after finish", app({
5454
let headerIconPath = path.join(projectDir, "build", "foo.ico")
5555
return copy(getTestAsset("headerIcon.ico"), headerIconPath)
5656
},
57-
packed: (projectDir, outDir) => {
58-
return doTest(outDir, false)
57+
packed: context => {
58+
return doTest(context.outDir, false)
5959
},
6060
}))
6161

@@ -194,14 +194,14 @@ test.ifNotCiOsx("boring, MUI_HEADER as option", () => {
194194

195195
test.ifDevOrLinuxCi("custom include", () => assertPack("test-app-one", {targets: nsisTarget}, {
196196
projectDirCreated: projectDir => copy(getTestAsset("installer.nsh"), path.join(projectDir, "build", "installer.nsh")),
197-
packed: projectDir => BluebirdPromise.all([
198-
assertThat(path.join(projectDir, "build", "customHeader")).isFile(),
199-
assertThat(path.join(projectDir, "build", "customInit")).isFile(),
200-
assertThat(path.join(projectDir, "build", "customInstall")).isFile(),
197+
packed: context => BluebirdPromise.all([
198+
assertThat(path.join(context.projectDir, "build", "customHeader")).isFile(),
199+
assertThat(path.join(context.projectDir, "build", "customInit")).isFile(),
200+
assertThat(path.join(context.projectDir, "build", "customInstall")).isFile(),
201201
]),
202202
}))
203203

204204
test.ifDevOrLinuxCi("custom script", app({targets: nsisTarget}, {
205205
projectDirCreated: projectDir => copy(getTestAsset("installer.nsi"), path.join(projectDir, "build", "installer.nsi")),
206-
packed: projectDir => assertThat(path.join(projectDir, "build", "customInstallerScript")).isFile(),
206+
packed: context => assertThat(path.join(context.projectDir, "build", "customInstallerScript")).isFile(),
207207
}))

test/src/winPackagerTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,8 @@ test.ifOsx("custom icon", () => {
108108
}
109109
})
110110
]),
111-
packed: async (projectDir) => {
112-
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.ico"))
111+
packed: async context => {
112+
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.ico"))
113113
return BluebirdPromise.resolve()
114114
},
115115
})

0 commit comments

Comments
 (0)