@chidchanun/bcp 0.1.21 → 0.1.22

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  BCP Framework is a React full-stack framework with file-based routing, SSR, client navigation, API routes, middleware, metadata, client islands, cache/revalidation, validation, structured errors, authentication, database primitives, security defaults and standalone production builds.
4
4
 
5
- > Current release target: `0.1.21`. BCP is still pre-1.0 and validates each release candidate before the manual npm publish step.
5
+ > Current release target: `0.1.22`. BCP is still pre-1.0 and validates each release candidate before the manual npm publish step.
6
6
 
7
7
  ## Quick start
8
8
 
@@ -110,6 +110,37 @@ Applications should not need to rewrite multiline classes to one line or use `su
110
110
 
111
111
  See [Hydration and deterministic rendering](docs/hydration.md) for the transform pipeline and troubleshooting guidance.
112
112
 
113
+ ## Developer diagnostics
114
+
115
+ BCP 0.1.22 adds dedicated developer tooling for diagnosing application setup without starting the development server.
116
+
117
+ Run a project health check:
118
+
119
+ ```bash
120
+ bcp doctor
121
+ ```
122
+
123
+ The doctor checks the Node.js runtime, project structure, installed BCP/React packages, React and React DOM version parity, duplicate React package roots, environment/config loading, route conflicts and client/server boundaries. Blocking failures produce a non-zero process exit code.
124
+
125
+ Inspect the resolved project inputs BCP sees:
126
+
127
+ ```bash
128
+ bcp inspect
129
+ ```
130
+
131
+ This prints development env filenames, public environment variable names, resolved BCP configuration, dependency versions and discovered page/API routes.
132
+
133
+ Both commands support JSON output:
134
+
135
+ ```bash
136
+ bcp doctor --json
137
+ bcp inspect --json
138
+ ```
139
+
140
+ The duplicate React checks are especially useful when verifying local framework builds. Install packed `.tgz` artifacts for release testing instead of linking `.package/bcp` directly into another project, because a linked staging directory can make the application and SSR renderer resolve different React instances.
141
+
142
+ See [Developer Tools](docs/developer-tools.md) for the complete command reference.
143
+
113
144
  ## Commands
114
145
 
115
146
  ```bash
@@ -117,6 +148,10 @@ bcp dev
117
148
  bcp routes
118
149
  bcp build
119
150
  bcp start
151
+ bcp doctor
152
+ bcp doctor --json
153
+ bcp inspect
154
+ bcp inspect --json
120
155
  bcp update
121
156
  bcp version
122
157
  ```
@@ -141,7 +176,7 @@ bcp update --dry-run
141
176
  Or select a published version/dist-tag explicitly:
142
177
 
143
178
  ```bash
144
- bcp update 0.1.21
179
+ bcp update 0.1.22
145
180
  bcp update next
146
181
  ```
147
182
 
@@ -810,6 +845,7 @@ No real npm publish command is run automatically by the repository.
810
845
  - [Database Migrations](docs/database-migrations.md)
811
846
  - [Middleware](docs/middleware.md)
812
847
  - [Hydration and deterministic rendering](docs/hydration.md)
848
+ - [Developer Tools](docs/developer-tools.md)
813
849
  - [Updating BCP Framework](docs/updating.md)
814
850
  - [Routing](docs/routing.md)
815
851
  - [Configuration](docs/configuration.md)
package/docs/README.md CHANGED
@@ -4,7 +4,7 @@ This directory is the documentation source of truth for the BCP Framework docume
4
4
 
5
5
  The recommended documentation website project name is `bcp-docs`.
6
6
 
7
- > Documentation target: BCP Framework `0.1.21`
7
+ > Documentation target: BCP Framework `0.1.22`
8
8
 
9
9
  ## Purpose
10
10
 
@@ -64,6 +64,7 @@ The website should not invent API behavior that is not documented or tested in t
64
64
  | --- | --- | --- |
65
65
  | `/docs/middleware` | `middleware.md` | Middleware System v2 and v1 compatibility |
66
66
  | `/docs/hydration` | `hydration.md` | SSR/client transform parity, deterministic rendering and Windows line endings |
67
+ | `/docs/developer-tools` | `developer-tools.md` | `bcp doctor`, `bcp inspect` and JSON diagnostics |
67
68
  | `/docs/caching` | `caching.md` | Cache and revalidation |
68
69
  | `/docs/security` | `security.md` | Framework security defaults |
69
70
  | `/docs/development-logging` | `development-logging.md` | Development request logging |
@@ -75,9 +76,9 @@ Use the files under `docs/releases/` for release pages.
75
76
  Recommended route format:
76
77
 
77
78
  ```text
78
- /releases/0.1.19
79
79
  /releases/0.1.20
80
80
  /releases/0.1.21
81
+ /releases/0.1.22
81
82
  ```
82
83
 
83
84
  The newest release should also be available from `/releases`.
@@ -151,6 +152,10 @@ Recommended feature groups:
151
152
  - Tailwind preset
152
153
  - Database/auth presets
153
154
  - `bcp update`
155
+ - `bcp doctor` project/runtime diagnostics
156
+ - `bcp inspect` environment/config/route inspection
157
+ - JSON developer-tool output for CI/automation
158
+ - Duplicate React package-root diagnostics
154
159
  - Standalone production builds
155
160
  - Critical CSS
156
161
  - Cache/revalidation
@@ -210,6 +215,7 @@ Database
210
215
  Runtime
211
216
  Middleware
212
217
  Hydration
218
+ Developer Tools
213
219
  Caching
214
220
  Security
215
221
 
@@ -218,9 +224,9 @@ Production
218
224
  Development Logging
219
225
 
220
226
  Releases
227
+ 0.1.22
221
228
  0.1.21
222
229
  0.1.20
223
- 0.1.19
224
230
  ```
225
231
 
226
232
  ## Suggested documentation page layout
@@ -305,6 +311,10 @@ bcp dev
305
311
  bcp routes
306
312
  bcp build
307
313
  bcp start
314
+ bcp doctor
315
+ bcp doctor --json
316
+ bcp inspect
317
+ bcp inspect --json
308
318
  bcp update
309
319
  bcp version
310
320
 
@@ -392,11 +402,25 @@ The docs website should make these points clear:
392
402
 
393
403
  See `hydration.md` for the full explanation, transform pipeline and troubleshooting steps.
394
404
 
395
- ## Release roadmap adjustment
405
+ ## Developer Tools documentation priority
396
406
 
397
- `0.1.21` is reserved for the hydration parity hotfix because `0.1.20` was already published before the remaining Babel JSX whitespace mismatch was isolated.
407
+ BCP 0.1.22 adds `bcp doctor` and `bcp inspect` as the first dedicated developer-diagnostics commands.
398
408
 
399
- The previously planned Developer Tools release moves to `0.1.22`, and later roadmap items should shift forward accordingly unless they are regrouped into a larger milestone.
409
+ The docs website should surface:
410
+
411
+ - PASS/WARN/FAIL health checks,
412
+ - non-zero exit codes for blocking doctor failures,
413
+ - React / React DOM version and package-root parity,
414
+ - config and development environment inspection,
415
+ - page/API route summaries,
416
+ - `--json` output for CI and automation,
417
+ - the recommendation to verify local releases from packed `.tgz` artifacts rather than linked staging directories.
418
+
419
+ See `developer-tools.md` for the full command reference.
420
+
421
+ ## Release roadmap
422
+
423
+ `0.1.22` is the Developer Tools milestone. The next planned milestone is `0.1.23` — Logging & Observability, followed by File Upload and the remaining pre-0.2 foundation milestones unless they are regrouped.
400
424
 
401
425
  ## Release workflow for documentation
402
426
 
@@ -0,0 +1,118 @@
1
+ # Developer Tools
2
+
3
+ BCP Framework 0.1.22 adds project diagnostics and runtime inspection commands for debugging a BCP application without starting the development server.
4
+
5
+ ## `bcp doctor`
6
+
7
+ Run a health check from the application root:
8
+
9
+ ```bash
10
+ bcp doctor
11
+ ```
12
+
13
+ The command checks:
14
+
15
+ - the current Node.js runtime against BCP's minimum supported version,
16
+ - `package.json` and the `app/` project structure,
17
+ - the declared and installed BCP package,
18
+ - installed `react` and `react-dom` versions,
19
+ - React / React DOM resolution parity between the application and the framework,
20
+ - development environment files,
21
+ - resolved `bcp.config.*` settings,
22
+ - page/API route discovery and conflicts,
23
+ - client/server module boundaries.
24
+
25
+ A successful check is printed as `PASS`, a non-blocking recommendation as `WARN`, and a blocking project/runtime problem as `FAIL`.
26
+
27
+ If one or more checks fail, `bcp doctor` sets a non-zero process exit code. This makes it suitable for local scripts and CI gates.
28
+
29
+ Example:
30
+
31
+ ```text
32
+ BCP Doctor v0.1.22
33
+ Project: D:\apps\my-bcp-app
34
+ Runtime: Node.js 24.15.0 | win32 x64
35
+
36
+ [PASS] Node.js runtime: Node.js 24.15.0 satisfies >=24.11.0.
37
+ [PASS] Project package: package.json is readable.
38
+ [PASS] App directory: app/ is present.
39
+ [PASS] React renderer version parity: react and react-dom both resolve to 19.2.8.
40
+ [PASS] Single React instance: BCP and the application resolve the same React package.
41
+
42
+ Summary: 11 passed, 0 warning(s), 0 failed.
43
+ ```
44
+
45
+ ### Duplicate React detection
46
+
47
+ `bcp doctor` specifically checks the package locations used by the application and by BCP itself.
48
+
49
+ This catches local-development layouts where an application resolves React from one `node_modules` tree while the BCP SSR renderer resolves React DOM from another. That situation commonly produces:
50
+
51
+ ```text
52
+ Invalid hook call. Hooks can only be called inside of the body of a function component.
53
+ ```
54
+
55
+ For local release testing, install the packed `.tgz` artifact instead of linking `.package/bcp` directly into another project. A packed package lets the BCP peer dependencies resolve from the application's normal `node_modules` tree.
56
+
57
+ ## `bcp inspect`
58
+
59
+ Use `inspect` when you want a deterministic snapshot of the project inputs BCP sees:
60
+
61
+ ```bash
62
+ bcp inspect
63
+ ```
64
+
65
+ It prints:
66
+
67
+ - framework version,
68
+ - Node.js/platform information,
69
+ - development `.env` files that were loaded,
70
+ - names of public `BCP_PUBLIC_*` variables (values are not exposed by the summary),
71
+ - the fully resolved BCP configuration,
72
+ - resolved BCP/React/React DOM package versions,
73
+ - discovered page and API routes.
74
+
75
+ `inspect` validates route conflicts and client boundaries before printing its report. It does not start an HTTP server.
76
+
77
+ ## JSON output
78
+
79
+ Both commands support machine-readable output:
80
+
81
+ ```bash
82
+ bcp doctor --json
83
+ bcp inspect --json
84
+ ```
85
+
86
+ You can also target another project directory:
87
+
88
+ ```bash
89
+ bcp doctor --root ../my-app --json
90
+ bcp inspect --root ../my-app --json
91
+ ```
92
+
93
+ `--json` is intentionally limited to `doctor` and `inspect` so other CLI commands keep their existing human-oriented output contracts.
94
+
95
+ ## Environment and config behavior
96
+
97
+ Developer tools inspect the development environment because they are intended to diagnose `bcp dev` projects.
98
+
99
+ Environment file precedence remains the same as the normal framework environment loader:
100
+
101
+ ```text
102
+ .env
103
+ .env.local
104
+ .env.development
105
+ .env.development.local
106
+ ```
107
+
108
+ Resolved configuration still follows the framework configuration precedence rules. `bcp inspect` displays the final resolved config rather than only the source `bcp.config.*` object.
109
+
110
+ ## CI example
111
+
112
+ A simple project-health gate can use:
113
+
114
+ ```bash
115
+ bcp doctor --json > bcp-doctor.json
116
+ ```
117
+
118
+ The command exits non-zero when blocking checks fail, while the JSON report remains available for CI logs or artifacts.
@@ -0,0 +1,77 @@
1
+ # BCP Framework 0.1.22
2
+
3
+ BCP 0.1.22 adds the first dedicated Developer Tools milestone.
4
+
5
+ ## Highlights
6
+
7
+ - Added `bcp doctor` for project/runtime health diagnostics.
8
+ - Added `bcp inspect` for environment, resolved config, dependency and route inspection.
9
+ - Added `--json` output for both developer-tool commands.
10
+ - `bcp doctor` returns a non-zero exit code when blocking checks fail, so it can be used as a CI health gate.
11
+ - Added React / React DOM version and package-location checks to detect duplicate React installations before they surface as `Invalid hook call` runtime failures.
12
+ - Added route conflict and client-boundary validation without starting the dev server.
13
+ - Added development environment diagnostics without printing private environment values.
14
+ - Added unit coverage for CLI parsing, version checks, missing-project diagnostics and deterministic inspection output.
15
+
16
+ ## `bcp doctor`
17
+
18
+ ```bash
19
+ bcp doctor
20
+ ```
21
+
22
+ The health report checks:
23
+
24
+ - Node.js support,
25
+ - `package.json`, `app/` and optional `public/`,
26
+ - declared and installed BCP dependencies,
27
+ - React and React DOM versions,
28
+ - whether BCP and the application resolve the same React/React DOM package roots,
29
+ - development environment loading,
30
+ - resolved framework config,
31
+ - page/API route discovery,
32
+ - client/server module boundaries.
33
+
34
+ Use JSON output in automation:
35
+
36
+ ```bash
37
+ bcp doctor --json
38
+ ```
39
+
40
+ ## `bcp inspect`
41
+
42
+ ```bash
43
+ bcp inspect
44
+ ```
45
+
46
+ The inspection report includes:
47
+
48
+ - framework/runtime identity,
49
+ - loaded development env filenames,
50
+ - public environment variable names,
51
+ - resolved BCP configuration,
52
+ - installed BCP/React/React DOM versions,
53
+ - page and API route mappings.
54
+
55
+ Machine-readable output:
56
+
57
+ ```bash
58
+ bcp inspect --json
59
+ ```
60
+
61
+ ## Duplicate React diagnostics
62
+
63
+ The Developer Tools milestone includes a check motivated by the 0.1.21 local release verification workflow.
64
+
65
+ If an application is linked directly to a framework staging directory, the application may resolve React from its own `node_modules` while the BCP SSR renderer resolves React DOM from the framework checkout. `bcp doctor` detects this package-root split and reports it as a failure before SSR reaches the `Invalid hook call` error.
66
+
67
+ For local release verification, continue using packed `.tgz` artifacts rather than installing `.package/bcp` as a linked directory.
68
+
69
+ ## Compatibility
70
+
71
+ 0.1.22 does not change public rendering, routing, database, authentication, validation, middleware or error-handling APIs.
72
+
73
+ The new functionality is additive CLI tooling. Existing BCP applications can continue using the current commands unchanged.
74
+
75
+ ## Next milestone
76
+
77
+ The next planned milestone is BCP 0.1.23 — Logging & Observability.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chidchanun/bcp",
3
- "version": "0.1.21",
3
+ "version": "0.1.22",
4
4
  "description": "BCP Framework - a React full-stack framework with file-based routing, SSR, APIs, middleware, islands, caching and standalone production builds.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -8,6 +8,8 @@ export type CliCommand =
8
8
  | "routes"
9
9
  | "update"
10
10
  | "db"
11
+ | "doctor"
12
+ | "inspect"
11
13
  | "help"
12
14
  | "version";
13
15
 
@@ -33,6 +35,8 @@ export interface CliOptions {
33
35
 
34
36
  updateDryRun?: boolean;
35
37
 
38
+ json?: boolean;
39
+
36
40
  dbAction?: DatabaseCliAction;
37
41
 
38
42
  dbMigrationName?: string;
@@ -61,6 +65,9 @@ export function parseCliArgs(
61
65
  let updateDryRun =
62
66
  false;
63
67
 
68
+ let json =
69
+ false;
70
+
64
71
  let dbAction:
65
72
  DatabaseCliAction | undefined;
66
73
 
@@ -209,6 +216,14 @@ export function parseCliArgs(
209
216
  continue;
210
217
  }
211
218
 
219
+ if (
220
+ argument === "--json"
221
+ ) {
222
+ json =
223
+ true;
224
+ continue;
225
+ }
226
+
212
227
  if (
213
228
  argument.startsWith("-")
214
229
  ) {
@@ -297,6 +312,8 @@ export function parseCliArgs(
297
312
  argument === "routes" ||
298
313
  argument === "update" ||
299
314
  argument === "db" ||
315
+ argument === "doctor" ||
316
+ argument === "inspect" ||
300
317
  argument === "help" ||
301
318
  argument === "version"
302
319
  ) {
@@ -322,6 +339,16 @@ export function parseCliArgs(
322
339
  );
323
340
  }
324
341
 
342
+ if (
343
+ json &&
344
+ command !== "doctor" &&
345
+ command !== "inspect"
346
+ ) {
347
+ throw new Error(
348
+ "Option --json is only valid with `bcp doctor` or `bcp inspect`."
349
+ );
350
+ }
351
+
325
352
  return {
326
353
  command,
327
354
  rootDirectory,
@@ -330,6 +357,11 @@ export function parseCliArgs(
330
357
  updateTarget,
331
358
  updateCheck,
332
359
  updateDryRun,
360
+ ...(json
361
+ ? {
362
+ json: true,
363
+ }
364
+ : {}),
333
365
  ...(command === "db"
334
366
  ? {
335
367
  dbAction,