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