OS X installation support

This commit is contained in:
Scott E. Graves
2018-12-11 10:31:04 -06:00
parent 29a72f4707
commit e603894e2d
3 changed files with 148 additions and 102 deletions

View File

@@ -310,7 +310,7 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
const setImage = (locations) => {
if (os.platform() === 'win32' || os.platform() === 'linux') {
let driveInUse = false;
let driveInUse;
for (const provider of Constants.PROVIDER_LIST) {
driveInUse = locations[provider].length > 0;
if (driveInUse)
@@ -504,16 +504,45 @@ ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
});
ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
if (os.platform() === 'win32') {
helpers
.executeAsync(data.Source)
.then(()=> {
mainWindow.close();
.then(() => {
closeApplication();
})
.catch(error => {
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
Source: data.Source,
}, error);
});
} else if (data.Source.toLocaleLowerCase().endsWith('.dmg')) {
helpers
.executeAsync('hdiutil', ['attach', data.Source])
.then(() => {
closeApplication();
})
.catch(error => {
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
Source: data.Source,
}, error);
});
} else if (data.Source.toLocaleLowerCase().endsWith('.appimage')) {
// TODO Generate and execute script with delay
/*helpers
.executeAsync(data.Source)
.then(() => {
closeApplication();
})
.catch(error => {
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
Source: data.Source,
}, error);
});*/
} else {
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
Source: data.Source,
}, Error('Unsupported upgrade: ' + data.Source));
}
});
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {

View File

@@ -134,7 +134,7 @@ module.exports.executeAsync = (command, args=[]) => {
reject(err, pid);
} else {
clearTimeout(timeout);
setTimeout(()=>launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
setTimeout(()=> launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
}
});

View File

@@ -153,6 +153,30 @@ class App extends Component {
}
};
extractFileNameFromURL = url => {
const parts = url.split('/');
return parts[parts.length - 1];
};
extractRelease = (data) => {
if (data.Success) {
const selectedVersion = this.getSelectedVersion();
ipcRenderer.send(Constants.IPC_Extract_Release, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Source: data.Destination,
Version: selectedVersion,
});
}
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingRelease: false,
ExtractActive: data.Success,
DownloadName: '',
});
};
getSelectedVersion = () => {
return this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
};
@@ -204,13 +228,10 @@ class App extends Component {
handleDependencyDownload = (url) => {
if (ipcRenderer) {
const items = url.split('/');
const fileName = items[items.length - 1];
this.setState({
DownloadActive: true,
DownloadingDependency: true,
DownloadName: fileName,
DownloadName: this.extractFileNameFromURL(url),
}, ()=> {
ipcRenderer.send(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
@@ -270,10 +291,11 @@ class App extends Component {
DownloadingUpgrade: true,
DownloadName: 'UI Upgrade',
}, ()=> {
const url = this.state.UpgradeData.urls[0];
ipcRenderer.send(Constants.IPC_Download_File, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : 'upgrade',
URL: this.state.UpgradeData.urls[0],
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
URL: url,
});
});
} else {
@@ -290,6 +312,37 @@ class App extends Component {
});
};
installDependency = data => {
if (data.Success) {
ipcRenderer.send(Constants.IPC_Install_Dependency, {
Source: data.Destination,
URL: data.URL,
});
}
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingDependency: data.Success,
DownloadName: '',
});
};
installUpgrade = data => {
if (data.Success) {
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
Source: data.Destination,
});
} else {
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingUpgrade: false,
DownloadName: '',
});
}
};
notifyAutoMountProcessed = () => {
this.setState({AutoMountProcessed: true});
};
@@ -330,49 +383,11 @@ class App extends Component {
onDownloadFileComplete = (event, arg) => {
if (this.state.DownloadingRelease) {
if (arg.data.Success) {
const selectedVersion = this.getSelectedVersion();
ipcRenderer.send(Constants.IPC_Extract_Release, {
Directory: Constants.DATA_LOCATIONS[this.props.platform],
Source: arg.data.Destination,
Version: selectedVersion,
});
}
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingRelease: false,
ExtractActive: arg.data.Success,
DownloadName: '',
});
this.extractRelease(arg.data);
} else if (this.state.DownloadingDependency) {
if (arg.data.Success) {
ipcRenderer.send(Constants.IPC_Install_Dependency, {
Source: arg.data.Destination,
URL: arg.data.URL,
});
}
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingDependency: arg.data.Success,
DownloadName: '',
});
this.installDependency(arg.data);
} else if (this.state.DownloadingUpgrade) {
if (arg.data.Success) {
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
Source: arg.data.Destination,
});
} else {
this.setState({
DownloadActive: false,
DownloadProgress: 0.0,
DownloadingUpgrade: false,
DownloadName: '',
});
}
this.installUpgrade(arg.data);
} else {
this.setState({
DownloadActive: false,
@@ -446,7 +461,8 @@ class App extends Component {
});
};
axios.get(Constants.RELEASES_URL)
axios
.get(Constants.RELEASES_URL)
.then(response => {
const versionLookup = {
Alpha: response.data.Versions.Alpha[this.props.platform],
@@ -479,7 +495,8 @@ class App extends Component {
};
onGrabUiReleasesReply = ()=> {
axios.get(Constants.UI_RELEASES_URL)
axios
.get(Constants.UI_RELEASES_URL)
.then(response => {
const data = response.data;
if (data.Versions &&