Skip to content

Commit 3da6893

Browse files
committed
fix: Looks for linux homepage in the development package.json not in the application package.json
Closes #334
1 parent c987439 commit 3da6893

File tree

7 files changed

+34
-18
lines changed

7 files changed

+34
-18
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Why the two package.json structure is ideal and how it solves a lot of issues
4343
See [options](https://github.com/electron-userland/electron-builder/wiki/Options), but consider to follow simple guide outlined below at first.
4444

4545
## In short
46-
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).
46+
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).
4747

4848
2. Specify [build](https://github.com/electron-userland/electron-builder/wiki/Options#build) field in the development `package.json`:
4949
```json

docs/Options.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,14 @@ Here documented only `electron-builder` specific options:
3636
| **name** | <a name="AppMetadata-name"></a>The application name.
3737
| 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>
3838
| **description** | <a name="AppMetadata-description"></a>The application description.
39+
| 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>
40+
| license | <a name="AppMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
3941

4042
<a name="DevMetadata"></a>
4143
# Development `package.json`
4244
| Name | Description
4345
| --- | ---
4446
| **build** | <a name="DevMetadata-build"></a>See [.build](#BuildMetadata).
45-
| 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>
46-
| license | <a name="DevMetadata-license"></a>*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
4747
| directories | <a name="DevMetadata-directories"></a>See [.directories](#MetadataDirectories)
4848

4949
<a name="BuildMetadata"></a>

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"command-line-args": "^2.1.6",
6060
"deep-assign": "^2.0.0",
6161
"electron-packager": "^7.0.0",
62-
"electron-winstaller-fixed": "~2.3.0-beta.0",
62+
"electron-winstaller-fixed": "~2.3.0-beta.1",
6363
"fs-extra": "^0.28.0",
6464
"fs-extra-p": "^0.2.0",
6565
"globby": "^4.0.0",

src/linuxPackager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ Icon=${this.metadata.name}
169169

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

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

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

197197
use(options.fpm, it => args.push(...it))

src/metadata.ts

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@ export interface AppMetadata extends Metadata {
2525
readonly description: string
2626

2727
readonly author: AuthorMetadata
28+
29+
/*
30+
The url to the project [homepage](https://docs.npmjs.com/files/package.json#homepage) (NuGet Package `projectUrl` (optional) or Linux Package URL (required)).
31+
32+
If not specified and your project repository is public on GitHub, it will be `https://github.com/${user}/${project}` by default.
33+
*/
34+
readonly homepage?: string
35+
36+
/*
37+
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
38+
*/
39+
readonly license?: string
2840
}
2941

3042
/*
@@ -36,16 +48,10 @@ export interface DevMetadata extends Metadata {
3648
*/
3749
readonly build: BuildMetadata
3850

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

46-
/*
47-
*linux-only.* The [license](https://docs.npmjs.com/files/package.json#license) name.
48-
*/
54+
// deprecated
4955
readonly license?: string
5056

5157
/*

src/packager.ts

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,20 @@ export class Packager implements BuildInfo {
150150
else if (appMetadata.version == null) {
151151
reportError("version")
152152
}
153-
else if ((<any>appMetadata) !== this.devMetadata && (<any>appMetadata).build != null) {
154-
throw new Error(util.format(errorMessages.buildInAppSpecified, appPackageFile, devAppPackageFile))
153+
else if ((<any>appMetadata) !== this.devMetadata) {
154+
if ((<any>appMetadata).build != null) {
155+
throw new Error(util.format(errorMessages.buildInAppSpecified, appPackageFile, devAppPackageFile))
156+
}
157+
158+
if (this.devMetadata.homepage != null) {
159+
console.warn("homepage in the development package.json is deprecated, please move to the application package.json")
160+
}
161+
if (this.devMetadata.license != null) {
162+
console.warn("license in the development package.json is deprecated, please move to the application package.json")
163+
}
155164
}
156-
else if (this.devMetadata.build == null) {
165+
166+
if (this.devMetadata.build == null) {
157167
throw new Error(util.format(errorMessages.buildIsMissed, devAppPackageFile))
158168
}
159169
else {

src/platformPackager.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ export abstract class PlatformPackager<DC extends PlatformSpecificBuildOptions>
181181
abstract packageInDistributableFormat(outDir: string, appOutDir: string, arch: string): Promise<any>
182182

183183
protected async computePackageUrl(): Promise<string> {
184-
const url = this.devMetadata.homepage
184+
const url = this.metadata.homepage || this.devMetadata.homepage
185185
if (url != null) {
186186
return url
187187
}

0 commit comments

Comments
 (0)