UNPKG

ocr-click-plugin

Version:

An Appium plugin that uses OCR (Optical Character Recognition) to find and click text elements on mobile device screens with AI-powered screen analysis

54 lines (45 loc) 1.87 kB
#!/usr/bin/env node const { execSync } = require('child_process'); const fs = require('fs'); const path = require('path'); console.log('🔧 OCR Click Plugin: Setting up Sharp with compatibility fixes...'); try { // Set environment variables for Sharp installation process.env.SHARP_IGNORE_GLOBAL_LIBVIPS = '1'; process.env.npm_config_sharp_binary_host = 'https://github.com/lovell/sharp-libvips/releases/download'; process.env.npm_config_sharp_libvips_binary_host = 'https://github.com/lovell/sharp-libvips/releases/download'; console.log('📦 Installing Sharp with prebuilt binaries...'); // Try to install Sharp with environment variables execSync('npm install --include=optional sharp', { stdio: 'inherit', env: { ...process.env, SHARP_IGNORE_GLOBAL_LIBVIPS: '1' } }); console.log('✅ Sharp installation completed successfully!'); console.log('🎉 OCR Click Plugin is ready to use!'); } catch (error) { console.error('❌ Sharp installation failed. Trying alternative approach...'); try { // Fallback: Try with different flags execSync('npm install --no-optional sharp', { stdio: 'inherit', env: { ...process.env, SHARP_IGNORE_GLOBAL_LIBVIPS: '1', SHARP_FORCE_GLOBAL_LIBVIPS: '0' } }); console.log('✅ Sharp installation completed with fallback method!'); } catch (fallbackError) { console.error('❌ Sharp installation failed completely.'); console.error(''); console.error('🔧 Manual installation required:'); console.error(' Run: SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm install --include=optional sharp'); console.error(' Or visit: https://sharp.pixelplumbing.com/install'); console.error(''); console.error('Original error:', error.message); console.error('Fallback error:', fallbackError.message); } }