mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
chore(package.json): upgrade bitsocial-react-hooks, stop yarn install from depending on kubo postinstall (#1090)
Removes the direct `kubo` install-time dependency and switches Electron dev to the repo-managed Kubo downloader in `electron/start-ipfs.js`. This keeps the hooks upgrade in place while avoiding the `dist.ipfs.tech` timeout during `yarn install`.
This commit is contained in:
+10
-5
@@ -10,6 +10,7 @@ const ipfsClientsPath = path.join(path.dirname(fileURLToPath(import.meta.url)),
|
||||
const ipfsClientWindowsPath = path.join(ipfsClientsPath, 'win');
|
||||
const ipfsClientMacPath = path.join(ipfsClientsPath, 'mac');
|
||||
const ipfsClientLinuxPath = path.join(ipfsClientsPath, 'linux');
|
||||
const kuboReleaseBaseUrl = 'https://github.com/ipfs/kubo/releases/download';
|
||||
|
||||
// plebbit kubo download links https://github.com/plebbit/kubo/releases
|
||||
// const ipfsClientVersion = '0.20.0'
|
||||
@@ -17,7 +18,6 @@ const ipfsClientLinuxPath = path.join(ipfsClientsPath, 'linux');
|
||||
// const ipfsClientMacUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-darwin-amd64`
|
||||
// const ipfsClientLinuxUrl = `https://github.com/plebbit/kubo/releases/download/v${ipfsClientVersion}/ipfs-linux-amd64`
|
||||
|
||||
// NOTE: Keep this version in sync with the kubo version in package.json to avoid repo version mismatches
|
||||
const ipfsClientVersion = '0.39.0';
|
||||
|
||||
// Resolve desired build arch: allow overriding via env (so cross-arch builds pick correct binary)
|
||||
@@ -33,11 +33,11 @@ const toKuboArch = (arch) => (arch === 'arm64' ? 'arm64' : 'amd64');
|
||||
|
||||
const getKuboUrl = (platform) => {
|
||||
const arch = toKuboArch(resolveBuildArch());
|
||||
if (platform === 'win32') return `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_windows-${arch}.zip`;
|
||||
if (platform === 'darwin') return `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_darwin-${arch}.tar.gz`;
|
||||
if (platform === 'linux') return `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-${arch}.tar.gz`;
|
||||
if (platform === 'win32') return `${kuboReleaseBaseUrl}/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_windows-${arch}.zip`;
|
||||
if (platform === 'darwin') return `${kuboReleaseBaseUrl}/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_darwin-${arch}.tar.gz`;
|
||||
if (platform === 'linux') return `${kuboReleaseBaseUrl}/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-${arch}.tar.gz`;
|
||||
// default to linux
|
||||
return `https://dist.ipfs.io/kubo/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-${arch}.tar.gz`;
|
||||
return `${kuboReleaseBaseUrl}/v${ipfsClientVersion}/kubo_v${ipfsClientVersion}_linux-${arch}.tar.gz`;
|
||||
};
|
||||
|
||||
const downloadWithProgress = (url) =>
|
||||
@@ -61,6 +61,11 @@ const downloadWithProgress = (url) =>
|
||||
return;
|
||||
}
|
||||
|
||||
if (!res.statusCode || res.statusCode >= 400) {
|
||||
reject(new Error(`Download request for ${url} failed with status ${res.statusCode ?? 'unknown'}`));
|
||||
return;
|
||||
}
|
||||
|
||||
const len = parseInt(res.headers['content-length'], 10);
|
||||
console.log();
|
||||
const bar = new ProgressBar(` ${fileName} [:bar] :rate/bps :percent :etas`, {
|
||||
|
||||
+21
-5
@@ -7,6 +7,7 @@ import proxyServer from './proxy-server.js';
|
||||
import tcpPortUsed from 'tcp-port-used';
|
||||
import EnvPaths from 'env-paths';
|
||||
import { fileURLToPath, pathToFileURL } from 'url';
|
||||
import { downloadIpfsClients } from './before-pack.js';
|
||||
const dirname = path.join(path.dirname(fileURLToPath(import.meta.url)));
|
||||
const envPaths = EnvPaths('plebbit', { suffix: false });
|
||||
|
||||
@@ -20,21 +21,36 @@ const getPlatformDir = () => {
|
||||
return 'linux';
|
||||
};
|
||||
|
||||
const getBundledKuboPath = (rootPath) => path.join(rootPath, 'bin', getPlatformDir(), getIpfsBinaryName());
|
||||
|
||||
// Resolve kubo binary path
|
||||
const getKuboPath = async () => {
|
||||
if (isDev) {
|
||||
// In dev, use kubo from node_modules
|
||||
const { path: getKuboBinaryPath } = await import('kubo');
|
||||
return getKuboBinaryPath();
|
||||
if (process.env.KUBO_BINARY) {
|
||||
return process.env.KUBO_BINARY;
|
||||
}
|
||||
|
||||
const bundledKuboPath = getBundledKuboPath(path.join(dirname, '..'));
|
||||
if (fs.existsSync(bundledKuboPath)) {
|
||||
return bundledKuboPath;
|
||||
}
|
||||
|
||||
console.log(`Kubo binary missing at ${bundledKuboPath}, downloading repo-managed binary...`);
|
||||
await downloadIpfsClients();
|
||||
|
||||
if (fs.existsSync(bundledKuboPath)) {
|
||||
return bundledKuboPath;
|
||||
}
|
||||
|
||||
throw new Error(`Kubo binary download completed but '${bundledKuboPath}' was not found`);
|
||||
} else {
|
||||
// In production, the binary is downloaded to bin/<platform>/ipfs by generateAssets hook
|
||||
// With asar: false, files are at resources/app/ instead of resources/app.asar.unpacked
|
||||
const appPath = process.resourcesPath;
|
||||
const binaryName = getIpfsBinaryName();
|
||||
const platformDir = getPlatformDir();
|
||||
|
||||
// Try the bin/ directory first (where generateAssets downloads binaries)
|
||||
const binDirPath = path.join(appPath, 'app', 'bin', platformDir, binaryName);
|
||||
const binDirPath = getBundledKuboPath(path.join(appPath, 'app'));
|
||||
if (fs.existsSync(binDirPath)) {
|
||||
return binDirPath;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user