pull/98/merge
Delta-official 2 years ago committed by GitHub
commit 20615740f7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,91 +0,0 @@
{
"editor.tabSize": 2,
"editor.wordWrap": "on",
"todo-tree.regex.regex" : "((//|#|<!--|;|\\*)\\s*($TAGS)|^\\s*- \\[ \\])",
"todo-tree.general.tags": [
"@bug",
"@deprecated",
"@docs",
"@experimental",
"@i18n",
"@note",
"@test",
"@todo",
"@warning"
],
"todo-tree.highlights.defaultHighlight": {
"gutterIcon": true
},
"todo-tree.highlights.customHighlight": {
"@bug": {
"icon": "bug",
"foreground": "#e87000",
"background": "#e87000",
"opacity": 0
},
"@deprecated": {
"icon": "hubot",
"foreground": "#dad24e",
"background": "#dad24e",
"opacity": 0
},
"@docs": {
"icon": "book",
"foreground": "#00d5ff",
"background": "#00d5ff",
"opacity": 0
},
"@experimental": {
"icon": "beaker",
"foreground": "#456aff",
"background": "#456aff",
"opacity": 0
},
"@i18n": {
"icon": "globe",
"foreground": "#46d6af",
"background": "#46d6af",
"opacity": 0
},
"@note": {
"icon": "pencil",
"foreground": "#7842ff",
"background": "#7842ff",
"opacity": 0
},
"@test": {
"icon": "gear",
"foreground": "#ec0ddf",
"background": "#ec0ddf",
"opacity": 0
},
"@todo": {
"icon": "checklist",
"foreground": "#34eb52",
"background": "#34eb52",
"opacity": 0
},
"@warning": {
"icon": "alert",
"foreground": "#da4e4e",
"background": "#da4e4e",
"opacity": 0
}
},
"eslint.codeActionsOnSave.mode": "problems",
"debug.showBreakpointsInOverviewRuler": true,
"editor.rulers": [
{
"column": 90,
"color": "#ffffff08"
}
],
"search.exclude": {
"**/.cache": true,
"**/node_modules": true,
"**/package-lock.json": true
},
"eslint.format.enable": true,
"eslint.lintTask.enable": true,
"eslint.alwaysShowStatus": true
}

File diff suppressed because one or more lines are too long

3
package-lock.json generated

@ -48,7 +48,8 @@
"remark-gfm": "^1.0.0",
"sass": "^1.42.1",
"sucrase": "^3.20.1",
"tinycolor2": "^1.4.2"
"tinycolor2": "^1.4.2",
"which": "^2.0.2"
},
"devDependencies": {
"chalk": "4.1.2",

@ -96,7 +96,8 @@
"remark-gfm": "^1.0.0",
"sass": "^1.42.1",
"sucrase": "^3.20.1",
"tinycolor2": "^1.4.2"
"tinycolor2": "^1.4.2",
"which": "^2.0.2"
},
"devDependencies": {
"chalk": "4.1.2",

@ -1,12 +1,10 @@
/* eslint-disable no-undef */
const { existsSync, promises: { writeFile, mkdir, access, readdir, rm } } = require('fs');
const { exec: _exec, spawn } = require('child_process');
const { join, posix, sep } = require('path');
const { existsSync, promises: { writeFile, mkdir, access, readdir, rm, realpath } } = require('fs');
const { spawn } = require('child_process');
const { join, posix, sep, dirname } = require('path');
const { prompt } = require('inquirer');
const { promisify } = require('util');
const chalk = require('chalk');
const exec = promisify(_exec);
const which = require("which");
let release;
@ -127,7 +125,11 @@ async function promptManualPathCompletion (action) {
} else if (process.platform === 'darwin') {
discordAppPath = join(discordPath, 'Contents', 'Resources', 'app');
} else {
discordAppPath = join(discordPath, 'resources', 'app');
discordAppPath = dirname(await realpath(await which(release)));
if (!existsSync(join(discordAppPath, 'app'))) {
mkdir(join(discordAppPath, 'app'));
}
}
if (!discordAppPath || !(await confirmExistAndHasPermissions(discordAppPath))) {
@ -166,7 +168,7 @@ async function getDiscordAppPath () {
if (process.platform === 'win32') {
const discordPath = join(process.env.LOCALAPPDATA, release?.replace(' ', ''));
if (!discordPath || !(await confirmExistAndHasPermissions(discordPath))) {
info(`Unfortunately, the ${release} directory couldn't be located.`);
error(`Unfortunately, the ${release} directory couldn't be located or you don't have enough permissions to access it.`);
return promptManualPathCompletion('inject');
}
@ -187,51 +189,29 @@ async function getDiscordAppPath () {
const discordPath = join('/Applications', `${release}.app`);
if (!discordPath || !(await confirmExistAndHasPermissions(discordPath))) {
error(`Unfortunately, the ${release} directory couldn't be located.`);
error(`Unfortunately, the ${release} directory couldn't be located or you don't have enough permissions to access it.`);
return promptManualPathCompletion('inject');
}
return join(discordPath, 'Contents', 'Resources', 'app');
}
/**
* If all else fails, assume the user is on Linux and try to find the Discord process.
*/
const discordProcess = (await exec('ps x')).toString().split('\n').map(s => s.split(' ').filter(Boolean)).find(process => process[4] && (/discord$/i).test(process[4]) && process.includes('--type=renderer'));
/**
* If the process can't be found, try to determine the directory path by checking if any
* predefined path directories exist.
*/
if (!discordProcess) {
warn('Cannot find Discord process, falling back to legacy path detection...');
/**
* Instead of using ~, use this to determine the user's home directory instead of the root's home directory.
* Unix-like systems
*/
const homeDirectory = (await exec('grep $(logname) /etc/passwd | cut -d ":" -f6').toString()).trim();
const paths = [
`/usr/share/${release.toLowerCase().replace(' ', '-')}`,
`/usr/lib64/${release.toLowerCase().replace(' ', '-')}`,
`/opt/${release.toLowerCase().replace(' ', '-')}`,
`/opt/${release.replace(' ', '')}`,
`${homeDirectory}/.local/bin/${release.replace(' ', '')}/`
];
const discordPath = paths.find(async path => !(await confirmExistAndHasPermissions(path)));
// eslint-disable-next-line no-else-return
} else {
const discordPath = dirname(await realpath(await which(release)));
if (!discordPath || !(await confirmExistAndHasPermissions(discordPath))) {
error(`Unfortunately, the ${release} directory couldn't be located.`);
error(`Unfortunately, the ${release} directory couldn't be located or you don't have enough permissions to access it.`);
return promptManualPathCompletion('inject');
}
return join(discordPath, 'resources', 'app');
}
if (!existsSync(join(discordPath, 'app'))) {
mkdir(join(discordPath, 'app'));
}
const discordPath = discordProcess[4].split('/');
discordPath.splice(discordPath.length - 1, 1);
return join('/', ...discordPath, 'resources', 'app');
return join(discordPath, 'app');
}
}
/**
@ -242,7 +222,7 @@ async function getDiscordAppPath () {
function installDependencies () {
return new Promise((resolve, reject) => {
const command = spawn('npm', [ 'install', '--only=production', '--silent' ], {
cwd: join(__dirname, '..', '..', '..'),
cwd: join(__dirname, '..'),
stdio: 'inherit',
shell: true
});
@ -303,7 +283,7 @@ async function ensureDependencies () {
return info('Dependencies are up-to-date!');
} catch (err) {
error(`An error occured while installing the dependencies:\n${err.message}`);
return process.exit(0);
return process.exit(70);
}
}
@ -368,7 +348,9 @@ async function inject (discordAppPath) {
}
await ensureDependencies();
await mkdir(discordAppPath);
if (confirmExistAndHasPermissions(discordAppPath)) {
await mkdir(discordAppPath);
}
Promise.all([
/**
* Relative to dist/setup.bundle.js
@ -423,13 +405,20 @@ async function startInjectionProcess () {
'*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*\n'
);
if (process.platform !== 'win32' || process.platform !== 'darwin') {
if (process.getuid() !== 0) {
error(`Vizality installer must be run as root on unix-like systems\nPlease rerun the installer with this command: ${chalk.reset()}node setup:sudo`);
process.exit(73);
}
}
/**
* Not sure why someone would clone into System32... but let's not let them proceed to avoid any issues.
*/
if (process.platform === 'win32') {
if (__dirname.toLowerCase().split(sep).join(posix.sep).includes('/windows/system32')) {
error('It seems Vizality is installed in your System 32 directory. This can create issues and bloat your Windows installation. Please move your Vizality installation to a different directory.');
return process.exit(0);
return process.exit(75);
}
}
@ -439,7 +428,7 @@ async function startInjectionProcess () {
const NODE_MAJOR_VERSION = process.versions.node.split('.')[0];
if (NODE_MAJOR_VERSION < 14) {
error(`It looks like you're on an outdated version of Node.js. Vizality requires you to run at least Node v14 or later. You can download a newer version here: https://nodejs.org`);
return process.exit(0);
return process.exit(69);
}
/**
@ -504,13 +493,25 @@ async function startInjectionProcess () {
*/
switch (true) {
case release.includes('Stable'):
release = 'Discord';
if (process.platform === 'win32' || process.platform === 'darwin') {
release = 'Discord';
} else {
release = 'discord';
}
break;
case release.includes('PTB'):
release = 'Discord PTB';
if (process.platform === 'win32' || process.platform === 'darwin') {
release = 'Discord PTB';
} else {
release = 'discord-ptb';
}
break;
case release.includes('Canary'):
release = 'Discord Canary';
if (process.platform === 'win32' || process.platform === 'darwin') {
release = 'Discord Canary';
} else {
release = 'discord-canary';
}
break;
}
switch (true) {

Loading…
Cancel
Save