Skip to content
Permalink
Browse files

feat(maker): add the flatpak maker for the linux target

  • Loading branch information
malept committed Dec 4, 2016
1 parent aea80d9 commit 218518ef1e4a24627ef871f34277176affb1b243
Showing with 65 additions and 15 deletions.
  1. +2 −0 .npmignore
  2. +5 −7 .travis.yml
  3. +8 −8 README.md
  4. +5 −0 ci/Dockerfile
  5. +6 −0 ci/docker.sh
  6. +9 −0 ci/script.sh
  7. +1 −0 package.json
  8. +29 −0 src/makers/linux/flatpak.js
@@ -1,2 +1,4 @@
src
test
.travis.yml
ci
@@ -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
@@ -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`

@@ -0,0 +1,5 @@
FROM malept/electron-forge-container:latest

RUN mkdir /code
WORKDIR /code
ADD . /code/
@@ -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
@@ -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
@@ -83,6 +83,7 @@
},
"optionalDependencies": {
"electron-installer-debian": "^0.4.0",
"electron-installer-flatpak": "^0.4.0",
"electron-installer-redhat": "^0.3.0"
}
}
@@ -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.
You can’t perform that action at this time.