mirror of
https://github.com/easingthemes/ssh-deploy
synced 2026-04-06 12:53:02 +08:00
Merge pull request #209 from easingthemes/refactor/remove-rsyncwrapper
feat!: replace rsyncwrapper with direct child_process.spawn
This commit is contained in:
4
.github/workflows/build.yml
vendored
4
.github/workflows/build.yml
vendored
@@ -18,9 +18,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
- name: Setup Node.js ${{ matrix.node-version }}
|
- name: Setup Node.js ${{ matrix.node-version }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.node-version }}
|
node-version: ${{ matrix.node-version }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
|
|||||||
6
.github/workflows/codeql-analysis.yml
vendored
6
.github/workflows/codeql-analysis.yml
vendored
@@ -31,11 +31,11 @@ jobs:
|
|||||||
language: [ 'javascript' ]
|
language: [ 'javascript' ]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# Initializes the CodeQL tools for scanning.
|
# Initializes the CodeQL tools for scanning.
|
||||||
- name: Initialize CodeQL
|
- name: Initialize CodeQL
|
||||||
uses: github/codeql-action/init@v3
|
uses: github/codeql-action/init@v4
|
||||||
with:
|
with:
|
||||||
languages: ${{ matrix.language }}
|
languages: ${{ matrix.language }}
|
||||||
|
|
||||||
@@ -44,4 +44,4 @@ jobs:
|
|||||||
npm run build --if-present
|
npm run build --if-present
|
||||||
|
|
||||||
- name: Perform CodeQL Analysis
|
- name: Perform CodeQL Analysis
|
||||||
uses: github/codeql-action/analyze@v3
|
uses: github/codeql-action/analyze@v4
|
||||||
|
|||||||
2
.github/workflows/e2e-manual.yml
vendored
2
.github/workflows/e2e-manual.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# ----------------------------------------------------------------
|
# ----------------------------------------------------------------
|
||||||
# START E2E Test Specific - steps
|
# START E2E Test Specific - steps
|
||||||
|
|||||||
4
.github/workflows/e2e.yml
vendored
4
.github/workflows/e2e.yml
vendored
@@ -15,7 +15,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# : ---------------------------------------------------------------
|
# : ---------------------------------------------------------------
|
||||||
# : START E2E Test Specific - steps
|
# : START E2E Test Specific - steps
|
||||||
@@ -111,7 +111,7 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
# : ---------------------------------------------------------------
|
# : ---------------------------------------------------------------
|
||||||
# : START E2E Test Specific - steps
|
# : START E2E Test Specific - steps
|
||||||
|
|||||||
7
.github/workflows/manual-release.yml
vendored
7
.github/workflows/manual-release.yml
vendored
@@ -49,9 +49,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repo
|
- name: Checkout repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
|
- name: Setup Node.js ${{ matrix.NODE_VERSION }}
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix.NODE_VERSION }}
|
node-version: ${{ matrix.NODE_VERSION }}
|
||||||
- name: Commit trigger
|
- name: Commit trigger
|
||||||
@@ -64,8 +64,9 @@ jobs:
|
|||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: npm test --if-present
|
run: npm test --if-present
|
||||||
- name: Create a release - ${{ github.event.inputs.version }}
|
- name: Create a release - ${{ github.event.inputs.version }}
|
||||||
uses: cycjimmy/semantic-release-action@v4
|
uses: cycjimmy/semantic-release-action@v6
|
||||||
with:
|
with:
|
||||||
|
semantic_version: 24
|
||||||
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
|
dry_run: ${{ github.event.inputs.dryRun == 'true' }}
|
||||||
extra_plugins: |
|
extra_plugins: |
|
||||||
@semantic-release/changelog
|
@semantic-release/changelog
|
||||||
|
|||||||
7
.github/workflows/release.yml
vendored
7
.github/workflows/release.yml
vendored
@@ -16,9 +16,9 @@ jobs:
|
|||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v6
|
||||||
- name: Setup Node.js
|
- name: Setup Node.js
|
||||||
uses: actions/setup-node@v4
|
uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version: ${{ matrix['node-version'] }}
|
node-version: ${{ matrix['node-version'] }}
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
@@ -28,8 +28,9 @@ jobs:
|
|||||||
- name: Run Tests
|
- name: Run Tests
|
||||||
run: npm test --if-present
|
run: npm test --if-present
|
||||||
- name: Release
|
- name: Release
|
||||||
uses: cycjimmy/semantic-release-action@v4
|
uses: cycjimmy/semantic-release-action@v6
|
||||||
with:
|
with:
|
||||||
|
semantic_version: 24
|
||||||
dry_run: false
|
dry_run: false
|
||||||
extra_plugins: |
|
extra_plugins: |
|
||||||
@semantic-release/changelog
|
@semantic-release/changelog
|
||||||
|
|||||||
23
.github/workflows/update-major-tag.yml
vendored
Normal file
23
.github/workflows/update-major-tag.yml
vendored
Normal 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
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
28
package-lock.json
generated
28
package-lock.json
generated
@@ -1,16 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@draganfilipovic/ssh-deploy",
|
"name": "@draganfilipovic/ssh-deploy",
|
||||||
"version": "4.1.10",
|
"version": "5.1.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@draganfilipovic/ssh-deploy",
|
"name": "@draganfilipovic/ssh-deploy",
|
||||||
"version": "4.1.10",
|
"version": "5.1.1",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
|
||||||
"rsyncwrapper": "^3.0.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.36.0",
|
"@vercel/ncc": "^0.36.0",
|
||||||
"eslint": "^8.30.0",
|
"eslint": "^8.30.0",
|
||||||
@@ -129,6 +126,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||||
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
|
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"bin": {
|
"bin": {
|
||||||
"acorn": "bin/acorn"
|
"acorn": "bin/acorn"
|
||||||
},
|
},
|
||||||
@@ -459,6 +457,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
|
||||||
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
|
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@eslint/eslintrc": "^1.4.1",
|
"@eslint/eslintrc": "^1.4.1",
|
||||||
"@humanwhocodes/config-array": "^0.11.8",
|
"@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",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
||||||
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
|
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"array-includes": "^3.1.4",
|
"array-includes": "^3.1.4",
|
||||||
"array.prototype.flat": "^1.2.5",
|
"array.prototype.flat": "^1.2.5",
|
||||||
@@ -1698,14 +1698,6 @@
|
|||||||
"url": "https://github.com/sponsors/isaacs"
|
"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": {
|
"node_modules/run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||||
@@ -2083,7 +2075,8 @@
|
|||||||
"version": "8.8.1",
|
"version": "8.8.1",
|
||||||
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
"resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz",
|
||||||
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
|
"integrity": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==",
|
||||||
"dev": true
|
"dev": true,
|
||||||
|
"peer": true
|
||||||
},
|
},
|
||||||
"acorn-jsx": {
|
"acorn-jsx": {
|
||||||
"version": "5.3.2",
|
"version": "5.3.2",
|
||||||
@@ -2328,6 +2321,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
|
"resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz",
|
||||||
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
|
"integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"@eslint/eslintrc": "^1.4.1",
|
"@eslint/eslintrc": "^1.4.1",
|
||||||
"@humanwhocodes/config-array": "^0.11.8",
|
"@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",
|
"resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.26.0.tgz",
|
||||||
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
|
"integrity": "sha512-hYfi3FXaM8WPLf4S1cikh/r4IxnO6zrhZbEGz2b660EJRbuxgpDS5gkCuYgGWg2xxh2rBuIr4Pvhve/7c31koA==",
|
||||||
"dev": true,
|
"dev": true,
|
||||||
|
"peer": true,
|
||||||
"requires": {
|
"requires": {
|
||||||
"array-includes": "^3.1.4",
|
"array-includes": "^3.1.4",
|
||||||
"array.prototype.flat": "^1.2.5",
|
"array.prototype.flat": "^1.2.5",
|
||||||
@@ -3221,11 +3216,6 @@
|
|||||||
"glob": "^7.1.3"
|
"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": {
|
"run-parallel": {
|
||||||
"version": "1.2.0",
|
"version": "1.2.0",
|
||||||
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
"resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.2.0.tgz",
|
||||||
|
|||||||
@@ -29,9 +29,6 @@
|
|||||||
"url": "https://github.com/easingthemes/ssh-deploy/issues"
|
"url": "https://github.com/easingthemes/ssh-deploy/issues"
|
||||||
},
|
},
|
||||||
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
|
"homepage": "https://github.com/easingthemes/ssh-deploy#readme",
|
||||||
"dependencies": {
|
|
||||||
"rsyncwrapper": "^3.0.1"
|
|
||||||
},
|
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@vercel/ncc": "^0.36.0",
|
"@vercel/ncc": "^0.36.0",
|
||||||
"eslint": "^8.30.0",
|
"eslint": "^8.30.0",
|
||||||
|
|||||||
56
src/rsync.js
Normal file
56
src/rsync.js
Normal 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));
|
||||||
|
};
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
const nodeRsync = require('rsyncwrapper');
|
const nodeRsync = require('./rsync');
|
||||||
|
|
||||||
const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
|
const nodeRsyncPromise = async (config) => new Promise((resolve, reject) => {
|
||||||
const logCMD = (cmd) => {
|
const logCMD = (cmd) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user