Comparing version 11.1.1 to 12.0.0
@@ -29,2 +29,3 @@ "use strict"; | ||
const make_dir_1 = __importDefault(require("make-dir")); | ||
const is_stream_1 = __importDefault(require("is-stream")); | ||
const shell_escape_1 = __importDefault(require("shell-escape")); | ||
@@ -92,3 +93,3 @@ const sb_scandir_1 = __importDefault(require("sb-scandir")); | ||
await new Promise((resolve, reject) => { | ||
sftp.mkdir(path, err => { | ||
sftp.mkdir(path, (err) => { | ||
if (err) { | ||
@@ -262,3 +263,3 @@ reject(err); | ||
assert_1.default(options.cwd == null || typeof options.cwd === 'string', 'options.cwd must be a valid string'); | ||
assert_1.default(options.stdin == null || typeof options.stdin === 'string', 'options.stdin must be a valid string'); | ||
assert_1.default(options.stdin == null || typeof options.stdin === 'string' || is_stream_1.default.readable(options.stdin), 'options.stdin must be a valid string or readable stream'); | ||
assert_1.default(options.execOptions == null || typeof options.execOptions === 'object', 'options.execOptions must be a valid object'); | ||
@@ -294,7 +295,16 @@ assert_1.default(options.encoding == null || typeof options.encoding === 'string', 'options.encoding must be a valid string'); | ||
}); | ||
if (options.stdin) { | ||
channel.write(options.stdin); | ||
if (options.stdin != null) { | ||
if (is_stream_1.default.readable(options.stdin)) { | ||
options.stdin.pipe(channel, { | ||
end: true, | ||
}); | ||
} | ||
else { | ||
channel.write(options.stdin); | ||
channel.end(); | ||
} | ||
} | ||
// Close stdout: | ||
channel.end(); | ||
else { | ||
channel.end(); | ||
} | ||
let code = null; | ||
@@ -371,3 +381,3 @@ let signal = null; | ||
await new Promise((resolve, reject) => { | ||
sftp.fastGet(unixifyPath(remoteFile), localFile, transferOptions || {}, err => { | ||
sftp.fastGet(unixifyPath(remoteFile), localFile, transferOptions || {}, (err) => { | ||
if (err) { | ||
@@ -393,4 +403,4 @@ reject(err); | ||
assert_1.default(transferOptions == null || typeof transferOptions === 'object', 'transferOptions must be a valid object'); | ||
assert_1.default(await new Promise(resolve => { | ||
fs_1.default.access(localFile, fs_1.default.constants.R_OK, err => { | ||
assert_1.default(await new Promise((resolve) => { | ||
fs_1.default.access(localFile, fs_1.default.constants.R_OK, (err) => { | ||
resolve(err === null); | ||
@@ -402,3 +412,3 @@ }); | ||
return new Promise((resolve, reject) => { | ||
sftp.fastPut(localFile, unixifyPath(remoteFile), transferOptions || {}, err => { | ||
sftp.fastPut(localFile, unixifyPath(remoteFile), transferOptions || {}, (err) => { | ||
if (err == null) { | ||
@@ -439,3 +449,3 @@ resolve(); | ||
await new Promise((resolve, reject) => { | ||
files.forEach(file => { | ||
files.forEach((file) => { | ||
queue | ||
@@ -466,3 +476,3 @@ .add(async () => { | ||
assert_1.default(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string'); | ||
const localDirectoryStat = await new Promise(resolve => { | ||
const localDirectoryStat = await new Promise((resolve) => { | ||
fs_1.default.stat(localDirectory, (err, stat) => { | ||
@@ -479,4 +489,4 @@ resolve(stat || null); | ||
}); | ||
const files = scanned.files.map(item => path_1.default.relative(localDirectory, item)); | ||
const directories = scanned.directories.map(item => path_1.default.relative(localDirectory, item)); | ||
const files = scanned.files.map((item) => path_1.default.relative(localDirectory, item)); | ||
const directories = scanned.directories.map((item) => path_1.default.relative(localDirectory, item)); | ||
// Sort shortest to longest | ||
@@ -489,3 +499,3 @@ directories.sort((a, b) => a.length - b.length); | ||
const queue = new sb_promise_queue_1.PromiseQueue({ concurrency }); | ||
directories.forEach(directory => { | ||
directories.forEach((directory) => { | ||
queue | ||
@@ -502,3 +512,3 @@ .add(async () => { | ||
const queue = new sb_promise_queue_1.PromiseQueue({ concurrency }); | ||
files.forEach(file => { | ||
files.forEach((file) => { | ||
queue | ||
@@ -532,3 +542,3 @@ .add(async () => { | ||
assert_1.default(typeof remoteDirectory === 'string' && remoteDirectory, 'remoteDirectory must be a string'); | ||
const localDirectoryStat = await new Promise(resolve => { | ||
const localDirectoryStat = await new Promise((resolve) => { | ||
fs_1.default.stat(localDirectory, (err, stat) => { | ||
@@ -559,3 +569,3 @@ resolve(stat || null); | ||
else { | ||
resolve(res.map(item => item.filename)); | ||
resolve(res.map((item) => item.filename)); | ||
} | ||
@@ -580,4 +590,4 @@ }); | ||
}); | ||
const files = scanned.files.map(item => path_1.default.relative(remoteDirectory, item)); | ||
const directories = scanned.directories.map(item => path_1.default.relative(remoteDirectory, item)); | ||
const files = scanned.files.map((item) => path_1.default.relative(remoteDirectory, item)); | ||
const directories = scanned.directories.map((item) => path_1.default.relative(remoteDirectory, item)); | ||
// Sort shortest to longest | ||
@@ -590,3 +600,3 @@ directories.sort((a, b) => a.length - b.length); | ||
const queue = new sb_promise_queue_1.PromiseQueue({ concurrency }); | ||
directories.forEach(directory => { | ||
directories.forEach((directory) => { | ||
queue | ||
@@ -603,3 +613,3 @@ .add(async () => { | ||
const queue = new sb_promise_queue_1.PromiseQueue({ concurrency }); | ||
files.forEach(file => { | ||
files.forEach((file) => { | ||
queue | ||
@@ -606,0 +616,0 @@ .add(async () => { |
/// <reference types="node" /> | ||
import stream from 'stream'; | ||
import SSH2, { ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions, ShellOptions } from 'ssh2'; | ||
@@ -12,3 +13,3 @@ import { Prompt, TransferOptions } from 'ssh2-streams'; | ||
cwd?: string; | ||
stdin?: string; | ||
stdin?: string | stream.Readable; | ||
execOptions?: ExecOptions; | ||
@@ -15,0 +16,0 @@ encoding?: BufferEncoding; |
The MIT License (MIT) | ||
Copyright (c) 2014-2020 Steel Brain | ||
Copyright (c) 2014-2021 Steel Brain | ||
@@ -5,0 +5,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
{ | ||
"name": "node-ssh", | ||
"version": "11.1.1", | ||
"version": "12.0.0", | ||
"description": "SS2 with Promises", | ||
@@ -45,11 +45,12 @@ "main": "lib/cjs/index.js", | ||
"@types/shell-escape": "^0.2.0", | ||
"@types/ssh2": "^0.5.43", | ||
"ava": "^3.7.0", | ||
"eslint-config-steelbrain": "^9.0.1", | ||
"node-pty": "^0.9.0", | ||
"@types/ssh2": "^0.5.47", | ||
"ava": "^3.15.0", | ||
"eslint-config-steelbrain": "^11.0.0", | ||
"node-pty": "^0.10.1", | ||
"ssh2-streams": "^0.4.10", | ||
"ts-node": "^9.0.0", | ||
"typescript": "^4.0.3" | ||
"ts-node": "^10.1.0", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"is-stream": "^2.0.0", | ||
"make-dir": "^3.1.0", | ||
@@ -59,3 +60,3 @@ "sb-promise-queue": "^2.1.0", | ||
"shell-escape": "^0.2.0", | ||
"ssh2": "^0.8.9" | ||
"ssh2": "^1.1.0" | ||
}, | ||
@@ -74,4 +75,4 @@ "ava": { | ||
"engines": { | ||
"node": ">= 8" | ||
"node": ">= 10" | ||
} | ||
} |
@@ -102,2 +102,3 @@ Node-SSH - SSH2 with Promises | ||
// API reference in Typescript typing format: | ||
import stream from 'stream' | ||
import { Client, ConnectConfig, ClientChannel, SFTPWrapper, ExecOptions, PseudoTtyOptions | ShellOptions } from 'ssh2'; | ||
@@ -127,3 +128,3 @@ import { Prompt, TransferOptions } from 'ssh2-streams'; | ||
cwd?: string; | ||
stdin?: string; | ||
stdin?: string | stream.Readable; | ||
execOptions?: ExecOptions; | ||
@@ -245,5 +246,27 @@ encoding?: BufferEncoding; | ||
### Typescript support | ||
`node-ssh` requires extra dependencies while working under Typescript. Please install them as shown below | ||
``` | ||
yarn add --dev @types/ssh2 | ||
# OR | ||
npm install --save-dev @types/ssh2 | ||
``` | ||
If you're still running into issues, try adding these to your `tsconfig.json` | ||
```json | ||
{ | ||
"compilerOptions": { | ||
"moduleResolution": "node", | ||
"allowSyntheticDefaultImports": true | ||
} | ||
} | ||
``` | ||
### Keyboard-interactive user authentication | ||
In some cases you have to enable keyboard-interactive user authentication. Otherwise you will get an `All configured authentication methods failed` error. | ||
In some cases you have to enable keyboard-interactive user authentication. | ||
Otherwise you will get an `All configured authentication methods failed` error. | ||
@@ -250,0 +273,0 @@ #### Example: |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1303
304
66271
6
6
+ Addedis-stream@^2.0.0
+ Addedbuildcheck@0.0.6(transitive)
+ Addedcpu-features@0.0.10(transitive)
+ Addedis-stream@2.0.1(transitive)
+ Addednan@2.20.0(transitive)
+ Addedssh2@1.16.0(transitive)
- Removedssh2@0.8.9(transitive)
- Removedssh2-streams@0.4.10(transitive)
- Removedstreamsearch@0.1.2(transitive)
Updatedssh2@^1.1.0