🎨 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'); console.log('🚀 Starting Pokedex.Online deployment');
if (isLocal) { if (isLocal) {
console.log(`📡 Target: local`); console.log(`📡 Target: local`);
} else { } else {
console.log( console.log(
`📡 Target: ${config.target} (${sshConfig.host}:${sshConfig.port})` `📡 Target: ${config.target} (${sshConfig.host}:${sshConfig.port})`
); );
} }
console.log(`🔌 Frontend Port: ${config.port}`); console.log(`🔌 Frontend Port: ${config.port}`);
if (config.sslPort) { if (config.sslPort) {
@@ -229,59 +229,59 @@ async function deploy() {
// Connect to Synology using ~/.ssh/config // Connect to Synology using ~/.ssh/config
if (!isLocal) { if (!isLocal) {
console.log('\n🔐 Connecting to Synology...'); console.log('\n🔐 Connecting to Synology...');
const keyPath = expandTilde(sshConfig.privateKeyPath); const keyPath = expandTilde(sshConfig.privateKeyPath);
console.log(` 🔑 Using SSH key: ${keyPath}`); console.log(` 🔑 Using SSH key: ${keyPath}`);
console.log( console.log(
` 📍 Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}` ` 📍 Target: ${sshConfig.username}@${sshConfig.host}:${sshConfig.port}`
); );
// Verify key file exists // Verify key file exists
if (!fs.existsSync(keyPath)) { if (!fs.existsSync(keyPath)) {
throw new Error(`SSH key file not found: ${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 try {
await ssh.connect({ const privateKeyContent = fs.readFileSync(keyPath, 'utf8');
host: sshConfig.host, const keySize = privateKeyContent.length;
port: sshConfig.port, console.log(` 📂 Key file size: ${keySize} bytes`);
username: sshConfig.username,
privateKey: privateKeyContent, if (keySize === 0) {
readyTimeout: 60000, throw new Error('SSH key file is empty');
tryKeyboard: false }
});
console.log('✅ Connected successfully'); // Use node-ssh with private key directly
} catch (connError) { await ssh.connect({
console.error('\n❌ SSH Connection Failed'); host: sshConfig.host,
console.error(`Error: ${connError.message}`); port: sshConfig.port,
console.error('\nPossible causes:'); username: sshConfig.username,
console.error( privateKey: privateKeyContent,
'1. SSH public key not added to ~/.ssh/authorized_keys on the server' readyTimeout: 60000,
); tryKeyboard: false
console.error('2. SSH key has wrong permissions (should be 600)'); });
console.error('3. SSH user home directory permissions are wrong'); console.log('✅ Connected successfully');
console.error('\nVerify the key works manually:'); } catch (connError) {
console.error( console.error('\n❌ SSH Connection Failed');
` ssh -i ${keyPath} ${sshConfig.username}@${sshConfig.host} -p ${sshConfig.port} "whoami"` console.error(`Error: ${connError.message}`);
); console.error('\nPossible causes:');
console.error( console.error(
'\nIf that fails, the public key needs to be added on the server:' '1. SSH public key not added to ~/.ssh/authorized_keys on the server'
); );
console.error( console.error('2. SSH key has wrong permissions (should be 600)');
` 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('3. SSH user home directory permissions are wrong');
); console.error('\nVerify the key works manually:');
throw new Error(`SSH connection failed: ${connError.message}`); 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 // Build Vue 3 application
@@ -318,8 +318,8 @@ async function deploy() {
} }
if (isLocal) { if (isLocal) {
await deployLocal(config); await deployLocal(config);
return; return;
} }
// Check if container exists and capture current image // Check if container exists and capture current image
@@ -572,8 +572,8 @@ async function deploy() {
ssh.dispose(); ssh.dispose();
} catch (error) { } catch (error) {
if (config && config.target === 'local') { if (config && config.target === 'local') {
console.error('\n❌ Deployment failed:', error.message); console.error('\n❌ Deployment failed:', error.message);
process.exit(1); process.exit(1);
} }
console.error('\n❌ Deployment failed:', error.message); console.error('\n❌ Deployment failed:', error.message);