Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Add Linux support (#274)
Browse files Browse the repository at this point in the history
  • Loading branch information
quanglam2807 authored Jul 7, 2019
1 parent 45523d6 commit 12f5c52
Show file tree
Hide file tree
Showing 30 changed files with 593 additions and 284 deletions.
23 changes: 19 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
language: node_js
os: osx
node_js: 12
osx_image: xcode10.2
matrix:
fast_finish: true
include:
- os: osx
osx_image: xcode10.2
- os: linux
env:
- CC=clang CXX=clang++ npm_config_clang=1
compiler: clang
addons:
apt:
packages:
- python3
- python3-pip
- python3-setuptools
- libxkbfile-dev
- libx11-dev
cache: yarn
before_script:
- npm install -g npx
- yarn template:install
- yarn lint
script:
- yarn dist
- yarn catalog:install && yarn catalog:test
- if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then yarn
- if [ "$TRAVIS_OS_NAME" == "linux" ]; then yarn catalog:install && yarn catalog:test; fi
- if [ "$TRAVIS_OS_NAME" == "linux" -a "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then yarn
catalog:install && yarn catalog:pack && yarn catalog:publish; fi
notifications:
email: false
Expand Down
25 changes: 23 additions & 2 deletions dist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const fs = require('fs-extra');
const builder = require('electron-builder');

const { Platform } = builder;
const { Arch, Platform } = builder;

console.log(`Machine: ${process.platform}`);

Expand All @@ -23,8 +23,25 @@ fs.writeJSONSync(TEMPLATE_JSON_PATH, {
version: templatePackageJson.version,
});

let targets;
switch (process.platform) {
case 'darwin': {
targets = Platform.MAC.createTarget();
break;
}
case 'win32': {
targets = Platform.WINDOWS.createTarget(['nsis'], Arch.x64);
break;
}
default:
case 'linux': {
targets = Platform.LINUX.createTarget(['AppImage'], Arch.x64);
break;
}
}

const opts = {
targets: Platform.MAC.createTarget(),
targets,
config: {
appId: 'com.webcatalog.jordan',
productName: 'WebCatalog',
Expand All @@ -43,6 +60,10 @@ const opts = {
mac: {
category: 'public.app-category.utilities',
},
linux: {
category: 'Utility',
packageCategory: 'utils',
},
afterAllArtifactBuild: () => [TEMPLATE_JSON_PATH],
},
};
Expand Down
156 changes: 156 additions & 0 deletions docs/_layouts/download.html

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions docs/download/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
layout: download
title: Download
---
5 changes: 5 additions & 0 deletions docs/download/linux.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: download
platform: linux
title: Download for Linux
---
5 changes: 5 additions & 0 deletions docs/download/mac.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
layout: download
platform: mac
title: Download for macOS
---
92 changes: 2 additions & 90 deletions docs/index.html
Original file line number Diff line number Diff line change
@@ -1,91 +1,3 @@
---
layout: default
---
<div class="hero-body">
<div class="container">
<div class="has-text-centered">
<h1 class="title is-3">
Run Web Apps like Real Apps
</h1>
<h2 class="subtitle">
Boost your productivity & protect your privacy with WebCatalog.
</h2>

<div class="buttons is-centered">
<a class="button is-medium is-black" href="https://github.com/webcatalog/webcatalog/releases/download/v{{ site.webcatalog_version }}/WebCatalog-{{ site.webcatalog_version }}.dmg">
<svg style="height: 24px; width: 24px;" aria-hidden="true" data-prefix="fab" data-icon="apple" class="svg-inline--fa fa-apple fa-w-12" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 376 512"><path fill="currentColor" d="M314.7 268.7c-.2-36.7 16.4-64.4 50-84.8-18.8-26.9-47.2-41.7-84.7-44.6-35.5-2.8-74.3 20.7-88.5 20.7-15 0-49.4-19.7-76.4-19.7C59.3 141.2 0 184.8 0 273.5c0 26.2 4.8 53.3 14.4 81.2 12.8 36.7 59 126.7 107.2 125.2 25.2-.6 43-17.9 75.8-17.9 31.8 0 48.3 17.9 76.4 17.9 48.6-.7 90.4-82.5 102.6-119.3-65.2-30.7-61.7-90-61.7-91.9zm-56.6-164.2c27.3-32.4 24.8-61.9 24-72.5-24.1 1.4-52 16.4-67.9 34.9-17.5 19.8-27.8 44.3-25.6 71.9 26.1 2 49.9-11.4 69.5-34.3z"></path></svg>
<span>&nbsp; Download for macOS*</span>
</a>
<a class="button is-medium is-link" href="https://webcatalog.onfastspring.com/webcatalog-lite">
<span>&nbsp; Buy Now - $4.<small>99</small></span>
</a>
</div>

<p><small>Version {{ site.webcatalog_version }} (<a href="https://github.com/quanglam2807/webcatalog/releases">Release Notes</a>). WebCatalog requires macOS 10.10 or later.</small></p>

<br />

<p><small>*You can install up to two apps for free.</small></p>

<p>
<a href="/images/demos/main.png">
<img src="/images/demos/main.png" alt="WebCatalog" class="demo_main">
</a>
</p>
</div>
<div class="content">
<hr />
<h4>How It Works</h4>
<p>WebCatalog lets you turn any web apps into native-like Mac apps (also called <a href="https://en.wikipedia.org/wiki/Site-specific_browser">site-specific browsers</a>). Now, with WebCatalog, you can launch your favorite apps quickly in self-contained, distraction-free windows. Each app's data is stored separately, protecting you from cross-website trackers and preserving your privacy.</p>
<hr />
<h4 class="is-pulled-left">Featured Apps</h4>
<a class="button is-white is-pulled-right" href="/catalog/">See more</a>
<div class="columns is-multiline" style="clear:both;">
{% for item in site.catalog %}
{% if item.featured == true %}
<div class="column is-3 has-text-centered" style="padding-top: 30px;">
<a href="/catalog/{{ item.key }}">
<img src="https://s3.getwebcatalog.com/apps/{{ item.key }}/{{ item.key }}-icon-128.png" class="app-icon-small" alt="{{ item.name }}">
<p>{{ item.name }}</p>
</a>
</div>
{% endif %}
{% endfor %}
</div>
<hr />
<h4>Notable Features</h4>
<div class="columns is-multiline">
<div class="column is-half has-text-centered">
<a href="/images/demos/catalog.png">
<img src="/images/demos/catalog.png" alt="Catalog" class="demo">
</a>
<p><small><b>Catalog</b> - Install apps quickly from our curated catalog.</small></p>
</div>
<div class="column is-half has-text-centered">
<a href="/images/demos/appview.png">
<img src="/images/demos/appview.png" alt="App View" class="demo">
</a>
<p><small><b>AppView</b> - Run any website like a real Mac app.</small></p>
</div>
<div class="column is-half has-text-centered">
<a href="/images/demos/workspace.png">
<img src="/images/demos/workspace.png" alt="Workspace" class="demo">
</a>
<p><small><b>Workspaces</b> - Switch between multiple accounts/projects.</small></p>
</div>
<div class="column is-half has-text-centered">
<a href="/images/demos/menubar.png">
<img src="/images/demos/menubar.png" alt="Menubar" class="demo">
</a>
<p><small><b>Menubar</b> - Access your apps anytime and anywhere.</small></p>
</div>
<div class="column has-text-centered">
<a href="/images/demos/customization.png">
<img src="/images/demos/customization.png" alt="Customization" class="demo">
</a>
<p><small><b>Customization</b> - Customize everything to suite your taste.</small></p>
</div>
</div>
</div>
</div>
</div>
layout: download
---
14 changes: 9 additions & 5 deletions public/libs/app-management/get-installed-apps-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,17 @@ const getInstalledAppsAsync = () => {
files.forEach((fileName) => {
if (fileName === '.DS_Store') return;

const packageJsonPath = path.join(installationPath, fileName, 'Contents', 'Resources', 'app.asar.unpacked', 'package.json');
const resourcesPath = process.platform === 'darwin'
? path.join(installationPath, fileName, 'Contents', 'Resources')
: path.join(installationPath, fileName, 'resources');

const legacyAppJsonPath = path.join(installationPath, fileName, 'Contents', 'Resources', 'app.asar.unpacked', 'public', 'app.json');
const legacyIconPath = path.join(installationPath, fileName, 'Contents', 'Resources', 'app.asar.unpacked', 'public', 'icon.png');
const packageJsonPath = path.join(resourcesPath, 'app.asar.unpacked', 'package.json');

const appJsonPath = path.join(installationPath, fileName, 'Contents', 'Resources', 'app.asar.unpacked', 'build', 'app.json');
const iconPath = path.join(installationPath, fileName, 'Contents', 'Resources', 'app.asar.unpacked', 'build', 'icon.png');
const legacyAppJsonPath = path.join(resourcesPath, 'app.asar.unpacked', 'public', 'app.json');
const legacyIconPath = path.join(resourcesPath, 'app.asar.unpacked', 'public', 'icon.png');

const appJsonPath = path.join(resourcesPath, 'app.asar.unpacked', 'build', 'app.json');
const iconPath = path.join(resourcesPath, 'app.asar.unpacked', 'build', 'icon.png');

let packageJson;
let appJson;
Expand Down
57 changes: 41 additions & 16 deletions public/libs/app-management/install-app-async/forked-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const tmpObj = tmp.dirSync();
const tmpPath = tmpObj.name;
const appPath = path.join(tmpPath, 'template');
const buildResourcesPath = path.join(tmpPath, 'build-resources');
const iconIcnsPath = path.join(buildResourcesPath, 'icon.icns');
const iconPngPath = path.join(buildResourcesPath, 'icon.png');
const iconIcnsPath = path.join(buildResourcesPath, 'e.icns');
const iconPngPath = path.join(buildResourcesPath, 'e.png');
const appJsonPath = path.join(appPath, 'build', 'app.json');
const publicIconPngPath = path.join(appPath, 'build', 'icon.png');
const packageJsonPath = path.join(appPath, 'package.json');
Expand All @@ -38,11 +38,11 @@ const outputPath = path.join(tmpPath, 'dist');
const menubarIconPath = path.join(appPath, 'build', 'menubar-icon.png');
const menubarIcon2xPath = path.join(appPath, 'build', '[email protected]');

const dotAppPath = path.join(outputPath, `${name}-darwin-x64`, `${name}.app`);
const dotAppPath = process.platform === 'darwin' ? path.join(outputPath, `${name}-darwin-x64`, `${name}.app`) : path.join(outputPath, `${name}-linux-x64`);

const allAppsPath = installationPath.replace('~', homePath);

const finalPath = path.join(allAppsPath, `${name}.app`);
const finalPath = process.platform === 'darwin' ? path.join(allAppsPath, `${name}.app`) : path.join(allAppsPath, `${name}`);

const sizes = [16, 32, 64, 128, 256, 512, 1024];

Expand All @@ -67,7 +67,7 @@ decompress(templatePath, tmpPath)
.then(() => {
if (isUrl(icon)) {
return download(icon, buildResourcesPath, {
filename: 'icon.png',
filename: 'e.png',
});
}

Expand Down Expand Up @@ -101,14 +101,18 @@ decompress(templatePath, tmpPath)

return Promise.all(p);
})
.then(() => icongen(buildResourcesPath, buildResourcesPath, {
report: true,
icns: {
name: 'icon',
sizes,
},
}))
.then(results => results[0])
.then(() => {
if (process.platform === 'darwin') {
return icongen(buildResourcesPath, buildResourcesPath, {
report: true,
icns: {
name: 'icon',
sizes,
},
});
}
return null;
})
.then(() => fsExtra.copy(iconPngPath, publicIconPngPath))
.then(() => {
const appJson = JSON.stringify({
Expand All @@ -129,8 +133,8 @@ decompress(templatePath, tmpPath)
const opts = {
name,
appBundleId: `com.webcatalog.juli.${id}`,
icon: iconIcnsPath,
platform: 'darwin',
icon: process.platform === 'darwin' ? iconIcnsPath : iconPngPath,
platform: process.platform,
dir: appPath,
out: outputPath,
overwrite: true,
Expand Down Expand Up @@ -165,19 +169,40 @@ decompress(templatePath, tmpPath)
if (requireAdmin === 'true') {
return sudoAsync(`mkdir -p "${allAppsPath}" && rm -rf "${finalPath}" && mv "${dotAppPath}" "${finalPath}"`);
}

return fsExtra.move(dotAppPath, finalPath, { overwrite: true });
})
.then(() => {
// create desktop file for linux
if (process.platform === 'linux') {
const execFilePath = path.join(finalPath, name);
const iconPath = path.join(finalPath, 'resources', 'app.asar.unpacked', 'build', 'icon.png');
const desktopFilePath = path.join(homePath, '.local', 'share', 'applications', `webcatalog-${id}.desktop`);
const desktopFileContent = `[Desktop Entry]
Version=1.0
Type=Application
Name=${name}
GenericName=${name}
Icon=${iconPath}
Exec=${execFilePath}
Terminal=false;
`;
return fsExtra.writeFileSync(desktopFilePath, desktopFileContent);
}
return null;
})
.then(() => {
process.exit(0);
})
.catch((e) => {
/* eslint-disable-next-line */
console.log(e);
process.send(e);
process.exit(1);
});

process.on('uncaughtException', (e) => {
/* eslint-disable-next-line */
console.log(e);
process.exit(1);
process.send(e);
});
10 changes: 8 additions & 2 deletions public/libs/app-management/open-app.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
const { app, shell } = require('electron');
const path = require('path');
const { exec } = require('child_process');

const { getPreference } = require('../preferences');

const openApp = (id, name) => {
const appPath = path.join(getPreference('installationPath').replace('~', app.getPath('home')), `${name}.app`);
shell.openItem(appPath);
let appPath;
if (process.platform === 'darwin') {
appPath = path.join(getPreference('installationPath').replace('~', app.getPath('home')), `${name}.app`);
shell.openItem(appPath);
} else if (process.platform === 'linux') {
exec(`gtk-launch webcatalog-${id}`);
}
};

module.exports = openApp;
20 changes: 17 additions & 3 deletions public/libs/app-management/uninstall-app-async/forked-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const argv = require('yargs-parser')(process.argv.slice(1));
const sudo = require('sudo-prompt');

const {
id,
name,
installationPath,
requireAdmin,
Expand Down Expand Up @@ -40,8 +41,9 @@ const checkExistsAndRemoveWithSudo = dirPath => fsExtra.exists(dirPath)
return null;
});

const dotAppPath = path.join(installationPath.replace('~', homePath), `${name}.app`);
const appDataPath = path.join(homePath, 'Library', 'Application Support', name);
const dotAppPath = process.platform === 'darwin'
? path.join(installationPath.replace('~', homePath), `${name}.app`)
: path.join(installationPath.replace('~', homePath), `${name}`);

Promise.resolve()
.then(() => {
Expand All @@ -50,7 +52,19 @@ Promise.resolve()
}
return checkExistsAndRemove(dotAppPath);
})
.then(() => checkExistsAndRemove(appDataPath))
.then(() => {
if (process.platform === 'darwin') {
const appDataPath = path.join(homePath, 'Library', 'Application Support', name);
return checkExistsAndRemove(appDataPath);
}

if (process.platform === 'linux') {
const desktopFilePath = path.join(homePath, '.local', 'share', 'applications', `webcatalog-${id}.desktop`);
return checkExistsAndRemove(desktopFilePath);
}

return null;
})
.then(() => {
process.exit(0);
})
Expand Down
Loading

0 comments on commit 12f5c52

Please sign in to comment.