50 lines
1.4 KiB
JavaScript
50 lines
1.4 KiB
JavaScript
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();
|