diff --git a/.npmignore b/.npmignore index 281df3934b..971d74d520 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,4 @@ src test +.travis.yml +ci diff --git a/.travis.yml b/.travis.yml index 1c552069df..f23968f5e2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,17 +4,15 @@ node_js: os: - linux - osx +dist: trusty +sudo: required -addons: - apt: - packages: - - rpm +services: +- docker env: matrix: - NODE_INSTALLER=npm - NODE_INSTALLER=yarn -script: -- if [[ "$NODE_INSTALLER" = "yarn" ]]; then npm i -g yarn; fi -- npm run test -- --installer=$NODE_INSTALLER +script: ci/script.sh diff --git a/README.md b/README.md index 4d295979eb..5667e5579c 100644 --- a/README.md +++ b/README.md @@ -107,14 +107,14 @@ Once you have generated a project your `package.json` file will have some defaul ## Possible `make` targets -| Target Name | Available Platforms | Description | Configurable Options | Requirements | -|-------------|---------------------|-------------|----------------------|--------------| -| `zip` | All | Zips your packaged application | None | `zip` on Darwin/Linux | -| `squirrel` | Windows | Generates an installer and `.nupkg` files for Squirrel.Windows | [`electronWinstallerConfig`](https://github.com/electron/windows-installer#usage) | -| `dmg` | Darwin | Generates a DMG file | [`electronInstallerDMG`](https://github.com/mongodb-js/electron-installer-dmg#api) | -| `deb` | Linux | Generates a Debian installer | [`electronInstallerDebian`](https://github.com/unindented/electron-installer-debian#options) | [`fakeroot` and `dpkg`](https://github.com/unindented/electron-installer-debian#requirements) | -| `rpm` | Linux | Generates a Redhat installer | [`electronInstallerRedhat`](https://github.com/unindented/electron-installer-redhat#options) | [`rpm`](https://github.com/unindented/electron-installer-redhatn#requirements) | -| `flatpak` | Linux | Generates a `flatpak` file | [`electronInstallerFlatpak`](https://github.com/endlessm/electron-installer-flatpak#options) | [`flatpak`](https://github.com/endlessm/electron-installer-flatpak#requirements) | +| Target Name | Available Platforms | Description | Configurable Options | Default? | Requirements | +|-------------|---------------------|-------------|----------------------|----------|--------------| +| `zip` | All | Zips your packaged application | None | Yes | `zip` on Darwin/Linux | +| `squirrel` | Windows | Generates an installer and `.nupkg` files for Squirrel.Windows | [`electronWinstallerConfig`](https://github.com/electron/windows-installer#usage) | Yes | | +| `dmg` | Darwin | Generates a DMG file | [`electronInstallerDMG`](https://github.com/mongodb-js/electron-installer-dmg#api) | No | | +| `deb` | Linux | Generates a Debian installer | [`electronInstallerDebian`](https://github.com/unindented/electron-installer-debian#options) | Yes | [`fakeroot` and `dpkg`](https://github.com/unindented/electron-installer-debian#requirements) | +| `rpm` | Linux | Generates a Redhat installer | [`electronInstallerRedhat`](https://github.com/unindented/electron-installer-redhat#options) | Yes | [`rpm`](https://github.com/unindented/electron-installer-redhatn#requirements) | +| `flatpak` | Linux | Generates a `flatpak` file | [`electronInstallerFlatpak`](https://github.com/endlessm/electron-installer-flatpak#options) | No | [`flatpak-builder`](https://github.com/endlessm/electron-installer-flatpak#requirements) | ## Configuring `package` diff --git a/ci/Dockerfile b/ci/Dockerfile new file mode 100644 index 0000000000..03604f992b --- /dev/null +++ b/ci/Dockerfile @@ -0,0 +1,5 @@ +FROM malept/electron-forge-container:latest + +RUN mkdir /code +WORKDIR /code +ADD . /code/ diff --git a/ci/docker.sh b/ci/docker.sh new file mode 100755 index 0000000000..42f5be3712 --- /dev/null +++ b/ci/docker.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +NODE_INSTALLER="$1" + +if [[ "$NODE_INSTALLER" = "yarn" ]]; then npm i -g yarn; fi +npm run test -- --installer=$NODE_INSTALLER diff --git a/ci/script.sh b/ci/script.sh new file mode 100755 index 0000000000..f12e5a5755 --- /dev/null +++ b/ci/script.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +if [[ "$TRAVIS_OS_NAME" = "linux" ]]; then + sudo docker build -f ci/Dockerfile . -t electron-forge-ci + sudo docker run -it electron-forge-ci ci/docker.sh $NODE_INSTALLER +else + if [[ "$NODE_INSTALLER" = "yarn" ]]; then npm i -g yarn; fi + npm run test -- --installer=$NODE_INSTALLER +fi diff --git a/package.json b/package.json index 7f616c3381..734e3dcd7b 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ }, "optionalDependencies": { "electron-installer-debian": "^0.4.0", + "electron-installer-flatpak": "^0.4.0", "electron-installer-redhat": "^0.3.0" } } diff --git a/src/makers/linux/flatpak.js b/src/makers/linux/flatpak.js new file mode 100644 index 0000000000..2e2c367066 --- /dev/null +++ b/src/makers/linux/flatpak.js @@ -0,0 +1,29 @@ +import installer from 'electron-installer-flatpak'; +import path from 'path'; +import pify from 'pify'; + +import { ensureFile } from '../../util/ensure-output'; + +function flatpakArch(nodeArch) { + switch (nodeArch) { + case 'ia32': return 'i386'; + case 'x64': return 'x86_64'; + // arm => arm + default: return nodeArch; + } +} + +export default async (dir, appName, forgeConfig, packageJSON) => { // eslint-disable-line + const arch = flatpakArch(process.arch); + const outPath = path.resolve(dir, '../make', `${packageJSON.name}_${packageJSON.version}_${arch}.flatpak`); + + await ensureFile(outPath); + const flatpakDefaults = { + arch, + dest: path.dirname(outPath), + src: dir, + }; + const flatpakConfig = Object.assign({}, forgeConfig.electronInstallerFlatpak, flatpakDefaults); + + await pify(installer)(flatpakConfig); +};