From ae036c6ff2c7db2b1127748b47d8fddd1afda248 Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 16 Feb 2017 08:59:45 +0100 Subject: [PATCH] feat: make description optional (just a warning) --- circle.yml | 2 +- packages/electron-builder/src/appInfo.ts | 2 +- packages/electron-builder/src/packager.ts | 13 +++++++++---- test/src/BuildTest.ts | 8 -------- 4 files changed, 11 insertions(+), 14 deletions(-) diff --git a/circle.yml b/circle.yml index eef75fa33d1..bf8dc19978c 100644 --- a/circle.yml +++ b/circle.yml @@ -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 git@github.com 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" diff --git a/packages/electron-builder/src/appInfo.ts b/packages/electron-builder/src/appInfo.ts index e9e3bc602b2..8e717024c7e 100644 --- a/packages/electron-builder/src/appInfo.ts +++ b/packages/electron-builder/src/appInfo.ts @@ -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 diff --git a/packages/electron-builder/src/packager.ts b/packages/electron-builder/src/packager.ts index c131fff872e..9bb188ce7a0 100644 --- a/packages/electron-builder/src/packager.ts +++ b/packages/electron-builder/src/packager.ts @@ -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" @@ -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 @@ -280,7 +282,7 @@ export class Packager implements BuildInfo { private checkMetadata(appPackageFile: string, devAppPackageFile: string): void { const errors: Array = [] 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) => { @@ -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) @@ -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) { diff --git a/test/src/BuildTest.ts b/test/src/BuildTest.ts index cf5d3a55d9e..3427da683cf 100644 --- a/test/src/BuildTest.ts +++ b/test/src/BuildTest.ts @@ -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: { - description: "", - } -})) - test("relative index", () => assertPack("test-app", allPlatforms(false), { projectDirCreated: projectDir => modifyPackageJson(projectDir, data => { data.main = "./index.js"