mirror of
https://github.com/bitsocialnet/5chan.git
synced 2026-08-03 07:41:04 +02:00
fix(deps): remove hooks consumer patch
This commit is contained in:
@@ -28,14 +28,14 @@ If uncertain, ask the developer before adding an entry.
|
||||
|
||||
## Entries
|
||||
|
||||
### 5chan patches its installed hooks tarball instead of using the local hooks repo
|
||||
### 5chan consumes a pinned hooks tarball instead of using the local hooks repo
|
||||
|
||||
- **Date:** 2026-04-15
|
||||
- **Observed by:** Codex
|
||||
- **Context:** Debugging strict `{name, publicKey}` community refs and the temporary `scripts/patch-bitsocial-react-hooks-esm.cjs` workaround
|
||||
- **What was surprising:** 5chan does not consume the nearby `/Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks` checkout; `package.json` installs a pinned GitHub tarball of `@bitsocialnet/bitsocial-react-hooks` and then mutates its `dist/` files in `postinstall`.
|
||||
- **Impact:** Agents can wrongly assume local hooks source changes are already active in 5chan, or treat the postinstall patch as app logic instead of a temporary package-level workaround.
|
||||
- **Mitigation:** Before debugging hooks behavior from 5chan, check `package.json` to see whether the app points at a tarball commit or a local path. If `scripts/patch-bitsocial-react-hooks-esm.cjs` is involved, fix the underlying issue in `bitsocial-react-hooks`, rebuild its `dist/`, update 5chan to the fixed commit/path, and then remove the patch script.
|
||||
- **Context:** Debugging strict `{name, publicKey}` community refs after upstream fixes landed in `bitsocial-react-hooks`
|
||||
- **What was surprising:** 5chan does not consume the nearby `/Users/Tommaso/Desktop/bitsocial/bitsocial-react-hooks` checkout by default; `package.json` installs a pinned GitHub tarball of `@bitsocialnet/bitsocial-react-hooks`.
|
||||
- **Impact:** Agents can wrongly assume local hooks source changes are already active in 5chan, or debug the wrong package build when the app is really running a tarball revision from GitHub.
|
||||
- **Mitigation:** Before debugging hooks behavior from 5chan, check `package.json` to see whether the app points at a tarball commit or a local path. If you need fresh hooks behavior, update the tarball commit or temporarily switch 5chan to a local path intentionally.
|
||||
- **Status:** confirmed
|
||||
|
||||
### Portless breaks Windows installs
|
||||
|
||||
+2
-2
@@ -8,7 +8,7 @@
|
||||
"license": "GPL-2.0-only",
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@bitsocialnet/bitsocial-react-hooks": "https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/9ebb84bd12ca95a10b426f44d43b0e73e740146d",
|
||||
"@bitsocialnet/bitsocial-react-hooks": "https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/8480b4276ca77588bfc2e3b45702ec80729adc3c",
|
||||
"@capacitor/app": "7.0.1",
|
||||
"@capacitor/status-bar": "7.0.1",
|
||||
"@capawesome/capacitor-android-edge-to-edge-support": "7.2.2",
|
||||
@@ -50,7 +50,7 @@
|
||||
"scripts": {
|
||||
"generate:assets": "node scripts/generate-asset-manifest.js",
|
||||
"sync:directories": "node scripts/sync-directories.js",
|
||||
"postinstall": "node scripts/patch-capacitor-cli-tar.cjs && node scripts/patch-bitsocial-react-hooks-esm.cjs",
|
||||
"postinstall": "node scripts/patch-capacitor-cli-tar.cjs",
|
||||
"prebuild": "corepack yarn sync:directories && corepack yarn generate:assets",
|
||||
"prestart": "corepack yarn sync:directories && corepack yarn generate:assets",
|
||||
"start": "node scripts/start-dev.js",
|
||||
|
||||
@@ -1,132 +0,0 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const packageDistPath = path.join(__dirname, '..', 'node_modules', '@bitsocialnet', 'bitsocial-react-hooks', 'dist');
|
||||
const logPrefix = '[patch-bitsocial-react-hooks-esm]';
|
||||
const packageIndexPath = path.join(packageDistPath, 'index.js');
|
||||
const communitiesPagesStorePath = path.join(packageDistPath, 'stores', 'communities-pages', 'communities-pages-store.js');
|
||||
|
||||
if (!fs.existsSync(packageDistPath)) {
|
||||
console.log(`${logPrefix} Skip: @bitsocialnet/bitsocial-react-hooks dist not found.`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
const relativeImportPattern = /(from\s+|import\s+)(['"])(\.\.?\/[^'"]+)\2/g;
|
||||
let touchedFiles = 0;
|
||||
let rewrittenImports = 0;
|
||||
let removedNodeDebugPatches = 0;
|
||||
let patchedCommunityFirstPageGuards = 0;
|
||||
|
||||
const nodeDebugPatchPattern =
|
||||
/\/\/ fix DEBUG_DEPTH bug https:\/\/github\.com\/debug-js\/debug\/issues\/746\s*try\s*\{\s*if \(process\.env\.DEBUG_DEPTH\) \{\s*require\("util"\)\.inspect\.defaultOptions\.depth = process\.env\.DEBUG_DEPTH;\s*\}\s*if \(process\.env\.DEBUG_ARRAY\) \{\s*require\("util"\)\.inspect\.defaultOptions\.maxArrayLength = process\.env\.DEBUG_ARRAY;\s*\}\s*\}\s*catch \(e\) \{ \}/m;
|
||||
const communityFirstPageAssertNeedle =
|
||||
" assert(community === null || community === void 0 ? void 0 : community.address, `getCommunityFirstPageCid community '${community}' invalid`);\n";
|
||||
|
||||
const splitSpecifier = (specifier) => {
|
||||
const suffixStart = specifier.search(/[?#]/);
|
||||
|
||||
if (suffixStart === -1) {
|
||||
return { bareSpecifier: specifier, suffix: '' };
|
||||
}
|
||||
|
||||
return {
|
||||
bareSpecifier: specifier.slice(0, suffixStart),
|
||||
suffix: specifier.slice(suffixStart),
|
||||
};
|
||||
};
|
||||
|
||||
const resolveSpecifier = (filePath, specifier) => {
|
||||
const { bareSpecifier, suffix } = splitSpecifier(specifier);
|
||||
|
||||
if (path.extname(bareSpecifier)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const absoluteSpecifierPath = path.resolve(path.dirname(filePath), bareSpecifier);
|
||||
|
||||
if (fs.existsSync(`${absoluteSpecifierPath}.js`)) {
|
||||
return `${bareSpecifier}.js${suffix}`;
|
||||
}
|
||||
|
||||
if (fs.existsSync(path.join(absoluteSpecifierPath, 'index.js'))) {
|
||||
return `${bareSpecifier}/index.js${suffix}`;
|
||||
}
|
||||
|
||||
return null;
|
||||
};
|
||||
|
||||
const patchFile = (filePath) => {
|
||||
const source = fs.readFileSync(filePath, 'utf8');
|
||||
let fileImportCount = 0;
|
||||
|
||||
let updated = source.replace(relativeImportPattern, (match, prefix, quote, specifier) => {
|
||||
const resolvedSpecifier = resolveSpecifier(filePath, specifier);
|
||||
|
||||
if (!resolvedSpecifier || resolvedSpecifier === specifier) {
|
||||
return match;
|
||||
}
|
||||
|
||||
fileImportCount += 1;
|
||||
return `${prefix}${quote}${resolvedSpecifier}${quote}`;
|
||||
});
|
||||
|
||||
if (filePath === packageIndexPath) {
|
||||
const nextUpdated = updated.replace(
|
||||
nodeDebugPatchPattern,
|
||||
'// Browser bundle: skip Node-only util DEBUG_DEPTH/DEBUG_ARRAY tuning.\n',
|
||||
);
|
||||
|
||||
if (nextUpdated !== updated) {
|
||||
updated = nextUpdated;
|
||||
removedNodeDebugPatches += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (filePath === communitiesPagesStorePath) {
|
||||
const nextUpdated = updated.replace(
|
||||
communityFirstPageAssertNeedle,
|
||||
" if (!(community === null || community === void 0 ? void 0 : community.address)) {\n return;\n }\n",
|
||||
);
|
||||
|
||||
if (nextUpdated !== updated) {
|
||||
updated = nextUpdated;
|
||||
patchedCommunityFirstPageGuards += 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!fileImportCount && updated === source) {
|
||||
return;
|
||||
}
|
||||
|
||||
fs.writeFileSync(filePath, updated, 'utf8');
|
||||
touchedFiles += 1;
|
||||
rewrittenImports += fileImportCount;
|
||||
};
|
||||
|
||||
const walk = (currentPath) => {
|
||||
for (const entry of fs.readdirSync(currentPath, { withFileTypes: true })) {
|
||||
const entryPath = path.join(currentPath, entry.name);
|
||||
|
||||
if (entry.isDirectory()) {
|
||||
walk(entryPath);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (entry.isFile() && entry.name.endsWith('.js')) {
|
||||
patchFile(entryPath);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
walk(packageDistPath);
|
||||
|
||||
if (!touchedFiles) {
|
||||
console.log(`${logPrefix} No relative ESM imports needed patching.`);
|
||||
process.exit(0);
|
||||
}
|
||||
|
||||
console.log(
|
||||
`${logPrefix} Patched ${rewrittenImports} imports across ${touchedFiles} files${removedNodeDebugPatches ? `, removed ${removedNodeDebugPatches} browser-incompatible debug util block(s)` : ''}${patchedCommunityFirstPageGuards ? `, and relaxed ${patchedCommunityFirstPageGuards} community first-page guard(s)` : ''}.`,
|
||||
);
|
||||
@@ -9,7 +9,7 @@ __metadata:
|
||||
version: 0.0.0-use.local
|
||||
resolution: "5chan@workspace:."
|
||||
dependencies:
|
||||
"@bitsocialnet/bitsocial-react-hooks": "https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/9ebb84bd12ca95a10b426f44d43b0e73e740146d"
|
||||
"@bitsocialnet/bitsocial-react-hooks": "https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/8480b4276ca77588bfc2e3b45702ec80729adc3c"
|
||||
"@capacitor/android": "npm:7.4.5"
|
||||
"@capacitor/app": "npm:7.0.1"
|
||||
"@capacitor/cli": "npm:7.4.5"
|
||||
@@ -1530,9 +1530,9 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"@bitsocialnet/bitsocial-react-hooks@https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/9ebb84bd12ca95a10b426f44d43b0e73e740146d":
|
||||
"@bitsocialnet/bitsocial-react-hooks@https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/8480b4276ca77588bfc2e3b45702ec80729adc3c":
|
||||
version: 0.1.0
|
||||
resolution: "@bitsocialnet/bitsocial-react-hooks@https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/9ebb84bd12ca95a10b426f44d43b0e73e740146d"
|
||||
resolution: "@bitsocialnet/bitsocial-react-hooks@https://codeload.github.com/bitsocialnet/bitsocial-react-hooks/tar.gz/8480b4276ca77588bfc2e3b45702ec80729adc3c"
|
||||
dependencies:
|
||||
"@bitsocial/bso-resolver": "npm:0.0.4"
|
||||
"@pkc/pkc-logger": "https://github.com/pkcprotocol/pkc-logger.git"
|
||||
@@ -1551,7 +1551,7 @@ __metadata:
|
||||
zustand: "npm:4.0.0"
|
||||
peerDependencies:
|
||||
react: ">=16.8"
|
||||
checksum: 10c0/a3ec5af0049e4244594eaf8c01b3153e0a32b55d3feb794bfbc96829154c2f7748f08ecc65c905db6e9da38a06ba839530f92bd99b7110214d478be4e234009a
|
||||
checksum: 10c0/becd25422d39b4f5dc599b583c32cd38ca6c7db5389505ec6bf82b7fd69a7419ac7ca9fba9db44cd4d83808a00e4f9bea883114d76ae46d0a053e92212a1409b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user