Upgrade electron version
Summary: CHANGELOG: Upgrade electron to 18.2.0. In Electron 18.2.0 we no longer have access to `remote`. Instead, we are recommended to implement IPC communications. We re-implement `remote` methods used before as IPC commands. To support type-safe execution of the commands, we create electron IPC clients on both sides: the main process and renderer process. We also move the main menu creation to the main process and track its usage via sending IPC messages to the renderer process where the logging happens. Reviewed By: mweststrate Differential Revision: D36593625 fbshipit-source-id: 6dcf531461ef2edceb9cac372a650f84f3370953
This commit is contained in:
committed by
Facebook GitHub Bot
parent
2fe7e73175
commit
92cdb81096
46
desktop/scripts/get-electron-cache-directory.tsx
Normal file
46
desktop/scripts/get-electron-cache-directory.tsx
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @format
|
||||
*/
|
||||
|
||||
import yargs from 'yargs';
|
||||
import * as crypto from 'crypto';
|
||||
import * as path from 'path';
|
||||
import * as url from 'url';
|
||||
|
||||
const argv = yargs
|
||||
.usage('$0 [args]')
|
||||
.options({
|
||||
electronVersion: {
|
||||
key: 'electronVersion',
|
||||
alias: 'v',
|
||||
type: 'string',
|
||||
demandOption: true,
|
||||
},
|
||||
})
|
||||
.help().argv;
|
||||
|
||||
// https://github.com/electron/get/blob/1671db2120142d7850260b098db72b0ef5ee988c/src/Cache.ts#L23
|
||||
const getCacheDirectory = (downloadUrl: string): string => {
|
||||
const parsedDownloadUrl = url.parse(downloadUrl);
|
||||
const {search, hash, pathname, ...rest} = parsedDownloadUrl;
|
||||
const strippedUrl = url.format({
|
||||
...rest,
|
||||
pathname: path.dirname(pathname || 'electron'),
|
||||
});
|
||||
|
||||
return crypto.createHash('sha256').update(strippedUrl).digest('hex');
|
||||
};
|
||||
|
||||
const getUrl = ({electronVersion}: {electronVersion: string}) => {
|
||||
// It is going to be stripped to https://github.com/electron/electron/releases/download/v${electronVersion}, so it is going to be the same for all platforms
|
||||
const url = `https://github.com/electron/electron/releases/download/v${electronVersion}/electron-v${electronVersion}-linux-x64.zip`;
|
||||
return getCacheDirectory(url);
|
||||
};
|
||||
|
||||
const folderName = getUrl(argv);
|
||||
console.log(folderName);
|
||||
Reference in New Issue
Block a user