diff --git a/code/utils/deploy-pokedex.js b/code/utils/deploy-pokedex.js index 600b15a..0d0cb4b 100644 --- a/code/utils/deploy-pokedex.js +++ b/code/utils/deploy-pokedex.js @@ -223,22 +223,24 @@ async function deploy() { 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}`); - + 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'); } - + // Use node-ssh with private key directly await ssh.connect({ host: sshConfig.host, @@ -253,13 +255,21 @@ async function deploy() { 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( + '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"`); + 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}`); } @@ -346,7 +356,7 @@ async function deploy() { // First transfer the dist directory console.log(' šŸ“¦ Transferring dist directory...'); - + // Count files for reporting let fileCount = 0; function countFiles(dir) { @@ -369,16 +379,16 @@ async function deploy() { // Transfer dist directory using rsync try { console.log(` šŸ“” Transferring dist directory via rsync...`); - + const { execSync } = await import('child_process'); const expandedKeyPath = expandTilde(sshConfig.privateKeyPath); - + // Use rsync with SSH for reliable transfer // Key options: // - IdentitiesOnly=yes: Only use specified key, not ssh-agent keys // - rsync-path: Ensure we use the correct rsync binary on remote const rsyncCmd = `rsync -av --delete -e "ssh -p ${sshConfig.port} -i ${expandedKeyPath} -o StrictHostKeyChecking=no -o IdentitiesOnly=yes" "${DIST_DIR}/" "${sshConfig.username}@${sshConfig.host}:${REMOTE_PATH}/dist/" --rsync-path="/usr/bin/rsync"`; - + try { execSync(rsyncCmd, { stdio: 'inherit', @@ -402,16 +412,16 @@ async function deploy() { // Use rsync for server files with exclusions try { console.log(` šŸ“” Transferring server files via rsync...`); - + const { execSync } = await import('child_process'); const expandedKeyPath = expandTilde(sshConfig.privateKeyPath); - + // Use rsync with SSH for reliable transfer and exclusions // Key options: // - IdentitiesOnly=yes: Only use specified key, not ssh-agent keys // - rsync-path: Ensure we use the correct rsync binary on remote const rsyncCmd = `rsync -av --delete --exclude='node_modules' --exclude='tests' --exclude='.git' --exclude='dist' --exclude='build' -e "ssh -p ${sshConfig.port} -i ${expandedKeyPath} -o StrictHostKeyChecking=no -o IdentitiesOnly=yes" "${serverDir}/" "${sshConfig.username}@${sshConfig.host}:${REMOTE_PATH}/server/" --rsync-path="/usr/bin/rsync"`; - + try { execSync(rsyncCmd, { stdio: 'inherit', @@ -461,9 +471,7 @@ async function deploy() { `Failed to transfer ${fileName}: ${catResult.stderr}` ); } - console.log( - ` āœ… ${fileName} (${fs.statSync(file.local).size} bytes)` - ); + console.log(` āœ… ${fileName} (${fs.statSync(file.local).size} bytes)`); } catch (error) { throw new Error(`Failed to transfer ${fileName}: ${error.message}`); } diff --git a/code/websites/pokedex.online/tests/unit/components/DeveloperTools.test.js b/code/websites/pokedex.online/tests/unit/components/DeveloperTools.test.js index 05ae014..c1fbc41 100644 --- a/code/websites/pokedex.online/tests/unit/components/DeveloperTools.test.js +++ b/code/websites/pokedex.online/tests/unit/components/DeveloperTools.test.js @@ -87,10 +87,10 @@ describe('DeveloperTools', () => { // Note: This test verifies the component structure, not actual NODE_ENV behavior // since process.env changes don't affect already-evaluated computed properties const wrapper = mount(DeveloperTools); - + // isAvailable is a computed property that exists expect(wrapper.vm.isAvailable).toBeDefined(); - + // In dev mode (which is what beforeEach sets), it should be true expect(wrapper.vm.isAvailable).toBe(true); }); diff --git a/test-ssh.js b/test-ssh.js index 2d80a64..b38a40f 100644 --- a/test-ssh.js +++ b/test-ssh.js @@ -22,7 +22,9 @@ const sshConfig = { }; console.log('šŸ”§ Testing SSH Connection\n'); -console.log(`šŸ“ Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}`); +console.log( + `šŸ“ Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}` +); console.log(`šŸ”‘ Key: ${keyPath}`); // Check key exists