diff --git a/.github/workflows/master.yml b/.github/workflows/master.yml index d2b2b36..e002687 100644 --- a/.github/workflows/master.yml +++ b/.github/workflows/master.yml @@ -7,10 +7,12 @@ jobs: matrix: os: [ubuntu-latest, windows-latest, macOS-latest] steps: - - uses: actions/checkout@v1 + - uses: actions/checkout@v2 with: fetch-depth: 1 - - uses: actions/setup-node@v1 + - uses: actions/setup-node@v2 + with: + node-version: '14' - name: "Install dependencies" run: yarn - name: "Build application" diff --git a/desktop-app/angular.json b/desktop-app/angular.json index 351ab23..acaf4cc 100644 --- a/desktop-app/angular.json +++ b/desktop-app/angular.json @@ -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" } } }, diff --git a/desktop-app/package.json b/desktop-app/package.json index d2ab95b..6e2e2fd 100644 --- a/desktop-app/package.json +++ b/desktop-app/package.json @@ -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": { diff --git a/desktop-app/src/app/adb-client.service.ts b/desktop-app/src/app/adb-client.service.ts index 8e4dbe2..0110be2 100644 --- a/desktop-app/src/app/adb-client.service.ts +++ b/desktop-app/src/app/adb-client.service.ts @@ -372,18 +372,27 @@ This can sometimes be caused by changes to your hosts file. Don't make changes u }); } isAdbDownloaded() { - let downloaded = true; - if (!this.doesFileExist(this.adbPath)) { + try { + let downloaded = true; + if (!this.doesFileExist(this.adbPath)) { + return false; + } + + let source_files = this.appService.fs.readdirSync(this.appService.getPlatformToolsSeedPath()); + if (source_files === null) { + return false; + } + let dest_files = this.appService.fs.readdirSync(this.adbPath); + source_files.forEach(d => { + if (dest_files.indexOf(d) === -1) { + downloaded = false; + } + }); + return downloaded; // this.doesFileExist(this.appService.path.join(this.adbPath, this.getAdbBinary())); + } catch (e) { + console.error('Error checking for ADB being installed', e); return false; } - let source_files = this.appService.fs.readdirSync(this.appService.path.join(process.cwd(), 'build', 'platform-tools')); - let dest_files = this.appService.fs.readdirSync(this.adbPath); - source_files.forEach(d => { - if (dest_files.indexOf(d) === -1) { - downloaded = false; - } - }); - return downloaded; // this.doesFileExist(this.appService.path.join(this.adbPath, this.getAdbBinary())); } setPermission(packageName: string, permission: string, isRevoke?: boolean) { return this.adbCommand('shell', { diff --git a/desktop-app/src/app/app.component.html b/desktop-app/src/app/app.component.html index fc1899e..2886e7b 100644 --- a/desktop-app/src/app/app.component.html +++ b/desktop-app/src/app/app.component.html @@ -5,7 +5,7 @@ - + @@ -21,7 +21,7 @@

Copy To Clipboard


-
Open Service Desk


+
Open Service Desk


diff --git a/desktop-app/src/app/app.component.ts b/desktop-app/src/app/app.component.ts index 87ab539..4eb8093 100644 --- a/desktop-app/src/app/app.component.ts +++ b/desktop-app/src/app/app.component.ts @@ -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, diff --git a/desktop-app/src/app/app.service.ts b/desktop-app/src/app/app.service.ts index c7f2082..87d99f2 100644 --- a/desktop-app/src/app/app.service.ts +++ b/desktop-app/src/app/app.service.ts @@ -74,8 +74,8 @@ export class AppService { this.semver = (window).require('semver'); this.crypto = (window).require('crypto'); this.electron = (window).require('electron'); - this.remote = this.electron.remote; - this.nativeApp = this.electron.remote.app; + this.remote = (window).require('@electron/remote'); + this.nativeApp = this.remote.app; this.appData = this.path.join(this.nativeApp.getPath('appData'), 'SideQuest'); this.exec = (window).require('child_process').exec; this.execSync = (window).require('child_process').execSync; @@ -225,11 +225,36 @@ export class AppService { break; } } + + private foundSeedToolsPath: string | null = null; + getPlatformToolsSeedPath() { + if (this.foundSeedToolsPath !== null) { + return this.foundSeedToolsPath; + } + let ogSourcesPath = this.path.join(process.resourcesPath, 'build', 'platform-tools'); + let sourcesPath = ogSourcesPath; + if (!this.doesFileExist(sourcesPath)) { + sourcesPath = sourcesPath.replace('app.asar', 'app.asar.unpacked'); + } + if (!this.doesFileExist(sourcesPath)) { + sourcesPath = this.path.join(process.resourcesPath, 'app.asar.unpacked', 'build', 'platform-tools'); + } + if (!this.doesFileExist(sourcesPath)) { + sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools'); + } + if (!this.doesFileExist(sourcesPath)) { + return null; + } + this.foundSeedToolsPath = sourcesPath; + return sourcesPath; + } seedPlatformTools() { - return new Promise(async resolve => { - let sourcesPath = this.path.join(__dirname, '..', 'platform-tools'); - if (!this.fs.existsSync(sourcesPath)) { - sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools'); + return new Promise(async resolve => { + let sourcesPath = this.getPlatformToolsSeedPath(); + if (sourcesPath == null) { + console.error('Unable to locate platform tools! Try reinstalling sidequest.'); + resolve(); + return; } await this.mkdir(this.path.join(this.appData, 'platform-tools')); try { @@ -247,7 +272,10 @@ export class AppService { } else { setTimeout(() => resolve(), 5000); } - } catch (e) {} + } catch (e) { + console.error('Error seeding platform tools! ', e); + resolve(); + } }); } makeFolders() { @@ -262,7 +290,7 @@ export class AppService { }); } setExecutable(path) { - return new Promise(resolve => { + return new Promise(resolve => { const ls = this.spawn('chmod', ['+x', path]); ls.stdout.on('data', res => { console.log(res); diff --git a/desktop-app/src/app/files/files.component.html b/desktop-app/src/app/files/files.component.html index 5a0a5b1..13825aa 100644 --- a/desktop-app/src/app/files/files.component.html +++ b/desktop-app/src/app/files/files.component.html @@ -1,6 +1,6 @@
-