create-bcp-app 0.1.4 → 0.1.5

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
@@ -20,6 +20,20 @@ Select a database:
20
20
  5) MongoDB
21
21
  ```
22
22
 
23
+ ## Generated application defaults
24
+
25
+ Generated applications include the project-root `@/` alias:
26
+
27
+ ```ts
28
+ import {
29
+ db,
30
+ } from "@/lib/database";
31
+ ```
32
+
33
+ The generated TypeScript configuration uses `module: "ESNext"` and `moduleResolution: "Bundler"` so extensionless application aliases match BCP's bundler and development runtime resolution.
34
+
35
+ Modules that use React client hooks such as `useState` or `useEffect` must declare `"use client"` at the top of the module.
36
+
23
37
  ## Generated optional setup
24
38
 
25
39
  ### Tailwind CSS
@@ -30,11 +44,10 @@ When Tailwind is enabled, the project includes:
30
44
  - `@tailwindcss/cli`
31
45
  - `concurrently`
32
46
  - `app/globals.css`
33
- - `app/api/bcp-styles/route.ts`
34
- - a stylesheet link in `app/layout.tsx`
47
+ - a stylesheet link to `/bcp.css` in `app/layout.tsx`
35
48
  - starter Tailwind utility classes in `app/page.tsx`
36
49
 
37
- The generated npm scripts compile Tailwind before starting BCP and keep Tailwind running in watch mode during development:
50
+ The generated npm scripts compile Tailwind directly to `public/bcp.css` before starting BCP and keep Tailwind running in watch mode during development:
38
51
 
39
52
  ```text
40
53
  npm run css:build
@@ -42,7 +55,7 @@ npm run css:watch
42
55
  npm run css:build:prod
43
56
  ```
44
57
 
45
- `npm run dev` performs an initial CSS build, then runs the Tailwind watcher and `bcp dev` together. `npm run build` creates a minified stylesheet before the BCP production build.
58
+ `npm run dev` performs an initial CSS build, then runs the Tailwind watcher and `bcp dev` together. BCP serves `/bcp.css` as a normal static asset from `public/`, avoiding an extra API route in the critical request chain. `npm run build` creates a minified stylesheet before the BCP production build.
46
59
 
47
60
  ### Database
48
61
 
@@ -54,6 +67,14 @@ The database choice adds a starter `lib/database.ts`, updates `.env.example`, an
54
67
  - MongoDB: `mongodb`
55
68
  - None: no database dependency
56
69
 
70
+ The generated database helper starts with:
71
+
72
+ ```ts
73
+ import "bcp/server-only";
74
+ ```
75
+
76
+ This prevents database code from being used in a page/client module graph. Query the database from an API route and call that API from client components.
77
+
57
78
  The generator intentionally installs database drivers directly and does not force an ORM.
58
79
 
59
80
  ## Options
@@ -79,5 +100,5 @@ npx create-bcp-app my-app --yes
79
100
  The `--bcp` option is primarily useful for prerelease and local package testing, for example:
80
101
 
81
102
  ```bash
82
- npx create-bcp-app my-app --bcp file:../bcp-0.1.4.tgz
103
+ npx create-bcp-app my-app --bcp file:../bcp-0.1.5.tgz
83
104
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -18,7 +18,9 @@ const DATABASE_PRESETS = {
18
18
  env: [
19
19
  "DATABASE_URL=mysql://root:password@localhost:3306/bcp_app",
20
20
  ],
21
- source: `import mysql from "mysql2/promise";
21
+ source: `import "bcp/server-only";
22
+
23
+ import mysql from "mysql2/promise";
22
24
 
23
25
  const connectionString =
24
26
  process.env.DATABASE_URL;
@@ -45,7 +47,9 @@ export const db =
45
47
  env: [
46
48
  "DATABASE_URL=postgresql://postgres:password@localhost:5432/bcp_app",
47
49
  ],
48
- source: `import {
50
+ source: `import "bcp/server-only";
51
+
52
+ import {
49
53
  Pool,
50
54
  } from "pg";
51
55
 
@@ -74,7 +78,9 @@ export const db =
74
78
  env: [
75
79
  "DATABASE_URL=./data/bcp.sqlite",
76
80
  ],
77
- source: `import fs from "node:fs";
81
+ source: `import "bcp/server-only";
82
+
83
+ import fs from "node:fs";
78
84
  import path from "node:path";
79
85
 
80
86
  import Database from "better-sqlite3";
@@ -111,7 +117,9 @@ export const db =
111
117
  "DATABASE_URL=mongodb://localhost:27017",
112
118
  "DATABASE_NAME=bcp_app",
113
119
  ],
114
- source: `import {
120
+ source: `import "bcp/server-only";
121
+
122
+ import {
115
123
  MongoClient,
116
124
  } from "mongodb";
117
125
 
@@ -259,56 +267,6 @@ function configureTailwind(
259
267
  `
260
268
  );
261
269
 
262
- writeFile(
263
- targetDirectory,
264
- "app/api/bcp-styles/route.ts",
265
- `import fs from "node:fs/promises";
266
- import path from "node:path";
267
-
268
- export async function GET() {
269
- const stylesheet =
270
- path.join(
271
- process.cwd(),
272
- "public",
273
- "bcp.css"
274
- );
275
-
276
- try {
277
- const css =
278
- await fs.readFile(
279
- stylesheet,
280
- "utf8"
281
- );
282
-
283
- return new Response(
284
- css,
285
- {
286
- headers: {
287
- "Content-Type":
288
- "text/css; charset=utf-8",
289
- "Cache-Control":
290
- "no-store, max-age=0",
291
- },
292
- }
293
- );
294
- } catch {
295
- return new Response(
296
- "/* BCP Tailwind stylesheet has not been built yet. */",
297
- {
298
- status: 503,
299
- headers: {
300
- "Content-Type":
301
- "text/css; charset=utf-8",
302
- "Cache-Control":
303
- "no-store, max-age=0",
304
- },
305
- }
306
- );
307
- }
308
- }
309
- `
310
- );
311
-
312
270
  fs.mkdirSync(
313
271
  path.join(
314
272
  targetDirectory,
@@ -370,7 +328,7 @@ function injectTailwindStylesheet(
370
328
  `${indent}<div>${newline}` +
371
329
  `${childIndent}<link${newline}` +
372
330
  `${propertyIndent}rel="stylesheet"${newline}` +
373
- `${propertyIndent}href="/api/bcp-styles"${newline}` +
331
+ `${propertyIndent}href="/bcp.css"${newline}` +
374
332
  `${childIndent}/>${newline}`;
375
333
 
376
334
  fs.writeFileSync(
@@ -1,14 +1,20 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "target": "ES2022",
4
- "module": "NodeNext",
5
- "moduleResolution": "NodeNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "Bundler",
6
6
  "jsx": "react-jsx",
7
7
  "strict": true,
8
8
  "noEmit": true,
9
9
  "esModuleInterop": true,
10
10
  "allowSyntheticDefaultImports": true,
11
11
  "skipLibCheck": true,
12
+ "baseUrl": ".",
13
+ "paths": {
14
+ "@/*": [
15
+ "./*"
16
+ ]
17
+ },
12
18
  "types": [
13
19
  "node",
14
20
  "react",