Skip to content

Commit

Permalink
feat: make description optional (just a warning)
Browse files Browse the repository at this point in the history
  • Loading branch information
develar committed Feb 17, 2017
1 parent bce672e commit ae036c6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ dependencies:
# circleci doesn't cache after test, only after deps, so, we do test in this phase
override:
- curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.deb.sh | sudo bash
- sudo apt-get install git-lfs=1.3.0
- sudo apt-get install git-lfs
- ssh [email protected] git-lfs-authenticate $CIRCLE_PROJECT_USERNAME/$CIRCLE_PROJECT_REPONAME.git download
- git lfs pull
- 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"
Expand Down
2 changes: 1 addition & 1 deletion packages/electron-builder/src/appInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SemVer } from "semver"
import { BuildInfo } from "./packagerApi"

export class AppInfo {
readonly description = smarten(this.metadata.description!)
readonly description = smarten(this.metadata.description || "")
readonly version: string
readonly buildNumber: string
readonly buildVersion: string
Expand Down
13 changes: 9 additions & 4 deletions packages/electron-builder/src/packager.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { extractFile } from "asar-electron-builder"
import BluebirdPromise from "bluebird-lst-c"
import { Arch, Platform, Target } from "electron-builder-core"
import { computeDefaultAppDirectory, exec, isEmptyOrSpaces, use } from "electron-builder-util"
import { computeDefaultAppDirectory, exec, isEmptyOrSpaces, use, debug } from "electron-builder-util"
import { deepAssign } from "electron-builder-util/out/deepAssign"
import { log, warn } from "electron-builder-util/out/log"
import { all, executeFinally } from "electron-builder-util/out/promise"
Expand Down Expand Up @@ -136,6 +136,8 @@ export class Packager implements BuildInfo {

if (this.isTwoPackageJsonProjectLayoutUsed) {
this.devMetadata = deepAssign(await readPackageJson(devPackageFile), devMetadataFromOptions)

debug(`Two package.json structure is used (dev: ${devPackageFile}, app: ${appPackageFile})`)
}
else {
this.devMetadata = this.metadata
Expand Down Expand Up @@ -280,7 +282,7 @@ export class Packager implements BuildInfo {
private checkMetadata(appPackageFile: string, devAppPackageFile: string): void {
const errors: Array<string> = []
const reportError = (missedFieldName: string) => {
errors.push(`Please specify '${missedFieldName}' in the application package.json ('${appPackageFile}')`)
errors.push(`Please specify '${missedFieldName}' in the package.json (${appPackageFile})`)
}

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

checkNotEmpty("name", appMetadata.name)
checkNotEmpty("description", appMetadata.description)

if (isEmptyOrSpaces(appMetadata.description)) {
warn(`description is missed in the package.json (${appPackageFile})`)
}
checkNotEmpty("version", appMetadata.version)

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

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

if (config.name != null) {
Expand Down
8 changes: 0 additions & 8 deletions test/src/BuildTest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,6 @@ test("build in the app package.json", appTwoThrows(/'build' in the application p

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

// this test also test appMetadata, so, we must use test-app here
test("empty description", appTwoThrows(/Please specify 'description'/, {
targets: Platform.LINUX.createTarget(),
appMetadata: <any>{
description: "",
}
}))

test("relative index", () => assertPack("test-app", allPlatforms(false), {
projectDirCreated: projectDir => modifyPackageJson(projectDir, data => {
data.main = "./index.js"
Expand Down

0 comments on commit ae036c6

Please sign in to comment.