Merge pull request #209 from easingthemes/refactor/remove-rsyncwrapper

feat!: replace rsyncwrapper with direct child_process.spawn
This commit is contained in:
Dragan Filipović
2026-04-02 23:20:52 +02:00
committed by GitHub
12 changed files with 106 additions and 38 deletions

View File

@@ -18,9 +18,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies

View File

@@ -31,11 +31,11 @@ jobs:
language: [ 'javascript' ]
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}
@@ -44,4 +44,4 @@ jobs:
npm run build --if-present
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4

View File

@@ -27,7 +27,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# ----------------------------------------------------------------
# START E2E Test Specific - steps

View File

@@ -15,7 +15,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# : ---------------------------------------------------------------
# : START E2E Test Specific - steps
@@ -111,7 +111,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
# : ---------------------------------------------------------------
# : START E2E Test Specific - steps

View File

@@ -49,9 +49,9 @@ jobs:
steps:
- name: Checkout repo
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix.NODE_VERSION }}
- name: Commit trigger
@@ -64,8 +64,9 @@ jobs:
- name: Run Tests
run: npm test --if-present
- name: Create a release - ${{ github.event.inputs.version }}
uses: cycjimmy/semantic-release-action@v4
uses: cycjimmy/semantic-release-action@v6
with:
semantic_version: 24
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
extra_plugins: |
@semantic-release/changelog

View File

@@ -16,9 +16,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@v6
with:
node-version: ${{ matrix['node-version'] }}
- name: Install dependencies
@@ -28,8 +28,9 @@ jobs:
- name: Run Tests
run: npm test --if-present
- name: Release
uses: cycjimmy/semantic-release-action@v4
uses: cycjimmy/semantic-release-action@v6
with:
semantic_version: 24
dry_run: false
extra_plugins: |
@semantic-release/changelog

23
.github/workflows/update-major-tag.yml vendored Normal file
View File

@@ -0,0 +1,23 @@
name: Update major version tag
on:
release:
types: [published]
jobs:
update-tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Update major version tag
run: |
VERSION="${{ github.event.release.tag_name }}"
MAJOR="v$(echo "$VERSION" | sed 's/^v//' | cut -d. -f1)"
echo "Updating $MAJOR tag to point to $VERSION"
git tag -f "$MAJOR" "$VERSION"
git push -f origin "$MAJOR"

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

28
package-lock.json generated
View File

@@ -1,16 +1,13 @@
{
"name": "@draganfilipovic/ssh-deploy",
"version": "4.1.10",
"version": "5.1.1",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "@draganfilipovic/ssh-deploy",
"version": "4.1.10",
"version": "5.1.1",
"license": "MIT",
"dependencies": {
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {
"@vercel/ncc": "^0.36.0",
"eslint": "^8.30.0",
@@ -129,6 +126,7 @@
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
"dev": true,
"peer": true,
"bin": {
"acorn": "bin/acorn"
},
@@ -459,6 +457,7 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
"dev": true,
"peer": true,
"dependencies": {
"@eslint/eslintrc": "^1.4.1",
"@humanwhocodes/config-array": "^0.11.8",
@@ -579,6 +578,7 @@
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
"dev": true,
"peer": true,
"dependencies": {
"array-includes": "^3.1.4",
"array.prototype.flat": "^1.2.5",
@@ -1698,14 +1698,6 @@
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/rsyncwrapper": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/rsyncwrapper/-/rsyncwrapper-3.0.1.tgz",
"integrity": "sha512-fkGmeEJRbKveT/6bBqTVzzHS1wtbGQwL6qnwT/+1AtMAsEV5dX1fSAiOJVZrDOnVsOr2lFl8ga1MZLoHekV3yg==",
"engines": {
"node": ">=8.1.3"
}
},
"node_modules/run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
@@ -2083,7 +2075,8 @@
"version": "8.8.1",
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
"dev": true
"dev": true,
"peer": true
},
"acorn-jsx": {
"version": "5.3.2",
@@ -2328,6 +2321,7 @@
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
"dev": true,
"peer": true,
"requires": {
"@eslint/eslintrc": "^1.4.1",
"@humanwhocodes/config-array": "^0.11.8",
@@ -2428,6 +2422,7 @@
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
"dev": true,
"peer": true,
"requires": {
"array-includes": "^3.1.4",
"array.prototype.flat": "^1.2.5",
@@ -3221,11 +3216,6 @@
"glob": "^7.1.3"
}
},
"rsyncwrapper": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/rsyncwrapper/-/rsyncwrapper-3.0.1.tgz",
"integrity": "sha512-fkGmeEJRbKveT/6bBqTVzzHS1wtbGQwL6qnwT/+1AtMAsEV5dX1fSAiOJVZrDOnVsOr2lFl8ga1MZLoHekV3yg=="
},
"run-parallel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",

View File

@@ -29,9 +29,6 @@
"url": "https://github.com/easingthemes/ssh-deploy/issues"
},
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
"dependencies": {
"rsyncwrapper": "^3.0.1"
},
"devDependencies": {
"@vercel/ncc": "^0.36.0",
"eslint": "^8.30.0",

56
src/rsync.js Normal file
View File

@@ -0,0 +1,56 @@
const { spawn } = require('child_process');
const escapeSpaces = (str) => (typeof str === 'string' ? str.replace(/\b\s/g, '\\ ') : str);
const buildRsyncCommand = ({ src, dest, excludeFirst, port, privateKey, args, sshCmdArgs }) => {
const cmdParts = [];
const sources = Array.isArray(src) ? src : [src];
cmdParts.push(...sources.map(escapeSpaces));
cmdParts.push(escapeSpaces(dest));
let sshCmd = `ssh -p ${port || 22} -i ${privateKey}`;
if (sshCmdArgs && sshCmdArgs.length > 0) {
sshCmd += ` ${sshCmdArgs.join(' ')}`;
}
cmdParts.push('--rsh', `"${sshCmd}"`);
cmdParts.push('--recursive');
if (Array.isArray(excludeFirst)) {
excludeFirst.forEach((pattern) => {
if (pattern) cmdParts.push(`--exclude=${escapeSpaces(pattern)}`);
});
}
if (Array.isArray(args)) {
cmdParts.push(...args);
}
return `rsync ${[...new Set(cmdParts)].join(' ')}`;
};
module.exports = (options, callback) => {
const cmd = buildRsyncCommand(options);
const noop = () => {};
const onStdout = options.onStdout || noop;
const onStderr = options.onStderr || noop;
let stdout = '';
let stderr = '';
const proc = spawn('/bin/sh', ['-c', cmd]);
proc.stdout.on('data', (data) => { onStdout(data); stdout += data; });
proc.stderr.on('data', (data) => { onStderr(data); stderr += data; });
proc.on('exit', (code) => {
let error = null;
if (code !== 0) {
error = new Error(`rsync exited with code ${code}`);
error.code = code;
}
callback(error, stdout, stderr, cmd);
});
proc.on('error', (err) => callback(err, stdout, stderr, cmd));
};

View File

@@ -1,5 +1,5 @@
const { execSync } = require('child_process');
const nodeRsync = require('rsyncwrapper');
const nodeRsync = require('./rsync');
const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
const logCMD = (cmd) => {