Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand All @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/e2e-manual.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# ----------------------------------------------------------------
# START E2E Test Specific - steps
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# : ---------------------------------------------------------------
# : START E2E Test Specific - steps
Expand Down Expand Up @@ -111,7 +111,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v6

# : ---------------------------------------------------------------
# : START E2E Test Specific - steps
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/manual-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
23 changes: 23 additions & 0 deletions .github/workflows/update-major-tag.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

28 changes: 9 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
56 changes: 56 additions & 0 deletions src/rsync.js
Original file line number Diff line number Diff line change
@@ -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));
};
2 changes: 1 addition & 1 deletion src/rsyncCli.js
Original file line number Diff line number Diff line change
@@ -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) => {
Expand Down
Loading