devicely 2.1.3 → 2.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/bin/devicely.js +105 -1
  2. package/lib/androidDeviceDetection.js +276 -1
  3. package/lib/appMappings.js +337 -1
  4. package/lib/deviceDetection.js +394 -1
  5. package/lib/devices.js +54 -1
  6. package/lib/doctor.js +94 -1
  7. package/lib/executor.js +104 -1
  8. package/lib/logger.js +35 -1
  9. package/lib/scriptLoader.js +75 -0
  10. package/lib/server.js +3483 -1
  11. package/package.json +3 -12
  12. package/scripts/compile-shell-scripts.js +208 -0
  13. package/scripts/encrypt-shell-simple.js +75 -0
  14. package/scripts/obfuscate-shell.js +160 -0
  15. package/scripts/shell/android_device_control +0 -0
  16. package/scripts/shell/android_device_control.sh +848 -0
  17. package/scripts/shell/apps_presets.conf +271 -0
  18. package/scripts/shell/connect_android_usb +0 -0
  19. package/scripts/shell/connect_android_usb_multi_final +0 -0
  20. package/scripts/shell/connect_android_usb_multi_final.sh +289 -0
  21. package/scripts/shell/connect_android_wireless +0 -0
  22. package/scripts/shell/connect_android_wireless.sh +58 -0
  23. package/scripts/shell/connect_android_wireless_multi_final +0 -0
  24. package/scripts/shell/connect_android_wireless_multi_final.sh +476 -0
  25. package/scripts/shell/connect_ios_usb +0 -0
  26. package/scripts/shell/connect_ios_usb_multi_final +0 -0
  27. package/scripts/shell/connect_ios_usb_multi_final.sh +4225 -0
  28. package/scripts/shell/connect_ios_wireless_multi_final +0 -0
  29. package/scripts/shell/connect_ios_wireless_multi_final.sh +4167 -0
  30. package/scripts/shell/create_production_scripts +0 -0
  31. package/scripts/shell/create_production_scripts.sh +38 -0
  32. package/scripts/shell/devices.conf +24 -0
  33. package/scripts/shell/diagnose_wireless_ios +0 -0
  34. package/scripts/shell/find_element_coordinates +0 -0
  35. package/scripts/shell/find_wda +0 -0
  36. package/scripts/shell/install_uiautomator2 +0 -0
  37. package/scripts/shell/install_uiautomator2.sh +93 -0
  38. package/scripts/shell/ios_device_control +0 -0
  39. package/scripts/shell/ios_device_control.sh +220 -0
  40. package/scripts/shell/organize_project +0 -0
  41. package/scripts/shell/organize_project.sh +59 -0
  42. package/scripts/shell/pre-publish-check +0 -0
  43. package/scripts/shell/pre-publish-check.sh +238 -0
  44. package/scripts/shell/publish +0 -0
  45. package/scripts/shell/publish-to-npm +0 -0
  46. package/scripts/shell/publish-to-npm.sh +366 -0
  47. package/scripts/shell/publish.sh +100 -0
  48. package/scripts/shell/setup +0 -0
  49. package/scripts/shell/setup.sh +121 -0
  50. package/scripts/shell/setup_android +0 -0
  51. package/scripts/shell/start +0 -0
  52. package/scripts/shell/start.sh +59 -0
  53. package/scripts/shell/sync-to-npm-package-final +0 -0
  54. package/scripts/shell/sync-to-npm-package-final.sh +60 -0
  55. package/scripts/shell/test-local-package.sh +95 -0
  56. package/scripts/shell/test_android_locators +0 -0
  57. package/scripts/shell/test_connect +0 -0
  58. package/scripts/shell/test_device_detection +0 -0
  59. package/scripts/shell/test_fixes +0 -0
  60. package/scripts/shell/test_getlocators_fix +0 -0
  61. package/scripts/shell/test_recording_feature +0 -0
  62. package/scripts/shell/verify-shell-protection +0 -0
  63. package/scripts/shell/verify-shell-protection.sh +73 -0
  64. package/scripts/shell/verify_distribution +0 -0
  65. package/lib/package-lock.json +0 -1678
  66. package/lib/package.json +0 -30
  67. package/lib/screenshots/screenshot_ios_iPhone17_20260205_225900.png +0 -0
  68. package/lib/screenshots/screenshot_ios_iPhone17_20260205_225942.png +0 -0
  69. package/lib/screenshots/screenshot_ios_iPhone17_20260205_231101.png +0 -0
  70. package/lib/screenshots/screenshot_ios_iPhone17_20260205_232911.png +0 -0
  71. package/lib/screenshots/screenshot_ios_iPhone17_20260208_095103.png +0 -0
  72. package/lib/screenshots/screenshot_ios_iPhone17_20260208_095720.png +0 -0
  73. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115040.png +0 -0
  74. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115047.png +0 -0
  75. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115118.png +0 -0
  76. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115125.png +0 -0
  77. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_115143.png +0 -0
  78. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120107.png +0 -0
  79. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120118.png +0 -0
  80. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120137.png +0 -0
  81. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_120201.png +0 -0
  82. package/lib/screenshots/screenshot_ios_iPhoneXR17x_20260206_134529.png +0 -0
  83. package/scripts/shell/android_device_control.enc +0 -1
  84. package/scripts/shell/connect_android_usb_multi_final.enc +0 -1
  85. package/scripts/shell/connect_android_wireless.enc +0 -1
  86. package/scripts/shell/connect_android_wireless_multi_final.enc +0 -1
  87. package/scripts/shell/connect_ios_usb_multi_final.enc +0 -1
  88. package/scripts/shell/connect_ios_wireless_multi_final.enc +0 -1
  89. package/scripts/shell/ios_device_control.enc +0 -1
@@ -0,0 +1,238 @@
1
+ #!/bin/bash
2
+
3
+ ###############################################################################
4
+ # Pre-Publish Verification Script
5
+ # Ensures the npm package is ready for publishing with all protections applied
6
+ ###############################################################################
7
+
8
+ echo "🔍 Pre-Publish Verification Starting..."
9
+ echo ""
10
+
11
+ DIST_DIR="npm-package/dist"
12
+ ERRORS=0
13
+ WARNINGS=0
14
+
15
+ # Color codes
16
+ RED='\033[0;31m'
17
+ GREEN='\033[0;32m'
18
+ YELLOW='\033[1;33m'
19
+ BLUE='\033[0;34m'
20
+ NC='\033[0m' # No Color
21
+
22
+ # Check functions
23
+ check_pass() {
24
+ echo -e "${GREEN}✅ PASS${NC}: $1"
25
+ }
26
+
27
+ check_fail() {
28
+ echo -e "${RED}❌ FAIL${NC}: $1"
29
+ ((ERRORS++))
30
+ }
31
+
32
+ check_warn() {
33
+ echo -e "${YELLOW}⚠️ WARN${NC}: $1"
34
+ ((WARNINGS++))
35
+ }
36
+
37
+ check_info() {
38
+ echo -e "${BLUE}ℹ️ INFO${NC}: $1"
39
+ }
40
+
41
+ echo "═══════════════════════════════════════════════════════════════"
42
+ echo "1️⃣ Checking Distribution Directory"
43
+ echo "═══════════════════════════════════════════════════════════════"
44
+
45
+ if [ ! -d "$DIST_DIR" ]; then
46
+ check_fail "Distribution directory not found: $DIST_DIR"
47
+ echo ""
48
+ echo "Run: cd npm-package && npm run build:obfuscated"
49
+ exit 1
50
+ else
51
+ check_pass "Distribution directory exists"
52
+ fi
53
+
54
+ echo ""
55
+ echo "═══════════════════════════════════════════════════════════════"
56
+ echo "2️⃣ Verifying Package Structure"
57
+ echo "═══════════════════════════════════════════════════════════════"
58
+
59
+ # Required directories
60
+ for dir in "bin" "lib" "scripts" "config"; do
61
+ if [ -d "$DIST_DIR/$dir" ]; then
62
+ check_pass "Directory exists: $dir/"
63
+ else
64
+ check_fail "Missing directory: $dir/"
65
+ fi
66
+ done
67
+
68
+ # Required files
69
+ for file in "package.json" "README.md" "LICENSE"; do
70
+ if [ -f "$DIST_DIR/$file" ]; then
71
+ check_pass "File exists: $file"
72
+ else
73
+ check_fail "Missing file: $file"
74
+ fi
75
+ done
76
+
77
+ echo ""
78
+ echo "═══════════════════════════════════════════════════════════════"
79
+ echo "3️⃣ Verifying JavaScript Obfuscation"
80
+ echo "═══════════════════════════════════════════════════════════════"
81
+
82
+ # Check if JS files are obfuscated (should not contain readable comments/formatting)
83
+ js_count=$(find "$DIST_DIR/lib" -name "*.js" 2>/dev/null | wc -l | tr -d ' ')
84
+ check_info "Found $js_count JavaScript files"
85
+
86
+ # Sample a file to check obfuscation
87
+ if [ -f "$DIST_DIR/lib/server.js" ]; then
88
+ if head -5 "$DIST_DIR/lib/server.js" | grep -q "function\s\+[a-zA-Z_]" 2>/dev/null; then
89
+ check_warn "JavaScript files may not be fully obfuscated"
90
+ else
91
+ check_pass "JavaScript files appear obfuscated"
92
+ fi
93
+ fi
94
+
95
+ echo ""
96
+ echo "═══════════════════════════════════════════════════════════════"
97
+ echo "4️⃣ Verifying Shell Script Protection"
98
+ echo "═══════════════════════════════════════════════════════════════"
99
+
100
+ sh_count=$(find "$DIST_DIR/scripts/shell" -name "*.sh" 2>/dev/null | wc -l | tr -d ' ')
101
+ binary_count=$(find "$DIST_DIR/scripts/shell" -type f -perm +111 2>/dev/null | wc -l | tr -d ' ')
102
+
103
+ if [ "$sh_count" -eq 0 ]; then
104
+ check_pass "No .sh files in distribution (fully protected)"
105
+ else
106
+ check_fail "Found $sh_count .sh files (should be 0)"
107
+ fi
108
+
109
+ if [ "$binary_count" -gt 0 ]; then
110
+ check_pass "Found $binary_count compiled binary executables"
111
+ else
112
+ check_fail "No binary executables found"
113
+ fi
114
+
115
+ # Verify binaries are actually compiled
116
+ if [ "$binary_count" -gt 0 ]; then
117
+ sample_binary=$(find "$DIST_DIR/scripts/shell" -type f -perm +111 2>/dev/null | head -1)
118
+ if [ -n "$sample_binary" ]; then
119
+ if file "$sample_binary" | grep -q "executable"; then
120
+ check_pass "Binaries are properly compiled executables"
121
+ else
122
+ check_warn "Binaries may not be properly compiled"
123
+ fi
124
+ fi
125
+ fi
126
+
127
+ echo ""
128
+ echo "═══════════════════════════════════════════════════════════════"
129
+ echo "5️⃣ Checking Package.json"
130
+ echo "═══════════════════════════════════════════════════════════════"
131
+
132
+ if [ -f "$DIST_DIR/package.json" ]; then
133
+ # Check name
134
+ pkg_name=$(grep -o '"name":\s*"[^"]*"' "$DIST_DIR/package.json" | cut -d'"' -f4)
135
+ check_info "Package name: $pkg_name"
136
+
137
+ # Check version
138
+ pkg_version=$(grep -o '"version":\s*"[^"]*"' "$DIST_DIR/package.json" | cut -d'"' -f4)
139
+ check_info "Package version: $pkg_version"
140
+
141
+ # Check main entry
142
+ pkg_main=$(grep -o '"main":\s*"[^"]*"' "$DIST_DIR/package.json" | cut -d'"' -f4)
143
+ if [ -f "$DIST_DIR/$pkg_main" ]; then
144
+ check_pass "Main entry point exists: $pkg_main"
145
+ else
146
+ check_fail "Main entry point missing: $pkg_main"
147
+ fi
148
+
149
+ # Check bin entry
150
+ if grep -q '"bin"' "$DIST_DIR/package.json"; then
151
+ check_pass "Binary entry point defined"
152
+ else
153
+ check_warn "No binary entry point defined"
154
+ fi
155
+
156
+ # Check if devDependencies removed
157
+ if grep -q '"devDependencies"' "$DIST_DIR/package.json"; then
158
+ check_warn "devDependencies still present (should be removed)"
159
+ else
160
+ check_pass "devDependencies removed from distribution"
161
+ fi
162
+ fi
163
+
164
+ echo ""
165
+ echo "═══════════════════════════════════════════════════════════════"
166
+ echo "6️⃣ Checking for Sensitive Data"
167
+ echo "═══════════════════════════════════════════════════════════════"
168
+
169
+ # Check for .env files (should not be in distribution)
170
+ if find "$DIST_DIR" -name ".env*" 2>/dev/null | grep -q .; then
171
+ check_fail ".env files found in distribution"
172
+ else
173
+ check_pass "No .env files in distribution"
174
+ fi
175
+
176
+ # Check for real API keys in config files (not in obfuscated code)
177
+ if grep -r "OPENAI_API_KEY\s*=\s*['\"]sk-" "$DIST_DIR/config" 2>/dev/null >/dev/null; then
178
+ check_fail "Real API keys found in config files"
179
+ else
180
+ check_pass "No API keys in config files"
181
+ fi
182
+
183
+ echo ""
184
+ echo "═══════════════════════════════════════════════════════════════"
185
+ echo "7️⃣ Checking File Sizes"
186
+ echo "═══════════════════════════════════════════════════════════════"
187
+
188
+ total_size=$(du -sh "$DIST_DIR" 2>/dev/null | cut -f1)
189
+ check_info "Total package size: $total_size"
190
+
191
+ # Check if package is too large
192
+ size_bytes=$(du -sb "$DIST_DIR" 2>/dev/null | cut -f1)
193
+ if [ "$size_bytes" -gt 52428800 ]; then # 50MB
194
+ check_warn "Package size is large (>50MB). Consider optimization."
195
+ else
196
+ check_pass "Package size is reasonable"
197
+ fi
198
+
199
+ echo ""
200
+ echo "═══════════════════════════════════════════════════════════════"
201
+ echo "8️⃣ Testing Package Installation"
202
+ echo "═══════════════════════════════════════════════════════════════"
203
+
204
+ # Test if package.json is valid
205
+ if node -e "JSON.parse(require('fs').readFileSync('$DIST_DIR/package.json', 'utf8'))" 2>/dev/null; then
206
+ check_pass "package.json is valid JSON"
207
+ else
208
+ check_fail "package.json has JSON syntax errors"
209
+ fi
210
+
211
+ # Check if main entry can be required
212
+ if [ -f "$DIST_DIR/$pkg_main" ]; then
213
+ if node -e "require('$DIST_DIR/$pkg_main')" 2>/dev/null; then
214
+ check_pass "Main entry point can be loaded"
215
+ else
216
+ check_warn "Main entry point may have runtime issues"
217
+ fi
218
+ fi
219
+
220
+ echo ""
221
+ echo "═══════════════════════════════════════════════════════════════"
222
+ echo "📊 Summary"
223
+ echo "═══════════════════════════════════════════════════════════════"
224
+
225
+ if [ $ERRORS -eq 0 ] && [ $WARNINGS -eq 0 ]; then
226
+ echo -e "${GREEN}✅ All checks passed! Package is ready for publishing.${NC}"
227
+ echo ""
228
+ echo "📝 Next steps:"
229
+ echo " cd npm-package/dist"
230
+ echo " npm publish --access public"
231
+ exit 0
232
+ elif [ $ERRORS -eq 0 ]; then
233
+ echo -e "${YELLOW}⚠️ $WARNINGS warning(s) found. Review before publishing.${NC}"
234
+ exit 0
235
+ else
236
+ echo -e "${RED}❌ $ERRORS error(s) and $WARNINGS warning(s) found. Fix issues before publishing.${NC}"
237
+ exit 1
238
+ fi
Binary file
Binary file
@@ -0,0 +1,366 @@
1
+ #!/bin/bash
2
+
3
+ ###############################################################################
4
+ # NPM Publish Script
5
+ # Handles version bumping and publishing to NPM with full build pipeline
6
+ ###############################################################################
7
+
8
+ set -e
9
+
10
+ # Colors
11
+ RED='\033[0;31m'
12
+ GREEN='\033[0;32m'
13
+ YELLOW='\033[1;33m'
14
+ BLUE='\033[0;34m'
15
+ CYAN='\033[0;36m'
16
+ MAGENTA='\033[0;35m'
17
+ NC='\033[0m' # No Color
18
+
19
+ # Directories
20
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
21
+ NPM_PKG_DIR="$SCRIPT_DIR/npm-package"
22
+ DIST_DIR="$NPM_PKG_DIR/dist"
23
+
24
+ # Banner
25
+ echo -e "${CYAN}"
26
+ cat << "EOF"
27
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
28
+ ____ _ __
29
+ / __ \___ __ __(_)____ / /_ __
30
+ / / / / _ \ | | / / / ___/ / / / / /
31
+ / /_/ / __/ | |/ / / / / / /_/ /
32
+ \____/\___/ |___/_/_/ /_/\__, /
33
+ /____/
34
+
35
+ NPM PUBLISH AUTOMATION SCRIPT
36
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
37
+ EOF
38
+ echo -e "${NC}"
39
+
40
+ # Function to show usage
41
+ show_usage() {
42
+ echo -e "${YELLOW}Usage:${NC}"
43
+ echo " $0 [patch|minor|major] [--dry-run] [--skip-tests]"
44
+ echo ""
45
+ echo -e "${YELLOW}Version Types:${NC}"
46
+ echo " patch - Bug fixes (1.0.0 -> 1.0.1)"
47
+ echo " minor - New features (1.0.0 -> 1.1.0)"
48
+ echo " major - Breaking changes (1.0.0 -> 2.0.0)"
49
+ echo ""
50
+ echo -e "${YELLOW}Options:${NC}"
51
+ echo " --dry-run - Run without actually publishing"
52
+ echo " --skip-tests - Skip test validation"
53
+ echo ""
54
+ echo -e "${YELLOW}Examples:${NC}"
55
+ echo " $0 patch # Publish patch version"
56
+ echo " $0 minor # Publish minor version"
57
+ echo " $0 major # Publish major version"
58
+ echo " $0 patch --dry-run # Test the process without publishing"
59
+ exit 1
60
+ }
61
+
62
+ # Parse arguments
63
+ VERSION_TYPE=""
64
+ DRY_RUN=false
65
+ SKIP_TESTS=false
66
+
67
+ while [[ $# -gt 0 ]]; do
68
+ case $1 in
69
+ patch|minor|major)
70
+ VERSION_TYPE="$1"
71
+ shift
72
+ ;;
73
+ --dry-run)
74
+ DRY_RUN=true
75
+ shift
76
+ ;;
77
+ --skip-tests)
78
+ SKIP_TESTS=true
79
+ shift
80
+ ;;
81
+ -h|--help)
82
+ show_usage
83
+ ;;
84
+ *)
85
+ echo -e "${RED}❌ Unknown argument: $1${NC}"
86
+ show_usage
87
+ ;;
88
+ esac
89
+ done
90
+
91
+ # Validate version type
92
+ if [[ -z "$VERSION_TYPE" ]]; then
93
+ echo -e "${RED}❌ Error: Version type is required${NC}\n"
94
+ show_usage
95
+ fi
96
+
97
+ # Header
98
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
99
+ echo -e "${CYAN}📦 Publishing Devicely to NPM${NC}"
100
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
101
+ echo ""
102
+ echo -e "${YELLOW}Version Type:${NC} $VERSION_TYPE"
103
+ echo -e "${YELLOW}Dry Run:${NC} $DRY_RUN"
104
+ echo -e "${YELLOW}Skip Tests:${NC} $SKIP_TESTS"
105
+ echo ""
106
+
107
+ # Function to run step
108
+ run_step() {
109
+ local step_num=$1
110
+ local step_name=$2
111
+ local step_desc=$3
112
+
113
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
114
+ echo -e "${CYAN}Step $step_num: $step_name${NC}"
115
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
116
+ [[ -n "$step_desc" ]] && echo -e "${YELLOW}$step_desc${NC}"
117
+ }
118
+
119
+ # Step 1: Pre-flight checks
120
+ run_step 1 "Pre-flight Checks" "Verifying environment and dependencies"
121
+
122
+ # Check if npm is installed
123
+ if ! command -v npm &> /dev/null; then
124
+ echo -e "${RED}❌ npm is not installed${NC}"
125
+ exit 1
126
+ fi
127
+ echo -e "${GREEN}✅ npm found: $(npm --version)${NC}"
128
+
129
+ # Check if node is installed
130
+ if ! command -v node &> /dev/null; then
131
+ echo -e "${RED}❌ node is not installed${NC}"
132
+ exit 1
133
+ fi
134
+ echo -e "${GREEN}✅ node found: $(node --version)${NC}"
135
+
136
+ # Check if git is clean
137
+ if [[ -n $(git status --porcelain 2>/dev/null) ]]; then
138
+ echo -e "${YELLOW}⚠️ Warning: You have uncommitted changes${NC}"
139
+ read -p "Continue anyway? (y/N): " -n 1 -r
140
+ echo
141
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
142
+ echo -e "${RED}❌ Aborted${NC}"
143
+ exit 1
144
+ fi
145
+ fi
146
+
147
+ # Check NPM authentication
148
+ echo -e "\n${CYAN}Checking NPM authentication...${NC}"
149
+ if ! npm whoami &> /dev/null; then
150
+ echo -e "${RED}❌ You are not logged in to NPM${NC}"
151
+ echo -e "${YELLOW}Please run: npm login${NC}"
152
+ exit 1
153
+ fi
154
+ echo -e "${GREEN}✅ Logged in as: $(npm whoami)${NC}"
155
+
156
+ # Get current version
157
+ CURRENT_VERSION=$(node -p "require('$NPM_PKG_DIR/package.json').version")
158
+ echo -e "\n${CYAN}Current version:${NC} $CURRENT_VERSION"
159
+
160
+ # Calculate new version
161
+ case $VERSION_TYPE in
162
+ patch)
163
+ NEW_VERSION=$(npm version patch --no-git-tag-version --prefix "$NPM_PKG_DIR" 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "")
164
+ ;;
165
+ minor)
166
+ NEW_VERSION=$(npm version minor --no-git-tag-version --prefix "$NPM_PKG_DIR" 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "")
167
+ ;;
168
+ major)
169
+ NEW_VERSION=$(npm version major --no-git-tag-version --prefix "$NPM_PKG_DIR" 2>&1 | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' || echo "")
170
+ ;;
171
+ esac
172
+
173
+ # If npm version failed, calculate manually
174
+ if [[ -z "$NEW_VERSION" ]]; then
175
+ IFS='.' read -ra VERSION_PARTS <<< "$CURRENT_VERSION"
176
+ case $VERSION_TYPE in
177
+ patch)
178
+ NEW_VERSION="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.$((VERSION_PARTS[2] + 1))"
179
+ ;;
180
+ minor)
181
+ NEW_VERSION="${VERSION_PARTS[0]}.$((VERSION_PARTS[1] + 1)).0"
182
+ ;;
183
+ major)
184
+ NEW_VERSION="$((VERSION_PARTS[0] + 1)).0.0"
185
+ ;;
186
+ esac
187
+ # Update package.json manually
188
+ node -e "const pkg = require('$NPM_PKG_DIR/package.json'); pkg.version = '$NEW_VERSION'; require('fs').writeFileSync('$NPM_PKG_DIR/package.json', JSON.stringify(pkg, null, 2) + '\n');"
189
+ fi
190
+
191
+ echo -e "${GREEN}✅ New version:${NC} ${MAGENTA}$NEW_VERSION${NC}"
192
+ echo ""
193
+
194
+ # Confirmation
195
+ if [[ "$DRY_RUN" == false ]]; then
196
+ echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
197
+ echo -e "${YELLOW}⚠️ You are about to publish:${NC}"
198
+ echo -e "${YELLOW} Package: ${NC}${MAGENTA}devicely${NC}"
199
+ echo -e "${YELLOW} Version: ${NC}${MAGENTA}$CURRENT_VERSION → $NEW_VERSION${NC}"
200
+ echo -e "${YELLOW} Type: ${NC}${MAGENTA}$VERSION_TYPE${NC}"
201
+ echo -e "${YELLOW}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
202
+ read -p "Continue? (y/N): " -n 1 -r
203
+ echo
204
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
205
+ echo -e "${RED}❌ Aborted${NC}"
206
+ # Revert version change
207
+ node -e "const pkg = require('$NPM_PKG_DIR/package.json'); pkg.version = '$CURRENT_VERSION'; require('fs').writeFileSync('$NPM_PKG_DIR/package.json', JSON.stringify(pkg, null, 2) + '\n');"
208
+ exit 1
209
+ fi
210
+ fi
211
+
212
+ # Step 2: Sync changes to npm-package
213
+ run_step 2 "Sync Changes" "Syncing from main project to npm-package"
214
+ cd "$SCRIPT_DIR"
215
+ if [[ -f "./sync-to-npm-package.sh" ]]; then
216
+ echo -e "${CYAN}Running sync script...${NC}"
217
+ ./sync-to-npm-package.sh
218
+ echo -e "${GREEN}✅ Sync complete${NC}"
219
+ else
220
+ echo -e "${YELLOW}⚠️ No sync script found, skipping...${NC}"
221
+ fi
222
+
223
+ # Update version in npm-package after sync (in case sync overwrote it)
224
+ node -e "const pkg = require('$NPM_PKG_DIR/package.json'); pkg.version = '$NEW_VERSION'; require('fs').writeFileSync('$NPM_PKG_DIR/package.json', JSON.stringify(pkg, null, 2) + '\n');"
225
+
226
+ # Step 3: Run tests
227
+ if [[ "$SKIP_TESTS" == false ]]; then
228
+ run_step 3 "Run Tests" "Validating functionality"
229
+
230
+ # Check if test script exists
231
+ if [[ -f "$SCRIPT_DIR/test_fixes.sh" ]]; then
232
+ echo -e "${CYAN}Running tests...${NC}"
233
+ cd "$SCRIPT_DIR"
234
+ if ./test_fixes.sh > /dev/null 2>&1; then
235
+ echo -e "${GREEN}✅ Tests passed${NC}"
236
+ else
237
+ echo -e "${YELLOW}⚠️ Some tests may have failed, but continuing...${NC}"
238
+ fi
239
+ else
240
+ echo -e "${YELLOW}⚠️ No test script found, skipping...${NC}"
241
+ fi
242
+ else
243
+ echo -e "${YELLOW}⚠️ Skipping tests as requested${NC}"
244
+ fi
245
+
246
+ # Step 4: Build obfuscated package
247
+ run_step 4 "Build Package" "Building obfuscated distribution"
248
+
249
+ cd "$NPM_PKG_DIR"
250
+ echo -e "${CYAN}Running build:obfuscated...${NC}"
251
+ npm run build:obfuscated
252
+
253
+ if [[ ! -d "$DIST_DIR" ]]; then
254
+ echo -e "${RED}❌ Build failed: dist directory not found${NC}"
255
+ exit 1
256
+ fi
257
+ echo -e "${GREEN}✅ Build complete${NC}"
258
+
259
+ # Verify compiled scripts
260
+ SCRIPT_COUNT=$(ls -1 "$DIST_DIR/scripts/shell" 2>/dev/null | wc -l)
261
+ echo -e "${GREEN}✅ Shell scripts compiled: $SCRIPT_COUNT files${NC}"
262
+
263
+ # Step 5: Verify package contents
264
+ run_step 5 "Verify Package" "Checking package contents"
265
+
266
+ cd "$DIST_DIR"
267
+ echo -e "${CYAN}Package contents:${NC}"
268
+ echo " 📁 lib/ - $(find lib -type f | wc -l | tr -d ' ') files"
269
+ echo " 📁 bin/ - $(find bin -type f | wc -l | tr -d ' ') files"
270
+ echo " 📁 scripts/ - $(find scripts -type f | wc -l | tr -d ' ') files"
271
+ echo " 📁 config/ - $(find config -type f | wc -l | tr -d ' ') files"
272
+ echo " 📁 frontend/ - $(find frontend -type f | wc -l | tr -d ' ') files"
273
+
274
+ # Verify version in dist
275
+ DIST_VERSION=$(node -p "require('./package.json').version")
276
+ if [[ "$DIST_VERSION" != "$NEW_VERSION" ]]; then
277
+ echo -e "${YELLOW}⚠️ Version mismatch detected, fixing...${NC}"
278
+ node -e "const pkg = require('./package.json'); pkg.version = '$NEW_VERSION'; require('fs').writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');"
279
+ echo -e "${GREEN}✅ Version fixed: $NEW_VERSION${NC}"
280
+ else
281
+ echo -e "${GREEN}✅ Version verified: $NEW_VERSION${NC}"
282
+ fi
283
+
284
+ # Step 6: Test local installation (dry run)
285
+ run_step 6 "Test Installation" "Testing package locally"
286
+
287
+ echo -e "${CYAN}Creating test installation...${NC}"
288
+ TEST_DIR=$(mktemp -d)
289
+ cd "$TEST_DIR"
290
+
291
+ if npm pack "$DIST_DIR" > /dev/null 2>&1; then
292
+ PACKAGE_FILE=$(ls devicely-*.tgz)
293
+ echo -e "${GREEN}✅ Package created: $PACKAGE_FILE${NC}"
294
+
295
+ # Verify package size
296
+ SIZE=$(du -h "$PACKAGE_FILE" | cut -f1)
297
+ echo -e "${GREEN}✅ Package size: $SIZE${NC}"
298
+
299
+ # Clean up
300
+ rm -rf "$TEST_DIR"
301
+ else
302
+ echo -e "${RED}❌ Package creation failed${NC}"
303
+ rm -rf "$TEST_DIR"
304
+ exit 1
305
+ fi
306
+
307
+ # Step 7: Publish to NPM
308
+ if [[ "$DRY_RUN" == true ]]; then
309
+ run_step 7 "Dry Run Complete" "No changes were published"
310
+ echo -e "${GREEN}✅ Dry run completed successfully${NC}"
311
+ echo -e "${YELLOW}To publish for real, run without --dry-run flag${NC}"
312
+ else
313
+ run_step 7 "Publish to NPM" "Publishing package to registry"
314
+
315
+ cd "$DIST_DIR"
316
+ echo -e "${CYAN}Publishing to NPM...${NC}"
317
+
318
+ if npm publish --access public; then
319
+ echo -e "${GREEN}✅ Published successfully!${NC}"
320
+
321
+ # Step 8: Git tag and commit
322
+ run_step 8 "Git Operations" "Tagging and committing changes"
323
+
324
+ cd "$SCRIPT_DIR"
325
+
326
+ # Commit version change
327
+ git add "$NPM_PKG_DIR/package.json"
328
+ git commit -m "chore: bump version to $NEW_VERSION" || echo "No changes to commit"
329
+
330
+ # Create git tag
331
+ git tag -a "v$NEW_VERSION" -m "Release version $NEW_VERSION"
332
+ echo -e "${GREEN}✅ Created git tag: v$NEW_VERSION${NC}"
333
+
334
+ echo -e "\n${YELLOW}Don't forget to push:${NC}"
335
+ echo " git push origin main"
336
+ echo " git push origin v$NEW_VERSION"
337
+
338
+ # Step 9: Success summary
339
+ echo ""
340
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
341
+ echo -e "${GREEN}🎉 SUCCESS!${NC}"
342
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
343
+ echo ""
344
+ echo -e "${CYAN}Package published:${NC} ${MAGENTA}devicely@$NEW_VERSION${NC}"
345
+ echo -e "${CYAN}Registry:${NC} https://www.npmjs.com/package/devicely"
346
+ echo ""
347
+ echo -e "${YELLOW}Next steps:${NC}"
348
+ echo " 1. Push changes: git push origin main"
349
+ echo " 2. Push tag: git push origin v$NEW_VERSION"
350
+ echo " 3. Test installation: npm install -g devicely"
351
+ echo " 4. Verify: devicely --version"
352
+ echo " 5. Create GitHub release: https://github.com/sureshkumarm8/Devicely/releases/new"
353
+ echo ""
354
+ echo -e "${CYAN}Installation:${NC}"
355
+ echo " npm install -g devicely"
356
+ echo ""
357
+
358
+ else
359
+ echo -e "${RED}❌ Publish failed${NC}"
360
+ exit 1
361
+ fi
362
+ fi
363
+
364
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
365
+ echo -e "${GREEN}✨ All done!${NC}"
366
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"