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
47 lines
1.4 KiB
TypeScript
47 lines
1.4 KiB
TypeScript
/**
|
|
* 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);
|