Added test logon
This commit is contained in:
@@ -6,14 +6,14 @@ import PropTypes from 'prop-types';
|
|||||||
|
|
||||||
const ApplicationBusy = ({ title }) => {
|
const ApplicationBusy = ({ title }) => {
|
||||||
return (
|
return (
|
||||||
<Box dxStyle={{ padding: 'var(--default_spacing)' }}>
|
<Box dxDark dxStyle={{ padding: 'var(--default_spacing)' }}>
|
||||||
<Text text={title || 'Please Wait...'} textAlign={'center'} type={'Heading1'} />
|
<Text text={title || 'Please Wait...'} textAlign={'center'} type={'Heading1'} />
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
paddingLeft: 'calc(50% - 16px)',
|
paddingLeft: 'calc(50% - 16px)',
|
||||||
paddingTop: 'var(--default_spacing)',
|
paddingTop: 'var(--default_spacing)',
|
||||||
}}>
|
}}>
|
||||||
<Loader color={'var(--heading_text_color)'} height={32} width={32} type="TailSpin" />
|
<Loader color={'var(--heading_text_color)'} height={32} width={32} type='TailSpin' />
|
||||||
</div>
|
</div>
|
||||||
</Box>
|
</Box>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -200,6 +200,9 @@ exports.IPC_Set_Linux_AppPlatform = 'IPC_Set_Linux_AppPlatform';
|
|||||||
|
|
||||||
exports.IPC_Shutdown = 'shutdown';
|
exports.IPC_Shutdown = 'shutdown';
|
||||||
|
|
||||||
|
exports.IPC_Skynet_Test_Logon = 'skynet_test_logon';
|
||||||
|
exports.IPC_Skynet_Test_Logon_Reply = 'skynet_test_logon_reply';
|
||||||
|
|
||||||
exports.IPC_Test_Release = 'test_release';
|
exports.IPC_Test_Release = 'test_release';
|
||||||
exports.IPC_Test_Release_Reply = 'test_release_reply';
|
exports.IPC_Test_Release_Reply = 'test_release_reply';
|
||||||
|
|
||||||
|
|||||||
@@ -2,15 +2,18 @@ import React from 'react';
|
|||||||
import Box from '../../components/UI/Box/Box';
|
import Box from '../../components/UI/Box/Box';
|
||||||
import Button from '../../components/UI/Button/Button';
|
import Button from '../../components/UI/Button/Button';
|
||||||
import DropDown from '../../components/UI/DropDown/DropDown';
|
import DropDown from '../../components/UI/DropDown/DropDown';
|
||||||
|
import IPCContainer from '../IPCContainer/IPCContainer';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Text from '../../components/UI/Text/Text';
|
import Text from '../../components/UI/Text/Text';
|
||||||
import { Component } from 'react';
|
|
||||||
import { addEditHostAction } from '../../redux/actions/host_actions';
|
import { addEditHostAction } from '../../redux/actions/host_actions';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
import { createDismissDisplay } from '../../utils.jsx';
|
import { createDismissDisplay } from '../../utils.jsx';
|
||||||
import { notifyError } from '../../redux/actions/error_actions';
|
import { notifyApplicationBusy } from '../../redux/actions/common_actions';
|
||||||
|
import { notifyError, notifyInfo } from '../../redux/actions/error_actions';
|
||||||
|
|
||||||
class AddEditHost extends Component {
|
const Constants = require('../../constants');
|
||||||
|
|
||||||
|
class AddEditHost extends IPCContainer {
|
||||||
state = {
|
state = {
|
||||||
AgentString: '',
|
AgentString: '',
|
||||||
ApiPassword: '',
|
ApiPassword: '',
|
||||||
@@ -25,13 +28,19 @@ class AddEditHost extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
this.setRequestHandler(Constants.IPC_Skynet_Test_Logon_Reply, this.onSkynetTestLogonReply);
|
||||||
|
|
||||||
if (this.props.HostData) {
|
if (this.props.HostData) {
|
||||||
this.setState({ ...this.state, ...this.props.HostData });
|
this.setState({ ...this.state, ...this.props.HostData });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
componentWillUnmount() {
|
||||||
|
super.componentWillUnmount();
|
||||||
|
}
|
||||||
|
|
||||||
handleSave = () => {
|
handleSave = () => {
|
||||||
if (this.state.HostNameOrIp.trim().length == 0) {
|
if (this.state.HostNameOrIp.trim().length === 0) {
|
||||||
this.props.notifyError('Host / IP cannot be empty');
|
this.props.notifyError('Host / IP cannot be empty');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -51,7 +60,7 @@ class AddEditHost extends Component {
|
|||||||
(i) =>
|
(i) =>
|
||||||
(i.HostNameOrIp || '').trim() === this.state.HostNameOrIp &&
|
(i.HostNameOrIp || '').trim() === this.state.HostNameOrIp &&
|
||||||
i.Protocol === this.state.Protocol &&
|
i.Protocol === this.state.Protocol &&
|
||||||
i.ApiPort == this.state.ApiPort
|
i.ApiPort == this.state.ApiPort,
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
this.props.notifyError(`Portal already exists`);
|
this.props.notifyError(`Portal already exists`);
|
||||||
@@ -61,7 +70,33 @@ class AddEditHost extends Component {
|
|||||||
this.props.completeAddEditHost(this.state);
|
this.props.completeAddEditHost(this.state);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleTestLogon = () => {
|
||||||
|
try {
|
||||||
|
this.props.notifyApplicationBusy(true);
|
||||||
|
this.sendRequest(Constants.IPC_Skynet_Test_Logon, {
|
||||||
|
Version: this.props.InstalledVersion,
|
||||||
|
AuthURL: this.state.AuthURL,
|
||||||
|
AuthUser: this.state.AuthUser,
|
||||||
|
AuthPassword: this.state.AuthPassword,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
this.props.notifyApplicationBusy(false);
|
||||||
|
this.props.notifyError(e);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
onSkynetTestLogonReply = (_, arg) => {
|
||||||
|
this.props.notifyApplicationBusy(false);
|
||||||
|
if (arg.data.Success) {
|
||||||
|
this.props.notifyInfo('Logon was successful!');
|
||||||
|
} else {
|
||||||
|
this.props.notifyError(arg.data.Error);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const allowTestLogon = this.state.AuthURL && this.state.AuthUser;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box dxDark dxStyle={{ width: '430px', height: 'auto', padding: '5px' }}>
|
<Box dxDark dxStyle={{ width: '430px', height: 'auto', padding: '5px' }}>
|
||||||
{createDismissDisplay(this.props.Close)}
|
{createDismissDisplay(this.props.Close)}
|
||||||
@@ -154,7 +189,21 @@ class AddEditHost extends Component {
|
|||||||
</div>
|
</div>
|
||||||
<div style={{ height: 'var(--default_spacing)' }} />
|
<div style={{ height: 'var(--default_spacing)' }} />
|
||||||
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
<div style={{ display: 'flex', flexDirection: 'row' }}>
|
||||||
<Text text={'Authentication URL (premium)'} textAlign={'left'} type={'Heading2'} />
|
<Text noOwner text={'Authentication URL (premium)'}
|
||||||
|
textAlign={'left'} type={'Heading2'} style={{ marginRight: 'auto' }} />
|
||||||
|
{allowTestLogon ? (
|
||||||
|
<a
|
||||||
|
href={'#'}
|
||||||
|
onClick={
|
||||||
|
(e) => {
|
||||||
|
this.handleTestLogon();
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<u>test logon</u>
|
||||||
|
</a>
|
||||||
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
||||||
<input
|
<input
|
||||||
@@ -191,13 +240,13 @@ class AddEditHost extends Component {
|
|||||||
<p>
|
<p>
|
||||||
<b>
|
<b>
|
||||||
{'Portal URL: ' +
|
{'Portal URL: ' +
|
||||||
this.state.Protocol +
|
this.state.Protocol +
|
||||||
'://' +
|
'://' +
|
||||||
this.state.HostNameOrIp +
|
this.state.HostNameOrIp +
|
||||||
((this.state.Protocol === 'http' && this.state.ApiPort != 80) ||
|
((this.state.Protocol === 'http' && this.state.ApiPort != 80) ||
|
||||||
(this.state.Protocol === 'https' && this.state.ApiPort != 443)
|
(this.state.Protocol === 'https' && this.state.ApiPort != 443)
|
||||||
? ':' + this.state.ApiPort.toString()
|
? ':' + this.state.ApiPort.toString()
|
||||||
: '')}
|
: '')}
|
||||||
</b>
|
</b>
|
||||||
</p>
|
</p>
|
||||||
<div style={{ height: 'var(--default_spacing)' }} />
|
<div style={{ height: 'var(--default_spacing)' }} />
|
||||||
@@ -212,6 +261,7 @@ const mapStateToProps = (state) => {
|
|||||||
return {
|
return {
|
||||||
HostData: state.host.HostData,
|
HostData: state.host.HostData,
|
||||||
HostList: state.host.HostList,
|
HostList: state.host.HostList,
|
||||||
|
InstalledVersion: state.relver.InstalledVersion,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -219,16 +269,21 @@ const mapDispatchToProps = (dispatch) => {
|
|||||||
return {
|
return {
|
||||||
Close: () => dispatch(addEditHostAction.complete(false)),
|
Close: () => dispatch(addEditHostAction.complete(false)),
|
||||||
completeAddEditHost: (host_data) => dispatch(addEditHostAction.complete(true, { host_data })),
|
completeAddEditHost: (host_data) => dispatch(addEditHostAction.complete(true, { host_data })),
|
||||||
|
notifyApplicationBusy: (busy) => dispatch(notifyApplicationBusy(busy, true)),
|
||||||
notifyError: (msg) => dispatch(notifyError(msg)),
|
notifyError: (msg) => dispatch(notifyError(msg)),
|
||||||
|
notifyInfo: (msg) => dispatch(notifyInfo(msg)),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
AddEditHost.propTypes = {
|
AddEditHost.propTypes = {
|
||||||
Close: PropTypes.func.isRequired,
|
Close: PropTypes.func.isRequired,
|
||||||
completeAddEditHost: PropTypes.func.isRequired,
|
|
||||||
HostData: PropTypes.object,
|
HostData: PropTypes.object,
|
||||||
HostList: PropTypes.array.isRequired,
|
HostList: PropTypes.array.isRequired,
|
||||||
|
InstalledVersion: PropTypes.string.isRequired,
|
||||||
|
completeAddEditHost: PropTypes.func.isRequired,
|
||||||
|
notifyApplicationBusy: PropTypes.func.isRequired,
|
||||||
notifyError: PropTypes.func.isRequired,
|
notifyError: PropTypes.func.isRequired,
|
||||||
|
notifyInfo: PropTypes.func.isRequired,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default connect(mapStateToProps, mapDispatchToProps)(AddEditHost);
|
export default connect(mapStateToProps, mapDispatchToProps)(AddEditHost);
|
||||||
|
|||||||
355
src/helpers.js
355
src/helpers.js
@@ -27,48 +27,48 @@ const _vcRuntimeExists = () => {
|
|||||||
: 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
: 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
||||||
];
|
];
|
||||||
_execProcessGetOutput(cmd, null, args)
|
_execProcessGetOutput(cmd, null, args)
|
||||||
.then((lines) => {
|
.then((lines) => {
|
||||||
const parseLine = (index) => {
|
const parseLine = (index) => {
|
||||||
if (index < lines.length) {
|
if (index < lines.length) {
|
||||||
const line = lines[index];
|
const line = lines[index];
|
||||||
if (line.startsWith('HKEY_LOCAL_MACHINE\\')) {
|
if (line.startsWith('HKEY_LOCAL_MACHINE\\')) {
|
||||||
let args2 = JSON.parse(JSON.stringify(args));
|
let args2 = JSON.parse(JSON.stringify(args));
|
||||||
args2[1] = 'HKLM\\' + line.substr(19);
|
args2[1] = 'HKLM\\' + line.substr(19);
|
||||||
args2.push('/v');
|
args2.push('/v');
|
||||||
args2.push('DisplayName');
|
args2.push('DisplayName');
|
||||||
args2.push('/t');
|
args2.push('/t');
|
||||||
args2.push('REG_SZ');
|
args2.push('REG_SZ');
|
||||||
_execProcessGetOutput(cmd, null, args2)
|
_execProcessGetOutput(cmd, null, args2)
|
||||||
.then((lines) => {
|
.then((lines) => {
|
||||||
const value = lines[2].trim().substr(args2[3].length).trim().substr(6).trim();
|
const value = lines[2].trim().substr(args2[3].length).trim().substr(6).trim();
|
||||||
if (
|
if (
|
||||||
value.includes(
|
value.includes(
|
||||||
IS_64BIT
|
IS_64BIT
|
||||||
? 'Microsoft Visual C++ 2015-2019 Redistributable (x64)'
|
? 'Microsoft Visual C++ 2015-2019 Redistributable (x64)'
|
||||||
: 'Microsoft Visual C++ 2015-2019 Redistributable (x32)'
|
: 'Microsoft Visual C++ 2015-2019 Redistributable (x32)',
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
vcRuntimeExists = true;
|
vcRuntimeExists = true;
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
} else {
|
||||||
parseLine(++index);
|
parseLine(++index);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch(() => {
|
||||||
parseLine(++index);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
parseLine(++index);
|
parseLine(++index);
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve(false);
|
parseLine(++index);
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
parseLine(0);
|
resolve(false);
|
||||||
})
|
}
|
||||||
.catch((err) => {
|
};
|
||||||
reject(err);
|
parseLine(0);
|
||||||
});
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -317,13 +317,13 @@ module.exports.cleanupOldReleases = (versionList) => {
|
|||||||
if (versionList && versionList.length > 0) {
|
if (versionList && versionList.length > 0) {
|
||||||
const dataDir = _getDataDirectory();
|
const dataDir = _getDataDirectory();
|
||||||
const directoryList = fs
|
const directoryList = fs
|
||||||
.readdirSync(dataDir, { withFileTypes: true })
|
.readdirSync(dataDir, { withFileTypes: true })
|
||||||
.filter((dirent) => dirent.isDirectory())
|
.filter((dirent) => dirent.isDirectory())
|
||||||
.map((dirent) => dirent);
|
.map((dirent) => dirent);
|
||||||
|
|
||||||
const removeList = directoryList
|
const removeList = directoryList
|
||||||
.filter((dirent) => !versionList.includes(dirent.name))
|
.filter((dirent) => !versionList.includes(dirent.name))
|
||||||
.map((dirent) => dirent.name);
|
.map((dirent) => dirent.name);
|
||||||
|
|
||||||
for (const dir of removeList) {
|
for (const dir of removeList) {
|
||||||
try {
|
try {
|
||||||
@@ -391,8 +391,8 @@ module.exports.detectRepertoryMounts = (version, providerList) => {
|
|||||||
const args = _getDefaultRepertoryArgs(
|
const args = _getDefaultRepertoryArgs(
|
||||||
provider,
|
provider,
|
||||||
!Constants.PROVIDER_LIST.includes(provider) &&
|
!Constants.PROVIDER_LIST.includes(provider) &&
|
||||||
provider.toLowerCase().startsWith('remote'),
|
provider.toLowerCase().startsWith('remote'),
|
||||||
!Constants.PROVIDER_LIST.includes(provider) && provider.toLowerCase().startsWith('s3')
|
!Constants.PROVIDER_LIST.includes(provider) && provider.toLowerCase().startsWith('s3'),
|
||||||
);
|
);
|
||||||
args.push('-status');
|
args.push('-status');
|
||||||
|
|
||||||
@@ -438,51 +438,51 @@ module.exports.downloadFile = (url, destination, progressCallback, completeCallb
|
|||||||
}
|
}
|
||||||
|
|
||||||
axios
|
axios
|
||||||
.get(url, {
|
.get(url, {
|
||||||
responseType: 'stream',
|
responseType: 'stream',
|
||||||
})
|
})
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
try {
|
try {
|
||||||
const total = parseInt(response.headers['content-length'], 10);
|
const total = parseInt(response.headers['content-length'], 10);
|
||||||
if (total === 0) {
|
if (total === 0) {
|
||||||
completeCallback(new Error('No data available for download'));
|
completeCallback(new Error('No data available for download'));
|
||||||
} else {
|
} else {
|
||||||
const stream = fs.createWriteStream(destination);
|
const stream = fs.createWriteStream(destination);
|
||||||
|
|
||||||
let downloaded = 0;
|
let downloaded = 0;
|
||||||
response.data.on('data', (chunk) => {
|
response.data.on('data', (chunk) => {
|
||||||
stream.write(Buffer.from(chunk));
|
stream.write(Buffer.from(chunk));
|
||||||
downloaded += chunk.length;
|
downloaded += chunk.length;
|
||||||
if (progressCallback) {
|
if (progressCallback) {
|
||||||
progressCallback(((downloaded / total) * 100.0).toFixed(2));
|
progressCallback(((downloaded / total) * 100.0).toFixed(2));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
response.data.on('end', () => {
|
||||||
|
stream.end(() => {
|
||||||
|
if (downloaded === 0) {
|
||||||
|
completeCallback(new Error('Received 0 bytes'));
|
||||||
|
} else if (downloaded !== total) {
|
||||||
|
completeCallback(new Error('Received incorrect number of bytes'));
|
||||||
|
} else {
|
||||||
|
completeCallback();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
response.data.on('end', () => {
|
response.data.on('error', (error) => {
|
||||||
stream.end(() => {
|
stream.end(() => {
|
||||||
if (downloaded === 0) {
|
completeCallback(error);
|
||||||
completeCallback(new Error('Received 0 bytes'));
|
|
||||||
} else if (downloaded !== total) {
|
|
||||||
completeCallback(new Error('Received incorrect number of bytes'));
|
|
||||||
} else {
|
|
||||||
completeCallback();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
});
|
||||||
response.data.on('error', (error) => {
|
|
||||||
stream.end(() => {
|
|
||||||
completeCallback(error);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} catch (error) {
|
|
||||||
completeCallback(error);
|
|
||||||
}
|
}
|
||||||
})
|
} catch (error) {
|
||||||
.catch((error) => {
|
|
||||||
completeCallback(error);
|
completeCallback(error);
|
||||||
});
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
completeCallback(error);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports.executeAndWait = (command, ignoreResult) => {
|
module.exports.executeAndWait = (command, ignoreResult) => {
|
||||||
@@ -539,9 +539,9 @@ module.exports.executeAsync = (command, args = []) => {
|
|||||||
() =>
|
() =>
|
||||||
launchProcess(
|
launchProcess(
|
||||||
count,
|
count,
|
||||||
setTimeout(() => resolve(), 3000)
|
setTimeout(() => resolve(), 3000),
|
||||||
),
|
),
|
||||||
1000
|
1000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -556,9 +556,9 @@ module.exports.executeAsync = (command, args = []) => {
|
|||||||
() =>
|
() =>
|
||||||
launchProcess(
|
launchProcess(
|
||||||
count,
|
count,
|
||||||
setTimeout(() => resolve(), 3000)
|
setTimeout(() => resolve(), 3000),
|
||||||
),
|
),
|
||||||
1000
|
1000,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -569,7 +569,7 @@ module.exports.executeAsync = (command, args = []) => {
|
|||||||
|
|
||||||
launchProcess(
|
launchProcess(
|
||||||
0,
|
0,
|
||||||
setTimeout(() => resolve(), 3000)
|
setTimeout(() => resolve(), 3000),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -785,16 +785,16 @@ module.exports.getMissingDependencies = (dependencies) => {
|
|||||||
if (index >= dep.registry.length) {
|
if (index >= dep.registry.length) {
|
||||||
if (dep.display === 'VC Runtime 2015-2019') {
|
if (dep.display === 'VC Runtime 2015-2019') {
|
||||||
_vcRuntimeExists()
|
_vcRuntimeExists()
|
||||||
.then((exists) => {
|
.then((exists) => {
|
||||||
if (!exists) {
|
if (!exists) {
|
||||||
missing.push(dep);
|
|
||||||
}
|
|
||||||
resolveIfComplete();
|
|
||||||
})
|
|
||||||
.catch(() => {
|
|
||||||
missing.push(dep);
|
missing.push(dep);
|
||||||
resolveIfComplete();
|
}
|
||||||
});
|
resolveIfComplete();
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
missing.push(dep);
|
||||||
|
resolveIfComplete();
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
missing.push(dep);
|
missing.push(dep);
|
||||||
resolveIfComplete();
|
resolveIfComplete();
|
||||||
@@ -861,18 +861,18 @@ module.exports.getMissingDependencies = (dependencies) => {
|
|||||||
module.exports.grabSkynetFileTree = (version) => {
|
module.exports.grabSkynetFileTree = (version) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
_exportAllSkylinks(version)
|
_exportAllSkylinks(version)
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
resolve([
|
resolve([
|
||||||
{
|
{
|
||||||
name: '/',
|
name: '/',
|
||||||
directory: true,
|
directory: true,
|
||||||
children: _createTreeNodes(results.success),
|
children: _createTreeNodes(results.success),
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
})
|
})
|
||||||
.catch((e) => {
|
.catch((e) => {
|
||||||
reject(e);
|
reject(e);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1048,53 +1048,53 @@ module.exports.performWindowsUninstall = (names) => {
|
|||||||
: 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
: 'HKLM\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall',
|
||||||
];
|
];
|
||||||
_execProcessGetOutput(cmd, null, args)
|
_execProcessGetOutput(cmd, null, args)
|
||||||
.then((lines) => {
|
.then((lines) => {
|
||||||
const parseLine = (index) => {
|
const parseLine = (index) => {
|
||||||
if (index < lines.length) {
|
if (index < lines.length) {
|
||||||
const line = lines[index];
|
const line = lines[index];
|
||||||
if (line.startsWith('HKEY_LOCAL_MACHINE\\')) {
|
if (line.startsWith('HKEY_LOCAL_MACHINE\\')) {
|
||||||
let args2 = JSON.parse(JSON.stringify(args));
|
let args2 = JSON.parse(JSON.stringify(args));
|
||||||
args2[1] = 'HKLM\\' + line.substr(19);
|
args2[1] = 'HKLM\\' + line.substr(19);
|
||||||
args2.push('/v');
|
args2.push('/v');
|
||||||
args2.push('DisplayName');
|
args2.push('DisplayName');
|
||||||
args2.push('/t');
|
args2.push('/t');
|
||||||
args2.push('REG_SZ');
|
args2.push('REG_SZ');
|
||||||
_execProcessGetOutput(cmd, null, args2)
|
_execProcessGetOutput(cmd, null, args2)
|
||||||
.then((lines) => {
|
.then((lines) => {
|
||||||
const value = lines[2].trim().substr(args2[3].length).trim().substr(6).trim();
|
const value = lines[2].trim().substr(args2[3].length).trim().substr(6).trim();
|
||||||
if (names.includes(value)) {
|
if (names.includes(value)) {
|
||||||
const items = line.split('\\');
|
const items = line.split('\\');
|
||||||
const productCode = items[items.length - 1];
|
const productCode = items[items.length - 1];
|
||||||
_executeProcess('msiexec.exe', null, ['/x', productCode, '/norestart'])
|
_executeProcess('msiexec.exe', null, ['/x', productCode, '/norestart'])
|
||||||
.then((code) => {
|
.then((code) => {
|
||||||
if (code === 0 || code === 3010 || code === 1641) {
|
if (code === 0 || code === 3010 || code === 1641) {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
} else {
|
|
||||||
reject('[' + value + '] uninstall failed: ' + code);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
reject(err);
|
|
||||||
});
|
|
||||||
} else {
|
} else {
|
||||||
parseLine(++index);
|
reject('[' + value + '] uninstall failed: ' + code);
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch(() => {
|
.catch((err) => {
|
||||||
parseLine(++index);
|
reject(err);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
|
parseLine(++index);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
parseLine(++index);
|
parseLine(++index);
|
||||||
}
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve(false);
|
parseLine(++index);
|
||||||
}
|
}
|
||||||
};
|
} else {
|
||||||
parseLine(0);
|
resolve(false);
|
||||||
})
|
}
|
||||||
.catch((err) => {
|
};
|
||||||
reject(err);
|
parseLine(0);
|
||||||
});
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -1136,6 +1136,37 @@ module.exports.setConfigValue = (name, value, provider, remote, s3, version) =>
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module.exports.testSkynetLogon = (version, authURL, authUser, authPassword, agentString, apiKey) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const repertoryExec = _getRepertoryExec(version);
|
||||||
|
const processOptions = {
|
||||||
|
cwd: repertoryExec.working,
|
||||||
|
detached: true,
|
||||||
|
shell: false,
|
||||||
|
windowsHide: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const args = _getDefaultRepertoryArgs('Skynet');
|
||||||
|
args.push('-tsa');
|
||||||
|
args.push(authURL);
|
||||||
|
args.push(authUser);
|
||||||
|
args.push(authPassword);
|
||||||
|
args.push(agentString || '');
|
||||||
|
args.push(apiKey || '');
|
||||||
|
|
||||||
|
const process = new spawn(repertoryExec.cmd, args, processOptions);
|
||||||
|
process.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('exit', (code) => {
|
||||||
|
resolve(code === 0);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.unref();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
module.exports.stopMountProcess = (version, provider, remote, s3) => {
|
module.exports.stopMountProcess = (version, provider, remote, s3) => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const repertoryExec = _getRepertoryExec(version);
|
const repertoryExec = _getRepertoryExec(version);
|
||||||
@@ -1187,16 +1218,16 @@ module.exports.testRepertoryBinary = (version) => {
|
|||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
const repertoryExec = _getRepertoryExec(version);
|
const repertoryExec = _getRepertoryExec(version);
|
||||||
_executeProcess(repertoryExec.cmd, repertoryExec.working, ['-dc'])
|
_executeProcess(repertoryExec.cmd, repertoryExec.working, ['-dc'])
|
||||||
.then((code) => {
|
.then((code) => {
|
||||||
if (code === 0) {
|
if (code === 0) {
|
||||||
resolve();
|
resolve();
|
||||||
} else {
|
} else {
|
||||||
reject(new Error('Invalid exit code: ' + code));
|
reject(new Error('Invalid exit code: ' + code));
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.catch((error) => {
|
.catch((error) => {
|
||||||
reject(error);
|
reject(error);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1243,7 +1274,7 @@ module.exports.verifySignature = (file, signatureFile, publicKeyFile) => {
|
|||||||
} else {
|
} else {
|
||||||
resolve(stdout);
|
resolve(stdout);
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -1267,7 +1298,7 @@ module.exports.verifySignature = (file, signatureFile, publicKeyFile) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
reject(new Error("Failed to locate 'openssl.exe'"));
|
reject(new Error('Failed to locate \'openssl.exe\''));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else if (os.platform() === 'linux') {
|
} else if (os.platform() === 'linux') {
|
||||||
|
|||||||
@@ -4,41 +4,56 @@ const helpers = require('../../helpers');
|
|||||||
const addListeners = (ipcMain, { standardIPCReply }) => {
|
const addListeners = (ipcMain, { standardIPCReply }) => {
|
||||||
ipcMain.on(Constants.IPC_Export_Skylinks, (event, data) => {
|
ipcMain.on(Constants.IPC_Export_Skylinks, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.exportSkylinks(data.Version, data.Paths)
|
.exportSkylinks(data.Version, data.Paths)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
standardIPCReply(event, Constants.IPC_Export_Skylinks_Reply, {
|
standardIPCReply(event, Constants.IPC_Export_Skylinks_Reply, {
|
||||||
Result: result,
|
Result: result,
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
standardIPCReply(event, Constants.IPC_Export_Skylinks_Reply, {}, error);
|
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
standardIPCReply(event, Constants.IPC_Export_Skylinks_Reply, {}, error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Grab_Skynet_Tree, (event, data) => {
|
ipcMain.on(Constants.IPC_Grab_Skynet_Tree, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.grabSkynetFileTree(data.Version)
|
.grabSkynetFileTree(data.Version)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
standardIPCReply(event, Constants.IPC_Grab_Skynet_Tree_Reply, {
|
standardIPCReply(event, Constants.IPC_Grab_Skynet_Tree_Reply, {
|
||||||
Result: result,
|
Result: result,
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
standardIPCReply(event, Constants.IPC_Grab_Skynet_Tree_Reply, {}, error);
|
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
standardIPCReply(event, Constants.IPC_Grab_Skynet_Tree_Reply, {}, error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Import_Skylinks, (event, data) => {
|
ipcMain.on(Constants.IPC_Import_Skylinks, (event, data) => {
|
||||||
helpers
|
helpers
|
||||||
.importSkylinks(data.Version, data.JsonArray)
|
.importSkylinks(data.Version, data.JsonArray)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
standardIPCReply(event, Constants.IPC_Import_Skylinks_Reply, {
|
standardIPCReply(event, Constants.IPC_Import_Skylinks_Reply, {
|
||||||
Result: result,
|
Result: result,
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch((error) => {
|
|
||||||
standardIPCReply(event, Constants.IPC_Import_Skylinks_Reply, {}, error);
|
|
||||||
});
|
});
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
standardIPCReply(event, Constants.IPC_Import_Skylinks_Reply, {}, error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on(Constants.IPC_Skynet_Test_Logon, (event, data) => {
|
||||||
|
helpers
|
||||||
|
.testSkynetLogon(data.Version, data.AuthURL, data.AuthUser, data.AuthPassword)
|
||||||
|
.then((success) => {
|
||||||
|
if (success) {
|
||||||
|
standardIPCReply(event, Constants.IPC_Skynet_Test_Logon_Reply, {});
|
||||||
|
} else {
|
||||||
|
standardIPCReply(event, Constants.IPC_Skynet_Test_Logon_Reply, {}, 'Logon failed. Please check credentials');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
standardIPCReply(event, Constants.IPC_Skynet_Test_Logon_Reply, {}, error);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user