Remote tests
This commit is contained in:
parent
ea0dc0c6f1
commit
4f10f38581
|
@ -147,7 +147,7 @@ export default class ServerEmu {
|
|||
activeUsers: Math.floor(Math.random() * 1000) + 1000,
|
||||
rated: Math.random() > .5,
|
||||
version: this.randomVersion(),
|
||||
repository: this.dummyRepo,
|
||||
repository: this.dummyThemeRepo,
|
||||
files: this.dummyFiles,
|
||||
author: this.dummyAuthor,
|
||||
description: ''
|
||||
|
@ -176,7 +176,7 @@ export default class ServerEmu {
|
|||
activeUsers: Math.floor(Math.random() * 1000) + 1000,
|
||||
rated: Math.random() > .5,
|
||||
version: this.randomVersion(),
|
||||
repository: this.dummyRepo,
|
||||
repository: this.dummyPluginRepo,
|
||||
files: this.dummyFiles,
|
||||
author: this.dummyAuthor,
|
||||
description: ''
|
||||
|
@ -186,11 +186,21 @@ export default class ServerEmu {
|
|||
return docs;
|
||||
}
|
||||
|
||||
static get dummyRepo() {
|
||||
static get dummyThemeRepo() {
|
||||
return {
|
||||
name: 'ExampleRepository',
|
||||
baseUri: 'https://github.com/Jiiks/ExampleRepository',
|
||||
rawUri: 'https://github.com/Jiiks/ExampleRepository/raw/master'
|
||||
rawUri: 'https://github.com/Jiiks/ExampleRepository/raw/master',
|
||||
assetUri: 'https://api.github.com/repos/Jiiks/ExampleRepository/releases/assets/10023264'
|
||||
}
|
||||
}
|
||||
|
||||
static get dummyPluginRepo() {
|
||||
return {
|
||||
name: 'ExampleRepository',
|
||||
baseUri: 'https://github.com/Jiiks/ExampleRepository',
|
||||
rawUri: 'https://github.com/Jiiks/ExampleRepository/raw/master',
|
||||
assetUri: 'https://api.github.com/repos/Jiiks/ExampleRepository/releases/assets/10023265'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
import { DOM, BdUI, BdMenu, Modals, Toasts, Notifications, BdContextMenu, DiscordContextMenu } from 'ui';
|
||||
import BdCss from './styles/index.scss';
|
||||
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity, Cache, Reflection } from 'modules';
|
||||
import { Events, CssEditor, Globals, Settings, Database, Updater, ModuleManager, PluginManager, ThemeManager, ExtModuleManager, Vendor, Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi, BdWebApi, Connectivity, Cache, Reflection, PackageInstaller } from 'modules';
|
||||
import { ClientLogger as Logger, ClientIPC, Utils } from 'common';
|
||||
import { BuiltinManager, EmoteModule, ReactDevtoolsModule, VueDevtoolsModule, TrackingProtection, E2EE } from 'builtin';
|
||||
import electron from 'electron';
|
||||
|
@ -31,7 +31,7 @@ class BetterDiscord {
|
|||
DOM, BdUI, BdMenu, Modals, Reflection, Toasts, Notifications, BdContextMenu, DiscordContextMenu,
|
||||
|
||||
Events, CssEditor, Globals, Settings, Database, Updater,
|
||||
ModuleManager, PluginManager, ThemeManager, ExtModuleManager,
|
||||
ModuleManager, PluginManager, ThemeManager, ExtModuleManager, PackageInstaller,
|
||||
Vendor,
|
||||
|
||||
Patcher, MonkeyPatch, ReactComponents, ReactHelpers, ReactAutoPatcher, DiscordApi,
|
||||
|
|
|
@ -103,7 +103,7 @@ export default class PackageInstaller {
|
|||
}
|
||||
|
||||
/**
|
||||
* Install package from remote location. Only github/bdapi is supoorted.
|
||||
* Install package from remote location. Only github/bdapi is supported.
|
||||
* @param {String} remoteLocation Remote resource location
|
||||
*/
|
||||
static async installRemotePackage(remoteLocation) {
|
||||
|
@ -113,6 +113,7 @@ export default class PackageInstaller {
|
|||
|
||||
const options = {
|
||||
uri: remoteLocation,
|
||||
encoding: null,
|
||||
headers: {
|
||||
'User-Agent': 'BetterDiscordClient',
|
||||
'Accept': 'application/octet-stream'
|
||||
|
@ -122,9 +123,10 @@ export default class PackageInstaller {
|
|||
const response = await request.get(options);
|
||||
const outputPath = path.join(Globals.getPath('tmp'), Security.hash('sha256', response, 'hex'));
|
||||
fs.writeFileSync(outputPath, response);
|
||||
console.log('response', response);
|
||||
console.log('output', outputPath);
|
||||
|
||||
await this.dragAndDropHandler(outputPath);
|
||||
|
||||
rimraf(outputPath, err => {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="bd-buttonGroup">
|
||||
<div class="bd-button">Install</div>
|
||||
<div class="bd-button" @click="install">Install</div>
|
||||
<div class="bd-button">Preview</div>
|
||||
<div class="bd-button" @click="openSourceUrl">Source</div>
|
||||
</div>
|
||||
|
@ -40,7 +40,7 @@
|
|||
</template>
|
||||
|
||||
<script>
|
||||
import { Reflection } from 'modules';
|
||||
import { Reflection, PackageInstaller } from 'modules';
|
||||
import { shell } from 'electron';
|
||||
|
||||
export default {
|
||||
|
@ -62,6 +62,9 @@
|
|||
if (!this.item.repository || !this.item.repository.baseUri) return;
|
||||
if (Object.assign(document.createElement('a'), { href: this.item.repository.baseUri }).hostname !== 'github.com') return;
|
||||
shell.openExternal(this.item.repository.baseUri);
|
||||
},
|
||||
async install() {
|
||||
await PackageInstaller.installRemotePackage(this.item.repository.assetUri);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue