Skip to content

Commit de2b817

Browse files
committed
feat: add architecture documentation outlining project structure and command flow
1 parent e0d9864 commit de2b817

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

‎docs/architecture.md‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Architecture
2+
3+
## Overview
4+
5+
```mermaid
6+
flowchart LR
7+
cli[cli.ts] --> parser[commands/parser.ts]
8+
parser --> executor[commands/executor.ts]
9+
executor --> sdk[sdk/management.ts]
10+
executor --> lib[lib/hash.ts / lib/sign.ts]
11+
sdk --> api[Source Push REST API]
12+
```
13+
14+
## Entry points
15+
16+
| File | Role |
17+
|------|------|
18+
| `src/cli.ts` | Parses argv via yargs, calls `execute()` |
19+
| `src/index.ts` | Re-exports `AccountManager` for programmatic use |
20+
| `dist/cli.js` | Published npm bin (`srcpush`) |
21+
| `dist/index.js` | Published SDK entry |
22+
23+
## Command flow
24+
25+
1. **Parser** (`commands/parser.ts`) — yargs definitions map argv → `ICommand` objects (`types/cli.ts`).
26+
2. **Executor** (`commands/executor.ts`) — dispatches by `CommandType`, formats output, handles confirmations.
27+
3. **Management SDK** (`sdk/management.ts`) — HTTP via superagent to the Source Push API.
28+
4. **Acquisition SDK** (`sdk/acquisition.ts`) — client-side update check protocol (used by RN plugin, also exported).
29+
30+
## `runtime` object
31+
32+
`commands/executor.ts` exports a `runtime` object (`sdk`, `log`, `spawn`, `confirm`, `createEmptyTempReleaseFolder`, `release`) so tests can stub dependencies without fighting ESM live bindings.
33+
34+
## Build
35+
36+
Vite compiles TypeScript to **CommonJS** with `preserveModules: true` into `dist/`. The shebang in `cli.ts` is preserved in `dist/cli.js`.
37+
38+
## Hash integrity
39+
40+
Package hashing in `src/lib/hash.ts` is duplicated in the API service for server-side validation. Keep both implementations aligned.

0 commit comments

Comments
 (0)