@chidchanun/bcp 0.2.3 → 0.2.4

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,13 +2,13 @@
2
2
 
3
3
  BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, guarded application flows, API routes, authentication, database access, validation, uploads, storage and standalone Node.js production deployment.
4
4
 
5
- > **Development target:** `0.2.3Database Platform v2`
5
+ > **Development target:** `0.2.4Application Packaging`
6
6
  >
7
- > `0.2.3` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.2.4` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## 0.2 platform
10
10
 
11
- `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, and `0.2.3` adds a provider-neutral SQL database platform with MySQL, PostgreSQL and SQLite support without intentionally removing public application entrypoints.
11
+ `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, `0.2.2` added Configuration & Environment v2, `0.2.3` added Database Platform v2, and `0.2.4` adds deployment-oriented application packaging without intentionally removing the existing public application model.
12
12
 
13
13
  Machine-readable platform contracts:
14
14
 
@@ -43,7 +43,7 @@ docs/api-manifest.json
43
43
  | Caching | Response cache and revalidation primitives |
44
44
  | Configuration | Typed `bcp.config.*`, optional `bcp.environment.*`, startup diagnostics and `bcp config check` |
45
45
  | Developer tools | Generators, Doctor/Inspect v2, updater, route inspection and project metadata |
46
- | Production | Standalone Node.js build, hardening gateway, graceful shutdown, trusted proxy controls and HTTP timeouts |
46
+ | Production | Standalone Node.js build, application packaging, production dependency pruning, deployment manifests, Docker starter, hardening and graceful shutdown |
47
47
  | Documentation | Manifest-driven docs navigation, platform metadata and public API reference |
48
48
 
49
49
  ## Requirements
@@ -80,7 +80,7 @@ Generated projects normally keep one framework dependency key:
80
80
 
81
81
  Do not install both `bcp` and a second direct `@chidchanun/bcp` dependency in the same application.
82
82
 
83
- ## Configuration
83
+ ## Configuration & environment
84
84
 
85
85
  Framework configuration stays in one of:
86
86
 
@@ -91,29 +91,16 @@ bcp.config.js
91
91
  bcp.config.mjs
92
92
  ```
93
93
 
94
- Example:
94
+ Application environment validation can be declared in:
95
95
 
96
- ```ts
97
- import {
98
- defineConfig,
99
- } from "bcp/config";
100
-
101
- export default defineConfig({
102
- server: {
103
- port: 3000,
104
- hostname: "0.0.0.0",
105
- },
106
- build: {
107
- minify: true,
108
- sourceMaps: false,
109
- },
110
- security: {
111
- poweredByHeader: false,
112
- },
113
- });
96
+ ```text
97
+ bcp.environment.ts
98
+ bcp.environment.mts
99
+ bcp.environment.js
100
+ bcp.environment.mjs
114
101
  ```
115
102
 
116
- Configuration precedence remains:
103
+ Configuration precedence is:
117
104
 
118
105
  ```text
119
106
  CLI override
@@ -125,114 +112,23 @@ bcp.config.*
125
112
  framework defaults
126
113
  ```
127
114
 
128
- Read more: [Configuration](docs/configuration.md)
129
-
130
- ## Environment Validation — 0.2.2
131
-
132
- Application-specific variables can be declared in an optional environment schema:
133
-
134
- ```text
135
- bcp.environment.ts
136
- ```
137
-
138
- Example:
139
-
140
- ```ts
141
- import {
142
- defineEnvironment,
143
- } from "bcp/config";
144
-
145
- export default defineEnvironment({
146
- DB_HOST: {
147
- type: "string",
148
- required: true,
149
- },
150
-
151
- DB_PORT: {
152
- type: "number",
153
- default: 3306,
154
- min: 1,
155
- max: 65535,
156
- },
157
-
158
- SESSION_SECRET: {
159
- type: "string",
160
- required: true,
161
- secret: true,
162
- minLength: 32,
163
- },
164
-
165
- FEATURE_ENABLED: {
166
- type: "boolean",
167
- default: false,
168
- },
169
-
170
- BCP_PUBLIC_API_URL: {
171
- type: "url",
172
- required: true,
173
- },
174
- });
175
- ```
176
-
177
- Supported types:
178
-
179
- ```text
180
- string
181
- number
182
- boolean
183
- url
184
- ```
185
-
186
- Validate the current project:
115
+ Validate configuration and declared environment values with:
187
116
 
188
117
  ```bash
189
118
  bcp config check
190
- ```
191
-
192
- JSON diagnostics:
193
-
194
- ```bash
195
119
  bcp config check --json
196
120
  ```
197
121
 
198
- On Windows, where Microsoft SQL Server may provide another `bcp.exe`, prefer:
199
-
200
- ```powershell
201
- npm exec -- bcp-framework config check
202
- npm exec -- bcp-framework config check --json
203
- ```
204
-
205
- `bcp dev` and `bcp build` also validate `bcp.environment.*` before startup/build. Invalid required values fail early.
206
-
207
- The development supervisor watches:
208
-
209
- ```text
210
- .env*
211
- bcp.config.*
212
- bcp.environment.*
213
- ```
214
-
215
- and restarts the worker when one of those files changes.
216
-
217
- ### Secret safety
218
-
219
- Variables beginning with `BCP_PUBLIC_` can be embedded into browser bundles.
220
-
221
- A variable marked:
222
-
223
- ```ts
224
- secret: true
225
- ```
226
-
227
- must not use `BCP_PUBLIC_`. BCP reports this as a configuration error.
122
+ Variables beginning with `BCP_PUBLIC_` may be embedded in browser output. Never expose application secrets through public-prefixed variables.
228
123
 
229
- `secret: true` is tooling metadata; it does not encrypt environment values.
124
+ Read more:
230
125
 
231
- Read more: [Environment Validation](docs/environment-validation.md)
126
+ - [Configuration](docs/configuration.md)
127
+ - [Environment Validation](docs/environment-validation.md)
232
128
 
233
129
  ## Database Platform v2 — 0.2.3
234
130
 
235
- Application code uses the same server-only entrypoint across supported SQL providers:
131
+ Application code uses one server-only database entrypoint across supported SQL providers:
236
132
 
237
133
  ```ts
238
134
  import {
@@ -241,7 +137,7 @@ import {
241
137
  } from "bcp/database";
242
138
  ```
243
139
 
244
- Built-in providers:
140
+ Built-in SQL providers:
245
141
 
246
142
  ```text
247
143
  mysql
@@ -249,7 +145,7 @@ postgresql
249
145
  sqlite
250
146
  ```
251
147
 
252
- Connections remain lazy, while explicit lifecycle control is available when needed:
148
+ Lifecycle control:
253
149
 
254
150
  ```ts
255
151
  await db.connect();
@@ -261,7 +157,7 @@ await db.disconnect();
261
157
 
262
158
  `db.close()` remains available for backward-compatible shutdown handling.
263
159
 
264
- Database migrations use the same CLI across providers:
160
+ Migration CLI:
265
161
 
266
162
  ```bash
267
163
  bcp db create create_users
@@ -270,13 +166,71 @@ bcp db status
270
166
  bcp db rollback
271
167
  ```
272
168
 
273
- BCP makes its internal migration bookkeeping provider-aware. Application SQL itself is not automatically translated between SQL dialects.
169
+ BCP makes framework migration bookkeeping provider-aware. Application migration SQL itself is not automatically translated between SQL dialects.
274
170
 
275
171
  Read more:
276
172
 
277
173
  - [Database](docs/database.md)
278
174
  - [Database Migrations](docs/database-migrations.md)
279
175
 
176
+ ## Application Packaging — 0.2.4
177
+
178
+ Create a fresh production build and convert it into a deployment-oriented package:
179
+
180
+ ```bash
181
+ bcp package
182
+ ```
183
+
184
+ Framework-repository development can also run:
185
+
186
+ ```bash
187
+ npm run package
188
+ ```
189
+
190
+ Output:
191
+
192
+ ```text
193
+ .bcp-framework/package/
194
+ ├─ client/
195
+ ├─ server/
196
+ │ └─ server.mjs
197
+ ├─ public/ # when present
198
+ ├─ manifest.json
199
+ ├─ package.json
200
+ ├─ package-lock.json # when a safe npm v3 production lock can be derived
201
+ ├─ bcp.package.json
202
+ ├─ bcp.deployment.json
203
+ ├─ bcp.env.json
204
+ ├─ Dockerfile
205
+ ├─ .dockerignore
206
+ └─ README.md
207
+ ```
208
+
209
+ The package layer:
210
+
211
+ - runs a fresh `bcp build` before packaging,
212
+ - strips application `devDependencies` from the deployment package,
213
+ - derives a production-only npm v3 lock graph when safe,
214
+ - records `npm ci --omit=dev` when the production lock is available,
215
+ - falls back explicitly to `npm install --omit=dev` when a safe lock cannot be produced,
216
+ - writes deployment/runtime metadata,
217
+ - records environment variable names without copying `.env` values,
218
+ - creates SHA-256 file integrity metadata,
219
+ - generates a Node 24 Alpine Docker starter.
220
+
221
+ The current package target is:
222
+
223
+ ```text
224
+ standalone-node
225
+ ```
226
+
227
+ Native executable, desktop, Android and iOS packaging remain later roadmap work.
228
+
229
+ Read more:
230
+
231
+ - [Application Packaging](docs/application-packaging.md)
232
+ - [Deployment](docs/deployment.md)
233
+
280
234
  ## Public entrypoints
281
235
 
282
236
  The current `0.2.x` platform contract recognizes:
@@ -310,6 +264,7 @@ Core commands:
310
264
  ```bash
311
265
  bcp dev
312
266
  bcp build
267
+ bcp package
313
268
  bcp start
314
269
  bcp routes
315
270
  bcp update
@@ -375,12 +330,14 @@ app/
375
330
 
376
331
  ## Production build
377
332
 
333
+ Raw standalone build:
334
+
378
335
  ```bash
379
336
  npm run build
380
337
  npm run start
381
338
  ```
382
339
 
383
- Standalone output:
340
+ Output:
384
341
 
385
342
  ```text
386
343
  .bcp-framework/build/
@@ -390,17 +347,13 @@ Standalone output:
390
347
  └─ server.mjs
391
348
  ```
392
349
 
393
- The current production target remains:
350
+ Deployment package:
394
351
 
395
- ```text
396
- standalone-node
352
+ ```bash
353
+ bcp package
397
354
  ```
398
355
 
399
- Native `.exe`, desktop and mobile compilation remain later roadmap work.
400
-
401
- Production hardening includes configurable request/header/keep-alive/shutdown timeouts, trusted-proxy handling and graceful `SIGTERM` / `SIGINT` shutdown.
402
-
403
- Read more: [Production Hardening](docs/production-hardening.md)
356
+ Both current targets remain Node.js `standalone-node` applications. Production hardening includes configurable request/header/keep-alive/shutdown timeouts, trusted-proxy handling and graceful `SIGTERM` / `SIGINT` shutdown.
404
357
 
405
358
  ## Documentation Platform
406
359
 
@@ -420,7 +373,7 @@ Read more:
420
373
 
421
374
  - [Documentation Source Map](docs/README.md)
422
375
  - [Documentation Platform](docs/documentation-platform.md)
423
- - [Environment Validation](docs/environment-validation.md)
376
+ - [Application Packaging](docs/application-packaging.md)
424
377
 
425
378
  ## Release validation
426
379
 
@@ -436,7 +389,7 @@ npm run test:e2e
436
389
  npm run rc:check
437
390
  ```
438
391
 
439
- `0.2.3` adds Database Platform v2 unit/package checks covering the adapter contract, MySQL/PostgreSQL/SQLite provider resolution, explicit connection lifecycle, failed-initialization retry behavior and provider-specific migration bookkeeping.
392
+ `0.2.4` adds Application Packaging unit and prepared-package smoke checks covering production dependency metadata, production lock pruning, environment-value exclusion, deployment metadata and the `bcp package` CLI surface.
440
393
 
441
394
  Do not tag or publish until the final release commit passes the complete RC sequence.
442
395
 
@@ -454,12 +407,13 @@ Do not tag or publish until the final release commit passes the complete RC sequ
454
407
  | `0.2.1` | Documentation Platform |
455
408
  | `0.2.2` | Configuration & Environment v2 |
456
409
  | `0.2.3` | Database Platform v2 |
410
+ | `0.2.4` | Application Packaging |
457
411
 
458
412
  ## Roadmap
459
413
 
460
- `0.2.3Database Platform v2` completes the planned database adapter contract, PostgreSQL support, SQLite support, connection lifecycle improvements and migration consistency across the built-in SQL providers.
414
+ `0.2.4Application Packaging` establishes the deployment artifact contract for the existing standalone Node.js runtime.
461
415
 
462
- The next planned `0.2.x` focus is application packaging. Native `.exe`, desktop and mobile compilation remain later roadmap work.
416
+ The next planned framework milestone can build on this package contract without changing the current Node.js deployment model. Native `.exe`, desktop and mobile compilation remain later roadmap work.
463
417
 
464
418
  ## License
465
419
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
3
  "framework": "bcp",
4
- "version": "0.2.3",
4
+ "version": "0.2.4",
5
5
  "releaseState": "unreleased",
6
6
  "coverage": "public-entrypoints",
7
7
  "entrypoints": [
@@ -0,0 +1,243 @@
1
+ # Application Packaging
2
+
3
+ BCP Framework `0.2.4` adds an application packaging layer on top of the standalone Node.js production build.
4
+
5
+ The goal is to turn a BCP project into a deployment-oriented directory that contains the built application, production dependency metadata, deployment metadata and container starter files without copying source-only development dependencies or project secrets.
6
+
7
+ ## Create a package
8
+
9
+ From the application root:
10
+
11
+ ```bash
12
+ bcp package
13
+ ```
14
+
15
+ `bcp package` always runs a fresh production build first. This prevents an older `.bcp-framework/build` directory from being packaged accidentally.
16
+
17
+ The output is written to:
18
+
19
+ ```text
20
+ .bcp-framework/
21
+ └── package/
22
+ ├── client/
23
+ ├── server/
24
+ │ └── server.mjs
25
+ ├── public/ # when the application has public assets
26
+ ├── manifest.json
27
+ ├── package.json
28
+ ├── package-lock.json # when a safe npm v3 production lock can be derived
29
+ ├── bcp.package.json
30
+ ├── bcp.deployment.json
31
+ ├── bcp.env.json
32
+ ├── Dockerfile
33
+ ├── .dockerignore
34
+ └── README.md
35
+ ```
36
+
37
+ The current packaging target is:
38
+
39
+ ```text
40
+ standalone-node
41
+ ```
42
+
43
+ Native executable, desktop and mobile packaging are not part of `0.2.4`.
44
+
45
+ ## Production dependencies
46
+
47
+ The generated package-level `package.json` keeps runtime metadata only:
48
+
49
+ - `dependencies`
50
+ - `optionalDependencies`
51
+ - `peerDependencies`
52
+ - supported peer metadata / overrides when present
53
+ - `engines.node`
54
+ - the standalone `start` script
55
+
56
+ `devDependencies` are intentionally excluded.
57
+
58
+ When the project has an npm lockfile v3 that can be safely converted to the production dependency graph, BCP writes a pruned `package-lock.json` and records:
59
+
60
+ ```bash
61
+ npm ci --omit=dev
62
+ ```
63
+
64
+ as the deployment install command.
65
+
66
+ If a safe production lock cannot be derived, packaging continues without copying an unsafe lockfile and records:
67
+
68
+ ```bash
69
+ npm install --omit=dev
70
+ ```
71
+
72
+ instead. The CLI prints a warning in that case.
73
+
74
+ This fallback is intentional: an application package must not pretend to be reproducibly locked when the framework cannot prove the lock metadata is safe for the standalone artifact.
75
+
76
+ ## Package manifest
77
+
78
+ `bcp.package.json` describes the produced artifact. It includes:
79
+
80
+ - schema version
81
+ - target runtime
82
+ - BCP Framework version
83
+ - application name/version
84
+ - Node.js requirement
85
+ - entrypoint and start command
86
+ - dependency installation command
87
+ - whether a production lockfile is included
88
+ - build/deployment/environment manifest paths
89
+ - package file inventory
90
+ - byte size and SHA-256 digest for each packaged file
91
+
92
+ Example shape:
93
+
94
+ ```json
95
+ {
96
+ "schemaVersion": 1,
97
+ "target": "standalone-node",
98
+ "frameworkVersion": "0.2.4",
99
+ "application": {
100
+ "name": "my-app",
101
+ "version": "0.1.0"
102
+ },
103
+ "runtime": {
104
+ "node": ">=24.11.0",
105
+ "entrypoint": "server/server.mjs",
106
+ "startCommand": "npm start"
107
+ },
108
+ "install": {
109
+ "command": "npm ci --omit=dev",
110
+ "lockfile": true,
111
+ "devDependenciesIncluded": false
112
+ }
113
+ }
114
+ ```
115
+
116
+ The file inventory allows deployment tooling to verify an application package before shipping it to a server or container image.
117
+
118
+ ## Deployment manifest
119
+
120
+ `bcp.deployment.json` is a small deployment contract for the current package target. It records:
121
+
122
+ ```text
123
+ runtime: Node.js
124
+ install: npm ci --omit=dev (or npm install --omit=dev fallback)
125
+ start: npm start
126
+ entrypoint: server/server.mjs
127
+ container starter: Dockerfile
128
+ ```
129
+
130
+ Future deployment adapters can consume this manifest without changing the current standalone Node.js contract.
131
+
132
+ ## Environment manifest and secret safety
133
+
134
+ BCP application packages do **not** copy project `.env` files.
135
+
136
+ `bcp.env.json` contains metadata only. When files such as `.env.example` exist, BCP can record declared variable names, but it does not record their values.
137
+
138
+ For example:
139
+
140
+ ```dotenv
141
+ DATABASE_URL=postgresql://user:password@example/db
142
+ BCP_SESSION_SECRET=secret
143
+ ```
144
+
145
+ is represented only as names such as:
146
+
147
+ ```json
148
+ {
149
+ "declaredKeys": [
150
+ "BCP_SESSION_SECRET",
151
+ "DATABASE_URL"
152
+ ],
153
+ "valuesIncluded": false,
154
+ "environmentFilesIncluded": false
155
+ }
156
+ ```
157
+
158
+ Supply real secrets through your deployment environment, secret manager or container/orchestrator configuration.
159
+
160
+ Runtime server overrides remain available through:
161
+
162
+ ```text
163
+ BCP_HOSTNAME
164
+ BCP_PORT
165
+ ```
166
+
167
+ ## Run the package
168
+
169
+ After copying `.bcp-framework/package` to the target machine:
170
+
171
+ ```bash
172
+ cd package
173
+ npm ci --omit=dev
174
+ npm start
175
+ ```
176
+
177
+ If `bcp.package.json` says `lockfile: false`, use the recorded install command instead.
178
+
179
+ You can also start the bundled entrypoint directly after dependencies are installed:
180
+
181
+ ```bash
182
+ node server/server.mjs
183
+ ```
184
+
185
+ ## Docker
186
+
187
+ The generated package contains a starter `Dockerfile`:
188
+
189
+ ```bash
190
+ docker build -t my-bcp-app .
191
+ docker run --rm -p 3000:3000 my-bcp-app
192
+ ```
193
+
194
+ Pass runtime environment values with the deployment mechanism you normally use. Do not bake secrets into the image.
195
+
196
+ ## Build vs package
197
+
198
+ Use `bcp build` when you need the framework's raw standalone build output:
199
+
200
+ ```text
201
+ .bcp-framework/build/
202
+ ```
203
+
204
+ Use `bcp package` when you need a deployment-oriented artifact:
205
+
206
+ ```text
207
+ .bcp-framework/package/
208
+ ```
209
+
210
+ In short:
211
+
212
+ ```text
213
+ source application
214
+
215
+ bcp build
216
+
217
+ standalone build
218
+
219
+ bcp package
220
+
221
+ deployment package + production metadata
222
+ ```
223
+
224
+ ## Determinism
225
+
226
+ The packaging layer writes sorted dependency metadata and a sorted file inventory. File hashes are calculated from the final package content.
227
+
228
+ The underlying BCP build currently retains its build identifier/timestamp behavior, so `0.2.4` does not promise byte-for-byte identical packages across independent build invocations. The integrity manifest is intended for verification of a specific produced artifact, not as a claim of fully reproducible builds.
229
+
230
+ ## Validation
231
+
232
+ Framework release validation includes Application Packaging unit and packed-package smoke coverage.
233
+
234
+ Recommended project validation is:
235
+
236
+ ```bash
237
+ bcp package
238
+ cd .bcp-framework/package
239
+ npm ci --omit=dev
240
+ npm start
241
+ ```
242
+
243
+ Then exercise representative routes, API endpoints and any optional runtime providers used by the application.