Add test/local environment configurations and fix #147

This commit is contained in:
Max Myers
2021-10-19 14:26:19 -04:00
parent c6d1f69fd4
commit cfcf2f0890
15 changed files with 203 additions and 16 deletions
+69
View File
@@ -49,6 +49,57 @@
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
},
"test": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
},
"test2": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.test2.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
},
"local": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.local.ts"
}
],
"optimization": false,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false
}
}
},
@@ -60,6 +111,15 @@
"configurations": {
"production": {
"browserTarget": "desktop-app:build:production"
},
"test": {
"browserTarget": "desktop-app:build:test"
},
"test2": {
"browserTarget": "desktop-app:build:test2"
},
"local": {
"browserTarget": "desktop-app:build:local"
}
}
},
@@ -113,6 +173,15 @@
"configurations": {
"production": {
"devServerTarget": "desktop-app:serve:production"
},
"test": {
"devServerTarget": "desktop-app:serve:test"
},
"test2": {
"devServerTarget": "desktop-app:serve:test2"
},
"local": {
"devServerTarget": "desktop-app:serve:local"
}
}
},
+7 -1
View File
@@ -4,10 +4,16 @@
"scripts": {
"ng": "ng",
"start": "ng serve",
"start:test": "ng serve -c test",
"start:test2": "ng serve -c test2",
"start:local": "ng serve -c local",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
"e2e": "ng e2e",
"e2e:test": "ng e2e -c test",
"e2e:local": "ng e2e -c test2",
"e2e:test2": "ng e2e -c local"
},
"private": true,
"dependencies": {
+2 -2
View File
@@ -5,7 +5,7 @@
<app-loading-spinner #spinner></app-loading-spinner>
<app-status-bar #status (getHelp)="getHelpModal.openModal(); helpStatus = $event; setExterHelp()"></app-status-bar>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" src="https://sidequestvr.com" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" ></webview>
<webview id="mainWebView" #webview httpreferrer="https://sdiequestvr.com" [attr.src]="webUrl" allowpopups [ngStyle]="{'left':webService.isWebviewOpen?'0':'-100%'}" class="bsaber-webview" ></webview>
<mz-modal #getHelpModal [fixedFooter]="true">
<mz-modal-header>
@@ -21,7 +21,7 @@
<br><br>
<div class="center-align">
<div class="btn pink-button waves-effect waves-light" (click)="statusService.copyStatus();statusService.showStatus('Copied to your clipboard!')">Copy To Clipboard</div><br><br>
<div class="btn btn-flat waves-effect waves-dark" (click)="appService.opn('https://sdq.st/support')">Open Service Desk</div><br><br>
<div class="btn btn-flat waves-effect waves-dark" (click)="appService.opn((shortenerUrl||'https://sdq.st')+'/support')">Open Service Desk</div><br><br>
</div>
</mz-modal-content>
<mz-modal-footer>
+4
View File
@@ -6,6 +6,8 @@ import { WebviewService } from './webview.service';
import { DragAndDropService } from './drag-and-drop.service';
import { ElectronService } from './electron.service';
import { AdbClientService } from './adb-client.service';
import { environment } from '../environments/environment';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
@@ -18,6 +20,8 @@ export class AppComponent implements OnInit, AfterViewInit {
helpStatus: string;
extraHelpStatus: string;
devMode: boolean;
webUrl = environment.configuration.web_url;
shortenerUrl = environment.configuration.shortenerUrl;
constructor(
private spinnerService: LoadingSpinnerService,
public statusService: StatusBarService,
@@ -79,7 +79,7 @@
</div>
<div class="user-menu browser-menu" #browserMenu>
<div class="btn-flat waves-light waves-light full-width center-align white-text truncate"
(click)="browserMenu.style.display = 'none';browserMenuBack.style.display = 'none';webService.loadUrl('https://sidequestvr.com')"
(click)="browserMenu.style.display = 'none';browserMenuBack.style.display = 'none';webService.loadUrl(webUrl || 'https://sidequestvr.com')"
routerLink="/webview"><i class="material-icons left">home</i>Home</div><br>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
@@ -99,7 +99,7 @@
</div>
<div class="user-menu" #userMenu>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
(click)="userMenu.style.display = 'none';userMenuBack.style.display = 'none';webService.loadUrl('https://sidequestvr.com')"
(click)="userMenu.style.display = 'none';userMenuBack.style.display = 'none';webService.loadUrl(webUrl || 'https://sidequestvr.com')"
routerLink="/webview"><i class="material-icons left">home</i>Home</div><br>
<div class="btn-flat waves-light waves-light full-width center-align white-text"
*ngIf="isConnected()&&osPlatform === 'win32'"
@@ -140,7 +140,7 @@
(click)="userMenu.style.display = 'block';userMenuBack.style.display = 'block'">
arrow_drop_down
</i>
<i mz-tooltip routerLink="/webview" (click)="webService.back()"
<i mz-tooltip routerLink="/webview" (click)="doBack()"
class="material-icons white-text no-outline" position="bottom" tooltip="Back">
arrow_back
</i>
@@ -312,7 +312,7 @@
</mz-modal-content>
<mz-modal-footer>
<button mz-button [flat]="true" mz-modal-close routerLink="/webview" (click)="webService.loadUrl('https://sidequestvr.com');" >SideQuest Home</button>
<button mz-button [flat]="true" mz-modal-close routerLink="/webview" (click)="webService.loadUrl(webUrl || 'https://sidequestvr.com');" >SideQuest Home</button>
<button mz-button [flat]="true" mz-modal-close>Close</button>
</mz-modal-footer>
</mz-modal>
+19 -2
View File
@@ -10,6 +10,8 @@ import { DragAndDropService } from '../drag-and-drop.service';
import { Router } from '@angular/router';
import { ProcessBucketService } from '../process-bucket.service';
import { Subscription } from 'rxjs/Subscription';
import { environment } from '../../environments/environment';
interface ReplaceText {
key: string;
value: string;
@@ -45,6 +47,7 @@ export class HeaderComponent implements OnInit {
adbCommandToRun: string;
osPlatform: string;
saveLogcatPath: string;
webUrl = environment.configuration.web_url;
favourites: {
browserFavourites: FavouriteItem[];
fileFavourites: FavouriteItem[];
@@ -98,7 +101,8 @@ export class HeaderComponent implements OnInit {
public statusService: StatusBarService,
public beatonService: BeatOnService,
public dragAndDropService: DragAndDropService,
public processService: ProcessBucketService
public processService: ProcessBucketService,
private router: Router
) {
this.osPlatform = this.appService.os.platform();
console.log('Platform: ' + this.osPlatform);
@@ -107,6 +111,19 @@ export class HeaderComponent implements OnInit {
this.resetFavourites('commandFavourites');
this.appService.headerComponent = this;
}
doBack() {
if (
this.appService.isTasksOpen ||
this.appService.isFilesOpen ||
this.appService.isPackagesOpen ||
this.appService.isSettingsOpen
) {
this.router.navigateByUrl('/webview');
return;
} else {
this.webService.back();
}
}
resetFavourites(type: string) {
let defaultFavs;
switch (type) {
@@ -182,7 +199,7 @@ export class HeaderComponent implements OnInit {
}
updateAvailable() {
this.appService.opn('https://sidequestvr.com/download');
this.appService.opn(`${environment.configuration.web_url || 'https://sidequestvr.com'}/download`);
}
startLogcat() {
+2 -1
View File
@@ -1,5 +1,6 @@
import { Injectable, isDevMode } from '@angular/core';
import { AppService } from './app.service';
import { environment } from '../environments/environment';
@Injectable({
providedIn: 'root',
@@ -7,7 +8,7 @@ import { AppService } from './app.service';
export class WebviewService {
webView: any;
isWebviewOpen: boolean;
currentAddress: string = 'https://sidequestvr.com';
currentAddress: string = environment.configuration.web_url || 'https://sidequestvr.com';
isWebviewLoading: boolean = false;
isLoaded = () => {};
constructor(private appService: AppService) {
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
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',
},
};
@@ -1,4 +1,10 @@
export const environment = {
production: true,
safeSideApiUrl: 'https://sdq.st',
configuration: {
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',
},
};
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
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',
},
};
@@ -0,0 +1,10 @@
export const environment = {
production: false,
configuration: {
web_url: 'https://test.side.quest',
ws_url: 'wss://testws.side.quest',
http_url: 'https://api.sidequestvr.com',
cdnUrl: 'https://cdn.sidequestvr.com',
shortenerUrl: 'https://sdq.st',
},
};
+7 -1
View File
@@ -4,7 +4,13 @@
export const environment = {
production: false,
safeSideApiUrl: 'https://sdq.st',
configuration: {
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',
},
};
/*
+6 -4
View File
@@ -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 },
+36
View File
@@ -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',
};
}
}
+10
View File
@@ -10,10 +10,20 @@
"scripts": {
"concurrently": "concurrently",
"start": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"",
"start:test": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .\" \"cd desktop-app && ng serve -c test --port 4205\"",
"start:test2": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=test2 electron .\" \"cd desktop-app && ng serve -c test2 --port 4205\"",
"start:local": "concurrently \"yarn electron-build && yarn platform-tools && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev SQ_ENV_CFG=local electron .\" \"cd desktop-app && ng serve -c local --port 4205\"",
"postinstall": "electron-builder install-app-deps && cd desktop-app && yarn install",
"dist": "yarn electron-build && yarn platform-tools && yarn app-build && electron-builder",
"angular": "cd desktop-app && ng serve --port 4205",
"angular:test": "cd desktop-app && ng serve -c test --port 4205",
"angular:test2": "cd desktop-app && ng serve -c test2 --port 4205",
"angular:local": "cd desktop-app && ng serve -c local --port 4205",
"electron-dev": "yarn platform-tools && cross-env NODE_ENV=dev electron .",
"electron-dev:test": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=test electron .",
"electron-dev:test2": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=test2 electron .",
"electron-dev:local": "yarn platform-tools && cross-env NODE_ENV=dev SQ_ENV_CFG=local electron .",
"electron": "yarn electron-build && yarn electron-dev",
"app-build": "cd desktop-app && ng build --prod --aot && cd ..",
"platform-tools": "node build-electron/platform-tools.js",