{"_id":"@malept/flatpak-bundler","_rev":"4245166","name":"@malept/flatpak-bundler","description":"A small utility for packing files in a flatpak.","dist-tags":{"latest":"0.4.0"},"maintainers":[{"name":"malept","email":"nodejs+npm@lazymalevolence.com"}],"time":{"modified":"2026-03-29T21:30:30.000Z","created":"2019-03-13T06:42:36.314Z","0.4.0":"2020-06-06T15:53:21.573Z","0.3.0":"2019-05-25T06:58:41.354Z","0.2.0":"2019-03-13T06:42:36.314Z"},"users":{},"author":{"name":"Matt Watson","email":"mattdangerw@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/malept/flatpak-bundler.git"},"versions":{"0.4.0":{"name":"@malept/flatpak-bundler","version":"0.4.0","description":"A small utility for packing files in a flatpak.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/malept/flatpak-bundler.git"},"keywords":["flatpak"],"author":{"name":"Matt Watson","email":"mattdangerw@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/malept/flatpak-bundler/issues"},"homepage":"https://github.com/malept/flatpak-bundler#readme","engines":{"node":">= 10.0.0"},"dependencies":{"debug":"^4.1.1","fs-extra":"^9.0.0","lodash":"^4.17.15","tmp-promise":"^3.0.2"},"devDependencies":{"husky":"^4.2.5","lint-staged":"^10.2.9","mocha":"^7.0.0","standard":"^14.0.0"},"scripts":{"lint":"standard","mocha":"mocha","test":"standard && mocha"},"husky":{"pre-commit":"lint-staged"},"lint-staged":{"*.js":"standard --fix"},"gitHead":"8f0dc27a217f5ae7f49fa0d5a5570d332cbc9ec7","_id":"@malept/flatpak-bundler@0.4.0","_nodeVersion":"10.20.1","_npmVersion":"6.14.4","dist":{"shasum":"e8a32c30a95d20c2b1bb635cc580981a06389858","size":7051,"noattachment":false,"key":"/@malept/flatpak-bundler/-/@malept/flatpak-bundler-0.4.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@malept/flatpak-bundler/download/@malept/flatpak-bundler-0.4.0.tgz"},"maintainers":[{"name":"malept","email":"nodejs+npm@lazymalevolence.com"}],"_npmUser":{"name":"malept","email":"nodejs.npm.nospam@lazymalevolence.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flatpak-bundler_0.4.0_1591458801232_0.9328386249180869"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-20T07:54:02.220Z","publish_time":1591458801573,"_cnpm_publish_time":1591458801573},"0.3.0":{"name":"@malept/flatpak-bundler","version":"0.3.0","description":"A small utility for packing files in a flatpak.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/malept/flatpak-bundler.git"},"keywords":["flatpak"],"author":{"name":"Matt Watson","email":"mattdangerw@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/malept/flatpak-bundler/issues"},"homepage":"https://github.com/malept/flatpak-bundler#readme","engines":{"node":">= 8.0.0"},"dependencies":{"debug":"^4.1.1","fs-extra":"^8.0.1","lodash":"^4.16.2","tmp-promise":"^2.0.1"},"devDependencies":{"mocha":"^6.1.4","standard":"^12.0.1"},"scripts":{"test":"standard && mocha"},"gitHead":"e060ae7bd1656d9316987612a29dd397f2e219e1","_id":"@malept/flatpak-bundler@0.3.0","_nodeVersion":"10.2.1","_npmVersion":"6.9.0","dist":{"shasum":"107c2343f982c61177ecc5fe0783a1bb47978258","size":6828,"noattachment":false,"key":"/@malept/flatpak-bundler/-/@malept/flatpak-bundler-0.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@malept/flatpak-bundler/download/@malept/flatpak-bundler-0.3.0.tgz"},"maintainers":[{"name":"malept","email":"nodejs+npm@lazymalevolence.com"}],"_npmUser":{"name":"malept","email":"nodejs.npm.nospam@lazymalevolence.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flatpak-bundler_0.3.0_1558767521262_0.34817710235423327"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-20T07:54:01.324Z","publish_time":1558767521354,"_cnpm_publish_time":1558767521354},"0.2.0":{"name":"@malept/flatpak-bundler","version":"0.2.0","description":"A small utility for packing files in a flatpak.","main":"index.js","repository":{"type":"git","url":"git+https://github.com/malept/flatpak-bundler.git"},"keywords":["flatpak"],"author":{"name":"Matt Watson","email":"mattdangerw@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/malept/flatpak-bundler/issues"},"homepage":"https://github.com/malept/flatpak-bundler#readme","engines":{"node":">=6.0.0"},"dependencies":{"debug":"^4.1.1","fs-extra":"^7.0.1","lodash":"^4.16.2","nodeify":"^1.0.1","tmp-promise":"^1.0.5"},"devDependencies":{"mocha":"^5.2.0","standard":"^12.0.1"},"scripts":{"test":"standard && mocha"},"gitHead":"ed2a3e7e6f62f773debd253d88112ab0f2160b26","_id":"@malept/flatpak-bundler@0.2.0","_npmVersion":"6.5.0","_nodeVersion":"10.14.1","_npmUser":{"name":"malept","email":"nodejs.npm.nospam@lazymalevolence.com"},"dist":{"shasum":"c7edfd1abef54b537383b70a02a0a36992d50fca","size":6936,"noattachment":false,"key":"/@malept/flatpak-bundler/-/@malept/flatpak-bundler-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@malept/flatpak-bundler/download/@malept/flatpak-bundler-0.2.0.tgz"},"maintainers":[{"name":"malept","email":"nodejs+npm@lazymalevolence.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/flatpak-bundler_0.2.0_1552459356140_0.3818828159427412"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2021-12-20T07:53:59.664Z","publish_time":1552459356314,"_cnpm_publish_time":1552459356314}},"readme":"# @malept/flatpak-bundler [![Version](https://img.shields.io/npm/v/@malept/flatpak-bundler.svg)](https://www.npmjs.com/package/@malept/flatpak-bundler) [![Build Status](https://github.com/malept/flatpak-bundler/workflows/CI/badge.svg)](https://github.com/malept/flatpak-bundler/actions?query=workflow%3ACI)\nBuild [flatpaks](https://flatpak.org/) from Node.js.\n\n# Quick Start\n\nInstall `@malept/flatpak-bundler`.\n```shell\n$ npm install @malept/flatpak-bundler\n```\n\n[Build a flatpak with a Node script](#hello-world).\n\nInstall and run it!\n```shell\n$ flatpak install --user --bundle hello.flatpak\n$ flatpak run org.world.Hello\nHello, world!\n```\n\n## Overview\nThis modules allows building flatpaks programmatically from Node. It requires\nNode 10 or above and flatpak >= 0.6.13 to be installed on your system.\n\nUnder the hood, this is just a wrapper for the [flatpak-builder](https://docs.flatpak.org/en/latest/flatpak-builder.html)\ntool with some extra sugar added.\n\nWith `flatpak-builder`, you specify a runtime, sandbox permissions and software\nmodules to build into your application, and build a flatpak from start to finish.\nThis module provides a few additional features:\n\n - Supports auto installing flatpak runtime and app dependencies\n - Supports exporting directly to the a single file flatpak bundle\n - Supports easy copying files and creating symlinks directly in `/app`\n\nThe latter is particularly useful for [Electron](https://electronjs.org/) and\n[nw.js](http://nwjs.io/) style Node applications, which often create packages\nfrom prebuilt binaries and do not attempt to follow an autotools-like\n[build api](https://github.com/cgwalters/build-api).\n\nThis module should make it easy to plug flatpak support into an Electron or nw.js\napp packaging phase.\n\n## Usage\n\n### translateArch(arch)\n\nUsed to translate a Node-style arch (e.g., `x64`) into a Flatpak-compatible arch (e.g., `x86_64`).\n\nIf the arch is unknown, it will pass through the input value.\n\n### bundle(manifest, buildOptions)\n\nTakes an [app manifest](#manifest) and a build options object. It returns a Promise.\n\nBoth the manifest and options objects support both camelCase and dash-separated\nvariants of any option.\n\nThe promise is returned with a `finalBuildOptions` value. It contains the build\noptions after default values have been applied. Useful to read out the\n`workingDir`, for example.\n\n#### Manifest\n\nThis matches the format for [`flatpak-builder` app\nmanifests](https://docs.flatpak.org/en/latest/manifests.html), with a few extra\noptions added and camelCase variants supported.\n\n - **id**: Required. The application id.\n - **runtime**: Required. The runtime for your flatpak application.\n - **sdk**: Required. The sdk for your flatpak application.\n - **base**: An app to inherit from. Use the app as a \"base\" for `/app`\n   contents.\n - **finishArgs**: The arguments to pass to `flatpak build-finish`. Use this to\n   add sandbox permissions. See the [Electron app example](#electron-app) for\n   some common app permissions.\n - **modules**: If you need to build other software modules into you flatpak app\n   (anything not already in your runtime or base app), you can specify them\n   here.\n\n#### Build Options\n\n - **bundlePath**: Output location for a single file version of the flatpak. If\n   non supplied, the single file flatpak will not be created.\n - **arch**: The architecture for the flatpak bundle. x86_64, i386 or arm.\n - **workingDir**: The working directory to call `flatpak-builder` from.\n   Defaults to a new tmp directory.\n - **buildDir**: The directory to build the application in. Defaults to\n   `${workingDir}/build`\n - **repoDir**: The directory for a flatpak repo, can be used to publish to an\n   existing repo. Defaults to `${workingDir}/repo`\n - **cleanTmpdirs**: Cleanup any tmp directories created during the build on\n   process exit. Defaults to true. Set false for easier debugging.\n - **autoInstallRuntime**: Install/update the runtime while building. Defaults\n   to true if runtimeFlatpakref is set in the manifest.\n - **autoInstallSdk**: Install/update the sdk while building. Defaults\n   to true if sdkFlatpakref is set in the manifest.\n - **autoInstallBase**: Install/update the base app while building. Defaults\n   to true if baseFlatpakref is set in the manifest.\n - **gpgSign**: The gpg key to use to sign the flatpak repo and bundle file.\n - **gpgHomedir**: The gpg homedir to use when signing.\n - **subject**: The single line subject to use for the flatpak repo commit\n   message.\n - **body**: The description to use for the flatpak repo commit message.\n - **files**: Files to copy directly into the app. Should be a list of [source,\n   dest] tuples. Source should be a relative/absolute path to a file/directory\n   to copy into the flatpak, and dest should be the path inside the app install\n   prefix (e.g. `/share/applications/`)\n - **symlinks**: Symlinks to create in the app files. Should be a list of\n   [target, location] symlink tuples. Target can be either a relative or\n   absolute path inside the app install prefix, and location should be a\n   absolute path inside the prefix to create the symlink at.\n - **extraExports**: Files to export outside of the flatpak sandbox, in addition\n   to the application desktop file, icons and appstream. File basename *must*\n   be prefixed with the app id. Should not be needed for common use.\n - **runtimeFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the runtime.\n - **sdkFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the sdk.\n - **baseFlatpakref**: A pathname or url to a flatpakref file to use to auto\n   install the base app.\n - **bundleRepoUrl**: Repo url for the single file bundle. Installing the bundle\n   will automatically configure a remote for this URL.\n - **extraFlatpakBuilderArgs**: List of extra arguments to pass to the\n   [flatpak-builder](https://docs.flatpak.org/en/latest/flatpak-builder-command-reference.html) command.\n - **extraFlatpakBuildExportArgs**: List of extra arguments to pass to the\n   [flatpak build-export](https://docs.flatpak.org/en/latest/flatpak-command-reference.html#flatpak-build-export) command.\n - **extraFlatpakBuildBundleArgs**: List of extra arguments to pass to the\n   [flatpak build-bundle](https://docs.flatpak.org/en/latest/flatpak-command-reference.html#flatpak-build-bundle) command.\n\n### Logging\nTo turn on debugging output, set the DEBUG environment variable:\n\n```shell\nDEBUG=flatpak-bundler npm run my-flatpak-command\n```\n\n## Examples\n\n### Hello world\n\n```javascript\nconst flatpakBundler = require('@malept/flatpak-bundler')\nconst fs = require('fs-extra')\n\n// Write a hello world script to disk\nawait fs.writeFile('hello',\n`#!/bin/bash\necho \"Hello, world!\"`, { mode: 0o755 })\n\n// Make a flatpak with it!\ntry {\n  await flatpakBundler.bundle({\n    id: 'org.world.Hello',\n    runtime: 'org.freedesktop.Platform',\n    runtimeVersion: '1.4',\n    sdk: 'org.freedesktop.Sdk',\n  }, {\n    bundlePath: 'hello.flatpak',\n    files: [\n      ['hello', '/bin/hello']\n    ],\n    runtimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref'\n  })\n  console.log('Flatpak built successfully')\n} catch (error) {\n    console.error('Error building flatpak', error)\n}\n```\n\n### Electron App\n\n```javascript\nconst flatpakBundler = require('@malept/flatpak-bundler')\n\ntry {\n  const finalBuildOptions = await flatpakBundler.bundle({ // Manifest\n    id: 'org.world.Hello',\n    base: 'io.atom.electron.BaseApp', // Electron base application\n    runtime: 'org.freedesktop.Platform', // Use the freedesktop runtime\n    runtimeVersion: '1.4',\n    sdk: 'org.freedesktop.Sdk',\n    finishArgs: [\n      '--share=ipc', '--socket=x11', // Allow app to show windows with X11\n      '--socket=pulseaudio', // Allow audio output\n      '--filesystem=home', // Allow access to users home directory\n      '--share=network', // Allow network access\n      '--device=dri' // Allow OpenGL rendering\n    ],\n    renameDesktopFile: 'hello.desktop', // Rename the desktop file to agree with the app ID so flatpak will export it\n    renameIcon: 'hello' // Rename the icon to agree with the app ID so flatpak will export it\n  }, { // Build options\n    arch: 'x86_64',\n    baseFlatpakref: 'https://s3-us-west-2.amazonaws.com/electron-flatpak.endlessm.com/electron-base-app-master.flatpakref', // So we can auto install the runtime\n    bundlePath: 'dist/hello_x86_64.flatpak',\n    files: [\n      [ 'static/linux', '/share/' ], // Desktop file and icons\n      [ packagedFileDir, '/share/bar' ] // Application binaries and assets\n    ],\n    gpgSign: '1234ABCD', // GPG key to sign with\n    runtimeFlatpakref: 'https://raw.githubusercontent.com/endlessm/flatpak-bundler/master/refs/freedesktop-runtime-1.4.flatpakref',\n    symlinks: [\n      [ '/share/bar/Bar', '/bin/Bar' ] // Create a symlink in /bin to to app executable\n    ]\n  })\n  console.log('Flatpak built successfully.')\n  console.log(`Build dir and repo in ${finalBuildOptions.workingDir}`)\n} catch (error) {\n  console.error('Error building flatpak', error)\n}\n```\n","_attachments":{},"homepage":"https://github.com/malept/flatpak-bundler#readme","bugs":{"url":"https://github.com/malept/flatpak-bundler/issues"},"license":"MIT"}