Skip to content

Commit

Permalink
feat(maker): add the flatpak maker for the linux target
Browse files Browse the repository at this point in the history
  • Loading branch information
malept committed Dec 9, 2016
1 parent aea80d9 commit 218518e
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 15 deletions.
2 changes: 2 additions & 0 deletions .npmignore
@@ -1,2 +1,4 @@
src
test
.travis.yml
ci
12 changes: 5 additions & 7 deletions .travis.yml
Expand Up @@ -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
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -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`

Expand Down
5 changes: 5 additions & 0 deletions ci/Dockerfile
@@ -0,0 +1,5 @@
FROM malept/electron-forge-container:latest

RUN mkdir /code
WORKDIR /code
ADD . /code/
6 changes: 6 additions & 0 deletions 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
9 changes: 9 additions & 0 deletions 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
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -83,6 +83,7 @@
},
"optionalDependencies": {
"electron-installer-debian": "^0.4.0",
"electron-installer-flatpak": "^0.4.0",
"electron-installer-redhat": "^0.3.0"
}
}
29 changes: 29 additions & 0 deletions 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);
};

0 comments on commit 218518e

Please sign in to comment.