Skip to content

Commit 5af3dd7

Browse files
docs: migration guide + ADR-0010 + update all docs for toolkit (#71)
- docs/migration.md: before/after package mapping, install, import, CLI, and fixture migration examples - docs/adr/0010-single-package-consolidation.md: ADR documenting the decision to consolidate four packages into @ocpp-debugkit/toolkit - Update README.md: package table, quickstart, install commands - Update CONTRIBUTING.md: package structure section - Update docs/adr/README.md: add ADR-0010 to index Closes #57
1 parent aa9b2c3 commit 5af3dd7

5 files changed

Lines changed: 447 additions & 26 deletions

File tree

CONTRIBUTING.md

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,24 @@ pnpm build
3232
```
3333
ocpp-debugkit/
3434
├── packages/
35-
│ ├── core/ # Data model, parser, normalizer, timeline, failure detection
36-
│ ├── scenarios/ # Predefined trace scenarios for testing
37-
│ ├── reporter/ # Report generators (Markdown, HTML)
38-
│ ├── cli/ # Command-line interface
39-
│ ├── replay/ # Replay engine (v0.2+)
40-
│ └── react/ # Reusable React components (v0.2+)
35+
│ └── toolkit/ # Single npm package @ocpp-debugkit/toolkit
36+
│ └── src/
37+
│ ├── core/ # Data model, parser, normalizer, timeline, failure detection
38+
│ ├── scenarios/ # Predefined trace scenarios for testing
39+
│ ├── reporter/ # Report generators (Markdown, HTML)
40+
│ ├── replay/ # Replay engine
41+
│ ├── react/ # Reusable React components
42+
│ └── cli/ # Command-line interface (bin: ocpp-debugkit)
4143
├── apps/
4244
│ └── web/ # Single Next.js app (landing, inspector, docs, blog)
4345
└── ...
4446
```
4547

48+
All modules ship in a single package, `@ocpp-debugkit/toolkit`, exposed via
49+
subpath exports (`@ocpp-debugkit/toolkit/core`, `/scenarios`, `/reporter`,
50+
`/replay`, `/react`, `/cli`, `/fixtures`). See
51+
[ADR-0010](./docs/adr/0010-single-package-consolidation.md) for the rationale.
52+
4653
See [`AGENTS.md`](./AGENTS.md) for a detailed overview of the architecture,
4754
build commands, and package dependency graph.
4855

README.md

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,33 @@ validate behavior against known scenarios.
3737

3838
## Architecture
3939

40-
OCPP DebugKit is a pnpm monorepo with independently versioned packages.
40+
OCPP DebugKit is a pnpm monorepo. All modules ship in a single npm package,
41+
`@ocpp-debugkit/toolkit`, exposed via [subpath exports](https://nodejs.org/api/packages.html#subpath-exports).
4142

4243
```
43-
core ← everything depends on this
44-
/ | \
45-
scenarios | reporter | replay
46-
\ | / |
47-
cli |
48-
| |
49-
apps/web (single Next.js app)
44+
@ocpp-debugkit/toolkit
45+
├── core ← data model, parser, normalizer, timeline, failure detection
46+
├── scenarios ← predefined trace scenarios (depends on core)
47+
├── reporter ← report generators — Markdown, HTML (depends on core)
48+
├── replay ← replay engine (depends on core)
49+
├── react ← reusable React components (depends on core, scenarios, reporter)
50+
└── cli ← command-line interface (depends on core, scenarios, reporter)
51+
52+
└── apps/web (single Next.js app)
5053
```
5154

52-
| Package | Description | Version |
53-
|---------|-------------|---------|
54-
| `@ocpp-debugkit/core` | Data model, trace parser, event normalizer, timeline, failure detection | [![npm](https://img.shields.io/npm/v/@ocpp-debugkit/core.svg)](https://www.npmjs.com/package/@ocpp-debugkit/core) |
55-
| `@ocpp-debugkit/scenarios` | Predefined trace scenarios for testing | [![npm](https://img.shields.io/npm/v/@ocpp-debugkit/scenarios.svg)](https://www.npmjs.com/package/@ocpp-debugkit/scenarios) |
56-
| `@ocpp-debugkit/reporter` | Report generators (Markdown) | [![npm](https://img.shields.io/npm/v/@ocpp-debugkit/reporter.svg)](https://www.npmjs.com/package/@ocpp-debugkit/reporter) |
57-
| `@ocpp-debugkit/cli` | Command-line interface | [![npm](https://img.shields.io/npm/v/@ocpp-debugkit/cli.svg)](https://www.npmjs.com/package/@ocpp-debugkit/cli) |
58-
| `@ocpp-debugkit/replay` | Replay engine | _planned (v0.2.0)_ |
59-
| `@ocpp-debugkit/react` | Reusable React components | _planned (v0.2.0)_ |
60-
| `apps/web` | Single Next.js app (landing, inspector, docs) ||
55+
| Import path | Description |
56+
|-------------|-------------|
57+
| `@ocpp-debugkit/toolkit/core` | Data model, trace parser, event normalizer, timeline, failure detection |
58+
| `@ocpp-debugkit/toolkit/scenarios` | Predefined trace scenarios for testing |
59+
| `@ocpp-debugkit/toolkit/reporter` | Report generators (Markdown) |
60+
| `@ocpp-debugkit/toolkit/replay` | Replay engine |
61+
| `@ocpp-debugkit/toolkit/react` | Reusable React components |
62+
| `@ocpp-debugkit/toolkit/cli` | Programmatic CLI entry (`bin: ocpp-debugkit`) |
63+
| `@ocpp-debugkit/toolkit/fixtures` | Trace fixtures for testing |
64+
| `apps/web` | Single Next.js app (landing, inspector, docs) |
6165

62-
**Build order:** core → scenarios/reporter/replay → cli → app
66+
**Build order:** toolkit (all internal modules in one `tsc` pass) → app
6367

6468
## Quickstart
6569

@@ -74,13 +78,19 @@ pnpm build
7478

7579
### CLI
7680

77-
Packages are published to npm under the `@ocpp-debugkit` scope:
81+
Install the single package globally to get the `ocpp-debugkit` binary:
7882

7983
```bash
80-
npm install -g @ocpp-debugkit/cli
84+
npm install -g @ocpp-debugkit/toolkit
8185
ocpp-debugkit inspect trace.json
8286
```
8387

88+
Or use `npx` without installing:
89+
90+
```bash
91+
npx ocpp-debugkit inspect trace.json
92+
```
93+
8494
Other commands:
8595

8696
```bash
@@ -89,6 +99,17 @@ ocpp-debugkit scenario list
8999
ocpp-debugkit scenario run failed-auth
90100
```
91101

102+
### Programmatic Usage
103+
104+
```ts
105+
import { parseTrace, detectFailures } from '@ocpp-debugkit/toolkit/core';
106+
import { scenarios } from '@ocpp-debugkit/toolkit/scenarios';
107+
import { generateMarkdownReport } from '@ocpp-debugkit/toolkit/reporter';
108+
```
109+
110+
See the [Migration Guide](./docs/migration.md) if you are upgrading from the
111+
old multi-package layout.
112+
92113
### Web App
93114

94115
Visit [ocppdebugkit.com/inspector](https://ocppdebugkit.com/inspector) to
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
# ADR-0010: Single Package Consolidation
2+
3+
## Status
4+
5+
Accepted
6+
7+
## Context
8+
9+
OCPP DebugKit was originally published as four independent npm packages under
10+
the `@ocpp-debugkit` scope:
11+
12+
- `@ocpp-debugkit/core` — data model, trace parser, event normalizer, timeline,
13+
failure detection
14+
- `@ocpp-debugkit/scenarios` — predefined trace scenarios for testing
15+
- `@ocpp-debugkit/reporter` — report generators (Markdown)
16+
- `@ocpp-debugkit/cli` — command-line interface
17+
18+
Two additional packages — `@ocpp-debugkit/replay` (replay engine) and
19+
`@ocpp-debugkit/react` (reusable React components) — were planned for v0.2.0.
20+
21+
This multi-package layout created several problems:
22+
23+
1. **Version drift.** Each package was independently versioned. Consumers had
24+
to keep peer versions in sync, and a mismatch between `core` and `scenarios`
25+
could cause subtle runtime failures that were hard to diagnose.
26+
27+
2. **Cross-package coupling.** `scenarios`, `reporter`, and `cli` all depend on
28+
`core` types. A change to a `core` type required coordinated releases across
29+
all dependent packages, defeating the supposed independence.
30+
31+
3. **Installation friction.** Consumers needed to install and list multiple
32+
packages:
33+
34+
```bash
35+
npm install @ocpp-debugkit/core @ocpp-debugkit/scenarios @ocpp-debugkit/reporter
36+
```
37+
38+
4. **Release overhead.** Each release required changeset coordination across
39+
multiple packages, multiple `npm publish` calls, and CI that had to build
40+
and test the full dependency graph in order.
41+
42+
5. **Small project, not a library ecosystem.** The packages are tightly coupled
43+
and maintained by a single team. The independence promised by the
44+
multi-package layout was theoretical — in practice, every meaningful change
45+
touched multiple packages simultaneously.
46+
47+
6. **Internal module boundaries are enough.** The actual source code already
48+
lives in a single `packages/toolkit` directory with subdirectories (`core`,
49+
`scenarios`, `reporter`, `replay`, `react`, `cli`). The npm package
50+
boundaries were a publishing artifact, not an architectural one.
51+
52+
## Decision
53+
54+
**Consolidate all four published packages into a single npm package,
55+
`@ocpp-debugkit/toolkit`, exposed via subpath exports.**
56+
57+
### Package structure
58+
59+
```
60+
@ocpp-debugkit/toolkit
61+
exports:
62+
. # umbrella entry (re-exports core + scenarios)
63+
./core # data model, parser, normalizer, timeline, failure detection
64+
./scenarios # predefined trace scenarios
65+
./reporter # report generators (Markdown, HTML)
66+
./replay # replay engine
67+
./react # reusable React components
68+
./cli # programmatic CLI entry
69+
./fixtures # trace fixtures (moved from core/fixtures)
70+
bin:
71+
ocpp-debugkit # CLI binary
72+
```
73+
74+
### Subpath exports
75+
76+
Consumers import from `@ocpp-debugkit/toolkit/<module>` instead of
77+
`@ocpp-debugkit/<module>`:
78+
79+
```ts
80+
// Before
81+
import { parseTrace } from '@ocpp-debugkit/core';
82+
import { scenarios } from '@ocpp-debugkit/scenarios';
83+
import { generateMarkdownReport } from '@ocpp-debugkit/reporter';
84+
85+
// After
86+
import { parseTrace } from '@ocpp-debugkit/toolkit/core';
87+
import { scenarios } from '@ocpp-debugkit/toolkit/scenarios';
88+
import { generateMarkdownReport } from '@ocpp-debugkit/toolkit/reporter';
89+
```
90+
91+
### Binary
92+
93+
The CLI binary name remains `ocpp-debugkit`. Consumers install one package and
94+
get the CLI:
95+
96+
```bash
97+
npm install -g @ocpp-debugkit/toolkit
98+
ocpp-debugkit inspect trace.json
99+
```
100+
101+
For `npx`:
102+
103+
```bash
104+
npx ocpp-debugkit inspect trace.json
105+
```
106+
107+
### Deprecation of old packages
108+
109+
The four old packages (`@ocpp-debugkit/core`, `@ocpp-debugkit/scenarios`,
110+
`@ocpp-debugkit/reporter`, `@ocpp-debugkit/cli`) remain on npm with a
111+
`deprecated` flag in their latest published versions. They will not receive new
112+
features or bug fixes. A migration guide is provided at
113+
[`docs/migration.md`](../migration.md).
114+
115+
### Single version
116+
117+
`@ocpp-debugkit/toolkit` is a single versioned unit. No more peer-dependency
118+
mismatches — one version, one install, one release.
119+
120+
## Consequences
121+
122+
### Positive
123+
124+
- **Simpler installation.** One package to install: `npm install
125+
@ocpp-debugkit/toolkit`.
126+
- **No version drift.** All modules share a single version. Mismatches are
127+
structurally impossible.
128+
- **Faster releases.** One package, one publish, one changeset — instead of
129+
coordinated multi-package releases.
130+
- **Cleaner dependency graph.** Internal modules depend on each other via
131+
TypeScript path aliases, not npm dependencies. The build is a single `tsc`
132+
pass.
133+
- **Better tree-shaking.** Subpath exports let bundlers include only the
134+
modules a consumer actually imports. A consumer using only `core` doesn't pull
135+
in `react` or `cli`.
136+
- **Module boundaries preserved.** The `core` / `scenarios` / `reporter` /
137+
`replay` / `react` / `cli` separation still exists as directories and export
138+
paths — the architectural boundary is intact, only the npm boundary is gone.
139+
140+
### Negative
141+
142+
- **Breaking change for existing consumers.** Anyone importing
143+
`@ocpp-debugkit/core` must update to `@ocpp-debugkit/toolkit/core`. The
144+
migration guide and deprecated old packages ease this.
145+
- **Larger single package.** The npm tarball is larger, though consumers only
146+
pay for what they import at runtime via subpath exports and tree-shaking.
147+
- **No independent versioning.** A bug fix to `reporter` bumps the version for
148+
all modules. Given the tight coupling, this is acceptable — a `reporter` fix
149+
often depends on a `core` change anyway.
150+
151+
### Neutral
152+
153+
- The old packages stay on npm indefinitely for backward compatibility, but
154+
they are deprecated and frozen.

docs/adr/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ significant architectural decision, its context, and its consequences.
1616
| [ADR-0007](0007-malformed-trace-handling.md) | Malformed Trace Handling | Accepted |
1717
| [ADR-0008](0008-browser-local-processing.md) | Browser-Local Processing & Privacy | Accepted |
1818
| [ADR-0009](0009-protocol-extensibility.md) | Future Protocol-Version Extensibility | Accepted |
19+
| [ADR-0010](0010-single-package-consolidation.md) | Single Package Consolidation | Accepted |
1920

2021
## Format
2122

0 commit comments

Comments
 (0)