@revealui/cli 0.0.1-pre.1 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +22 -202
- package/README.md +194 -0
- package/bin/create-revealui.js +6 -0
- package/bin/revealui.js +6 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.js +1801 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +1795 -124
- package/dist/index.js.map +1 -0
- package/package.json +49 -42
- package/templates/basic-blog/.env.example +36 -0
- package/templates/basic-blog/_gitignore +26 -0
- package/templates/basic-blog/next.config.mjs +10 -0
- package/templates/basic-blog/package.json +36 -0
- package/templates/basic-blog/postcss.config.mjs +5 -0
- package/templates/basic-blog/revealui.config.ts +19 -0
- package/templates/basic-blog/src/app/globals.css +6 -0
- package/templates/basic-blog/src/app/layout.tsx +15 -0
- package/templates/basic-blog/src/app/page.tsx +57 -0
- package/templates/basic-blog/src/app/posts/[slug]/page.tsx +66 -0
- package/templates/basic-blog/src/app/posts/page.tsx +61 -0
- package/templates/basic-blog/src/collections/Posts.ts +42 -0
- package/templates/basic-blog/src/seed.ts +73 -0
- package/templates/basic-blog/tsconfig.json +11 -0
- package/templates/e-commerce/.env.example +36 -0
- package/templates/e-commerce/_gitignore +26 -0
- package/templates/e-commerce/next.config.mjs +10 -0
- package/templates/e-commerce/package.json +36 -0
- package/templates/e-commerce/postcss.config.mjs +5 -0
- package/templates/e-commerce/revealui.config.ts +20 -0
- package/templates/e-commerce/src/app/globals.css +6 -0
- package/templates/e-commerce/src/app/layout.tsx +15 -0
- package/templates/e-commerce/src/app/page.tsx +82 -0
- package/templates/e-commerce/src/app/products/[slug]/page.tsx +80 -0
- package/templates/e-commerce/src/app/products/page.tsx +72 -0
- package/templates/e-commerce/src/collections/Orders.ts +63 -0
- package/templates/e-commerce/src/collections/Products.ts +50 -0
- package/templates/e-commerce/src/seed.ts +72 -0
- package/templates/e-commerce/tsconfig.json +11 -0
- package/templates/portfolio/.env.example +36 -0
- package/templates/portfolio/_gitignore +26 -0
- package/templates/portfolio/next.config.mjs +10 -0
- package/templates/portfolio/package.json +36 -0
- package/templates/portfolio/postcss.config.mjs +5 -0
- package/templates/portfolio/revealui.config.ts +19 -0
- package/templates/portfolio/src/app/globals.css +6 -0
- package/templates/portfolio/src/app/layout.tsx +15 -0
- package/templates/portfolio/src/app/page.tsx +60 -0
- package/templates/portfolio/src/app/projects/[slug]/page.tsx +95 -0
- package/templates/portfolio/src/app/projects/page.tsx +85 -0
- package/templates/portfolio/src/collections/Projects.ts +49 -0
- package/templates/portfolio/src/seed.ts +73 -0
- package/templates/portfolio/tsconfig.json +11 -0
- package/templates/starter/.env.example +36 -0
- package/templates/starter/_gitignore +26 -0
- package/templates/starter/next.config.mjs +10 -0
- package/templates/starter/package.json +36 -0
- package/templates/starter/postcss.config.mjs +5 -0
- package/templates/starter/revealui.config.ts +18 -0
- package/templates/starter/src/app/globals.css +6 -0
- package/templates/starter/src/app/layout.tsx +15 -0
- package/templates/starter/src/app/page.tsx +18 -0
- package/templates/starter/src/seed.ts +40 -0
- package/templates/starter/tsconfig.json +11 -0
- package/dist/commands/add.d.ts +0 -28
- package/dist/commands/add.d.ts.map +0 -1
- package/dist/commands/add.js +0 -115
- package/dist/commands/check.d.ts +0 -7
- package/dist/commands/check.d.ts.map +0 -1
- package/dist/commands/check.js +0 -34
- package/dist/commands/doctor/checks/build.d.ts +0 -10
- package/dist/commands/doctor/checks/build.d.ts.map +0 -1
- package/dist/commands/doctor/checks/build.js +0 -74
- package/dist/commands/doctor/checks/config.d.ts +0 -14
- package/dist/commands/doctor/checks/config.d.ts.map +0 -1
- package/dist/commands/doctor/checks/config.js +0 -116
- package/dist/commands/doctor/checks/dependencies.d.ts +0 -14
- package/dist/commands/doctor/checks/dependencies.d.ts.map +0 -1
- package/dist/commands/doctor/checks/dependencies.js +0 -126
- package/dist/commands/doctor/checks/practices.d.ts +0 -14
- package/dist/commands/doctor/checks/practices.d.ts.map +0 -1
- package/dist/commands/doctor/checks/practices.js +0 -142
- package/dist/commands/doctor/checks/structure.d.ts +0 -14
- package/dist/commands/doctor/checks/structure.d.ts.map +0 -1
- package/dist/commands/doctor/checks/structure.js +0 -107
- package/dist/commands/doctor/fixes/index.d.ts +0 -26
- package/dist/commands/doctor/fixes/index.d.ts.map +0 -1
- package/dist/commands/doctor/fixes/index.js +0 -108
- package/dist/commands/doctor/index.d.ts +0 -11
- package/dist/commands/doctor/index.d.ts.map +0 -1
- package/dist/commands/doctor/index.js +0 -37
- package/dist/commands/doctor/print.d.ts +0 -6
- package/dist/commands/doctor/print.d.ts.map +0 -1
- package/dist/commands/doctor/print.js +0 -31
- package/dist/commands/doctor/types.d.ts +0 -16
- package/dist/commands/doctor/types.d.ts.map +0 -1
- package/dist/commands/doctor/types.js +0 -1
- package/dist/commands/fix.d.ts +0 -5
- package/dist/commands/fix.d.ts.map +0 -1
- package/dist/commands/fix.js +0 -129
- package/dist/commands/init.d.ts +0 -35
- package/dist/commands/init.d.ts.map +0 -1
- package/dist/commands/init.js +0 -104
- package/dist/commands/upgrade.d.ts +0 -9
- package/dist/commands/upgrade.d.ts.map +0 -1
- package/dist/commands/upgrade.js +0 -85
- package/dist/index.d.ts.map +0 -1
- package/dist/onLoad.d.ts +0 -3
- package/dist/onLoad.d.ts.map +0 -1
- package/dist/onLoad.js +0 -5
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -6
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import fs from "node:fs/promises";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
/**
|
|
4
|
-
* Check reveal.config.ts exists and is valid
|
|
5
|
-
*/
|
|
6
|
-
export async function checkRevealConfig(cwd) {
|
|
7
|
-
const results = [];
|
|
8
|
-
const configPath = path.join(cwd, "reveal.config.ts");
|
|
9
|
-
try {
|
|
10
|
-
await fs.access(configPath);
|
|
11
|
-
const content = await fs.readFile(configPath, "utf-8");
|
|
12
|
-
// Basic syntax check (look for export default)
|
|
13
|
-
if (content.includes("export default")) {
|
|
14
|
-
results.push({
|
|
15
|
-
check: "reveal.config.ts exists",
|
|
16
|
-
status: "pass",
|
|
17
|
-
message: "Configuration file found and appears valid",
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else {
|
|
21
|
-
results.push({
|
|
22
|
-
check: "reveal.config.ts exists",
|
|
23
|
-
status: "warn",
|
|
24
|
-
message: "Configuration file found but may be invalid",
|
|
25
|
-
suggestion: "Ensure 'export default defineConfig({...})' is present",
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
catch {
|
|
30
|
-
results.push({
|
|
31
|
-
check: "reveal.config.ts exists",
|
|
32
|
-
status: "fail",
|
|
33
|
-
message: "Configuration file not found",
|
|
34
|
-
suggestion: "Run 'reveal init' to create a configuration file",
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
return results;
|
|
38
|
-
}
|
|
39
|
-
/**
|
|
40
|
-
* Check TypeScript configuration
|
|
41
|
-
*/
|
|
42
|
-
export async function checkTypeScriptConfig(cwd) {
|
|
43
|
-
const results = [];
|
|
44
|
-
const tsconfigPath = path.join(cwd, "tsconfig.json");
|
|
45
|
-
try {
|
|
46
|
-
await fs.access(tsconfigPath);
|
|
47
|
-
const tsconfig = JSON.parse(await fs.readFile(tsconfigPath, "utf-8"));
|
|
48
|
-
if (tsconfig.compilerOptions?.strict) {
|
|
49
|
-
results.push({
|
|
50
|
-
check: "TypeScript configuration",
|
|
51
|
-
status: "pass",
|
|
52
|
-
message: "tsconfig.json found with strict mode enabled",
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
results.push({
|
|
57
|
-
check: "TypeScript configuration",
|
|
58
|
-
status: "warn",
|
|
59
|
-
message: "tsconfig.json found but strict mode is disabled",
|
|
60
|
-
suggestion: "Enable 'strict: true' in compilerOptions for better type safety",
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
catch {
|
|
65
|
-
results.push({
|
|
66
|
-
check: "TypeScript configuration",
|
|
67
|
-
status: "warn",
|
|
68
|
-
message: "tsconfig.json not found",
|
|
69
|
-
suggestion: "Consider adding TypeScript for better type safety",
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return results;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Check environment variables
|
|
76
|
-
*/
|
|
77
|
-
export async function checkEnvironmentVariables(cwd) {
|
|
78
|
-
const results = [];
|
|
79
|
-
const envTemplatePath = path.join(cwd, ".env.template");
|
|
80
|
-
const envLocalPath = path.join(cwd, ".env.local");
|
|
81
|
-
// Check for .env.template
|
|
82
|
-
try {
|
|
83
|
-
await fs.access(envTemplatePath);
|
|
84
|
-
results.push({
|
|
85
|
-
check: "Environment template",
|
|
86
|
-
status: "pass",
|
|
87
|
-
message: ".env.template found",
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
catch {
|
|
91
|
-
results.push({
|
|
92
|
-
check: "Environment template",
|
|
93
|
-
status: "warn",
|
|
94
|
-
message: ".env.template not found",
|
|
95
|
-
suggestion: "Create .env.template to document required environment variables",
|
|
96
|
-
});
|
|
97
|
-
}
|
|
98
|
-
// Check if .env.local exists (user should have this)
|
|
99
|
-
try {
|
|
100
|
-
await fs.access(envLocalPath);
|
|
101
|
-
results.push({
|
|
102
|
-
check: "Environment configuration",
|
|
103
|
-
status: "pass",
|
|
104
|
-
message: ".env.local found",
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
results.push({
|
|
109
|
-
check: "Environment configuration",
|
|
110
|
-
status: "warn",
|
|
111
|
-
message: ".env.local not found",
|
|
112
|
-
suggestion: "Create .env.local from .env.template and fill in your values",
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
return results;
|
|
116
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { DiagnosticResult } from "../types.js";
|
|
2
|
-
/**
|
|
3
|
-
* Check package.json exists and has reveal package
|
|
4
|
-
*/
|
|
5
|
-
export declare function checkRevealPackage(cwd: string): Promise<DiagnosticResult[]>;
|
|
6
|
-
/**
|
|
7
|
-
* Check required dependencies
|
|
8
|
-
*/
|
|
9
|
-
export declare function checkRequiredDependencies(cwd: string): Promise<DiagnosticResult[]>;
|
|
10
|
-
/**
|
|
11
|
-
* Check for outdated packages
|
|
12
|
-
*/
|
|
13
|
-
export declare function checkOutdatedPackages(cwd: string): Promise<DiagnosticResult[]>;
|
|
14
|
-
//# sourceMappingURL=dependencies.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../../../../src/commands/doctor/checks/dependencies.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAkC7B;AAED;;GAEG;AACH,wBAAsB,yBAAyB,CAC7C,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA8C7B;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAuC7B"}
|
|
@@ -1,126 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,142 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,107 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,108 +0,0 @@
|
|
|
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
|
-
}
|