mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(electron): upgrade ipfs version
This commit is contained in:
+38
-17
@@ -10,12 +10,17 @@ const ipfsClientWindowsPath = path.join(ipfsClientsPath, 'win');
|
||||
const ipfsClientMacPath = path.join(ipfsClientsPath, 'mac');
|
||||
const ipfsClientLinuxPath = path.join(ipfsClientsPath, 'linux');
|
||||
|
||||
// kubo download links https://docs.ipfs.tech/install/command-line/#install-official-binary-distributions
|
||||
// plebbit kubu download links https://github.com/plebbit/kubo/releases
|
||||
const ipfsClientVersion = '0.20.0';
|
||||
const ipfsClientWindowsUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-windows-amd64`;
|
||||
const ipfsClientMacUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-darwin-amd64`;
|
||||
const ipfsClientLinuxPUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-linux-amd64`;
|
||||
// const ipfsClientVersion = '0.20.0'
|
||||
// const ipfsClientWindowsUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-windows-amd64`
|
||||
// const ipfsClientMacUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-darwin-amd64`
|
||||
// const ipfsClientLinuxPUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-linux-amd64`
|
||||
|
||||
// official kubo download links https://docs.ipfs.tech/install/command-line/#install-official-binary-distributions
|
||||
const ipfsClientVersion = '0.24.0';
|
||||
const ipfsClientWindowsUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_windows-amd64.zip`;
|
||||
const ipfsClientMacUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_darwin-amd64.tar.gz`;
|
||||
const ipfsClientLinuxPUrl = `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-amd64.tar.gz`;
|
||||
|
||||
const downloadWithProgress = (url) =>
|
||||
new Promise((resolve) => {
|
||||
@@ -50,6 +55,7 @@ const downloadWithProgress = (url) =>
|
||||
req.end();
|
||||
});
|
||||
|
||||
// plebbit kubo downloads dont need to be extracted
|
||||
const download = async (url, destinationPath) => {
|
||||
let binName = 'ipfs';
|
||||
if (destinationPath.endsWith('win')) {
|
||||
@@ -66,24 +72,39 @@ const download = async (url, destinationPath) => {
|
||||
const file = await downloadWithProgress(url);
|
||||
fs.ensureDirSync(destinationPath);
|
||||
await fs.writeFile(binPath, file);
|
||||
};
|
||||
|
||||
// decompress
|
||||
// await fs.writeFile(dowloadPath, file);
|
||||
// await decompress(dowloadPath, destinationPath);
|
||||
// const extractedPath = path.join(destinationPath, 'kubo');
|
||||
// const extractedBinPath = path.join(extractedPath, binName);
|
||||
// fs.moveSync(extractedBinPath, binPath);
|
||||
// fs.removeSync(extractedPath);
|
||||
// fs.removeSync(dowloadPath);
|
||||
// official kubo downloads need to be extracted
|
||||
const downloadAndExtract = async (url, destinationPath) => {
|
||||
let binName = 'ipfs';
|
||||
if (destinationPath.endsWith('win')) {
|
||||
binName += '.exe';
|
||||
}
|
||||
const binPath = path.join(destinationPath, binName);
|
||||
if (fs.pathExistsSync(binPath)) {
|
||||
return;
|
||||
}
|
||||
const split = url.split('/');
|
||||
const fileName = split[split.length - 1];
|
||||
const dowloadPath = path.join(destinationPath, fileName);
|
||||
const file = await downloadWithProgress(url);
|
||||
fs.ensureDirSync(destinationPath);
|
||||
await fs.writeFile(dowloadPath, file);
|
||||
await decompress(dowloadPath, destinationPath);
|
||||
const extractedPath = path.join(destinationPath, 'kubo');
|
||||
const extractedBinPath = path.join(extractedPath, binName);
|
||||
fs.moveSync(extractedBinPath, binPath);
|
||||
fs.removeSync(extractedPath);
|
||||
fs.removeSync(dowloadPath);
|
||||
};
|
||||
|
||||
const downloadIpfsClients = async () => {
|
||||
await download(ipfsClientWindowsUrl, ipfsClientWindowsPath);
|
||||
await download(ipfsClientMacUrl, ipfsClientMacPath);
|
||||
await download(ipfsClientLinuxPUrl, ipfsClientLinuxPath);
|
||||
await downloadAndExtract(ipfsClientWindowsUrl, ipfsClientWindowsPath);
|
||||
await downloadAndExtract(ipfsClientMacUrl, ipfsClientMacPath);
|
||||
await downloadAndExtract(ipfsClientLinuxPUrl, ipfsClientLinuxPath);
|
||||
};
|
||||
|
||||
exports.downloadIpfsClients = downloadIpfsClients
|
||||
exports.downloadIpfsClients = downloadIpfsClients;
|
||||
|
||||
exports.default = async (context) => {
|
||||
await downloadIpfsClients();
|
||||
|
||||
Reference in New Issue
Block a user