diff --git a/code/utils/deploy-pokedex.js b/code/utils/deploy-pokedex.js index 34b646a..c9fce2e 100644 --- a/code/utils/deploy-pokedex.js +++ b/code/utils/deploy-pokedex.js @@ -215,11 +215,11 @@ async function deploy() { console.log('šŸš€ Starting Pokedex.Online deployment'); if (isLocal) { - console.log(`šŸ“” Target: local`); + console.log(`šŸ“” Target: local`); } else { - console.log( + console.log( `šŸ“” Target: ${config.target} (${sshConfig.host}:${sshConfig.port})` - ); + ); } console.log(`šŸ”Œ Frontend Port: ${config.port}`); if (config.sslPort) { @@ -229,59 +229,59 @@ async function deploy() { // Connect to Synology using ~/.ssh/config if (!isLocal) { - console.log('\nšŸ” Connecting to Synology...'); + console.log('\nšŸ” Connecting to Synology...'); - const keyPath = expandTilde(sshConfig.privateKeyPath); - console.log(` šŸ”‘ Using SSH key: ${keyPath}`); - console.log( - ` šŸ“ Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}` - ); + const keyPath = expandTilde(sshConfig.privateKeyPath); + console.log(` šŸ”‘ Using SSH key: ${keyPath}`); + console.log( + ` šŸ“ Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}` + ); - // Verify key file exists - if (!fs.existsSync(keyPath)) { - throw new Error(`SSH key file not found: ${keyPath}`); - } - - try { - const privateKeyContent = fs.readFileSync(keyPath, 'utf8'); - const keySize = privateKeyContent.length; - console.log(` šŸ“‚ Key file size: ${keySize} bytes`); - - if (keySize === 0) { - throw new Error('SSH key file is empty'); + // Verify key file exists + if (!fs.existsSync(keyPath)) { + throw new Error(`SSH key file not found: ${keyPath}`); } - // Use node-ssh with private key directly - await ssh.connect({ - host: sshConfig.host, - port: sshConfig.port, - username: sshConfig.username, - privateKey: privateKeyContent, - readyTimeout: 60000, - tryKeyboard: false - }); - console.log('āœ… Connected successfully'); - } catch (connError) { - console.error('\nāŒ SSH Connection Failed'); - console.error(`Error: ${connError.message}`); - console.error('\nPossible causes:'); - console.error( - '1. SSH public key not added to ~/.ssh/authorized_keys on the server' - ); - console.error('2. SSH key has wrong permissions (should be 600)'); - console.error('3. SSH user home directory permissions are wrong'); - console.error('\nVerify the key works manually:'); - console.error( - ` ssh -i ${keyPath} ${sshConfig.username}@${sshConfig.host} -p ${sshConfig.port} "whoami"` - ); - console.error( - '\nIf that fails, the public key needs to be added on the server:' - ); - console.error( - ` cat ~/.ssh/${path.basename(keyPath)}.pub | ssh ${sshConfig.username}@${sshConfig.host} -p ${sshConfig.port} "cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"` - ); - throw new Error(`SSH connection failed: ${connError.message}`); - } + try { + const privateKeyContent = fs.readFileSync(keyPath, 'utf8'); + const keySize = privateKeyContent.length; + console.log(` šŸ“‚ Key file size: ${keySize} bytes`); + + if (keySize === 0) { + throw new Error('SSH key file is empty'); + } + + // Use node-ssh with private key directly + await ssh.connect({ + host: sshConfig.host, + port: sshConfig.port, + username: sshConfig.username, + privateKey: privateKeyContent, + readyTimeout: 60000, + tryKeyboard: false + }); + console.log('āœ… Connected successfully'); + } catch (connError) { + console.error('\nāŒ SSH Connection Failed'); + console.error(`Error: ${connError.message}`); + console.error('\nPossible causes:'); + console.error( + '1. SSH public key not added to ~/.ssh/authorized_keys on the server' + ); + console.error('2. SSH key has wrong permissions (should be 600)'); + console.error('3. SSH user home directory permissions are wrong'); + console.error('\nVerify the key works manually:'); + console.error( + ` ssh -i ${keyPath} ${sshConfig.username}@${sshConfig.host} -p ${sshConfig.port} "whoami"` + ); + console.error( + '\nIf that fails, the public key needs to be added on the server:' + ); + console.error( + ` cat ~/.ssh/${path.basename(keyPath)}.pub | ssh ${sshConfig.username}@${sshConfig.host} -p ${sshConfig.port} "cat >> ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys"` + ); + throw new Error(`SSH connection failed: ${connError.message}`); + } } // Build Vue 3 application @@ -318,8 +318,8 @@ async function deploy() { } if (isLocal) { - await deployLocal(config); - return; + await deployLocal(config); + return; } // Check if container exists and capture current image @@ -572,8 +572,8 @@ async function deploy() { ssh.dispose(); } catch (error) { if (config && config.target === 'local') { - console.error('\nāŒ Deployment failed:', error.message); - process.exit(1); + console.error('\nāŒ Deployment failed:', error.message); + process.exit(1); } console.error('\nāŒ Deployment failed:', error.message);