ssh-client-wrapper 2.12.4 → 2.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/dependabot.yml +11 -0
- package/.github/workflows/coverage_report.yml +3 -3
- package/.github/workflows/release.yml +29 -0
- package/.github/workflows/run_test.yml +7 -10
- package/.husky/_pre-commit +1 -0
- package/.husky/pre-commit +0 -3
- package/.releaserc.json +16 -0
- package/CHANGELOG.md +20 -0
- package/README.md +99 -0
- package/eslint.config.mjs +77 -102
- package/lib/fork.js +10 -14
- package/lib/index.js +23 -21
- package/lib/rsyncExec.js +13 -17
- package/lib/sshExec.js +15 -23
- package/lib/util.js +22 -36
- package/package.json +28 -25
- package/test/getSshOption.js +6 -6
- package/test/interface.js +30 -27
- package/test/rsyncExec.js +17 -17
- package/test/sanityCheck.js +6 -6
- package/test/sshExec.js +17 -13
- package/test/testUtil/hostInfo.js +1 -2
- package/test/testUtil/testFiles.js +16 -19
- package/.eslintrc.json +0 -34
- package/.github/workflows/npm_publish.yml +0 -22
- package/test/.eslintrc.json +0 -28
package/test/sshExec.js
CHANGED
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import path from "path";
|
|
2
|
+
import { fileURLToPath } from "url";
|
|
3
3
|
|
|
4
|
-
process.on("unhandledRejection", console.dir);
|
|
4
|
+
process.on("unhandledRejection", console.dir);
|
|
5
5
|
Error.traceLimit = 100000;
|
|
6
6
|
|
|
7
7
|
//setup test framework
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import * as chai from "chai";
|
|
9
|
+
import { expect } from "chai";
|
|
10
|
+
import sinon from "sinon";
|
|
11
|
+
import sinonChai from "sinon-chai";
|
|
12
|
+
import chaiAsPromised from "chai-as-promised";
|
|
13
|
+
chai.use(sinonChai);
|
|
14
|
+
chai.use(chaiAsPromised);
|
|
13
15
|
|
|
14
16
|
const sshout = sinon.stub();
|
|
15
17
|
|
|
16
18
|
//testee
|
|
17
|
-
|
|
19
|
+
import { sshExec, canConnect, disconnect } from "../lib/sshExec.js";
|
|
18
20
|
|
|
19
21
|
//test helpers
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
22
|
+
import hostInfo from "./testUtil/hostInfo.js";
|
|
23
|
+
import { clearRemoteTestFiles, clearLocalTestFiles, nonExisting } from "./testUtil/testFiles.js";
|
|
24
|
+
import { send } from "../lib/rsyncExec.js";
|
|
25
|
+
|
|
26
|
+
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
23
27
|
|
|
24
28
|
describe("test for ssh execution", function () {
|
|
25
29
|
const rcfilePath = "/home/testuser/testrc";
|
|
26
|
-
this.timeout(65000)
|
|
30
|
+
this.timeout(65000);
|
|
27
31
|
beforeEach(async ()=>{
|
|
28
32
|
sshout.reset();
|
|
29
33
|
await clearRemoteTestFiles(hostInfo);
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const path = require("path");
|
|
1
|
+
import fs from "fs-extra";
|
|
2
|
+
import path from "path";
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
import { sshExec } from "../../lib/sshExec.js";
|
|
6
5
|
|
|
7
6
|
/*
|
|
8
7
|
* test directory tree
|
|
@@ -50,7 +49,7 @@ const nonExisting = "ARSSH_nonExisting";
|
|
|
50
49
|
/**
|
|
51
50
|
*
|
|
52
51
|
*/
|
|
53
|
-
async function createLocalFiles() {
|
|
52
|
+
export async function createLocalFiles() {
|
|
54
53
|
const localDir2 = path.join(localRoot, "hoge");
|
|
55
54
|
const promises = [];
|
|
56
55
|
await fs.mkdir(localRoot);
|
|
@@ -65,7 +64,7 @@ async function createLocalFiles() {
|
|
|
65
64
|
/**
|
|
66
65
|
*
|
|
67
66
|
*/
|
|
68
|
-
async function clearLocalTestFiles() {
|
|
67
|
+
export async function clearLocalTestFiles() {
|
|
69
68
|
return fs.remove(localRoot);
|
|
70
69
|
}
|
|
71
70
|
|
|
@@ -73,7 +72,7 @@ async function clearLocalTestFiles() {
|
|
|
73
72
|
*
|
|
74
73
|
* @param hostInfo
|
|
75
74
|
*/
|
|
76
|
-
async function createRemoteFiles(hostInfo) {
|
|
75
|
+
export async function createRemoteFiles(hostInfo) {
|
|
77
76
|
//create remote files
|
|
78
77
|
await sshExec(hostInfo, `mkdir -p ${remoteRoot}/hoge`);
|
|
79
78
|
await sshExec(hostInfo, `mkdir -p ${remoteEmptyDir}`);
|
|
@@ -87,18 +86,16 @@ async function createRemoteFiles(hostInfo) {
|
|
|
87
86
|
*
|
|
88
87
|
* @param hostInfo
|
|
89
88
|
*/
|
|
90
|
-
async function clearRemoteTestFiles(hostInfo) {
|
|
89
|
+
export async function clearRemoteTestFiles(hostInfo) {
|
|
91
90
|
return sshExec(hostInfo, `rm -fr ${remoteRoot}`);
|
|
92
91
|
}
|
|
93
92
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
module.exports.remoteEmptyDir = remoteEmptyDir;
|
|
104
|
-
module.exports.remoteFiles = remoteFiles;
|
|
93
|
+
export {
|
|
94
|
+
localRoot,
|
|
95
|
+
localEmptyDir,
|
|
96
|
+
localFiles,
|
|
97
|
+
nonExisting,
|
|
98
|
+
remoteRoot,
|
|
99
|
+
remoteEmptyDir,
|
|
100
|
+
remoteFiles
|
|
101
|
+
};
|
package/.eslintrc.json
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"commonjs": true,
|
|
5
|
-
"es2021": true
|
|
6
|
-
},
|
|
7
|
-
"extends": ["standard"],
|
|
8
|
-
"overrides": [
|
|
9
|
-
{
|
|
10
|
-
"env": {
|
|
11
|
-
"node": true
|
|
12
|
-
},
|
|
13
|
-
"files": [
|
|
14
|
-
".eslintrc.{js,cjs}"
|
|
15
|
-
],
|
|
16
|
-
"parserOptions": {
|
|
17
|
-
"sourceType": "script"
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
],
|
|
21
|
-
"parserOptions": {
|
|
22
|
-
"ecmaVersion": "latest"
|
|
23
|
-
},
|
|
24
|
-
"rules": {
|
|
25
|
-
"semi": [
|
|
26
|
-
"error",
|
|
27
|
-
"always"
|
|
28
|
-
],
|
|
29
|
-
"quotes": [
|
|
30
|
-
"error",
|
|
31
|
-
"double"
|
|
32
|
-
]
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
name: publish npm package
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
tags:
|
|
5
|
-
- 'v*'
|
|
6
|
-
jobs:
|
|
7
|
-
test:
|
|
8
|
-
uses: ./.github/workflows/run_test.yml
|
|
9
|
-
publish-npm:
|
|
10
|
-
needs:
|
|
11
|
-
- test
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
steps:
|
|
14
|
-
- uses: actions/checkout@v3
|
|
15
|
-
- uses: actions/setup-node@v3
|
|
16
|
-
with:
|
|
17
|
-
node-version: 20
|
|
18
|
-
registry-url: https://registry.npmjs.org/
|
|
19
|
-
- run: npm ci
|
|
20
|
-
- run: npm publish
|
|
21
|
-
env:
|
|
22
|
-
NODE_AUTH_TOKEN: ${{ secrets.npm_token }}
|
package/test/.eslintrc.json
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"node": true,
|
|
4
|
-
"mocha": true,
|
|
5
|
-
"es6": true
|
|
6
|
-
},
|
|
7
|
-
"settings": {
|
|
8
|
-
"node": {
|
|
9
|
-
"allowModules": [
|
|
10
|
-
"chai",
|
|
11
|
-
"chai-fs",
|
|
12
|
-
"chai-as-promised",
|
|
13
|
-
"sinon",
|
|
14
|
-
"sinon-chai",
|
|
15
|
-
"fs-extra",
|
|
16
|
-
"rewire"
|
|
17
|
-
]
|
|
18
|
-
}
|
|
19
|
-
},
|
|
20
|
-
"plugins": [
|
|
21
|
-
"chai-expect",
|
|
22
|
-
"chai-friendly"
|
|
23
|
-
],
|
|
24
|
-
"rules": {
|
|
25
|
-
"no-unused-expressions": 0,
|
|
26
|
-
"chai-friendly/no-unused-expressions": 2
|
|
27
|
-
}
|
|
28
|
-
}
|