diff --git a/.idea/dictionaries/develar.xml b/.idea/dictionaries/develar.xml index ca2ce47e7e1..e7e3d47c0f4 100644 --- a/.idea/dictionaries/develar.xml +++ b/.idea/dictionaries/develar.xml @@ -106,6 +106,7 @@ libnss libunity libxss + libxtst localappdata lockfile lzfse diff --git a/.travis.yml b/.travis.yml index 193c169a9ff..3d0325aa83a 100755 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,7 @@ before_install: install: - nvm install $NODE_VERSION - nvm use --delete-prefix $NODE_VERSION -- ln -sf $PWD/test/yarn.js /usr/local/bin/yarn +- ln -sf $PWD/test/vendor/yarn.js /usr/local/bin/yarn - yarn install --pure-lockfile - if [[ "$TRAVIS_BRANCH" == "master" && "$TRAVIS_PULL_REQUEST" == "false" && "$AUTO_PUBLISH" != "false" && "$TRAVIS_TAG" == "" && "$PUBLISH_TO_NPM" == "true" ]]; then yarn add @develar/semantic-release@next --dev ; fi diff --git a/README.md b/README.md index 23d564675d8..9d1ae6db931 100755 --- a/README.md +++ b/README.md @@ -125,8 +125,8 @@ const Platform = builder.Platform // Promise is returned builder.build({ targets: Platform.MAC.createTarget(), - devMetadata: { - "//": "build and other properties, see https://goo.gl/5jVxoO" + config: { + "//": "build options, see https://goo.gl/ZhRfla" } }) .then(() => { diff --git a/appveyor.yml b/appveyor.yml index 0b630d336a7..b5e2cc20789 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -10,9 +10,9 @@ environment: install: - ps: Install-Product node 6 x64 - - node ./test/yarn.js + - node ./test/vendor/yarn.js build: off test_script: - - node ./test/yarn.js test \ No newline at end of file + - node ./test/vendor/yarn.js test \ No newline at end of file diff --git a/circle.yml b/circle.yml index a4d8a8ab6a0..ede4c79d7c1 100644 --- a/circle.yml +++ b/circle.yml @@ -14,7 +14,7 @@ dependencies: - sudo apt-get install git-lfs=1.3.0 - 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:$([ "$CIRCLE_NODE_INDEX" == "2" ] && echo "6" || echo "wine") /bin/bash -c "node ./test/yarn.js && node ./test/yarn.js test" + - 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:$([ "$CIRCLE_NODE_INDEX" == "2" ] && echo "6" || echo "wine") /bin/bash -c "node ./test/vendor/yarn.js && node ./test/vendor/yarn.js test" test: override: diff --git a/docker/base/Dockerfile b/docker/base/Dockerfile index 1f9fa2ffd8b..6931ae0a9b7 100644 --- a/docker/base/Dockerfile +++ b/docker/base/Dockerfile @@ -16,7 +16,7 @@ ENV DEBUG_COLORS true ENV FORCE_COLOR true RUN curl -L https://yarnpkg.com/latest.tar.gz | tar xvz && mv dist yarn && ln -s /yarn/bin/yarn /usr/local/bin/yarn && apt-get update -y && \ - apt-get install --no-install-recommends -y git snapcraft xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \ + apt-get install --no-install-recommends -y git snapcraft qtbase5-dev xorriso bsdtar build-essential autoconf libssl-dev icnsutils graphicsmagick gcc-multilib g++-multilib libgnome-keyring-dev lzip rpm yasm && \ apt-get clean && \ rm -rf /var/lib/apt/lists/* && \ curl -L http://tukaani.org/xz/xz-$XZ_VERSION.tar.xz | tar -xJ && cd xz-$XZ_VERSION && ./configure && make && make install && cd .. && rm -rf xz-$XZ_VERSION && ldconfig && \ diff --git a/docs/Options.md b/docs/Options.md index 286ad40c51f..d0b2da91bde 100644 --- a/docs/Options.md +++ b/docs/Options.md @@ -83,6 +83,7 @@ Don't customize paths to background and icon, — just follow conventions. | squirrelWindows | See [.build.squirrelWindows](#SquirrelWindowsOptions). | appx | See [.build.appx](#AppXOptions). | linux | See [.build.linux](#LinuxBuildOptions). +| snap | See [.build.snap](#SnapOptions). | compression | The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly. | afterPack | *programmatic API only* The function to be run after pack (but before pack into distributable format and sign). Promise must be returned. | npmRebuild | Whether to [rebuild](https://docs.npmjs.com/cli/rebuild) native dependencies (`npm rebuild`) before starting to package the app. Defaults to `true`. @@ -167,7 +168,7 @@ Linux specific build options. | vendor | The vendor. Defaults to [author](#AppMetadata-author). | desktop | The [Desktop file](https://developer.gnome.org/integration-guide/stable/desktop-files.html.en) entries (name to value). | compression | *deb-only.* The compression type, one of `gz`, `bzip2`, `xz`. Defaults to `xz`. -| depends | Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`. +| depends | Package dependencies. Defaults to `["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3"]` for `deb`. | executableName |

The executable name. Defaults to productName.

Cannot be specified per target, allowed only in the .build.linux.

@@ -281,6 +282,8 @@ Amazon S3 — `https` must be used, so, if you use direct Amazon S3 endpoints, f | summary | The 78 character long summary. Defaults to [productName](#AppMetadata-productName). | grade |

The quality grade of the snap. It can be either devel (i.e. a development version of the snap, so not to be published to the “stable” or “candidate” channels) or “stable” (i.e. a stable release or release candidate, which can be released to all channels). Defaults to stable.

| assumes | The list of features that must be supported by the core in order for this snap to install. +| stagePackages |

The list of Ubuntu packages to use that are needed to support the app part creation. Like depends for deb. Defaults to ["libnotify4", "libappindicator1", "libxtst6", "libnss3", "fontconfig-config"].

+| ubuntuAppPlatformContent |

Specify ubuntu-app-platform1 to use [ubuntu-app-platform](https://insights.ubuntu.com/2016/11/17/how-to-create-snap-packages-on-qt-applications/). Snap size will be greatly reduced, but it is not recommended for now because “the snaps must be connected before running uitk-gallery for the first time”.

### `.build.squirrelWindows` diff --git a/docs/programmaticUsage.js b/docs/programmaticUsage.js index 093d67a56f7..d9dc1d2c19d 100644 --- a/docs/programmaticUsage.js +++ b/docs/programmaticUsage.js @@ -7,7 +7,7 @@ builder.build({ platform: [builder.Platform.MAC], "//": "platform, arch and other properties, see PackagerOptions in the node_modules/electron-builder/out/electron-builder.d.ts", config: { - "//": "build and other properties, see https://goo.gl/5jVxoO" + "//": "build options, see https://goo.gl/ZhRfla" } }) .then(() => { diff --git a/package.json b/package.json index 81cea15261f..134528f16a8 100644 --- a/package.json +++ b/package.json @@ -16,11 +16,11 @@ "scripts": { "compile": "ts-babel . nsis-auto-updater test", "lint": "node ./test/lint.js", - "pretest": "node ./test/yarn.js run compile && node ./test/yarn.js run lint", + "pretest": "node ./test/vendor/yarn.js run compile && node ./test/vendor/yarn.js run lint", "check-deps": "node ./test/out/helpers/checkDeps.js", "test": "node ./test/out/helpers/runTests.js", "test-linux": "docker run --rm -ti -v ${PWD}:/project -v ${PWD##*/}-node-modules:/project/node_modules -v ~/.electron:/root/.electron electronuserland/electron-builder:wine /test.sh", - "pack-updater": "cd nsis-auto-updater && node ./test/yarn.js --production && cd ..", + "pack-updater": "cd nsis-auto-updater && node ./test/vendor/yarn.js --production && cd ..", "semantic-release": "semantic-release pre && npm publish && semantic-release post", "//": "Update wiki if docs changed. Update only if functionalily are generally available (latest release, not next)", "update-wiki": "git subtree split -b wiki --prefix docs/ && git push -f wiki wiki:master", @@ -89,7 +89,7 @@ "read-installed": "^4.0.3", "sanitize-filename": "^1.6.1", "semver": "^5.3.0", - "source-map-support": "^0.4.6", + "source-map-support": "^0.4.8", "stat-mode": "^0.2.2", "tunnel-agent": "^0.4.3", "update-notifier": "^1.0.3", diff --git a/src/metadata.ts b/src/metadata.ts index 29ae81bf80e..a90e3b894e2 100755 --- a/src/metadata.ts +++ b/src/metadata.ts @@ -3,7 +3,7 @@ import { PlatformPackager } from "./platformPackager" import { MacOptions, DmgOptions, MasBuildOptions } from "./options/macOptions" import { Publish } from "./options/publishOptions" import { WinBuildOptions, NsisOptions, SquirrelWindowsOptions, AppXOptions } from "./options/winOptions" -import { LinuxBuildOptions } from "./options/linuxOptions" +import { LinuxBuildOptions, SnapOptions } from "./options/linuxOptions" export interface Metadata { readonly repository?: string | RepositoryInfo | null @@ -181,6 +181,11 @@ export interface BuildMetadata { readonly deb?: LinuxBuildOptions | null + /* + See [.build.snap](#SnapOptions). + */ + readonly snap?: SnapOptions | null + /* The compression level, one of `store`, `normal`, `maximum` (default: `normal`). If you want to rapidly test build, `store` can reduce build time significantly. */ diff --git a/src/options/linuxOptions.ts b/src/options/linuxOptions.ts index f235e99dca1..f8dc4456739 100644 --- a/src/options/linuxOptions.ts +++ b/src/options/linuxOptions.ts @@ -60,7 +60,7 @@ export interface LinuxBuildOptions extends PlatformSpecificBuildOptions { readonly compression?: string | null /* - Package dependencies. Defaults to `["libappindicator1", "libnotify-bin"]`. + Package dependencies. Defaults to `["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3"]` for `deb`. */ readonly depends?: string[] | null @@ -98,4 +98,16 @@ export interface SnapOptions extends LinuxBuildOptions { The list of features that must be supported by the core in order for this snap to install. */ assumes?: Array | null + + /* + The list of Ubuntu packages to use that are needed to support the `app` part creation. Like `depends` for `deb`. + Defaults to `["libnotify4", "libappindicator1", "libxtst6", "libnss3", "fontconfig-config"]`. + */ + stagePackages?: Array | null + + /* + Specify `ubuntu-app-platform1` to use [ubuntu-app-platform](https://insights.ubuntu.com/2016/11/17/how-to-create-snap-packages-on-qt-applications/). + Snap size will be greatly reduced, but it is not recommended for now because "the snaps must be connected before running uitk-gallery for the first time". + */ + ubuntuAppPlatformContent?: string | null } \ No newline at end of file diff --git a/src/targets/fpm.ts b/src/targets/fpm.ts index 98ccd50c2f5..0cc6877445a 100644 --- a/src/targets/fpm.ts +++ b/src/targets/fpm.ts @@ -128,7 +128,7 @@ export default class FpmTarget extends Target { let depends = options.depends if (depends == null) { if (target === "deb") { - depends = ["libnotify4", "libnss3"] + depends = ["gconf2", "gconf-service", "libnotify4", "libappindicator1", "libxtst6", "libnss3"] } else { depends = [] diff --git a/src/targets/snap.ts b/src/targets/snap.ts index 0f0659c6605..991aeeed0f7 100644 --- a/src/targets/snap.ts +++ b/src/targets/snap.ts @@ -10,6 +10,7 @@ import { safeDump } from "js-yaml" import { spawn } from "../util/util" import { homedir } from "os" import { Target } from "./targetFactory" +import BluebirdPromise from "bluebird-lst-c" export default class SnapTarget extends Target { private readonly options: SnapOptions = Object.assign({}, this.packager.platformSpecificBuildOptions, (this.packager.config)[this.name]) @@ -28,6 +29,13 @@ export default class SnapTarget extends Target { const snapDir = `${appOutDir}-snap` await emptyDir(snapDir) + const extraSnapSourceDir = path.join(snapDir, ".extra") + const isUseUbuntuPlatform = options.ubuntuAppPlatformContent != null + if (isUseUbuntuPlatform) { + // ubuntu-app-platform requires empty directory + await BluebirdPromise.all([this.helper.icons, emptyDir(path.join(extraSnapSourceDir, "ubuntu-app-platform"))]) + } + const snap: any = {} snap.name = packager.executableName snap.version = appInfo.version @@ -57,21 +65,36 @@ export default class SnapTarget extends Target { [snap.name]: { command: `desktop-launch $SNAP/${packager.executableName}`, plugs: [ - "home", "x11", "unity7", "unity8", "browser-support", "network", "gsettings", "pulseaudio", "opengl", + "home", "x11", "unity7", "unity8", "browser-support", "network", "gsettings", "pulseaudio", "opengl", "platform", ] } } + if (isUseUbuntuPlatform) { + snap.plugs = { + platform: { + interface: "content", + content: "ubuntu-app-platform1", + target: "ubuntu-app-platform", + "default-provider": "ubuntu-app-platform", + } + } + } + const isUseDocker = process.platform !== "linux" snap.parts = { app: { plugin: "dump", - "stage-packages": ["libnotify4", "libnss3", "fontconfig-config"], + "stage-packages": options.stagePackages || (isUseUbuntuPlatform ? ["libnss3"] : ["libnotify4", "libappindicator1", "libxtst6", "libnss3", "fontconfig-config"]), source: isUseDocker ? `/out/${path.basename(snapDir)}` : appOutDir, - filesets: { - app: [`${appOutDir}/*`], - }, - after: ["desktop-glib-only"] + after: isUseUbuntuPlatform ? ["extra", "desktop-ubuntu-app-platform"] : ["desktop-glib-only"] + } + } + + if (isUseUbuntuPlatform) { + snap.parts.extra = { + plugin: "dump", + source: extraSnapSourceDir } } @@ -95,6 +118,7 @@ export default class SnapTarget extends Target { else { await spawn("snapcraft", ["snap"], { cwd: snapDir, + stdio: ["ignore", "inherit", "pipe"] }) } diff --git a/test/jestSetup.js b/test/jestSetup.js index a88a1221cd7..26f27872f21 100644 --- a/test/jestSetup.js +++ b/test/jestSetup.js @@ -35,6 +35,7 @@ test.ifNotCiWin = isCi && isWindows ? skip : test test.ifDevOrWinCi = !isCi || isWindows ? test : skip test.ifDevOrLinuxCi = !isCi || process.platform === "linux" ? test : skip test.ifWinCi = isCi && isWindows ? test : skip +test.ifLinux = process.platform === "linux" ? test : skip delete process.env.CSC_NAME process.env.CSC_IDENTITY_AUTO_DISCOVERY = "false" diff --git a/test/src/helpers/packTester.ts b/test/src/helpers/packTester.ts index 4e025d9e854..d96d141b49c 100755 --- a/test/src/helpers/packTester.ts +++ b/test/src/helpers/packTester.ts @@ -250,7 +250,7 @@ async function checkLinuxResult(outDir: string, packager: Packager, checkOptions Vendor: "Foo Bar ", Package: "testapp", Description: " \n Test Application (test quite “ #378)", - Depends: checkOptions == null || checkOptions.expectedDepends == null ? "libappindicator1, libnotify-bin" : checkOptions.expectedDepends, + Depends: checkOptions == null || checkOptions.expectedDepends == null ? "gconf2, gconf-service, libnotify4, libappindicator1, libxtst6, libnss3" : checkOptions.expectedDepends, Section: "devel", }) } diff --git a/test/src/linux/linuxPackagerTest.ts b/test/src/linux/linuxPackagerTest.ts index f34f50ca433..90a5558a286 100755 --- a/test/src/linux/linuxPackagerTest.ts +++ b/test/src/linux/linuxPackagerTest.ts @@ -5,18 +5,6 @@ import { Platform } from "out" test.ifDevOrLinuxCi("AppImage", app({targets: Platform.LINUX.createTarget()})) -if (process.platform === "linux") { - test("snap", app({ - targets: Platform.LINUX.createTarget("snap"), - config: { - productName: "Snap Electron Builder Test", - }, - appMetadata: { - name: "snap-electron-builder-test", - }, - })) -} - test.ifDevOrLinuxCi("AppImage - default icon, custom executable and custom desktop", app({ targets: Platform.LINUX.createTarget("appimage"), effectiveOptionComputed: async (it) => { diff --git a/test/src/linux/snapTest.ts b/test/src/linux/snapTest.ts new file mode 100644 index 00000000000..7c6b2353284 --- /dev/null +++ b/test/src/linux/snapTest.ts @@ -0,0 +1,25 @@ +import { Platform } from "out" +import { app } from "../helpers/packTester" + +test.ifLinux("platform", app({ + targets: Platform.LINUX.createTarget("snap"), + config: { + productName: "Sep P", + snap: { + ubuntuAppPlatformContent: "ubuntu-app-platform1", + }, + }, + appMetadata: { + name: "sep-p", + }, +})) + +test.ifLinux("snap", app({ + targets: Platform.LINUX.createTarget("snap"), + config: { + productName: "Sep", + }, + appMetadata: { + name: "sep", + }, +})) diff --git a/test/typings/jest-ex.d.ts b/test/typings/jest-ex.d.ts index cb62b4c5aa2..eb7ef7b8d98 100644 --- a/test/typings/jest-ex.d.ts +++ b/test/typings/jest-ex.d.ts @@ -9,6 +9,7 @@ declare module jest { ifDevOrWinCi: jest.It ifWinCi: jest.It ifDevOrLinuxCi: jest.It + ifLinux: jest.It } interface Matchers { diff --git a/test/yarn.js b/test/vendor/yarn.js similarity index 100% rename from test/yarn.js rename to test/vendor/yarn.js diff --git a/yarn.lock b/yarn.lock index 33f94fb4cb3..39894c8cc26 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2350,8 +2350,8 @@ lodash@^3.6.0: resolved "https://registry.yarnpkg.com/lodash/-/lodash-3.10.1.tgz#5bf45e8e49ba4189e17d482789dfd15bd140b7b6" lodash@^4.0.0, lodash@^4.14.0, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.5.1, lodash@^4.8.0: - version "4.17.2" - resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42" + version "4.17.3" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.3.tgz#557ed7d2a9438cac5fd5a43043ca60cb455e01f7" longest@^1.0.1: version "1.0.1" @@ -3184,9 +3184,9 @@ sntp@1.x.x: dependencies: hoek "2.x.x" -source-map-support@^0.4.2, source-map-support@^0.4.6: - version "0.4.7" - resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.7.tgz#7a7988e0e66241c778c78dd179199bb6bcd35bd6" +source-map-support@^0.4.2, source-map-support@^0.4.6, source-map-support@^0.4.8: + version "0.4.8" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.8.tgz#4871918d8a3af07289182e974e32844327b2e98b" dependencies: source-map "^0.5.3"