forked from w3b3d3v/kitdot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-cli.js
More file actions
87 lines (68 loc) · 2.14 KB
/
Copy pathtest-cli.js
File metadata and controls
87 lines (68 loc) · 2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#!/usr/bin/env node
import { spawn } from "child_process";
import fs from "fs-extra";
import path from "path";
const testDir = "/tmp/kitdot-test-project";
async function runTest() {
console.log("🧪 Testing kitdot CLI...");
// Clean up test directory
await fs.remove(testDir);
// Test CLI help
console.log("📝 Testing CLI help...");
const helpProcess = spawn("node", ["dist/cli.js", "--help"], {
cwd: "/Users/nomadbitcoin/Projects/kitdot",
stdio: "inherit",
});
await new Promise((resolve) => helpProcess.on("close", resolve));
console.log("✅ CLI help test passed!");
// Test project structure creation (without interactive prompt)
console.log("📁 Testing project structure creation...");
// We'll test the utility functions directly since we can't easily simulate interactive input
const { createProjectStructure } = await import(
"./dist/utils/project-structure.js"
);
const testConfig = {
name: "test-project",
type: "fullstack",
directory: testDir,
features: {
contracts: true,
frontend: true,
cloudFunctions: true,
documentation: true,
},
};
try {
await createProjectStructure(testConfig);
// Verify structure
const expectedDirs = [
"contracts/develop",
"contracts/deploy",
"front",
"cloud-functions",
"docs",
];
for (const dir of expectedDirs) {
const dirPath = path.join(testDir, dir);
if (!(await fs.pathExists(dirPath))) {
throw new Error(`Directory ${dir} was not created`);
}
}
// Verify files
const expectedFiles = ["package.json", ".gitignore", "README.md"];
for (const file of expectedFiles) {
const filePath = path.join(testDir, file);
if (!(await fs.pathExists(filePath))) {
throw new Error(`File ${file} was not created`);
}
}
console.log("✅ Project structure test passed!");
// Clean up
await fs.remove(testDir);
console.log("🎉 All tests passed! kitdot CLI is working correctly.");
} catch (error) {
console.error("❌ Test failed:", error.message);
process.exit(1);
}
}
runTest().catch(console.error);