OS X installation support
This commit is contained in:
51
electron.js
51
electron.js
@@ -310,7 +310,7 @@ ipcMain.on(Constants.IPC_Detect_Mounts, (event, data) => {
|
|||||||
|
|
||||||
const setImage = (locations) => {
|
const setImage = (locations) => {
|
||||||
if (os.platform() === 'win32' || os.platform() === 'linux') {
|
if (os.platform() === 'win32' || os.platform() === 'linux') {
|
||||||
let driveInUse = false;
|
let driveInUse;
|
||||||
for (const provider of Constants.PROVIDER_LIST) {
|
for (const provider of Constants.PROVIDER_LIST) {
|
||||||
driveInUse = locations[provider].length > 0;
|
driveInUse = locations[provider].length > 0;
|
||||||
if (driveInUse)
|
if (driveInUse)
|
||||||
@@ -504,16 +504,45 @@ ipcMain.on(Constants.IPC_Install_Dependency, (event, data) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
ipcMain.on(Constants.IPC_Install_Upgrade, (event, data) => {
|
||||||
helpers
|
if (os.platform() === 'win32') {
|
||||||
.executeAsync(data.Source)
|
helpers
|
||||||
.then(()=> {
|
.executeAsync(data.Source)
|
||||||
mainWindow.close();
|
.then(() => {
|
||||||
})
|
closeApplication();
|
||||||
.catch(error => {
|
})
|
||||||
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
|
.catch(error => {
|
||||||
Source: data.Source,
|
standardIPCReply(event, Constants.IPC_Install_Upgrade_Reply, {
|
||||||
}, error);
|
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) => {
|
ipcMain.on(Constants.IPC_Mount_Drive, (event, data) => {
|
||||||
|
|||||||
@@ -134,7 +134,7 @@ module.exports.executeAsync = (command, args=[]) => {
|
|||||||
reject(err, pid);
|
reject(err, pid);
|
||||||
} else {
|
} else {
|
||||||
clearTimeout(timeout);
|
clearTimeout(timeout);
|
||||||
setTimeout(()=>launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
|
setTimeout(()=> launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
197
src/App.js
197
src/App.js
@@ -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 = () => {
|
getSelectedVersion = () => {
|
||||||
return this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
return this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
||||||
};
|
};
|
||||||
@@ -204,13 +228,10 @@ class App extends Component {
|
|||||||
|
|
||||||
handleDependencyDownload = (url) => {
|
handleDependencyDownload = (url) => {
|
||||||
if (ipcRenderer) {
|
if (ipcRenderer) {
|
||||||
const items = url.split('/');
|
|
||||||
const fileName = items[items.length - 1];
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
DownloadActive: true,
|
DownloadActive: true,
|
||||||
DownloadingDependency: true,
|
DownloadingDependency: true,
|
||||||
DownloadName: fileName,
|
DownloadName: this.extractFileNameFromURL(url),
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
ipcRenderer.send(Constants.IPC_Download_File, {
|
ipcRenderer.send(Constants.IPC_Download_File, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
||||||
@@ -270,10 +291,11 @@ class App extends Component {
|
|||||||
DownloadingUpgrade: true,
|
DownloadingUpgrade: true,
|
||||||
DownloadName: 'UI Upgrade',
|
DownloadName: 'UI Upgrade',
|
||||||
}, ()=> {
|
}, ()=> {
|
||||||
|
const url = this.state.UpgradeData.urls[0];
|
||||||
ipcRenderer.send(Constants.IPC_Download_File, {
|
ipcRenderer.send(Constants.IPC_Download_File, {
|
||||||
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
Directory: Constants.DATA_LOCATIONS[this.props.platform],
|
||||||
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : 'upgrade',
|
Filename: this.props.platform === 'win32' ? 'upgrade.exe' : this.extractFileNameFromURL(url),
|
||||||
URL: this.state.UpgradeData.urls[0],
|
URL: url,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
} else {
|
} 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 = () => {
|
notifyAutoMountProcessed = () => {
|
||||||
this.setState({AutoMountProcessed: true});
|
this.setState({AutoMountProcessed: true});
|
||||||
};
|
};
|
||||||
@@ -330,49 +383,11 @@ class App extends Component {
|
|||||||
|
|
||||||
onDownloadFileComplete = (event, arg) => {
|
onDownloadFileComplete = (event, arg) => {
|
||||||
if (this.state.DownloadingRelease) {
|
if (this.state.DownloadingRelease) {
|
||||||
if (arg.data.Success) {
|
this.extractRelease(arg.data);
|
||||||
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: '',
|
|
||||||
});
|
|
||||||
} else if (this.state.DownloadingDependency) {
|
} else if (this.state.DownloadingDependency) {
|
||||||
if (arg.data.Success) {
|
this.installDependency(arg.data);
|
||||||
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: '',
|
|
||||||
});
|
|
||||||
} else if (this.state.DownloadingUpgrade) {
|
} else if (this.state.DownloadingUpgrade) {
|
||||||
if (arg.data.Success) {
|
this.installUpgrade(arg.data);
|
||||||
ipcRenderer.send(Constants.IPC_Install_Upgrade, {
|
|
||||||
Source: arg.data.Destination,
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.setState({
|
|
||||||
DownloadActive: false,
|
|
||||||
DownloadProgress: 0.0,
|
|
||||||
DownloadingUpgrade: false,
|
|
||||||
DownloadName: '',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
DownloadActive: false,
|
DownloadActive: false,
|
||||||
@@ -446,58 +461,60 @@ class App extends Component {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
axios.get(Constants.RELEASES_URL)
|
axios
|
||||||
.then(response => {
|
.get(Constants.RELEASES_URL)
|
||||||
const versionLookup = {
|
.then(response => {
|
||||||
Alpha: response.data.Versions.Alpha[this.props.platform],
|
const versionLookup = {
|
||||||
Beta: response.data.Versions.Beta[this.props.platform],
|
Alpha: response.data.Versions.Alpha[this.props.platform],
|
||||||
RC: response.data.Versions.RC[this.props.platform],
|
Beta: response.data.Versions.Beta[this.props.platform],
|
||||||
Release: response.data.Versions.Release[this.props.platform],
|
RC: response.data.Versions.RC[this.props.platform],
|
||||||
};
|
Release: response.data.Versions.Release[this.props.platform],
|
||||||
const locationsLookup = {
|
};
|
||||||
...response.data.Locations[this.props.platform],
|
const locationsLookup = {
|
||||||
};
|
...response.data.Locations[this.props.platform],
|
||||||
|
};
|
||||||
|
|
||||||
window.localStorage.setItem('releases', JSON.stringify({
|
window.localStorage.setItem('releases', JSON.stringify({
|
||||||
LocationsLookup: locationsLookup,
|
LocationsLookup: locationsLookup,
|
||||||
VersionLookup: versionLookup
|
VersionLookup: versionLookup
|
||||||
}));
|
}));
|
||||||
|
|
||||||
doUpdate(locationsLookup, versionLookup);
|
|
||||||
}).catch(error => {
|
|
||||||
const releases = window.localStorage.getItem('releases');
|
|
||||||
if (releases && (releases.length > 0)) {
|
|
||||||
const obj = JSON.parse(releases);
|
|
||||||
const locationsLookup = obj.LocationsLookup;
|
|
||||||
const versionLookup = obj.VersionLookup;
|
|
||||||
|
|
||||||
doUpdate(locationsLookup, versionLookup);
|
doUpdate(locationsLookup, versionLookup);
|
||||||
} else {
|
}).catch(error => {
|
||||||
this.setErrorState(error, null, true);
|
const releases = window.localStorage.getItem('releases');
|
||||||
}
|
if (releases && (releases.length > 0)) {
|
||||||
});
|
const obj = JSON.parse(releases);
|
||||||
|
const locationsLookup = obj.LocationsLookup;
|
||||||
|
const versionLookup = obj.VersionLookup;
|
||||||
|
|
||||||
|
doUpdate(locationsLookup, versionLookup);
|
||||||
|
} else {
|
||||||
|
this.setErrorState(error, null, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
onGrabUiReleasesReply = ()=> {
|
onGrabUiReleasesReply = ()=> {
|
||||||
axios.get(Constants.UI_RELEASES_URL)
|
axios
|
||||||
.then(response => {
|
.get(Constants.UI_RELEASES_URL)
|
||||||
const data = response.data;
|
.then(response => {
|
||||||
if (data.Versions &&
|
const data = response.data;
|
||||||
data.Versions[this.props.platform] &&
|
if (data.Versions &&
|
||||||
(data.Versions[this.props.platform].length > 0) &&
|
data.Versions[this.props.platform] &&
|
||||||
(data.Versions[this.props.platform][0] !== this.props.version)) {
|
(data.Versions[this.props.platform].length > 0) &&
|
||||||
|
(data.Versions[this.props.platform][0] !== this.props.version)) {
|
||||||
|
this.setState({
|
||||||
|
UpgradeAvailable: true,
|
||||||
|
UpgradeDismissed: false,
|
||||||
|
UpgradeData: data.Locations[this.props.platform][data.Versions[this.props.platform][0]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).catch(() => {
|
||||||
this.setState({
|
this.setState({
|
||||||
UpgradeAvailable: true,
|
UpgradeAvailable: false,
|
||||||
UpgradeDismissed: false,
|
UpgradeData: {},
|
||||||
UpgradeData: data.Locations[this.props.platform][data.Versions[this.props.platform][0]],
|
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}).catch(() => {
|
|
||||||
this.setState({
|
|
||||||
UpgradeAvailable: false,
|
|
||||||
UpgradeData: {},
|
|
||||||
});
|
});
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onInstallDependencyReply = (event, arg) => {
|
onInstallDependencyReply = (event, arg) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user