🛠️ Improve code readability by reformatting console logs and removing unnecessary whitespace
This commit is contained in:
@@ -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}`);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user