@revealui/cli 0.2.0 → 0.3.0

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.
Files changed (66) hide show
  1. package/README.md +114 -6
  2. package/bin/create-revealui.js +3 -3
  3. package/bin/revealui.js +6 -0
  4. package/dist/cli.d.ts +3 -1
  5. package/dist/cli.js +1399 -673
  6. package/dist/cli.js.map +1 -1
  7. package/dist/index.d.ts +0 -10
  8. package/dist/index.js +1380 -657
  9. package/dist/index.js.map +1 -1
  10. package/package.json +15 -6
  11. package/templates/{minimal → basic-blog}/package.json +8 -6
  12. package/templates/basic-blog/postcss.config.mjs +5 -0
  13. package/templates/basic-blog/revealui.config.ts +19 -0
  14. package/templates/basic-blog/src/app/globals.css +6 -0
  15. package/templates/{minimal → basic-blog}/src/app/layout.tsx +4 -4
  16. package/templates/basic-blog/src/app/page.tsx +57 -0
  17. package/templates/basic-blog/src/app/posts/[slug]/page.tsx +66 -0
  18. package/templates/basic-blog/src/app/posts/page.tsx +61 -0
  19. package/templates/basic-blog/src/collections/Posts.ts +42 -0
  20. package/templates/basic-blog/src/seed.ts +73 -0
  21. package/templates/{minimal → basic-blog}/tsconfig.json +1 -1
  22. package/templates/e-commerce/.env.example +36 -0
  23. package/templates/e-commerce/_gitignore +26 -0
  24. package/templates/e-commerce/next.config.mjs +10 -0
  25. package/templates/e-commerce/package.json +36 -0
  26. package/templates/e-commerce/postcss.config.mjs +5 -0
  27. package/templates/e-commerce/revealui.config.ts +20 -0
  28. package/templates/e-commerce/src/app/globals.css +6 -0
  29. package/templates/e-commerce/src/app/layout.tsx +15 -0
  30. package/templates/e-commerce/src/app/page.tsx +82 -0
  31. package/templates/e-commerce/src/app/products/[slug]/page.tsx +80 -0
  32. package/templates/e-commerce/src/app/products/page.tsx +72 -0
  33. package/templates/e-commerce/src/collections/Orders.ts +63 -0
  34. package/templates/e-commerce/src/collections/Products.ts +50 -0
  35. package/templates/e-commerce/src/seed.ts +72 -0
  36. package/templates/e-commerce/tsconfig.json +11 -0
  37. package/templates/portfolio/.env.example +36 -0
  38. package/templates/portfolio/_gitignore +26 -0
  39. package/templates/portfolio/next.config.mjs +10 -0
  40. package/templates/portfolio/package.json +36 -0
  41. package/templates/portfolio/postcss.config.mjs +5 -0
  42. package/templates/portfolio/revealui.config.ts +19 -0
  43. package/templates/portfolio/src/app/globals.css +6 -0
  44. package/templates/portfolio/src/app/layout.tsx +15 -0
  45. package/templates/portfolio/src/app/page.tsx +60 -0
  46. package/templates/portfolio/src/app/projects/[slug]/page.tsx +95 -0
  47. package/templates/portfolio/src/app/projects/page.tsx +85 -0
  48. package/templates/portfolio/src/collections/Projects.ts +49 -0
  49. package/templates/portfolio/src/seed.ts +73 -0
  50. package/templates/portfolio/tsconfig.json +11 -0
  51. package/templates/starter/.env.example +36 -0
  52. package/templates/starter/_gitignore +26 -0
  53. package/templates/starter/next.config.mjs +10 -0
  54. package/templates/starter/package.json +36 -0
  55. package/templates/starter/postcss.config.mjs +5 -0
  56. package/templates/{minimal → starter}/revealui.config.ts +4 -4
  57. package/templates/starter/src/app/globals.css +6 -0
  58. package/templates/starter/src/app/layout.tsx +15 -0
  59. package/templates/starter/src/app/page.tsx +18 -0
  60. package/templates/starter/src/seed.ts +40 -0
  61. package/templates/starter/tsconfig.json +11 -0
  62. package/templates/minimal/src/app/globals.css +0 -15
  63. package/templates/minimal/src/app/page.tsx +0 -20
  64. /package/templates/{minimal → basic-blog}/.env.example +0 -0
  65. /package/templates/{minimal → basic-blog}/_gitignore +0 -0
  66. /package/templates/{minimal → basic-blog}/next.config.mjs +0 -0
package/dist/index.js CHANGED
@@ -1,158 +1,452 @@
1
1
  #!/usr/bin/env node
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __esm = (fn, res) => function __init() {
5
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
6
- };
7
- var __export = (target, all) => {
8
- for (var name in all)
9
- __defProp(target, name, { get: all[name], enumerable: true });
10
- };
11
-
12
- // ../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.56.2_@types+node@25.3.0__@swc+core@1.15.11_@swc+h_406b258ea3c313c6308725a34065a5eb/node_modules/tsup/assets/esm_shims.js
13
- import path from "path";
14
- import { fileURLToPath } from "url";
15
- var init_esm_shims = __esm({
16
- "../../node_modules/.pnpm/tsup@8.5.1_@microsoft+api-extractor@7.56.2_@types+node@25.3.0__@swc+core@1.15.11_@swc+h_406b258ea3c313c6308725a34065a5eb/node_modules/tsup/assets/esm_shims.js"() {
17
- "use strict";
18
- }
19
- });
20
2
 
21
3
  // src/cli.ts
22
- import { createLogger } from "@revealui/setup/utils";
4
+ import { createLogger as createLogger11 } from "@revealui/setup/utils";
23
5
  import { Command } from "commander";
24
- function createCli() {
25
- const program = new Command();
26
- program.name("create-revealui").description("Create a new RevealUI project").version("0.1.0").argument("[project-name]", "Name of the project").option("-t, --template <name>", "Template to use (basic-blog, e-commerce, portfolio)").option("--skip-git", "Skip git initialization", false).option("--skip-install", "Skip dependency installation", false).action(async (projectName, options) => {
27
- logger.header("\u{1F680} Create RevealUI Project");
28
- const { run: run2 } = await Promise.resolve().then(() => (init_index(), index_exports));
29
- await run2(projectName, options);
30
- });
31
- return program;
6
+
7
+ // src/commands/create-flow.ts
8
+ import { readFileSync } from "fs";
9
+ import { homedir } from "os";
10
+ import { join } from "path";
11
+ import { createLogger as createLogger6 } from "@revealui/setup/utils";
12
+ import { importSPKI, jwtVerify } from "jose";
13
+
14
+ // src/prompts/database.ts
15
+ import inquirer from "inquirer";
16
+
17
+ // src/validators/credentials.ts
18
+ import { createLogger } from "@revealui/setup/utils";
19
+ var logger = createLogger({ prefix: "Validator" });
20
+ async function validateStripeKey(key) {
21
+ if (!(key.startsWith("sk_test_") || key.startsWith("sk_live_"))) {
22
+ return {
23
+ valid: false,
24
+ message: "Stripe key must start with sk_test_ or sk_live_"
25
+ };
26
+ }
27
+ return { valid: true };
32
28
  }
33
- var logger;
34
- var init_cli = __esm({
35
- "src/cli.ts"() {
36
- "use strict";
37
- init_esm_shims();
38
- logger = createLogger({ prefix: "CLI" });
29
+ async function validateNeonUrl(url) {
30
+ try {
31
+ const parsed = new URL(url);
32
+ if (!parsed.protocol.startsWith("postgres")) {
33
+ return {
34
+ valid: false,
35
+ message: "Database URL must use postgres:// or postgresql:// protocol"
36
+ };
37
+ }
38
+ return { valid: true };
39
+ } catch {
40
+ return {
41
+ valid: false,
42
+ message: "Invalid database URL format"
43
+ };
39
44
  }
40
- });
41
-
42
- // src/validators/node-version.ts
43
- import { createLogger as createLogger2 } from "@revealui/setup/utils";
44
- function validateNodeVersion() {
45
- const currentVersion = process.version.slice(1);
46
- const [currentMajor, currentMinor] = currentVersion.split(".").map(Number);
47
- const [requiredMajor, requiredMinor] = REQUIRED_NODE_VERSION.split(".").map(Number);
48
- if (currentMajor < requiredMajor || currentMajor === requiredMajor && currentMinor < requiredMinor) {
49
- logger2.error(
50
- `Node.js ${REQUIRED_NODE_VERSION} or higher is required. You have ${currentVersion}.`
51
- );
52
- logger2.info("Please upgrade Node.js: https://nodejs.org/");
53
- return false;
45
+ }
46
+ async function validateVercelToken(token) {
47
+ if (!token || token.length < 20) {
48
+ return {
49
+ valid: false,
50
+ message: "Vercel token appears invalid (too short)"
51
+ };
54
52
  }
55
- return true;
53
+ return { valid: true };
56
54
  }
57
- var logger2, REQUIRED_NODE_VERSION;
58
- var init_node_version = __esm({
59
- "src/validators/node-version.ts"() {
60
- "use strict";
61
- init_esm_shims();
62
- logger2 = createLogger2({ prefix: "Setup" });
63
- REQUIRED_NODE_VERSION = "24.12.0";
55
+ async function validateSupabaseUrl(url) {
56
+ try {
57
+ const parsed = new URL(url);
58
+ if (!parsed.hostname.includes("supabase")) {
59
+ logger.warn("URL does not appear to be a Supabase URL");
60
+ }
61
+ return { valid: true };
62
+ } catch {
63
+ return {
64
+ valid: false,
65
+ message: "Invalid Supabase URL format"
66
+ };
64
67
  }
65
- });
68
+ }
66
69
 
67
- // src/generators/devbox.ts
68
- import fs from "fs/promises";
69
- import path2 from "path";
70
- async function generateDevbox(projectPath) {
71
- const devboxConfig = {
72
- packages: ["nodejs@24.12.0", "pnpm@10.28.2", "postgresql@16", "stripe-cli@latest"],
73
- shell: {
74
- init_hook: [
75
- "corepack enable",
76
- 'echo "\u{1F680} RevealUI Devbox shell ready!"',
77
- 'echo "Run: pnpm dev to start development"'
70
+ // src/prompts/database.ts
71
+ async function promptDatabaseConfig() {
72
+ const { provider } = await inquirer.prompt([
73
+ {
74
+ type: "list",
75
+ name: "provider",
76
+ message: "Which database provider would you like to use?",
77
+ choices: [
78
+ {
79
+ name: "NeonDB - Serverless PostgreSQL (recommended)",
80
+ value: "neon"
81
+ },
82
+ {
83
+ name: "Supabase - PostgreSQL with built-in features",
84
+ value: "supabase"
85
+ },
86
+ {
87
+ name: "Local PostgreSQL - Use existing local database",
88
+ value: "local"
89
+ },
90
+ {
91
+ name: "Skip - Configure later",
92
+ value: "skip"
93
+ }
78
94
  ],
79
- scripts: {
80
- dev: "pnpm dev",
81
- setup: "pnpm install && pnpm db:init",
82
- test: "pnpm test"
95
+ default: "neon"
96
+ }
97
+ ]);
98
+ if (provider === "skip") {
99
+ return { provider: "skip" };
100
+ }
101
+ if (provider === "local") {
102
+ const { postgresUrl: postgresUrl2 } = await inquirer.prompt([
103
+ {
104
+ type: "input",
105
+ name: "postgresUrl",
106
+ message: "Enter your PostgreSQL connection string:",
107
+ default: "postgresql://postgres:postgres@localhost:5432/revealui",
108
+ validate: async (input) => {
109
+ const result = await validateNeonUrl(input);
110
+ return result.valid ? true : result.message || "Invalid database URL";
111
+ }
112
+ }
113
+ ]);
114
+ return { provider: "local", postgresUrl: postgresUrl2 };
115
+ }
116
+ const { postgresUrl } = await inquirer.prompt([
117
+ {
118
+ type: "input",
119
+ name: "postgresUrl",
120
+ message: `Enter your ${provider === "neon" ? "Neon" : "Supabase"} database connection string:`,
121
+ validate: async (input) => {
122
+ if (!input || input.trim() === "") {
123
+ return "Database URL is required";
124
+ }
125
+ const result = await validateNeonUrl(input);
126
+ return result.valid ? true : result.message || "Invalid database URL";
83
127
  }
128
+ }
129
+ ]);
130
+ return { provider, postgresUrl };
131
+ }
132
+
133
+ // src/prompts/devenv.ts
134
+ import inquirer2 from "inquirer";
135
+ async function promptDevEnvConfig() {
136
+ const answers = await inquirer2.prompt([
137
+ {
138
+ type: "confirm",
139
+ name: "createDevContainer",
140
+ message: "Create Dev Container configuration for VS Code / GitHub Codespaces?",
141
+ default: true
84
142
  },
85
- env: {
86
- NODE_ENV: "development"
143
+ {
144
+ type: "confirm",
145
+ name: "createDevbox",
146
+ message: "Create Devbox configuration for Nix-powered development?",
147
+ default: true
87
148
  }
88
- };
89
- await fs.writeFile(
90
- path2.join(projectPath, "devbox.json"),
91
- JSON.stringify(devboxConfig, null, 2),
92
- "utf-8"
93
- );
149
+ ]);
150
+ return answers;
94
151
  }
95
- var init_devbox = __esm({
96
- "src/generators/devbox.ts"() {
97
- "use strict";
98
- init_esm_shims();
99
- }
100
- });
101
152
 
102
- // src/generators/devcontainer.ts
103
- import fs2 from "fs/promises";
104
- import path3 from "path";
105
- async function generateDevContainer(projectPath) {
106
- const devcontainerDir = path3.join(projectPath, ".devcontainer");
107
- await fs2.mkdir(devcontainerDir, { recursive: true });
108
- const devcontainerConfig = {
109
- name: "RevealUI Development",
110
- image: "mcr.microsoft.com/devcontainers/typescript-node:24",
111
- features: {
112
- "ghcr.io/devcontainers/features/common-utils:2": {
113
- installZsh: true,
114
- installOhMyZsh: true
153
+ // src/prompts/payments.ts
154
+ import inquirer3 from "inquirer";
155
+ async function promptPaymentConfig() {
156
+ const { enabled } = await inquirer3.prompt([
157
+ {
158
+ type: "confirm",
159
+ name: "enabled",
160
+ message: "Do you want to configure Stripe payments?",
161
+ default: true
162
+ }
163
+ ]);
164
+ if (!enabled) {
165
+ return { enabled: false };
166
+ }
167
+ const answers = await inquirer3.prompt([
168
+ {
169
+ type: "input",
170
+ name: "stripeSecretKey",
171
+ message: "Enter your Stripe secret key (sk_test_... or sk_live_...):",
172
+ validate: async (input) => {
173
+ if (!input || input.trim() === "") {
174
+ return "Stripe secret key is required";
175
+ }
176
+ const result = await validateStripeKey(input);
177
+ return result.valid ? true : result.message || "Invalid Stripe key";
115
178
  }
116
179
  },
117
- forwardPorts: [3e3, 4e3, 5432],
118
- portsAttributes: {
119
- "3000": {
120
- label: "Web App",
121
- onAutoForward: "notify"
122
- },
123
- "4000": {
124
- label: "CMS",
125
- onAutoForward: "notify"
126
- },
127
- "5432": {
128
- label: "PostgreSQL",
129
- onAutoForward: "silent"
180
+ {
181
+ type: "input",
182
+ name: "stripePublishableKey",
183
+ message: "Enter your Stripe publishable key (pk_test_... or pk_live_...):",
184
+ validate: (input) => {
185
+ if (!input || input.trim() === "") {
186
+ return "Stripe publishable key is required";
187
+ }
188
+ if (!(input.startsWith("pk_test_") || input.startsWith("pk_live_"))) {
189
+ return "Stripe publishable key must start with pk_test_ or pk_live_";
190
+ }
191
+ return true;
130
192
  }
131
193
  },
132
- postCreateCommand: "corepack enable && pnpm install",
133
- customizations: {
134
- vscode: {
135
- extensions: [
136
- "dbaeumer.vscode-eslint",
137
- "biomejs.biome",
138
- "bradlc.vscode-tailwindcss",
139
- "Prisma.prisma",
140
- "ms-azuretools.vscode-docker",
141
- "streetsidesoftware.code-spell-checker"
142
- ],
143
- settings: {
144
- "editor.defaultFormatter": "biomejs.biome",
145
- "editor.formatOnSave": true,
146
- "editor.codeActionsOnSave": {
147
- "quickfix.biome": "explicit",
148
- "source.organizeImports.biome": "explicit"
149
- }
194
+ {
195
+ type: "input",
196
+ name: "stripeWebhookSecret",
197
+ message: "Enter your Stripe webhook secret (whsec_..., optional - press Enter to skip):",
198
+ default: ""
199
+ }
200
+ ]);
201
+ return {
202
+ enabled: true,
203
+ stripeSecretKey: answers.stripeSecretKey,
204
+ stripePublishableKey: answers.stripePublishableKey,
205
+ stripeWebhookSecret: answers.stripeWebhookSecret || void 0
206
+ };
207
+ }
208
+
209
+ // src/prompts/project.ts
210
+ import fs from "fs";
211
+ import path from "path";
212
+ import inquirer4 from "inquirer";
213
+ var VALID_TEMPLATES = ["basic-blog", "e-commerce", "portfolio"];
214
+ async function promptProjectConfig(defaultName, templateArg) {
215
+ let projectName;
216
+ if (defaultName) {
217
+ projectName = defaultName;
218
+ } else {
219
+ const answers = await inquirer4.prompt([
220
+ {
221
+ type: "input",
222
+ name: "projectName",
223
+ message: "What is your project name?",
224
+ default: "my-revealui-project",
225
+ validate: (input) => {
226
+ if (!/^[a-z0-9-]+$/.test(input)) {
227
+ return "Project name must contain only lowercase letters, numbers, and hyphens";
228
+ }
229
+ const projectPath = path.resolve(process.cwd(), input);
230
+ if (fs.existsSync(projectPath)) {
231
+ return `Directory "${input}" already exists`;
232
+ }
233
+ return true;
234
+ }
235
+ }
236
+ ]);
237
+ projectName = answers.projectName;
238
+ }
239
+ let template;
240
+ if (templateArg && VALID_TEMPLATES.includes(templateArg)) {
241
+ template = templateArg;
242
+ } else {
243
+ const answers = await inquirer4.prompt([
244
+ {
245
+ type: "list",
246
+ name: "template",
247
+ message: "Which template would you like to use?",
248
+ choices: [
249
+ { name: "Basic Blog - A simple blog with posts and pages", value: "basic-blog" },
250
+ { name: "E-commerce - Product catalog with checkout", value: "e-commerce" },
251
+ { name: "Portfolio - Personal portfolio site", value: "portfolio" }
252
+ ],
253
+ default: "basic-blog"
254
+ }
255
+ ]);
256
+ template = answers.template;
257
+ }
258
+ return {
259
+ projectName,
260
+ projectPath: path.resolve(process.cwd(), projectName),
261
+ template
262
+ };
263
+ }
264
+
265
+ // src/prompts/storage.ts
266
+ import inquirer5 from "inquirer";
267
+ async function promptStorageConfig() {
268
+ const { provider } = await inquirer5.prompt([
269
+ {
270
+ type: "list",
271
+ name: "provider",
272
+ message: "Which storage provider would you like to use?",
273
+ choices: [
274
+ {
275
+ name: "Vercel Blob - Simple object storage (recommended)",
276
+ value: "vercel-blob"
277
+ },
278
+ {
279
+ name: "Supabase Storage - Integrated with Supabase",
280
+ value: "supabase"
281
+ },
282
+ {
283
+ name: "Skip - Configure later",
284
+ value: "skip"
285
+ }
286
+ ],
287
+ default: "vercel-blob"
288
+ }
289
+ ]);
290
+ if (provider === "skip") {
291
+ return { provider: "skip" };
292
+ }
293
+ if (provider === "vercel-blob") {
294
+ const { blobToken } = await inquirer5.prompt([
295
+ {
296
+ type: "input",
297
+ name: "blobToken",
298
+ message: "Enter your Vercel Blob read/write token:",
299
+ validate: async (input) => {
300
+ if (!input || input.trim() === "") {
301
+ return "Blob token is required";
302
+ }
303
+ const result = await validateVercelToken(input);
304
+ return result.valid ? true : result.message || "Invalid token";
305
+ }
306
+ }
307
+ ]);
308
+ return { provider: "vercel-blob", blobToken };
309
+ }
310
+ const answers = await inquirer5.prompt([
311
+ {
312
+ type: "input",
313
+ name: "supabaseUrl",
314
+ message: "Enter your Supabase project URL:",
315
+ validate: async (input) => {
316
+ if (!input || input.trim() === "") {
317
+ return "Supabase URL is required";
150
318
  }
319
+ const result = await validateSupabaseUrl(input);
320
+ return result.valid ? true : result.message || "Invalid URL";
151
321
  }
152
322
  },
153
- remoteUser: "node"
323
+ {
324
+ type: "input",
325
+ name: "supabasePublishableKey",
326
+ message: "Enter your Supabase publishable key (sb_publishable_...):",
327
+ validate: (input) => {
328
+ if (!input || input.trim() === "") {
329
+ return "Supabase publishable key is required";
330
+ }
331
+ return true;
332
+ }
333
+ }
334
+ ]);
335
+ return {
336
+ provider: "supabase",
337
+ supabaseUrl: answers.supabaseUrl,
338
+ supabasePublishableKey: answers.supabasePublishableKey
339
+ };
340
+ }
341
+
342
+ // src/validators/node-version.ts
343
+ import { createLogger as createLogger2 } from "@revealui/setup/utils";
344
+ var logger2 = createLogger2({ prefix: "Setup" });
345
+ var REQUIRED_NODE_VERSION = "24.13.0";
346
+ function validateNodeVersion() {
347
+ const currentVersion = process.version.slice(1);
348
+ const [currentMajor, currentMinor] = currentVersion.split(".").map(Number);
349
+ const [requiredMajor, requiredMinor] = REQUIRED_NODE_VERSION.split(".").map(Number);
350
+ if (currentMajor < requiredMajor || currentMajor === requiredMajor && currentMinor < requiredMinor) {
351
+ logger2.error(
352
+ `Node.js ${REQUIRED_NODE_VERSION} or higher is required. You have ${currentVersion}.`
353
+ );
354
+ logger2.info("Please upgrade Node.js: https://nodejs.org/");
355
+ return false;
356
+ }
357
+ return true;
358
+ }
359
+
360
+ // src/commands/create.ts
361
+ import crypto from "crypto";
362
+ import fs5 from "fs/promises";
363
+ import path5 from "path";
364
+ import { fileURLToPath } from "url";
365
+ import { createLogger as createLogger5 } from "@revealui/setup/utils";
366
+ import ora2 from "ora";
367
+
368
+ // src/generators/devbox.ts
369
+ import fs2 from "fs/promises";
370
+ import path2 from "path";
371
+ async function generateDevbox(projectPath) {
372
+ const devboxConfig = {
373
+ packages: ["nodejs@24.13.0", "pnpm@10.28.2", "postgresql@16", "stripe-cli@latest"],
374
+ shell: {
375
+ init_hook: [
376
+ "corepack enable",
377
+ 'echo "\u{1F680} RevealUI Devbox shell ready!"',
378
+ 'echo "Run: pnpm dev to start development"'
379
+ ],
380
+ scripts: {
381
+ dev: "pnpm dev",
382
+ setup: "pnpm install && pnpm db:init",
383
+ test: "pnpm test"
384
+ }
385
+ },
386
+ env: {
387
+ NODE_ENV: "development"
388
+ }
154
389
  };
155
390
  await fs2.writeFile(
391
+ path2.join(projectPath, "devbox.json"),
392
+ JSON.stringify(devboxConfig, null, 2),
393
+ "utf-8"
394
+ );
395
+ }
396
+
397
+ // src/generators/devcontainer.ts
398
+ import fs3 from "fs/promises";
399
+ import path3 from "path";
400
+ async function generateDevContainer(projectPath) {
401
+ const devcontainerDir = path3.join(projectPath, ".devcontainer");
402
+ await fs3.mkdir(devcontainerDir, { recursive: true });
403
+ const devcontainerConfig = {
404
+ name: "RevealUI Development",
405
+ image: "mcr.microsoft.com/devcontainers/typescript-node:24",
406
+ features: {
407
+ "ghcr.io/devcontainers/features/common-utils:2": {
408
+ installZsh: true,
409
+ installOhMyZsh: true
410
+ }
411
+ },
412
+ forwardPorts: [3e3, 4e3, 5432],
413
+ portsAttributes: {
414
+ "3000": {
415
+ label: "Web App",
416
+ onAutoForward: "notify"
417
+ },
418
+ "4000": {
419
+ label: "CMS",
420
+ onAutoForward: "notify"
421
+ },
422
+ "5432": {
423
+ label: "PostgreSQL",
424
+ onAutoForward: "silent"
425
+ }
426
+ },
427
+ postCreateCommand: "corepack enable && pnpm install",
428
+ customizations: {
429
+ vscode: {
430
+ extensions: [
431
+ "biomejs.biome",
432
+ "bradlc.vscode-tailwindcss",
433
+ "Prisma.prisma",
434
+ "ms-azuretools.vscode-docker",
435
+ "streetsidesoftware.code-spell-checker"
436
+ ],
437
+ settings: {
438
+ "editor.defaultFormatter": "biomejs.biome",
439
+ "editor.formatOnSave": true,
440
+ "editor.codeActionsOnSave": {
441
+ "quickfix.biome": "explicit",
442
+ "source.organizeImports.biome": "explicit"
443
+ }
444
+ }
445
+ }
446
+ },
447
+ remoteUser: "node"
448
+ };
449
+ await fs3.writeFile(
156
450
  path3.join(devcontainerDir, "devcontainer.json"),
157
451
  JSON.stringify(devcontainerConfig, null, 2),
158
452
  "utf-8"
@@ -182,7 +476,7 @@ services:
182
476
  volumes:
183
477
  postgres-data:
184
478
  `;
185
- await fs2.writeFile(path3.join(devcontainerDir, "docker-compose.yml"), dockerCompose, "utf-8");
479
+ await fs3.writeFile(path3.join(devcontainerDir, "docker-compose.yml"), dockerCompose, "utf-8");
186
480
  const dockerfile = `FROM mcr.microsoft.com/devcontainers/typescript-node:24
187
481
 
188
482
  # Install additional tools
@@ -192,7 +486,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \\
192
486
  # Enable pnpm
193
487
  RUN corepack enable
194
488
  `;
195
- await fs2.writeFile(path3.join(devcontainerDir, "Dockerfile"), dockerfile, "utf-8");
489
+ await fs3.writeFile(path3.join(devcontainerDir, "Dockerfile"), dockerfile, "utf-8");
196
490
  const readme = `# Dev Container Setup
197
491
 
198
492
  This directory contains the Dev Container configuration for RevealUI.
@@ -213,11 +507,10 @@ This directory contains the Dev Container configuration for RevealUI.
213
507
 
214
508
  ## What's Included
215
509
 
216
- - Node.js 24.12.0
510
+ - Node.js 24.13.0
217
511
  - pnpm package manager
218
512
  - PostgreSQL 16 with pgvector
219
513
  - VS Code extensions:
220
- - ESLint
221
514
  - Biome
222
515
  - Tailwind CSS
223
516
  - Prisma
@@ -235,17 +528,11 @@ For GitHub Codespaces, set secrets in your repository settings.
235
528
  - 4000: CMS
236
529
  - 5432: PostgreSQL database
237
530
  `;
238
- await fs2.writeFile(path3.join(devcontainerDir, "README.md"), readme, "utf-8");
531
+ await fs3.writeFile(path3.join(devcontainerDir, "README.md"), readme, "utf-8");
239
532
  }
240
- var init_devcontainer = __esm({
241
- "src/generators/devcontainer.ts"() {
242
- "use strict";
243
- init_esm_shims();
244
- }
245
- });
246
533
 
247
534
  // src/generators/readme.ts
248
- import fs3 from "fs/promises";
535
+ import fs4 from "fs/promises";
249
536
  import path4 from "path";
250
537
  async function generateReadme(projectPath, projectConfig) {
251
538
  const readme = `# ${projectConfig.projectName}
@@ -282,7 +569,7 @@ The web application runs on [http://localhost:3000](http://localhost:3000).
282
569
  ### Standard Setup
283
570
 
284
571
  Requirements:
285
- - Node.js 24.12.0 or higher
572
+ - Node.js 24.13.0 or higher
286
573
  - pnpm 10.28.2 or higher
287
574
  - PostgreSQL 16
288
575
 
@@ -346,19 +633,14 @@ This project was created using the **${projectConfig.template}** template.
346
633
 
347
634
  MIT
348
635
  `;
349
- await fs3.writeFile(path4.join(projectPath, "README.md"), readme, "utf-8");
636
+ await fs4.writeFile(path4.join(projectPath, "README.md"), readme, "utf-8");
350
637
  }
351
- var init_readme = __esm({
352
- "src/generators/readme.ts"() {
353
- "use strict";
354
- init_esm_shims();
355
- }
356
- });
357
638
 
358
639
  // src/installers/dependencies.ts
359
640
  import { createLogger as createLogger3 } from "@revealui/setup/utils";
360
641
  import { execa } from "execa";
361
642
  import ora from "ora";
643
+ var logger3 = createLogger3({ prefix: "Install" });
362
644
  async function installDependencies(projectPath) {
363
645
  const spinner = ora("Installing dependencies with pnpm...").start();
364
646
  try {
@@ -381,18 +663,11 @@ async function isPnpmInstalled() {
381
663
  return false;
382
664
  }
383
665
  }
384
- var logger3;
385
- var init_dependencies = __esm({
386
- "src/installers/dependencies.ts"() {
387
- "use strict";
388
- init_esm_shims();
389
- logger3 = createLogger3({ prefix: "Install" });
390
- }
391
- });
392
666
 
393
667
  // src/utils/git.ts
394
668
  import { createLogger as createLogger4 } from "@revealui/setup/utils";
395
669
  import { execa as execa2 } from "execa";
670
+ var logger4 = createLogger4({ prefix: "Git" });
396
671
  async function initializeGitRepo(projectPath) {
397
672
  try {
398
673
  await execa2("git", ["init"], { cwd: projectPath });
@@ -420,22 +695,12 @@ async function isGitInstalled() {
420
695
  return false;
421
696
  }
422
697
  }
423
- var logger4;
424
- var init_git = __esm({
425
- "src/utils/git.ts"() {
426
- "use strict";
427
- init_esm_shims();
428
- logger4 = createLogger4({ prefix: "Git" });
429
- }
430
- });
431
698
 
432
699
  // src/commands/create.ts
433
- import crypto from "crypto";
434
- import fs4 from "fs/promises";
435
- import path5 from "path";
436
- import { fileURLToPath as fileURLToPath2 } from "url";
437
- import { createLogger as createLogger5 } from "@revealui/setup/utils";
438
- import ora2 from "ora";
700
+ var logger5 = createLogger5({ prefix: "Create" });
701
+ var __filename2 = fileURLToPath(import.meta.url);
702
+ var __dirname2 = path5.dirname(__filename2);
703
+ var TEMPLATES_DIR = path5.resolve(__dirname2, "../../templates");
439
704
  function buildEnvLocal(cfg) {
440
705
  const lines = [
441
706
  "# Generated by @revealui/cli \u2014 fill in the remaining placeholders before running `pnpm dev`",
@@ -479,20 +744,28 @@ function buildEnvLocal(cfg) {
479
744
  function generateSecret() {
480
745
  return crypto.randomBytes(24).toString("hex");
481
746
  }
747
+ async function listAvailableTemplates() {
748
+ try {
749
+ const entries = await fs5.readdir(TEMPLATES_DIR, { withFileTypes: true });
750
+ return entries.filter((e) => e.isDirectory()).map((e) => e.name);
751
+ } catch {
752
+ return [];
753
+ }
754
+ }
482
755
  async function copyTemplate(templateName, targetPath) {
483
756
  const templatePath = path5.join(TEMPLATES_DIR, templateName);
484
757
  try {
485
- await fs4.access(templatePath);
758
+ await fs5.access(templatePath);
486
759
  } catch {
487
- throw new Error(
488
- `Template "${templateName}" not found at ${templatePath}. Available templates: minimal, basic-blog, e-commerce, portfolio`
489
- );
760
+ const available = await listAvailableTemplates();
761
+ const listing = available.length > 0 ? `Available templates: ${available.join(", ")}` : `No templates found in ${TEMPLATES_DIR}`;
762
+ throw new Error(`Template "${templateName}" not found at ${templatePath}. ${listing}`);
490
763
  }
491
764
  await copyDir(templatePath, targetPath);
492
765
  }
493
766
  async function copyDir(src, dest) {
494
- await fs4.mkdir(dest, { recursive: true });
495
- const entries = await fs4.readdir(src, { withFileTypes: true });
767
+ await fs5.mkdir(dest, { recursive: true });
768
+ const entries = await fs5.readdir(src, { withFileTypes: true });
496
769
  for (const entry of entries) {
497
770
  const srcPath = path5.join(src, entry.name);
498
771
  const destName = entry.name === "_gitignore" ? ".gitignore" : entry.name;
@@ -500,17 +773,17 @@ async function copyDir(src, dest) {
500
773
  if (entry.isDirectory()) {
501
774
  await copyDir(srcPath, destPath);
502
775
  } else {
503
- await fs4.copyFile(srcPath, destPath);
776
+ await fs5.copyFile(srcPath, destPath);
504
777
  }
505
778
  }
506
779
  }
507
780
  function resolveTemplateName(template) {
508
781
  const map = {
509
- "basic-blog": "minimal",
510
- "e-commerce": "minimal",
511
- portfolio: "minimal"
782
+ "basic-blog": "basic-blog",
783
+ "e-commerce": "e-commerce",
784
+ portfolio: "portfolio"
512
785
  };
513
- return map[template] ?? "minimal";
786
+ return map[template] ?? "starter";
514
787
  }
515
788
  async function createProject(cfg) {
516
789
  const { project, skipGit = false, skipInstall = false } = cfg;
@@ -525,13 +798,13 @@ async function createProject(cfg) {
525
798
  }
526
799
  const pkgJsonPath = path5.join(projectPath, "package.json");
527
800
  try {
528
- const raw = await fs4.readFile(pkgJsonPath, "utf-8");
529
- await fs4.writeFile(pkgJsonPath, raw.replaceAll("{{PROJECT_NAME}}", projectName), "utf-8");
801
+ const raw = await fs5.readFile(pkgJsonPath, "utf-8");
802
+ await fs5.writeFile(pkgJsonPath, raw.replaceAll("{{PROJECT_NAME}}", projectName), "utf-8");
530
803
  } catch {
531
804
  }
532
805
  const envSpinner = ora2("Writing .env.local...").start();
533
806
  try {
534
- await fs4.writeFile(path5.join(projectPath, ".env.local"), buildEnvLocal(cfg), "utf-8");
807
+ await fs5.writeFile(path5.join(projectPath, ".env.local"), buildEnvLocal(cfg), "utf-8");
535
808
  envSpinner.succeed(".env.local written");
536
809
  } catch (err) {
537
810
  envSpinner.fail("Failed to write .env.local");
@@ -550,7 +823,9 @@ async function createProject(cfg) {
550
823
  if (!skipInstall) {
551
824
  const pnpmOk = await isPnpmInstalled();
552
825
  if (!pnpmOk) {
553
- logger5.warn("pnpm not found \u2014 skipping dependency installation. Run `pnpm install` manually.");
826
+ logger5.warn(
827
+ "pnpm not found \u2014 skipping dependency installation. Run `pnpm install` manually."
828
+ );
554
829
  } else {
555
830
  await installDependencies(projectPath);
556
831
  }
@@ -569,393 +844,11 @@ async function createProject(cfg) {
569
844
  logger5.info("Skipping git initialisation (--skip-git)");
570
845
  }
571
846
  }
572
- var logger5, __filename2, __dirname2, TEMPLATES_DIR;
573
- var init_create = __esm({
574
- "src/commands/create.ts"() {
575
- "use strict";
576
- init_esm_shims();
577
- init_devbox();
578
- init_devcontainer();
579
- init_readme();
580
- init_dependencies();
581
- init_git();
582
- logger5 = createLogger5({ prefix: "Create" });
583
- __filename2 = fileURLToPath2(import.meta.url);
584
- __dirname2 = path5.dirname(__filename2);
585
- TEMPLATES_DIR = path5.resolve(__dirname2, "../../templates");
586
- }
587
- });
588
847
 
589
- // src/validators/credentials.ts
590
- import { createLogger as createLogger6 } from "@revealui/setup/utils";
591
- async function validateStripeKey(key) {
592
- if (!(key.startsWith("sk_test_") || key.startsWith("sk_live_"))) {
593
- return {
594
- valid: false,
595
- message: "Stripe key must start with sk_test_ or sk_live_"
596
- };
597
- }
598
- return { valid: true };
599
- }
600
- async function validateNeonUrl(url) {
601
- try {
602
- const parsed = new URL(url);
603
- if (!parsed.protocol.startsWith("postgres")) {
604
- return {
605
- valid: false,
606
- message: "Database URL must use postgres:// or postgresql:// protocol"
607
- };
608
- }
609
- return { valid: true };
610
- } catch {
611
- return {
612
- valid: false,
613
- message: "Invalid database URL format"
614
- };
615
- }
616
- }
617
- async function validateVercelToken(token) {
618
- if (!token || token.length < 20) {
619
- return {
620
- valid: false,
621
- message: "Vercel token appears invalid (too short)"
622
- };
623
- }
624
- return { valid: true };
625
- }
626
- async function validateSupabaseUrl(url) {
627
- try {
628
- const parsed = new URL(url);
629
- if (!parsed.hostname.includes("supabase")) {
630
- logger6.warn("URL does not appear to be a Supabase URL");
631
- }
632
- return { valid: true };
633
- } catch {
634
- return {
635
- valid: false,
636
- message: "Invalid Supabase URL format"
637
- };
638
- }
639
- }
640
- var logger6;
641
- var init_credentials = __esm({
642
- "src/validators/credentials.ts"() {
643
- "use strict";
644
- init_esm_shims();
645
- logger6 = createLogger6({ prefix: "Validator" });
646
- }
647
- });
648
-
649
- // src/prompts/database.ts
650
- import inquirer from "inquirer";
651
- async function promptDatabaseConfig() {
652
- const { provider } = await inquirer.prompt([
653
- {
654
- type: "list",
655
- name: "provider",
656
- message: "Which database provider would you like to use?",
657
- choices: [
658
- {
659
- name: "NeonDB - Serverless PostgreSQL (recommended)",
660
- value: "neon"
661
- },
662
- {
663
- name: "Supabase - PostgreSQL with built-in features",
664
- value: "supabase"
665
- },
666
- {
667
- name: "Local PostgreSQL - Use existing local database",
668
- value: "local"
669
- },
670
- {
671
- name: "Skip - Configure later",
672
- value: "skip"
673
- }
674
- ],
675
- default: "neon"
676
- }
677
- ]);
678
- if (provider === "skip") {
679
- return { provider: "skip" };
680
- }
681
- if (provider === "local") {
682
- const { postgresUrl: postgresUrl2 } = await inquirer.prompt([
683
- {
684
- type: "input",
685
- name: "postgresUrl",
686
- message: "Enter your PostgreSQL connection string:",
687
- default: "postgresql://postgres:postgres@localhost:5432/revealui",
688
- validate: async (input) => {
689
- const result = await validateNeonUrl(input);
690
- return result.valid ? true : result.message || "Invalid database URL";
691
- }
692
- }
693
- ]);
694
- return { provider: "local", postgresUrl: postgresUrl2 };
695
- }
696
- const { postgresUrl } = await inquirer.prompt([
697
- {
698
- type: "input",
699
- name: "postgresUrl",
700
- message: `Enter your ${provider === "neon" ? "Neon" : "Supabase"} database connection string:`,
701
- validate: async (input) => {
702
- if (!input || input.trim() === "") {
703
- return "Database URL is required";
704
- }
705
- const result = await validateNeonUrl(input);
706
- return result.valid ? true : result.message || "Invalid database URL";
707
- }
708
- }
709
- ]);
710
- return { provider, postgresUrl };
711
- }
712
- var init_database = __esm({
713
- "src/prompts/database.ts"() {
714
- "use strict";
715
- init_esm_shims();
716
- init_credentials();
717
- }
718
- });
719
-
720
- // src/prompts/devenv.ts
721
- import inquirer2 from "inquirer";
722
- async function promptDevEnvConfig() {
723
- const answers = await inquirer2.prompt([
724
- {
725
- type: "confirm",
726
- name: "createDevContainer",
727
- message: "Create Dev Container configuration for VS Code / GitHub Codespaces?",
728
- default: true
729
- },
730
- {
731
- type: "confirm",
732
- name: "createDevbox",
733
- message: "Create Devbox configuration for Nix-powered development?",
734
- default: true
735
- }
736
- ]);
737
- return answers;
738
- }
739
- var init_devenv = __esm({
740
- "src/prompts/devenv.ts"() {
741
- "use strict";
742
- init_esm_shims();
743
- }
744
- });
745
-
746
- // src/prompts/payments.ts
747
- import inquirer3 from "inquirer";
748
- async function promptPaymentConfig() {
749
- const { enabled } = await inquirer3.prompt([
750
- {
751
- type: "confirm",
752
- name: "enabled",
753
- message: "Do you want to configure Stripe payments?",
754
- default: true
755
- }
756
- ]);
757
- if (!enabled) {
758
- return { enabled: false };
759
- }
760
- const answers = await inquirer3.prompt([
761
- {
762
- type: "input",
763
- name: "stripeSecretKey",
764
- message: "Enter your Stripe secret key (sk_test_... or sk_live_...):",
765
- validate: async (input) => {
766
- if (!input || input.trim() === "") {
767
- return "Stripe secret key is required";
768
- }
769
- const result = await validateStripeKey(input);
770
- return result.valid ? true : result.message || "Invalid Stripe key";
771
- }
772
- },
773
- {
774
- type: "input",
775
- name: "stripePublishableKey",
776
- message: "Enter your Stripe publishable key (pk_test_... or pk_live_...):",
777
- validate: (input) => {
778
- if (!input || input.trim() === "") {
779
- return "Stripe publishable key is required";
780
- }
781
- if (!(input.startsWith("pk_test_") || input.startsWith("pk_live_"))) {
782
- return "Stripe publishable key must start with pk_test_ or pk_live_";
783
- }
784
- return true;
785
- }
786
- },
787
- {
788
- type: "input",
789
- name: "stripeWebhookSecret",
790
- message: "Enter your Stripe webhook secret (whsec_..., optional - press Enter to skip):",
791
- default: ""
792
- }
793
- ]);
794
- return {
795
- enabled: true,
796
- stripeSecretKey: answers.stripeSecretKey,
797
- stripePublishableKey: answers.stripePublishableKey,
798
- stripeWebhookSecret: answers.stripeWebhookSecret || void 0
799
- };
800
- }
801
- var init_payments = __esm({
802
- "src/prompts/payments.ts"() {
803
- "use strict";
804
- init_esm_shims();
805
- init_credentials();
806
- }
807
- });
808
-
809
- // src/prompts/project.ts
810
- import fs5 from "fs";
811
- import path6 from "path";
812
- import inquirer4 from "inquirer";
813
- async function promptProjectConfig(defaultName) {
814
- const answers = await inquirer4.prompt([
815
- {
816
- type: "input",
817
- name: "projectName",
818
- message: "What is your project name?",
819
- default: defaultName || "my-revealui-project",
820
- validate: (input) => {
821
- if (!/^[a-z0-9-]+$/.test(input)) {
822
- return "Project name must contain only lowercase letters, numbers, and hyphens";
823
- }
824
- const projectPath = path6.resolve(process.cwd(), input);
825
- if (fs5.existsSync(projectPath)) {
826
- return `Directory "${input}" already exists`;
827
- }
828
- return true;
829
- }
830
- },
831
- {
832
- type: "list",
833
- name: "template",
834
- message: "Which template would you like to use?",
835
- choices: [
836
- {
837
- name: "Basic Blog - A simple blog with posts and pages",
838
- value: "basic-blog"
839
- },
840
- {
841
- name: "E-commerce - Product catalog with checkout",
842
- value: "e-commerce"
843
- },
844
- {
845
- name: "Portfolio - Personal portfolio site",
846
- value: "portfolio"
847
- }
848
- ],
849
- default: "basic-blog"
850
- }
851
- ]);
852
- return {
853
- projectName: answers.projectName,
854
- projectPath: path6.resolve(process.cwd(), answers.projectName),
855
- template: answers.template
856
- };
857
- }
858
- var init_project = __esm({
859
- "src/prompts/project.ts"() {
860
- "use strict";
861
- init_esm_shims();
862
- }
863
- });
864
-
865
- // src/prompts/storage.ts
866
- import inquirer5 from "inquirer";
867
- async function promptStorageConfig() {
868
- const { provider } = await inquirer5.prompt([
869
- {
870
- type: "list",
871
- name: "provider",
872
- message: "Which storage provider would you like to use?",
873
- choices: [
874
- {
875
- name: "Vercel Blob - Simple object storage (recommended)",
876
- value: "vercel-blob"
877
- },
878
- {
879
- name: "Supabase Storage - Integrated with Supabase",
880
- value: "supabase"
881
- },
882
- {
883
- name: "Skip - Configure later",
884
- value: "skip"
885
- }
886
- ],
887
- default: "vercel-blob"
888
- }
889
- ]);
890
- if (provider === "skip") {
891
- return { provider: "skip" };
892
- }
893
- if (provider === "vercel-blob") {
894
- const { blobToken } = await inquirer5.prompt([
895
- {
896
- type: "input",
897
- name: "blobToken",
898
- message: "Enter your Vercel Blob read/write token:",
899
- validate: async (input) => {
900
- if (!input || input.trim() === "") {
901
- return "Blob token is required";
902
- }
903
- const result = await validateVercelToken(input);
904
- return result.valid ? true : result.message || "Invalid token";
905
- }
906
- }
907
- ]);
908
- return { provider: "vercel-blob", blobToken };
909
- }
910
- const answers = await inquirer5.prompt([
911
- {
912
- type: "input",
913
- name: "supabaseUrl",
914
- message: "Enter your Supabase project URL:",
915
- validate: async (input) => {
916
- if (!input || input.trim() === "") {
917
- return "Supabase URL is required";
918
- }
919
- const result = await validateSupabaseUrl(input);
920
- return result.valid ? true : result.message || "Invalid URL";
921
- }
922
- },
923
- {
924
- type: "input",
925
- name: "supabaseAnonKey",
926
- message: "Enter your Supabase anonymous key:",
927
- validate: (input) => {
928
- if (!input || input.trim() === "") {
929
- return "Supabase anonymous key is required";
930
- }
931
- return true;
932
- }
933
- }
934
- ]);
935
- return {
936
- provider: "supabase",
937
- supabaseUrl: answers.supabaseUrl,
938
- supabaseAnonKey: answers.supabaseAnonKey
939
- };
940
- }
941
- var init_storage = __esm({
942
- "src/prompts/storage.ts"() {
943
- "use strict";
944
- init_esm_shims();
945
- init_credentials();
946
- }
947
- });
948
-
949
- // src/index.ts
950
- var index_exports = {};
951
- __export(index_exports, {
952
- run: () => run
953
- });
954
- import { readFileSync } from "fs";
955
- import { homedir } from "os";
956
- import { join } from "path";
957
- import { createLogger as createLogger7 } from "@revealui/setup/utils";
958
- function checkProLicense() {
848
+ // src/commands/create-flow.ts
849
+ var logger6 = createLogger6({ prefix: "@revealui/cli" });
850
+ var PRO_TEMPLATES = /* @__PURE__ */ new Set([]);
851
+ async function checkProLicense() {
959
852
  let key = process.env.REVEALUI_LICENSE_KEY;
960
853
  if (!key) {
961
854
  try {
@@ -966,111 +859,941 @@ function checkProLicense() {
966
859
  }
967
860
  }
968
861
  if (!key) return false;
862
+ const publicKeyPem = process.env.REVEALUI_LICENSE_PUBLIC_KEY;
863
+ if (publicKeyPem) {
864
+ try {
865
+ const publicKey = await importSPKI(publicKeyPem, "RS256");
866
+ const { payload } = await jwtVerify(key, publicKey);
867
+ const tier = payload.tier ?? "free";
868
+ return tier === "pro" || tier === "enterprise";
869
+ } catch {
870
+ return false;
871
+ }
872
+ }
969
873
  try {
970
874
  const parts = key.split(".");
971
- if (parts.length < 2) return false;
972
- const payload = JSON.parse(Buffer.from(parts[1] ?? "", "base64").toString("utf8"));
875
+ if (parts.length < 3) return false;
876
+ const payload = JSON.parse(Buffer.from(parts[1] ?? "", "base64url").toString("utf8"));
877
+ if (payload.exp !== void 0 && payload.exp < Math.floor(Date.now() / 1e3)) {
878
+ return false;
879
+ }
973
880
  const tier = payload.tier ?? "free";
974
881
  return tier === "pro" || tier === "enterprise";
975
882
  } catch {
976
883
  return false;
977
884
  }
978
885
  }
979
- async function run(projectName, _options) {
980
- try {
981
- logger7.info("[1/8] Validating Node.js version...");
982
- if (!validateNodeVersion()) {
983
- process.exit(1);
886
+ async function runCreateFlow(projectName, options) {
887
+ logger6.info("[1/8] Validating Node.js version...");
888
+ if (!validateNodeVersion()) {
889
+ process.exit(1);
890
+ }
891
+ logger6.success(`Node.js version: ${process.version}`);
892
+ logger6.info("[2/8] Configure your project");
893
+ const projectConfig = await promptProjectConfig(projectName, options.template);
894
+ logger6.success(`Project: ${projectConfig.projectName}`);
895
+ logger6.success(`Template: ${projectConfig.template}`);
896
+ if (PRO_TEMPLATES.has(projectConfig.template)) {
897
+ if (!await checkProLicense()) {
898
+ logger6.error(`The "${projectConfig.template}" template requires a RevealUI Pro license.`);
899
+ logger6.info("Get Pro at https://revealui.com/pricing");
900
+ logger6.info("Set your license key: export REVEALUI_LICENSE_KEY=<your-key>");
901
+ process.exit(2);
984
902
  }
985
- logger7.success(`Node.js version: ${process.version}`);
986
- logger7.info("[2/8] Configure your project");
987
- const projectConfig = await promptProjectConfig(projectName);
988
- logger7.success(`Project: ${projectConfig.projectName}`);
989
- logger7.success(`Template: ${projectConfig.template}`);
990
- if (PRO_TEMPLATES.has(projectConfig.template)) {
991
- if (!checkProLicense()) {
992
- logger7.error(`The "${projectConfig.template}" template requires a RevealUI Pro license.`);
993
- logger7.info("Get Pro at https://revealui.com/pricing");
994
- logger7.info("Set your license key: export REVEALUI_LICENSE_KEY=<your-key>");
995
- process.exit(2);
903
+ logger6.success("Pro license verified");
904
+ }
905
+ const nonInteractive = options.yes === true;
906
+ logger6.info("[3/8] Configure database");
907
+ const databaseConfig = nonInteractive ? { provider: "skip" } : await promptDatabaseConfig();
908
+ if (databaseConfig.provider !== "skip") {
909
+ logger6.success(`Database: ${databaseConfig.provider}`);
910
+ } else {
911
+ logger6.info("Database configuration skipped");
912
+ }
913
+ logger6.info("[4/8] Configure storage");
914
+ const storageConfig = nonInteractive ? { provider: "skip" } : await promptStorageConfig();
915
+ if (storageConfig.provider !== "skip") {
916
+ logger6.success(`Storage: ${storageConfig.provider}`);
917
+ } else {
918
+ logger6.info("Storage configuration skipped");
919
+ }
920
+ logger6.info("[5/8] Configure payments");
921
+ const paymentConfig = nonInteractive ? { enabled: false } : await promptPaymentConfig();
922
+ if (paymentConfig.enabled) {
923
+ logger6.success("Stripe configured");
924
+ } else {
925
+ logger6.info("Payments disabled");
926
+ }
927
+ logger6.info("[6/8] Configure development environment");
928
+ const devEnvConfig = nonInteractive ? { createDevContainer: false, createDevbox: false } : await promptDevEnvConfig();
929
+ logger6.success(
930
+ `Dev Container: ${devEnvConfig.createDevContainer ? "Yes" : "No"}, Devbox: ${devEnvConfig.createDevbox ? "Yes" : "No"}`
931
+ );
932
+ logger6.info("[7/8] Creating project...");
933
+ await createProject({
934
+ project: projectConfig,
935
+ database: databaseConfig,
936
+ storage: storageConfig,
937
+ payment: paymentConfig,
938
+ devenv: devEnvConfig,
939
+ skipGit: options.skipGit,
940
+ skipInstall: options.skipInstall
941
+ });
942
+ logger6.success("Project created successfully");
943
+ logger6.info("[8/8] Next steps");
944
+ logger6.divider();
945
+ logger6.info(`cd ${projectConfig.projectName}`);
946
+ logger6.info("pnpm install");
947
+ logger6.info("pnpm dev");
948
+ logger6.divider();
949
+ logger6.success(`Project ${projectConfig.projectName} created successfully`);
950
+ }
951
+
952
+ // src/commands/db.ts
953
+ import fs8 from "fs/promises";
954
+ import path8 from "path";
955
+ import { createLogger as createLogger7 } from "@revealui/setup/utils";
956
+ import { execa as execa4 } from "execa";
957
+
958
+ // src/utils/command.ts
959
+ import net from "net";
960
+ import { execa as execa3 } from "execa";
961
+ async function commandExists(command) {
962
+ try {
963
+ await execa3("bash", ["-lc", `command -v ${command}`], {
964
+ stdio: "pipe"
965
+ });
966
+ return true;
967
+ } catch {
968
+ return false;
969
+ }
970
+ }
971
+ async function isTcpReachable(host, port, timeoutMs = 1500) {
972
+ return await new Promise((resolve) => {
973
+ const socket = new net.Socket();
974
+ const finalize = (value) => {
975
+ socket.removeAllListeners();
976
+ socket.destroy();
977
+ resolve(value);
978
+ };
979
+ socket.setTimeout(timeoutMs);
980
+ socket.once("connect", () => finalize(true));
981
+ socket.once("timeout", () => finalize(false));
982
+ socket.once("error", () => finalize(false));
983
+ socket.connect(port, host);
984
+ });
985
+ }
986
+
987
+ // src/utils/db.ts
988
+ import fs6 from "fs/promises";
989
+ import path6 from "path";
990
+ function resolveLocalDbConfig(cwd = process.cwd(), env = process.env) {
991
+ const pgdata = env.PGDATA || path6.join(cwd, ".pgdata");
992
+ const pghost = env.PGHOST || pgdata;
993
+ const pgdatabase = env.PGDATABASE || "postgres";
994
+ const pguser = env.PGUSER || "postgres";
995
+ const postgresUrl = env.POSTGRES_URL || "postgresql://postgres@localhost:5432/postgres";
996
+ const databaseUrl = env.DATABASE_URL || postgresUrl;
997
+ return {
998
+ pgdata,
999
+ pghost,
1000
+ pgdatabase,
1001
+ pguser,
1002
+ postgresUrl,
1003
+ databaseUrl
1004
+ };
1005
+ }
1006
+ function isLocalDbUrl(url) {
1007
+ if (!url) return false;
1008
+ try {
1009
+ const parsed = new URL(url);
1010
+ return parsed.hostname === "localhost" || parsed.hostname === "127.0.0.1";
1011
+ } catch {
1012
+ return false;
1013
+ }
1014
+ }
1015
+ function detectDbTarget(url) {
1016
+ if (!url) return "missing";
1017
+ return isLocalDbUrl(url) ? "local" : "remote";
1018
+ }
1019
+ function buildPostgresConfig(pgdata) {
1020
+ return `
1021
+ # RevealUI Development Settings
1022
+ listen_addresses = 'localhost'
1023
+ port = 5432
1024
+ max_connections = 100
1025
+ shared_buffers = 128MB
1026
+ unix_socket_directories = '${pgdata}'
1027
+ `.trimStart();
1028
+ }
1029
+ function buildPgHbaConfig() {
1030
+ return `
1031
+ # TYPE DATABASE USER ADDRESS METHOD
1032
+ local all all trust
1033
+ host all all 127.0.0.1/32 trust
1034
+ host all all ::1/128 trust
1035
+ `.trimStart();
1036
+ }
1037
+ async function writeLocalDbConfigs(pgdata) {
1038
+ await fs6.appendFile(path6.join(pgdata, "postgresql.conf"), buildPostgresConfig(pgdata), "utf8");
1039
+ await fs6.writeFile(path6.join(pgdata, "pg_hba.conf"), buildPgHbaConfig(), "utf8");
1040
+ }
1041
+
1042
+ // src/utils/workspace.ts
1043
+ import fs7 from "fs";
1044
+ import path7 from "path";
1045
+ function findWorkspaceRoot(startDir = process.cwd()) {
1046
+ let current = path7.resolve(startDir);
1047
+ while (true) {
1048
+ const packageJsonPath = path7.join(current, "package.json");
1049
+ if (fs7.existsSync(packageJsonPath)) {
1050
+ try {
1051
+ const pkg = JSON.parse(fs7.readFileSync(packageJsonPath, "utf8"));
1052
+ if (pkg.name === "revealui" && pkg.private === true) {
1053
+ return current;
1054
+ }
1055
+ } catch {
996
1056
  }
997
- logger7.success("Pro license verified");
998
1057
  }
999
- logger7.info("[3/8] Configure database");
1000
- const databaseConfig = await promptDatabaseConfig();
1001
- if (databaseConfig.provider !== "skip") {
1002
- logger7.success(`Database: ${databaseConfig.provider}`);
1003
- } else {
1004
- logger7.info("Database configuration skipped");
1058
+ const parent = path7.dirname(current);
1059
+ if (parent === current) {
1060
+ return null;
1005
1061
  }
1006
- logger7.info("[4/8] Configure storage");
1007
- const storageConfig = await promptStorageConfig();
1008
- if (storageConfig.provider !== "skip") {
1009
- logger7.success(`Storage: ${storageConfig.provider}`);
1010
- } else {
1011
- logger7.info("Storage configuration skipped");
1062
+ current = parent;
1063
+ }
1064
+ }
1065
+
1066
+ // src/commands/db.ts
1067
+ var logger7 = createLogger7({ prefix: "DB" });
1068
+ function isPgCtlNotRunningError(error) {
1069
+ return typeof error === "object" && error !== null && "exitCode" in error && error.exitCode === 3;
1070
+ }
1071
+ function getWorkspaceRootOrThrow() {
1072
+ const root = findWorkspaceRoot();
1073
+ if (!root) {
1074
+ throw new Error("RevealUI workspace root not found");
1075
+ }
1076
+ return root;
1077
+ }
1078
+ function buildDbEnv(root) {
1079
+ const config = resolveLocalDbConfig(root, process.env);
1080
+ return {
1081
+ ...process.env,
1082
+ PGDATA: config.pgdata,
1083
+ PGHOST: config.pghost,
1084
+ PGDATABASE: config.pgdatabase,
1085
+ PGUSER: config.pguser,
1086
+ POSTGRES_URL: config.postgresUrl,
1087
+ DATABASE_URL: config.databaseUrl
1088
+ };
1089
+ }
1090
+ function getPgDataOrThrow(env) {
1091
+ const pgdata = env.PGDATA;
1092
+ if (!pgdata) {
1093
+ throw new Error("PGDATA is not configured for the local RevealUI database");
1094
+ }
1095
+ return pgdata;
1096
+ }
1097
+ async function requireCommand(command) {
1098
+ if (!await commandExists(command)) {
1099
+ throw new Error(`${command} is not available in PATH`);
1100
+ }
1101
+ }
1102
+ async function runDbInitCommand(options = {}) {
1103
+ const root = getWorkspaceRootOrThrow();
1104
+ const env = buildDbEnv(root);
1105
+ const pgdata = getPgDataOrThrow(env);
1106
+ await requireCommand("initdb");
1107
+ try {
1108
+ await fs8.access(pgdata);
1109
+ if (!options.force) {
1110
+ throw new Error(`PostgreSQL is already initialized at ${pgdata}. Use --force to reset it.`);
1012
1111
  }
1013
- logger7.info("[5/8] Configure payments");
1014
- const paymentConfig = await promptPaymentConfig();
1015
- if (paymentConfig.enabled) {
1016
- logger7.success("Stripe configured");
1017
- } else {
1018
- logger7.info("Payments disabled");
1112
+ await fs8.rm(pgdata, { recursive: true, force: true });
1113
+ } catch (error) {
1114
+ if (error instanceof Error && !error.message.includes("already initialized")) {
1115
+ } else if (error instanceof Error) {
1116
+ throw error;
1019
1117
  }
1020
- logger7.info("[6/8] Configure development environment");
1021
- const devEnvConfig = await promptDevEnvConfig();
1022
- logger7.success(
1023
- `Dev Container: ${devEnvConfig.createDevContainer ? "Yes" : "No"}, Devbox: ${devEnvConfig.createDevbox ? "Yes" : "No"}`
1024
- );
1025
- logger7.info("[7/8] Creating project...");
1026
- await createProject({
1027
- project: projectConfig,
1028
- database: databaseConfig,
1029
- storage: storageConfig,
1030
- payment: paymentConfig,
1031
- devenv: devEnvConfig,
1032
- skipGit: _options.skipGit,
1033
- skipInstall: _options.skipInstall
1118
+ }
1119
+ await execa4(
1120
+ "initdb",
1121
+ ["--locale=C.UTF-8", "--encoding=UTF8", "-D", pgdata, "--username=postgres"],
1122
+ {
1123
+ env,
1124
+ stdio: "inherit"
1125
+ }
1126
+ );
1127
+ await writeLocalDbConfigs(pgdata);
1128
+ logger7.success(`PostgreSQL initialized at ${pgdata}`);
1129
+ }
1130
+ async function runDbStartCommand() {
1131
+ const root = getWorkspaceRootOrThrow();
1132
+ const env = buildDbEnv(root);
1133
+ const pgdata = getPgDataOrThrow(env);
1134
+ await requireCommand("pg_ctl");
1135
+ await fs8.access(pgdata);
1136
+ await execa4(
1137
+ "pg_ctl",
1138
+ ["start", "-D", pgdata, "-l", path8.join(pgdata, "logfile"), "-o", `-k ${pgdata}`],
1139
+ {
1140
+ env,
1141
+ stdio: "inherit"
1142
+ }
1143
+ );
1144
+ }
1145
+ async function runDbStopCommand() {
1146
+ const root = getWorkspaceRootOrThrow();
1147
+ const env = buildDbEnv(root);
1148
+ const pgdata = getPgDataOrThrow(env);
1149
+ await requireCommand("pg_ctl");
1150
+ await execa4("pg_ctl", ["stop", "-D", pgdata], {
1151
+ env,
1152
+ stdio: "inherit"
1153
+ });
1154
+ }
1155
+ async function runDbStatusCommand() {
1156
+ const root = getWorkspaceRootOrThrow();
1157
+ const env = buildDbEnv(root);
1158
+ const pgdata = getPgDataOrThrow(env);
1159
+ await requireCommand("pg_ctl");
1160
+ try {
1161
+ await execa4("pg_ctl", ["status", "-D", pgdata], {
1162
+ env,
1163
+ stdio: "inherit"
1034
1164
  });
1035
- logger7.success("Project created successfully");
1036
- logger7.info("[8/8] Next steps");
1037
- logger7.divider();
1038
- logger7.info(`cd ${projectConfig.projectName}`);
1039
- logger7.info("pnpm install");
1040
- logger7.info("pnpm dev");
1041
- logger7.divider();
1042
- logger7.success(`\u{1F389} Project ${projectConfig.projectName} created successfully!`);
1043
1165
  } catch (error) {
1044
- if (error instanceof Error) {
1045
- logger7.error(`Failed to create project: ${error.message}`);
1166
+ if (isPgCtlNotRunningError(error)) {
1167
+ logger7.warn(`PostgreSQL is not running (PGDATA: ${pgdata})`);
1168
+ return;
1169
+ }
1170
+ throw error;
1171
+ }
1172
+ }
1173
+ async function runDbResetCommand(options = {}) {
1174
+ if (!options.force) {
1175
+ throw new Error("db reset is destructive. Re-run with --force.");
1176
+ }
1177
+ const root = getWorkspaceRootOrThrow();
1178
+ const env = buildDbEnv(root);
1179
+ const pgdata = getPgDataOrThrow(env);
1180
+ if (await commandExists("pg_ctl")) {
1181
+ try {
1182
+ await execa4("pg_ctl", ["stop", "-D", pgdata], { env, stdio: "pipe" });
1183
+ } catch {
1184
+ }
1185
+ }
1186
+ await fs8.rm(pgdata, { recursive: true, force: true });
1187
+ await runDbInitCommand({ force: false });
1188
+ }
1189
+ async function runDbMigrateCommand() {
1190
+ const root = getWorkspaceRootOrThrow();
1191
+ const env = buildDbEnv(root);
1192
+ await execa4("pnpm", ["--filter", "@revealui/db", "db:migrate"], {
1193
+ cwd: root,
1194
+ env,
1195
+ stdio: "inherit"
1196
+ });
1197
+ }
1198
+ async function runDbCleanupCommand(options = {}) {
1199
+ const root = getWorkspaceRootOrThrow();
1200
+ const env = { ...process.env };
1201
+ if (options.dryRun) env.DRY_RUN = "true";
1202
+ if (options.tables) env.TABLES = options.tables;
1203
+ await execa4("pnpm", ["--filter", "@revealui/db", "db:cleanup"], {
1204
+ cwd: root,
1205
+ env,
1206
+ stdio: "inherit"
1207
+ });
1208
+ }
1209
+
1210
+ // src/commands/dev.ts
1211
+ import { createLogger as createLogger10 } from "@revealui/setup/utils";
1212
+ import { execa as execa6 } from "execa";
1213
+
1214
+ // src/runtime/doctor.ts
1215
+ function getMcpDetail(env) {
1216
+ const configuredKeys = [
1217
+ env.VERCEL_API_KEY ? "vercel" : null,
1218
+ env.STRIPE_SECRET_KEY ? "stripe" : null
1219
+ ].filter((value) => value !== null);
1220
+ if (configuredKeys.length === 0) {
1221
+ return {
1222
+ ok: false,
1223
+ detail: "mcp credentials missing (set VERCEL_API_KEY and/or STRIPE_SECRET_KEY)"
1224
+ };
1225
+ }
1226
+ return {
1227
+ ok: true,
1228
+ detail: `mcp credentials configured for ${configuredKeys.join(", ")}`
1229
+ };
1230
+ }
1231
+ async function gatherDoctorReport(cwd = process.cwd(), env = process.env) {
1232
+ const workspaceRoot = findWorkspaceRoot(cwd);
1233
+ const dbConfig = resolveLocalDbConfig(workspaceRoot ?? cwd, env);
1234
+ const dbTarget = detectDbTarget(env.POSTGRES_URL || env.DATABASE_URL);
1235
+ const nodeOk = validateNodeVersion();
1236
+ const pnpmOk = await commandExists("pnpm");
1237
+ const nixOk = await commandExists("nix");
1238
+ const direnvActive = Boolean(env.DIRENV_FILE || env.DIRENV_DIR);
1239
+ const pgCtlOk = await commandExists("pg_ctl");
1240
+ const initdbOk = await commandExists("initdb");
1241
+ const dockerOk = await commandExists("docker");
1242
+ const postgresReachable = dbTarget === "local" ? await isTcpReachable("127.0.0.1", 5432, 1e3) : false;
1243
+ const mcp = getMcpDetail(env);
1244
+ return {
1245
+ workspaceRoot,
1246
+ dbTarget,
1247
+ checks: [
1248
+ {
1249
+ id: "workspace",
1250
+ ok: workspaceRoot !== null,
1251
+ detail: workspaceRoot ?? "RevealUI workspace root not found"
1252
+ },
1253
+ {
1254
+ id: "node",
1255
+ ok: nodeOk,
1256
+ detail: process.version
1257
+ },
1258
+ {
1259
+ id: "pnpm",
1260
+ ok: pnpmOk,
1261
+ detail: pnpmOk ? "pnpm available" : "pnpm not found"
1262
+ },
1263
+ {
1264
+ id: "nix",
1265
+ ok: nixOk,
1266
+ detail: nixOk ? "nix available" : "nix not found"
1267
+ },
1268
+ {
1269
+ id: "direnv",
1270
+ ok: direnvActive,
1271
+ detail: direnvActive ? "direnv active" : "direnv not active"
1272
+ },
1273
+ {
1274
+ id: "db-target",
1275
+ ok: dbTarget !== "missing",
1276
+ detail: dbTarget === "missing" ? "No POSTGRES_URL or DATABASE_URL configured" : `${dbTarget} database target (${dbConfig.postgresUrl})`
1277
+ },
1278
+ {
1279
+ id: "pg_ctl",
1280
+ ok: pgCtlOk,
1281
+ detail: pgCtlOk ? "pg_ctl available" : "pg_ctl not found"
1282
+ },
1283
+ {
1284
+ id: "initdb",
1285
+ ok: initdbOk,
1286
+ detail: initdbOk ? "initdb available" : "initdb not found"
1287
+ },
1288
+ {
1289
+ id: "postgres",
1290
+ ok: dbTarget === "local" ? postgresReachable : true,
1291
+ detail: dbTarget === "local" ? postgresReachable ? "local postgres reachable on 127.0.0.1:5432" : "local postgres not reachable on 127.0.0.1:5432" : "postgres reachability skipped for non-local target"
1292
+ },
1293
+ {
1294
+ id: "docker",
1295
+ ok: dockerOk,
1296
+ detail: dockerOk ? "docker available" : "docker not found"
1297
+ },
1298
+ {
1299
+ id: "mcp",
1300
+ ok: mcp.ok,
1301
+ detail: mcp.detail
1302
+ }
1303
+ ]
1304
+ };
1305
+ }
1306
+ function formatDoctorReport(report) {
1307
+ const lines = ["", `RevealUI \xB7 ${report.workspaceRoot ?? "workspace not found"}`, ""];
1308
+ for (const check of report.checks) {
1309
+ lines.push(`${check.ok ? "OK" : "NO"} ${check.id.padEnd(10)} ${check.detail}`);
1310
+ }
1311
+ return lines.join("\n");
1312
+ }
1313
+
1314
+ // src/utils/dev-config.ts
1315
+ import fs9 from "fs";
1316
+ import path9 from "path";
1317
+ function getDevConfigPath(startDir = process.cwd()) {
1318
+ const workspaceRoot = findWorkspaceRoot(startDir);
1319
+ if (!workspaceRoot) {
1320
+ return null;
1321
+ }
1322
+ return path9.join(workspaceRoot, ".revealui", "dev.json");
1323
+ }
1324
+ function readDevConfig(startDir = process.cwd()) {
1325
+ const configPath = getDevConfigPath(startDir);
1326
+ if (!(configPath && fs9.existsSync(configPath))) {
1327
+ return {};
1328
+ }
1329
+ try {
1330
+ return JSON.parse(fs9.readFileSync(configPath, "utf8"));
1331
+ } catch {
1332
+ return {};
1333
+ }
1334
+ }
1335
+ function writeDevConfig(config, startDir = process.cwd()) {
1336
+ const configPath = getDevConfigPath(startDir);
1337
+ if (!configPath) {
1338
+ throw new Error("RevealUI workspace root not found");
1339
+ }
1340
+ fs9.mkdirSync(path9.dirname(configPath), { recursive: true });
1341
+ fs9.writeFileSync(`${configPath}`, `${JSON.stringify(config, null, 2)}
1342
+ `, "utf8");
1343
+ return configPath;
1344
+ }
1345
+
1346
+ // src/commands/doctor.ts
1347
+ import { createLogger as createLogger8 } from "@revealui/setup/utils";
1348
+ var logger8 = createLogger8({ prefix: "Doctor" });
1349
+ function getDoctorFixPlan(report) {
1350
+ const attempted = [];
1351
+ const skipped = [];
1352
+ const postgresCheck = report.checks.find((check) => check.id === "postgres");
1353
+ const initdbCheck = report.checks.find((check) => check.id === "initdb");
1354
+ const pgCtlCheck = report.checks.find((check) => check.id === "pg_ctl");
1355
+ const mcpCheck = report.checks.find((check) => check.id === "mcp");
1356
+ if (report.dbTarget === "local" && postgresCheck && !postgresCheck.ok) {
1357
+ if (initdbCheck?.ok && pgCtlCheck?.ok) {
1358
+ attempted.push("initialize/start local postgres");
1046
1359
  } else {
1047
- logger7.error("An unexpected error occurred");
1360
+ skipped.push("local postgres repair requires both initdb and pg_ctl in PATH");
1361
+ }
1362
+ }
1363
+ if (mcpCheck && !mcpCheck.ok) {
1364
+ skipped.push("MCP readiness requires credentials and cannot be auto-fixed safely");
1365
+ }
1366
+ if (attempted.length === 0 && skipped.length === 0) {
1367
+ skipped.push("no safe automatic fixes available");
1368
+ }
1369
+ return { attempted, skipped };
1370
+ }
1371
+ async function applyDoctorFixes(report) {
1372
+ const plan = getDoctorFixPlan(report);
1373
+ if (plan.attempted.includes("initialize/start local postgres")) {
1374
+ try {
1375
+ await runDbInitCommand();
1376
+ } catch {
1377
+ }
1378
+ await runDbStartCommand();
1379
+ }
1380
+ return plan;
1381
+ }
1382
+ function formatDoctorFixPlan(plan) {
1383
+ const lines = ["", "RevealUI Doctor Fix Plan", ""];
1384
+ for (const action of plan.attempted) {
1385
+ lines.push(`fix ${action}`);
1386
+ }
1387
+ for (const action of plan.skipped) {
1388
+ lines.push(`skip ${action}`);
1389
+ }
1390
+ return lines.join("\n");
1391
+ }
1392
+ async function runDoctorCommand(options = {}) {
1393
+ let report = await gatherDoctorReport();
1394
+ const fixPlan = getDoctorFixPlan(report);
1395
+ if (options.json) {
1396
+ process.stdout.write(`${JSON.stringify({ report, fixPlan }, null, 2)}
1397
+ `);
1398
+ return;
1399
+ }
1400
+ process.stdout.write(`${formatDoctorReport(report)}
1401
+ `);
1402
+ process.stdout.write(`${formatDoctorFixPlan(fixPlan)}
1403
+ `);
1404
+ if (options.fix) {
1405
+ if (fixPlan.attempted.length === 0) {
1406
+ logger8.warn("No safe automatic fixes available");
1407
+ } else {
1408
+ await applyDoctorFixes(report);
1409
+ report = await gatherDoctorReport();
1410
+ process.stdout.write(`${formatDoctorReport(report)}
1411
+ `);
1412
+ }
1413
+ }
1414
+ if (report.checks.some((check) => !check.ok)) {
1415
+ logger8.warn("Some checks failed");
1416
+ if (options.strict || options.json || process.env.CI) {
1417
+ process.exitCode = 1;
1048
1418
  }
1049
- process.exit(1);
1050
1419
  }
1051
1420
  }
1052
- var logger7, PRO_TEMPLATES;
1053
- var init_index = __esm({
1054
- "src/index.ts"() {
1055
- init_esm_shims();
1056
- init_cli();
1057
- init_node_version();
1058
- init_create();
1059
- init_database();
1060
- init_devenv();
1061
- init_payments();
1062
- init_project();
1063
- init_storage();
1064
- logger7 = createLogger7({ prefix: "@revealui/cli" });
1065
- PRO_TEMPLATES = /* @__PURE__ */ new Set(["e-commerce", "portfolio"]);
1066
- if (import.meta.url === `file://${process.argv[1]}`) {
1067
- const cli = createCli();
1068
- cli.parse(process.argv);
1421
+
1422
+ // src/commands/shell.ts
1423
+ import { createLogger as createLogger9 } from "@revealui/setup/utils";
1424
+ import { execa as execa5 } from "execa";
1425
+ var logger9 = createLogger9({ prefix: "Shell" });
1426
+ async function runShellCommand(options = {}) {
1427
+ if (!(options.inside || process.env.IN_NIX_SHELL) && await commandExists("nix")) {
1428
+ const workspaceRoot = findWorkspaceRoot();
1429
+ if (workspaceRoot) {
1430
+ const reentryArgs = options.ensure ? ["dev", "up"] : ["dev", "status"];
1431
+ await execa5(
1432
+ "nix",
1433
+ [
1434
+ "develop",
1435
+ "-c",
1436
+ "node",
1437
+ "packages/cli/bin/revealui.js",
1438
+ ...reentryArgs,
1439
+ ...options.forwardArgs ?? [],
1440
+ "--inside",
1441
+ ...options.json ? ["--json"] : []
1442
+ ],
1443
+ {
1444
+ cwd: workspaceRoot,
1445
+ stdio: "inherit"
1446
+ }
1447
+ );
1448
+ return true;
1449
+ }
1450
+ }
1451
+ const report = await gatherDoctorReport();
1452
+ if (options.ensure && report.dbTarget === "local" && await commandExists("pg_ctl")) {
1453
+ const postgresCheck = report.checks.find((check) => check.id === "postgres");
1454
+ if (postgresCheck && !postgresCheck.ok) {
1455
+ try {
1456
+ await runDbInitCommand();
1457
+ } catch {
1458
+ }
1459
+ await runDbStartCommand();
1069
1460
  }
1070
1461
  }
1071
- });
1072
- init_index();
1073
- export {
1074
- run
1462
+ const freshReport = await gatherDoctorReport();
1463
+ if (options.json) {
1464
+ process.stdout.write(`${JSON.stringify(freshReport, null, 2)}
1465
+ `);
1466
+ return false;
1467
+ }
1468
+ process.stdout.write(`${formatDoctorReport(freshReport)}
1469
+ `);
1470
+ logger9.info("Use `revealui doctor --json` for machine-readable status.");
1471
+ return false;
1472
+ }
1473
+
1474
+ // src/commands/dev.ts
1475
+ var logger10 = createLogger10({ prefix: "Dev" });
1476
+ var DEV_PROFILES = {
1477
+ local: {},
1478
+ agent: {
1479
+ include: ["mcp"]
1480
+ },
1481
+ cms: {
1482
+ script: "dev:cms"
1483
+ },
1484
+ fullstack: {
1485
+ include: ["mcp"],
1486
+ script: "dev"
1487
+ }
1075
1488
  };
1489
+ function getConfiguredProfile() {
1490
+ const configured = readDevConfig().defaultProfile;
1491
+ if (configured && configured in DEV_PROFILES) {
1492
+ return configured;
1493
+ }
1494
+ return void 0;
1495
+ }
1496
+ function resolveDevUpOptions(options = {}) {
1497
+ const selectedProfile = options.profile ?? getConfiguredProfile();
1498
+ const profile = selectedProfile ? DEV_PROFILES[selectedProfile] : void 0;
1499
+ if (selectedProfile && !profile) {
1500
+ throw new Error(
1501
+ `Unknown dev profile "${selectedProfile}". Use one of: ${Object.keys(DEV_PROFILES).join(", ")}`
1502
+ );
1503
+ }
1504
+ const include = Array.from(
1505
+ /* @__PURE__ */ new Set([...profile?.include ?? [], ...options.include ?? []])
1506
+ );
1507
+ return {
1508
+ ensure: options.ensure ?? true,
1509
+ json: options.json ?? false,
1510
+ inside: options.inside ?? false,
1511
+ profile: selectedProfile,
1512
+ script: options.script ?? profile?.script,
1513
+ include
1514
+ };
1515
+ }
1516
+ function getDevPlan(options = {}) {
1517
+ const resolved = resolveDevUpOptions(options);
1518
+ return {
1519
+ profile: resolved.profile ?? (options.include?.length || options.script ? "custom" : "local"),
1520
+ ensure: resolved.ensure,
1521
+ include: resolved.include,
1522
+ script: resolved.script,
1523
+ dryRun: options.dryRun ?? false
1524
+ };
1525
+ }
1526
+ function formatDevPlan(plan) {
1527
+ const lines = ["", "RevealUI Dev Plan", ""];
1528
+ lines.push(`profile ${plan.profile}`);
1529
+ lines.push(`ensure ${plan.ensure ? "yes" : "no"}`);
1530
+ lines.push(`dry-run ${plan.dryRun ? "yes" : "no"}`);
1531
+ lines.push(`include ${plan.include.length > 0 ? plan.include.join(", ") : "none"}`);
1532
+ lines.push(`script ${plan.script ?? "none"}`);
1533
+ return lines.join("\n");
1534
+ }
1535
+ function getDevActions(plan) {
1536
+ const actions = [];
1537
+ if (plan.ensure) {
1538
+ actions.push("ensure local shell and database prerequisites");
1539
+ } else {
1540
+ actions.push("skip automatic shell/database ensure");
1541
+ }
1542
+ actions.push("run database migrations");
1543
+ if (shouldIncludeMcp(plan.include)) {
1544
+ actions.push("validate MCP credentials via `pnpm setup:mcp`");
1545
+ }
1546
+ if (plan.script) {
1547
+ actions.push(`start pnpm script \`${plan.script}\``);
1548
+ }
1549
+ return actions;
1550
+ }
1551
+ function formatDevActions(plan) {
1552
+ const actions = getDevActions(plan);
1553
+ const lines = ["", "RevealUI Dev Actions", ""];
1554
+ for (const action of actions) {
1555
+ lines.push(`- ${action}`);
1556
+ }
1557
+ return lines.join("\n");
1558
+ }
1559
+ function shouldIncludeMcp(include) {
1560
+ return include.includes("mcp");
1561
+ }
1562
+ async function runDevUpCommand(options = {}) {
1563
+ const resolved = resolveDevUpOptions(options);
1564
+ const plan = getDevPlan(options);
1565
+ const forwardArgs = [];
1566
+ if (options.dryRun) {
1567
+ forwardArgs.push("--dry-run");
1568
+ }
1569
+ if (options.fix) {
1570
+ forwardArgs.push("--fix");
1571
+ }
1572
+ if (options.profile) {
1573
+ forwardArgs.push("--profile", options.profile);
1574
+ }
1575
+ for (const service of options.include ?? []) {
1576
+ forwardArgs.push("--include", service);
1577
+ }
1578
+ if (options.script) {
1579
+ forwardArgs.push("--script", options.script);
1580
+ }
1581
+ if (options.ensure === false) {
1582
+ forwardArgs.push("--no-ensure");
1583
+ }
1584
+ const reentered = await runShellCommand({
1585
+ ensure: resolved.ensure,
1586
+ json: resolved.json,
1587
+ inside: resolved.inside,
1588
+ forwardArgs
1589
+ });
1590
+ if (reentered) {
1591
+ return;
1592
+ }
1593
+ if (resolved.json) {
1594
+ return;
1595
+ }
1596
+ process.stdout.write(`${formatDevPlan(plan)}
1597
+ `);
1598
+ process.stdout.write(`${formatDevActions(plan)}
1599
+ `);
1600
+ if (plan.dryRun) {
1601
+ logger10.info("Dry run only; no migrations or services were started.");
1602
+ return;
1603
+ }
1604
+ if (options.fix) {
1605
+ await runDoctorCommand({ fix: true });
1606
+ }
1607
+ await runDbMigrateCommand();
1608
+ logger10.success("Database migration complete");
1609
+ if (shouldIncludeMcp(resolved.include)) {
1610
+ const workspaceRoot = findWorkspaceRoot();
1611
+ if (!workspaceRoot) {
1612
+ throw new Error("RevealUI workspace root not found");
1613
+ }
1614
+ logger10.info("Validating MCP setup");
1615
+ await execa6("pnpm", ["setup:mcp"], {
1616
+ cwd: workspaceRoot,
1617
+ stdio: "inherit"
1618
+ });
1619
+ }
1620
+ if (resolved.script) {
1621
+ const workspaceRoot = findWorkspaceRoot();
1622
+ if (!workspaceRoot) {
1623
+ throw new Error("RevealUI workspace root not found");
1624
+ }
1625
+ logger10.info(`Starting dev script: ${resolved.script}`);
1626
+ await execa6("pnpm", [resolved.script], {
1627
+ cwd: workspaceRoot,
1628
+ stdio: "inherit"
1629
+ });
1630
+ }
1631
+ }
1632
+ async function runDevStatusCommand(options = {}) {
1633
+ const plan = getDevPlan(options);
1634
+ const forwardArgs = [];
1635
+ if (options.profile) {
1636
+ forwardArgs.push("--profile", options.profile);
1637
+ }
1638
+ for (const service of options.include ?? []) {
1639
+ forwardArgs.push("--include", service);
1640
+ }
1641
+ if (options.script) {
1642
+ forwardArgs.push("--script", options.script);
1643
+ }
1644
+ if (options.ensure === false) {
1645
+ forwardArgs.push("--no-ensure");
1646
+ }
1647
+ if (!(options.inside || process.env.IN_NIX_SHELL) && await commandExists("nix")) {
1648
+ const reentered = await runShellCommand({
1649
+ ensure: false,
1650
+ json: options.json,
1651
+ inside: options.inside,
1652
+ forwardArgs
1653
+ });
1654
+ if (reentered) {
1655
+ return;
1656
+ }
1657
+ }
1658
+ const report = await gatherDoctorReport();
1659
+ if (options.json) {
1660
+ process.stdout.write(
1661
+ `${JSON.stringify({ report, plan, actions: getDevActions(plan) }, null, 2)}
1662
+ `
1663
+ );
1664
+ return;
1665
+ }
1666
+ process.stdout.write(`${formatDoctorReport(report)}
1667
+ `);
1668
+ process.stdout.write(`${formatDevPlan(plan)}
1669
+ `);
1670
+ process.stdout.write(`${formatDevActions(plan)}
1671
+ `);
1672
+ }
1673
+ async function runDevDownCommand() {
1674
+ await runDbStopCommand();
1675
+ }
1676
+ async function runDevProfileSetCommand(profile) {
1677
+ if (!(profile in DEV_PROFILES)) {
1678
+ throw new Error(
1679
+ `Unknown dev profile "${profile}". Use one of: ${Object.keys(DEV_PROFILES).join(", ")}`
1680
+ );
1681
+ }
1682
+ const configPath = writeDevConfig({ defaultProfile: profile });
1683
+ logger10.success(`Default dev profile set to "${profile}" in ${configPath}`);
1684
+ }
1685
+ async function runDevProfileShowCommand(options = {}) {
1686
+ const configuredProfile = getConfiguredProfile() ?? null;
1687
+ if (options.json) {
1688
+ process.stdout.write(`${JSON.stringify({ defaultProfile: configuredProfile }, null, 2)}
1689
+ `);
1690
+ return;
1691
+ }
1692
+ process.stdout.write(`Default dev profile: ${configuredProfile ?? "not set"}
1693
+ `);
1694
+ }
1695
+
1696
+ // src/cli.ts
1697
+ var logger11 = createLogger11({ prefix: "CLI" });
1698
+ function configureCreateCommand(command, legacyName) {
1699
+ command.description("Create a new RevealUI project").argument("[project-name]", "Name of the project").option("-t, --template <name>", "Template to use (basic-blog, e-commerce, portfolio)").option("--skip-git", "Skip git initialization", false).option("--skip-install", "Skip dependency installation", false).option("-y, --yes", "Skip all prompts and use defaults", false).action(async (projectName, options) => {
1700
+ logger11.header(legacyName ? "Create RevealUI Project" : "RevealUI Create");
1701
+ await runCreateFlow(projectName, options);
1702
+ });
1703
+ return command;
1704
+ }
1705
+ function createCli() {
1706
+ const program = new Command();
1707
+ program.name("revealui").description("RevealUI operational CLI").version("0.2.0");
1708
+ configureCreateCommand(program.command("create"), void 0);
1709
+ program.command("doctor").description("Check RevealUI workspace and developer environment health").option("--json", "Output machine-readable JSON", false).option("--fix", "Apply safe automatic fixes when possible", false).option("--strict", "Exit nonzero when checks fail", false).action(async (options) => {
1710
+ await runDoctorCommand(options);
1711
+ });
1712
+ const db = program.command("db").description("Manage the local RevealUI database");
1713
+ db.command("init").description("Initialize the local PostgreSQL data directory").option("--force", "Delete and recreate the local data directory", false).action(async (options) => {
1714
+ await runDbInitCommand(options);
1715
+ });
1716
+ db.command("start").description("Start the local PostgreSQL server").action(async () => {
1717
+ await runDbStartCommand();
1718
+ });
1719
+ db.command("stop").description("Stop the local PostgreSQL server").action(async () => {
1720
+ await runDbStopCommand();
1721
+ });
1722
+ db.command("status").description("Show local PostgreSQL status").action(async () => {
1723
+ await runDbStatusCommand();
1724
+ });
1725
+ db.command("reset").description("Reset the local PostgreSQL data directory").option("--force", "Confirm the destructive reset", false).action(async (options) => {
1726
+ await runDbResetCommand(options);
1727
+ });
1728
+ db.command("migrate").description("Run Drizzle migrations using the local RevealUI database environment").action(async () => {
1729
+ await runDbMigrateCommand();
1730
+ });
1731
+ db.command("cleanup").description(
1732
+ "Delete expired sessions, rate-limit rows, password-reset tokens, magic links, and publish due scheduled pages. Uses DATABASE_URL / POSTGRES_URL from the environment."
1733
+ ).option("--dry-run", "Count stale rows without deleting them", false).option(
1734
+ "--tables <names>",
1735
+ "Comma-separated subset: sessions,rateLimits,passwordResetTokens,magicLinks,scheduledPages"
1736
+ ).action(async (options) => {
1737
+ await runDbCleanupCommand(options);
1738
+ });
1739
+ const dev = program.command("dev").description("Prepare and manage the RevealUI development workspace");
1740
+ dev.command("up").description(
1741
+ "Ensure the local dev environment is ready, migrate the DB, optionally validate MCP, and start a dev script"
1742
+ ).option("--json", "Output machine-readable JSON", false).option("--dry-run", "Print the effective plan and actions without executing them", false).option("--fix", "Apply safe automatic fixes before bootstrapping when possible", false).option("--no-ensure", "Skip automatic local DB initialization/start").option("--profile <name>", "Named dev profile: local, agent, cms, fullstack").option(
1743
+ "--include <service...>",
1744
+ "Additional development services to prepare (currently supports: mcp)"
1745
+ ).option("--script <name>", "Optional pnpm script to run after environment bootstrap").option("--inside", "Internal flag used after re-entering nix develop", false).action(
1746
+ async (options) => {
1747
+ await runDevUpCommand(options);
1748
+ }
1749
+ );
1750
+ dev.command("status").description("Show current RevealUI development environment status").option("--json", "Output machine-readable JSON", false).option("--profile <name>", "Named dev profile: local, agent, cms, fullstack").option(
1751
+ "--include <service...>",
1752
+ "Additional development services to preview in the effective plan"
1753
+ ).option("--script <name>", "Optional pnpm script to preview in the effective plan").option("--inside", "Internal flag used after re-entering nix develop", false).action(
1754
+ async (options) => {
1755
+ await runDevStatusCommand(options);
1756
+ }
1757
+ );
1758
+ dev.command("down").description("Stop local RevealUI development services that are managed by the CLI").action(async () => {
1759
+ await runDevDownCommand();
1760
+ });
1761
+ dev.command("shell").description("Alias for `revealui dev up` without starting an app script").option("--json", "Output machine-readable JSON", false).option("--dry-run", "Print the effective plan and actions without executing them", false).option("--fix", "Apply safe automatic fixes before bootstrapping when possible", false).option("--no-ensure", "Skip automatic local DB initialization/start").option("--profile <name>", "Named dev profile: local, agent, cms, fullstack").option(
1762
+ "--include <service...>",
1763
+ "Additional development services to prepare (currently supports: mcp)"
1764
+ ).option("--inside", "Internal flag used after re-entering nix develop", false).action(
1765
+ async (options) => {
1766
+ await runDevUpCommand({
1767
+ ensure: options.ensure,
1768
+ json: options.json,
1769
+ dryRun: options.dryRun,
1770
+ fix: options.fix,
1771
+ profile: options.profile,
1772
+ include: options.include,
1773
+ inside: options.inside
1774
+ });
1775
+ }
1776
+ );
1777
+ const devProfile = dev.command("profile").description("Persist or inspect the default dev profile");
1778
+ devProfile.command("set").description("Set the default profile used by `revealui dev up` and `revealui dev status`").argument("<name>", "Profile name: local, agent, cms, fullstack").action(async (name) => {
1779
+ await runDevProfileSetCommand(name);
1780
+ });
1781
+ devProfile.command("show").description("Show the configured default dev profile").option("--json", "Output machine-readable JSON", false).action(async (options) => {
1782
+ await runDevProfileShowCommand(options);
1783
+ });
1784
+ program.command("shell").description("Deprecated alias for `revealui dev shell`").option("--ensure", "Initialize/start the local DB when possible", false).option("--json", "Output machine-readable JSON", false).option("--inside", "Internal flag used after re-entering nix develop", false).action(async (options) => {
1785
+ await runDevUpCommand({
1786
+ ensure: options.ensure,
1787
+ json: options.json,
1788
+ inside: options.inside
1789
+ });
1790
+ });
1791
+ return program;
1792
+ }
1793
+
1794
+ // src/index.ts
1795
+ if (import.meta.url === `file://${process.argv[1]}`) {
1796
+ const cli = createCli();
1797
+ cli.parse(process.argv);
1798
+ }
1076
1799
  //# sourceMappingURL=index.js.map