Skip to content

Commit

Permalink
feat: install-app-deps.ts subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Jun 13, 2017
1 parent ac44fcd commit 5e0a646
Show file tree
Hide file tree
Showing 15 changed files with 51 additions and 45 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
"ajv": "^5.1.5",
"ajv-keywords": "^2.1.0",
"archiver": "^1.3.0",
"aws-sdk": "^2.67.0",
"aws-sdk": "^2.68.0",
"bluebird-lst": "^1.0.2",
"chalk": "^1.1.3",
"chromium-pickle-js": "^0.2.0",
Expand Down Expand Up @@ -63,7 +63,7 @@
"update-notifier": "^2.2.0",
"uuid-1345": "^0.99.6",
"xelement": "^1.0.16",
"yargs": "^8.0.1"
"yargs": "^8.0.2"
},
"devDependencies": {
"@types/ini": "^1.3.29",
Expand Down Expand Up @@ -92,7 +92,7 @@
"source-map-support": "^0.4.15",
"ts-babel": "^3.0.1",
"tslint": "^5.4.3",
"typescript": "^2.3.4",
"typescript": "^2.4.0",
"whitespace": "^2.1.0",
"xml2js": "^0.4.17"
},
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder-core/src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,8 +135,8 @@ export interface BeforeBuildContext {
}

export interface SourceRepositoryInfo {
type: string
domain: string
type?: string
domain?: string
user: string
project: string
}
2 changes: 1 addition & 1 deletion packages/electron-builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"semver": "^5.3.0",
"update-notifier": "^2.2.0",
"uuid-1345": "^0.99.6",
"yargs": "^8.0.1",
"yargs": "^8.0.2",
"debug": "2.6.8",
"asar-integrity": "0.0.0-semantic-release"
},
Expand Down
5 changes: 5 additions & 0 deletions packages/electron-builder/src/cli/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,14 @@ import { printErrorAndExit } from "electron-builder-util/out/promise"
import yargs from "yargs"
import { buildCommandHandler, configureBuildCommand } from "../builder"
import { createSelfSignedCert } from "./create-self-signed-cert"
import { configureInstallAppDepsCommand, installAppDeps } from "./install-app-deps"

yargs
.command(<any>["build", "*"], "Build", configureBuildCommand, buildCommandHandler)
.command("install-app-deps", "Install app deps", configureInstallAppDepsCommand, argv => {
installAppDeps(argv)
.catch(printErrorAndExit)
})
.command("create-self-signed-cert", "Create self-signed code signing cert for Windows apps",
yargs => yargs
.option("publisher", {
Expand Down
17 changes: 12 additions & 5 deletions packages/electron-builder/src/cli/install-app-deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import yargs from "yargs"
import { getElectronVersion, loadConfig } from "../util/readPackageJson"
import { installOrRebuild } from "../yarn"

async function main() {
const args: any = yargs
export function configureInstallAppDepsCommand(yargs: yargs.Yargs): yargs.Yargs {
return yargs
.option("platform", {
choices: ["linux", "darwin", "win32"],
default: process.platform,
Expand All @@ -17,8 +17,9 @@ async function main() {
choices: ["ia32", "x64", "all"],
default: process.arch,
})
.argv
}

export async function installAppDeps(args: any) {
const projectDir = process.cwd()
const config = (await loadConfig(projectDir)) || {}
const muonVersion = config.muonVersion
Expand All @@ -31,5 +32,11 @@ async function main() {
await installOrRebuild(config, results[0], {version: results[1], useCustomDist: muonVersion == null}, args.platform, args.arch, results[0] !== projectDir)
}

main()
.catch(printErrorAndExit)
function main() {
return installAppDeps(configureInstallAppDepsCommand(yargs).argv)
}

if (process.mainModule === module) {
main()
.catch(printErrorAndExit)
}
2 changes: 1 addition & 1 deletion packages/electron-builder/src/options/winOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ export interface SquirrelWindowsOptions extends WinBuildOptions {
/**
* AppX options. See [Windows AppX docs](https://msdn.microsoft.com/en-us/library/windows/apps/br211453.aspx).
*/
export interface AppXOptions {
export interface AppXOptions extends TargetSpecificOptions {
/**
* The background color of the app tile.
* @see [Visual Elements](https://msdn.microsoft.com/en-us/library/windows/apps/br211471.aspx).
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ export class Packager implements BuildInfo {

readonly tempDirManager = new TmpDir()

private _repositoryInfo = new Lazy<SourceRepositoryInfo>(() => getRepositoryInfo(this.projectDir, this.metadata, this.devMetadata))
private _repositoryInfo = new Lazy<SourceRepositoryInfo | null>(() => getRepositoryInfo(this.projectDir, this.metadata, this.devMetadata))

private readonly afterPackHandlers: Array<(context: AfterPackContext) => Promise<any> | null> = []

get repositoryInfo(): Promise<SourceRepositoryInfo> {
get repositoryInfo(): Promise<SourceRepositoryInfo | null> {
return this._repositoryInfo.value
}

Expand Down
12 changes: 4 additions & 8 deletions packages/electron-builder/src/repositoryInfo.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { SourceRepositoryInfo } from "electron-builder-core"
import { readFile } from "fs-extra-p"
import { fromUrl as parseRepositoryUrl, Info } from "hosted-git-info"
import { fromUrl as parseRepositoryUrl } from "hosted-git-info"
import * as path from "path"
import { Metadata, RepositoryInfo } from "./metadata"

export interface RepositorySlug {
user: string
project: string
}

export function getRepositoryInfo(projectDir: string, metadata?: Metadata, devMetadata?: Metadata): Promise<Info | null> {
export function getRepositoryInfo(projectDir: string, metadata?: Metadata, devMetadata?: Metadata): Promise<SourceRepositoryInfo | null> {
return _getInfo(projectDir, <RepositoryInfo>(devMetadata == null ? null : devMetadata.repository) || (metadata == null ? null : metadata.repository))
}

Expand Down Expand Up @@ -40,7 +36,7 @@ async function getGitUrlFromGitConfig(projectDir: string): Promise<string | null
return null
}

async function _getInfo(projectDir: string, repo?: RepositoryInfo | null): Promise<RepositorySlug | null> {
async function _getInfo(projectDir: string, repo?: RepositoryInfo | null): Promise<SourceRepositoryInfo | null> {
if (repo != null) {
return parseRepositoryUrl(typeof repo === "string" ? repo : repo.url)
}
Expand Down
9 changes: 3 additions & 6 deletions packages/electron-builder/src/winPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
}
})

private iconPath: Promise<string> | null
private _iconPath = new Lazy<string | null>(() => this.getValidIconPath())

readonly computedPublisherName = new Lazy<Array<string> | null>(async () => {
let publisherName = (<WinBuildOptions>this.platformSpecificBuildOptions).publisherName
Expand All @@ -71,7 +71,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
if (publisherName == null && cscFile != null) {
if (process.platform === "win32") {
try {
const subject = parseDn(await exec("powershell.exe", [`(Get-PfxCertificate "${cscFile}").Subject`])).get("CN")
const subject = parseDn(await exec("powershell.exe", [`(Get-PfxCertificate "${cscFile}").Subject`], {timeout: 30 * 1000})).get("CN")
if (subject) {
return asArray(subject)
}
Expand Down Expand Up @@ -161,10 +161,7 @@ export class WinPackager extends PlatformPackager<WinBuildOptions> {
}

getIconPath() {
if (this.iconPath == null) {
this.iconPath = this.getValidIconPath()
}
return this.iconPath
return this._iconPath.value
}

private async getValidIconPath(): Promise<string | null> {
Expand Down
4 changes: 2 additions & 2 deletions packages/electron-publish/src/gitHubPublisher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ interface Asset {

export class GitHubPublisher extends HttpPublisher {
private tag: string
private _releasePromise: Promise<Release>
private _releasePromise: Promise<Release | null>

private readonly token: string

Expand Down Expand Up @@ -155,7 +155,7 @@ export class GitHubPublisher extends HttpPublisher {
// test only
//noinspection JSUnusedGlobalSymbols
async getRelease(): Promise<any> {
return this.githubRequest<Release>(`/repos/${this.info.owner}/${this.info.repo}/releases/${(await this._releasePromise).id}`, this.token)
return this.githubRequest<Release>(`/repos/${this.info.owner}/${this.info.repo}/releases/${(await this._releasePromise)!.id}`, this.token)
}

//noinspection JSUnusedGlobalSymbols
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-publisher-s3/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"dependencies": {
"fs-extra-p": "^4.3.0",
"aws-sdk": "^2.67.0",
"aws-sdk": "^2.68.0",
"mime": "^1.3.6",
"electron-publish": "~0.0.0-semantic-release",
"electron-builder-util": "~0.0.0-semantic-release"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-updater/src/NsisUpdater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class NsisUpdater extends AppUpdater {
}

return await new BluebirdPromise<string | null>((resolve, reject) => {
execFile("powershell.exe", [`Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress`], {maxBuffer: 4 * 1024000}, (error, stdout, stderr) => {
execFile("powershell.exe", [`Get-AuthenticodeSignature '${tempUpdateFile}' | ConvertTo-Json -Compress`], {maxBuffer: 4 * 1024000, timeout: 60 * 1000}, (error, stdout, stderr) => {
if (error != null) {
reject(error)
return
Expand Down
1 change: 1 addition & 0 deletions packages/jsdoc2md.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ async function main() {
"!***/*-repositoryInfo.js",
"!***/*-readPackageJson.js",
"!***/*-create-self-signed-cert.js",
"!***/*-install-app-deps.js",
], {cwd: source}))
.filter(it => !userFiles.includes(it))

Expand Down
2 changes: 1 addition & 1 deletion test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ test("cli", async () => {
expect(parseExtraMetadata("--em.foo=bar"))
})

test("build in the app package.json", appTwoThrows(linuxDirTarget, {
test("build in the app package.json", appTwoThrows({targets: linuxDirTarget}, {
projectDirCreated: it => modifyPackageJson(it, data => {
data.build = {
"productName": "bar",
Expand Down
24 changes: 12 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@
resolved "https://registry.yarnpkg.com/@types/node-forge/-/node-forge-0.6.9.tgz#38e0e00de8e6f3ff0bb1f4cddcad43e7b580733a"

"@types/node@*":
version "7.0.29"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.29.tgz#ccfcec5b7135c7caf6c4ffb8c7f33102340d99df"
version "7.0.31"
resolved "https://registry.yarnpkg.com/@types/node/-/node-7.0.31.tgz#80ea4d175599b2a00149c29a10a4eb2dff592e86"

"@types/source-map-support@^0.4.0":
version "0.4.0"
Expand Down Expand Up @@ -135,8 +135,8 @@ ansi-styles@^2.2.1:
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe"

ansi-styles@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.0.0.tgz#5404e93a544c4fec7f048262977bebfe3155e0c1"
version "3.1.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.1.0.tgz#09c202d5c917ec23188caa5c9cb9179cd9547750"
dependencies:
color-convert "^1.0.0"

Expand Down Expand Up @@ -265,9 +265,9 @@ asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"

aws-sdk@^2.67.0:
version "2.67.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.67.0.tgz#c0fc3a4343cfc631265d9dd6bc50ba709401f857"
aws-sdk@^2.68.0:
version "2.68.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.68.0.tgz#9bad3135b31fa82be72a5985189a37aee70c6940"
dependencies:
buffer "5.0.6"
crypto-browserify "1.0.9"
Expand Down Expand Up @@ -3356,8 +3356,8 @@ type-check@~0.3.2:
prelude-ls "~1.1.2"

typescript@^2.3.4:
version "2.3.4"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.3.4.tgz#3d38321828231e434f287514959c37a82b629f42"
version "2.4.0"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-2.4.0.tgz#aef5a8d404beba36ad339abf079ddddfffba86dd"

typescript@~2.1.5:
version "2.1.6"
Expand Down Expand Up @@ -3721,9 +3721,9 @@ yargs@^7.0.2:
y18n "^3.2.1"
yargs-parser "^5.0.0"

yargs@^8.0.1:
version "8.0.1"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.1.tgz#420ef75e840c1457a80adcca9bc6fa3849de51aa"
yargs@^8.0.2:
version "8.0.2"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-8.0.2.tgz#6299a9055b1cefc969ff7e79c1d918dceb22c360"
dependencies:
camelcase "^4.1.0"
cliui "^3.2.0"
Expand Down

0 comments on commit 5e0a646

Please sign in to comment.