mirror of
https://github.com/easingthemes/ssh-deploy
synced 2026-06-03 00:59:40 +08:00
Compare commits
9 Commits
v5.1.2
...
refactor/r
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
0e75a8e721 | ||
|
|
aea56817cd | ||
|
|
a4b077c853 | ||
|
|
33880d2926 | ||
|
|
c81b43c5bf | ||
|
|
71b8eb300f | ||
|
|
76668b2cd6 | ||
|
|
be39df3f93 | ||
|
|
b11fb7f911 |
25
.eslintrc.js
25
.eslintrc.js
@@ -1,25 +0,0 @@
|
|||||||
module.exports = {
|
|
||||||
env: {
|
|
||||||
commonjs: true,
|
|
||||||
es6: true,
|
|
||||||
node: true
|
|
||||||
},
|
|
||||||
extends: [
|
|
||||||
'airbnb-base'
|
|
||||||
],
|
|
||||||
globals: {
|
|
||||||
Atomics: 'readonly',
|
|
||||||
SharedArrayBuffer: 'readonly'
|
|
||||||
},
|
|
||||||
parserOptions: {
|
|
||||||
ecmaVersion: 2018
|
|
||||||
},
|
|
||||||
rules: {
|
|
||||||
'comma-dangle': [
|
|
||||||
'error',
|
|
||||||
'never'
|
|
||||||
],
|
|
||||||
'no-console': 'off',
|
|
||||||
'object-curly-newline': 'off'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
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
52
eslint.config.js
Normal file
52
eslint.config.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
const js = require('@eslint/js');
|
||||||
|
const stylistic = require('@stylistic/eslint-plugin');
|
||||||
|
const globals = require('globals');
|
||||||
|
|
||||||
|
module.exports = [
|
||||||
|
js.configs.recommended,
|
||||||
|
{
|
||||||
|
plugins: {
|
||||||
|
'@stylistic': stylistic
|
||||||
|
},
|
||||||
|
languageOptions: {
|
||||||
|
ecmaVersion: 2020,
|
||||||
|
sourceType: 'commonjs',
|
||||||
|
globals: {
|
||||||
|
...globals.node,
|
||||||
|
...globals.commonjs,
|
||||||
|
...globals.es2020,
|
||||||
|
Atomics: 'readonly',
|
||||||
|
SharedArrayBuffer: 'readonly'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
// Stylistic rules (migrated from airbnb-base)
|
||||||
|
'@stylistic/comma-dangle': ['error', 'never'],
|
||||||
|
'@stylistic/indent': ['error', 2, { SwitchCase: 1 }],
|
||||||
|
'@stylistic/semi': ['error', 'always'],
|
||||||
|
'@stylistic/quotes': ['error', 'single', { avoidEscape: true }],
|
||||||
|
'@stylistic/arrow-parens': ['error', 'always'],
|
||||||
|
'@stylistic/brace-style': ['error', '1tbs', { allowSingleLine: true }],
|
||||||
|
'@stylistic/comma-spacing': ['error', { before: false, after: true }],
|
||||||
|
'@stylistic/key-spacing': ['error', { beforeColon: false, afterColon: true }],
|
||||||
|
'@stylistic/keyword-spacing': ['error', { before: true, after: true }],
|
||||||
|
'@stylistic/eol-last': ['error', 'always'],
|
||||||
|
'@stylistic/no-trailing-spaces': 'error',
|
||||||
|
'@stylistic/space-before-blocks': 'error',
|
||||||
|
'@stylistic/space-infix-ops': 'error',
|
||||||
|
'@stylistic/arrow-spacing': ['error', { before: true, after: true }],
|
||||||
|
|
||||||
|
// JS rules (migrated from airbnb-base)
|
||||||
|
'no-console': 'off',
|
||||||
|
'no-var': 'error',
|
||||||
|
'prefer-const': 'error',
|
||||||
|
'prefer-arrow-callback': 'error',
|
||||||
|
'prefer-template': 'error',
|
||||||
|
'object-shorthand': ['error', 'always'],
|
||||||
|
'no-shadow': 'error',
|
||||||
|
'no-use-before-define': ['error', { functions: true, classes: true, variables: true }],
|
||||||
|
'camelcase': ['error', { properties: 'never' }],
|
||||||
|
'no-unused-vars': ['error', { vars: 'all', args: 'after-used', ignoreRestSiblings: true }]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
3207
package-lock.json
generated
3207
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -29,17 +29,11 @@
|
|||||||
"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",
|
"@eslint/js": "^10.0.1",
|
||||||
"eslint": "^8.30.0",
|
"@stylistic/eslint-plugin": "^5.10.0",
|
||||||
"eslint-config-airbnb-base": "^15.0.0",
|
"@vercel/ncc": "^0.38.4",
|
||||||
"eslint-plugin-import": "^2.26.0"
|
"eslint": "^10.1.0",
|
||||||
},
|
"globals": "^17.4.0"
|
||||||
"overrides": {
|
|
||||||
"word-wrap": "npm:@aashutoshrathi/word-wrap@1.2.5",
|
|
||||||
"semver": "^7.5.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ const run = async () => {
|
|||||||
if (scriptBefore) {
|
if (scriptBefore) {
|
||||||
await remoteCmdBefore(scriptBefore, privateKeyPath, scriptBeforeRequired);
|
await remoteCmdBefore(scriptBefore, privateKeyPath, scriptBeforeRequired);
|
||||||
}
|
}
|
||||||
/* eslint-disable object-property-newline */
|
|
||||||
await sshDeploy({
|
await sshDeploy({
|
||||||
source, rsyncServer, exclude, remotePort,
|
source, rsyncServer, exclude, remotePort,
|
||||||
privateKeyPath, args, sshCmdArgs
|
privateKeyPath, args, sshCmdArgs
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ inputNames.forEach((input) => {
|
|||||||
const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName];
|
const inputVal = process.env[input] || process.env[`INPUT_${input}`] || defaultInputs[inputName];
|
||||||
const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal;
|
const validVal = inputVal === undefined ? defaultInputs[inputName] : inputVal;
|
||||||
let extendedVal = validVal;
|
let extendedVal = validVal;
|
||||||
// eslint-disable-next-line default-case
|
|
||||||
switch (inputName) {
|
switch (inputName) {
|
||||||
case 'source':
|
case 'source':
|
||||||
extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`);
|
extendedVal = validVal.split(' ').map((src) => `${githubWorkspace}/${src}`);
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ const handleError = (message, isRequired, callback) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// eslint-disable-next-line max-len
|
|
||||||
const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Promise((resolve, reject) => {
|
const remoteCmd = async (content, privateKeyPath, isRequired, label) => new Promise((resolve, reject) => {
|
||||||
const uuid = crypto.randomUUID();
|
const uuid = crypto.randomUUID();
|
||||||
const filename = `local_ssh_script-${label}-${uuid}.sh`;
|
const filename = `local_ssh_script-${label}-${uuid}.sh`;
|
||||||
|
|||||||
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) => {
|
||||||
@@ -46,7 +46,7 @@ const validateRsync = async () => {
|
|||||||
execSync('sudo DEBIAN_FRONTEND=noninteractive apt-get -y update && sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install rsync', { stdio: 'inherit' });
|
execSync('sudo DEBIAN_FRONTEND=noninteractive apt-get -y update && sudo DEBIAN_FRONTEND=noninteractive apt-get --no-install-recommends -y install rsync', { stdio: 'inherit' });
|
||||||
console.log('✅ [CLI] Rsync installed. \n');
|
console.log('✅ [CLI] Rsync installed. \n');
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
throw new Error(`⚠️ [CLI] Rsync installation failed. Aborting ... error: ${error.message}`);
|
throw new Error(`⚠️ [CLI] Rsync installation failed. Aborting ... error: ${error.message}`, { cause: error });
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -65,7 +65,6 @@ const rsyncCli = async ({
|
|||||||
};
|
};
|
||||||
|
|
||||||
// RSYNC COMMAND
|
// RSYNC COMMAND
|
||||||
/* eslint-disable object-property-newline */
|
|
||||||
return nodeRsyncPromise({
|
return nodeRsyncPromise({
|
||||||
...defaultOptions,
|
...defaultOptions,
|
||||||
src: source, dest: rsyncServer, excludeFirst: exclude, port: remotePort,
|
src: source, dest: rsyncServer, excludeFirst: exclude, port: remotePort,
|
||||||
|
|||||||
Reference in New Issue
Block a user