@bitsocial/bitsocial-cli 0.19.39 → 0.19.40
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 +91 -19
- package/dist/cli/base-command.js +7 -4
- package/dist/cli/commands/community/create.js +2 -2
- package/dist/cli/commands/community/delete.js +2 -2
- package/dist/cli/commands/community/edit.js +2 -2
- package/dist/cli/commands/community/list.js +2 -2
- package/dist/cli/commands/community/start.js +2 -2
- package/dist/cli/commands/community/stop.js +2 -2
- package/dist/cli/commands/daemon.js +4 -5
- package/dist/ipfs/startIpfs.js +2 -2
- package/dist/util.d.ts +4 -3
- package/dist/util.js +2 -4
- package/dist/webui/daemon-server.js +2 -2
- package/oclif.manifest.json +691 -0
- package/package.json +4 -2
- package/dist/cli/commands/subplebbit/create.d.ts +0 -12
- package/dist/cli/commands/subplebbit/create.js +0 -54
- package/dist/cli/commands/subplebbit/edit.d.ts +0 -12
- package/dist/cli/commands/subplebbit/edit.js +0 -73
- package/dist/cli/commands/subplebbit/get.d.ts +0 -9
- package/dist/cli/commands/subplebbit/get.js +0 -32
- package/dist/cli/commands/subplebbit/list.d.ts +0 -9
- package/dist/cli/commands/subplebbit/list.js +0 -30
- package/dist/cli/commands/subplebbit/start.d.ts +0 -10
- package/dist/cli/commands/subplebbit/start.js +0 -41
- package/dist/cli/commands/subplebbit/stop.d.ts +0 -10
- package/dist/cli/commands/subplebbit/stop.js +0 -43
- package/dist/seeder.d.ts +0 -1
- package/dist/seeder.js +0 -83
package/README.md
CHANGED
|
@@ -311,6 +311,9 @@ $ bitsocial community edit mysub.bso '--roles["author-address.bso"]' null
|
|
|
311
311
|
* [`bitsocial daemon`](#bitsocial-daemon)
|
|
312
312
|
* [`bitsocial help [COMMAND]`](#bitsocial-help-command)
|
|
313
313
|
* [`bitsocial logs`](#bitsocial-logs)
|
|
314
|
+
* [`bitsocial update check`](#bitsocial-update-check)
|
|
315
|
+
* [`bitsocial update install [VERSION]`](#bitsocial-update-install-version)
|
|
316
|
+
* [`bitsocial update versions`](#bitsocial-update-versions)
|
|
314
317
|
|
|
315
318
|
## `bitsocial challenge install PACKAGE`
|
|
316
319
|
|
|
@@ -341,7 +344,7 @@ EXAMPLES
|
|
|
341
344
|
$ bitsocial challenge install ./my-local-challenge
|
|
342
345
|
```
|
|
343
346
|
|
|
344
|
-
_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.40/src/cli/commands/challenge/install.ts)_
|
|
345
348
|
|
|
346
349
|
## `bitsocial challenge list`
|
|
347
350
|
|
|
@@ -364,7 +367,7 @@ EXAMPLES
|
|
|
364
367
|
$ bitsocial challenge list -q
|
|
365
368
|
```
|
|
366
369
|
|
|
367
|
-
_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.40/src/cli/commands/challenge/list.ts)_
|
|
368
371
|
|
|
369
372
|
## `bitsocial challenge remove NAME`
|
|
370
373
|
|
|
@@ -389,7 +392,7 @@ EXAMPLES
|
|
|
389
392
|
$ bitsocial challenge remove @scope/my-challenge
|
|
390
393
|
```
|
|
391
394
|
|
|
392
|
-
_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.40/src/cli/commands/challenge/remove.ts)_
|
|
393
396
|
|
|
394
397
|
## `bitsocial community create`
|
|
395
398
|
|
|
@@ -414,7 +417,7 @@ EXAMPLES
|
|
|
414
417
|
$ bitsocial community create --title 'Hello Plebs' --description 'Welcome'
|
|
415
418
|
```
|
|
416
419
|
|
|
417
|
-
_See code: [src/cli/commands/community/create.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
420
|
+
_See code: [src/cli/commands/community/create.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/create.ts)_
|
|
418
421
|
|
|
419
422
|
## `bitsocial community delete ADDRESSES`
|
|
420
423
|
|
|
@@ -439,7 +442,7 @@ EXAMPLES
|
|
|
439
442
|
$ bitsocial community delete 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu
|
|
440
443
|
```
|
|
441
444
|
|
|
442
|
-
_See code: [src/cli/commands/community/delete.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
445
|
+
_See code: [src/cli/commands/community/delete.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/delete.ts)_
|
|
443
446
|
|
|
444
447
|
## `bitsocial community edit ADDRESS`
|
|
445
448
|
|
|
@@ -491,7 +494,7 @@ EXAMPLES
|
|
|
491
494
|
$ bitsocial community edit plebbit.bso --settings.fetchThumbnailUrls=false
|
|
492
495
|
```
|
|
493
496
|
|
|
494
|
-
_See code: [src/cli/commands/community/edit.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
497
|
+
_See code: [src/cli/commands/community/edit.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/edit.ts)_
|
|
495
498
|
|
|
496
499
|
## `bitsocial community get ADDRESS`
|
|
497
500
|
|
|
@@ -516,7 +519,7 @@ EXAMPLES
|
|
|
516
519
|
$ bitsocial community get 12D3KooWG3XbzoVyAE6Y9vHZKF64Yuuu4TjdgQKedk14iYmTEPWu
|
|
517
520
|
```
|
|
518
521
|
|
|
519
|
-
_See code: [src/cli/commands/community/get.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
522
|
+
_See code: [src/cli/commands/community/get.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/get.ts)_
|
|
520
523
|
|
|
521
524
|
## `bitsocial community list`
|
|
522
525
|
|
|
@@ -539,7 +542,7 @@ EXAMPLES
|
|
|
539
542
|
$ bitsocial community list
|
|
540
543
|
```
|
|
541
544
|
|
|
542
|
-
_See code: [src/cli/commands/community/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
545
|
+
_See code: [src/cli/commands/community/list.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/list.ts)_
|
|
543
546
|
|
|
544
547
|
## `bitsocial community start ADDRESSES`
|
|
545
548
|
|
|
@@ -568,7 +571,7 @@ EXAMPLES
|
|
|
568
571
|
$ bitsocial community start $(bitsocial community list -q)
|
|
569
572
|
```
|
|
570
573
|
|
|
571
|
-
_See code: [src/cli/commands/community/start.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
574
|
+
_See code: [src/cli/commands/community/start.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/start.ts)_
|
|
572
575
|
|
|
573
576
|
## `bitsocial community stop ADDRESSES`
|
|
574
577
|
|
|
@@ -593,7 +596,7 @@ EXAMPLES
|
|
|
593
596
|
$ bitsocial community stop Qmb99crTbSUfKXamXwZBe829Vf6w5w5TktPkb6WstC9RFW
|
|
594
597
|
```
|
|
595
598
|
|
|
596
|
-
_See code: [src/cli/commands/community/stop.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
599
|
+
_See code: [src/cli/commands/community/stop.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/community/stop.ts)_
|
|
597
600
|
|
|
598
601
|
## `bitsocial daemon`
|
|
599
602
|
|
|
@@ -635,7 +638,7 @@ EXAMPLES
|
|
|
635
638
|
$ bitsocial daemon --chainProviderUrls viem --chainProviderUrls https://mainnet.infura.io/v3/YOUR_KEY
|
|
636
639
|
```
|
|
637
640
|
|
|
638
|
-
_See code: [src/cli/commands/daemon.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
641
|
+
_See code: [src/cli/commands/daemon.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/daemon.ts)_
|
|
639
642
|
|
|
640
643
|
## `bitsocial help [COMMAND]`
|
|
641
644
|
|
|
@@ -663,15 +666,16 @@ View the latest BitSocial daemon log file. By default dumps the full log and exi
|
|
|
663
666
|
|
|
664
667
|
```
|
|
665
668
|
USAGE
|
|
666
|
-
$ bitsocial logs [-f] [-n <value>] [--since <value>] [--until <value>]
|
|
669
|
+
$ bitsocial logs [-f] [-n <value>] [--since <value>] [--until <value>] [--logPath <value>]
|
|
667
670
|
|
|
668
671
|
FLAGS
|
|
669
|
-
-f, --follow
|
|
670
|
-
-n, --tail=<value>
|
|
671
|
-
--
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
672
|
+
-f, --follow Follow log output in real-time (like tail -f)
|
|
673
|
+
-n, --tail=<value> [default: all] Number of log entries to show from the end. Use "all" to show everything.
|
|
674
|
+
--logPath=<value> Specify the directory containing log files
|
|
675
|
+
--since=<value> Show logs since timestamp (ISO 8601, e.g. 2026-01-02T13:23:37Z) or relative time (e.g. 30s,
|
|
676
|
+
42m, 2h, 1d)
|
|
677
|
+
--until=<value> Show logs before timestamp (ISO 8601, e.g. 2026-01-02T13:23:37Z) or relative time (e.g. 30s,
|
|
678
|
+
42m, 2h, 1d)
|
|
675
679
|
|
|
676
680
|
DESCRIPTION
|
|
677
681
|
View the latest BitSocial daemon log file. By default dumps the full log and exits. Use --follow to stream new output
|
|
@@ -691,7 +695,75 @@ EXAMPLES
|
|
|
691
695
|
$ bitsocial logs --since 1h -f
|
|
692
696
|
```
|
|
693
697
|
|
|
694
|
-
_See code: [src/cli/commands/logs.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.
|
|
698
|
+
_See code: [src/cli/commands/logs.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/logs.ts)_
|
|
699
|
+
|
|
700
|
+
## `bitsocial update check`
|
|
701
|
+
|
|
702
|
+
Check if a newer version of bitsocial is available on npm
|
|
703
|
+
|
|
704
|
+
```
|
|
705
|
+
USAGE
|
|
706
|
+
$ bitsocial update check
|
|
707
|
+
|
|
708
|
+
DESCRIPTION
|
|
709
|
+
Check if a newer version of bitsocial is available on npm
|
|
710
|
+
|
|
711
|
+
EXAMPLES
|
|
712
|
+
$ bitsocial update check
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
_See code: [src/cli/commands/update/check.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/update/check.ts)_
|
|
716
|
+
|
|
717
|
+
## `bitsocial update install [VERSION]`
|
|
718
|
+
|
|
719
|
+
Install a specific version of bitsocial from npm
|
|
720
|
+
|
|
721
|
+
```
|
|
722
|
+
USAGE
|
|
723
|
+
$ bitsocial update install [VERSION] [--force]
|
|
724
|
+
|
|
725
|
+
ARGUMENTS
|
|
726
|
+
[VERSION] [default: latest] Version to install (e.g. "0.19.40" or "latest")
|
|
727
|
+
|
|
728
|
+
FLAGS
|
|
729
|
+
--force Reinstall even if already on the requested version
|
|
730
|
+
|
|
731
|
+
DESCRIPTION
|
|
732
|
+
Install a specific version of bitsocial from npm
|
|
733
|
+
|
|
734
|
+
EXAMPLES
|
|
735
|
+
$ bitsocial update install
|
|
736
|
+
|
|
737
|
+
$ bitsocial update install latest
|
|
738
|
+
|
|
739
|
+
$ bitsocial update install 0.19.40
|
|
740
|
+
|
|
741
|
+
$ bitsocial update install --force
|
|
742
|
+
```
|
|
743
|
+
|
|
744
|
+
_See code: [src/cli/commands/update/install.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/update/install.ts)_
|
|
745
|
+
|
|
746
|
+
## `bitsocial update versions`
|
|
747
|
+
|
|
748
|
+
List available bitsocial versions on npm
|
|
749
|
+
|
|
750
|
+
```
|
|
751
|
+
USAGE
|
|
752
|
+
$ bitsocial update versions [--limit <value>]
|
|
753
|
+
|
|
754
|
+
FLAGS
|
|
755
|
+
--limit=<value> [default: 20] Maximum number of versions to display
|
|
756
|
+
|
|
757
|
+
DESCRIPTION
|
|
758
|
+
List available bitsocial versions on npm
|
|
759
|
+
|
|
760
|
+
EXAMPLES
|
|
761
|
+
$ bitsocial update versions
|
|
762
|
+
|
|
763
|
+
$ bitsocial update versions --limit 5
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
_See code: [src/cli/commands/update/versions.ts](https://github.com/bitsocialnet/bitsocial-cli/blob/v0.19.40/src/cli/commands/update/versions.ts)_
|
|
695
767
|
<!-- commandsstop -->
|
|
696
768
|
|
|
697
769
|
## Contribution
|
package/dist/cli/base-command.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command, Flags } from "@oclif/core";
|
|
2
2
|
import defaults from "../common-utils/defaults.js";
|
|
3
3
|
import PKC from "@pkcprotocol/pkc-js";
|
|
4
|
-
import {
|
|
4
|
+
import { PKCLogger, setupDebugLogger } from "../util.js";
|
|
5
5
|
const getPKCConnectOverride = () => {
|
|
6
6
|
const globalWithOverride = globalThis;
|
|
7
7
|
return globalWithOverride.__PKC_RPC_CONNECT_OVERRIDE;
|
|
@@ -16,8 +16,7 @@ export class BaseCommand extends Command {
|
|
|
16
16
|
};
|
|
17
17
|
async init() {
|
|
18
18
|
await super.init();
|
|
19
|
-
|
|
20
|
-
setupDebugLogger(Logger, { enableDefaultNamespace: false });
|
|
19
|
+
setupDebugLogger(PKCLogger, { enableDefaultNamespace: false });
|
|
21
20
|
}
|
|
22
21
|
async _connectToPkcRpc(pkcRpcUrl) {
|
|
23
22
|
const connectOverride = getPKCConnectOverride();
|
|
@@ -28,7 +27,6 @@ export class BaseCommand extends Command {
|
|
|
28
27
|
const errors = [];
|
|
29
28
|
pkc.on("error", (err) => {
|
|
30
29
|
errors.push(err);
|
|
31
|
-
console.error("Error from pkc instance", err);
|
|
32
30
|
});
|
|
33
31
|
await new Promise((resolve, reject) => {
|
|
34
32
|
const timeout = setTimeout(() => {
|
|
@@ -39,6 +37,11 @@ export class BaseCommand extends Command {
|
|
|
39
37
|
clearTimeout(timeout);
|
|
40
38
|
resolve();
|
|
41
39
|
});
|
|
40
|
+
}).catch((err) => {
|
|
41
|
+
if (err && typeof err === "object" && "code" in err && err.code === "ERR_RPC_AUTH_REQUIRED") {
|
|
42
|
+
throw err;
|
|
43
|
+
}
|
|
44
|
+
throw new Error(`Could not connect to the daemon at ${pkcRpcUrl}. Is it running? Start it with: bitsocial daemon`);
|
|
42
45
|
});
|
|
43
46
|
return pkc;
|
|
44
47
|
}
|
|
@@ -3,7 +3,7 @@ import { Flags } from "@oclif/core";
|
|
|
3
3
|
import DataObjectParser from "dataobject-parser";
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import { BaseCommand } from "../../base-command.js";
|
|
6
|
-
import {
|
|
6
|
+
import { PKCLogger } from "../../../util.js";
|
|
7
7
|
import * as remeda from "remeda";
|
|
8
8
|
export default class Create extends BaseCommand {
|
|
9
9
|
static description = "Create a community with specific properties. A newly created community will be started after creation and be able to receive publications. For a list of properties, visit https://github.com/pkcprotocol/pkc-js";
|
|
@@ -21,7 +21,7 @@ export default class Create extends BaseCommand {
|
|
|
21
21
|
};
|
|
22
22
|
async run() {
|
|
23
23
|
const { flags } = await this.parse(Create);
|
|
24
|
-
const log = (
|
|
24
|
+
const log = PKCLogger("bitsocial-cli:commands:community:create");
|
|
25
25
|
log(`flags: `, flags);
|
|
26
26
|
const pkc = await this._connectToPkcRpc(flags.pkcRpcUrl.toString());
|
|
27
27
|
const createOptions = DataObjectParser.transpose(remeda.omit(flags, ["pkcRpcUrl", "privateKeyPath"]))["_data"];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PKCLogger } from "../../../util.js";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
export default class Delete extends BaseCommand {
|
|
@@ -17,7 +17,7 @@ export default class Delete extends BaseCommand {
|
|
|
17
17
|
];
|
|
18
18
|
async run() {
|
|
19
19
|
const { argv, flags } = await this.parse(Delete);
|
|
20
|
-
const log = (
|
|
20
|
+
const log = PKCLogger("bitsocial-cli:commands:community:delete");
|
|
21
21
|
log(`addresses: `, argv);
|
|
22
22
|
log(`flags: `, flags);
|
|
23
23
|
const addresses = argv;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import DataObjectParser from "dataobject-parser";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
import { BaseCommand } from "../../base-command.js";
|
|
5
|
-
import {
|
|
5
|
+
import { PKCLogger, mergeDeep } from "../../../util.js";
|
|
6
6
|
import * as remeda from "remeda";
|
|
7
7
|
export default class Edit extends BaseCommand {
|
|
8
8
|
static description = "Edit a community's properties. For a list of properties, visit https://github.com/pkcprotocol/pkc-js";
|
|
@@ -45,7 +45,7 @@ export default class Edit extends BaseCommand {
|
|
|
45
45
|
];
|
|
46
46
|
async run() {
|
|
47
47
|
const { flags, args } = await this.parse(Edit);
|
|
48
|
-
const log = (
|
|
48
|
+
const log = PKCLogger("bitsocial-cli:commands:community:edit");
|
|
49
49
|
log(`flags: `, flags);
|
|
50
50
|
const pkc = await this._connectToPkcRpc(flags.pkcRpcUrl.toString());
|
|
51
51
|
const editOptions = DataObjectParser.transpose(remeda.omit(flags, ["pkcRpcUrl"]))["_data"];
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Flags } from "@oclif/core";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { EOL } from "os";
|
|
4
|
-
import {
|
|
4
|
+
import { PKCLogger } from "../../../util.js";
|
|
5
5
|
import { printTable } from "@oclif/table";
|
|
6
6
|
export default class List extends BaseCommand {
|
|
7
7
|
static description = "List your communities";
|
|
@@ -11,7 +11,7 @@ export default class List extends BaseCommand {
|
|
|
11
11
|
};
|
|
12
12
|
async run() {
|
|
13
13
|
const { flags } = await this.parse(List);
|
|
14
|
-
const log = (
|
|
14
|
+
const log = PKCLogger("bitsocial-cli:commands:community:list");
|
|
15
15
|
log(`flags: `, flags);
|
|
16
16
|
const pkc = await this._connectToPkcRpc(flags.pkcRpcUrl.toString());
|
|
17
17
|
const communities = pkc.communities;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PKCLogger } from "../../../util.js";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
export default class Start extends BaseCommand {
|
|
@@ -22,7 +22,7 @@ export default class Start extends BaseCommand {
|
|
|
22
22
|
async run() {
|
|
23
23
|
const { argv, flags } = await this.parse(Start);
|
|
24
24
|
const addresses = argv;
|
|
25
|
-
const log = (
|
|
25
|
+
const log = PKCLogger("bitsocial-cli:commands:community:start");
|
|
26
26
|
log(`addresses: `, addresses);
|
|
27
27
|
log(`flags: `, flags);
|
|
28
28
|
const pkc = await this._connectToPkcRpc(flags.pkcRpcUrl.toString());
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PKCLogger } from "../../../util.js";
|
|
2
2
|
import { BaseCommand } from "../../base-command.js";
|
|
3
3
|
import { Args } from "@oclif/core";
|
|
4
4
|
export default class Stop extends BaseCommand {
|
|
@@ -17,7 +17,7 @@ export default class Stop extends BaseCommand {
|
|
|
17
17
|
];
|
|
18
18
|
async run() {
|
|
19
19
|
const { argv, flags } = await this.parse(Stop);
|
|
20
|
-
const log = (
|
|
20
|
+
const log = PKCLogger("bitsocial-cli:commands:community:stop");
|
|
21
21
|
log(`addresses: `, argv);
|
|
22
22
|
log(`flags: `, flags);
|
|
23
23
|
const addresses = argv;
|
|
@@ -3,7 +3,7 @@ import defaults from "../../common-utils/defaults.js";
|
|
|
3
3
|
import { startKuboNode } from "../../ipfs/startIpfs.js";
|
|
4
4
|
import path from "path";
|
|
5
5
|
import tcpPortUsed from "tcp-port-used";
|
|
6
|
-
import { getLanIpV4Address,
|
|
6
|
+
import { getLanIpV4Address, PKCLogger, setupDebugLogger, loadKuboConfigFile, parseMultiAddrKuboRpcToUrl, parseMultiAddrIpfsGatewayToUrl } from "../../util.js";
|
|
7
7
|
import { startDaemonServer } from "../../webui/daemon-server.js";
|
|
8
8
|
import { loadChallengesIntoPKC } from "../../challenge-packages/challenge-utils.js";
|
|
9
9
|
import { migrateDataDirectory } from "../../common-utils/data-migration.js";
|
|
@@ -161,10 +161,9 @@ export default class Daemon extends Command {
|
|
|
161
161
|
process.env["DEBUG_COLORS"] = "1";
|
|
162
162
|
process.env["DEBUG_HIDE_DATE"] = "1";
|
|
163
163
|
const { flags } = await this.parse(Daemon);
|
|
164
|
-
|
|
165
|
-
this.
|
|
166
|
-
const
|
|
167
|
-
const log = Logger("bitsocial-cli:daemon");
|
|
164
|
+
this._setupLogger(PKCLogger);
|
|
165
|
+
const { logFilePath, stdoutWrite } = await this._pipeDebugLogsToLogFile(flags.logPath, PKCLogger);
|
|
166
|
+
const log = PKCLogger("bitsocial-cli:daemon");
|
|
168
167
|
try {
|
|
169
168
|
// Log debug info after pipe is set up so it goes to the log file, not terminal
|
|
170
169
|
const envDebug = process.env["_PKC_DEBUG"] || process.env["DEBUG"];
|
package/dist/ipfs/startIpfs.js
CHANGED
|
@@ -5,7 +5,7 @@ import * as fsPromises from "fs/promises";
|
|
|
5
5
|
import assert from "assert";
|
|
6
6
|
import tcpPortUsed from "tcp-port-used";
|
|
7
7
|
import { path as ipfsExePathFunc } from "kubo";
|
|
8
|
-
import {
|
|
8
|
+
import { PKCLogger } from "../util.js";
|
|
9
9
|
async function getKuboExePath() {
|
|
10
10
|
return ipfsExePathFunc();
|
|
11
11
|
}
|
|
@@ -189,7 +189,7 @@ async function ensureIpfsPortsAreAvailable(log, configPath, apiUrl, gatewayUrl)
|
|
|
189
189
|
}
|
|
190
190
|
export async function startKuboNode(apiUrl, gatewayUrl, dataPath, onSpawn) {
|
|
191
191
|
return new Promise(async (resolve, reject) => {
|
|
192
|
-
const log = (
|
|
192
|
+
const log = PKCLogger("bitsocial-cli:ipfs:startKuboNode");
|
|
193
193
|
const ipfsDataPath = process.env["IPFS_PATH"] || path.join(dataPath, ".bitsocial-cli.ipfs");
|
|
194
194
|
await fs.promises.mkdir(ipfsDataPath, { recursive: true });
|
|
195
195
|
const ipfsConfigPath = path.join(ipfsDataPath, "config");
|
package/dist/util.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import PKCLogger from "@pkcprotocol/pkc-logger";
|
|
2
|
+
export { PKCLogger };
|
|
3
|
+
export type PKCLoggerType = typeof PKCLogger & {
|
|
2
4
|
inspectOpts?: {
|
|
3
5
|
depth?: number;
|
|
4
6
|
colors?: boolean;
|
|
5
7
|
[key: string]: any;
|
|
6
8
|
};
|
|
7
9
|
};
|
|
8
|
-
export declare function getPKCLogger(): Promise<typeof import("@pkcprotocol/pkc-logger").default>;
|
|
9
10
|
/**
|
|
10
11
|
* Read _PKC_DEBUG / DEBUG env vars and configure the Logger instance.
|
|
11
12
|
* Does NOT redirect output — debug logs go to stderr (the default for the debug module).
|
|
@@ -14,7 +15,7 @@ export declare function getPKCLogger(): Promise<typeof import("@pkcprotocol/pkc-
|
|
|
14
15
|
* when no DEBUG env is set (used by daemon). If false, only enable if user
|
|
15
16
|
* explicitly set DEBUG or _PKC_DEBUG (used by non-daemon commands).
|
|
16
17
|
*/
|
|
17
|
-
export declare function setupDebugLogger(Logger:
|
|
18
|
+
export declare function setupDebugLogger(Logger: PKCLoggerType, options?: {
|
|
18
19
|
enableDefaultNamespace?: boolean;
|
|
19
20
|
}): {
|
|
20
21
|
debugNamespace: string | undefined;
|
package/dist/util.js
CHANGED
|
@@ -2,10 +2,8 @@ import os from "os";
|
|
|
2
2
|
import path from "path";
|
|
3
3
|
import fs from "fs";
|
|
4
4
|
import * as fsPromises from "fs/promises";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return Logger.default;
|
|
8
|
-
}
|
|
5
|
+
import PKCLogger from "@pkcprotocol/pkc-logger";
|
|
6
|
+
export { PKCLogger };
|
|
9
7
|
/**
|
|
10
8
|
* Read _PKC_DEBUG / DEBUG env vars and configure the Logger instance.
|
|
11
9
|
* Does NOT redirect output — debug logs go to stderr (the default for the debug module).
|
|
@@ -3,7 +3,7 @@ import { fileURLToPath } from "url";
|
|
|
3
3
|
const __filename = fileURLToPath(import.meta.url);
|
|
4
4
|
const __dirname = path.dirname(__filename);
|
|
5
5
|
import fs from "fs/promises";
|
|
6
|
-
import {
|
|
6
|
+
import { PKCLogger } from "../util.js";
|
|
7
7
|
import { randomBytes } from "crypto";
|
|
8
8
|
import express from "express";
|
|
9
9
|
import { loadChallengesIntoPKC } from "../challenge-packages/challenge-utils.js";
|
|
@@ -40,7 +40,7 @@ async function _generateRpcAuthKeyIfNotExisting(pkcDataPath) {
|
|
|
40
40
|
// The daemon server will host both RPC and webui on the same port
|
|
41
41
|
export async function startDaemonServer(rpcUrl, ipfsGatewayUrl, pkcOptions) {
|
|
42
42
|
// Start pkc-js RPC
|
|
43
|
-
const log = (
|
|
43
|
+
const log = PKCLogger("bitsocial-cli:daemon:startDaemonServer");
|
|
44
44
|
const webuiExpressApp = express();
|
|
45
45
|
const httpServer = webuiExpressApp.listen(Number(rpcUrl.port));
|
|
46
46
|
log("HTTP server is running on", "0.0.0.0" + ":" + rpcUrl.port);
|