-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest-npm-publish.sh
More file actions
executable file
Β·139 lines (118 loc) Β· 3.45 KB
/
Copy pathtest-npm-publish.sh
File metadata and controls
executable file
Β·139 lines (118 loc) Β· 3.45 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/bin/bash
# OpenLearnX v2.0.4 NPM Publishing Test Script
# This script validates the package before publishing to NPM
set -e
echo "π OpenLearnX v2.0.4 - NPM Publishing Test"
echo "==========================================="
echo ""
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
# Helper functions
pass() {
echo -e "${GREEN}β
$1${NC}"
}
fail() {
echo -e "${RED}β $1${NC}"
exit 1
}
warn() {
echo -e "${YELLOW}β οΈ $1${NC}"
}
# Test 1: Check if we're in the right directory
echo "π Test 1: Checking directory structure..."
if [ -f "frontend/package.json" ]; then
pass "Found frontend/package.json"
else
fail "Not in correct directory. Run from project root."
fi
# Test 2: Verify package.json structure
echo ""
echo "π¦ Test 2: Validating package.json..."
cd frontend
if [ ! -f "package.json" ]; then
fail "package.json not found in frontend/"
fi
# Check for required fields
if grep -q '"name": "@th30d4y/openlearnx"' package.json; then
pass "Package name is correct: @th30d4y/openlearnx"
else
fail "Package name is incorrect or missing"
fi
if grep -q '"version": "2.0.4"' package.json; then
pass "Version is correct: 2.0.4"
else
fail "Version is not 2.0.4"
fi
if grep -q '"private": false' package.json; then
pass "Package is public (private: false)"
else
fail "Package is marked as private"
fi
if grep -q 'https://registry.npmjs.org' package.json; then
pass "Publishing to correct registry: npmjs.org"
else
fail "Publishing registry not configured correctly"
fi
# Test 3: Check for link: dependencies
echo ""
echo "π Test 3: Checking for local link: dependencies..."
if grep -q 'link:' package.json; then
fail "Found link: dependencies that break NPM publishing. Package has been fixed."
else
pass "No link: dependencies found β
"
fi
# Test 4: Validate JSON
echo ""
echo "π Test 4: Validating JSON syntax..."
if node -e "JSON.parse(require('fs').readFileSync('package.json', 'utf8'))" 2>/dev/null; then
pass "package.json has valid JSON syntax"
else
fail "package.json has invalid JSON syntax"
fi
# Test 5: Check npm is installed
echo ""
echo "π Test 5: Checking NPM installation..."
if command -v npm &> /dev/null; then
npm_version=$(npm --version)
pass "npm is installed (version: $npm_version)"
else
fail "npm is not installed"
fi
# Test 6: Verify npm registry access
echo ""
echo "π Test 6: Checking npm registry access..."
if npm ping --registry https://registry.npmjs.org 2>/dev/null; then
pass "Connected to NPM registry"
else
warn "Could not reach NPM registry (might need internet)"
fi
# Test 7: Check npm login status
echo ""
echo "π Test 7: Checking npm authentication..."
if npm whoami 2>/dev/null > /dev/null; then
logged_in_user=$(npm whoami 2>/dev/null)
pass "Logged in as: $logged_in_user"
else
warn "Not logged in to npm. You'll need to run: npm login"
fi
# Test 8: Dry run of package creation
echo ""
echo "π¦ Test 8: Testing package creation (dry run)..."
if npm pack --dry-run 2>&1 | grep -q "@th30d4y/openlearnx@2.0.4"; then
pass "Package would be created successfully"
else
fail "Package creation test failed"
fi
echo ""
echo "==========================================="
echo -e "${GREEN}β
All tests passed!${NC}"
echo ""
echo "π Ready to publish:"
echo " npm publish"
echo ""
echo "Or test locally first:"
echo " npm pack && tar -tzf th30d4y-openlearnx-2.0.4.tgz | head -20"
echo ""