Add test/local environment configurations and fix #147
This commit is contained in:
+6
-4
@@ -1,6 +1,8 @@
|
||||
import { app, protocol, ipcMain, Menu, MenuItemConstructorOptions, BrowserWindow, shell } from 'electron';
|
||||
import { StateStorage, EnvironmentConfig } from './state-storage';
|
||||
import { AppWindow } from './window';
|
||||
import { getEnvCfg } from './env-config';
|
||||
|
||||
const path = require('path');
|
||||
const { autoUpdater } = require('electron-updater');
|
||||
const download = require('./download');
|
||||
@@ -32,7 +34,7 @@ class ADB {
|
||||
}
|
||||
async checkAPK(updateStatus: (string) => void, filePath: string): Promise<boolean> {
|
||||
const hash = await this.computeFileHash(updateStatus, filePath);
|
||||
const url = `https://sdq.st/check-app-hash/${hash}`;
|
||||
const url = `${getEnvCfg().shortenerUrl || 'https://sdq.st'}/check-app-hash/${hash}`;
|
||||
updateStatus('Checking APK against blacklist...');
|
||||
return new Promise((resolve, reject) => {
|
||||
let options = {
|
||||
@@ -41,7 +43,7 @@ class ADB {
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Origin: 'https://sidequestvr.com',
|
||||
Origin: getEnvCfg().web_url,
|
||||
},
|
||||
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
|
||||
};
|
||||
@@ -102,12 +104,12 @@ class ADB {
|
||||
}
|
||||
installFromToken(token, cb, ecb) {
|
||||
let options = {
|
||||
url: 'https://api.sidequestvr.com/install-from-key',
|
||||
url: `${getEnvCfg().http_url || 'https://api.sidequestvr.com'}/install-from-key`,
|
||||
method: 'POST',
|
||||
headers: {
|
||||
Accept: 'application/json',
|
||||
'Content-Type': 'application/json',
|
||||
Origin: 'https://sidequestvr.com',
|
||||
Origin: getEnvCfg().web_url || 'https://sidequestvr.com',
|
||||
},
|
||||
rejectUnauthorized: process.env.NODE_ENV !== 'dev',
|
||||
json: { token: token },
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
export function getEnvCfg() {
|
||||
switch (process.env['SQ_ENV_CFG']) {
|
||||
case 'test':
|
||||
return {
|
||||
web_url: 'https://sidetestvr.com',
|
||||
ws_url: 'wss://ws.sidetestvr.com',
|
||||
http_url: 'https://api.sidetestvr.com',
|
||||
cdnUrl: 'https://cdn.sidetestvr.com',
|
||||
shortenerUrl: 'https://links.sidetestvr.com',
|
||||
};
|
||||
case 'test2':
|
||||
return {
|
||||
web_url: 'https://test.side.quest',
|
||||
ws_url: 'wss://testws.side.quest',
|
||||
http_url: 'https://testapi.side.quest',
|
||||
cdnUrl: 'https://testcdn.sidequestvr.com',
|
||||
shortenerUrl: 'https://testlinks.side.quest',
|
||||
};
|
||||
case 'local':
|
||||
return {
|
||||
web_url: 'https://sidequestvr.local',
|
||||
ws_url: 'wss://ws.sidetestvr.local',
|
||||
http_url: 'https://api.sidetestvr.local',
|
||||
cdnUrl: 'https://cdn.sidetestvr.local',
|
||||
shortenerUrl: 'https://links.sidetestvr.local',
|
||||
};
|
||||
default:
|
||||
return {
|
||||
web_url: 'https://sidequestvr.com',
|
||||
ws_url: 'wss://ws.sidequestvr.com',
|
||||
http_url: 'https://api.sidequestvr.com',
|
||||
cdnUrl: 'https://cdn.sidequestvr.com',
|
||||
shortenerUrl: 'https://sdq.st',
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user