ssh-client-wrapper 2.2.3 → 2.2.4

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/.dockerignore CHANGED
@@ -1 +1,2 @@
1
1
  node_modules
2
+ run_test_all.sh
package/.eslintrc.json CHANGED
@@ -1,163 +1,34 @@
1
1
  {
2
- "root": true,
3
- "extends": [
4
- "eslint"
5
- ],
6
- "plugins": [
7
- "node",
8
- "jsdoc"
9
- ],
10
2
  "env": {
11
- "node": true,
12
- "es6": true
3
+ "browser": true,
4
+ "commonjs": true,
5
+ "es2021": true
13
6
  },
14
- "rules": {
15
- "no-param-reassign": "warn",
16
- "arrow-parens": [
17
- "error",
18
- "always"
19
- ],
20
- "arrow-body-style": [
21
- "error",
22
- "always"
23
- ],
24
- "arrow-spacing": [
25
- "error",
26
- {
27
- "before": false,
28
- "after": false
29
- }
30
- ],
31
- "camelcase": [
32
- "error",
33
- {
34
- "properties": "never"
35
- }
36
- ],
37
- "eqeqeq": [
38
- "error",
39
- "always",
40
- {
41
- "null": "ignore"
42
- }
43
- ],
44
- "func-style": [
45
- "error",
46
- "declaration",
47
- {
48
- "allowArrowFunctions": true
49
- }
50
- ],
51
- "indent": [
52
- "error",
53
- 2,
54
- {
55
- "SwitchCase": 1
56
- }
57
- ],
58
- "lines-around-comment": [
59
- "error",
60
- {
61
- "beforeBlockComment": true,
62
- "beforeLineComment": false
63
- }
64
- ],
65
- "lines-between-class-members": [
66
- "error",
67
- "always",
68
- {
69
- "exceptAfterSingleLine": true
70
- }
71
- ],
72
- "newline-per-chained-call": "error",
73
- "no-use-before-define": [
74
- "error",
75
- {
76
- "functions": false
77
- }
78
- ],
79
- "no-warning-comments": "warn",
80
- "padded-blocks": [
81
- "error",
82
- "never"
83
- ],
84
- "padding-line-between-statements": [
85
- "error",
86
- {
87
- "blankLine": "any",
88
- "prev": [
89
- "const",
90
- "let",
91
- "var"
92
- ],
93
- "next": "*"
7
+ "extends": ["standard"],
8
+ "overrides": [
9
+ {
10
+ "env": {
11
+ "node": true
94
12
  },
95
- {
96
- "blankLine": "always",
97
- "prev": "*",
98
- "next": [
99
- "block-like",
100
- "class",
101
- "do",
102
- "for",
103
- "function",
104
- "multiline-block-like",
105
- "switch",
106
- "try",
107
- "while"
108
- ]
109
- },
110
- {
111
- "blankLine": "any",
112
- "prev": [
113
- "const",
114
- "let",
115
- "var",
116
- "for",
117
- "while",
118
- "do",
119
- "block-like",
120
- "multiline-block-like"
121
- ],
122
- "next": [
123
- "block-like",
124
- "do",
125
- "for",
126
- "multiline-block-like",
127
- "switch",
128
- "try",
129
- "while"
130
- ]
13
+ "files": [
14
+ ".eslintrc.{js,cjs}"
15
+ ],
16
+ "parserOptions": {
17
+ "sourceType": "script"
131
18
  }
132
- ],
133
- "spaced-comment": [
134
- "error",
135
- "never"
136
- ],
137
- "node/exports-style": [
138
- "error",
139
- "module.exports"
140
- ],
141
- "require-unicode-regexp": "off",
142
- "node/no-unsupported-features": [
19
+ }
20
+ ],
21
+ "parserOptions": {
22
+ "ecmaVersion": "latest"
23
+ },
24
+ "rules": {
25
+ "semi": [
143
26
  "error",
144
- {
145
- "version": 10
146
- }
147
- ],
148
- "jsdoc/require-hyphen-before-param-description": [
149
- "warn",
150
27
  "always"
151
28
  ],
152
- "jsdoc/newline-after-description": "off",
153
- "jsdoc/require-param-description": "warn",
154
- "jsdoc/require-param-name": "warn",
155
- "jsdoc/require-param-type": "warn",
156
- "jsdoc/require-jsdoc": "off",
157
- "jsdoc/require-param": "off",
158
- "jsdoc/require-returns": "off"
159
- },
160
- "parserOptions": {
161
- "ecmaVersion": 2018
29
+ "quotes": [
30
+ "error",
31
+ "double"
32
+ ]
162
33
  }
163
34
  }
package/Dockerfile CHANGED
@@ -1,9 +1,7 @@
1
1
  # syntax=docker/dockerfile:1
2
- FROM --platform=linux/amd64 node:hydrogen-bookworm-slim
3
- #FROM --platform=linux/amd64 node:hydrogen-bullseye-slim
4
- #FROM --platform=linux/amd64 node:hydrogen-buster-slim
2
+ FROM --platform=linux/amd64 node:20-bookworm-slim
5
3
 
6
- WORKDIR /work
4
+ WORKDIR /work/ssh-client-wrapper
7
5
  RUN apt-get update && apt -y install ssh rsync bzip2 python3 g++ build-essential
8
- COPY ./ ssh-client-wrapper
9
- RUN cd ssh-client-wrapper && npm install
6
+ COPY ./ ./
7
+ RUN npm install
@@ -0,0 +1,7 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM --platform=linux/amd64 node:20-bookworm-slim
3
+
4
+ WORKDIR /work/ssh-client-wrapper
5
+ RUN apt-get update && apt -y install ssh rsync bzip2 python3 g++ build-essential
6
+ COPY ./ ./
7
+ RUN npm install
@@ -0,0 +1,7 @@
1
+ # syntax=docker/dockerfile:1
2
+ FROM --platform=linux/amd64 node:20-bookworm-slim
3
+
4
+ WORKDIR /work/ssh-client-wrapper
5
+ RUN apt-get update && apt -y install ssh rsync bzip2 python3 g++ build-essential
6
+ COPY ./ ./
7
+ RUN npm install
package/README.md CHANGED
@@ -4,9 +4,3 @@
4
4
  [![Maintainability](https://api.codeclimate.com/v1/badges/8f3c0ea00e755ae31081/maintainability)](https://codeclimate.com/github/so5/ssh-client-wrapper/maintainability)
5
5
  # ssh-client-wrapper
6
6
  open ssh client wrapper library for nodejs
7
-
8
-
9
- # how to test on local machine
10
- ```
11
- docker-compose up --build
12
- ```
@@ -1,9 +1,9 @@
1
1
  version: "3.8"
2
2
  services:
3
- test-bed:
3
+ testbed:
4
4
  image: naoso5/test-sshd
5
5
  ports:
6
- - 4000:22
6
+ - "4000:22"
7
7
  container_name: testbed
8
8
  tester:
9
9
  build:
@@ -14,4 +14,24 @@ services:
14
14
  TEST_PW: passw0rd
15
15
  TEST_HOST: testbed
16
16
  working_dir: /work/ssh-client-wrapper
17
- command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run test"
17
+ command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
18
+ tester-bullseye:
19
+ build:
20
+ context: .
21
+ dockerfile: Dockerfile-bullseye
22
+ environment:
23
+ TEST_USER: testuser
24
+ TEST_PW: passw0rd
25
+ TEST_HOST: testbed
26
+ working_dir: /work/ssh-client-wrapper
27
+ command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
28
+ tester-buster:
29
+ build:
30
+ context: .
31
+ dockerfile: Dockerfile-buster
32
+ environment:
33
+ TEST_USER: testuser
34
+ TEST_PW: passw0rd
35
+ TEST_HOST: testbed
36
+ working_dir: /work/ssh-client-wrapper
37
+ command: bash -c "mkdir /root/.ssh 2>/dev/null; npm run mocha"
package/lib/index.js CHANGED
@@ -67,8 +67,6 @@ class SshClientWrapper {
67
67
  * @param {Integer} timeout - timeout in secconds
68
68
  * @param { Function } outputCallback - call back routine for output
69
69
  * @returns {Integer} - Return code of cmd.
70
- *
71
- * If stdout and stderr is array, last 5 line of stdout and stderr is stored in them.
72
70
  */
73
71
  async exec(cmd, timeout = 0, outputCallback = null) {
74
72
  debug("exec called", cmd);
@@ -92,33 +90,6 @@ class SshClientWrapper {
92
90
  return ls(this.hostInfo, target, lsOpt, timeout);
93
91
  }
94
92
 
95
- /**
96
- * Execute command repeatedly until specified keyword is found in stdout and/or stderr.
97
- * @param {string} cmd - Cmdline which will be executed.
98
- * @param {RegExp} regexp - End condition.
99
- * @param {number} retryDelay - Duration between each try (in sec).
100
- * @param {number} maxRetry - Max retry count.
101
- * @returns {Integer} - Return code of cmd.
102
- */
103
- async watch(cmd, regexp, retryDelay = 3, maxRetry = null) {
104
- debug("watch called", cmd, regexp, retryDelay, maxRetry);
105
-
106
- if (typeof cmd !== "string") {
107
- return logAndReject("cmd must be string");
108
- }
109
- if (!(regexp instanceof RegExp)) {
110
- const err = new Error("illegal regexp specified");
111
- err.regexp = regexp;
112
- err.cmd = cmd;
113
- err.retryDelay = retryDelay;
114
- err.maxRetry = maxRetry;
115
- return Promise.reject(new Error("err"));
116
- }
117
- //not implemented yet !!!
118
- return this.exec(cmd, ()=>{
119
- });
120
- }
121
-
122
93
  /**
123
94
  * Send file or directory and its child to server.
124
95
  * @param {string[]} src - File or directory name which to be recieve.
package/lib/util.js CHANGED
@@ -74,7 +74,10 @@ const buff2String = (func, data)=>{
74
74
  */
75
75
  const sanityCheck = (hostInfo)=>{
76
76
  debug("sanityCheck called", hostInfo);
77
- //keep password, passphrase, and masterPty
77
+ //keep password, passphrase, and masterPty before validate.
78
+ //these properties can have invalid value for JSON.
79
+ //ajv will remove that at validation pahse becase of additionalProperties setting
80
+ //so we keep them here and put back later.
78
81
  const { password, passphrase, masterPty } = hostInfo;
79
82
  validate(hostInfo);
80
83
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ssh-client-wrapper",
3
- "version": "2.2.3",
3
+ "version": "2.2.4",
4
4
  "description": "wrapper library for open ssh client and rsync",
5
5
  "keywords": [
6
6
  "ssh",
@@ -47,17 +47,19 @@
47
47
  "chai-fs": "^2.0.0",
48
48
  "eslint": "^8.38.0",
49
49
  "eslint-config-eslint": "^7.0.0",
50
+ "eslint-config-standard": "^17.1.0",
50
51
  "eslint-plugin-chai-expect": "^3.0.0",
51
- "eslint-plugin-chai-friendly": "^0.7.2",
52
- "eslint-plugin-jsdoc": "^43.0.6",
53
- "eslint-plugin-node": "^11.1.0",
52
+ "eslint-plugin-chai-friendly": "^0.7.4",
53
+ "eslint-plugin-import": "^2.29.1",
54
+ "eslint-plugin-n": "^16.6.2",
55
+ "eslint-plugin-promise": "^6.1.1",
54
56
  "fs-extra": "^11.1.1",
55
57
  "husky": "^8.0.0",
56
58
  "lint-staged": "^13.2.1",
57
59
  "mocha": "^10.2.0",
58
- "sinon": "^15.0.3",
59
- "rewire": "^7.0.0",
60
60
  "nyc": "^15.1.0",
61
+ "rewire": "^7.0.0",
62
+ "sinon": "^15.0.3",
61
63
  "sinon-chai": "^3.7.0"
62
64
  }
63
65
  }
@@ -0,0 +1,11 @@
1
+ #!/bin/bash
2
+ docker-compose up testbed -d
3
+ export TEST_HOST=localhost
4
+ export TEST_USER=testuser
5
+ export TEST_PW=passw0rd
6
+ export TEST_PORT=4000
7
+ npm run test
8
+ docker-compose run --build --rm tester &&
9
+ docker-compose run --build --rm tester-bullseye &&
10
+ docker-compose run --build --rm tester-buster &&
11
+ docker-compose rm --stop --force testbed
package/test/interface.js CHANGED
@@ -42,7 +42,6 @@ describe("test for interface", ()=>{
42
42
  it("should successfully instanciate only with host prop", ()=>{
43
43
  expect(new SshClientWrapper({ host: "hoge" })).to.have.property("exec");
44
44
  expect(new SshClientWrapper({ host: "hoge" })).to.have.property("ls");
45
- expect(new SshClientWrapper({ host: "hoge" })).to.have.property("watch");
46
45
  expect(new SshClientWrapper({ host: "hoge" })).to.have.property("send");
47
46
  expect(new SshClientWrapper({ host: "hoge" })).to.have.property("recv");
48
47
  expect(new SshClientWrapper({ host: "hoge" })).to.have.property("canConnect");