@bitsocial/bitsocial-cli 0.19.56 → 0.19.58
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -16
- package/dist/cli/commands/daemon.js +6 -6
- package/dist/cli/commands/logs.js +65 -42
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
## What is Bitsocial?
|
|
21
21
|
|
|
22
|
-
Bitsocial is p2p and decentralized social media protocol built completely with IPFS/IPNS/pubsub. It doesn't use any central server, central database, public HTTP endpoint or DNS, it is pure peer to peer and fully content addressable. It will allow community owners to retain full ownership over their community.
|
|
22
|
+
Bitsocial is p2p and decentralized social media protocol built completely with IPFS/IPNS/pubsub. It doesn't use any central server, central database, public HTTP endpoint or DNS, it is pure peer to peer and fully content addressable. It will allow community owners to retain full ownership over their community. Learn more [here](https://bitsocial.net).
|
|
23
23
|
|
|
24
24
|
## What is bitsocial-cli?
|
|
25
25
|
|
|
@@ -344,7 +344,7 @@ EXAMPLES
|
|
|
344
344
|
$ bitsocial challenge install ./my-local-challenge
|
|
345
345
|
```
|
|
346
346
|
|
|
347
|
-
_See code: [src/cli/commands/challenge/install.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
347
|
+
_See code: [src/cli/commands/challenge/install.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/challenge/install.ts)_
|
|
348
348
|
|
|
349
349
|
## `bitsocial challenge list`
|
|
350
350
|
|
|
@@ -367,7 +367,7 @@ EXAMPLES
|
|
|
367
367
|
$ bitsocial challenge list -q
|
|
368
368
|
```
|
|
369
369
|
|
|
370
|
-
_See code: [src/cli/commands/challenge/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
370
|
+
_See code: [src/cli/commands/challenge/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/challenge/list.ts)_
|
|
371
371
|
|
|
372
372
|
## `bitsocial challenge remove NAME`
|
|
373
373
|
|
|
@@ -392,7 +392,7 @@ EXAMPLES
|
|
|
392
392
|
$ bitsocial challenge remove @scope/my-challenge
|
|
393
393
|
```
|
|
394
394
|
|
|
395
|
-
_See code: [src/cli/commands/challenge/remove.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
395
|
+
_See code: [src/cli/commands/challenge/remove.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/challenge/remove.ts)_
|
|
396
396
|
|
|
397
397
|
## `bitsocial community create`
|
|
398
398
|
|
|
@@ -422,7 +422,7 @@ EXAMPLES
|
|
|
422
422
|
$ bitsocial community create --jsonFile ./create-options.json
|
|
423
423
|
```
|
|
424
424
|
|
|
425
|
-
_See code: [src/cli/commands/community/create.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
425
|
+
_See code: [src/cli/commands/community/create.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/create.ts)_
|
|
426
426
|
|
|
427
427
|
## `bitsocial community delete ADDRESSES`
|
|
428
428
|
|
|
@@ -447,7 +447,7 @@ EXAMPLES
|
|
|
447
447
|
$ bitsocial community delete 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu
|
|
448
448
|
```
|
|
449
449
|
|
|
450
|
-
_See code: [src/cli/commands/community/delete.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
450
|
+
_See code: [src/cli/commands/community/delete.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/delete.ts)_
|
|
451
451
|
|
|
452
452
|
## `bitsocial community edit ADDRESS`
|
|
453
453
|
|
|
@@ -517,7 +517,7 @@ EXAMPLES
|
|
|
517
517
|
$ bitsocial community edit bitsocial.bso --jsonFile ./edit-options.json
|
|
518
518
|
```
|
|
519
519
|
|
|
520
|
-
_See code: [src/cli/commands/community/edit.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
520
|
+
_See code: [src/cli/commands/community/edit.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/edit.ts)_
|
|
521
521
|
|
|
522
522
|
## `bitsocial community get [ADDRESS]`
|
|
523
523
|
|
|
@@ -548,7 +548,7 @@ EXAMPLES
|
|
|
548
548
|
$ bitsocial community get --publicKey 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu
|
|
549
549
|
```
|
|
550
550
|
|
|
551
|
-
_See code: [src/cli/commands/community/get.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
551
|
+
_See code: [src/cli/commands/community/get.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/get.ts)_
|
|
552
552
|
|
|
553
553
|
## `bitsocial community list`
|
|
554
554
|
|
|
@@ -571,7 +571,7 @@ EXAMPLES
|
|
|
571
571
|
$ bitsocial community list
|
|
572
572
|
```
|
|
573
573
|
|
|
574
|
-
_See code: [src/cli/commands/community/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
574
|
+
_See code: [src/cli/commands/community/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/list.ts)_
|
|
575
575
|
|
|
576
576
|
## `bitsocial community start ADDRESSES`
|
|
577
577
|
|
|
@@ -605,7 +605,7 @@ EXAMPLES
|
|
|
605
605
|
$ bitsocial community start $(bitsocial community list -q) --concurrency 1
|
|
606
606
|
```
|
|
607
607
|
|
|
608
|
-
_See code: [src/cli/commands/community/start.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
608
|
+
_See code: [src/cli/commands/community/start.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/start.ts)_
|
|
609
609
|
|
|
610
610
|
## `bitsocial community stop ADDRESSES`
|
|
611
611
|
|
|
@@ -630,7 +630,7 @@ EXAMPLES
|
|
|
630
630
|
$ bitsocial community stop Qmb99crTbSUfKXamXwZBe829Vf6w5w5TktPkb6WstC9RFW
|
|
631
631
|
```
|
|
632
632
|
|
|
633
|
-
_See code: [src/cli/commands/community/stop.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
633
|
+
_See code: [src/cli/commands/community/stop.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/community/stop.ts)_
|
|
634
634
|
|
|
635
635
|
## `bitsocial daemon`
|
|
636
636
|
|
|
@@ -671,7 +671,7 @@ EXAMPLES
|
|
|
671
671
|
$ bitsocial daemon --chainProviderUrls https://mainnet.infura.io/v3/YOUR_KEY
|
|
672
672
|
```
|
|
673
673
|
|
|
674
|
-
_See code: [src/cli/commands/daemon.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
674
|
+
_See code: [src/cli/commands/daemon.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/daemon.ts)_
|
|
675
675
|
|
|
676
676
|
## `bitsocial help [COMMAND]`
|
|
677
677
|
|
|
@@ -737,7 +737,7 @@ EXAMPLES
|
|
|
737
737
|
$ bitsocial logs --stdout -f
|
|
738
738
|
```
|
|
739
739
|
|
|
740
|
-
_See code: [src/cli/commands/logs.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
740
|
+
_See code: [src/cli/commands/logs.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/logs.ts)_
|
|
741
741
|
|
|
742
742
|
## `bitsocial update check`
|
|
743
743
|
|
|
@@ -754,7 +754,7 @@ EXAMPLES
|
|
|
754
754
|
$ bitsocial update check
|
|
755
755
|
```
|
|
756
756
|
|
|
757
|
-
_See code: [src/cli/commands/update/check.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
757
|
+
_See code: [src/cli/commands/update/check.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/update/check.ts)_
|
|
758
758
|
|
|
759
759
|
## `bitsocial update install [VERSION]`
|
|
760
760
|
|
|
@@ -786,7 +786,7 @@ EXAMPLES
|
|
|
786
786
|
$ bitsocial update install --no-restart-daemons
|
|
787
787
|
```
|
|
788
788
|
|
|
789
|
-
_See code: [src/cli/commands/update/install.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
789
|
+
_See code: [src/cli/commands/update/install.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/update/install.ts)_
|
|
790
790
|
|
|
791
791
|
## `bitsocial update versions`
|
|
792
792
|
|
|
@@ -808,7 +808,7 @@ EXAMPLES
|
|
|
808
808
|
$ bitsocial update versions --limit 5
|
|
809
809
|
```
|
|
810
810
|
|
|
811
|
-
_See code: [src/cli/commands/update/versions.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
811
|
+
_See code: [src/cli/commands/update/versions.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.58/src/cli/commands/update/versions.ts)_
|
|
812
812
|
<!-- commandsstop -->
|
|
813
813
|
|
|
814
814
|
## Contribution
|
|
@@ -167,17 +167,17 @@ export default class Daemon extends Command {
|
|
|
167
167
|
log(`Will remove log (${deletedLogFile}) because we reached capacity (${logfilesCapacity})`);
|
|
168
168
|
}
|
|
169
169
|
// Write real errors to both the terminal and the log file
|
|
170
|
-
const writeErrorToTerminal = (err) => {
|
|
170
|
+
const writeErrorToTerminal = (label, err) => {
|
|
171
171
|
const msg = err instanceof Error ? err.stack || err.message : String(err);
|
|
172
|
-
stderrWrite(msg
|
|
172
|
+
stderrWrite(`[${label}] ${msg}${EOL}`);
|
|
173
173
|
};
|
|
174
174
|
process.on("uncaughtException", (err) => {
|
|
175
|
-
writeErrorToTerminal(err);
|
|
176
|
-
console.error(err);
|
|
175
|
+
writeErrorToTerminal("uncaughtException", err);
|
|
176
|
+
console.error("[uncaughtException]", err);
|
|
177
177
|
});
|
|
178
178
|
process.on("unhandledRejection", (err) => {
|
|
179
|
-
writeErrorToTerminal(err);
|
|
180
|
-
console.error(err);
|
|
179
|
+
writeErrorToTerminal("unhandledRejection", err);
|
|
180
|
+
console.error("[unhandledRejection]", err);
|
|
181
181
|
});
|
|
182
182
|
process.on("exit", () => {
|
|
183
183
|
// close() returns a promise but exit handlers must be synchronous.
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Flags, Command } from "@oclif/core";
|
|
2
2
|
import defaults from "../../common-utils/defaults.js";
|
|
3
|
-
import fs from "fs";
|
|
4
3
|
import fsPromise from "fs/promises";
|
|
5
4
|
import path from "path";
|
|
6
5
|
export default class Logs extends Command {
|
|
@@ -174,42 +173,56 @@ export default class Logs extends Command {
|
|
|
174
173
|
const stat = await fsPromise.stat(currentLogFile);
|
|
175
174
|
let position = stat.size;
|
|
176
175
|
let pendingBuffer = "";
|
|
177
|
-
// Watch for new data
|
|
176
|
+
// Watch for new data by reading directly from `position`. We intentionally do
|
|
177
|
+
// NOT gate on fsPromise.stat().size — on Windows + NTFS, stat() returns a stale
|
|
178
|
+
// size for a short window after another process appends, which causes the gate
|
|
179
|
+
// to miss new bytes. read() sees the true file end at syscall time.
|
|
180
|
+
const READ_BUF_SIZE = 64 * 1024;
|
|
181
|
+
const readBuf = Buffer.alloc(READ_BUF_SIZE);
|
|
178
182
|
const readNewData = async () => {
|
|
183
|
+
let fd;
|
|
179
184
|
try {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
const
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
fd = await fsPromise.open(currentLogFile, "r");
|
|
186
|
+
let chunk = "";
|
|
187
|
+
while (true) {
|
|
188
|
+
const { bytesRead } = await fd.read(readBuf, 0, readBuf.length, position);
|
|
189
|
+
if (bytesRead === 0)
|
|
190
|
+
break;
|
|
186
191
|
position += bytesRead;
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
192
|
+
chunk += readBuf.subarray(0, bytesRead).toString("utf-8");
|
|
193
|
+
if (bytesRead < readBuf.length)
|
|
194
|
+
break;
|
|
195
|
+
}
|
|
196
|
+
if (!chunk)
|
|
197
|
+
return;
|
|
198
|
+
const combined = pendingBuffer + chunk;
|
|
199
|
+
const lastNewline = combined.lastIndexOf("\n");
|
|
200
|
+
if (lastNewline === -1) {
|
|
201
|
+
pendingBuffer = combined;
|
|
202
|
+
return;
|
|
203
|
+
}
|
|
204
|
+
pendingBuffer = combined.slice(lastNewline + 1);
|
|
205
|
+
const completeText = combined.slice(0, lastNewline + 1);
|
|
206
|
+
if (!since && !until && !streamFilter) {
|
|
207
|
+
// No filtering — pass through directly
|
|
208
|
+
process.stdout.write(completeText);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
const newEntries = this._parseLogEntries(completeText.replace(/\n$/, ""));
|
|
212
|
+
const filteredNew = this._filterEntries(newEntries, since, until);
|
|
213
|
+
const streamFilteredNew = streamFilter ? this._filterByStream(filteredNew, streamFilter) : filteredNew;
|
|
214
|
+
const output = streamFilteredNew.map((e) => e.lines.join("\n")).join("\n");
|
|
215
|
+
if (output)
|
|
216
|
+
process.stdout.write(output + "\n");
|
|
208
217
|
}
|
|
209
218
|
}
|
|
210
219
|
catch {
|
|
211
220
|
// File may have been rotated or deleted
|
|
212
221
|
}
|
|
222
|
+
finally {
|
|
223
|
+
if (fd)
|
|
224
|
+
await fd.close().catch(() => { });
|
|
225
|
+
}
|
|
213
226
|
};
|
|
214
227
|
// Periodically check if a newer log file has appeared (e.g. after daemon restart)
|
|
215
228
|
const checkForNewLogFile = async () => {
|
|
@@ -231,8 +244,6 @@ export default class Logs extends Command {
|
|
|
231
244
|
process.stdout.write(pbOutput + "\n");
|
|
232
245
|
}
|
|
233
246
|
}
|
|
234
|
-
// Switch watchers
|
|
235
|
-
fs.unwatchFile(currentLogFile, readNewData);
|
|
236
247
|
currentLogFile = newestFile;
|
|
237
248
|
pendingBuffer = "";
|
|
238
249
|
process.stderr.write(`\n--- switched to new log file: ${path.basename(newestFile)} ---\n\n`);
|
|
@@ -255,25 +266,37 @@ export default class Logs extends Command {
|
|
|
255
266
|
}
|
|
256
267
|
const newStat = await fsPromise.stat(currentLogFile);
|
|
257
268
|
position = newStat.size;
|
|
258
|
-
fs.watchFile(currentLogFile, { interval: 300 }, readNewData);
|
|
259
269
|
}
|
|
260
270
|
catch {
|
|
261
271
|
// Directory listing failed or file disappeared — retry next cycle
|
|
262
272
|
}
|
|
263
273
|
};
|
|
264
|
-
fs.watchFile
|
|
274
|
+
// Userspace polling instead of fs.watchFile — libuv's uv_fs_poll_t doesn't
|
|
275
|
+
// reliably notify on cross-process appends on Windows (see nodejs/node#36888).
|
|
276
|
+
let polling = true;
|
|
277
|
+
let pollTimer = null;
|
|
278
|
+
const pollLoop = async () => {
|
|
279
|
+
if (!polling)
|
|
280
|
+
return;
|
|
281
|
+
try {
|
|
282
|
+
await readNewData();
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
if (polling)
|
|
286
|
+
pollTimer = setTimeout(pollLoop, 300);
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
pollTimer = setTimeout(pollLoop, 300);
|
|
265
290
|
const newFileCheckInterval = setInterval(checkForNewLogFile, 3000);
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
process.exit(0);
|
|
271
|
-
});
|
|
272
|
-
process.on("SIGTERM", () => {
|
|
291
|
+
const shutdown = () => {
|
|
292
|
+
polling = false;
|
|
293
|
+
if (pollTimer)
|
|
294
|
+
clearTimeout(pollTimer);
|
|
273
295
|
clearInterval(newFileCheckInterval);
|
|
274
|
-
fs.unwatchFile(currentLogFile, readNewData);
|
|
275
296
|
process.exit(0);
|
|
276
|
-
}
|
|
297
|
+
};
|
|
298
|
+
process.on("SIGINT", shutdown);
|
|
299
|
+
process.on("SIGTERM", shutdown);
|
|
277
300
|
// Keep process alive
|
|
278
301
|
await new Promise(() => { });
|
|
279
302
|
}
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bitsocial/bitsocial-cli",
|
|
3
|
-
"version": "0.19.
|
|
3
|
+
"version": "0.19.58",
|
|
4
4
|
"description": "Command line interface to Bitsocial API",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"homepage": "https://github.com/bitsocialnet/bitsocial-cli",
|
|
@@ -119,7 +119,7 @@
|
|
|
119
119
|
"@oclif/plugin-help": "6.2.36",
|
|
120
120
|
"@oclif/plugin-not-found": "3.2.73",
|
|
121
121
|
"@oclif/table": "0.5.1",
|
|
122
|
-
"@pkcprotocol/pkc-js": "0.0.
|
|
122
|
+
"@pkcprotocol/pkc-js": "0.0.35",
|
|
123
123
|
"dataobject-parser": "1.2.22",
|
|
124
124
|
"decompress": "4.2.1",
|
|
125
125
|
"env-paths": "2.2.1",
|