@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.
@@ -4,6 +4,7 @@ import path from "node:path";
4
4
  export type CliCommand =
5
5
  | "dev"
6
6
  | "build"
7
+ | "package"
7
8
  | "start"
8
9
  | "routes"
9
10
  | "update"
@@ -417,6 +418,7 @@ export function parseCliArgs(
417
418
  if (
418
419
  argument === "dev" ||
419
420
  argument === "build" ||
421
+ argument === "package" ||
420
422
  argument === "start" ||
421
423
  argument === "routes" ||
422
424
  argument === "update" ||
@@ -520,6 +520,7 @@ function resolveEnvironmentMode(
520
520
 
521
521
  if (
522
522
  command === "build" ||
523
+ command === "package" ||
523
524
  command === "start"
524
525
  ) {
525
526
  return "production";
@@ -51,6 +51,11 @@ switch (cliOptions.command) {
51
51
  break;
52
52
  }
53
53
 
54
+ case "package": {
55
+ await runPackage();
56
+ break;
57
+ }
58
+
54
59
  case "start": {
55
60
  await runStart();
56
61
  break;
@@ -356,6 +361,57 @@ async function runBuild() {
356
361
  console.log("");
357
362
  }
358
363
 
364
+ async function runPackage(): Promise<void> {
365
+ process.env.NODE_ENV =
366
+ "production";
367
+
368
+ await runBuild();
369
+
370
+ const rootDirectory =
371
+ resolveProjectRoot(
372
+ cliOptions.rootDirectory
373
+ );
374
+ const {
375
+ packageApplication,
376
+ } =
377
+ await import(
378
+ "./application-packaging.js"
379
+ );
380
+ const result =
381
+ packageApplication({
382
+ rootDirectory,
383
+ frameworkVersion:
384
+ FRAMEWORK_VERSION,
385
+ });
386
+
387
+ console.log(
388
+ "[BCP Package] Application package created."
389
+ );
390
+ console.log(
391
+ `[BCP Package] Output: ${result.outputDirectory}`
392
+ );
393
+ console.log(
394
+ `[BCP Package] Target: ${result.packageManifest.target}`
395
+ );
396
+ console.log(
397
+ `[BCP Package] Files: ${result.packageManifest.files.length}`
398
+ );
399
+ console.log(
400
+ `[BCP Package] Install: ${result.packageManifest.install.command}`
401
+ );
402
+ console.log(
403
+ `[BCP Package] Start: ${result.packageManifest.runtime.startCommand}`
404
+ );
405
+
406
+ for (const warning of result.warnings) {
407
+ console.warn(
408
+ `[BCP Package] Warning: ${warning}`
409
+ );
410
+ }
411
+
412
+ console.log("");
413
+ }
414
+
359
415
  async function runStart() {
360
416
  process.env.NODE_ENV =
361
417
  "production";
@@ -866,6 +922,7 @@ Usage:
866
922
  Commands:
867
923
  dev Start the development server
868
924
  build Create optimized client assets and standalone server.mjs
925
+ package Build and create a production deployment package
869
926
  start Start the standalone production build
870
927
  routes Print discovered page and API routes
871
928
  update [target] Update BCP Framework (default target: latest)
@@ -890,12 +947,13 @@ Options:
890
947
  -v, --version Show version
891
948
 
892
949
  Config precedence:
893
- dev/build: CLI > BCP_* environment > bcp.config.ts > defaults
894
- start: CLI > runtime BCP_* environment > frozen build config
950
+ dev/build/package: CLI > BCP_* environment > bcp.config.ts > defaults
951
+ start: CLI > runtime BCP_* environment > frozen build config
895
952
 
896
953
  Examples:
897
954
  bcp dev
898
955
  bcp build
956
+ bcp package
899
957
  bcp start
900
958
  bcp routes
901
959
  bcp generate page dashboard/users