Skip to content

Commit 01ae1f1

Browse files
authored
Merge branch 'main' into ci/add-codeql-workflow
2 parents fa2305d + f1c1118 commit 01ae1f1

71 files changed

Lines changed: 6115 additions & 581 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/sour-dolls-sip.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"nostream": major
3+
---
4+
5+
Add a brand-new unified `nostream` CLI/TUI that replaces the legacy `scripts/*` shell wrappers for lifecycle, setup, info, config, data, and development workflows.
6+
7+
**Fixes**
8+
- fixed some consistnacy issues after the migration from `npm` to `pnpm`

.changeset/sunny-jars-try.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"nostream": patch
3+
---
4+
5+
fix: static mirroring silently drops events when mirror has no limits configured

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,6 @@ WORKER_COUNT=2 # Defaults to CPU count. Use 1 or 2 for local testing.
6969
# HIDDEN_SERVICE_PORT=80
7070

7171
# --- I2P (Optional) ---
72-
# To enable I2P, use: ./scripts/start_with_i2p
72+
# To enable I2P, use: nostream start --i2p
7373
# I2P tunnel configuration lives in i2p/tunnels.conf and i2p/i2pd.conf.
7474
# No application-level env vars are needed; the i2pd sidecar handles everything.

.github/workflows/checks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@ jobs:
6161
run: pnpm install --frozen-lockfile
6262
- name: Run build check
6363
run: pnpm run build:check
64+
- name: Build artifacts
65+
run: pnpm run build
66+
- name: Verify built CLI entrypoint
67+
run: pnpm run verify:cli:build
6468
test-units-and-cover:
6569
name: Unit Tests And Coverage
6670
runs-on: ubuntu-latest
@@ -80,6 +84,8 @@ jobs:
8084
run: pnpm install --frozen-lockfile
8185
- name: Run unit tests
8286
run: pnpm run test:unit
87+
- name: Run CLI test suite
88+
run: pnpm run test:cli
8389
- name: Run coverage for unit tests
8490
run: pnpm run cover:unit
8591
if: ${{ always() }}

.knip.json

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
11
{
22
"$schema": "https://unpkg.com/knip@2/schema.json",
33
"entry": [
4-
"src/index.ts",
5-
"src/import-events.ts",
6-
"knexfile.js"
4+
"src/index.ts!",
5+
"src/import-events.ts!",
6+
"src/cli/index.ts!",
7+
"src/scripts/benchmark-queries.ts!",
8+
"knexfile.js!"
79
],
810
"project": [
9-
"src/**/*.ts"
11+
"src/**/*.ts!"
1012
],
1113
"ignoreDependencies": [
1214
"lzma-native"
1315
],
14-
"ignoreFiles": [],
16+
"ignore": [
17+
".nostr/**"
18+
],
1519
"commitlint": false,
1620
"eslint": false,
1721
"github-actions": false,
1822
"husky": false,
1923
"mocha": false,
2024
"nyc": false,
2125
"semantic-release": false
22-
}
26+
}

CLI.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Nostream CLI
2+
3+
Nostream ships a unified command-line interface:
4+
5+
```bash
6+
nostream --help
7+
pnpm run cli -- --help
8+
```
9+
10+
When run with no arguments in an interactive terminal, `nostream` launches an interactive TUI.
11+
In non-interactive environments, it prints help and exits successfully.
12+
13+
## Exit Codes
14+
15+
- `0`: success
16+
- `1`: runtime/validation error
17+
- `2`: usage error (invalid command/options)
18+
19+
## Core Commands
20+
21+
```bash
22+
nostream start [--tor] [--i2p] [--nginx] [--debug] [--port 8008]
23+
nostream stop [--all|--tor|--i2p|--nginx|--local]
24+
nostream info [--tor-hostname] [--i2p-hostname] [--json]
25+
nostream update
26+
nostream clean
27+
nostream setup [--yes] [--start]
28+
nostream seed [--count 100]
29+
nostream import [file.jsonl|file.json] [--file file.jsonl|file.json] [--batch-size 1000]
30+
nostream export [output] [--output output] [--format jsonl|json]
31+
```
32+
33+
## Removed Legacy Wrappers
34+
35+
The old shell wrapper scripts are no longer shipped in `scripts/`.
36+
Use the unified `nostream` CLI directly instead:
37+
38+
```bash
39+
scripts/start -> nostream start
40+
scripts/start_with_tor -> nostream start --tor
41+
scripts/start_with_i2p -> nostream start --i2p
42+
scripts/start_with_nginx -> nostream start --nginx
43+
scripts/stop -> nostream stop
44+
scripts/print_tor_hostname -> nostream info --tor-hostname
45+
scripts/print_i2p_hostname -> nostream info --i2p-hostname
46+
scripts/update -> nostream update
47+
scripts/clean -> nostream clean
48+
```
49+
50+
## Configuration Commands
51+
52+
```bash
53+
nostream config list
54+
nostream config list --json
55+
nostream config get <path>
56+
nostream config get <path> --json
57+
nostream config set <path> <value> [--type inferred|json] [--validate|--no-validate] [--restart]
58+
nostream config validate
59+
60+
nostream config env list [--show-secrets]
61+
nostream config env get <key> [--show-secrets]
62+
nostream config env set <key> <value>
63+
nostream config env validate
64+
```
65+
66+
Path syntax supports dot keys and array indexes:
67+
68+
```bash
69+
nostream config get limits.event.content[0].maxLength
70+
nostream config set limits.event.content[0].maxLength 2048
71+
nostream config set nip05.domainWhitelist '["example.com","relay.io"]' --type json
72+
```
73+
74+
## Development Commands
75+
76+
```bash
77+
nostream dev db:clean [--all|--older-than=30|--kinds=1,7,4] [--dry-run] [--force]
78+
nostream dev db:reset [--yes]
79+
nostream dev seed:relay
80+
nostream dev docker:clean [--yes]
81+
nostream dev test:unit
82+
nostream dev test:cli
83+
nostream dev test:integration
84+
```
85+
86+
## TUI Navigation
87+
88+
Run:
89+
90+
```bash
91+
nostream
92+
```
93+
94+
Main menu includes:
95+
- Start relay
96+
- Stop relay
97+
- Configure settings
98+
- Manage data (export/import)
99+
- Development tools
100+
- View relay info
101+
- Exit
102+
103+
TUI behavior highlights:
104+
- Each submenu includes an explicit `Back` option, so you can return without using signal keys.
105+
- Start menu prompts for Tor/I2P/Debug, optional custom port, and final confirmation.
106+
- Configure menu offers guided editing for common categories such as payments, network, and limits.
107+
- Advanced dot-path get/set remains available for full settings access.
108+
- Manage menu asks for import/export format and file paths.
109+
- Dev menu displays explicit destructive warnings before DB reset/clean and Docker clean.
110+
111+
## Common Workflows
112+
113+
```bash
114+
# Start relay with Tor + I2P
115+
nostream start --tor --i2p
116+
117+
# Print Tor hostname
118+
nostream info --tor-hostname
119+
120+
# Machine-readable output for automation
121+
nostream info --json
122+
nostream config list --json
123+
nostream config get payments.enabled --json
124+
125+
# Import and export events
126+
nostream import --file ./events.jsonl --batch-size 500
127+
nostream import --file ./events.json --batch-size 500
128+
nostream export --output backup.jsonl --format jsonl
129+
nostream export --output backup.json --format json
130+
131+
# Update YAML settings and restart relay
132+
nostream config set payments.enabled true --restart
133+
134+
# Update env settings
135+
nostream config env set RELAY_PORT 8008
136+
nostream config env get SECRET --show-secrets
137+
nostream config env validate
138+
```

CONFIGURATION.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ Tunnel keys are persisted at `.nostr/i2p/data/` so the `.b32.i2p` address surviv
7373

7474
The i2pd web console (tunnel status, `.b32.i2p` destinations) is published to the host on **`127.0.0.1:7070`** only. Remove the `ports:` mapping in `docker-compose.i2p.yml` to disable host-side access.
7575

76-
- Start with I2P: `./scripts/start_with_i2p`
77-
- Print hostname hints: `./scripts/print_i2p_hostname`
76+
- Start with I2P: `nostream start --i2p`
7877

7978
If you've set READ_REPLICAS to 4, you should configure RR0_ through RR3_.
8079

CONTRIBUTING.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ corepack enable
4747
pnpm install
4848
```
4949

50+
Use the unified CLI for relay lifecycle and supported development operations from this source
51+
checkout:
52+
53+
```
54+
pnpm run cli -- --help
55+
```
56+
5057
> **Important:** Pre-commit hooks installed by Husky run linting and formatting checks on every
5158
> commit. Do **not** bypass them with `git commit --no-verify`. If a hook fails, fix the reported
5259
> issues before committing.
@@ -56,7 +63,7 @@ pnpm install
5663
Start the relay (runs in the foreground until stopped with Ctrl+C):
5764

5865
```
59-
./scripts/start
66+
pnpm run cli -- start
6067
```
6168

6269
### Development Quick Start (Standalone)
@@ -149,7 +156,7 @@ cd /path/to/nostream
149156
Run unit tests:
150157

151158
```
152-
pnpm test:unit
159+
pnpm run cli -- dev test:unit
153160
```
154161

155162
Run unit tests in watch mode:
@@ -223,7 +230,7 @@ DB_MAX_POOL_SIZE=2
223230
Run the integration tests:
224231

225232
```
226-
pnpm test:integration
233+
pnpm run cli -- dev test:integration
227234
```
228235

229236
Open the integration test report:

0 commit comments

Comments
 (0)