-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.js
64 lines (60 loc) · 1.38 KB
/
setup.js
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
const fs = require('fs');
const path = require('path');
// Define the project structure
const structure = {
'src': {
'app': {
'page.tsx': '',
'layout.tsx': '',
'globals.css': ''
},
'components': {
'SearchQuery.tsx': '',
'ResultsTable.tsx': '',
'Pagination.tsx': '',
'ui': {
'Button.tsx': '',
'Card.tsx': '',
'Input.tsx': ''
}
},
'types': {
'stock.ts': ''
},
'utils': {
'queryParser.ts': '',
'stockFilter.ts': '',
'cn.ts': ''
}
},
'public': {
'data': {
'stocks.json': ''
}
}
};
// Function to create directory structure
function createDirectory(basePath, structure) {
for (const [name, content] of Object.entries(structure)) {
const currentPath = path.join(basePath, name);
if (typeof content === 'object') {
// If it's a directory
if (!fs.existsSync(currentPath)) {
fs.mkdirSync(currentPath, { recursive: true });
}
createDirectory(currentPath, content);
} else {
// If it's a file
if (!fs.existsSync(currentPath)) {
fs.writeFileSync(currentPath, '');
}
}
}
}
// Create the project structure
try {
createDirectory(process.cwd(), structure);
console.log('Project structure created successfully!');
} catch (error) {
console.error('Error creating project structure:', error);
}