-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-build.mjs
More file actions
92 lines (78 loc) · 2.86 KB
/
test-build.mjs
File metadata and controls
92 lines (78 loc) · 2.86 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
88
89
90
91
92
#!/usr/bin/env node
// Simple test script to verify the library builds work correctly
import fs from 'fs';
import path from 'path';
console.log('🧪 Testing MicroUI builds...\n');
const distDir = path.join(process.cwd(), 'dist');
const requiredFiles = ['microui.js', 'microui.min.js', 'microui.esm.js'];
// Check if all build files exist
console.log('📁 Checking build files:');
for (const file of requiredFiles) {
const filePath = path.join(distDir, file);
if (fs.existsSync(filePath)) {
const stats = fs.statSync(filePath);
const sizeKB = (stats.size / 1024).toFixed(2);
console.log(`✅ ${file} - ${sizeKB}KB`);
} else {
console.log(`❌ ${file} - Missing!`);
process.exit(1);
}
}
// Try to load the UMD build in Node.js environment
console.log('\n🔄 Testing UMD build:');
try {
const umdContent = fs.readFileSync(path.join(distDir, 'microui.js'), 'utf8');
// Check if it contains the expected structure
if (umdContent.includes('MicroUI')) {
console.log('✅ UMD build contains MicroUI global');
} else {
console.log('❌ UMD build missing MicroUI global');
process.exit(1);
}
if (umdContent.includes('version: \'1.0.0\'')) {
console.log('✅ Version information present');
} else {
console.log('❌ Version information missing');
process.exit(1);
}
// Check for main API methods
const expectedMethods = ['ready', 'on', 'off', 'get', 'post', 'fadeIn', 'fadeOut'];
for (const method of expectedMethods) {
if (umdContent.includes(method)) {
console.log(`✅ ${method} method found`);
} else {
console.log(`❌ ${method} method missing`);
process.exit(1);
}
}
} catch (error) {
console.log('❌ Error testing UMD build:', error.message);
process.exit(1);
}
// Check minified version
console.log('\n⚡ Testing minified build:');
try {
const minContent = fs.readFileSync(path.join(distDir, 'microui.min.js'), 'utf8');
if (minContent.length < 15000) { // Should be smaller than unminified
console.log('✅ Minified version is properly compressed');
} else {
console.log('❌ Minified version seems too large');
process.exit(1);
}
if (minContent.includes('MicroUI')) {
console.log('✅ Minified build contains MicroUI global');
} else {
console.log('❌ Minified build missing MicroUI global');
process.exit(1);
}
} catch (error) {
console.log('❌ Error testing minified build:', error.message);
process.exit(1);
}
console.log('\n🎉 All tests passed! MicroUI library is ready for use.');
console.log('\n📖 Next steps:');
console.log('1. Test the examples/basic.html file in a browser');
console.log('2. Create a git repository and commit your code');
console.log('3. Create a GitHub repository and push the code');
console.log('4. Create a tag (e.g., v1.0.0) to trigger the GitHub Actions build');
console.log('5. Publish to NPM if desired');