const ftp = require('basic-ftp'); const path = require('path'); const dotenv = require('dotenv'); dotenv.config(); async function deploy() { const client = new ftp.Client(); client.ftp.verbose = true; const config = { host: process.env.FTP_HOST || 'ka-el.fr', user: process.env.FTP_USER || 'antigravity@ka-el.fr', password: process.env.FTP_PASSWORD || 'dxr1yaor4i', port: parseInt(process.env.FTP_PORT || '21', 10), secure: false, // Set to true or 'implicit' if FTPS is enforced }; const localDistDir = path.join(__dirname, '..', 'dist'); const remoteTargetDir = process.env.FTP_REMOTE_DIR || '/'; console.log(`\nšŸš€ [Hostverge FTP Deploy] Connecting to ${config.host} as ${config.user}...`); try { await client.access({ host: config.host, user: config.user, password: config.password, port: config.port, secure: config.secure, }); console.log(`āœ… [FTP Connected] Uploading files from "${localDistDir}" to remote "${remoteTargetDir}"...`); // Ensure remote directory exists and upload full dist/ content await client.ensureDir(remoteTargetDir); await client.clearWorkingDir(); await client.uploadFromDir(localDistDir); console.log(`\nšŸŽ‰ [Success] Application successfully deployed to Hostverge (${config.host}) !\n`); } catch (err) { console.error(`\nāŒ [FTP Deploy Failed]:`, err); process.exit(1); } finally { client.close(); } } deploy();