added platform tools download to build as well as generating compiled code
This commit is contained in:
+1
-2
@@ -33,11 +33,10 @@ jspm_packages/
|
||||
.env.test
|
||||
|
||||
build/app
|
||||
build/platform-tools
|
||||
build-electron
|
||||
!build-electron/*.jsc
|
||||
.idea
|
||||
.vscode
|
||||
platform-tools
|
||||
dist
|
||||
/app
|
||||
desktop-app/sources/*.json
|
||||
|
||||
Binary file not shown.
@@ -347,7 +347,7 @@ export class AdbClientService {
|
||||
}
|
||||
async setupAdb() {
|
||||
if (!this.isAdbDownloaded()) {
|
||||
await this.downloadTools();
|
||||
this.appService.seedPlatformTools();
|
||||
}
|
||||
this.appService.electron.ipcRenderer.on('adb-command', (event, arg: any) => {
|
||||
if (this.adbResolves[arg.uuid]) {
|
||||
|
||||
@@ -225,13 +225,19 @@ export class AppService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
seedSources() {
|
||||
if (!this.fs.existsSync(this.path.join(this.appData, 'sources.txt'))) {
|
||||
let sourcesPath = this.path.join(__dirname, 'assets', 'sources.txt');
|
||||
seedPlatformTools() {
|
||||
if (!this.fs.existsSync(this.path.join(this.appData, 'platform-tools'))) {
|
||||
let sourcesPath = this.path.join(__dirname, 'platform-tools');
|
||||
if (!this.fs.existsSync(sourcesPath)) {
|
||||
sourcesPath = this.path.join(process.cwd(), 'desktop-app', 'src', 'assets', 'sources.txt');
|
||||
sourcesPath = this.path.join(process.cwd(), 'build', 'platform-tools');
|
||||
}
|
||||
this.fs.createReadStream(sourcesPath).pipe(this.fs.createWriteStream(this.path.join(this.appData, 'sources.txt')));
|
||||
this.fs.readdir(sourcesPath, (err, files) => {
|
||||
files.forEach(file => {
|
||||
this.fs
|
||||
.createReadStream(this.path.join(sourcesPath, file))
|
||||
.pipe(this.fs.createWriteStream(this.path.join(this.appData, file)));
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
makeFolders() {
|
||||
|
||||
@@ -1,9 +1,5 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
interface CheckSubmissionResponse {
|
||||
found: boolean;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
|
||||
+5
-2
@@ -9,5 +9,8 @@ v8.setFlagsFromString('--no-lazy');
|
||||
if (!fs.existsSync(__dirname + '/app.jsc') || process.env.NODE_ENV === 'dev') {
|
||||
bytenode.compileFile(__dirname + '/app.js', __dirname + '/app.jsc');
|
||||
}
|
||||
|
||||
require('./app.jsc');
|
||||
if (process.argv.indexOf('gen-code') > -1) {
|
||||
require('electron').app.quit();
|
||||
} else {
|
||||
require('./app.jsc');
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const https = require('https');
|
||||
const http = require('http');
|
||||
const _fs = require('fs');
|
||||
const { basename } = require('path');
|
||||
const Url = require('url');
|
||||
|
||||
@@ -10,7 +11,7 @@ module.exports = function(url, path, progress) {
|
||||
if (!path) {
|
||||
path = basename(uri.path);
|
||||
}
|
||||
const file = fs.createWriteStream(path);
|
||||
const file = _fs.createWriteStream(path);
|
||||
|
||||
function get(url, callback) {
|
||||
let request = (uri.protocol === 'https:' ? https : http).get(url, function(response) {
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
const __fs = require('fs');
|
||||
const extract = require('extract-zip');
|
||||
const download = require('./download');
|
||||
const url = 'https://dl.google.com/android/repository/platform-tools-latest-';
|
||||
let downloadUrl;
|
||||
switch (os.platform()) {
|
||||
case 'win32':
|
||||
downloadUrl = url + 'windows.zip';
|
||||
break;
|
||||
case 'darwin':
|
||||
downloadUrl = url + 'darwin.zip';
|
||||
break;
|
||||
case 'linux':
|
||||
downloadUrl = url + 'linux.zip';
|
||||
break;
|
||||
}
|
||||
console.log('Platform: ' + os.platform());
|
||||
let outputPath = path.join(__dirname, '..', 'build', 'platform-tools');
|
||||
if (!__fs.existsSync(outputPath)) {
|
||||
__fs.mkdir(outputPath, { recursive: true }, err => {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
console.log('Downloading platform tools...');
|
||||
download(downloadUrl, path.join(__dirname, 'platform-tools.zip'), stats => {
|
||||
// console.log(stats);
|
||||
})
|
||||
.then(() => {
|
||||
console.log('Downloaded platform tools.');
|
||||
console.log('Extracting platform tools...');
|
||||
extract(
|
||||
path.join(__dirname, 'platform-tools.zip'),
|
||||
{
|
||||
dir: __dirname,
|
||||
onEntry: entry => {
|
||||
let stats = entry.fileName;
|
||||
// console.log(stats);
|
||||
},
|
||||
},
|
||||
err => {
|
||||
if (err) console.log(err);
|
||||
console.log('Extracted platform tools.');
|
||||
__fs.readdir(path.join(__dirname, 'platform-tools'), (err, files) => {
|
||||
files.forEach(file => {
|
||||
let curPath = path.join(__dirname, 'platform-tools', file);
|
||||
if (!__fs.lstatSync(curPath).isDirectory()) {
|
||||
__fs.rename(curPath, path.join(outputPath, file), function(err) {
|
||||
if (err) console.log(err);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
})
|
||||
.catch(e => {
|
||||
console.log(e);
|
||||
});
|
||||
}
|
||||
+4
-2
@@ -10,11 +10,13 @@
|
||||
"concurrently": "concurrently",
|
||||
"start": "concurrently \"yarn electron-build && wait-on http-get://localhost:4205/ && cross-env NODE_ENV=dev electron .\" \"cd desktop-app && ng serve --port 4205\"",
|
||||
"postinstall": "electron-builder install-app-deps && cd desktop-app && yarn install",
|
||||
"dist": "yarn electron-build && yarn app-build && electron-builder",
|
||||
"dist": "yarn platform-tools && yarn electron-gen && yarn electron-build && yarn app-build && electron-builder",
|
||||
"angular": "cd desktop-app && ng serve --port 4205",
|
||||
"electron-dev": "cross-env NODE_ENV=dev electron .",
|
||||
"electron-dev": "yarn platform-tools && cross-env NODE_ENV=dev electron .",
|
||||
"electron-gen": "yarn electron-dev gen-code",
|
||||
"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",
|
||||
"electron-build": "tsc",
|
||||
"reset": "rm -rf node_modules && rm -rf desktop-app/node_modules && yarn install && cd desktop-app && yarn install"
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user