sftp-deploy-js
SFTP deployer using ssh2-sftp-client
Installation
npm install --save-dev sftp-deploy-js
Example
import { fileURLToPath } from 'url';
import path from 'path';
const __dirname = path.dirname(fileURLToPath(import.meta.url));
import Deployer from 'sftp-deploy-js';
const deployer = new Deployer();
const config = {
host: 'your host',
port: '22',
username: 'your username',
password: 'your password' || null,
from: path.join(__dirname, 'dist'),
to: '/path/on/server/',
rmdir: true,
};
await deployer.init(config);
deployer.on('upload', console.log);
let total = await deployer.deploy();
console.log(`Total files: ` + total);