@revealui/cli 0.0.1-pre.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/LICENSE +202 -0
  2. package/dist/commands/add.d.ts +28 -0
  3. package/dist/commands/add.d.ts.map +1 -0
  4. package/dist/commands/add.js +115 -0
  5. package/dist/commands/check.d.ts +7 -0
  6. package/dist/commands/check.d.ts.map +1 -0
  7. package/dist/commands/check.js +34 -0
  8. package/dist/commands/doctor/checks/build.d.ts +10 -0
  9. package/dist/commands/doctor/checks/build.d.ts.map +1 -0
  10. package/dist/commands/doctor/checks/build.js +74 -0
  11. package/dist/commands/doctor/checks/config.d.ts +14 -0
  12. package/dist/commands/doctor/checks/config.d.ts.map +1 -0
  13. package/dist/commands/doctor/checks/config.js +116 -0
  14. package/dist/commands/doctor/checks/dependencies.d.ts +14 -0
  15. package/dist/commands/doctor/checks/dependencies.d.ts.map +1 -0
  16. package/dist/commands/doctor/checks/dependencies.js +126 -0
  17. package/dist/commands/doctor/checks/practices.d.ts +14 -0
  18. package/dist/commands/doctor/checks/practices.d.ts.map +1 -0
  19. package/dist/commands/doctor/checks/practices.js +142 -0
  20. package/dist/commands/doctor/checks/structure.d.ts +14 -0
  21. package/dist/commands/doctor/checks/structure.d.ts.map +1 -0
  22. package/dist/commands/doctor/checks/structure.js +107 -0
  23. package/dist/commands/doctor/fixes/index.d.ts +26 -0
  24. package/dist/commands/doctor/fixes/index.d.ts.map +1 -0
  25. package/dist/commands/doctor/fixes/index.js +108 -0
  26. package/dist/commands/doctor/index.d.ts +11 -0
  27. package/dist/commands/doctor/index.d.ts.map +1 -0
  28. package/dist/commands/doctor/index.js +37 -0
  29. package/dist/commands/doctor/print.d.ts +6 -0
  30. package/dist/commands/doctor/print.d.ts.map +1 -0
  31. package/dist/commands/doctor/print.js +31 -0
  32. package/dist/commands/doctor/types.d.ts +16 -0
  33. package/dist/commands/doctor/types.d.ts.map +1 -0
  34. package/dist/commands/doctor/types.js +1 -0
  35. package/dist/commands/fix.d.ts +5 -0
  36. package/dist/commands/fix.d.ts.map +1 -0
  37. package/dist/commands/fix.js +129 -0
  38. package/dist/commands/init.d.ts +35 -0
  39. package/dist/commands/init.d.ts.map +1 -0
  40. package/dist/commands/init.js +104 -0
  41. package/dist/commands/upgrade.d.ts +9 -0
  42. package/dist/commands/upgrade.d.ts.map +1 -0
  43. package/dist/commands/upgrade.js +85 -0
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.d.ts.map +1 -0
  46. package/dist/index.js +128 -0
  47. package/dist/onLoad.d.ts +3 -0
  48. package/dist/onLoad.d.ts.map +1 -0
  49. package/dist/onLoad.js +5 -0
  50. package/dist/utils.d.ts +3 -0
  51. package/dist/utils.d.ts.map +1 -0
  52. package/dist/utils.js +6 -0
  53. package/package.json +58 -0
@@ -0,0 +1,126 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ /**
4
+ * Check package.json exists and has reveal package
5
+ */
6
+ export async function checkRevealPackage(cwd) {
7
+ const results = [];
8
+ const packageJsonPath = path.join(cwd, "package.json");
9
+ try {
10
+ const content = await fs.readFile(packageJsonPath, "utf-8");
11
+ const packageJson = JSON.parse(content);
12
+ if (packageJson.dependencies?.reveal || packageJson.devDependencies?.reveal) {
13
+ const version = packageJson.dependencies?.reveal || packageJson.devDependencies?.reveal;
14
+ results.push({
15
+ check: "reveal package installed",
16
+ status: "pass",
17
+ message: `RevealUI package is installed (${version})`,
18
+ });
19
+ }
20
+ else {
21
+ results.push({
22
+ check: "reveal package installed",
23
+ status: "fail",
24
+ message: "RevealUI package not found in dependencies",
25
+ suggestion: "Run 'pnpm add reveal' to install",
26
+ });
27
+ }
28
+ }
29
+ catch {
30
+ results.push({
31
+ check: "package.json exists",
32
+ status: "fail",
33
+ message: "package.json not found",
34
+ suggestion: "Initialize a Node.js project first",
35
+ });
36
+ }
37
+ return results;
38
+ }
39
+ /**
40
+ * Check required dependencies
41
+ */
42
+ export async function checkRequiredDependencies(cwd) {
43
+ const results = [];
44
+ const packageJsonPath = path.join(cwd, "package.json");
45
+ try {
46
+ const content = await fs.readFile(packageJsonPath, "utf-8");
47
+ const packageJson = JSON.parse(content);
48
+ const deps = {
49
+ ...packageJson.dependencies,
50
+ ...packageJson.devDependencies,
51
+ };
52
+ // Check for React 19
53
+ const requiredDeps = ["react", "react-dom"];
54
+ const missingDeps = requiredDeps.filter((dep) => !deps[dep]);
55
+ if (missingDeps.length === 0) {
56
+ const reactVersion = deps.react;
57
+ if (reactVersion?.includes("19")) {
58
+ results.push({
59
+ check: "required dependencies",
60
+ status: "pass",
61
+ message: `All required dependencies installed (React ${reactVersion})`,
62
+ });
63
+ }
64
+ else {
65
+ results.push({
66
+ check: "React version",
67
+ status: "warn",
68
+ message: `React ${reactVersion} detected, React 19 recommended`,
69
+ suggestion: "Update to React 19: 'pnpm add react@^19.2.0 react-dom@^19.2.0'",
70
+ });
71
+ }
72
+ }
73
+ else {
74
+ results.push({
75
+ check: "required dependencies",
76
+ status: "fail",
77
+ message: `Missing dependencies: ${missingDeps.join(", ")}`,
78
+ suggestion: `Run 'pnpm add ${missingDeps.join(" ")}'`,
79
+ });
80
+ }
81
+ }
82
+ catch {
83
+ // package.json check handled elsewhere
84
+ }
85
+ return results;
86
+ }
87
+ /**
88
+ * Check for outdated packages
89
+ */
90
+ export async function checkOutdatedPackages(cwd) {
91
+ const results = [];
92
+ const packageJsonPath = path.join(cwd, "package.json");
93
+ try {
94
+ const content = await fs.readFile(packageJsonPath, "utf-8");
95
+ const packageJson = JSON.parse(content);
96
+ // Check for common outdated patterns
97
+ const deps = { ...packageJson.dependencies, ...packageJson.devDependencies };
98
+ const outdated = [];
99
+ // Check for specific packages that should be updated
100
+ if (deps.react && !deps.react.includes("19")) {
101
+ outdated.push("react");
102
+ }
103
+ if (deps["react-dom"] && !deps["react-dom"].includes("19")) {
104
+ outdated.push("react-dom");
105
+ }
106
+ if (outdated.length > 0) {
107
+ results.push({
108
+ check: "package versions",
109
+ status: "warn",
110
+ message: `Some packages may be outdated: ${outdated.join(", ")}`,
111
+ suggestion: "Run 'pnpm outdated' to check for updates",
112
+ });
113
+ }
114
+ else {
115
+ results.push({
116
+ check: "package versions",
117
+ status: "pass",
118
+ message: "Package versions appear up to date",
119
+ });
120
+ }
121
+ }
122
+ catch {
123
+ // package.json check handled elsewhere
124
+ }
125
+ return results;
126
+ }
@@ -0,0 +1,14 @@
1
+ import type { DiagnosticResult } from "../types.js";
2
+ /**
3
+ * Check .gitignore is properly configured
4
+ */
5
+ export declare function checkGitignore(cwd: string): Promise<DiagnosticResult[]>;
6
+ /**
7
+ * Check environment files are not committed
8
+ */
9
+ export declare function checkEnvFilesNotCommitted(cwd: string): Promise<DiagnosticResult[]>;
10
+ /**
11
+ * Check security best practices
12
+ */
13
+ export declare function checkSecurityPractices(cwd: string): Promise<DiagnosticResult[]>;
14
+ //# sourceMappingURL=practices.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"practices.d.ts","sourceRoot":"","sources":["../../../../src/commands/doctor/checks/practices.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,wBAAsB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAoC7E;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAyC7B;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAwD7B"}
@@ -0,0 +1,142 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ /**
4
+ * Check .gitignore is properly configured
5
+ */
6
+ export async function checkGitignore(cwd) {
7
+ const results = [];
8
+ const gitignorePath = path.join(cwd, ".gitignore");
9
+ try {
10
+ const content = await fs.readFile(gitignorePath, "utf-8");
11
+ const requiredPatterns = ["node_modules", ".env"];
12
+ const missingPatterns = requiredPatterns.filter((pattern) => !content.includes(pattern));
13
+ if (missingPatterns.length === 0) {
14
+ results.push({
15
+ check: ".gitignore configuration",
16
+ status: "pass",
17
+ message: ".gitignore properly configured",
18
+ });
19
+ }
20
+ else {
21
+ results.push({
22
+ check: ".gitignore configuration",
23
+ status: "warn",
24
+ message: `.gitignore missing patterns: ${missingPatterns.join(", ")}`,
25
+ suggestion: `Add ${missingPatterns.join(", ")} to .gitignore`,
26
+ });
27
+ }
28
+ }
29
+ catch {
30
+ results.push({
31
+ check: ".gitignore configuration",
32
+ status: "warn",
33
+ message: ".gitignore not found",
34
+ suggestion: "Create .gitignore to prevent committing sensitive files",
35
+ });
36
+ }
37
+ return results;
38
+ }
39
+ /**
40
+ * Check environment files are not committed
41
+ */
42
+ export async function checkEnvFilesNotCommitted(cwd) {
43
+ const results = [];
44
+ const envFiles = [".env", ".env.local", ".env.development.local"];
45
+ for (const envFile of envFiles) {
46
+ try {
47
+ const envPath = path.join(cwd, envFile);
48
+ await fs.access(envPath);
49
+ // Check if .gitignore mentions it
50
+ try {
51
+ const gitignorePath = path.join(cwd, ".gitignore");
52
+ const gitignoreContent = await fs.readFile(gitignorePath, "utf-8");
53
+ if (gitignoreContent.includes(envFile) || gitignoreContent.includes(".env*")) {
54
+ results.push({
55
+ check: `Environment file: ${envFile}`,
56
+ status: "pass",
57
+ message: `${envFile} exists and is gitignored`,
58
+ });
59
+ }
60
+ else {
61
+ results.push({
62
+ check: `Environment file: ${envFile}`,
63
+ status: "warn",
64
+ message: `${envFile} exists but may not be gitignored`,
65
+ suggestion: `Add ${envFile} to .gitignore`,
66
+ });
67
+ }
68
+ }
69
+ catch {
70
+ results.push({
71
+ check: `Environment file: ${envFile}`,
72
+ status: "warn",
73
+ message: `${envFile} exists but .gitignore not found`,
74
+ suggestion: "Create .gitignore and add .env* patterns",
75
+ });
76
+ }
77
+ }
78
+ catch {
79
+ // File doesn't exist, which is fine
80
+ }
81
+ }
82
+ return results;
83
+ }
84
+ /**
85
+ * Check security best practices
86
+ */
87
+ export async function checkSecurityPractices(cwd) {
88
+ const results = [];
89
+ // Check for hardcoded secrets in code (basic check)
90
+ try {
91
+ const { readdir, readFile } = await import("fs/promises");
92
+ const srcPath = path.join(cwd, "src");
93
+ try {
94
+ const files = await readdir(srcPath, { recursive: true });
95
+ const suspiciousPatterns = [
96
+ /password\s*=\s*["'][^"']+["']/i,
97
+ /api[_-]?key\s*=\s*["'][^"']+["']/i,
98
+ /secret\s*=\s*["'][^"']+["']/i,
99
+ ];
100
+ let foundIssues = false;
101
+ for (const file of files) {
102
+ if (typeof file === "string" && (file.endsWith(".ts") || file.endsWith(".tsx") || file.endsWith(".js"))) {
103
+ const filePath = path.join(srcPath, file);
104
+ try {
105
+ const content = await readFile(filePath, "utf-8");
106
+ for (const pattern of suspiciousPatterns) {
107
+ if (pattern.test(content) && !content.includes("process.env")) {
108
+ foundIssues = true;
109
+ break;
110
+ }
111
+ }
112
+ }
113
+ catch {
114
+ // Skip files we can't read
115
+ }
116
+ }
117
+ }
118
+ if (!foundIssues) {
119
+ results.push({
120
+ check: "Security: hardcoded secrets",
121
+ status: "pass",
122
+ message: "No obvious hardcoded secrets detected",
123
+ });
124
+ }
125
+ else {
126
+ results.push({
127
+ check: "Security: hardcoded secrets",
128
+ status: "warn",
129
+ message: "Potential hardcoded secrets detected",
130
+ suggestion: "Use environment variables instead of hardcoding secrets",
131
+ });
132
+ }
133
+ }
134
+ catch {
135
+ // src directory might not exist
136
+ }
137
+ }
138
+ catch {
139
+ // Could not check
140
+ }
141
+ return results;
142
+ }
@@ -0,0 +1,14 @@
1
+ import type { DiagnosticResult } from "../types.js";
2
+ /**
3
+ * Check pages directory exists with content
4
+ */
5
+ export declare function checkPagesDirectory(cwd: string): Promise<DiagnosticResult[]>;
6
+ /**
7
+ * Check components directory structure
8
+ */
9
+ export declare function checkComponentsDirectory(cwd: string): Promise<DiagnosticResult[]>;
10
+ /**
11
+ * Check public assets directory
12
+ */
13
+ export declare function checkPublicDirectory(cwd: string): Promise<DiagnosticResult[]>;
14
+ //# sourceMappingURL=structure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structure.d.ts","sourceRoot":"","sources":["../../../../src/commands/doctor/checks/structure.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAgD7B;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAiC7B;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAqB7B"}
@@ -0,0 +1,107 @@
1
+ import fs from "node:fs/promises";
2
+ import path from "node:path";
3
+ /**
4
+ * Check pages directory exists with content
5
+ */
6
+ export async function checkPagesDirectory(cwd) {
7
+ const results = [];
8
+ const pagesDirs = [
9
+ path.join(cwd, "src/pages"),
10
+ path.join(cwd, "src/app"),
11
+ path.join(cwd, "pages"),
12
+ ];
13
+ let pagesFound = false;
14
+ for (const pagesDir of pagesDirs) {
15
+ try {
16
+ await fs.access(pagesDir);
17
+ const files = await fs.readdir(pagesDir, { withFileTypes: true });
18
+ const hasFiles = files.some((file) => {
19
+ const name = file.name.toLowerCase();
20
+ return (name.includes("page") ||
21
+ name.includes("index") ||
22
+ name.includes(".tsx") ||
23
+ name.includes(".jsx"));
24
+ });
25
+ if (hasFiles) {
26
+ pagesFound = true;
27
+ results.push({
28
+ check: "pages directory",
29
+ status: "pass",
30
+ message: `Pages directory found at ${path.relative(cwd, pagesDir)} with content`,
31
+ });
32
+ break;
33
+ }
34
+ }
35
+ catch {
36
+ // Continue to next directory
37
+ }
38
+ }
39
+ if (!pagesFound) {
40
+ results.push({
41
+ check: "pages directory",
42
+ status: "fail",
43
+ message: "No pages directory found or empty",
44
+ suggestion: "Create src/pages/ or src/app/ directory and add at least one page",
45
+ });
46
+ }
47
+ return results;
48
+ }
49
+ /**
50
+ * Check components directory structure
51
+ */
52
+ export async function checkComponentsDirectory(cwd) {
53
+ const results = [];
54
+ const componentsDirs = [
55
+ path.join(cwd, "src/components"),
56
+ path.join(cwd, "components"),
57
+ ];
58
+ let componentsFound = false;
59
+ for (const compDir of componentsDirs) {
60
+ try {
61
+ await fs.access(compDir);
62
+ componentsFound = true;
63
+ results.push({
64
+ check: "components directory",
65
+ status: "pass",
66
+ message: `Components directory found at ${path.relative(cwd, compDir)}`,
67
+ });
68
+ break;
69
+ }
70
+ catch {
71
+ // Continue
72
+ }
73
+ }
74
+ if (!componentsFound) {
75
+ results.push({
76
+ check: "components directory",
77
+ status: "warn",
78
+ message: "Components directory not found",
79
+ suggestion: "Consider creating src/components/ for reusable components",
80
+ });
81
+ }
82
+ return results;
83
+ }
84
+ /**
85
+ * Check public assets directory
86
+ */
87
+ export async function checkPublicDirectory(cwd) {
88
+ const results = [];
89
+ const publicDir = path.join(cwd, "public");
90
+ try {
91
+ await fs.access(publicDir);
92
+ results.push({
93
+ check: "public directory",
94
+ status: "pass",
95
+ message: "Public directory found",
96
+ });
97
+ }
98
+ catch {
99
+ results.push({
100
+ check: "public directory",
101
+ status: "warn",
102
+ message: "Public directory not found",
103
+ suggestion: "Create public/ directory for static assets",
104
+ });
105
+ }
106
+ return results;
107
+ }
@@ -0,0 +1,26 @@
1
+ import type { DiagnosticResult } from "../types.js";
2
+ /**
3
+ * Apply automatic fixes for diagnostic issues
4
+ */
5
+ export declare function applyFixes(results: DiagnosticResult[]): Promise<void>;
6
+ /**
7
+ * Create missing reveal.config.ts
8
+ */
9
+ export declare function fixMissingRevealConfig(cwd: string): Promise<void>;
10
+ /**
11
+ * Add missing dependencies
12
+ */
13
+ export declare function fixMissingDependencies(cwd: string, dependencies: string[]): Promise<void>;
14
+ /**
15
+ * Create missing directories
16
+ */
17
+ export declare function fixMissingDirectories(cwd: string, dirs: string[]): Promise<void>;
18
+ /**
19
+ * Add patterns to .gitignore
20
+ */
21
+ export declare function fixGitignore(cwd: string, patterns: string[]): Promise<void>;
22
+ /**
23
+ * Create .env.template
24
+ */
25
+ export declare function fixMissingEnvTemplate(cwd: string): Promise<void>;
26
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/commands/doctor/fixes/index.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,wBAAsB,UAAU,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CA2B3E;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBvE;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC3C,GAAG,EAAE,MAAM,EACX,YAAY,EAAE,MAAM,EAAE,GACpB,OAAO,CAAC,IAAI,CAAC,CAQf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAC1C,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EAAE,GACZ,OAAO,CAAC,IAAI,CAAC,CAIf;AAED;;GAEG;AACH,wBAAsB,YAAY,CACjC,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAAE,GAChB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAkBtE"}
@@ -0,0 +1,108 @@
1
+ import pc from "@brillout/picocolors";
2
+ import { execSync } from "child_process";
3
+ import fs from "node:fs/promises";
4
+ import path from "node:path";
5
+ /**
6
+ * Apply automatic fixes for diagnostic issues
7
+ */
8
+ export async function applyFixes(results) {
9
+ const fixableResults = results.filter((r) => r.fix && (r.status === "fail" || r.status === "warn"));
10
+ if (fixableResults.length === 0) {
11
+ console.log(pc.yellow("No auto-fixable issues found."));
12
+ return;
13
+ }
14
+ console.log(pc.cyan(`\nFound ${fixableResults.length} fixable issue(s):\n`));
15
+ for (const result of fixableResults) {
16
+ console.log(pc.yellow(`Fixing: ${result.check}`));
17
+ if (result.fix) {
18
+ try {
19
+ await result.fix();
20
+ console.log(pc.green(` ✓ Fixed: ${result.check}\n`));
21
+ }
22
+ catch (error) {
23
+ console.log(pc.red(` ✗ Failed to fix: ${error instanceof Error ? error.message : String(error)}\n`));
24
+ }
25
+ }
26
+ }
27
+ }
28
+ /**
29
+ * Create missing reveal.config.ts
30
+ */
31
+ export async function fixMissingRevealConfig(cwd) {
32
+ const configPath = path.join(cwd, "reveal.config.ts");
33
+ const configContent = `import { defineConfig } from "@revealui/core/config";
34
+ import react from "@revealui/core/plugins/react";
35
+ import vercel from "@revealui/core/plugins/vercel";
36
+
37
+ export default defineConfig({
38
+ plugins: [
39
+ react(),
40
+ vercel(),
41
+ ],
42
+ vike: {
43
+ prerender: true,
44
+ },
45
+ });
46
+ `;
47
+ await fs.writeFile(configPath, configContent, "utf-8");
48
+ }
49
+ /**
50
+ * Add missing dependencies
51
+ */
52
+ export async function fixMissingDependencies(cwd, dependencies) {
53
+ if (dependencies.length === 0)
54
+ return;
55
+ const depsString = dependencies.join(" ");
56
+ execSync(`pnpm add ${depsString}`, {
57
+ cwd,
58
+ stdio: "inherit",
59
+ });
60
+ }
61
+ /**
62
+ * Create missing directories
63
+ */
64
+ export async function fixMissingDirectories(cwd, dirs) {
65
+ for (const dir of dirs) {
66
+ await fs.mkdir(path.join(cwd, dir), { recursive: true });
67
+ }
68
+ }
69
+ /**
70
+ * Add patterns to .gitignore
71
+ */
72
+ export async function fixGitignore(cwd, patterns) {
73
+ const gitignorePath = path.join(cwd, ".gitignore");
74
+ let content = "";
75
+ try {
76
+ content = await fs.readFile(gitignorePath, "utf-8");
77
+ }
78
+ catch {
79
+ // .gitignore doesn't exist, we'll create it
80
+ }
81
+ const lines = content.split("\n").filter((line) => line.trim());
82
+ const newPatterns = patterns.filter((pattern) => !content.includes(pattern));
83
+ if (newPatterns.length > 0) {
84
+ const updatedContent = [...lines, ...newPatterns].join("\n") + "\n";
85
+ await fs.writeFile(gitignorePath, updatedContent, "utf-8");
86
+ }
87
+ }
88
+ /**
89
+ * Create .env.template
90
+ */
91
+ export async function fixMissingEnvTemplate(cwd) {
92
+ const envTemplatePath = path.join(cwd, ".env.template");
93
+ const templateContent = `# PayloadCMS Configuration
94
+ PAYLOAD_SECRET=your-secret-key-here
95
+ PAYLOAD_PUBLIC_SERVER_URL=http://localhost:3000
96
+ NEXT_PUBLIC_SERVER_URL=http://localhost:3000
97
+
98
+ # Database (optional - uses SQLite by default)
99
+ POSTGRES_URL=
100
+
101
+ # Storage (optional - required for media uploads)
102
+ BLOB_READ_WRITE_TOKEN=
103
+
104
+ # Generate a secure secret with:
105
+ # node -e "console.log(require('crypto').randomBytes(32).toString('hex'))"
106
+ `;
107
+ await fs.writeFile(envTemplatePath, templateContent, "utf-8");
108
+ }
@@ -0,0 +1,11 @@
1
+ import type { DiagnosticResult } from "./types.js";
2
+ import { printDiagnostics } from "./print.js";
3
+ /**
4
+ * Runs comprehensive health diagnostics on the RevealUI project
5
+ */
6
+ export declare function runDiagnostics(): Promise<DiagnosticResult[]>;
7
+ /**
8
+ * Print diagnostic results to console
9
+ */
10
+ export { printDiagnostics };
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/index.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C;;GAEG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA6BlE;AAED;;GAEG;AACH,OAAO,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,37 @@
1
+ import * as configChecks from "./checks/config.js";
2
+ import * as dependencyChecks from "./checks/dependencies.js";
3
+ import * as structureChecks from "./checks/structure.js";
4
+ import * as buildChecks from "./checks/build.js";
5
+ import * as practiceChecks from "./checks/practices.js";
6
+ import { printDiagnostics } from "./print.js";
7
+ /**
8
+ * Runs comprehensive health diagnostics on the RevealUI project
9
+ */
10
+ export async function runDiagnostics() {
11
+ const cwd = process.cwd();
12
+ const results = [];
13
+ // Configuration checks
14
+ results.push(...(await configChecks.checkRevealConfig(cwd)));
15
+ results.push(...(await configChecks.checkTypeScriptConfig(cwd)));
16
+ results.push(...(await configChecks.checkEnvironmentVariables(cwd)));
17
+ // Dependency checks
18
+ results.push(...(await dependencyChecks.checkRevealPackage(cwd)));
19
+ results.push(...(await dependencyChecks.checkRequiredDependencies(cwd)));
20
+ results.push(...(await dependencyChecks.checkOutdatedPackages(cwd)));
21
+ // Structure checks
22
+ results.push(...(await structureChecks.checkPagesDirectory(cwd)));
23
+ results.push(...(await structureChecks.checkComponentsDirectory(cwd)));
24
+ results.push(...(await structureChecks.checkPublicDirectory(cwd)));
25
+ // Build checks
26
+ results.push(...(await buildChecks.checkTypeScriptCompilation(cwd)));
27
+ results.push(...(await buildChecks.checkBuildProcess(cwd)));
28
+ // Best practices checks
29
+ results.push(...(await practiceChecks.checkGitignore(cwd)));
30
+ results.push(...(await practiceChecks.checkEnvFilesNotCommitted(cwd)));
31
+ results.push(...(await practiceChecks.checkSecurityPractices(cwd)));
32
+ return results;
33
+ }
34
+ /**
35
+ * Print diagnostic results to console
36
+ */
37
+ export { printDiagnostics };
@@ -0,0 +1,6 @@
1
+ import type { DiagnosticResult } from "./types.js";
2
+ /**
3
+ * Prints diagnostic results to the console
4
+ */
5
+ export declare function printDiagnostics(results: DiagnosticResult[]): void;
6
+ //# sourceMappingURL=print.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"print.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/print.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG,IAAI,CAoClE"}
@@ -0,0 +1,31 @@
1
+ import pc from "@brillout/picocolors";
2
+ /**
3
+ * Prints diagnostic results to the console
4
+ */
5
+ export function printDiagnostics(results) {
6
+ console.log(pc.cyan("\nRevealUI Project Diagnostics\n"));
7
+ console.log(pc.gray("─".repeat(50) + "\n"));
8
+ for (const result of results) {
9
+ const icon = result.status === "pass"
10
+ ? pc.green("✓")
11
+ : result.status === "warn"
12
+ ? pc.yellow("⚠")
13
+ : pc.red("✗");
14
+ console.log(`${icon} ${pc.bold(result.check)}`);
15
+ console.log(` ${result.message}`);
16
+ if (result.suggestion) {
17
+ console.log(pc.gray(` → ${result.suggestion}`));
18
+ }
19
+ console.log();
20
+ }
21
+ const passCount = results.filter((r) => r.status === "pass").length;
22
+ const warnCount = results.filter((r) => r.status === "warn").length;
23
+ const failCount = results.filter((r) => r.status === "fail").length;
24
+ console.log(pc.gray("─".repeat(50)));
25
+ console.log(`Summary: ${pc.green(`${passCount} passed`)}, ${pc.yellow(`${warnCount} warnings`)}, ${pc.red(`${failCount} failed`)}`);
26
+ console.log();
27
+ if (failCount > 0) {
28
+ console.log(pc.yellow("💡 Tip: Run 'reveal fix' to automatically fix some issues"));
29
+ console.log();
30
+ }
31
+ }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Diagnostic result from health check
3
+ */
4
+ export interface DiagnosticResult {
5
+ /** Name of the diagnostic check */
6
+ check: string;
7
+ /** Status of the check */
8
+ status: "pass" | "warn" | "fail";
9
+ /** Diagnostic message */
10
+ message: string;
11
+ /** Optional suggestion for fixing issues */
12
+ suggestion?: string;
13
+ /** Optional fix action that can be applied */
14
+ fix?: () => Promise<void> | void;
15
+ }
16
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/commands/doctor/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,0BAA0B;IAC1B,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,4CAA4C;IAC5C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,8CAA8C;IAC9C,GAAG,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CAClC"}
@@ -0,0 +1 @@
1
+ export {};