Merge pull request #279 from GNS3/as-user-can-install-solarputty

As user I can install solarputty and get list of installed software
This commit is contained in:
ziajka 2019-02-04 11:40:24 +01:00 committed by GitHub
commit 643240eb59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 11 deletions

3
.gitignore vendored
View File

@ -55,3 +55,6 @@ licenses.csv
# Temps
.temp-var-file.ts
# external software
/external

View File

@ -6,7 +6,7 @@ var fetch = require('node-fetch')
var stream = require('stream');
var path = require('path');
const { spawn } = require('child_process');
const { ipcMain } = require('electron')
const { ipcMain } = require('electron');
var pipeline = util.promisify(stream.pipeline);
@ -40,8 +40,24 @@ async function downloadFile(resource, softwarePath) {
);
}
async function getSoftwareInstallationPath(software) {
if (software.installer) {
return path.join(app.getPath('temp'), software.binary);
}
else {
const externalPath = path.join(app.getAppPath(), 'external');
const exists = fs.existsSync(externalPath);
if (!exists) {
fs.mkdirSync(externalPath);
}
return path.join(externalPath, software.binary);
}
}
ipcMain.on('installed-software-install', async function (event, software) {
const softwarePath = path.join(app.getPath('temp'), software.binary);
const softwarePath = await getSoftwareInstallationPath(software);
const responseChannel = `installed-software-installed-${software.name}`;
if (software.type == 'web') {

View File

@ -33,8 +33,8 @@
"prettier:check": "yarn prettier:base -- --list-different \"src/**/*.{ts,js,html,scss}\"",
"prettier:write": "yarn prettier:base -- --write \"src/**/*.{ts,js,html,scss}\"",
"generate-licenses-file": "yarn license-checker --production --csv --out licenses.csv",
"prebuild": "node set-variables-in-env.js --set src/environments/environment.prod.ts",
"postbuild": "node set-variables-in-env.js --unset src/environments/environment.prod.ts"
"prebuildforelectron": "node set-variables-in-env.js --set src/environments/environment.electron.prod.ts",
"postbuildforelectron": "node set-variables-in-env.js --unset src/environments/environment.electron.prod.ts"
},
"private": true,
"dependencies": {
@ -67,7 +67,8 @@
"rxjs-compat": "^6.3.3",
"typeface-roboto": "^0.0.54",
"yargs": "^12.0.5",
"zone.js": "^0.8.26"
"zone.js": "^0.8.26",
"node-fetch": "^2.3.0"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.11.4",
@ -91,7 +92,6 @@
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"license-checker": "^24.1.0",
"node-fetch": "^2.3.0",
"node-sass": "^4.11.0",
"popper.js": "^1.14.6",
"prettier": "^1.15.2",

View File

@ -30,21 +30,24 @@ export class ExternalSoftwareDefinitionService {
binary: 'Wireshark.exe',
sudo: true,
installation_arguments: [],
installed: false
installed: false,
installer: true
}
];
const solarPutty = {
name: 'SolarPuTTY',
locations: [
'SolarPuTTY.exe'
'SolarPuTTY.exe',
'external\\SolarPuTTY.exe'
],
type: 'web',
resource: '',
binary: 'SolarPuTTY.exe',
sudo: false,
installation_arguments: ['--only-ask'],
installed: false
installed: false,
installer: false
};
if(environment.solarputty_download_url) {

View File

@ -1,5 +1,5 @@
export const environment = {
solarputty_download_url: "",
production: true,
electron: true,
solarputty_download_url: ""
};

View File

@ -1,5 +1,5 @@
export const environment = {
production: false,
electron: true,
solarputty_download_url: ""
solarputty_download_url: "",
};