Compare commits

...

53 Commits

Author SHA1 Message Date
Florian Metz
c73f13baa8 🚮 Trusted Accessibility Client 2019-10-16 16:55:42 +02:00
Florian Metz
a44c68ef46 Update deploy.yml 2019-10-14 03:48:46 +02:00
Florian Metz
218627e62d Update deploy.yml 2019-10-14 03:41:49 +02:00
Florian Metz
5d6e775b02 Update deploy.yml 2019-10-14 03:33:32 +02:00
Florian Metz
2b86cff3f3 Update deploy.yml 2019-10-14 03:25:08 +02:00
Florian Metz
0bc70dbc9e Update deploy.yml 2019-10-14 03:20:01 +02:00
Florian Metz
d1f7baad2b Update deploy.yml 2019-10-14 03:11:17 +02:00
Florian Metz
6d57bc2c5a Update deploy.yml 2019-10-14 03:06:36 +02:00
Florian Metz
8e3cf93011 Update deploy.yml 2019-10-14 03:01:19 +02:00
Florian Metz
51f6d17fbb Update deploy.yml 2019-10-14 02:48:18 +02:00
Florian Metz
b2e5229c78 Update deploy.yml 2019-10-14 02:40:14 +02:00
Florian Metz
87ec87e09d Update deploy.yml 2019-10-14 02:32:50 +02:00
Florian Metz
25bf7ac915 Update deploy.yml 2019-10-14 02:21:27 +02:00
Florian Metz
bcadad5564 Update deploy.yml 2019-10-14 02:08:34 +02:00
Florian Metz
bacda4624f Update deploy.yml 2019-10-14 02:02:14 +02:00
Florian Metz
9c5434e32c Update deploy.yml 2019-10-14 01:31:10 +02:00
Florian Metz
058421b9aa Update deploy.yml 2019-10-14 01:17:52 +02:00
Florian Metz
f947f50213 Update deploy.yml 2019-10-14 01:15:22 +02:00
Florian Metz
54688e6a71 Update deploy.yml 2019-10-14 00:59:11 +02:00
Florian Metz
d789bd7710 Update deploy.yml 2019-10-14 00:52:28 +02:00
Florian Metz
b3fa69f7c7 Update deploy.yml 2019-10-14 00:49:39 +02:00
Florian Metz
3ec47b2310 sss 2019-10-14 00:31:55 +02:00
Florian Metz
9bc37d8ecd reee 2019-10-14 00:25:41 +02:00
Florian Metz
dd21c46331 🛠 DePloY 2019-10-14 00:19:31 +02:00
Florian Metz
3c69cf7d5a 🛠 DePloY 2019-10-14 00:11:44 +02:00
Florian Metz
97f8a0faf6 🛠 DePloY 2019-10-14 00:10:10 +02:00
Florian Metz
ce8b6dc995 🛠 DePloY 2019-10-13 23:48:22 +02:00
Florian Metz
d78eebdb0e 🛠 DePloY 2019-10-13 23:46:36 +02:00
Florian Metz
01f78e0595 🛠 DePloY 2019-10-13 23:44:44 +02:00
Florian Metz
fc8e710a07 🛠 DePloY 2019-10-13 23:37:56 +02:00
Florian Metz
929131f5e6 🛠 DePloY 2019-10-13 23:35:49 +02:00
Florian Metz
4fbb0e454e 🛠 DePloY 2019-10-13 23:33:12 +02:00
Florian Metz
3832a8811d 🛠 DePloY 2019-10-13 23:30:48 +02:00
Florian Metz
8f6461e80f 🛠 DePloY 2019-10-13 23:27:36 +02:00
Florian Metz
e21e12820b 🛠 DePloY 2019-10-13 23:26:43 +02:00
Florian Metz
1edff1048f 🛠 DePloY 2019-10-13 23:25:54 +02:00
Florian Metz
8e71e6b0ea 🛠 DePloY 2019-10-13 23:24:49 +02:00
Florian Metz
1efd3dbea9 🛠 DePloY 2019-10-13 23:17:03 +02:00
Florian Metz
d02ad5a5b6 🛠 DePloY 2019-10-13 19:53:34 +02:00
Florian Metz
8758047ff0 🛠 DePloY 2019-10-13 19:51:18 +02:00
Florian Metz
c17df3c2b6 🛠 DePloY 2019-10-13 19:48:09 +02:00
Florian Metz
fe54d6537f ♻️ delete app folder 2019-10-13 19:25:34 +02:00
Florian Metz
dcc3516587 eeech 2019-10-13 19:20:31 +02:00
Florian Metz
7039296c64 🛠 GitHub actions refinement 2019-10-13 19:18:51 +02:00
Florian Metz
cdba36628f ♻️ Some installer changes 2019-10-13 19:10:00 +02:00
Florian Metz
b2465f9bdc 🚮 Remove inApplicationFolder 2019-10-13 18:37:18 +02:00
Florian Metz
4b4a398c99 🐛 Only hide dock if MacOS 2019-10-13 17:55:46 +02:00
Florian Metz
d292bd033f ♻️ UpdateChecker improvements 2019-10-13 17:53:51 +02:00
Florian Metz
faa5683b26 Add moveToApplicationsFolder to prevent issues 2019-10-13 17:52:37 +02:00
Florian Metz
ce0ae1bf04 🐛 Don't force quit app on port error 2019-10-13 17:51:07 +02:00
Florian Metz
b8f49b9312 🐛 Catch setActivity/destroy errors 2019-10-13 17:49:44 +02:00
Florian Metz
7b9bcdfd10 🚮 InputManager 2019-10-13 16:29:58 +02:00
Florian Metz
72d65a18ef ♻️ Move types to files 2019-10-13 16:28:28 +02:00
18 changed files with 263 additions and 490 deletions

15
.github/deploy.ts vendored
View File

@@ -1,6 +1,7 @@
import * as Client from "ssh2-sftp-client";
import * as archiver from "archiver";
import { platform, arch } from "os";
import * as rimraf from "rimraf";
import { platform } from "os";
import { createWriteStream } from "fs";
let sftp = new Client();
@@ -12,22 +13,18 @@ sftp
password: process.env.SSH_PASSWORD
})
.then(async () => {
rimraf.sync("../dist/app/");
console.log("Zipping...");
let output = createWriteStream("app.zip"),
archive = archiver("zip");
archive.directory(
`../dist/PreMiD-${platform()}-${arch()}`,
`PreMiD-${platform()}-${arch()}`
);
archive.directory(`../dist/`, platform());
output.on("close", function() {
console.log("Uploading...");
sftp
.fastPut(
"app.zip",
`/home/PreMiD/builds/PreMiD-${platform()}-${arch()}.zip`
)
.fastPut("app.zip", `/home/PreMiD/builds/${platform()}.zip`)
.then(() => {
console.log("Done!");
sftp.end();

View File

@@ -1,13 +1,13 @@
name: DePloY
on: push
env:
env:
NODE_ENV: DePloY
jobs:
build:
package:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
os: [windows-latest, macOS-latest]
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
@@ -23,3 +23,62 @@ jobs:
SSH_USERNAME: ${{ secrets.SSHUSERNAME }}
SSH_PASSWORD: ${{ secrets.SSHPASSWORD }}
run: npm run deploy
installer:
needs: package
runs-on: "ubuntu-latest"
steps:
- name: Prepare for installer
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSHHOST }}
username: ${{ secrets.SSHUSERNAME }}
password: ${{ secrets.SSHPASSWORD }}
script: |
cd /home/PreMiD/builds
unzip darwin.zip
unzip win32.zip
mv darwin/PreMiD-darwin-x64 PreMiD-darwin-x64
mv win32/PreMiD-win32-ia32 PreMiD-win32-ia32
mv win32/PreMiD-win32-x64 PreMiD-win32-x64
rm -r win32.zip darwin.zip darwin win32
- name: Create installer (Windows 32bit)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSHHOST }}
username: ${{ secrets.SSHUSERNAME }}
password: ${{ secrets.SSHPASSWORD }}
script: |
cd /home/PreMiD/builds
node prepare.js PreMiD-win32-ia32
/opt/installbuilder-19.9.0/bin/builder build installer.xml windows
- name: Create installer (Windows 64bit)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSHHOST }}
username: ${{ secrets.SSHUSERNAME }}
password: ${{ secrets.SSHPASSWORD }}
script: |
cd /home/PreMiD/builds
node prepare.js PreMiD-win32-x64
/opt/installbuilder-19.9.0/bin/builder build installer.xml windows
- name: Create installer (MacOS)
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSHHOST }}
username: ${{ secrets.SSHUSERNAME }}
password: ${{ secrets.SSHPASSWORD }}
script: |
cd /home/PreMiD/builds
node prepare.js PreMiD-darwin-x64
/opt/installbuilder-19.9.0/bin/builder build installer.xml osx
- name: Cleanup
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.SSHHOST }}
username: ${{ secrets.SSHUSERNAME }}
password: ${{ secrets.SSHPASSWORD }}
script: |
cd /home/PreMiD/builds
rm -r PreMiD-darwin-x64 PreMiD-win32-ia32 PreMiD-win32-x64

22
@types/PreMiD/ExtensionSettings.d.ts vendored Normal file
View File

@@ -0,0 +1,22 @@
export default interface ExtensionSettings {
/**
* If extension is enabled
*/
enabled: boolean;
/**
* Autolaunch enabled
*/
autoLaunch: boolean;
/**
* Media keys enabled
*/
mediaKeys: boolean;
/**
* title menubar (TrayTitle)
*/
titleMenubar: boolean;
/**
* language of extension
*/
language: string;
}

16
@types/PreMiD/Presence.d.ts vendored Normal file
View File

@@ -0,0 +1,16 @@
import * as Discord from "discord-rpc";
export default interface Presence {
/**
* Client ID of presence
*/
clientId: string;
/**
* Rich Procedual call connection
*/
rpc: Discord.Client;
/**
* Connection ready?
*/
ready: Boolean;
}

33
@types/PreMiD/PresenceData.d.ts vendored Normal file
View File

@@ -0,0 +1,33 @@
import * as Discord from "discord-rpc";
export default interface PresenceData {
/**
* Client ID of presence
*/
clientId: string;
/**
* Tray title to be shown in Mac OS tray
*/
trayTitle: string;
/**
* service name of presence
* @deprecated
*/
service: string;
/**
* Determines if the service is currently playing something back or not, if false it will automatically hide after 1 minute
*/
playback: boolean;
/**
* Discord Presence which gets sent directly to Discord app
*/
presenceData: Discord.Presence;
/**
* Determines if the service should be hidden (clearActivity)
*/
hidden: boolean;
/**
* Determines if the service is mediaKey able / uses them
*/
mediaKeys: boolean;
}

View File

@@ -1,236 +0,0 @@
<project>
<shortName>PreMiD</shortName>
<fullName>PreMiD</fullName>
<version>2.0</version>
<installerFilename>${product_fullname}-${product_version}-installer_32bit.${platform_exec_suffix}</installerFilename>
<wrapLicenseFileText>0</wrapLicenseFileText>
<logoImage>appIcon.png</logoImage>
<componentList>
<component>
<name>default</name>
<description>Default Component</description>
<canBeEdited>1</canBeEdited>
<selected>1</selected>
<show>1</show>
<folderList>
<folder>
<description>Program Files</description>
<destination>${installdir}</destination>
<name>programfiles</name>
<platforms>all</platforms>
<distributionFileList>
<distributionFile>
<origin>../tmp/update.ini</origin>
</distributionFile>
</distributionFileList>
</folder>
<folder>
<description>Program Files</description>
<destination>${installdir}</destination>
<name>programfileslinux</name>
<platforms>linux</platforms>
</folder>
<folder>
<description>Program Files</description>
<destination>${installdir}</destination>
<name>programfileswindows</name>
<platforms>windows</platforms>
<distributionFileList>
<distributionDirectory allowWildcards="1">
<origin>../dist/PreMiD-win32-ia32/*</origin>
</distributionDirectory>
<distributionFile>
<origin>appIcon.ico</origin>
</distributionFile>
<distributionFile>
<origin>updater.exe</origin>
</distributionFile>
</distributionFileList>
</folder>
<folder>
<description>Program Files</description>
<destination>${installdir}</destination>
<name>programfilesosx</name>
<platforms>osx</platforms>
<distributionFileList>
<distributionFile>
<origin>updater.app</origin>
</distributionFile>
<distributionFile>
<origin>../dist/PreMiD-darwin-x64/PreMiD.app</origin>
</distributionFile>
</distributionFileList>
</folder>
</folderList>
<startMenuShortcutList>
<startMenuShortcut>
<comment></comment>
<name>${product_fullname}</name>
<runAsAdmin>0</runAsAdmin>
<runInTerminal>0</runInTerminal>
<windowsExec>${installdir}/PreMID.exe</windowsExec>
<windowsExecArgs></windowsExecArgs>
<windowsIcon></windowsIcon>
<windowsPath>${installdir}/</windowsPath>
</startMenuShortcut>
</startMenuShortcutList>
</component>
</componentList>
<preInstallationActionList>
<kill>
<abortOnError>0</abortOnError>
<name>${product_fullname}.exe</name>
<progressText>Killing ${product_fullname}</progressText>
<showMessageOnError>0</showMessageOnError>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
</ruleList>
</kill>
<runProgram>
<program>pkill</program>
<programArguments>PreMiD</programArguments>
<runAs>${env(USER)}</runAs>
<useMSDOSPath>0</useMSDOSPath>
<workingDirectory>${installdir}/</workingDirectory>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
<processTest>
<logic>is_running</logic>
<name>PreMiD</name>
</processTest>
</ruleList>
</runProgram>
<runProgram>
<program>${windows_folder_local_appdata}\premid\Update.exe</program>
<programArguments>--uninstall</programArguments>
<onErrorActionList>
<deleteFile>
<matchHiddenFiles>1</matchHiddenFiles>
<path>${windows_folder_local_appdata}\premid</path>
</deleteFile>
</onErrorActionList>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
<fileExists>
<path>${windows_folder_local_appdata}\premid\PreMiD.exe</path>
</fileExists>
</ruleList>
</runProgram>
</preInstallationActionList>
<postInstallationActionList>
<runProgram>
<abortOnError>0</abortOnError>
<program>PreMID.exe</program>
<programArguments>&amp;</programArguments>
<progressText>Launching PreMiD</progressText>
<show>0</show>
<showMessageOnError>0</showMessageOnError>
<workingDirectory>${installdir}</workingDirectory>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
</ruleList>
</runProgram>
<setInstallerVariableFromRegEx show="0">
<name>escaped_installdir</name>
<pattern> </pattern>
<substitution>\\ </substitution>
<text>${installdir}</text>
</setInstallerVariableFromRegEx>
<runProgram>
<program>open</program>
<programArguments> ${escaped_installdir}/PreMiD.app</programArguments>
<progressText>Launching PreMiD</progressText>
<runAs>${env(USER)}</runAs>
<useMSDOSPath>0</useMSDOSPath>
<workingDirectory>${installdir}/</workingDirectory>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
</ruleList>
</runProgram>
<deleteFile>
<path>${installdir}/update</path>
</deleteFile>
<addDirectoriesToUninstaller>
<addContents>1</addContents>
<files>${installdir}</files>
</addDirectoriesToUninstaller>
<deleteFile>
<path>${windows_folder_local_appdata}\premid</path>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
</ruleList>
</deleteFile>
</postInstallationActionList>
<preUninstallationActionList>
<kill>
<abortOnError>0</abortOnError>
<name>${product_fullname}.exe</name>
<progressText>Killing ${product_fullname}</progressText>
<showMessageOnError>0</showMessageOnError>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
</ruleList>
</kill>
<runProgram>
<program>pkill</program>
<programArguments>PreMiD</programArguments>
<runAs>${env(USER)}</runAs>
<useMSDOSPath>0</useMSDOSPath>
<workingDirectory>${installdir}/</workingDirectory>
<ruleList>
<platformTest>
<type>osx</type>
</platformTest>
<processTest>
<logic>is_running</logic>
<name>PreMiD</name>
</processTest>
</ruleList>
</runProgram>
<deleteFile>
<path>${installdir}/update/</path>
</deleteFile>
<deleteFile>
<matchHiddenFiles>1</matchHiddenFiles>
<path>${windows_folder_appdata}/${product_fullname}</path>
</deleteFile>
</preUninstallationActionList>
<defaultInstallationMode>unattended</defaultInstallationMode>
<enableRollback>0</enableRollback>
<enableTimestamp>1</enableTimestamp>
<osxPlatforms>osx-intel osx-x86_64</osxPlatforms>
<outputDirectory>../dist/installer</outputDirectory>
<productDisplayIcon>${installdir}/appIcon.ico</productDisplayIcon>
<saveRelativePaths>1</saveRelativePaths>
<unattendedModeUI>minimal</unattendedModeUI>
<vendor>Timeraa</vendor>
<windowsExecutableIcon>appIcon.ico</windowsExecutableIcon>
<parameterList>
<directoryParameter>
<name>installdir</name>
<description>Installer.Parameter.installdir.description</description>
<explanation>Installer.Parameter.installdir.explanation</explanation>
<value></value>
<default>${platform_install_prefix}/${product_shortname}</default>
<allowEmptyValue>0</allowEmptyValue>
<cliOptionName>prefix</cliOptionName>
<mustBeWritable>1</mustBeWritable>
<mustExist>0</mustExist>
<width>40</width>
</directoryParameter>
</parameterList>
</project>

View File

@@ -1,10 +1,11 @@
<project>
<shortName>PreMiD</shortName>
<fullName>PreMiD</fullName>
<version>2.0</version>
<version>{{VERSION}}</version>
<installerFilename>${product_fullname}-${product_version}-installer_64bit.${platform_exec_suffix}</installerFilename>
<wrapLicenseFileText>0</wrapLicenseFileText>
<logoImage>appIcon.png</logoImage>
<logoImage>../installer_assets/appIcon.png</logoImage>
<osxApplicationBundleIcon>../installer_assets/appIcon.icns</osxApplicationBundleIcon>
<componentList>
<component>
<name>default</name>
@@ -20,7 +21,7 @@
<platforms>all</platforms>
<distributionFileList>
<distributionFile>
<origin>../tmp/update.ini</origin>
<origin>update.ini</origin>
</distributionFile>
</distributionFileList>
</folder>
@@ -37,13 +38,13 @@
<platforms>windows</platforms>
<distributionFileList>
<distributionDirectory allowWildcards="1">
<origin>../dist/PreMiD-win32-x64/*</origin>
<origin>../dist/PACKAGEDNAME/*</origin>
</distributionDirectory>
<distributionFile>
<origin>appIcon.ico</origin>
<origin>../installer_assets/appIcon.ico</origin>
</distributionFile>
<distributionFile>
<origin>updater.exe</origin>
<origin>../installer_assets/updater.exe</origin>
</distributionFile>
</distributionFileList>
</folder>
@@ -54,10 +55,10 @@
<platforms>osx</platforms>
<distributionFileList>
<distributionFile>
<origin>updater.app</origin>
<origin>../installer_assets/updater.app</origin>
</distributionFile>
<distributionFile>
<origin>../dist/PreMiD-darwin-x64/PreMiD.app</origin>
<origin>../dist/PACKAGEDNAME/PreMiD.app</origin>
</distributionFile>
</distributionFileList>
</folder>
@@ -68,7 +69,7 @@
<name>${product_fullname}</name>
<runAsAdmin>0</runAsAdmin>
<runInTerminal>0</runInTerminal>
<windowsExec>${installdir}/PreMID.exe</windowsExec>
<windowsExec>${installdir}/PreMiD.exe</windowsExec>
<windowsExecArgs></windowsExecArgs>
<windowsIcon></windowsIcon>
<windowsPath>${installdir}/</windowsPath>
@@ -122,11 +123,29 @@
</fileExists>
</ruleList>
</runProgram>
<runProgram>
<program>${windows_folder_common_appdata}\${system_username}\premid\Update.exe</program>
<programArguments>--uninstall</programArguments>
<onErrorActionList>
<deleteFile>
<matchHiddenFiles>1</matchHiddenFiles>
<path>${windows_folder_common_appdata}\${system_username}\premid</path>
</deleteFile>
</onErrorActionList>
<ruleList>
<platformTest>
<type>windows</type>
</platformTest>
<fileExists>
<path>${windows_folder_common_appdata}\${system_username}\premid\PreMiD.exe</path>
</fileExists>
</ruleList>
</runProgram>
</preInstallationActionList>
<postInstallationActionList>
<runProgram>
<abortOnError>0</abortOnError>
<program>PreMID.exe</program>
<program>PreMiD.exe</program>
<programArguments>&amp;</programArguments>
<progressText>Launching PreMiD</progressText>
<show>0</show>
@@ -212,13 +231,15 @@
<defaultInstallationMode>unattended</defaultInstallationMode>
<enableRollback>0</enableRollback>
<enableTimestamp>1</enableTimestamp>
<osxPlatforms>osx-intel osx-x86_64</osxPlatforms>
<installationScope>user</installationScope>
<overwritePolicy>onlyIfNewer</overwritePolicy>
<osxApplicationBundleIdentifier>eu.Timeraa.PreMiD</osxApplicationBundleIdentifier>
<outputDirectory>../dist/installer</outputDirectory>
<productDisplayIcon>${installdir}/appIcon.ico</productDisplayIcon>
<saveRelativePaths>1</saveRelativePaths>
<unattendedModeUI>minimal</unattendedModeUI>
<vendor>Timeraa</vendor>
<windowsExecutableIcon>appIcon.ico</windowsExecutableIcon>
<windowsExecutableIcon>../installer_assets/appIcon.ico</windowsExecutableIcon>
<parameterList>
<directoryParameter>
<name>installdir</name>
@@ -234,4 +255,3 @@
</directoryParameter>
</parameterList>
</project>

View File

@@ -8,5 +8,4 @@
<enableSslSupport>1</enableSslSupport>
<outputDirectory>./</outputDirectory>
<installerFilename>updater.${platform_exec_suffix}</installerFilename>
<osxPlatforms>osx-intel osx-x86_64</osxPlatforms>
</autoUpdateProject>

12
package-lock.json generated
View File

@@ -1,6 +1,6 @@
{
"name": "premid",
"version": "2.0.4",
"version": "2.0.5",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
@@ -231,6 +231,16 @@
"@types/request": "*"
}
},
"@types/rimraf": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/@types/rimraf/-/rimraf-2.0.2.tgz",
"integrity": "sha512-Hm/bnWq0TCy7jmjeN5bKYij9vw5GrDFWME4IuxV08278NtU/VdGbzsBohcCUJ7+QMqmUq5hpRKB39HeQWJjztQ==",
"dev": true,
"requires": {
"@types/glob": "*",
"@types/node": "*"
}
},
"@types/socket.io": {
"version": "2.1.4",
"resolved": "https://registry.npmjs.org/@types/socket.io/-/socket.io-2.1.4.tgz",

View File

@@ -2,7 +2,7 @@
"name": "premid",
"productName": "PreMiD",
"description": "Discord Rich Presence for websites.",
"version": "2.0.4",
"version": "2.0.5",
"repository": "https://github.com/PreMiD/PreMiD",
"scripts": {
"init": "tsc && tsc pkg devMode && node devMode.js compile",
@@ -23,6 +23,7 @@
"@types/ora": "3.2.0",
"@types/prompts": "2.0.1",
"@types/request-promise-native": "1.0.17",
"@types/rimraf": "^2.0.2",
"@types/socket.io": "2.1.4",
"@types/ssh2-sftp-client": "4.1.0",
"archiver": "3.1.1",

36
pkg.ts
View File

@@ -1,5 +1,5 @@
import * as electronPackager from "electron-packager";
import { platform } from "os";
import { platform, arch } from "os";
import { existsSync, readFileSync, writeFileSync } from "fs";
import { resolve } from "path";
import { exec } from "child_process";
@@ -11,7 +11,7 @@ import * as ora from "ora";
(async () => {
let response = {
os: "current",
arch: "current",
arch: "all",
installer: false
};
@@ -90,7 +90,26 @@ import * as ora from "ora";
}
]);
if (!response.os) return;
//#region WIP
let installerXml = readFileSync(`installer_assets/installer.xml`, "utf-8");
installerXml = installerXml.replace(
"{{VERSION}}",
require("./package.json").version
);
installerXml = installerXml.replace(
/(PACKAGEDNAME)/g,
`PreMiD-${platform()}-${arch()}`
);
ensureDirSync("tmp");
writeFileSync("tmp/installer.xml", installerXml);
//#endregion
if (!response.os) {
process.exit();
return;
}
let icon: string;
@@ -109,7 +128,7 @@ import * as ora from "ora";
removeSync("./dist/app/updater.exe");
let spinner = ora("Packaging app").start(),
packagingOptions = {
packagingOptions: electronPackager.Options = {
dir: "./dist/app",
out: "./dist",
darwinDarkModeSupport: true,
@@ -120,7 +139,9 @@ import * as ora from "ora";
appCategoryType: "Utilities",
appCopyright: `Timeraa 2018-${new Date().getFullYear()}`,
prune: true,
// @ts-ignore
arch: response.arch,
// @ts-ignore
platform: response.os
};
@@ -132,6 +153,7 @@ import * as ora from "ora";
if (!response.installer) {
spinner.text = "Done!";
spinner.succeed();
process.exit();
return;
}
@@ -166,6 +188,7 @@ import * as ora from "ora";
if (!existsSync(bitRockBuilder) || !existsSync(bitRockUpdater)) {
spinner.fail("Bitrock installation not found.");
process.exit();
return;
}
@@ -180,12 +203,13 @@ import * as ora from "ora";
updater.once("exit", (code, signal) => {
if (![0, 1].includes(code)) {
spinner.fail(`Updater failed with code ${code}: ${signal}`);
process.exit();
return;
}
spinner.text = "Building installer";
let builder = exec(
`"${bitRockBuilder}" build installer_assets/PreMiD_x64.xml ${
`"${bitRockBuilder}" build tmp/installer.xml ${
platform() === "win32" ? "windows" : "osx"
}`
);
@@ -195,11 +219,13 @@ import * as ora from "ora";
if (code !== 0) {
spinner.fail(`Error code: ${code}`);
process.exit();
return;
}
spinner.text = "Done!";
spinner.succeed();
process.exit();
return;
});
});

View File

@@ -7,37 +7,26 @@ import { init as initTray } from "./managers/trayManager";
import { update as initAutoLaunch } from "./managers/launchManager";
import { platform } from "os";
import { checkForUpdate } from "./util/updateChecker";
import { info } from "./util/debug";
//* Define and set it to null
//* Set AppUserModelId for task manager etc
//* Hide app icon if Mac OS
//* Mac OS truted accessability client
//* When app is ready
export let updateCheckerInterval = null;
app.setAppUserModelId("Timeraa.PreMiD");
if (platform() === "darwin") {
app.dock.hide();
!systemPreferences.isTrustedAccessibilityClient(false)
? systemPreferences.isTrustedAccessibilityClient(true)
: info("Trusted accessibility client.");
}
//* When app is ready
app.whenReady().then(async () => {
//* Init auto launch
initAutoLaunch();
//* Check for updates > Update and relaunch
//* Init socket
//* init application tray icon
//* If app is packaged, run an update check every 15 mins
initAutoLaunch();
await checkForUpdate(true);
await initSocket();
await initTray();
app.isPackaged
? (updateCheckerInterval = setInterval(checkForUpdate, 15 * 1000 * 60))
: undefined;
if (platform() === "darwin") app.dock.hide();
});
//* If second instance started, close old one

View File

@@ -3,7 +3,10 @@ import { app } from "electron";
import { platform } from "os";
import { tray } from "./trayManager";
import { info } from "../util/debug";
import { init as initKeybinds, deinit as deinitKeybinds } from "./inputManager";
//* Import custom types
import Presence from "../../@types/PreMiD/Presence";
import PresenceData from "../../@types/PreMiD/PresenceData";
//* Define Presence array
let loggedInPresences: Array<Presence> = [];
@@ -13,21 +16,18 @@ let loggedInPresences: Array<Presence> = [];
* @param presence PresenceData to set activity
*/
export function setActivity(presence: PresenceData) {
//* If presence.mediakeys defined & enabled, init
//* If platform is darwin (Mac OS) set trayTitle if theres one
//* Check if theres an active RPC connection that we can use
//* If we have one, use it
//* Else create one and use it
//* Show debug
if (presence.mediaKeys) initKeybinds();
else deinitKeybinds();
if (platform() === "darwin" && presence.trayTitle)
tray.setTitle(presence.trayTitle);
let rpc = loggedInPresences.find(p => p.clientId === presence.clientId);
if (rpc) rpc.rpc.setActivity(presence.presenceData);
if (rpc) rpc.rpc.setActivity(presence.presenceData).catch(destroy);
else
loginPresence(presence.clientId).then(p =>
p.rpc.setActivity(presence.presenceData)
p.rpc.setActivity(presence.presenceData).catch(destroy)
);
info("setActivity");
}
@@ -37,22 +37,20 @@ export function setActivity(presence: PresenceData) {
* @param clientId clientId of presence to clear
*/
export function clearActivity(clientId: string = undefined) {
//* Clear keybinds
//* Clear tray title
//* If clientId set
//* Else map through presences and clear them
//* Show Debug
deinitKeybinds();
if (platform() === "darwin") tray.setTitle("");
if (clientId) {
//* Check if this presence is logged in
//* If it is clear its activity
//* Return to prevent further actions
let pTC = loggedInPresences.find(p => p.clientId === clientId);
if (pTC) pTC.rpc.clearActivity();
if (pTC) pTC.rpc.clearActivity().catch(destroy);
return;
}
loggedInPresences.map(p => p.rpc.clearActivity());
loggedInPresences.map(p => p.rpc.clearActivity().catch(destroy));
info("clearActivity");
}
@@ -101,7 +99,7 @@ export function destroy() {
//* Map through loggedInPresences and destroy their rpcs
//* Set loggedInPresences to new Array
//* Return the promise
if (platform() === "darwin") tray.setTitle("");
if (platform() === "darwin" && typeof tray !== "undefined") tray.setTitle("");
let res = Promise.all(
loggedInPresences.map((presence: Presence) =>
presence.rpc.destroy().catch(() => {})
@@ -118,50 +116,3 @@ app.once("will-quit", () => {
info("Closing rpc connections");
destroy();
});
//TODO Try to move this to a type file
interface Presence {
/**
* Client ID of presence
*/
clientId: string;
/**
* Rich Procedual call connection
*/
rpc: Discord.Client;
/**
* Connection ready?
*/
ready: Boolean;
}
interface PresenceData {
/**
* Client ID of presence
*/
clientId: string;
/**
* Tray title to be shown in Mac OS tray
*/
trayTitle: string;
/**
* service name of presence
* @deprecated
*/
service: string;
/**
* Determines if the service is currently playing something back or not, if false it will automatically hide after 1 minute
*/
playback: boolean;
/**
* Discord Presence which gets sent directly to Discord app
*/
presenceData: Discord.Presence;
/**
* Determines if the service should be hidden (clearActivity)
*/
hidden: boolean;
/**
* Determines if the service is mediaKey able / uses them
*/
mediaKeys: boolean;
}

View File

@@ -1,97 +0,0 @@
import { app, globalShortcut } from "electron";
import { socket } from "./socketManager";
import { info, error, success } from "./../util/debug";
let playPauseSwitch = null,
playPauseTimeout = null;
/**
* Register media keyboard shortcuts
*/
export function init() {
//! Disabled for now
return
//* If registered or not enabled return
//* Bind mediaplaypause
//* Bind medianexttrack
//* Bind mediaprevioustrack
//* Debug if bound failed/succeeded
if (
globalShortcut.isRegistered("mediaplaypause") ||
globalShortcut.isRegistered("medianexttrack") ||
globalShortcut.isRegistered("mediaprevioustrack")
)
return;
let mpp = globalShortcut.register("mediaplaypause", () => {
//* Return if not connected
//* if playPause timeout not set set it - 500ms timeout > switch play/pause, nextrack/previoustrack
//* Increase switch each press
//* Show debug
if (!socket.connected) return;
if (!playPauseTimeout)
playPauseTimeout = setTimeout(handlePlayPause, 500);
playPauseSwitch++;
info("Media Play/Pause");
}),
mnt = globalShortcut.register("medianexttrack", () => {
//* send keybind to app if connected
if (socket.connected)
socket.emit("keybinds", {
playback: "nextTrack"
});
info("Media Nextrack");
}),
mpt = globalShortcut.register("mediaprevioustrack", () => {
//* send keybind to app if connected
if (socket.connected)
socket.emit("keybinds", {
playback: "previousTrack"
});
info("Media Previoustrack");
});
if (mpp && mnt && mpt) success("Registered keyboard shortcuts.");
else error("Registering keyboard shortcuts failed.");
}
/**
* Handle Play/Pause media key after 500ms timeout
*/
function handlePlayPause() {
//* Switch case -> emit
//* Reset switch let
//* Reset timeout let
switch (playPauseSwitch) {
case 1:
socket.emit("keybinds", { playback: "pause" });
break;
case 2:
socket.emit("keybinds", { playback: "nextTrack" });
break;
case 3:
socket.emit("keybinds", { playback: "previousTrack" });
break;
}
playPauseSwitch = null;
playPauseTimeout = null;
}
/**
* Unregister all globalShortcuts set by app
*/
export function deinit() {
//* Return if they aren't bound
//* Clear keybinds
//* Show debug
if (
!globalShortcut.isRegistered("mediaplaypause") &&
!globalShortcut.isRegistered("medianexttrack") &&
!globalShortcut.isRegistered("mediaprevioustrack")
)
return;
globalShortcut.unregisterAll();
info("Cleared keybinds");
}
//* If app will quit deinit keybinds
app.once("will-quit", deinit);

View File

@@ -2,9 +2,11 @@ import ElectronStore from "electron-store";
import { tray } from "./trayManager";
import { update as updateAutoLaunch } from "./launchManager";
import { platform } from "os";
import { deinit as deinitInputs } from "./inputManager";
import { info } from "../util/debug";
//* Import custom types
import ExtensionSettings from "../../@types/PreMiD/ExtensionSettings";
//* Export and set default settings
export let settings = new ElectronStore({
defaults: {
@@ -16,44 +18,16 @@ export let settings = new ElectronStore({
* Update settings of app
* @param extensionSettings Settings from extension
*/
export function update(extensionSettings: extensionSettings) {
console.log(extensionSettings);
export function update(extensionSettings: ExtensionSettings) {
//* Show debug
//* remove title if disabled
//* unbind keybinds if disabled
//* Update autolaunch if updated
//* Save Settings
info("Updated settings");
if (!extensionSettings.titleMenubar && platform() === "darwin")
tray.setTitle("");
if (!extensionSettings.mediaKeys) deinitInputs();
if (settings.get("autoLaunch") != extensionSettings.autoLaunch) {
settings.set("autoLaunch", extensionSettings.autoLaunch);
updateAutoLaunch();
}
}
//TODO Try to move types into file
interface extensionSettings {
/**
* If extension is enabled
*/
enabled: boolean;
/**
* Autolaunch enabled
*/
autoLaunch: boolean;
/**
* Media keys enabled
*/
mediaKeys: boolean;
/**
* title menubar (TrayTitle)
*/
titleMenubar: boolean;
/**
* language of extension
*/
language: string;
}

View File

@@ -2,7 +2,6 @@ import socketIo from "socket.io";
import { createServer, Server } from "http";
import { app, dialog } from "electron";
import { success, error } from "../util/debug";
import { deinit as deinitInputs } from "./inputManager";
import { update as updateSettings } from "./settingsManager";
import { openFileDialog } from "./presenceDevManager";
import { setActivity, clearActivity, destroy } from "./discordManager";
@@ -52,10 +51,8 @@ function socketConnection(cSocket: socketIo.Socket) {
socket.once("disconnect", () => {
//* Show debug
//* Destroy all open RPC connections
//* Clear input bindings
error("Socket disconnection.");
destroy();
deinitInputs();
});
}
@@ -75,6 +72,6 @@ function socketError(e: any) {
e.port
}.\nIs ${app.getName()} running already?`
);
app.exit(0);
app.quit();
}
}

View File

@@ -1,4 +1,4 @@
import { spawn } from "child_process";
import { spawn, exec } from "child_process";
import { resolve } from "path";
import { error, info } from "./debug";
import { trayContextMenu } from "../managers/trayManager";
@@ -12,11 +12,15 @@ import sudoPrompt from "sudo-prompt";
let updaterPath: string;
export async function checkForUpdate(autoUpdate = false) {
if (!app.isPackaged) {
//* Skip Update checker if unsupported OS / not packaged
if (!app.isPackaged || !["darwin", "win32"].includes(platform())) {
//* Show debug
//* return
info("Skipping UpdateChecker");
return;
}
//* Resolve paths for each OS
switch (platform()) {
case "darwin":
updaterPath = resolve(
@@ -28,22 +32,17 @@ export async function checkForUpdate(autoUpdate = false) {
break;
}
// TODO remove?
//* return if update doesn't exist
if (!existsSync(updaterPath)) {
error("Updater not found.");
clearInterval(updateCheckerInterval);
return;
}
//* Spawn update checker
let child = spawn(updaterPath, ["--mode", "unattended"]);
child.on("error", err => {
// @ts-ignore
if (err.code === "ENOENT") {
error("Updater file not found. Skipping updater functions.");
clearInterval(updateCheckerInterval);
return;
}
});
child.on("exit", code => {
//* If no update or error return
if (code === 1) {
@@ -84,13 +83,26 @@ export async function checkForUpdate(autoUpdate = false) {
}
export function update() {
if (platform() === "darwin") {
exec(
`\"${updaterPath}\" --mode unattended --unattendedmodebehavior download`,
() => {
dialog.showErrorBox(
"Error while updating",
`${app.getName()} was unable to update itself. Please try again later.`
);
}
);
return;
}
sudoPrompt.exec(
`\"${updaterPath}\" --mode unattended --unattendedmodebehavior download`,
{
name: app.getName()
},
(error: Error) => {
dialog.showMessageBox({ message: error.message });
dialog.showErrorBox(
"Error while updating",
`${app.getName()} was unable to update itself. Please try again later.`
);
if (error) {
checkForUpdate();
return;

View File

@@ -3,12 +3,12 @@
"module": "commonjs",
"target": "es2018",
"sourceMap": true,
"baseUrl": ".",
"outDir": "dist/app",
"removeComments": true,
"esModuleInterop": true
"esModuleInterop": true,
"typeRoots": ["@types/*"]
},
"include": ["src/**/*"],
"include": ["@types/*", "src/**/*"],
"exclude": [
"devMode.ts",
"pkg.ts",