@seip/bluebird-js 0.1.5 → 0.1.7

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/core/app.js CHANGED
@@ -10,6 +10,7 @@ import Debug from "./debug.js";
10
10
  import WebSocketManager from "./ws.js";
11
11
  import RateLimit from "./ratelimit.js";
12
12
  import Seo from "./seo.js";
13
+ import AI, { ai } from "./ai.js";
13
14
 
14
15
  const props = Config.props();
15
16
  const SERVER_BOOT_ID = Date.now().toString(36) + Math.random().toString(36).slice(2, 6);
@@ -762,6 +763,15 @@ class App {
762
763
  * @param {Object} [options={}] - Rate limit options (windowMs, max, message, driver, keyGenerator).
763
764
  * @returns {Function} Express middleware.
764
765
  */
766
+ /**
767
+ * Returns a new or default unified AI instance.
768
+ * @param {Object} [options={}] - AI configuration options.
769
+ * @returns {AI}
770
+ */
771
+ static ai(options = {}) {
772
+ return Object.keys(options).length > 0 ? new AI(options) : ai;
773
+ }
774
+
765
775
  static rateLimit(options = {}) {
766
776
  return RateLimit.middleware(options);
767
777
  }
@@ -787,5 +797,5 @@ export class AppError extends Error {
787
797
  }
788
798
  }
789
799
 
790
- export { App };
800
+ export { App, AI, ai };
791
801
  export default App;
@@ -0,0 +1,167 @@
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import readline from "node:readline/promises";
6
+ import colors from "../util/colors.js";
7
+ import { Database, DB_TYPE } from "../database.js";
8
+ import Config from "../config.js";
9
+
10
+ try {
11
+ process.loadEnvFile?.();
12
+ } catch {}
13
+
14
+ /**
15
+ * Prompts user for yes/no confirmation via CLI.
16
+ * @param {string} question
17
+ * @param {boolean} [defaultYes=false]
18
+ * @returns {Promise<boolean>}
19
+ */
20
+ async function promptConfirm(question, defaultYes = false) {
21
+ if (!process.stdin.isTTY) {
22
+ return defaultYes;
23
+ }
24
+ const rl = readline.createInterface({
25
+ input: process.stdin,
26
+ output: process.stdout,
27
+ });
28
+ try {
29
+ const answer = await rl.question(colors.cyan(question));
30
+ const trimmed = answer.trim().toLowerCase();
31
+ if (!trimmed) return defaultYes;
32
+ return ["y", "yes", "s", "si", "true", "1"].includes(trimmed);
33
+ } finally {
34
+ rl.close();
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Formats byte size into human-readable string.
40
+ * @param {number} bytes
41
+ * @returns {string}
42
+ */
43
+ function formatSize(bytes) {
44
+ if (bytes < 1024) return `${bytes} B`;
45
+ if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(2)} KB`;
46
+ return `${(bytes / (1024 * 1024)).toFixed(2)} MB`;
47
+ }
48
+
49
+ /**
50
+ * Executes database backup CLI command.
51
+ */
52
+ export async function runBackup() {
53
+ const args = process.argv.slice(2);
54
+ let keep = 10;
55
+ let outDir = null;
56
+ let compress = true;
57
+
58
+ for (let i = 0; i < args.length; i++) {
59
+ if (args[i] === "--keep" && args[i + 1]) {
60
+ keep = parseInt(args[i + 1], 10) || 10;
61
+ i++;
62
+ } else if (args[i].startsWith("--keep=")) {
63
+ keep = parseInt(args[i].split("=")[1], 10) || 10;
64
+ } else if (args[i] === "--out" && args[i + 1]) {
65
+ outDir = args[i + 1];
66
+ i++;
67
+ } else if (args[i].startsWith("--out=")) {
68
+ outDir = args[i].split("=")[1];
69
+ } else if (args[i] === "--no-compress") {
70
+ compress = false;
71
+ }
72
+ }
73
+
74
+ console.log(colors.cyan(`[INFO] Creating atomic database backup (${DB_TYPE})...`));
75
+
76
+ try {
77
+ const result = await Database.backup({
78
+ out: outDir,
79
+ keep,
80
+ compress,
81
+ });
82
+
83
+ console.log(colors.green(`[OK] Database backup created successfully:`));
84
+ console.log(` ${colors.bold("File:")} ${result.file}`);
85
+ console.log(` ${colors.bold("Size:")} ${formatSize(result.size)}`);
86
+ console.log(` ${colors.bold("Type:")} ${result.dbType}`);
87
+ if (result.rotated > 0) {
88
+ console.log(` ${colors.bold("Rotated:")} ${result.rotated} older backup(s) purged (retention: ${keep})`);
89
+ }
90
+ } catch (err) {
91
+ console.error(colors.red(`[ERROR] Database backup failed:`), err.message);
92
+ process.exit(1);
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Executes database restore CLI command.
98
+ */
99
+ export async function runRestore() {
100
+ const args = process.argv.slice(2);
101
+ let targetFile = null;
102
+ let isAutoYes = false;
103
+
104
+ for (let i = 0; i < args.length; i++) {
105
+ const arg = args[i];
106
+ if (arg === "--yes" || arg === "-y") {
107
+ isAutoYes = true;
108
+ } else if (arg !== "db:restore" && arg !== "restore" && !arg.startsWith("--")) {
109
+ targetFile = arg;
110
+ }
111
+ }
112
+
113
+ if (!targetFile) {
114
+ const backupsDir = path.resolve(Config.userDataDir(), "database/backups");
115
+ console.log(colors.yellow("[WARN] No backup file specified."));
116
+ if (fs.existsSync(backupsDir)) {
117
+ const files = fs.readdirSync(backupsDir).filter((f) => !f.startsWith("."));
118
+ if (files.length > 0) {
119
+ console.log(colors.cyan("\nAvailable backups in database/backups:"));
120
+ for (const f of files.slice(0, 10)) {
121
+ console.log(` - ${f}`);
122
+ }
123
+ console.log(colors.gray("\nUsage: npx bluebird-js db:restore <filename> [--yes]"));
124
+ }
125
+ }
126
+ process.exit(1);
127
+ }
128
+
129
+ if (!isAutoYes) {
130
+ const confirmed = await promptConfirm(
131
+ `⚠️ WARNING: Restoring will overwrite the active database.\nA safety snapshot of the current database will be saved automatically.\nAre you sure you want to proceed? (y/N): `,
132
+ false
133
+ );
134
+ if (!confirmed) {
135
+ console.log(colors.yellow("[CANCELLED] Database restore cancelled by user."));
136
+ return;
137
+ }
138
+ }
139
+
140
+ console.log(colors.cyan(`[INFO] Restoring database from '${targetFile}'...`));
141
+
142
+ try {
143
+ const result = await Database.restore(targetFile, {
144
+ safetyBackup: true,
145
+ verify: true,
146
+ });
147
+
148
+ console.log(colors.green(`[OK] Database restored successfully:`));
149
+ console.log(` ${colors.bold("Source:")} ${result.restoredFrom}`);
150
+ console.log(` ${colors.bold("Target:")} ${result.targetFile}`);
151
+ console.log(` ${colors.bold("Size:")} ${formatSize(result.size)}`);
152
+ if (result.preRestoreBackup) {
153
+ console.log(` ${colors.bold("Snapshot:")} ${result.preRestoreBackup} (pre-restore safety backup)`);
154
+ }
155
+ } catch (err) {
156
+ console.error(colors.red(`[ERROR] Database restore failed:`), err.message);
157
+ process.exit(1);
158
+ }
159
+ }
160
+
161
+ const action = process.argv[2];
162
+ if (action === "db:restore" || action === "restore") {
163
+ runRestore();
164
+ } else {
165
+ runBackup();
166
+ }
167
+
package/core/cli/init.js CHANGED
@@ -10,7 +10,7 @@ import colors from "../util/colors.js";
10
10
 
11
11
  try {
12
12
  process.loadEnvFile?.();
13
- } catch {}
13
+ } catch { }
14
14
 
15
15
  /**
16
16
  * Initializes a new Bluebird project with interactive configuration.
@@ -280,7 +280,7 @@ ${dbEnvBlock}
280
280
  if (fs.existsSync(pkgPath)) {
281
281
  try {
282
282
  pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
283
- } catch {}
283
+ } catch { }
284
284
  } else {
285
285
  const appName =
286
286
  path.basename(this.appDir).toLowerCase().replace(/[^a-z0-9_-]/g, "-") ||
@@ -290,7 +290,7 @@ ${dbEnvBlock}
290
290
  version: "1.0.0",
291
291
  type: "module",
292
292
  dependencies: {
293
- "@seip/bluebird-js": "^0.1.5",
293
+ "@seip/bluebird-js": "^0.1.6",
294
294
  },
295
295
  };
296
296
  }
@@ -326,7 +326,7 @@ ${dbEnvBlock}
326
326
  pkg.dependencies = {};
327
327
  }
328
328
  if (!pkg.dependencies["@seip/bluebird-js"]) {
329
- pkg.dependencies["@seip/bluebird-js"] = "^0.1.5";
329
+ pkg.dependencies["@seip/bluebird-js"] = "^0.1.6";
330
330
  }
331
331
 
332
332
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
@@ -639,7 +639,7 @@ export default function LiveCounter({ initial = 0, label = "Interactive Counter"
639
639
  pkg.scripts["dev:client"] = "vite";
640
640
  fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2));
641
641
  console.log(colors.green("[OK] Added 'build:client' and 'dev:client' scripts to package.json"));
642
- } catch {}
642
+ } catch { }
643
643
  }
644
644
 
645
645
  console.log(colors.bold.green("\nReact Islands setup complete!"));
@@ -877,6 +877,8 @@ function showHelp() {
877
877
  console.log(` ${colors.green("npx bluebird-js migrate:rollback")} Reverts the latest migration batch`);
878
878
  console.log(` ${colors.green("npx bluebird-js make:seed <name>")} Creates a new database seed file`);
879
879
  console.log(` ${colors.green("npx bluebird-js seed")} Executes all seed files`);
880
+ console.log(` ${colors.green("npx bluebird-js db:backup [--keep 10] [--out dir]")} Creates compressed WAL-safe database backup`);
881
+ console.log(` ${colors.green("npx bluebird-js db:restore <file> [--yes]")} Safely restores database with pre-backup & verification`);
880
882
  console.log(` ${colors.green("npx bluebird-js nginx:conf [domain] [port] [root]")} Generates Host Nginx reverse proxy`);
881
883
  console.log(` ${colors.green("npx bluebird-js make:ecosystem [--start]")} Generates PM2 cluster config`);
882
884
  console.log(` ${colors.green("npx bluebird-js add <module>")} Installs optional on-demand package
@@ -915,6 +917,13 @@ if (command === "make:ecosystem" || command === "ecosystem") {
915
917
  command === "make:seed"
916
918
  ) {
917
919
  import("./migrate.js");
920
+ } else if (
921
+ command === "db:backup" ||
922
+ command === "backup" ||
923
+ command === "db:restore" ||
924
+ command === "restore"
925
+ ) {
926
+ import("./backup.js");
918
927
  } else if (command === "swagger-install") {
919
928
  addCommand("swagger");
920
929
  } else if (command === "add") {
package/core/cli/view.js CHANGED
@@ -1,161 +1,161 @@
1
- #!/usr/bin/env node
2
-
3
- import fs from "node:fs";
4
- import path from "node:path";
5
- import colors from "../util/colors.js";
6
-
7
- const VIEWS_DIR = path.resolve(process.cwd(), "app/views");
8
-
9
- const rawArgs = process.argv.slice(2);
10
- const args = rawArgs.filter(
11
- (a) => a !== "view" && a !== "make:view" && !a.endsWith("view.js")
12
- );
13
- const viewName = args.find((a) => !a.startsWith("-"));
14
- const isHtml = rawArgs.some((a) => a === "--html");
15
- const isJs = rawArgs.some((a) => a === "--js");
16
- const isJsx = !isHtml && !isJs;
17
-
18
- if (!viewName) {
19
- console.log(colors.red("[ERROR] Missing view name."));
20
- console.log("Usage: npx bluebird-js make:view <name> [--jsx | --js | --html]");
21
- process.exit(1);
22
- }
23
-
24
- const cleanName = viewName.toLowerCase().replace(/[^a-z0-9_-]/g, "_");
25
- const titleCase = cleanName.charAt(0).toUpperCase() + cleanName.slice(1);
26
-
27
- if (!fs.existsSync(VIEWS_DIR)) {
28
- fs.mkdirSync(VIEWS_DIR, { recursive: true });
29
- }
30
-
31
- if (isHtml) {
32
- const filePath = path.join(VIEWS_DIR, `${cleanName}.html`);
33
- if (fs.existsSync(filePath)) {
34
- console.log(colors.yellow(`[WARN] View '${cleanName}.html' already exists at app/views/${cleanName}.html`));
35
- process.exit(0);
36
- }
37
-
38
- const rawHtml = `<!DOCTYPE html>
39
- <html lang="en" class="dark" data-theme="dark">
40
- <head>
41
- <meta charset="UTF-8" />
42
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
43
- <title>${titleCase}</title>
44
- <link rel="preconnect" href="https://fonts.googleapis.com">
45
- <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
46
- <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
47
- <script src="/js/tailwind.js"></script>
48
- <style type="text/tailwindcss">
49
- @custom-variant dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));
50
- @theme {
51
- --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
52
- }
53
- </style>
54
- </head>
55
- <body class="min-h-screen bg-slate-950 text-slate-100 font-sans p-8 max-w-4xl mx-auto">
56
- <h1 class="text-3xl font-extrabold text-sky-400 mb-4">${titleCase}</h1>
57
- </body>
58
- </html>
59
- `;
60
- fs.writeFileSync(filePath, rawHtml, "utf-8");
61
- console.log(colors.green(`[OK] Static HTML view created at app/views/${cleanName}.html`));
62
- console.log(colors.cyan("To render:"));
63
- console.log(colors.gray(` routerWeb.get("/${cleanName}", (req, res) => Render.html(res, "${cleanName}.html"));`));
64
- process.exit(0);
65
- }
66
-
67
- if (isJsx) {
68
- const filePath = path.join(VIEWS_DIR, `${cleanName}.jsx`);
69
- if (fs.existsSync(filePath)) {
70
- console.log(colors.yellow(`[WARN] View '${cleanName}.jsx' already exists at app/views/${cleanName}.jsx`));
71
- process.exit(0);
72
- }
73
-
74
- const jsxTemplate = `import { Client } from "@seip/bluebird-js/core/jsx.js";
75
-
76
- export const layout = "main";
77
-
78
- export const head = () => ({
79
- title: "${titleCase} — Blue Bird",
80
- description: "${titleCase} view rendered with Bluebird React SSR",
81
- });
82
-
83
- /**
84
- * ${titleCase} React SSR view module.
85
- * @param {Object} props
86
- */
87
- export default async function ${titleCase}View(props = {}) {
88
- return (
89
- <>
90
- <section className="py-10 md:py-14 border-b border-slate-800/80">
91
- <h1 className="text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 to-indigo-400 bg-clip-text text-transparent">
92
- ${titleCase}
93
- </h1>
94
- <p className="mt-4 text-base md:text-lg text-slate-300">
95
- Welcome to your new Bluebird React SSR view.
96
- </p>
97
- </section>
98
-
99
- <div className="mt-8">
100
- <article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6">
101
- <p className="text-slate-300">
102
- Rendered on the server with zero-build JSX and instant partial navigation.
103
- </p>
104
- </article>
105
- </div>
106
- </>
107
- );
108
- }
109
- `;
110
-
111
- fs.writeFileSync(filePath, jsxTemplate, "utf-8");
112
- console.log(colors.green(`[OK] React JSX view created at app/views/${cleanName}.jsx`));
113
- console.log("");
114
- console.log(colors.cyan("To render this view in a route:"));
115
- console.log(colors.gray(` import Render from "@seip/bluebird-js/core/render.js";`));
116
- console.log(colors.gray(` routerWeb.get("/${cleanName}", Render.view("${cleanName}"));`));
117
- process.exit(0);
118
- }
119
-
120
- const filePath = path.join(VIEWS_DIR, `${cleanName}.js`);
121
- if (fs.existsSync(filePath)) {
122
- console.log(colors.yellow(`[WARN] View '${cleanName}.js' already exists at app/views/${cleanName}.js`));
123
- process.exit(0);
124
- }
125
-
126
- const serverTemplate = `import { html, script } from "@seip/bluebird-js/core/html.js";
127
-
128
- export const layout = "main";
129
-
130
- export const head = () => ({
131
- title: "${titleCase} — Blue Bird",
132
- description: "${titleCase} view",
133
- });
134
-
135
- /**
136
- * ${titleCase} view module.
137
- * @param {Object} props
138
- * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
139
- */
140
- export default function ${titleCase}View(props = {}) {
141
- return html\`
142
- <section class="py-10 md:py-14 border-b border-slate-800/80">
143
- <h1 class="text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 to-indigo-400 bg-clip-text text-transparent">${titleCase}</h1>
144
- <p class="mt-4 text-base md:text-lg text-slate-300">Welcome to your new Bluebird view.</p>
145
- </section>
146
-
147
- <div class="mt-8">
148
- <article class="rounded-2xl border border-slate-800 bg-slate-900/60 p-6">
149
- <p class="text-slate-300">Rendered with pure JavaScript ESM and zero build tools.</p>
150
- </article>
151
- </div>
152
- \`;
153
- }
154
- `;
155
-
156
- fs.writeFileSync(filePath, serverTemplate, "utf-8");
157
- console.log(colors.green(`[OK] View created at app/views/${cleanName}.js`));
158
- console.log("");
159
- console.log(colors.cyan("To render this view in a route:"));
160
- console.log(colors.gray(` import Render from "@seip/bluebird-js/core/render.js";`));
161
- console.log(colors.gray(` routerWeb.get("/${cleanName}", Render.view("${cleanName}"));`));
1
+ #!/usr/bin/env node
2
+
3
+ import fs from "node:fs";
4
+ import path from "node:path";
5
+ import colors from "../util/colors.js";
6
+
7
+ const VIEWS_DIR = path.resolve(process.cwd(), "app/views");
8
+
9
+ const rawArgs = process.argv.slice(2);
10
+ const args = rawArgs.filter(
11
+ (a) => a !== "view" && a !== "make:view" && !a.endsWith("view.js")
12
+ );
13
+ const viewName = args.find((a) => !a.startsWith("-"));
14
+ const isHtml = rawArgs.some((a) => a === "--html");
15
+ const isJs = rawArgs.some((a) => a === "--js");
16
+ const isJsx = !isHtml && !isJs;
17
+
18
+ if (!viewName) {
19
+ console.log(colors.red("[ERROR] Missing view name."));
20
+ console.log("Usage: npx bluebird-js make:view <name> [--jsx | --js | --html]");
21
+ process.exit(1);
22
+ }
23
+
24
+ const cleanName = viewName.toLowerCase().replace(/[^a-z0-9_-]/g, "_");
25
+ const titleCase = cleanName.charAt(0).toUpperCase() + cleanName.slice(1);
26
+
27
+ if (!fs.existsSync(VIEWS_DIR)) {
28
+ fs.mkdirSync(VIEWS_DIR, { recursive: true });
29
+ }
30
+
31
+ if (isHtml) {
32
+ const filePath = path.join(VIEWS_DIR, `${cleanName}.html`);
33
+ if (fs.existsSync(filePath)) {
34
+ console.log(colors.yellow(`[WARN] View '${cleanName}.html' already exists at app/views/${cleanName}.html`));
35
+ process.exit(0);
36
+ }
37
+
38
+ const rawHtml = `<!DOCTYPE html>
39
+ <html lang="en" class="dark" data-theme="dark">
40
+ <head>
41
+ <meta charset="UTF-8" />
42
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
43
+ <title>${titleCase}</title>
44
+ <link rel="preconnect" href="https://fonts.googleapis.com">
45
+ <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
46
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet">
47
+ <script src="/js/tailwind.js"></script>
48
+ <style type="text/tailwindcss">
49
+ @custom-variant dark (&:where(.dark, .dark *, [data-theme="dark"], [data-theme="dark"] *));
50
+ @theme {
51
+ --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
52
+ }
53
+ </style>
54
+ </head>
55
+ <body class="min-h-screen bg-slate-950 text-slate-100 font-sans p-8 max-w-4xl mx-auto">
56
+ <h1 class="text-3xl font-extrabold text-sky-400 mb-4">${titleCase}</h1>
57
+ </body>
58
+ </html>
59
+ `;
60
+ fs.writeFileSync(filePath, rawHtml, "utf-8");
61
+ console.log(colors.green(`[OK] Static HTML view created at app/views/${cleanName}.html`));
62
+ console.log(colors.cyan("To render:"));
63
+ console.log(colors.gray(` routerWeb.get("/${cleanName}", (req, res) => Render.html(res, "${cleanName}.html"));`));
64
+ process.exit(0);
65
+ }
66
+
67
+ if (isJsx) {
68
+ const filePath = path.join(VIEWS_DIR, `${cleanName}.jsx`);
69
+ if (fs.existsSync(filePath)) {
70
+ console.log(colors.yellow(`[WARN] View '${cleanName}.jsx' already exists at app/views/${cleanName}.jsx`));
71
+ process.exit(0);
72
+ }
73
+
74
+ const jsxTemplate = `import { Client } from "@seip/bluebird-js/core/jsx.js";
75
+
76
+ export const layout = "main";
77
+
78
+ export const head = () => ({
79
+ title: "${titleCase} — Blue Bird",
80
+ description: "${titleCase} view rendered with Bluebird React SSR",
81
+ });
82
+
83
+ /**
84
+ * ${titleCase} React SSR view module.
85
+ * @param {Object} props
86
+ */
87
+ export default async function ${titleCase}View(props = {}) {
88
+ return (
89
+ <>
90
+ <section className="py-10 md:py-14 border-b border-slate-800/80">
91
+ <h1 className="text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 to-indigo-400 bg-clip-text text-transparent">
92
+ ${titleCase}
93
+ </h1>
94
+ <p className="mt-4 text-base md:text-lg text-slate-300">
95
+ Welcome to your new Bluebird React SSR view.
96
+ </p>
97
+ </section>
98
+
99
+ <div className="mt-8">
100
+ <article className="rounded-2xl border border-slate-800 bg-slate-900/60 p-6">
101
+ <p className="text-slate-300">
102
+ Rendered on the server with zero-build JSX and instant partial navigation.
103
+ </p>
104
+ </article>
105
+ </div>
106
+ </>
107
+ );
108
+ }
109
+ `;
110
+
111
+ fs.writeFileSync(filePath, jsxTemplate, "utf-8");
112
+ console.log(colors.green(`[OK] React JSX view created at app/views/${cleanName}.jsx`));
113
+ console.log("");
114
+ console.log(colors.cyan("To render this view in a route:"));
115
+ console.log(colors.gray(` import Render from "@seip/bluebird-js/core/render.js";`));
116
+ console.log(colors.gray(` routerWeb.get("/${cleanName}", Render.view("${cleanName}"));`));
117
+ process.exit(0);
118
+ }
119
+
120
+ const filePath = path.join(VIEWS_DIR, `${cleanName}.js`);
121
+ if (fs.existsSync(filePath)) {
122
+ console.log(colors.yellow(`[WARN] View '${cleanName}.js' already exists at app/views/${cleanName}.js`));
123
+ process.exit(0);
124
+ }
125
+
126
+ const serverTemplate = `import { html, script } from "@seip/bluebird-js/core/html.js";
127
+
128
+ export const layout = "main";
129
+
130
+ export const head = () => ({
131
+ title: "${titleCase} — Blue Bird",
132
+ description: "${titleCase} view",
133
+ });
134
+
135
+ /**
136
+ * ${titleCase} view module.
137
+ * @param {Object} props
138
+ * @returns {import('@seip/bluebird-js/core/html.js').SafeHtml}
139
+ */
140
+ export default function ${titleCase}View(props = {}) {
141
+ return html\`
142
+ <section class="py-10 md:py-14 border-b border-slate-800/80">
143
+ <h1 class="text-3xl md:text-5xl font-extrabold tracking-tight bg-gradient-to-r from-sky-400 to-indigo-400 bg-clip-text text-transparent">${titleCase}</h1>
144
+ <p class="mt-4 text-base md:text-lg text-slate-300">Welcome to your new Bluebird view.</p>
145
+ </section>
146
+
147
+ <div class="mt-8">
148
+ <article class="rounded-2xl border border-slate-800 bg-slate-900/60 p-6">
149
+ <p class="text-slate-300">Rendered with pure JavaScript ESM and zero build tools.</p>
150
+ </article>
151
+ </div>
152
+ \`;
153
+ }
154
+ `;
155
+
156
+ fs.writeFileSync(filePath, serverTemplate, "utf-8");
157
+ console.log(colors.green(`[OK] View created at app/views/${cleanName}.js`));
158
+ console.log("");
159
+ console.log(colors.cyan("To render this view in a route:"));
160
+ console.log(colors.gray(` import Render from "@seip/bluebird-js/core/render.js";`));
161
+ console.log(colors.gray(` routerWeb.get("/${cleanName}", Render.view("${cleanName}"));`));