Skip to content

Commit

Permalink
fix: Looks for linux homepage in the development package.json not in …
Browse files Browse the repository at this point in the history
…the application package.json

Closes #334
  • Loading branch information
develar committed Apr 19, 2016
1 parent c987439 commit 3da6893
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 18 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ Why the two package.json structure is ideal and how it solves a lot of issues
See [options](https://github.com/electron-userland/electron-builder/wiki/Options), but consider to follow simple guide outlined below at first.

## In short
1. Specify standard fields in the application `package.json`[name](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-name), `description`, `version` and [author](https://docs.npmjs.com/files/package.json#people-fields-author-contributors) (for Linux [homepage](https://github.com/electron-userland/electron-builder/wiki/Options#DevMetadata-homepage) and [license](https://github.com/electron-userland/electron-builder/wiki/Options#DevMetadata-license) are also required).
1. Specify standard fields in the application `package.json`[name](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-name), `description`, `version` and [author](https://docs.npmjs.com/files/package.json#people-fields-author-contributors) (for Linux [homepage](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-homepage) and [license](https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-license) are also required).

2. Specify [build](https://github.com/electron-userland/electron-builder/wiki/Options#build) field in the development `package.json`:
```json
Expand Down
4 changes: 2 additions & 2 deletions docs/Options.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,14 @@ Here documented only `electron-builder` specific options:
| **name** | <a name="AppMetadata-name"></a>The application name.
| productName | <a name="AppMetadata-productName"></a><p>As [name](#AppMetadata-name), but allows you to specify a product name for your executable which contains spaces and other special characters not allowed in the [name property](https://docs.npmjs.com/files/package.json#name}).</p>
| **description** | <a name="AppMetadata-description"></a>The application description.
| homepage | <a name="AppMetadata-homepage"></a><p>The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package <code>projectUrl</code> (optional) or Linux Package URL (required)).</p> <p>If not specified and your project repository is public on GitHub, it will be <code>https://github.com/${user}/${project}</code> by default.</p>
| license | <a name="AppMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.

<a name="DevMetadata"></a>
# Development `package.json`
| Name | Description
| --- | ---
| **build** | <a name="DevMetadata-build"></a>See [.build](#BuildMetadata).
| homepage | <a name="DevMetadata-homepage"></a><p>The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package <code>projectUrl</code> (optional) or Linux Package URL (required)).</p> <p>If not specified and your project repository is public on GitHub, it will be <code>https://github.com/${user}/${project}</code> by default.</p>
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
| directories | <a name="DevMetadata-directories"></a>See [.directories](#MetadataDirectories)

<a name="BuildMetadata"></a>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
"command-line-args": "^2.1.6",
"deep-assign": "^2.0.0",
"electron-packager": "^7.0.0",
"electron-winstaller-fixed": "~2.3.0-beta.0",
"electron-winstaller-fixed": "~2.3.0-beta.1",
"fs-extra": "^0.28.0",
"fs-extra-p": "^0.2.0",
"globby": "^4.0.0",
Expand Down
4 changes: 2 additions & 2 deletions src/linuxPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ Icon=${this.metadata.name}

const projectUrl = await this.computePackageUrl()
if (projectUrl == null) {
throw new Error("Please specify project homepage")
throw new Error("Please specify project homepage, see https://github.com/electron-userland/electron-builder/wiki/Options#AppMetadata-homepage")
}

const author = options.maintainer || `${this.metadata.author.name} <${this.metadata.author.email}>`
Expand All @@ -191,7 +191,7 @@ Icon=${this.metadata.name}
"--url", projectUrl,
]

use(this.devMetadata.license, it => args.push("--license", it))
use(this.metadata.license || this.devMetadata.license, it => args.push("--license", it))
use(this.computeBuildNumber(), it => args.push("--iteration", it))

use(options.fpm, it => args.push(...it))
Expand Down
22 changes: 14 additions & 8 deletions src/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ export interface AppMetadata extends Metadata {
readonly description: string

readonly author: AuthorMetadata

/*
The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)).
If not specified and your project repository is public on GitHub, it will be `https://github.com/${user}/${project}` by default.
*/
readonly homepage?: string

/*
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
*/
readonly license?: string
}

/*
Expand All @@ -36,16 +48,10 @@ export interface DevMetadata extends Metadata {
*/
readonly build: BuildMetadata

/*
The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)).
If not specified and your project repository is public on GitHub, it will be `https://github.com/${user}/${project}` by default.
*/
// deprecated
readonly homepage?: string

/*
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
*/
// deprecated
readonly license?: string

/*
Expand Down
16 changes: 13 additions & 3 deletions src/packager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,10 +150,20 @@ export class Packager implements BuildInfo {
else if (appMetadata.version == null) {
reportError("version")
}
else if ((<any>appMetadata) !== this.devMetadata && (<any>appMetadata).build != null) {
throw new Error(util.format(errorMessages.buildInAppSpecified, appPackageFile, devAppPackageFile))
else if ((<any>appMetadata) !== this.devMetadata) {
if ((<any>appMetadata).build != null) {
throw new Error(util.format(errorMessages.buildInAppSpecified, appPackageFile, devAppPackageFile))
}

if (this.devMetadata.homepage != null) {
console.warn("homepage in the development package.json is deprecated, please move to the application package.json")
}
if (this.devMetadata.license != null) {
console.warn("license in the development package.json is deprecated, please move to the application package.json")
}
}
else if (this.devMetadata.build == null) {

if (this.devMetadata.build == null) {
throw new Error(util.format(errorMessages.buildIsMissed, devAppPackageFile))
}
else {
Expand Down
2 changes: 1 addition & 1 deletion src/platformPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any>

protected async computePackageUrl(): Promise<string> {
const url = this.devMetadata.homepage
const url = this.metadata.homepage || this.devMetadata.homepage
if (url != null) {
return url
}
Expand Down

0 comments on commit 3da6893

Please sign in to comment.