OverviewFilesCommitsIssuesDocsReleasesPeers

wirecore commits / 12f5f3d

Fix Pear module resolution and enable P2P installation
Fixes: - Removed dynamic import('fs') and import('path') which don't work in Bare/Pear runtime - Changed to try-catch pattern for checking storage existence - Fixed variable scoping in loadState() function - Updated .pearignore to exclude local storage directories Pear packaging: - Successfully staged to pear://zupx3qzpwj61hdt1bxanabctcyxqqu3arogctwim4qt3wfbzn4bo - Seeding active in background - Tested and working: init, post, whoami commands Installation: - Anyone can now install with: pear run pear://... - No manual npm install required - Works on any system with Pear installed This resolves the critical module resolution bug we documented in pear-deployment-lessons.md. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
12f5f3de9a5a82b75098d92927dc6a1e0d3f5428
by plankatron <fleeky@gmail.com> · 2026-01-20T20:32:30.000Z

Changed files (2) +37 -31

pear-app/.pearignore +4 -0
……@@ -18,3 +18,7 @@ docs/
1818*.swp
1919*.swo
2020*~
21
22# Local data (should be per-installation)
23wirecore-storage/
24test-storage/
pear-app/index.js +33 -31
……@@ -39,43 +39,45 @@ let follows = new Map() // discoveryKey -> { feed, publicKey, name }
3939async function loadState() {
4040 if (store) return true // Already loaded
4141
42 // Check if storage directory exists first
43 const fs = await import('fs')
44 const path = await import('path')
45 const identityPath = path.join(STORAGE_PATH, 'cores')
46
47 if (!fs.existsSync(identityPath)) {
48 return null // Not initialized yet
49 }
50
51 store = new Corestore(STORAGE_PATH)
52 await store.ready()
42 // Try to open Corestore - if it fails, storage doesn't exist yet
43 let identityCore
44 try {
45 store = new Corestore(STORAGE_PATH)
46 await store.ready()
5347
54 // Load identity
55 const identityCore = store.get({ name: 'identity' })
56 await identityCore.ready()
48 // Load identity
49 identityCore = store.get({ name: 'identity' })
50 await identityCore.ready()
5751
58 if (identityCore.length === 0) {
59 await store.close()
60 store = null
61 return null // Not initialized
62 }
52 if (identityCore.length === 0) {
53 await store.close()
54 store = null
55 return null // Not initialized
56 }
6357
64 const identitySeed = await identityCore.get(0)
65 identity = await IdentityKey.from({ seed: identitySeed })
58 const identitySeed = await identityCore.get(0)
59 identity = await IdentityKey.from({ seed: identitySeed })
6660
67 // Load personal feed
68 myFeed = store.get({ name: 'my-feed' })
69 await myFeed.ready()
61 // Load personal feed
62 myFeed = store.get({ name: 'my-feed' })
63 await myFeed.ready()
7064
71 // Load metadata
72 metaBee = new Hyperbee(store.get({ name: 'metadata' }), {
73 keyEncoding: 'utf-8',
74 valueEncoding: 'json'
75 })
76 await metaBee.ready()
65 // Load metadata
66 metaBee = new Hyperbee(store.get({ name: 'metadata' }), {
67 keyEncoding: 'utf-8',
68 valueEncoding: 'json'
69 })
70 await metaBee.ready()
7771
78 return true
72 return true
73 } catch (err) {
74 // Storage doesn't exist or is corrupted
75 if (store) {
76 try { await store.close() } catch {}
77 store = null
78 }
79 return null
80 }
7981}
8082
8183/**