@toon-protocol/townhouse 0.1.0-rc5 → 0.1.1
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 +117 -0
- package/dist/chunk-5O4SBV5O.js +538 -0
- package/dist/chunk-5O4SBV5O.js.map +1 -0
- package/dist/chunk-GQNBZJ6F.js +39 -0
- package/dist/chunk-GQNBZJ6F.js.map +1 -0
- package/dist/{chunk-UTFWPLTB.js → chunk-I2R4CRUX.js} +2 -22
- package/dist/chunk-I2R4CRUX.js.map +1 -0
- package/dist/chunk-JCOFMUPL.js +65 -0
- package/dist/chunk-JCOFMUPL.js.map +1 -0
- package/dist/chunk-W33MEOPM.js +22111 -0
- package/dist/chunk-W33MEOPM.js.map +1 -0
- package/dist/cli.d.ts +94 -2
- package/dist/cli.js +3116 -111
- package/dist/cli.js.map +1 -1
- package/dist/compose/townhouse-dev.yml +1 -1
- package/dist/compose/townhouse-hs.yml +126 -19
- package/dist/{demo-MJR47QHZ.js → demo-3DWRDMYY.js} +3 -2
- package/dist/{demo-MJR47QHZ.js.map → demo-3DWRDMYY.js.map} +1 -1
- package/dist/image-manifest.json +12 -12
- package/dist/index.d.ts +1286 -655
- package/dist/index.js +37 -140
- package/dist/index.js.map +1 -1
- package/dist/manager-SsneW_Mj.d.ts +519 -0
- package/dist/rsa-from-seed-XIT6EU73.js +67 -0
- package/dist/rsa-from-seed-XIT6EU73.js.map +1 -0
- package/dist/tui-OIFXGBTL.js +625 -0
- package/dist/tui-OIFXGBTL.js.map +1 -0
- package/package.json +19 -3
- package/dist/chunk-IB6TNCUQ.js +0 -8274
- package/dist/chunk-IB6TNCUQ.js.map +0 -1
- package/dist/chunk-UTFWPLTB.js.map +0 -1
package/dist/cli.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import Docker from 'dockerode';
|
|
3
|
+
import { C as ComposeLoaderOptions, T as TownhouseConfig, W as WalletManager, N as NodeType } from './manager-SsneW_Mj.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Cross-platform browser opener for the wizard CLI command.
|
|
@@ -9,6 +10,33 @@ interface BrowserOpener {
|
|
|
9
10
|
open(url: string): Promise<void>;
|
|
10
11
|
}
|
|
11
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Port-collision preflight for `townhouse hs up` (Epic 49 Followup B).
|
|
15
|
+
*
|
|
16
|
+
* Detects host-port conflicts BEFORE handing off to Docker, so operators get
|
|
17
|
+
* an actionable error message instead of a cryptic mid-boot EADDRINUSE.
|
|
18
|
+
*
|
|
19
|
+
* Detection strategy (defense in depth):
|
|
20
|
+
* 1. Bind a transient TCP socket to 127.0.0.1:<port> and immediately close.
|
|
21
|
+
* If bind throws EADDRINUSE, the port is occupied. Pure Node, no deps,
|
|
22
|
+
* works on Linux/Mac/WSL — this is the source of truth.
|
|
23
|
+
* 2. If (1) flags a collision, ask Docker for the offending container's
|
|
24
|
+
* name + compose project so the message can name a culprit. Best-effort
|
|
25
|
+
* enrichment — Docker may be unreachable, in which case we still report
|
|
26
|
+
* the port and suggest `lsof` for non-Docker processes.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
interface PortCollision {
|
|
30
|
+
/** The host port that is already bound. */
|
|
31
|
+
port: number;
|
|
32
|
+
/** Name of the Docker container holding the port (when known). */
|
|
33
|
+
containerName?: string;
|
|
34
|
+
/** Compose project the container belongs to (when known). */
|
|
35
|
+
composeProject?: string;
|
|
36
|
+
/** Container status string e.g. "Up 5 hours" (when known). */
|
|
37
|
+
status?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
12
40
|
/**
|
|
13
41
|
* CLI entrypoint for `@toon-protocol/townhouse` (Story 21.1).
|
|
14
42
|
*
|
|
@@ -29,10 +57,74 @@ interface BrowserOpener {
|
|
|
29
57
|
declare class CliHelpRequested extends Error {
|
|
30
58
|
constructor();
|
|
31
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Dependency-injection overrides for the `hs up` / `hs down` CLI path.
|
|
62
|
+
* Used by unit tests to stub out Docker, file I/O, and admin client.
|
|
63
|
+
*/
|
|
64
|
+
interface CliHsOverrides {
|
|
65
|
+
/** Override materializeComposeTemplate (avoids disk writes in tests). */
|
|
66
|
+
materializeComposeTemplate?: (profile: string, opts?: ComposeLoaderOptions) => {
|
|
67
|
+
composePath: string;
|
|
68
|
+
manifestPath: string;
|
|
69
|
+
};
|
|
70
|
+
/** Override the DockerOrchestrator constructor (avoids real Docker in tests). */
|
|
71
|
+
createOrchestrator?: (docker: Docker, config: TownhouseConfig, walletManager: WalletManager | undefined, options: {
|
|
72
|
+
profile: 'hs';
|
|
73
|
+
composePath: string;
|
|
74
|
+
}) => {
|
|
75
|
+
up: (profiles: NodeType[]) => Promise<void>;
|
|
76
|
+
down: () => Promise<void>;
|
|
77
|
+
on: (event: string, handler: (...args: unknown[]) => void) => unknown;
|
|
78
|
+
/**
|
|
79
|
+
* Pre-pull a single image ref (Epic 49 Followup D).
|
|
80
|
+
* Optional on the stub interface — when omitted on a real orchestrator,
|
|
81
|
+
* the cold-pull narration phase is skipped (silent degrade).
|
|
82
|
+
*/
|
|
83
|
+
pullImage?: (image: string) => Promise<void>;
|
|
84
|
+
};
|
|
85
|
+
/** Override ConnectorAdminClient construction (avoids real HTTP in tests). */
|
|
86
|
+
createAdminClient?: (baseUrl: string, timeoutMs: number) => {
|
|
87
|
+
getHsHostname: () => Promise<{
|
|
88
|
+
hostname: string | null;
|
|
89
|
+
publishedAt: string | null;
|
|
90
|
+
}>;
|
|
91
|
+
};
|
|
92
|
+
/** Override `docker compose down -v` spawn for --rotate-keys (avoids real Docker). */
|
|
93
|
+
runComposeDown?: (composePath: string, withVolumes: boolean) => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* Override BootReconciler construction (Story 46.1). Tests inject a stub
|
|
96
|
+
* with a spied-on `reconcile()` to assert wiring without touching disk
|
|
97
|
+
* or the connector. When omitted, the default constructs a real
|
|
98
|
+
* `BootReconciler` against `~/.townhouse/{nodes.yaml,reconciler.log}`.
|
|
99
|
+
*/
|
|
100
|
+
createReconciler?: (nodesYamlPath: string, reconcilerLogPath: string) => {
|
|
101
|
+
reconcile: () => Promise<void>;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Override the port-collision preflight check (Epic 49 Followup B).
|
|
105
|
+
* Default invokes `checkHsPortCollisions(docker)` from
|
|
106
|
+
* `./cli/preflight-ports.js`. Tests inject a stub that returns either
|
|
107
|
+
* `[]` (happy path) or a fabricated PortCollision[] (collision path) so
|
|
108
|
+
* the production socket-bind + Docker enrichment is not exercised in
|
|
109
|
+
* unit tests.
|
|
110
|
+
*/
|
|
111
|
+
checkPortCollisions?: (docker: Docker) => Promise<PortCollision[]>;
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Dependency-injection overrides for the `node add` / `node remove` / `node list` CLI path.
|
|
115
|
+
* Used by unit tests to stub `fetch` and the interactive confirmation prompt.
|
|
116
|
+
*/
|
|
117
|
+
interface CliNodeCommandOverrides {
|
|
118
|
+
fetch?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
119
|
+
confirm?: (question: string) => Promise<boolean>;
|
|
120
|
+
apiUrl?: string;
|
|
121
|
+
}
|
|
32
122
|
/**
|
|
33
123
|
* Main CLI entry — exported for testability (same pattern as Mill CLI).
|
|
34
124
|
* Accepts optional dockerode instance for dependency injection in tests.
|
|
125
|
+
* The optional `hsOverrides` bag is used by unit tests to stub out Docker,
|
|
126
|
+
* file I/O, and admin-client calls in the `hs up` / `hs down` path.
|
|
35
127
|
*/
|
|
36
|
-
declare function main(argv: string[], dockerInstance?: Docker, browserOpener?: BrowserOpener): Promise<void>;
|
|
128
|
+
declare function main(argv: string[], dockerInstance?: Docker, browserOpener?: BrowserOpener, hsOverrides?: CliHsOverrides, nodeCommandOverrides?: CliNodeCommandOverrides): Promise<void>;
|
|
37
129
|
|
|
38
|
-
export { CliHelpRequested, main };
|
|
130
|
+
export { CliHelpRequested, type CliHsOverrides, type CliNodeCommandOverrides, main };
|