Fix Linux dev mode and updater
This commit is contained in:
parent
7266a46c66
commit
cbabc0c38e
4 changed files with 39 additions and 13 deletions
|
@ -80,7 +80,7 @@
|
|||
"dom-scroll-into-view": "^1.2.1",
|
||||
"electron": "4.1.0",
|
||||
"electron-builder": "^20.38.4",
|
||||
"electron-devtools-installer": "^2.2.3",
|
||||
"electron-devtools-installer": "^2.2.4",
|
||||
"electron-is-dev": "^0.3.0",
|
||||
"electron-publisher-s3": "^20.8.1",
|
||||
"electron-webpack": "^2.6.2",
|
||||
|
|
|
@ -86,7 +86,24 @@ app.on('ready', async() => {
|
|||
startSandbox();
|
||||
|
||||
if (isDev) {
|
||||
await installExtensions();
|
||||
//await installExtensions();
|
||||
const {
|
||||
default: installExtension,
|
||||
REACT_DEVELOPER_TOOLS,
|
||||
REDUX_DEVTOOLS, REACT_PERF,
|
||||
} = require('electron-devtools-installer');
|
||||
|
||||
await installExtension(REACT_DEVELOPER_TOOLS)
|
||||
.then((name) => console.log(`Added Extension: ${name}`))
|
||||
.catch((err) => console.log('An error occurred: ', err));
|
||||
|
||||
await installExtension(REDUX_DEVTOOLS)
|
||||
.then((name) => console.log(`Added Extension: ${name}`))
|
||||
.catch((err) => console.log('An error occurred: ', err));
|
||||
|
||||
await installExtension(REACT_PERF)
|
||||
.then((name) => console.log(`Added Extension: ${name}`))
|
||||
.catch((err) => console.log('An error occurred: ', err));
|
||||
}
|
||||
|
||||
rendererWindow = createWindow(appState);
|
||||
|
@ -208,12 +225,6 @@ ipcMain.on('version-info-requested', () => {
|
|||
}
|
||||
|
||||
const localVersion = pjson.version;
|
||||
const latestReleaseAPIURL = 'https://api.github.com/repos/lbryio/lbry-desktop/releases/latest';
|
||||
const opts = {
|
||||
headers: {
|
||||
'User-Agent': `LBRY/${localVersion}`,
|
||||
},
|
||||
};
|
||||
let result = '';
|
||||
const onSuccess = res => {
|
||||
res.on('data', data => {
|
||||
|
@ -221,7 +232,13 @@ ipcMain.on('version-info-requested', () => {
|
|||
});
|
||||
|
||||
res.on('end', () => {
|
||||
const tagName = JSON.parse(result).tag_name;
|
||||
let json;
|
||||
try {
|
||||
json = JSON.parse(result);
|
||||
} catch(e) {
|
||||
return;
|
||||
}
|
||||
const tagName = json.tag_name;
|
||||
if (tagName) {
|
||||
const [, remoteVersion] = tagName.match(/^v([\d.]+(?:-?rc\d+)?)$/);
|
||||
if (!remoteVersion) {
|
||||
|
@ -244,8 +261,12 @@ ipcMain.on('version-info-requested', () => {
|
|||
});
|
||||
};
|
||||
|
||||
const requestLatestRelease = (apiUrl, alreadyRedirected = false) => {
|
||||
const req = https.get(Object.assign(opts, new url.URL(apiUrl)), res => {
|
||||
const requestLatestRelease = (alreadyRedirected = false) => {
|
||||
const req = https.get({
|
||||
hostname: 'api.github.com',
|
||||
path: '/repos/lbryio/lbry-desktop/releases/latest',
|
||||
headers: { 'user-agent': 'LBRY/0.29.4' },
|
||||
}, res => {
|
||||
if (res.statusCode === 301 || res.statusCode === 302) {
|
||||
requestLatestRelease(res.headers.location, true);
|
||||
} else {
|
||||
|
@ -262,7 +283,7 @@ ipcMain.on('version-info-requested', () => {
|
|||
});
|
||||
};
|
||||
|
||||
requestLatestRelease(latestReleaseAPIURL);
|
||||
requestLatestRelease();
|
||||
});
|
||||
|
||||
ipcMain.on('get-auth-token', event => {
|
||||
|
@ -276,6 +297,7 @@ ipcMain.on('set-auth-token', (event, token) => {
|
|||
});
|
||||
|
||||
process.on('uncaughtException', error => {
|
||||
console.log(error);
|
||||
dialog.showErrorBox('Error Encountered', `Caught error: ${error}`);
|
||||
appState.isQuitting = true;
|
||||
if (daemon) daemon.quit();
|
||||
|
|
|
@ -55,6 +55,8 @@ if (process.env.NODE_ENV === 'production') {
|
|||
externals: {
|
||||
keytar: 'require("keytar")',
|
||||
electron: 'require("electron")',
|
||||
express: 'require("express")',
|
||||
'electron-updater': 'require("electron-updater")',
|
||||
},
|
||||
});
|
||||
} else {
|
||||
|
@ -64,6 +66,8 @@ if (process.env.NODE_ENV === 'production') {
|
|||
externals: {
|
||||
keytar: 'require("keytar")',
|
||||
electron: 'require("electron")',
|
||||
express: 'require("express")',
|
||||
'electron-updater': 'require("electron-updater")',
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
|
@ -3378,7 +3378,7 @@ electron-builder@^20.38.4:
|
|||
update-notifier "^2.5.0"
|
||||
yargs "^12.0.5"
|
||||
|
||||
electron-devtools-installer@^2.2.3, electron-devtools-installer@^2.2.4:
|
||||
electron-devtools-installer@^2.2.4:
|
||||
version "2.2.4"
|
||||
resolved "https://registry.yarnpkg.com/electron-devtools-installer/-/electron-devtools-installer-2.2.4.tgz#261a50337e37121d338b966f07922eb4939a8763"
|
||||
integrity sha512-b5kcM3hmUqn64+RUcHjjr8ZMpHS2WJ5YO0pnG9+P/RTdx46of/JrEjuciHWux6pE+On6ynWhHJF53j/EDJN0PA==
|
||||
|
|
Loading…
Reference in a new issue