Skip to content

Commit ae036c6

Browse files
committed
feat: make description optional (just a warning)
1 parent bce672e commit ae036c6

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

circle.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ dependencies:
1111
# circleci doesn't cache after test, only after deps, so, we do test in this phase
1212
override:
1313
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
14-
- sudo apt-get install git-lfs=1.3.0
14+
- sudo apt-get install git-lfs
1515
- ssh git@github.com git-lfs-authenticate $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git download
1616
- git lfs pull
1717
- docker run --rm --env-file ./test/docker-env.list -v ${PWD}:/project -v ~/.electron:/root/.electron -v ~/.cache/electron-builder:/root/.cache/electron-builder electronuserland/electron-builder:wine /bin/bash -c "node ./test/vendor/yarn.js --link-duplicates --pure-lockfile && node ./test/vendor/yarn.js test"

packages/electron-builder/src/appInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { SemVer } from "semver"
66
import { BuildInfo } from "./packagerApi"
77

88
export class AppInfo {
9-
readonly description = smarten(this.metadata.description!)
9+
readonly description = smarten(this.metadata.description || "")
1010
readonly version: string
1111
readonly buildNumber: string
1212
readonly buildVersion: string

packages/electron-builder/src/packager.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { extractFile } from "asar-electron-builder"
22
import BluebirdPromise from "bluebird-lst-c"
33
import { Arch, Platform, Target } from "electron-builder-core"
4-
import { computeDefaultAppDirectory, exec, isEmptyOrSpaces, use } from "electron-builder-util"
4+
import { computeDefaultAppDirectory, exec, isEmptyOrSpaces, use, debug } from "electron-builder-util"
55
import { deepAssign } from "electron-builder-util/out/deepAssign"
66
import { log, warn } from "electron-builder-util/out/log"
77
import { all, executeFinally } from "electron-builder-util/out/promise"
@@ -136,6 +136,8 @@ export class Packager implements BuildInfo {
136136

137137
if (this.isTwoPackageJsonProjectLayoutUsed) {
138138
this.devMetadata = deepAssign(await readPackageJson(devPackageFile), devMetadataFromOptions)
139+
140+
debug(`Two package.json structure is used (dev: ${devPackageFile}, app: ${appPackageFile})`)
139141
}
140142
else {
141143
this.devMetadata = this.metadata
@@ -280,7 +282,7 @@ export class Packager implements BuildInfo {
280282
private checkMetadata(appPackageFile: string, devAppPackageFile: string): void {
281283
const errors: Array<string> = []
282284
const reportError = (missedFieldName: string) => {
283-
errors.push(`Please specify '${missedFieldName}' in the application package.json ('${appPackageFile}')`)
285+
errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`)
284286
}
285287

286288
const checkNotEmpty = (name: string, value: string | n) => {
@@ -292,7 +294,10 @@ export class Packager implements BuildInfo {
292294
const appMetadata = this.metadata
293295

294296
checkNotEmpty("name", appMetadata.name)
295-
checkNotEmpty("description", appMetadata.description)
297+
298+
if (isEmptyOrSpaces(appMetadata.description)) {
299+
warn(`description is missed in the package.json (${appPackageFile})`)
300+
}
296301
checkNotEmpty("version", appMetadata.version)
297302

298303
checkDependencies(this.devMetadata.dependencies, errors)
@@ -320,7 +325,7 @@ export class Packager implements BuildInfo {
320325

321326
const author = appMetadata.author
322327
if (author == null) {
323-
errors.push(`Please specify "author" in the application package.json ('${appPackageFile}') — it is used as company name and copyright owner.`)
328+
errors.push(`Please specify "author" in the application package.json (${appPackageFile}) — it is used as company name and copyright owner.`)
324329
}
325330

326331
if (config.name != null) {

test/src/BuildTest.ts

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,6 @@ test("build in the app package.json", appTwoThrows(/'build' in the application p
100100

101101
test("name in the build", appThrows(/'name' in the config is forbidden/, currentPlatform(), {projectDirCreated: packageJson(it => it.build = {"name": "Cool App"})}))
102102

103-
// this test also test appMetadata, so, we must use test-app here
104-
test("empty description", appTwoThrows(/Please specify 'description'/, {
105-
targets: Platform.LINUX.createTarget(),
106-
appMetadata: <any>{
107-
description: "",
108-
}
109-
}))
110-
111103
test("relative index", () => assertPack("test-app", allPlatforms(false), {
112104
projectDirCreated: projectDir => modifyPackageJson(projectDir, data => {
113105
data.main = "./index.js"

0 commit comments

Comments
 (0)