🎨 Adjust indentation and formatting for consistent code style in deployment script

This commit is contained in:
2026-01-30 04:58:32 +00:00
parent e472db461d
commit 61613ac7d5

View File

@@ -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);