Files
ssh-deploy/src/index.js
Dragan Filipovic c88faf5656 fix: upgrade devDependencies and migrate to eslint 10 flat config
- Upgrade eslint 8.31 → 10.1 with new flat config (eslint.config.js)
- Upgrade @vercel/ncc 0.36 → 0.38.4
- Replace eslint-config-airbnb-base + eslint-plugin-import with @eslint/js + @stylistic/eslint-plugin
- Remove stale overrides in package.json (word-wrap, semver)
- Remove obsolete eslint-disable comments from source files
- Add { cause } to rethrown error in rsyncCli.js
- Add .gitignore and CLAUDE.md
- Resolves all 3 npm audit vulnerabilities (flatted, minimatch, js-yaml)
2026-04-02 23:31:02 +02:00

48 lines
1.4 KiB
JavaScript

#!/usr/bin/env node
const { sshDeploy } = require('./rsyncCli');
const { remoteCmdBefore, remoteCmdAfter } = require('./remoteCmd');
const { addSshKey, getPrivateKeyPath, updateKnownHosts } = require('./sshKey');
const { validateRequiredInputs } = require('./helpers');
const inputs = require('./inputs');
const run = async () => {
const {
source, remoteUser, remoteHost, remotePort,
deployKeyName, sshPrivateKey,
args, exclude, sshCmdArgs,
scriptBefore, scriptBeforeRequired,
scriptAfter, scriptAfterRequired,
rsyncServer
} = inputs;
// Validate required inputs
validateRequiredInputs({ sshPrivateKey, remoteHost, remoteUser });
// Add SSH key
addSshKey(sshPrivateKey, deployKeyName);
const { path: privateKeyPath } = getPrivateKeyPath(deployKeyName);
// Update known hosts if ssh command is present to avoid prompt
if (scriptBefore || scriptAfter) {
updateKnownHosts(remoteHost, remotePort);
}
// Check Script before
if (scriptBefore) {
await remoteCmdBefore(scriptBefore, privateKeyPath, scriptBeforeRequired);
}
await sshDeploy({
source, rsyncServer, exclude, remotePort,
privateKeyPath, args, sshCmdArgs
});
// Check script after
if (scriptAfter) {
await remoteCmdAfter(scriptAfter, privateKeyPath, scriptAfterRequired);
}
};
run()
.then((data = '') => {
console.log('✅ [DONE]', data);
})
.catch((error) => {
console.error('❌ [ERROR]', error.message);
process.exit(1);
});