mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
bonfida resolutions shouldn't be needed
This commit is contained in:
@@ -47,7 +47,6 @@
|
|||||||
"kubo": "0.39.0"
|
"kubo": "0.39.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"postinstall": "node scripts/fix-bonfida-imports.js",
|
|
||||||
"generate:assets": "node scripts/generate-asset-manifest.js",
|
"generate:assets": "node scripts/generate-asset-manifest.js",
|
||||||
"prebuild": "yarn generate:assets",
|
"prebuild": "yarn generate:assets",
|
||||||
"prestart": "yarn generate:assets",
|
"prestart": "yarn generate:assets",
|
||||||
@@ -139,8 +138,6 @@
|
|||||||
"wait-on": "9.0.3"
|
"wait-on": "9.0.3"
|
||||||
},
|
},
|
||||||
"resolutions": {
|
"resolutions": {
|
||||||
"@bonfida/spl-name-service": "3.0.16",
|
|
||||||
"@bonfida/sns-records": "0.0.1",
|
|
||||||
"js-yaml": "4.1.1",
|
"js-yaml": "4.1.1",
|
||||||
"baseline-browser-mapping": "^2.9.11",
|
"baseline-browser-mapping": "^2.9.11",
|
||||||
"vite": "npm:rolldown-vite@7.3.1",
|
"vite": "npm:rolldown-vite@7.3.1",
|
||||||
|
|||||||
@@ -1,140 +0,0 @@
|
|||||||
#!/usr/bin/env node
|
|
||||||
// Fix broken ESM imports in @bonfida/spl-name-service
|
|
||||||
// The package ships with hardcoded ../node_modules/ paths that break in electron asar
|
|
||||||
|
|
||||||
import fs from 'fs';
|
|
||||||
import path from 'path';
|
|
||||||
import { fileURLToPath } from 'url';
|
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
||||||
const rootDir = path.join(__dirname, '..');
|
|
||||||
const bonfidaEsmDir = path.join(rootDir, 'node_modules/@bonfida/spl-name-service/dist/esm');
|
|
||||||
const bonfidaCjsDir = path.join(rootDir, 'node_modules/@bonfida/spl-name-service/dist/cjs');
|
|
||||||
|
|
||||||
// Map of known packages to their correct import paths
|
|
||||||
const packageMappings = {
|
|
||||||
'@noble/hashes': (subpath) => {
|
|
||||||
// ../node_modules/@noble/hashes/esm/sha256.js -> @noble/hashes/sha256
|
|
||||||
if (subpath.includes('/sha256')) return '@noble/hashes/sha256';
|
|
||||||
if (subpath.includes('/sha512')) return '@noble/hashes/sha512';
|
|
||||||
return '@noble/hashes';
|
|
||||||
},
|
|
||||||
'@noble/curves': (subpath) => {
|
|
||||||
// ../node_modules/@noble/curves/esm/ed25519.js -> @noble/curves/ed25519
|
|
||||||
if (subpath.includes('/ed25519')) return '@noble/curves/ed25519';
|
|
||||||
if (subpath.includes('/secp256k1')) return '@noble/curves/secp256k1';
|
|
||||||
return '@noble/curves';
|
|
||||||
},
|
|
||||||
'@solana/spl-token': () => '@solana/spl-token',
|
|
||||||
'@solana/web3.js': () => '@solana/web3.js',
|
|
||||||
'@bonfida/sns-records': () => '@bonfida/sns-records',
|
|
||||||
'@scure/base': () => '@scure/base',
|
|
||||||
buffer: () => 'buffer',
|
|
||||||
borsh: () => 'borsh',
|
|
||||||
graphemesplit: () => 'graphemesplit',
|
|
||||||
bs58: () => 'bs58',
|
|
||||||
'ipaddr.js': () => 'ipaddr.js',
|
|
||||||
punycode: () => 'punycode',
|
|
||||||
};
|
|
||||||
|
|
||||||
// Generic function to fix node_modules imports
|
|
||||||
function fixImportsInContent(content) {
|
|
||||||
// Match patterns like from"../node_modules/PACKAGE/..." or from"./node_modules/PACKAGE/..."
|
|
||||||
const importPattern = /from\s*["'](\.\.?\/node_modules\/((?:@[^\/]+\/[^\/]+|[^\/]+))([^"']*))["']/g;
|
|
||||||
const sideEffectPattern = /import\s*["'](\.\.?\/node_modules\/((?:@[^\/]+\/[^\/]+|[^\/]+))([^"']*))["']/g;
|
|
||||||
const requirePattern = /require\s*\(\s*["'](\.\.?\/node_modules\/((?:@[^\/]+\/[^\/]+|[^\/]+))([^"']*))["']\s*\)/g;
|
|
||||||
|
|
||||||
let modified = false;
|
|
||||||
|
|
||||||
const replaceImport = (match, fullPath, packageName, subpath) => {
|
|
||||||
modified = true;
|
|
||||||
const mapper = packageMappings[packageName];
|
|
||||||
const correctImport = mapper ? mapper(subpath) : packageName;
|
|
||||||
return `from"${correctImport}"`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const replaceSideEffect = (match, fullPath, packageName, subpath) => {
|
|
||||||
modified = true;
|
|
||||||
const mapper = packageMappings[packageName];
|
|
||||||
const correctImport = mapper ? mapper(subpath) : packageName;
|
|
||||||
return `import"${correctImport}"`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const replaceRequire = (match, fullPath, packageName, subpath) => {
|
|
||||||
modified = true;
|
|
||||||
const mapper = packageMappings[packageName];
|
|
||||||
const correctImport = mapper ? mapper(subpath) : packageName;
|
|
||||||
return `require("${correctImport}")`;
|
|
||||||
};
|
|
||||||
|
|
||||||
let result = content;
|
|
||||||
result = result.replace(importPattern, replaceImport);
|
|
||||||
result = result.replace(sideEffectPattern, replaceSideEffect);
|
|
||||||
result = result.replace(requirePattern, replaceRequire);
|
|
||||||
|
|
||||||
return { content: result, modified };
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixFile(filePath) {
|
|
||||||
if (!fs.existsSync(filePath)) return false;
|
|
||||||
|
|
||||||
const content = fs.readFileSync(filePath, 'utf8');
|
|
||||||
const result = fixImportsInContent(content);
|
|
||||||
|
|
||||||
if (result.modified) {
|
|
||||||
fs.writeFileSync(filePath, result.content);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
function fixDirectory(dir) {
|
|
||||||
if (!fs.existsSync(dir)) {
|
|
||||||
console.log(`Directory not found: ${dir}`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
let fixedCount = 0;
|
|
||||||
|
|
||||||
function walk(currentDir) {
|
|
||||||
const entries = fs.readdirSync(currentDir, { withFileTypes: true });
|
|
||||||
|
|
||||||
for (const entry of entries) {
|
|
||||||
const fullPath = path.join(currentDir, entry.name);
|
|
||||||
|
|
||||||
if (entry.isDirectory() && entry.name !== 'node_modules') {
|
|
||||||
walk(fullPath);
|
|
||||||
} else if (entry.isFile() && /\.(m?js|cjs)$/.test(entry.name)) {
|
|
||||||
if (fixFile(fullPath)) {
|
|
||||||
fixedCount++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
walk(dir);
|
|
||||||
return fixedCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Fixing @bonfida/spl-name-service broken imports...');
|
|
||||||
|
|
||||||
const esmFixed = fixDirectory(bonfidaEsmDir);
|
|
||||||
const cjsFixed = fixDirectory(bonfidaCjsDir);
|
|
||||||
|
|
||||||
console.log(`Fixed ${esmFixed} ESM files and ${cjsFixed} CJS files`);
|
|
||||||
|
|
||||||
// Also remove the nested node_modules that are no longer needed
|
|
||||||
const nestedEsm = path.join(bonfidaEsmDir, 'node_modules');
|
|
||||||
const nestedCjs = path.join(bonfidaCjsDir, 'node_modules');
|
|
||||||
|
|
||||||
if (fs.existsSync(nestedEsm)) {
|
|
||||||
fs.rmSync(nestedEsm, { recursive: true });
|
|
||||||
console.log('Removed nested ESM node_modules');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fs.existsSync(nestedCjs)) {
|
|
||||||
fs.rmSync(nestedCjs, { recursive: true });
|
|
||||||
console.log('Removed nested CJS node_modules');
|
|
||||||
}
|
|
||||||
|
|
||||||
console.log('Done!');
|
|
||||||
@@ -1012,18 +1012,18 @@
|
|||||||
bs58 "5.0.0"
|
bs58 "5.0.0"
|
||||||
buffer "^6.0.3"
|
buffer "^6.0.3"
|
||||||
|
|
||||||
"@bonfida/spl-name-service@3.0.10", "@bonfida/spl-name-service@3.0.16":
|
"@bonfida/spl-name-service@3.0.10":
|
||||||
version "3.0.16"
|
version "3.0.10"
|
||||||
resolved "https://registry.yarnpkg.com/@bonfida/spl-name-service/-/spl-name-service-3.0.16.tgz#5ebcadbb1908af9348ff15c20a4e4fdc8a1408da"
|
resolved "https://registry.yarnpkg.com/@bonfida/spl-name-service/-/spl-name-service-3.0.10.tgz#883f2e077eef7d91147f44ae383990a82479d5f8"
|
||||||
integrity sha512-Y47inKaoGYQ2gxykZsLepc0fNPMLWd5ycGQ6k2FiHvIzlY4trHijc7zr9TyDhB/eI9c3XTy5ItM01Izy5pIZ/A==
|
integrity sha512-CrqlEDz43K9fPIVaUXn29OiMWZUOs3+sxU7zHrlPjjdXn9GrJSVao5gjmflfK6tcwLxSSGC4F4GOg5erSfyR/A==
|
||||||
dependencies:
|
dependencies:
|
||||||
"@bonfida/sns-records" "0.0.1"
|
"@bonfida/sns-records" "0.0.1"
|
||||||
"@noble/curves" "^1.9.1"
|
"@noble/curves" "^1.4.0"
|
||||||
"@scure/base" "^1.2.5"
|
"@scure/base" "^1.1.6"
|
||||||
"@solana/spl-token" "0.4.6"
|
"@solana/spl-token" "0.4.6"
|
||||||
borsh "2.0.0"
|
borsh "2.0.0"
|
||||||
buffer "^6.0.3"
|
buffer "^6.0.3"
|
||||||
graphemesplit "^2.6.0"
|
graphemesplit "^2.4.4"
|
||||||
ipaddr.js "^2.2.0"
|
ipaddr.js "^2.2.0"
|
||||||
punycode "^2.3.1"
|
punycode "^2.3.1"
|
||||||
|
|
||||||
@@ -3981,7 +3981,7 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@noble/hashes" "1.8.0"
|
"@noble/hashes" "1.8.0"
|
||||||
|
|
||||||
"@noble/curves@^1.4.0", "@noble/curves@^1.4.2", "@noble/curves@^1.9.1", "@noble/curves@~1.9.0":
|
"@noble/curves@^1.4.0", "@noble/curves@^1.4.2", "@noble/curves@~1.9.0":
|
||||||
version "1.9.7"
|
version "1.9.7"
|
||||||
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951"
|
resolved "https://registry.yarnpkg.com/@noble/curves/-/curves-1.9.7.tgz#79d04b4758a43e4bca2cbdc62e7771352fa6b951"
|
||||||
integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==
|
integrity sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==
|
||||||
@@ -4667,7 +4667,7 @@
|
|||||||
estree-walker "^2.0.2"
|
estree-walker "^2.0.2"
|
||||||
picomatch "^4.0.2"
|
picomatch "^4.0.2"
|
||||||
|
|
||||||
"@scure/base@^1.2.5", "@scure/base@~1.2.5":
|
"@scure/base@^1.1.6", "@scure/base@~1.2.5":
|
||||||
version "1.2.6"
|
version "1.2.6"
|
||||||
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.6.tgz#ca917184b8231394dd8847509c67a0be522e59f6"
|
resolved "https://registry.yarnpkg.com/@scure/base/-/base-1.2.6.tgz#ca917184b8231394dd8847509c67a0be522e59f6"
|
||||||
integrity sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==
|
integrity sha512-g/nm5FgUa//MCj1gV09zTJTaM6KBAHqLN907YVQqf7zC49+DcO4B1so4ZX07Ef10Twr6nuqYEH9GEggFXA4Fmg==
|
||||||
@@ -8802,7 +8802,7 @@ graceful-fs@^4.1.10, graceful-fs@^4.1.15, graceful-fs@^4.1.2, graceful-fs@^4.1.6
|
|||||||
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
|
resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.11.tgz#4183e4e8bf08bb6e05bbb2f7d2e0c8f712ca40e3"
|
||||||
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
|
integrity sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==
|
||||||
|
|
||||||
graphemesplit@^2.6.0:
|
graphemesplit@^2.4.4:
|
||||||
version "2.6.0"
|
version "2.6.0"
|
||||||
resolved "https://registry.yarnpkg.com/graphemesplit/-/graphemesplit-2.6.0.tgz#548ec986e83dcdfec31adf5c98b282985077ce46"
|
resolved "https://registry.yarnpkg.com/graphemesplit/-/graphemesplit-2.6.0.tgz#548ec986e83dcdfec31adf5c98b282985077ce46"
|
||||||
integrity sha512-rG9w2wAfkpg0DILa1pjnjNfucng3usON360shisqIMUBw/87pojcBSrHmeE4UwryAuBih7g8m1oilf5/u8EWdQ==
|
integrity sha512-rG9w2wAfkpg0DILa1pjnjNfucng3usON360shisqIMUBw/87pojcBSrHmeE4UwryAuBih7g8m1oilf5/u8EWdQ==
|
||||||
|
|||||||
Reference in New Issue
Block a user