From 76be3551bc9c0fe413d000183f7e7eadcba7cffb Mon Sep 17 00:00:00 2001 From: develar Date: Thu, 3 Nov 2016 17:41:06 +0100 Subject: [PATCH] refactor: extract linuxOptions --- CONTRIBUTING.md | 4 +- src/index.ts | 5 ++- src/linuxPackager.ts | 3 +- src/metadata.ts | 68 +------------------------------- src/options/linuxOptions.ts | 68 ++++++++++++++++++++++++++++++++ src/targets/LinuxTargetHelper.ts | 2 +- src/targets/appImage.ts | 3 +- src/targets/fpm.ts | 3 +- 8 files changed, 81 insertions(+), 75 deletions(-) create mode 100644 src/options/linuxOptions.ts diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7243f5716be..36dc41d6469 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -88,8 +88,8 @@ Only IntelliJ Platform IDEs (IntelliJ IDEA, WebStorm) support debug. [Forked ver Use one of the shared run configurations as a template and: -* Ensure that `Before launch` contains `Compile TypeScript`. -* Set `Node interpreter` to NodeJS 7. Yes — NodeJS 7 is required to debug. Download [nightly build](https://nodejs.org/download/nightly/). +* Ensure that `Before launch` contains `Compile TypeScript` (note – currently do not add, please do`npm run compile` before run). +* Set `Node interpreter` to NodeJS 7. NodeJS 7 is required to debug. * Set `Node parameters` to `--inspect`. * Set `Application Parameters` to `--match="test name" relative-test-file-name` if you want to debug particular test. E.g. ``` diff --git a/src/index.ts b/src/index.ts index ac63223dbf2..30a535da396 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,6 +3,7 @@ export { PackagerOptions, ArtifactCreated, BuildInfo } from "./platformPackager" export { DIR_TARGET, DEFAULT_TARGET } from "./targets/targetFactory" export { BuildOptions, build, CliOptions, createTargets } from "./builder" export { PublishOptions, Publisher } from "./publish/publisher" -export { AppMetadata, DevMetadata, Platform, Arch, archFromString, BuildMetadata, LinuxBuildOptions, CompressionLevel } from "./metadata" +export { AppMetadata, DevMetadata, Platform, Arch, archFromString, BuildMetadata, CompressionLevel } from "./metadata" export { MacOptions, DmgOptions, MasBuildOptions } from "./options/macOptions" -export { WinBuildOptions, NsisOptions } from "./options/winOptions" \ No newline at end of file +export { WinBuildOptions, NsisOptions } from "./options/winOptions" +export { LinuxBuildOptions } from "./options/linuxOptions" \ No newline at end of file diff --git a/src/linuxPackager.ts b/src/linuxPackager.ts index 27491861144..aad4907ce7b 100755 --- a/src/linuxPackager.ts +++ b/src/linuxPackager.ts @@ -1,12 +1,13 @@ import * as path from "path" import BluebirdPromise from "bluebird-lst-c" import { PlatformPackager, BuildInfo, Target, TargetEx } from "./platformPackager" -import { Platform, LinuxBuildOptions, Arch } from "./metadata" +import { Platform, Arch } from "./metadata" import FpmTarget from "./targets/fpm" import { createCommonTarget, DEFAULT_TARGET } from "./targets/targetFactory" import { LinuxTargetHelper } from "./targets/LinuxTargetHelper" import AppImageTarget from "./targets/appImage" import { rename } from "fs-extra-p" +import { LinuxBuildOptions } from "./options/linuxOptions" export class LinuxPackager extends PlatformPackager { constructor(info: BuildInfo) { diff --git a/src/metadata.ts b/src/metadata.ts index a76195f2947..88db430449b 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -3,6 +3,7 @@ import { PlatformPackager } from "./platformPackager" import { MacOptions, DmgOptions, MasBuildOptions } from "./options/macOptions" import { Publish } from "./options/publishOptions" import { WinBuildOptions, NsisOptions, SquirrelWindowsOptions } from "./options/winOptions" +import { LinuxBuildOptions } from "./options/linuxOptions" export interface Metadata { readonly repository?: string | RepositoryInfo | null @@ -238,73 +239,6 @@ export interface AfterPackContext { readonly packager: PlatformPackager } -/* - ### `.build.linux` - - Linux specific build options. - */ -export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { - /* - The [application category](https://specifications.freedesktop.org/menu-spec/latest/apa.html#main-category-registry). - */ - readonly category?: string | null - - /* - The [package category](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Section). Not applicable for AppImage. - */ - readonly packageCategory?: string | null - - /* - As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux. - */ - readonly description?: string | null - - /* - Target package type: list of `AppImage`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `AppImage`. - - The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default. - - Only `deb` and `AppImage` is tested. Feel free to file issues for `rpm` and other package formats. - */ - readonly target?: Array | null - - /* - *deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description). - */ - readonly synopsis?: string | null - - /* - The maintainer. Defaults to [author](#AppMetadata-author). - */ - readonly maintainer?: string | null - - /* - The vendor. Defaults to [author](#AppMetadata-author). - */ - readonly vendor?: string | null - - // should be not documented, only to experiment - readonly fpm?: Array | null - - /** - The [Desktop file](https://developer.gnome.org/integration-guide/stable/desktop-files.html.en) entries. - */ - readonly desktop?: { [key: string]: string; } | null - - readonly afterInstall?: string | null - readonly afterRemove?: string | null - - /* - *deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`. - */ - readonly compression?: string | null - - /* - Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`. - */ - readonly depends?: string[] | null -} - /* ### `.build.fileAssociations` diff --git a/src/options/linuxOptions.ts b/src/options/linuxOptions.ts new file mode 100644 index 00000000000..3af2ae9b16a --- /dev/null +++ b/src/options/linuxOptions.ts @@ -0,0 +1,68 @@ +import { PlatformSpecificBuildOptions } from "../metadata" + +/* + ### `.build.linux` + + Linux specific build options. + */ +export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { + /* + The [application category](https://specifications.freedesktop.org/menu-spec/latest/apa.html#main-category-registry). + */ + readonly category?: string | null + + /* + The [package category](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Section). Not applicable for AppImage. + */ + readonly packageCategory?: string | null + + /* + As [description](#AppMetadata-description) from application package.json, but allows you to specify different for Linux. + */ + readonly description?: string | null + + /* + Target package type: list of `AppImage`, `deb`, `rpm`, `freebsd`, `pacman`, `p5p`, `apk`, `7z`, `zip`, `tar.xz`, `tar.lz`, `tar.gz`, `tar.bz2`, `dir`. Defaults to `AppImage`. + + The most effective [xz](https://en.wikipedia.org/wiki/Xz) compression format used by default. + + Only `deb` and `AppImage` is tested. Feel free to file issues for `rpm` and other package formats. + */ + readonly target?: Array | null + + /* + *deb-only.* The [short description](https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description). + */ + readonly synopsis?: string | null + + /* + The maintainer. Defaults to [author](#AppMetadata-author). + */ + readonly maintainer?: string | null + + /* + The vendor. Defaults to [author](#AppMetadata-author). + */ + readonly vendor?: string | null + + // should be not documented, only to experiment + readonly fpm?: Array | null + + /** + The [Desktop file](https://developer.gnome.org/integration-guide/stable/desktop-files.html.en) entries. + */ + readonly desktop?: { [key: string]: string; } | null + + readonly afterInstall?: string | null + readonly afterRemove?: string | null + + /* + *deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`. + */ + readonly compression?: string | null + + /* + Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`. + */ + readonly depends?: string[] | null +} diff --git a/src/targets/LinuxTargetHelper.ts b/src/targets/LinuxTargetHelper.ts index 7ad25ff7db6..1a1cd180a72 100644 --- a/src/targets/LinuxTargetHelper.ts +++ b/src/targets/LinuxTargetHelper.ts @@ -3,7 +3,7 @@ import * as path from "path" import { exec, debug, isEmptyOrSpaces } from "../util/util" import { PlatformPackager } from "../platformPackager" import BluebirdPromise from "bluebird-lst-c" -import { LinuxBuildOptions } from "../metadata" +import { LinuxBuildOptions } from "../options/linuxOptions" export const installPrefix = "/opt" diff --git a/src/targets/appImage.ts b/src/targets/appImage.ts index 7a2b4548343..d81fc81ab5d 100644 --- a/src/targets/appImage.ts +++ b/src/targets/appImage.ts @@ -1,5 +1,5 @@ import { PlatformPackager, TargetEx } from "../platformPackager" -import { LinuxBuildOptions, Arch } from "../metadata" +import { Arch } from "../metadata" import * as path from "path" import { exec, unlinkIfExists } from "../util/util" import { open, write, createReadStream, createWriteStream, close, chmod } from "fs-extra-p" @@ -7,6 +7,7 @@ import { LinuxTargetHelper } from "./LinuxTargetHelper" import { getBin } from "../util/binDownload" import BluebirdPromise from "bluebird-lst-c" import { v1 as uuid1 } from "uuid-1345" +import { LinuxBuildOptions } from "../options/linuxOptions" const appImageVersion = process.platform === "darwin" ? "AppImage-09-07-16-mac" : "AppImage-09-07-16-linux" //noinspection SpellCheckingInspection diff --git a/src/targets/fpm.ts b/src/targets/fpm.ts index aa3ff1a15eb..650ad365af5 100644 --- a/src/targets/fpm.ts +++ b/src/targets/fpm.ts @@ -1,4 +1,4 @@ -import { LinuxBuildOptions, Arch } from "../metadata" +import { Arch } from "../metadata" import { smarten, PlatformPackager, TargetEx } from "../platformPackager" import { use, exec } from "../util/util" import * as path from "path" @@ -8,6 +8,7 @@ import BluebirdPromise from "bluebird-lst-c" import { LinuxTargetHelper, installPrefix } from "./LinuxTargetHelper" import * as errorMessages from "../errorMessages" import { TmpDir } from "../util/tmp" +import { LinuxBuildOptions } from "../options/linuxOptions" const template = require("lodash.template")