Skip to content

Commit

Permalink
fix: rename linux to linux-unpacked #670
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Aug 26, 2016
1 parent bda802e commit 5d404ea
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 66 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,11 @@
"archiver": "^1.0.1",
"archiver-utils": "^1.2.0",
"asar-electron-builder": "^0.13.2",
"bluebird": "^3.4.1",
"bluebird": "^3.4.3",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.1.0",
"cli-cursor": "^1.0.2",
"cuint": "^0.2.1",
"cuint": "^0.2.2",
"debug": "^2.2.0",
"electron-download": "^2.1.2",
"electron-osx-sign": "^0.4.0-beta4",
Expand Down Expand Up @@ -109,21 +109,21 @@
"@types/debug": "0.0.28",
"@types/mime": "0.0.28",
"@types/progress": "^1.1.27",
"@types/semver": "^5.3.28",
"@types/semver": "^5.3.29",
"@types/source-map-support": "^0.2.27",
"ava-tf": "^0.16.0",
"babel-plugin-array-includes": "^2.0.3",
"babel-plugin-transform-es2015-destructuring": "^6.9.0",
"babel-plugin-transform-es2015-parameters": "^6.11.4",
"babel-plugin-transform-es2015-spread": "^6.8.0",
"decompress-zip": "^0.3.0",
"diff": "^2.2.3",
"diff": "^3.0.0",
"json8": "^0.9.2",
"path-sort": "^0.1.0",
"pre-git": "^3.10.0",
"ts-babel": "^1.0.4",
"tslint": "^3.14.0-dev.1",
"typescript": "^2.1.0-dev.20160802",
"tslint": "^3.15.1",
"typescript": "^2.1.0-dev.20160826",
"whitespace": "^2.1.0"
},
"babel": {
Expand Down
2 changes: 1 addition & 1 deletion src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
}

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

dispatchArtifactCreated(file: string, artifactName?: string) {
Expand Down
4 changes: 2 additions & 2 deletions src/util/filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@ function flatDependencies(data: any, seen: Set<string>): any {
return flatDependencies(deps[d], seen)
})
.filter(it => it !== null)
.reduce(function FLAT(l, r) {
return l.concat(Array.isArray(r) ? r.reduce(FLAT, []) : r)
.reduce(function flat(l, r): Array<string> {
return l.concat(Array.isArray(r) ? r.reduce(flat, []) : r)
}, [])

}
Expand Down
29 changes: 13 additions & 16 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ test("custom output dir", app(allPlatforms(false), {
app: ".",
}
}),
packed: async (projectDir) => {
await assertThat(path.join(projectDir, "customDist")).isDirectory()
packed: async context => {
await assertThat(path.join(context.projectDir, "customDist")).isDirectory()
}
}))

Expand Down Expand Up @@ -225,10 +225,9 @@ test.ifDevOrLinuxCi("extra metadata", () => {
existingProp: 22,
}
}),
packed: async (projectDir) => {
const out = path.join(projectDir, "dist", "linux")
await assertThat(path.join(out, "NewName")).isFile()
assertThat(JSON.parse(extractFile(path.join(out, "resources", "app.asar"), "package.json").toString())).hasProperties({
packed: async context => {
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "package.json").toString())).hasProperties({
foo: {
bar: 12,
existingProp: 22,
Expand All @@ -246,9 +245,8 @@ test.ifDevOrLinuxCi("extra metadata - two", () => {
targets: Platform.LINUX.createTarget(DIR_TARGET),
extraMetadata: extraMetadata,
}, {
packed: async (projectDir, outDir) => {
const out = path.join(outDir, "linux")
await assertThat(path.join(out, "NewName")).isFile()
packed: async context => {
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
}
})
})
Expand All @@ -265,9 +263,8 @@ test.ifOsx("extra metadata - override icon", t => t.throws((() => {
targets: Platform.OSX.createTarget(DIR_TARGET),
extraMetadata: extraMetadata,
}, {
packed: async (projectDir, outDir) => {
const out = path.join(outDir, "linux")
await assertThat(path.join(out, "NewName")).isFile()
packed: async context => {
await assertThat(path.join(context.getContent(Platform.LINUX), "NewName")).isFile()
}
})
})(), /ENOENT: no such file or directory/))
Expand All @@ -277,8 +274,8 @@ test.ifOsx("app-executable-deps", () => {
targets: Platform.current().createTarget(DIR_TARGET),
}, {
useTempDir: false,
packed: async (projectDir, outDir) => {
const data = await readJson(path.join(outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json"))
packed: async context => {
const data = await readJson(path.join(context.outDir, "mac/app-executable-deps.app/Contents/Resources/app.asar.unpacked", "node_modules", "node-notifier", "package.json"))
for (let name of Object.getOwnPropertyNames(data)) {
if (name[0] === "_") {
throw new Error("Property name starts with _")
Expand All @@ -299,8 +296,8 @@ test.ifDevOrLinuxCi("smart unpack", () => {
"edge-cs": "^1.0.0"
}
}),
packed: (projectDir, outDir) => {
assertThat(JSON.parse(extractFile(path.join(outDir, "linux", "resources", "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
packed: context => {
assertThat(JSON.parse(extractFile(path.join(context.getResources(Platform.LINUX), "app.asar"), "node_modules/debug/package.json").toString())).hasProperties({
name: "debug"
})
return BluebirdPromise.resolve()
Expand Down
40 changes: 17 additions & 23 deletions test/src/globTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ test.ifDevOrLinuxCi("ignore build resources", app({
projectDirCreated: projectDir => {
return outputFile(path.join(projectDir, "one/build/foo.txt"), "data")
},
packed: (projectDir, outDir) => {
return assertThat(path.join(outDir, "linux", "resources", "app", "one", "build", "foo.txt")).isFile()
packed: context => {
return assertThat(path.join(context.getResources(Platform.LINUX), "app", "one", "build", "foo.txt")).isFile()
},
}))

Expand All @@ -39,8 +39,8 @@ test.ifDevOrLinuxCi("files", app({
projectDirCreated: projectDir => {
return outputFile(path.join(projectDir, "ignoreMe", "foo"), "data")
},
packed: (projectDir, outDir) => {
return assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist()
packed: context => {
return assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist()
},
}))

Expand All @@ -60,10 +60,10 @@ test.ifDevOrLinuxCi("unpackDir one", app({
outputFile(path.join(projectDir, "b2", "file"), "data"),
])
},
packed: (projectDir, outDir) => {
packed: context => {
return BluebirdPromise.all([
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(),
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(),
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(),
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(),
])
},
}))
Expand All @@ -85,10 +85,10 @@ test.ifDevOrLinuxCi("unpackDir", () => {
outputFile(path.join(projectDir, "app", "b2", "file"), "data"),
])
},
packed: (projectDir, outDir) => {
packed: context => {
return BluebirdPromise.all([
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "assets")).isDirectory(),
assertThat(path.join(outDir, "linux", "resources", "app.asar.unpacked", "b2")).isDirectory(),
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "assets")).isDirectory(),
assertThat(path.join(context.getResources(Platform.LINUX), "app.asar.unpacked", "b2")).isDirectory(),
])
},
})
Expand Down Expand Up @@ -120,10 +120,10 @@ test.ifNotCiOsx("ignore node_modules known dev dep", () => {
outputFile(path.join(projectDir, "ignoreMe"), ""),
])
},
packed: (projectDir, outDir) => {
packed: context => {
return BluebirdPromise.all([
assertThat(path.join(outDir, "linux", "resources", "app", "node_modules", "electron-osx-sign")).doesNotExist(),
assertThat(path.join(outDir, "linux", "resources", "app", "ignoreMe")).doesNotExist(),
assertThat(path.join(context.getResources(Platform.LINUX), "app", "node_modules", "electron-osx-sign")).doesNotExist(),
assertThat(path.join(context.getResources(Platform.LINUX), "app", "ignoreMe")).doesNotExist(),
])
},
})
Expand Down Expand Up @@ -185,15 +185,12 @@ test("extraResources", async () => {
outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
])
},
packed: async (projectDir, outDir) => {
const base = path.join(outDir, platform.buildConfigurationKey)
packed: async context => {
const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`)
let resourcesDir = path.join(base, "resources")
if (platform === Platform.MAC) {
resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources")
}
else if (platform === Platform.WINDOWS) {
resourcesDir = path.join(base + "-unpacked", "resources")
}
await assertThat(path.join(resourcesDir, "foo")).isDirectory()
await assertThat(path.join(resourcesDir, "foo", "nameWithoutDot")).isFile()
await assertThat(path.join(resourcesDir, "bar", "hello.txt")).isFile()
Expand Down Expand Up @@ -258,15 +255,12 @@ test("extraResources - one-package", async () => {
outputFile(path.join(projectDir, "ignoreMe.txt"), "ignoreMe"),
])
},
packed: async (projectDir, outDir) => {
const base = path.join(outDir, platform.buildConfigurationKey)
packed: async context => {
const base = path.join(context.outDir, platform.buildConfigurationKey + `${platform === Platform.MAC ? "" : "-unpacked"}`)
let resourcesDir = path.join(base, "resources")
if (platform === Platform.MAC) {
resourcesDir = path.join(base, "TestApp.app", "Contents", "Resources")
}
else if (platform === Platform.WINDOWS) {
resourcesDir = path.join(base + "-unpacked", "resources")
}
const appDir = path.join(resourcesDir, "app")

await assertThat(path.join(resourcesDir, "foo")).isDirectory()
Expand Down
21 changes: 19 additions & 2 deletions test/src/helpers/packTester.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const OUT_DIR_NAME = "dist"

interface AssertPackOptions {
readonly projectDirCreated?: (projectDir: string) => Promise<any>
readonly packed?: (projectDir: string, outDir: string) => Promise<any>
readonly packed?: (context: PackedContext) => Promise<any>
readonly expectedContents?: Array<string>
readonly expectedArtifacts?: Array<string>

Expand All @@ -41,6 +41,14 @@ interface AssertPackOptions {
readonly npmInstallBefore?: boolean
}

interface PackedContext {
readonly projectDir: string,
readonly outDir: string

readonly getResources: (platform: Platform) => string
readonly getContent: (platform: Platform) => string
}

let tmpDirCounter = 0

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

if (checkOptions.packed != null) {
await checkOptions.packed(projectDir, outDir)
function base(platform: Platform): string {
return path.join(outDir, `${platform.buildConfigurationKey}${platform === Platform.MAC ? "" : "-unpacked"}`)
}

await checkOptions.packed({
projectDir: projectDir,
outDir: outDir,
getResources: platform => path.join(base(platform), "resources"),
getContent: platform => base(platform),
})
}
}
finally {
Expand Down
10 changes: 5 additions & 5 deletions test/src/macPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ else {
writeFile(path.join(projectDir, "build", "entitlements.mac.plist"), ""),
writeFile(path.join(projectDir, "build", "entitlements.mac.inherit.plist"), ""),
]),
packed: projectDir => {
packed: context => {
assertThat(platformPackager.effectiveSignOptions).hasProperties({
entitlements: path.join(projectDir, "build", "entitlements.mac.plist"),
"entitlements-inherit": path.join(projectDir, "build", "entitlements.mac.inherit.plist"),
entitlements: path.join(context.projectDir, "build", "entitlements.mac.plist"),
"entitlements-inherit": path.join(context.projectDir, "build", "entitlements.mac.inherit.plist"),
})
return BluebirdPromise.resolve()
}
Expand Down Expand Up @@ -178,10 +178,10 @@ test.ifOsx("custom background - new way", () => {
}
})
]),
packed: async (projectDir) => {
packed: async context => {
assertThat(platformPackager.effectiveDistOptions.background).isEqualTo(customBackground)
assertThat(platformPackager.effectiveDistOptions.icon).isEqualTo("foo.icns")
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.icns"))
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.icns"))
},
})
})
Expand Down
18 changes: 9 additions & 9 deletions test/src/nsisTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ test("one-click", app({
}, {
useTempDir: true,
signed: true,
packed: (projectDir, outDir) => {
return doTest(outDir, true)
packed: context => {
return doTest(context.outDir, true)
}
}))

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

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

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

test.ifDevOrLinuxCi("custom script", app({targets: nsisTarget}, {
projectDirCreated: projectDir => copy(getTestAsset("installer.nsi"), path.join(projectDir, "build", "installer.nsi")),
packed: projectDir => assertThat(path.join(projectDir, "build", "customInstallerScript")).isFile(),
packed: context => assertThat(path.join(context.projectDir, "build", "customInstallerScript")).isFile(),
}))
4 changes: 2 additions & 2 deletions test/src/winPackagerTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ test.ifOsx("custom icon", () => {
}
})
]),
packed: async (projectDir) => {
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(projectDir, "customIcon.ico"))
packed: async context => {
assertThat(await platformPackager.getIconPath()).isEqualTo(path.join(context.projectDir, "customIcon.ico"))
return BluebirdPromise.resolve()
},
})
Expand Down

0 comments on commit 5d404ea

Please sign in to comment.