-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.sh
79 lines (63 loc) · 1.68 KB
/
test.sh
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
#!/bin/bash
# Exit on any error
set -e
# Function to check if a file exists
check_file() {
if [ ! -f "$1" ]; then
echo "❌ Error: File $1 not found"
exit 1
else
echo "✅ File $1 exists"
fi
}
# Function to check if a directory exists
check_directory() {
if [ ! -d "$1" ]; then
echo "❌ Error: Directory $1 not found"
exit 1
else
echo "✅ Directory $1 exists"
fi
}
echo "🚀 Starting test of bootstrap script"
# Create test output directory
mkdir -p test-output
cd test-output
# Run the initialization script
echo "Running bootstrap-nodejs-package with project name: $TEST_PROJECT_NAME"
../bootstrap-nodejs-package "$TEST_PROJECT_NAME"
# Verify the project structure
cd "$TEST_PROJECT_NAME"
echo "📋 Verifying project structure..."
# Check directories
ls -al
check_directory "node_modules"
check_directory ".github/workflows"
# Check files
check_file "package.json"
check_file "tsconfig.json"
check_file "jest.config.cjs"
check_file ".gitignore"
check_file ".github/workflows/ci.yml"
check_file "eslint.config.mjs"
# Verify npm packages are installed
echo "📦 Verifying npm packages..."
if ! npm list typescript > /dev/null 2>&1; then
echo "❌ Error: TypeScript not installed"
exit 1
fi
# Try to build the project
echo "🔨 Testing build..."
if ! npm run build > /dev/null 2>&1; then
echo "❌ Error: Build failed"
exit 1
fi
echo "✅ Build successful"
# Try to run tests (even though there are none yet)
echo "🧪 Testing test command..."
if ! npm test > /dev/null 2>&1; then
echo "❌ Error: Test command failed"
exit 1
fi
echo "✅ Test command successful"
echo "🎉 All tests passed successfully!"