@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.
- package/README.md +114 -6
- package/bin/create-revealui.js +3 -3
- package/bin/revealui.js +6 -0
- package/dist/cli.d.ts +3 -1
- package/dist/cli.js +1399 -673
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +0 -10
- package/dist/index.js +1380 -657
- package/dist/index.js.map +1 -1
- package/package.json +15 -6
- package/templates/{minimal → basic-blog}/package.json +8 -6
- 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/{minimal → basic-blog}/src/app/layout.tsx +4 -4
- 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/{minimal → basic-blog}/tsconfig.json +1 -1
- 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/{minimal → starter}/revealui.config.ts +4 -4
- 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/templates/minimal/src/app/globals.css +0 -15
- package/templates/minimal/src/app/page.tsx +0 -20
- /package/templates/{minimal → basic-blog}/.env.example +0 -0
- /package/templates/{minimal → basic-blog}/_gitignore +0 -0
- /package/templates/{minimal → basic-blog}/next.config.mjs +0 -0
package/dist/cli.js
CHANGED
|
@@ -1,141 +1,455 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
|
-
};
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
1
|
+
// src/cli.ts
|
|
2
|
+
import { createLogger as createLogger11 } from "@revealui/setup/utils";
|
|
3
|
+
import { Command } from "commander";
|
|
10
4
|
|
|
11
|
-
//
|
|
12
|
-
import
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
});
|
|
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";
|
|
19
11
|
|
|
20
|
-
// src/
|
|
12
|
+
// src/prompts/database.ts
|
|
13
|
+
import inquirer from "inquirer";
|
|
14
|
+
|
|
15
|
+
// src/validators/credentials.ts
|
|
21
16
|
import { createLogger } from "@revealui/setup/utils";
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
);
|
|
30
|
-
logger.info("Please upgrade Node.js: https://nodejs.org/");
|
|
31
|
-
return false;
|
|
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
|
+
};
|
|
32
24
|
}
|
|
33
|
-
return true;
|
|
25
|
+
return { valid: true };
|
|
34
26
|
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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
|
+
};
|
|
42
65
|
}
|
|
43
|
-
}
|
|
66
|
+
}
|
|
44
67
|
|
|
45
|
-
// src/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
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
|
+
}
|
|
56
92
|
],
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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";
|
|
61
125
|
}
|
|
62
|
-
},
|
|
63
|
-
env: {
|
|
64
|
-
NODE_ENV: "development"
|
|
65
126
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
path2.join(projectPath, "devbox.json"),
|
|
69
|
-
JSON.stringify(devboxConfig, null, 2),
|
|
70
|
-
"utf-8"
|
|
71
|
-
);
|
|
127
|
+
]);
|
|
128
|
+
return { provider, postgresUrl };
|
|
72
129
|
}
|
|
73
|
-
var init_devbox = __esm({
|
|
74
|
-
"src/generators/devbox.ts"() {
|
|
75
|
-
"use strict";
|
|
76
|
-
init_esm_shims();
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
130
|
|
|
80
|
-
// src/
|
|
81
|
-
import
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
features: {
|
|
90
|
-
"ghcr.io/devcontainers/features/common-utils:2": {
|
|
91
|
-
installZsh: true,
|
|
92
|
-
installOhMyZsh: true
|
|
93
|
-
}
|
|
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
|
|
94
140
|
},
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
"
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
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";
|
|
108
176
|
}
|
|
109
177
|
},
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
"
|
|
117
|
-
"Prisma.prisma",
|
|
118
|
-
"ms-azuretools.vscode-docker",
|
|
119
|
-
"streetsidesoftware.code-spell-checker"
|
|
120
|
-
],
|
|
121
|
-
settings: {
|
|
122
|
-
"editor.defaultFormatter": "biomejs.biome",
|
|
123
|
-
"editor.formatOnSave": true,
|
|
124
|
-
"editor.codeActionsOnSave": {
|
|
125
|
-
"quickfix.biome": "explicit",
|
|
126
|
-
"source.organizeImports.biome": "explicit"
|
|
127
|
-
}
|
|
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";
|
|
128
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;
|
|
129
190
|
}
|
|
130
191
|
},
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
);
|
|
138
|
-
|
|
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'
|
|
139
453
|
|
|
140
454
|
services:
|
|
141
455
|
app:
|
|
@@ -160,7 +474,7 @@ services:
|
|
|
160
474
|
volumes:
|
|
161
475
|
postgres-data:
|
|
162
476
|
`;
|
|
163
|
-
await
|
|
477
|
+
await fs3.writeFile(path3.join(devcontainerDir, "docker-compose.yml"), dockerCompose, "utf-8");
|
|
164
478
|
const dockerfile = `FROM mcr.microsoft.com/devcontainers/typescript-node:24
|
|
165
479
|
|
|
166
480
|
# Install additional tools
|
|
@@ -170,7 +484,7 @@ RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \\
|
|
|
170
484
|
# Enable pnpm
|
|
171
485
|
RUN corepack enable
|
|
172
486
|
`;
|
|
173
|
-
await
|
|
487
|
+
await fs3.writeFile(path3.join(devcontainerDir, "Dockerfile"), dockerfile, "utf-8");
|
|
174
488
|
const readme = `# Dev Container Setup
|
|
175
489
|
|
|
176
490
|
This directory contains the Dev Container configuration for RevealUI.
|
|
@@ -191,11 +505,10 @@ This directory contains the Dev Container configuration for RevealUI.
|
|
|
191
505
|
|
|
192
506
|
## What's Included
|
|
193
507
|
|
|
194
|
-
- Node.js 24.
|
|
508
|
+
- Node.js 24.13.0
|
|
195
509
|
- pnpm package manager
|
|
196
510
|
- PostgreSQL 16 with pgvector
|
|
197
511
|
- VS Code extensions:
|
|
198
|
-
- ESLint
|
|
199
512
|
- Biome
|
|
200
513
|
- Tailwind CSS
|
|
201
514
|
- Prisma
|
|
@@ -213,17 +526,11 @@ For GitHub Codespaces, set secrets in your repository settings.
|
|
|
213
526
|
- 4000: CMS
|
|
214
527
|
- 5432: PostgreSQL database
|
|
215
528
|
`;
|
|
216
|
-
await
|
|
529
|
+
await fs3.writeFile(path3.join(devcontainerDir, "README.md"), readme, "utf-8");
|
|
217
530
|
}
|
|
218
|
-
var init_devcontainer = __esm({
|
|
219
|
-
"src/generators/devcontainer.ts"() {
|
|
220
|
-
"use strict";
|
|
221
|
-
init_esm_shims();
|
|
222
|
-
}
|
|
223
|
-
});
|
|
224
531
|
|
|
225
532
|
// src/generators/readme.ts
|
|
226
|
-
import
|
|
533
|
+
import fs4 from "fs/promises";
|
|
227
534
|
import path4 from "path";
|
|
228
535
|
async function generateReadme(projectPath, projectConfig) {
|
|
229
536
|
const readme = `# ${projectConfig.projectName}
|
|
@@ -260,7 +567,7 @@ The web application runs on [http://localhost:3000](http://localhost:3000).
|
|
|
260
567
|
### Standard Setup
|
|
261
568
|
|
|
262
569
|
Requirements:
|
|
263
|
-
- Node.js 24.
|
|
570
|
+
- Node.js 24.13.0 or higher
|
|
264
571
|
- pnpm 10.28.2 or higher
|
|
265
572
|
- PostgreSQL 16
|
|
266
573
|
|
|
@@ -324,19 +631,14 @@ This project was created using the **${projectConfig.template}** template.
|
|
|
324
631
|
|
|
325
632
|
MIT
|
|
326
633
|
`;
|
|
327
|
-
await
|
|
634
|
+
await fs4.writeFile(path4.join(projectPath, "README.md"), readme, "utf-8");
|
|
328
635
|
}
|
|
329
|
-
var init_readme = __esm({
|
|
330
|
-
"src/generators/readme.ts"() {
|
|
331
|
-
"use strict";
|
|
332
|
-
init_esm_shims();
|
|
333
|
-
}
|
|
334
|
-
});
|
|
335
636
|
|
|
336
637
|
// src/installers/dependencies.ts
|
|
337
|
-
import { createLogger as
|
|
638
|
+
import { createLogger as createLogger3 } from "@revealui/setup/utils";
|
|
338
639
|
import { execa } from "execa";
|
|
339
640
|
import ora from "ora";
|
|
641
|
+
var logger3 = createLogger3({ prefix: "Install" });
|
|
340
642
|
async function installDependencies(projectPath) {
|
|
341
643
|
const spinner = ora("Installing dependencies with pnpm...").start();
|
|
342
644
|
try {
|
|
@@ -347,7 +649,7 @@ async function installDependencies(projectPath) {
|
|
|
347
649
|
spinner.succeed("Dependencies installed successfully");
|
|
348
650
|
} catch (error) {
|
|
349
651
|
spinner.fail("Failed to install dependencies");
|
|
350
|
-
|
|
652
|
+
logger3.error('Please run "pnpm install" manually');
|
|
351
653
|
throw error;
|
|
352
654
|
}
|
|
353
655
|
}
|
|
@@ -359,24 +661,17 @@ async function isPnpmInstalled() {
|
|
|
359
661
|
return false;
|
|
360
662
|
}
|
|
361
663
|
}
|
|
362
|
-
var logger2;
|
|
363
|
-
var init_dependencies = __esm({
|
|
364
|
-
"src/installers/dependencies.ts"() {
|
|
365
|
-
"use strict";
|
|
366
|
-
init_esm_shims();
|
|
367
|
-
logger2 = createLogger2({ prefix: "Install" });
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
664
|
|
|
371
665
|
// src/utils/git.ts
|
|
372
|
-
import { createLogger as
|
|
666
|
+
import { createLogger as createLogger4 } from "@revealui/setup/utils";
|
|
373
667
|
import { execa as execa2 } from "execa";
|
|
668
|
+
var logger4 = createLogger4({ prefix: "Git" });
|
|
374
669
|
async function initializeGitRepo(projectPath) {
|
|
375
670
|
try {
|
|
376
671
|
await execa2("git", ["init"], { cwd: projectPath });
|
|
377
|
-
|
|
672
|
+
logger4.success("Initialized git repository");
|
|
378
673
|
} catch (error) {
|
|
379
|
-
|
|
674
|
+
logger4.warn("Failed to initialize git repository");
|
|
380
675
|
throw error;
|
|
381
676
|
}
|
|
382
677
|
}
|
|
@@ -384,9 +679,9 @@ async function createInitialCommit(projectPath) {
|
|
|
384
679
|
try {
|
|
385
680
|
await execa2("git", ["add", "."], { cwd: projectPath });
|
|
386
681
|
await execa2("git", ["commit", "-m", "Initial commit from @revealui/cli"], { cwd: projectPath });
|
|
387
|
-
|
|
682
|
+
logger4.success("Created initial commit");
|
|
388
683
|
} catch (error) {
|
|
389
|
-
|
|
684
|
+
logger4.warn("Failed to create initial commit");
|
|
390
685
|
throw error;
|
|
391
686
|
}
|
|
392
687
|
}
|
|
@@ -398,22 +693,12 @@ async function isGitInstalled() {
|
|
|
398
693
|
return false;
|
|
399
694
|
}
|
|
400
695
|
}
|
|
401
|
-
var logger3;
|
|
402
|
-
var init_git = __esm({
|
|
403
|
-
"src/utils/git.ts"() {
|
|
404
|
-
"use strict";
|
|
405
|
-
init_esm_shims();
|
|
406
|
-
logger3 = createLogger3({ prefix: "Git" });
|
|
407
|
-
}
|
|
408
|
-
});
|
|
409
696
|
|
|
410
697
|
// src/commands/create.ts
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
import { createLogger as createLogger4 } from "@revealui/setup/utils";
|
|
416
|
-
import ora2 from "ora";
|
|
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");
|
|
417
702
|
function buildEnvLocal(cfg) {
|
|
418
703
|
const lines = [
|
|
419
704
|
"# Generated by @revealui/cli \u2014 fill in the remaining placeholders before running `pnpm dev`",
|
|
@@ -457,20 +742,28 @@ function buildEnvLocal(cfg) {
|
|
|
457
742
|
function generateSecret() {
|
|
458
743
|
return crypto.randomBytes(24).toString("hex");
|
|
459
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
|
+
}
|
|
460
753
|
async function copyTemplate(templateName, targetPath) {
|
|
461
754
|
const templatePath = path5.join(TEMPLATES_DIR, templateName);
|
|
462
755
|
try {
|
|
463
|
-
await
|
|
756
|
+
await fs5.access(templatePath);
|
|
464
757
|
} catch {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
);
|
|
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}`);
|
|
468
761
|
}
|
|
469
762
|
await copyDir(templatePath, targetPath);
|
|
470
763
|
}
|
|
471
764
|
async function copyDir(src, dest) {
|
|
472
|
-
await
|
|
473
|
-
const entries = await
|
|
765
|
+
await fs5.mkdir(dest, { recursive: true });
|
|
766
|
+
const entries = await fs5.readdir(src, { withFileTypes: true });
|
|
474
767
|
for (const entry of entries) {
|
|
475
768
|
const srcPath = path5.join(src, entry.name);
|
|
476
769
|
const destName = entry.name === "_gitignore" ? ".gitignore" : entry.name;
|
|
@@ -478,17 +771,17 @@ async function copyDir(src, dest) {
|
|
|
478
771
|
if (entry.isDirectory()) {
|
|
479
772
|
await copyDir(srcPath, destPath);
|
|
480
773
|
} else {
|
|
481
|
-
await
|
|
774
|
+
await fs5.copyFile(srcPath, destPath);
|
|
482
775
|
}
|
|
483
776
|
}
|
|
484
777
|
}
|
|
485
778
|
function resolveTemplateName(template) {
|
|
486
779
|
const map = {
|
|
487
|
-
"basic-blog": "
|
|
488
|
-
"e-commerce": "
|
|
489
|
-
portfolio: "
|
|
780
|
+
"basic-blog": "basic-blog",
|
|
781
|
+
"e-commerce": "e-commerce",
|
|
782
|
+
portfolio: "portfolio"
|
|
490
783
|
};
|
|
491
|
-
return map[template] ?? "
|
|
784
|
+
return map[template] ?? "starter";
|
|
492
785
|
}
|
|
493
786
|
async function createProject(cfg) {
|
|
494
787
|
const { project, skipGit = false, skipInstall = false } = cfg;
|
|
@@ -503,437 +796,57 @@ async function createProject(cfg) {
|
|
|
503
796
|
}
|
|
504
797
|
const pkgJsonPath = path5.join(projectPath, "package.json");
|
|
505
798
|
try {
|
|
506
|
-
const raw = await
|
|
507
|
-
await
|
|
799
|
+
const raw = await fs5.readFile(pkgJsonPath, "utf-8");
|
|
800
|
+
await fs5.writeFile(pkgJsonPath, raw.replaceAll("{{PROJECT_NAME}}", projectName), "utf-8");
|
|
508
801
|
} catch {
|
|
509
802
|
}
|
|
510
803
|
const envSpinner = ora2("Writing .env.local...").start();
|
|
511
804
|
try {
|
|
512
|
-
await
|
|
805
|
+
await fs5.writeFile(path5.join(projectPath, ".env.local"), buildEnvLocal(cfg), "utf-8");
|
|
513
806
|
envSpinner.succeed(".env.local written");
|
|
514
807
|
} catch (err) {
|
|
515
808
|
envSpinner.fail("Failed to write .env.local");
|
|
516
809
|
throw err;
|
|
517
810
|
}
|
|
518
811
|
await generateReadme(projectPath, project);
|
|
519
|
-
|
|
812
|
+
logger5.success("README.md generated");
|
|
520
813
|
if (cfg.devenv.createDevContainer) {
|
|
521
814
|
await generateDevContainer(projectPath);
|
|
522
|
-
|
|
815
|
+
logger5.success(".devcontainer/ generated");
|
|
523
816
|
}
|
|
524
817
|
if (cfg.devenv.createDevbox) {
|
|
525
818
|
await generateDevbox(projectPath);
|
|
526
|
-
|
|
819
|
+
logger5.success("devbox.json generated");
|
|
527
820
|
}
|
|
528
821
|
if (!skipInstall) {
|
|
529
822
|
const pnpmOk = await isPnpmInstalled();
|
|
530
823
|
if (!pnpmOk) {
|
|
531
|
-
|
|
824
|
+
logger5.warn(
|
|
825
|
+
"pnpm not found \u2014 skipping dependency installation. Run `pnpm install` manually."
|
|
826
|
+
);
|
|
532
827
|
} else {
|
|
533
828
|
await installDependencies(projectPath);
|
|
534
829
|
}
|
|
535
830
|
} else {
|
|
536
|
-
|
|
831
|
+
logger5.info("Skipping dependency installation (--skip-install)");
|
|
537
832
|
}
|
|
538
833
|
if (!skipGit) {
|
|
539
834
|
const gitOk = await isGitInstalled();
|
|
540
835
|
if (!gitOk) {
|
|
541
|
-
|
|
836
|
+
logger5.warn("git not found \u2014 skipping repository initialisation.");
|
|
542
837
|
} else {
|
|
543
838
|
await initializeGitRepo(projectPath);
|
|
544
839
|
await createInitialCommit(projectPath);
|
|
545
840
|
}
|
|
546
841
|
} else {
|
|
547
|
-
|
|
548
|
-
}
|
|
549
|
-
}
|
|
550
|
-
var logger4, __filename2, __dirname2, TEMPLATES_DIR;
|
|
551
|
-
var init_create = __esm({
|
|
552
|
-
"src/commands/create.ts"() {
|
|
553
|
-
"use strict";
|
|
554
|
-
init_esm_shims();
|
|
555
|
-
init_devbox();
|
|
556
|
-
init_devcontainer();
|
|
557
|
-
init_readme();
|
|
558
|
-
init_dependencies();
|
|
559
|
-
init_git();
|
|
560
|
-
logger4 = createLogger4({ prefix: "Create" });
|
|
561
|
-
__filename2 = fileURLToPath2(import.meta.url);
|
|
562
|
-
__dirname2 = path5.dirname(__filename2);
|
|
563
|
-
TEMPLATES_DIR = path5.resolve(__dirname2, "../../templates");
|
|
564
|
-
}
|
|
565
|
-
});
|
|
566
|
-
|
|
567
|
-
// src/validators/credentials.ts
|
|
568
|
-
import { createLogger as createLogger5 } from "@revealui/setup/utils";
|
|
569
|
-
async function validateStripeKey(key) {
|
|
570
|
-
if (!(key.startsWith("sk_test_") || key.startsWith("sk_live_"))) {
|
|
571
|
-
return {
|
|
572
|
-
valid: false,
|
|
573
|
-
message: "Stripe key must start with sk_test_ or sk_live_"
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
return { valid: true };
|
|
577
|
-
}
|
|
578
|
-
async function validateNeonUrl(url) {
|
|
579
|
-
try {
|
|
580
|
-
const parsed = new URL(url);
|
|
581
|
-
if (!parsed.protocol.startsWith("postgres")) {
|
|
582
|
-
return {
|
|
583
|
-
valid: false,
|
|
584
|
-
message: "Database URL must use postgres:// or postgresql:// protocol"
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
return { valid: true };
|
|
588
|
-
} catch {
|
|
589
|
-
return {
|
|
590
|
-
valid: false,
|
|
591
|
-
message: "Invalid database URL format"
|
|
592
|
-
};
|
|
593
|
-
}
|
|
594
|
-
}
|
|
595
|
-
async function validateVercelToken(token) {
|
|
596
|
-
if (!token || token.length < 20) {
|
|
597
|
-
return {
|
|
598
|
-
valid: false,
|
|
599
|
-
message: "Vercel token appears invalid (too short)"
|
|
600
|
-
};
|
|
601
|
-
}
|
|
602
|
-
return { valid: true };
|
|
603
|
-
}
|
|
604
|
-
async function validateSupabaseUrl(url) {
|
|
605
|
-
try {
|
|
606
|
-
const parsed = new URL(url);
|
|
607
|
-
if (!parsed.hostname.includes("supabase")) {
|
|
608
|
-
logger5.warn("URL does not appear to be a Supabase URL");
|
|
609
|
-
}
|
|
610
|
-
return { valid: true };
|
|
611
|
-
} catch {
|
|
612
|
-
return {
|
|
613
|
-
valid: false,
|
|
614
|
-
message: "Invalid Supabase URL format"
|
|
615
|
-
};
|
|
616
|
-
}
|
|
617
|
-
}
|
|
618
|
-
var logger5;
|
|
619
|
-
var init_credentials = __esm({
|
|
620
|
-
"src/validators/credentials.ts"() {
|
|
621
|
-
"use strict";
|
|
622
|
-
init_esm_shims();
|
|
623
|
-
logger5 = createLogger5({ prefix: "Validator" });
|
|
624
|
-
}
|
|
625
|
-
});
|
|
626
|
-
|
|
627
|
-
// src/prompts/database.ts
|
|
628
|
-
import inquirer from "inquirer";
|
|
629
|
-
async function promptDatabaseConfig() {
|
|
630
|
-
const { provider } = await inquirer.prompt([
|
|
631
|
-
{
|
|
632
|
-
type: "list",
|
|
633
|
-
name: "provider",
|
|
634
|
-
message: "Which database provider would you like to use?",
|
|
635
|
-
choices: [
|
|
636
|
-
{
|
|
637
|
-
name: "NeonDB - Serverless PostgreSQL (recommended)",
|
|
638
|
-
value: "neon"
|
|
639
|
-
},
|
|
640
|
-
{
|
|
641
|
-
name: "Supabase - PostgreSQL with built-in features",
|
|
642
|
-
value: "supabase"
|
|
643
|
-
},
|
|
644
|
-
{
|
|
645
|
-
name: "Local PostgreSQL - Use existing local database",
|
|
646
|
-
value: "local"
|
|
647
|
-
},
|
|
648
|
-
{
|
|
649
|
-
name: "Skip - Configure later",
|
|
650
|
-
value: "skip"
|
|
651
|
-
}
|
|
652
|
-
],
|
|
653
|
-
default: "neon"
|
|
654
|
-
}
|
|
655
|
-
]);
|
|
656
|
-
if (provider === "skip") {
|
|
657
|
-
return { provider: "skip" };
|
|
658
|
-
}
|
|
659
|
-
if (provider === "local") {
|
|
660
|
-
const { postgresUrl: postgresUrl2 } = await inquirer.prompt([
|
|
661
|
-
{
|
|
662
|
-
type: "input",
|
|
663
|
-
name: "postgresUrl",
|
|
664
|
-
message: "Enter your PostgreSQL connection string:",
|
|
665
|
-
default: "postgresql://postgres:postgres@localhost:5432/revealui",
|
|
666
|
-
validate: async (input) => {
|
|
667
|
-
const result = await validateNeonUrl(input);
|
|
668
|
-
return result.valid ? true : result.message || "Invalid database URL";
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
]);
|
|
672
|
-
return { provider: "local", postgresUrl: postgresUrl2 };
|
|
673
|
-
}
|
|
674
|
-
const { postgresUrl } = await inquirer.prompt([
|
|
675
|
-
{
|
|
676
|
-
type: "input",
|
|
677
|
-
name: "postgresUrl",
|
|
678
|
-
message: `Enter your ${provider === "neon" ? "Neon" : "Supabase"} database connection string:`,
|
|
679
|
-
validate: async (input) => {
|
|
680
|
-
if (!input || input.trim() === "") {
|
|
681
|
-
return "Database URL is required";
|
|
682
|
-
}
|
|
683
|
-
const result = await validateNeonUrl(input);
|
|
684
|
-
return result.valid ? true : result.message || "Invalid database URL";
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
]);
|
|
688
|
-
return { provider, postgresUrl };
|
|
689
|
-
}
|
|
690
|
-
var init_database = __esm({
|
|
691
|
-
"src/prompts/database.ts"() {
|
|
692
|
-
"use strict";
|
|
693
|
-
init_esm_shims();
|
|
694
|
-
init_credentials();
|
|
695
|
-
}
|
|
696
|
-
});
|
|
697
|
-
|
|
698
|
-
// src/prompts/devenv.ts
|
|
699
|
-
import inquirer2 from "inquirer";
|
|
700
|
-
async function promptDevEnvConfig() {
|
|
701
|
-
const answers = await inquirer2.prompt([
|
|
702
|
-
{
|
|
703
|
-
type: "confirm",
|
|
704
|
-
name: "createDevContainer",
|
|
705
|
-
message: "Create Dev Container configuration for VS Code / GitHub Codespaces?",
|
|
706
|
-
default: true
|
|
707
|
-
},
|
|
708
|
-
{
|
|
709
|
-
type: "confirm",
|
|
710
|
-
name: "createDevbox",
|
|
711
|
-
message: "Create Devbox configuration for Nix-powered development?",
|
|
712
|
-
default: true
|
|
713
|
-
}
|
|
714
|
-
]);
|
|
715
|
-
return answers;
|
|
716
|
-
}
|
|
717
|
-
var init_devenv = __esm({
|
|
718
|
-
"src/prompts/devenv.ts"() {
|
|
719
|
-
"use strict";
|
|
720
|
-
init_esm_shims();
|
|
721
|
-
}
|
|
722
|
-
});
|
|
723
|
-
|
|
724
|
-
// src/prompts/payments.ts
|
|
725
|
-
import inquirer3 from "inquirer";
|
|
726
|
-
async function promptPaymentConfig() {
|
|
727
|
-
const { enabled } = await inquirer3.prompt([
|
|
728
|
-
{
|
|
729
|
-
type: "confirm",
|
|
730
|
-
name: "enabled",
|
|
731
|
-
message: "Do you want to configure Stripe payments?",
|
|
732
|
-
default: true
|
|
733
|
-
}
|
|
734
|
-
]);
|
|
735
|
-
if (!enabled) {
|
|
736
|
-
return { enabled: false };
|
|
737
|
-
}
|
|
738
|
-
const answers = await inquirer3.prompt([
|
|
739
|
-
{
|
|
740
|
-
type: "input",
|
|
741
|
-
name: "stripeSecretKey",
|
|
742
|
-
message: "Enter your Stripe secret key (sk_test_... or sk_live_...):",
|
|
743
|
-
validate: async (input) => {
|
|
744
|
-
if (!input || input.trim() === "") {
|
|
745
|
-
return "Stripe secret key is required";
|
|
746
|
-
}
|
|
747
|
-
const result = await validateStripeKey(input);
|
|
748
|
-
return result.valid ? true : result.message || "Invalid Stripe key";
|
|
749
|
-
}
|
|
750
|
-
},
|
|
751
|
-
{
|
|
752
|
-
type: "input",
|
|
753
|
-
name: "stripePublishableKey",
|
|
754
|
-
message: "Enter your Stripe publishable key (pk_test_... or pk_live_...):",
|
|
755
|
-
validate: (input) => {
|
|
756
|
-
if (!input || input.trim() === "") {
|
|
757
|
-
return "Stripe publishable key is required";
|
|
758
|
-
}
|
|
759
|
-
if (!(input.startsWith("pk_test_") || input.startsWith("pk_live_"))) {
|
|
760
|
-
return "Stripe publishable key must start with pk_test_ or pk_live_";
|
|
761
|
-
}
|
|
762
|
-
return true;
|
|
763
|
-
}
|
|
764
|
-
},
|
|
765
|
-
{
|
|
766
|
-
type: "input",
|
|
767
|
-
name: "stripeWebhookSecret",
|
|
768
|
-
message: "Enter your Stripe webhook secret (whsec_..., optional - press Enter to skip):",
|
|
769
|
-
default: ""
|
|
770
|
-
}
|
|
771
|
-
]);
|
|
772
|
-
return {
|
|
773
|
-
enabled: true,
|
|
774
|
-
stripeSecretKey: answers.stripeSecretKey,
|
|
775
|
-
stripePublishableKey: answers.stripePublishableKey,
|
|
776
|
-
stripeWebhookSecret: answers.stripeWebhookSecret || void 0
|
|
777
|
-
};
|
|
778
|
-
}
|
|
779
|
-
var init_payments = __esm({
|
|
780
|
-
"src/prompts/payments.ts"() {
|
|
781
|
-
"use strict";
|
|
782
|
-
init_esm_shims();
|
|
783
|
-
init_credentials();
|
|
784
|
-
}
|
|
785
|
-
});
|
|
786
|
-
|
|
787
|
-
// src/prompts/project.ts
|
|
788
|
-
import fs5 from "fs";
|
|
789
|
-
import path6 from "path";
|
|
790
|
-
import inquirer4 from "inquirer";
|
|
791
|
-
async function promptProjectConfig(defaultName) {
|
|
792
|
-
const answers = await inquirer4.prompt([
|
|
793
|
-
{
|
|
794
|
-
type: "input",
|
|
795
|
-
name: "projectName",
|
|
796
|
-
message: "What is your project name?",
|
|
797
|
-
default: defaultName || "my-revealui-project",
|
|
798
|
-
validate: (input) => {
|
|
799
|
-
if (!/^[a-z0-9-]+$/.test(input)) {
|
|
800
|
-
return "Project name must contain only lowercase letters, numbers, and hyphens";
|
|
801
|
-
}
|
|
802
|
-
const projectPath = path6.resolve(process.cwd(), input);
|
|
803
|
-
if (fs5.existsSync(projectPath)) {
|
|
804
|
-
return `Directory "${input}" already exists`;
|
|
805
|
-
}
|
|
806
|
-
return true;
|
|
807
|
-
}
|
|
808
|
-
},
|
|
809
|
-
{
|
|
810
|
-
type: "list",
|
|
811
|
-
name: "template",
|
|
812
|
-
message: "Which template would you like to use?",
|
|
813
|
-
choices: [
|
|
814
|
-
{
|
|
815
|
-
name: "Basic Blog - A simple blog with posts and pages",
|
|
816
|
-
value: "basic-blog"
|
|
817
|
-
},
|
|
818
|
-
{
|
|
819
|
-
name: "E-commerce - Product catalog with checkout",
|
|
820
|
-
value: "e-commerce"
|
|
821
|
-
},
|
|
822
|
-
{
|
|
823
|
-
name: "Portfolio - Personal portfolio site",
|
|
824
|
-
value: "portfolio"
|
|
825
|
-
}
|
|
826
|
-
],
|
|
827
|
-
default: "basic-blog"
|
|
828
|
-
}
|
|
829
|
-
]);
|
|
830
|
-
return {
|
|
831
|
-
projectName: answers.projectName,
|
|
832
|
-
projectPath: path6.resolve(process.cwd(), answers.projectName),
|
|
833
|
-
template: answers.template
|
|
834
|
-
};
|
|
835
|
-
}
|
|
836
|
-
var init_project = __esm({
|
|
837
|
-
"src/prompts/project.ts"() {
|
|
838
|
-
"use strict";
|
|
839
|
-
init_esm_shims();
|
|
840
|
-
}
|
|
841
|
-
});
|
|
842
|
-
|
|
843
|
-
// src/prompts/storage.ts
|
|
844
|
-
import inquirer5 from "inquirer";
|
|
845
|
-
async function promptStorageConfig() {
|
|
846
|
-
const { provider } = await inquirer5.prompt([
|
|
847
|
-
{
|
|
848
|
-
type: "list",
|
|
849
|
-
name: "provider",
|
|
850
|
-
message: "Which storage provider would you like to use?",
|
|
851
|
-
choices: [
|
|
852
|
-
{
|
|
853
|
-
name: "Vercel Blob - Simple object storage (recommended)",
|
|
854
|
-
value: "vercel-blob"
|
|
855
|
-
},
|
|
856
|
-
{
|
|
857
|
-
name: "Supabase Storage - Integrated with Supabase",
|
|
858
|
-
value: "supabase"
|
|
859
|
-
},
|
|
860
|
-
{
|
|
861
|
-
name: "Skip - Configure later",
|
|
862
|
-
value: "skip"
|
|
863
|
-
}
|
|
864
|
-
],
|
|
865
|
-
default: "vercel-blob"
|
|
866
|
-
}
|
|
867
|
-
]);
|
|
868
|
-
if (provider === "skip") {
|
|
869
|
-
return { provider: "skip" };
|
|
870
|
-
}
|
|
871
|
-
if (provider === "vercel-blob") {
|
|
872
|
-
const { blobToken } = await inquirer5.prompt([
|
|
873
|
-
{
|
|
874
|
-
type: "input",
|
|
875
|
-
name: "blobToken",
|
|
876
|
-
message: "Enter your Vercel Blob read/write token:",
|
|
877
|
-
validate: async (input) => {
|
|
878
|
-
if (!input || input.trim() === "") {
|
|
879
|
-
return "Blob token is required";
|
|
880
|
-
}
|
|
881
|
-
const result = await validateVercelToken(input);
|
|
882
|
-
return result.valid ? true : result.message || "Invalid token";
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
]);
|
|
886
|
-
return { provider: "vercel-blob", blobToken };
|
|
887
|
-
}
|
|
888
|
-
const answers = await inquirer5.prompt([
|
|
889
|
-
{
|
|
890
|
-
type: "input",
|
|
891
|
-
name: "supabaseUrl",
|
|
892
|
-
message: "Enter your Supabase project URL:",
|
|
893
|
-
validate: async (input) => {
|
|
894
|
-
if (!input || input.trim() === "") {
|
|
895
|
-
return "Supabase URL is required";
|
|
896
|
-
}
|
|
897
|
-
const result = await validateSupabaseUrl(input);
|
|
898
|
-
return result.valid ? true : result.message || "Invalid URL";
|
|
899
|
-
}
|
|
900
|
-
},
|
|
901
|
-
{
|
|
902
|
-
type: "input",
|
|
903
|
-
name: "supabaseAnonKey",
|
|
904
|
-
message: "Enter your Supabase anonymous key:",
|
|
905
|
-
validate: (input) => {
|
|
906
|
-
if (!input || input.trim() === "") {
|
|
907
|
-
return "Supabase anonymous key is required";
|
|
908
|
-
}
|
|
909
|
-
return true;
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
]);
|
|
913
|
-
return {
|
|
914
|
-
provider: "supabase",
|
|
915
|
-
supabaseUrl: answers.supabaseUrl,
|
|
916
|
-
supabaseAnonKey: answers.supabaseAnonKey
|
|
917
|
-
};
|
|
918
|
-
}
|
|
919
|
-
var init_storage = __esm({
|
|
920
|
-
"src/prompts/storage.ts"() {
|
|
921
|
-
"use strict";
|
|
922
|
-
init_esm_shims();
|
|
923
|
-
init_credentials();
|
|
842
|
+
logger5.info("Skipping git initialisation (--skip-git)");
|
|
924
843
|
}
|
|
925
|
-
}
|
|
844
|
+
}
|
|
926
845
|
|
|
927
|
-
// src/
|
|
928
|
-
var
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
});
|
|
932
|
-
import { readFileSync } from "fs";
|
|
933
|
-
import { homedir } from "os";
|
|
934
|
-
import { join } from "path";
|
|
935
|
-
import { createLogger as createLogger6 } from "@revealui/setup/utils";
|
|
936
|
-
function checkProLicense() {
|
|
846
|
+
// src/commands/create-flow.ts
|
|
847
|
+
var logger6 = createLogger6({ prefix: "@revealui/cli" });
|
|
848
|
+
var PRO_TEMPLATES = /* @__PURE__ */ new Set([]);
|
|
849
|
+
async function checkProLicense() {
|
|
937
850
|
let key = process.env.REVEALUI_LICENSE_KEY;
|
|
938
851
|
if (!key) {
|
|
939
852
|
try {
|
|
@@ -944,132 +857,945 @@ function checkProLicense() {
|
|
|
944
857
|
}
|
|
945
858
|
}
|
|
946
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
|
+
}
|
|
947
871
|
try {
|
|
948
872
|
const parts = key.split(".");
|
|
949
|
-
if (parts.length <
|
|
950
|
-
const payload = JSON.parse(Buffer.from(parts[1] ?? "", "
|
|
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
|
+
}
|
|
951
878
|
const tier = payload.tier ?? "free";
|
|
952
879
|
return tier === "pro" || tier === "enterprise";
|
|
953
880
|
} catch {
|
|
954
881
|
return false;
|
|
955
882
|
}
|
|
956
883
|
}
|
|
957
|
-
async function
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
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);
|
|
962
900
|
}
|
|
963
|
-
logger6.success(
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
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 {
|
|
974
1054
|
}
|
|
975
|
-
logger6.success("Pro license verified");
|
|
976
1055
|
}
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
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 {
|
|
983
1182
|
}
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
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");
|
|
988
1357
|
} else {
|
|
989
|
-
|
|
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 {
|
|
990
1375
|
}
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
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");
|
|
995
1405
|
} else {
|
|
996
|
-
|
|
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;
|
|
997
1447
|
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
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(", ")}`
|
|
1002
1500
|
);
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
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"
|
|
1012
1616
|
});
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
logger6.info("pnpm dev");
|
|
1019
|
-
logger6.divider();
|
|
1020
|
-
logger6.success(`\u{1F389} Project ${projectConfig.projectName} created successfully!`);
|
|
1021
|
-
} catch (error) {
|
|
1022
|
-
if (error instanceof Error) {
|
|
1023
|
-
logger6.error(`Failed to create project: ${error.message}`);
|
|
1024
|
-
} else {
|
|
1025
|
-
logger6.error("An unexpected error occurred");
|
|
1617
|
+
}
|
|
1618
|
+
if (resolved.script) {
|
|
1619
|
+
const workspaceRoot = findWorkspaceRoot();
|
|
1620
|
+
if (!workspaceRoot) {
|
|
1621
|
+
throw new Error("RevealUI workspace root not found");
|
|
1026
1622
|
}
|
|
1027
|
-
|
|
1623
|
+
logger10.info(`Starting dev script: ${resolved.script}`);
|
|
1624
|
+
await execa6("pnpm", [resolved.script], {
|
|
1625
|
+
cwd: workspaceRoot,
|
|
1626
|
+
stdio: "inherit"
|
|
1627
|
+
});
|
|
1028
1628
|
}
|
|
1029
1629
|
}
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
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;
|
|
1048
1654
|
}
|
|
1049
1655
|
}
|
|
1050
|
-
|
|
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
|
+
}
|
|
1051
1693
|
|
|
1052
1694
|
// src/cli.ts
|
|
1053
|
-
|
|
1054
|
-
|
|
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
|
+
}
|
|
1055
1703
|
function createCli() {
|
|
1056
1704
|
const program = new Command();
|
|
1057
|
-
program.name("
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
await
|
|
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
|
+
});
|
|
1061
1788
|
});
|
|
1062
1789
|
return program;
|
|
1063
1790
|
}
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
"
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
});
|
|
1071
|
-
init_cli();
|
|
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
|
+
}
|
|
1072
1797
|
export {
|
|
1073
|
-
createCli
|
|
1798
|
+
createCli,
|
|
1799
|
+
createLegacyCreateCli
|
|
1074
1800
|
};
|
|
1075
1801
|
//# sourceMappingURL=cli.js.map
|