-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck-ui-components.js
More file actions
67 lines (55 loc) · 1.92 KB
/
check-ui-components.js
File metadata and controls
67 lines (55 loc) · 1.92 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
import fs from 'fs';
import path from 'path';
import { fileURLToPath } from 'url';
// Get the current directory
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Define the components to check
const components = [
'src/components/ui/button.tsx',
'src/components/ui/card.tsx',
'src/components/ui/alert.tsx',
'src/components/ui/cloudinary-image.tsx',
'src/components/ui/cloudinary-upload.tsx',
'src/lib/utils.ts'
];
// Check if each component exists
console.log('Checking UI components...');
let allComponentsExist = true;
components.forEach(componentPath => {
const fullPath = path.join(process.cwd(), componentPath);
if (fs.existsSync(fullPath)) {
console.log(`✅ ${componentPath} exists`);
// Check if the file has the correct imports
const content = fs.readFileSync(fullPath, 'utf8');
if (componentPath.includes('ui/') && !content.includes('@/lib/utils')) {
console.log(`❌ ${componentPath} is missing the import from @/lib/utils`);
allComponentsExist = false;
}
} else {
console.log(`❌ ${componentPath} does not exist`);
allComponentsExist = false;
}
});
// Create the components directory structure if it doesn't exist
if (!allComponentsExist) {
console.log('\nCreating missing components...');
// Ensure directories exist
const directories = [
'src/components/ui',
'src/lib'
];
directories.forEach(dir => {
const fullPath = path.join(process.cwd(), dir);
if (!fs.existsSync(fullPath)) {
console.log(`Creating directory: ${dir}`);
fs.mkdirSync(fullPath, { recursive: true });
}
});
console.log('\nPlease run the setup-ui.sh script to create the components:');
console.log('chmod +x setup-ui.sh && ./setup-ui.sh');
} else {
console.log('\nAll UI components exist and are correctly configured! 🎉');
}
// Exit with appropriate code
process.exit(allComponentsExist ? 0 : 1);