mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
Redo branch & pr for registry (#36)
* Redo branch & pr for registry * fix lint ignore file
This commit is contained in:
parent
a10db61d8e
commit
b244519045
@ -50,6 +50,7 @@
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.MsiCompsComponent">
|
||||
<ROW Component="AI_CustomARPName" ComponentId="{2817ACD9-F494-4729-9830-111EF3311CFA}" Directory_="APPDIR" Attributes="4" KeyPath="DisplayName" Options="1"/>
|
||||
<ROW Component="PodUrl" ComponentId="{EA80D82D-BC65-4075-A9A8-F53E2B2513CE}" Directory_="APPDIR" Attributes="260" KeyPath="PodUrl"/>
|
||||
<ROW Component="ProductInformation" ComponentId="{8B92B687-8AE0-4A5C-B6AB-5D1854009CEA}" Directory_="APPDIR" Attributes="4" KeyPath="Version"/>
|
||||
<ROW Component="Symphony" ComponentId="{A6B4BA2F-2403-4B8E-9303-BF8400A9B1C4}" Directory_="Symphony_Dir" Attributes="0"/>
|
||||
<ROW Component="Symphony.config" ComponentId="{644A231D-2C96-4D3D-ADB0-7820DA373499}" Directory_="config_Dir" Attributes="0" KeyPath="Symphony.config_1" Type="0"/>
|
||||
@ -66,7 +67,7 @@
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.MsiFeatsComponent">
|
||||
<ROW Feature="D564007E3BBE4F85950A09B470A7CA65" Title="Visual C++ Redistributable for Visual Studio 2013 x86" Description="Visual C++ Redistributable for Visual Studio 2013 x86" Display="3" Level="1" Attributes="0" Components="AI_CustomARPName"/>
|
||||
<ROW Feature="MainFeature" Title="MainFeature" Description="Description" Display="1" Level="1" Directory_="APPDIR" Attributes="0" Components="AI_CustomARPName ProductInformation Symphony Symphony.config Symphony.exe am.pak appupdate.yml blink_image_resources_200_percent.pak d3dcompiler_47.dll ffmpeg.dll libEGL.dll libGLESv2.dll node.dll xinput1_3.dll"/>
|
||||
<ROW Feature="MainFeature" Title="MainFeature" Description="Description" Display="1" Level="1" Directory_="APPDIR" Attributes="0" Components="AI_CustomARPName PodUrl ProductInformation Symphony Symphony.config Symphony.exe am.pak appupdate.yml blink_image_resources_200_percent.pak d3dcompiler_47.dll ffmpeg.dll libEGL.dll libGLESv2.dll node.dll xinput1_3.dll"/>
|
||||
<ATTRIBUTE name="CurrentFeature" value="MainFeature"/>
|
||||
</COMPONENT>
|
||||
<COMPONENT cid="caphyon.advinst.msicomp.MsiFilesComponent">
|
||||
@ -386,6 +387,7 @@
|
||||
<ROW Registry="ModifyPath" Root="-1" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName] [ProductVersion]" Name="ModifyPath" Value="[AI_UNINSTALLER] /I [ProductCode]" Component_="AI_CustomARPName"/>
|
||||
<ROW Registry="NoRepair" Root="-1" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName] [ProductVersion]" Name="NoRepair" Value="#1" Component_="AI_CustomARPName"/>
|
||||
<ROW Registry="Path" Root="-1" Key="Software\[Manufacturer]\[ProductName]" Name="Path" Value="[APPDIR]" Component_="ProductInformation"/>
|
||||
<ROW Registry="PodUrl" Root="-1" Key="Software\[Manufacturer]\[ProductName]" Name="PodUrl" Component_="PodUrl"/>
|
||||
<ROW Registry="Publisher" Root="-1" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName] [ProductVersion]" Name="Publisher" Value="[Manufacturer]" Component_="AI_CustomARPName"/>
|
||||
<ROW Registry="URLInfoAbout" Root="-1" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName] [ProductVersion]" Name="URLInfoAbout" Value="[ARPURLINFOABOUT]" Component_="AI_CustomARPName"/>
|
||||
<ROW Registry="URLUpdateInfo" Root="-1" Key="Software\Microsoft\Windows\CurrentVersion\Uninstall\[ProductName] [ProductVersion]" Name="URLUpdateInfo" Value="[ARPURLUPDATEINFO]" Component_="AI_CustomARPName"/>
|
||||
|
@ -6,6 +6,7 @@ const path = require('path');
|
||||
const fs = require('fs');
|
||||
const isDevEnv = require('./utils/misc.js').isDevEnv;
|
||||
const isMac = require('./utils/misc.js').isMac;
|
||||
const getRegistry = require('./utils/getRegistry.js');
|
||||
|
||||
/**
|
||||
* reads global configuration file: config/Symphony.config. this file is
|
||||
@ -14,14 +15,11 @@ const isMac = require('./utils/misc.js').isMac;
|
||||
* this file is located relative to the executable - it is placed there by
|
||||
* the installer. this makes the file easily modifable by admin (or person who
|
||||
* installed app). for dev env, the file is read directly from packed asar file.
|
||||
*
|
||||
* @return {Object} configuration parameters (e.g., url)
|
||||
*/
|
||||
function getConfig() {
|
||||
return new Promise(function(resolve, reject) {
|
||||
var getConfig = function () {
|
||||
var promise = new Promise(function(resolve, reject) {
|
||||
let configPath;
|
||||
const configFile = 'config/Symphony.config';
|
||||
|
||||
if (isDevEnv) {
|
||||
// for dev env, get config file from asar
|
||||
configPath = path.join(app.getAppPath(), configFile);
|
||||
@ -38,16 +36,24 @@ function getConfig() {
|
||||
if (err) {
|
||||
reject('cannot open config file: ' + configPath + ', error: ' + err);
|
||||
} else {
|
||||
let config = {};
|
||||
try {
|
||||
// data is the contents of the text file we just read
|
||||
let config = JSON.parse(data);
|
||||
resolve(config);
|
||||
config = JSON.parse(data);
|
||||
} catch (e) {
|
||||
reject('can not parse config file data: ' + data + ', error: ' + err);
|
||||
}
|
||||
getRegistry('PodUrl')
|
||||
.then(function(url){
|
||||
config.url = url;
|
||||
resolve(config);
|
||||
}).catch(function (){
|
||||
resolve(config);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
module.exports = getConfig
|
||||
|
33
js/main.js
33
js/main.js
@ -42,25 +42,28 @@ function getUrlAndOpenMainWindow() {
|
||||
}
|
||||
}
|
||||
|
||||
getConfig().then(function(config) {
|
||||
let protocol = '';
|
||||
// add https protocol if none found.
|
||||
let parsedUrl = nodeURL.parse(config.url);
|
||||
if (!parsedUrl.protocol) {
|
||||
protocol = 'https';
|
||||
}
|
||||
var url = nodeURL.format({
|
||||
protocol: protocol,
|
||||
slahes: true,
|
||||
pathname: parsedUrl.href
|
||||
});
|
||||
windowMgr.createMainWindow(url);
|
||||
}).catch(function(err) {
|
||||
getConfig()
|
||||
.then(createWin).catch(function (err){
|
||||
let title = 'Error loading configuration';
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
electron.dialog.showErrorBox(title, title + ': ' + err);
|
||||
});
|
||||
}
|
||||
|
||||
function createWin(config){
|
||||
let protocol = '';
|
||||
// add https protocol if none found.
|
||||
let parsedUrl = nodeURL.parse(config.url);
|
||||
if (!parsedUrl.protocol) {
|
||||
protocol = 'https';
|
||||
}
|
||||
var url = nodeURL.format({
|
||||
protocol: protocol,
|
||||
slahes: true,
|
||||
pathname: parsedUrl.href
|
||||
});
|
||||
windowMgr.createMainWindow(url);
|
||||
}
|
||||
|
||||
app.on('window-all-closed', function() {
|
||||
// On OS X it is common for applications and their menu bar
|
||||
// to stay active until the user quits explicitly with Cmd + Q
|
||||
|
58
js/utils/getRegistry.js
Normal file
58
js/utils/getRegistry.js
Normal file
@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
const symphonyRegistry = '\\Software\\Symphony\\Symphony\\';
|
||||
const { isMac } = require('./misc.js');
|
||||
|
||||
var Registry = require('winreg');
|
||||
var symphonyRegistryHKCU = new Registry({
|
||||
hive: Registry.HKCU,
|
||||
key: symphonyRegistry
|
||||
});
|
||||
|
||||
var symphonyRegistryHKLM = new Registry({
|
||||
key: symphonyRegistry
|
||||
});
|
||||
|
||||
var symphonyRegistryHKLM6432 = new Registry({
|
||||
key: symphonyRegistry.replace('\\Software','\\Software\\WOW6432Node')
|
||||
});
|
||||
|
||||
/**
|
||||
* Reads Windows Registry key. This Registry holds the Symphony registry keys
|
||||
* that are intended to be used as global (or default) value for all users
|
||||
* running this app.
|
||||
*/
|
||||
var getRegistry = function (name) {
|
||||
var promise = new Promise(function(resolve, reject) {
|
||||
if (isMac){
|
||||
reject('Mac OS. Using default url from config.json.');
|
||||
} else{
|
||||
//Try to get registry on HKEY_CURRENT_USER
|
||||
symphonyRegistryHKCU.get( name, function( err1, reg1 ) {
|
||||
if ( !err1 && reg1!==null && reg1.value) {
|
||||
resolve(reg1.value);
|
||||
} else{
|
||||
//Try to get registry on HKEY_LOCAL_MACHINE
|
||||
symphonyRegistryHKLM.get( name, function( err2, reg2 ) {
|
||||
if ( !err2 && reg2!==null && reg2.value) {
|
||||
resolve(reg2.value);
|
||||
} else{
|
||||
//Try to get registry on HKEY_LOCAL_MACHINE in case 32bit app installed on 64bit system.
|
||||
//winreg does not merge keys as normally windows does.
|
||||
symphonyRegistryHKLM6432.get( name, function( err3, reg3 ) {
|
||||
if ( !err3 && reg3!==null && reg3.value) {
|
||||
resolve(reg3.value);
|
||||
} else{
|
||||
reject('Cannot find PodUrl Registry. Using default url.');
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return promise;
|
||||
}
|
||||
|
||||
module.exports = getRegistry
|
@ -77,6 +77,7 @@
|
||||
"dependencies": {
|
||||
"async": "^2.1.5",
|
||||
"electron-squirrel-startup": "^1.0.0",
|
||||
"keymirror": "0.1.1"
|
||||
"keymirror": "0.1.1",
|
||||
"winreg": "^1.2.3"
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user