Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support .AppImage format #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions docs/assets.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Nuts uses GitHub Releases and assets to serve the right file to the right user.

See GitHub guides: [About Releases](https://help.github.com/articles/about-releases/) & [Creating Releases](https://help.github.com/articles/creating-releases/).

### Naming
## Naming

Nuts uses some filename/extension conventions to serve the correct asset to a specific request:

Expand All @@ -18,18 +18,17 @@ By default releases are tagged as 32-bits (except for OSX), but 64-bits will als

Filetype and usage will be detected from the extension:

| Platform | Extensions (sorted by priority) |
| -------- | ---------- |
| Windows | `.exe`, `.nupkg`, `.zip` |
| OS X | `.dmg`, `.zip` |
| Linux | `.deb`, `.rpm`, `.zip` |

| Platform | Extensions (sorted by priority) |
| -------- | ----------------------------------- |
| Windows | `.exe`, `.nupkg`, `.zip` |
| OS X | `.dmg`, `.zip` |
| Linux | `.AppImage`, `.deb`, `.rpm`, `.zip` |

### Example

Here is a list of files in one of the latest release of our [GitBook Editor](https://www.gitbook.com/editor):

```
```sh
gitbook-editor-5.0.0-beta.10-linux-ia32.deb
gitbook-editor-5.0.0-beta.10-linux-x64.deb
gitbook-editor-5.0.0-beta.10-osx-x64.dmg
Expand Down
12 changes: 10 additions & 2 deletions lib/utils/platforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ var platforms = {
LINUX: 'linux',
LINUX_32: 'linux_32',
LINUX_64: 'linux_64',
LINUX_APPIMAGE: 'linux_AppImage',
LINUX_APPIMAGE_32: 'linux_AppImage_32',
LINUX_APPIMAGE_64: 'linux_AppImage_64',
LINUX_RPM: 'linux_rpm',
LINUX_RPM_32: 'linux_rpm_32',
LINUX_RPM_64: 'linux_rpm_64',
Expand Down Expand Up @@ -41,11 +44,15 @@ function detectPlatform(platform) {
if (_.contains(name, 'linux')
|| _.contains(name, 'ubuntu')
|| hasSuffix(name, '.deb')
|| hasSuffix(name, '.appimage')
|| hasSuffix(name, '.rpm')
|| hasSuffix(name, '.tgz')
|| hasSuffix(name, '.tar.gz')) {

if (_.contains(name, 'linux_deb') || hasSuffix(name, '.deb')) {
if (_.contains(name, 'linux_appimage') || hasSuffix(name, '.appimage')) {
prefix = platforms.LINUX_APPIMAGE;
}
else if (_.contains(name, 'linux_deb') || hasSuffix(name, '.deb')) {
prefix = platforms.LINUX_DEB;
}
else if (_.contains(name, 'linux_rpm') || hasSuffix(name, '.rpm')) {
Expand All @@ -64,6 +71,7 @@ function detectPlatform(platform) {
// Detect suffix: 32 or 64
if (_.contains(name, '32')
|| _.contains(name, 'ia32')
|| _.contains(name, 'i386')
|| _.contains(name, 'i386')) suffix = '32';
if (_.contains(name, '64') || _.contains(name, 'x64') || _.contains(name, 'amd64')) suffix = '64';

Expand All @@ -89,7 +97,7 @@ function satisfiesPlatform(platform, list) {
function resolveForVersion(version, platformID, opts) {
opts = _.defaults(opts || {}, {
// Order for filetype
filePreference: ['.exe', '.dmg', '.deb', '.rpm', '.tgz', '.tar.gz', '.zip', '.nupkg'],
filePreference: ['.exe', '.dmg', '.AppImage', '.deb', '.rpm', '.tgz', '.tar.gz', '.zip', '.nupkg'],
wanted: null
});

Expand Down
26 changes: 26 additions & 0 deletions test/platforms.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ describe('Platforms', function() {
platforms.detect('enterprise-ia32.tgz').should.be.exactly(platforms.LINUX_32);
});

it('should detect AppImage_32', function() {
platforms.detect('appimaged-i686.AppImage').should.be.exactly(platforms.LINUX_APPIMAGE_32);
});

it('should detect AppImage_64', function() {
platforms.detect('appimaged-x86_64.AppImage').should.be.exactly(platforms.LINUX_APPIMAGE_64);
});

it('should detect debian_32', function() {
platforms.detect('atom-ia32.deb').should.be.exactly(platforms.LINUX_DEB_32);
});
Expand Down Expand Up @@ -88,6 +96,22 @@ describe('Platforms', function() {
'download_url': 'https://api.github.com/repos/atom/atom/releases/assets/825658',
'download_count': 2494
},
{
'type': 'linux_AppImage_32',
'filename': 'appimaged-i686.AppImage',
'size': 244728,
'content_type': 'application/octet-stream',
'download_url': 'https://api.github.com/repos/AppImage/AppImageKit/releases/assets/5295931',
'download_count': 55
},
{
'type': 'linux_AppImage_64',
'filename': 'appimaged-x86_64.AppImage',
'size': 244728,
'content_type': 'application/octet-stream',
'download_url': 'https://api.github.com/repos/AppImage/AppImageKit/releases/assets/5295938',
'download_count': 55
},
{
'type': 'linux_rpm_32',
'filename': 'atom-ia32.rpm',
Expand Down Expand Up @@ -146,6 +170,8 @@ describe('Platforms', function() {
platforms.resolve(version, 'linux_64').filename.should.be.exactly('atom-amd64.tar.gz');
platforms.resolve(version, 'linux_32').filename.should.be.exactly('atom-ia32.tar.gz');
platforms.resolve(version, 'linux_rpm_32').filename.should.be.exactly('atom-ia32.rpm');
platforms.resolve(version, 'linux_AppImage_32').filename.should.be.exactly('appimaged-i686.AppImage');
platforms.resolve(version, 'linux_AppImage_64').filename.should.be.exactly('appimaged-x86_64.AppImage');
platforms.resolve(version, 'linux_rpm_64').filename.should.be.exactly('atom-amd64.rpm');
platforms.resolve(version, 'linux_deb_32').filename.should.be.exactly('atom-ia32.deb');
platforms.resolve(version, 'linux_deb_64').filename.should.be.exactly('atom-amd64.deb');
Expand Down