scp-next 1.0.19 → 1.0.20

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/README.md CHANGED
@@ -19,25 +19,26 @@
19
19
  It uses SFTP internally through `ssh2-sftp-client` instead of implementing SCP or SFTP protocols manually.
20
20
  Developer documentation is available at [GitHub Pages](https://chengchuu.github.io/scp-next/).
21
21
 
22
+ ## Features
23
+
24
+ - Upload and download files or directories recursively.
25
+ - CLI usage with clear `<source> <destination>` operands.
26
+ - ESM `import` and CommonJS `require` support.
27
+ - JSON configuration files, named profiles, and configured jobs.
28
+ - Reusable transfer client.
29
+
22
30
  ## Contents
23
31
 
24
32
  - [Installation](#installation)
25
33
  - [Quick Start](#quick-start)
26
- - [Basic Usage](#basic-usage)
34
+ - [CLI Usage](#cli-usage)
27
35
  - [CLI Options](#cli-options)
28
36
  - [Library Usage](#library-usage)
29
37
  - [Library Options](#library-options)
30
38
  - [Advanced Usage](#advanced-usage)
31
39
  - [Configuration File Options](#configuration-file-options)
32
40
  - [Environment Variables](#environment-variables)
33
-
34
- ## Features
35
-
36
- - Upload and download files or directories recursively.
37
- - CLI usage with clear `<source> <destination>` operands.
38
- - ESM `import` and CommonJS `require` support.
39
- - JSON configuration files, named profiles, and configured jobs.
40
- - Reusable transfer client.
41
+ - [User Guides](#user-guides)
41
42
 
42
43
  ## Installation
43
44
 
@@ -99,7 +100,7 @@ await upload({
99
100
  });
100
101
  ```
101
102
 
102
- ## Basic Usage
103
+ ## CLI Usage
103
104
 
104
105
  ### CLI Syntax
105
106
 
@@ -292,26 +293,26 @@ await upload({
292
293
 
293
294
  ### Library Options
294
295
 
295
- | Field | Used by | Description |
296
- | ------------------- | ----------------- | ------------------------------------------------------------ |
297
- | `host` | server | SSH server host. |
298
- | `port` | server | SSH server port. Defaults to `22`. |
299
- | `username` | server | SSH username. |
300
- | `password` | server | SSH password. |
301
- | `privateKey` | server | Private-key content as a string or Buffer. |
302
- | `privateKeyFile` | server | Private-key file path. |
303
- | `passphrase` | server | Passphrase for an encrypted private key. |
304
- | `agent` | server | SSH agent socket path. |
305
- | `hostFingerprint` | server | Expected server host-key SHA-256 fingerprint. |
306
- | `knownHostsFile` | server | Known-hosts file for host verification. |
307
- | `localPath` | upload/download | Local source for upload or local destination for download. |
308
- | `remotePath` | upload/download | Remote destination for upload or remote source for download. |
309
- | `recursive` | transfer | Transfer directories recursively. Defaults to `false`. |
310
- | `overwrite` | transfer | Allow replacing existing files. |
311
- | `createDirectories` | transfer | Create missing destination directories. Defaults to `true`. |
312
- | `dryRun` | transfer | Validate and plan without modifying local or remote files. |
313
- | `timeout` | server/transfer | SSH connection ready timeout in milliseconds. |
314
- | `onProgress` | transfer | Progress callback for file and directory transfers. |
296
+ | Field | Used by | Description |
297
+ | ------------------- | --------------- | ------------------------------------------------------------ |
298
+ | `host` | server | SSH server host. |
299
+ | `port` | server | SSH server port. Defaults to `22`. |
300
+ | `username` | server | SSH username. |
301
+ | `password` | server | SSH password. |
302
+ | `privateKey` | server | Private-key content as a string or Buffer. |
303
+ | `privateKeyFile` | server | Private-key file path. |
304
+ | `passphrase` | server | Passphrase for an encrypted private key. |
305
+ | `agent` | server | SSH agent socket path. |
306
+ | `hostFingerprint` | server | Expected server host-key SHA-256 fingerprint. |
307
+ | `knownHostsFile` | server | Known-hosts file for host verification. |
308
+ | `localPath` | upload/download | Local source for upload or local destination for download. |
309
+ | `remotePath` | upload/download | Remote destination for upload or remote source for download. |
310
+ | `recursive` | transfer | Transfer directories recursively. Defaults to `false`. |
311
+ | `overwrite` | transfer | Allow replacing existing files. |
312
+ | `createDirectories` | transfer | Create missing destination directories. Defaults to `true`. |
313
+ | `dryRun` | transfer | Validate and plan without modifying local or remote files. |
314
+ | `timeout` | server/transfer | SSH connection ready timeout in milliseconds. |
315
+ | `onProgress` | transfer | Progress callback for file and directory transfers. |
315
316
 
316
317
  ## Advanced Usage
317
318
 
@@ -590,6 +591,11 @@ copy(options: CopyOptions): Promise<void>
590
591
  Upload and download APIs use explicit `localPath` and `remotePath` names.
591
592
  The optional generic `copy()` API accepts typed local/remote endpoint objects.
592
593
 
594
+ ## User Guides
595
+
596
+ - [English](https://github.com/chengchuu/scp-next/blob/main/docs/release-notes/introducing-scp-next-v1.0.19-en.md)
597
+ - [简体中文](https://github.com/chengchuu/scp-next/blob/main/docs/release-notes/introducing-scp-next-v1.0.19-zh.md)
598
+
593
599
  ## Development
594
600
 
595
601
  ```bash
@@ -0,0 +1,347 @@
1
+ # Introducing scp-next v1.0.19: An SSH File Transfer Tool for Node.js Developers
2
+
3
+ ![scp-next](http://blog.mazey.net/wp-content/uploads/2026/07/scp-next-SF-s7x3.jpg)
4
+
5
+ Learn how to install `scp-next` from npm, use the CLI for uploads and downloads, configure reusable jobs, handle credentials safely, call the library API, and onboard a new engineer quickly.
6
+
7
+ - [Introduction](#introduction)
8
+ - [Who Should Use It](#who-should-use-it)
9
+ - [Installation](#installation)
10
+ - [Understand Transfer Direction First](#understand-transfer-direction-first)
11
+ - [CLI Quick Start](#cli-quick-start)
12
+ - [Recommended Credential Patterns](#recommended-credential-patterns)
13
+ - [Common CLI Options](#common-cli-options)
14
+ - [Configuration Files](#configuration-files)
15
+ - [Library API Usage](#library-api-usage)
16
+ - [Host Verification](#host-verification)
17
+ - [New Engineer Checklist](#new-engineer-checklist)
18
+
19
+ ## Introduction
20
+
21
+ `scp-next` is an SCP-style npm package. It provides both a command-line tool and a library for secure file transfers over SSH. Although the package name includes SCP, normal transfers use SFTP internally through `ssh2-sftp-client`, so regular transfers do not execute remote shell commands.
22
+
23
+ ## Who Should Use It
24
+
25
+ Use `scp-next` when you need file transfers in deployment scripts, CI workflows, or Node.js applications. Common use cases include:
26
+
27
+ - Uploading local build output to a server.
28
+ - Downloading logs or generated artifacts from a server.
29
+ - Managing different server environments with configuration files.
30
+ - Reusing one transfer client across multiple operations in application code.
31
+
32
+ `scp-next` requires Node.js 18.18.0 or later.
33
+
34
+ ## Installation
35
+
36
+ Install it globally when you want to call the `scp-next` command directly.
37
+
38
+ ```bash
39
+ npm install --global scp-next
40
+ ```
41
+
42
+ Install it as a project dependency when you want to import the API from Node.js code.
43
+
44
+ ```bash
45
+ npm install scp-next
46
+ ```
47
+
48
+ If a project only needs the CLI in scripts, you can also install it locally and call it with `npx scp-next` or through npm scripts.
49
+
50
+ ## Understand Transfer Direction First
51
+
52
+ The CLI always uses two positional operands: `<source> <destination>`.
53
+
54
+ ```text
55
+ scp-next upload <source> <destination> [options]
56
+ scp-next download <source> <destination> [options]
57
+ scp-next run <job> [source] [destination] [options]
58
+ ```
59
+
60
+ The direction rules are:
61
+
62
+ | Operation | Source | Destination |
63
+ | --------- | ------ | ----------- |
64
+ | Upload | Local | Remote |
65
+ | Download | Remote | Local |
66
+
67
+ The programmatic API does not use `<source>` and `<destination>`. Upload and download options use `localPath` and `remotePath`, which keeps local and remote paths explicit in application code.
68
+
69
+ ## CLI Quick Start
70
+
71
+ Upload a local directory to a remote server.
72
+
73
+ ```bash
74
+ scp-next upload ./dist /var/www/example \
75
+ --host your-host \
76
+ --username your-username \
77
+ --password your-password \
78
+ --recursive
79
+ ```
80
+
81
+ Download a remote file to a local path.
82
+
83
+ ```bash
84
+ scp-next download /var/log/example.log ./logs/example.log \
85
+ --host your-host \
86
+ --username your-username \
87
+ --password your-password
88
+ ```
89
+
90
+ If the destination directory does not exist, `scp-next` creates it by default. This matches familiar `cp` and `scp` behavior for day-to-day use. Use `--no-create-directories` to disable automatic destination directory creation.
91
+
92
+ Preview an upload plan without connecting to the server.
93
+
94
+ ```bash
95
+ scp-next upload ./dist /var/www/example \
96
+ --host your-host \
97
+ --username your-username \
98
+ --password your-password \
99
+ --recursive \
100
+ --dry-run
101
+ ```
102
+
103
+ `--dry-run` resolves configuration and validates local paths. It does not connect to the remote server, and it does not modify local or remote files.
104
+
105
+ ## Recommended Credential Patterns
106
+
107
+ Password arguments are convenient for local trials.
108
+
109
+ ```bash
110
+ scp-next upload ./dist /var/www/example \
111
+ --host your-host \
112
+ --username your-username \
113
+ --password your-password \
114
+ --recursive
115
+ ```
116
+
117
+ For shared or production environments, prefer environment variables. This lowers the risk of exposing passwords through shell history or process listings.
118
+
119
+ ```bash
120
+ export SCP_NEXT_HOST="your-host"
121
+ export SCP_NEXT_USERNAME="your-username"
122
+ export SCP_NEXT_PASSWORD="your-password"
123
+
124
+ scp-next upload ./dist /var/www/example --recursive
125
+ ```
126
+
127
+ You can also use a protected private-key file.
128
+
129
+ ```bash
130
+ scp-next upload ./dist /var/www/example \
131
+ --host your-host \
132
+ --username your-username \
133
+ --private-key-file ~/.ssh/id_ed25519 \
134
+ --recursive
135
+ ```
136
+
137
+ If your environment already uses SSH agent authentication, add the key first and let `scp-next` use `SSH_AUTH_SOCK`.
138
+
139
+ ```bash
140
+ ssh-add ~/.ssh/id_ed25519
141
+
142
+ export SCP_NEXT_HOST="your-host"
143
+ export SCP_NEXT_USERNAME="your-username"
144
+
145
+ scp-next upload ./dist /var/www/example --recursive
146
+ ```
147
+
148
+ ## Common CLI Options
149
+
150
+ | Option | Description |
151
+ | ------------------------------------- | ---------------------------------------------------------------------- |
152
+ | `--host <host>` | SSH server host. |
153
+ | `--port <port>` | SSH server port. Defaults to `22`. |
154
+ | `--username <username>` | SSH username. |
155
+ | `--password <password>` | SSH password. |
156
+ | `--private-key-file <privateKeyFile>` | Private-key file path. Supports `~` expansion. |
157
+ | `--passphrase <passphrase>` | Passphrase for an encrypted private key. |
158
+ | `--config <path>` | Explicit configuration file path. |
159
+ | `--profile <name>` | Named server profile from the configuration file. |
160
+ | `--recursive` | Transfer directories recursively. Defaults to `false`. |
161
+ | `--overwrite` | Allow replacing existing destination files. |
162
+ | `--create-directories` | Create missing destination directories. Enabled by default. |
163
+ | `--no-create-directories` | Disable automatic destination directory creation. |
164
+ | `--dry-run` | Resolve and validate the operation without connecting or transferring. |
165
+ | `--timeout <milliseconds>` | SSH connection ready timeout in milliseconds. |
166
+ | `--quiet` | Disable progress and non-error output. |
167
+ | `--verbose` | Print non-sensitive diagnostic details. |
168
+
169
+ `--timeout` maps to the SSH `readyTimeout`. It controls how long to wait for the connection handshake, not the duration of each file transfer or the whole transfer run.
170
+
171
+ ## Configuration Files
172
+
173
+ The CLI automatically searches for these configuration files.
174
+
175
+ ```text
176
+ scp-next.config.json
177
+ .scp-nextrc
178
+ .scp-nextrc.json
179
+ ```
180
+
181
+ You can also pass an explicit path.
182
+
183
+ ```bash
184
+ scp-next upload ./dist /var/www/example \
185
+ --config ./scp-next.config.json \
186
+ --profile production
187
+ ```
188
+
189
+ The example below defines a server profile and two reusable jobs.
190
+
191
+ ```json
192
+ {
193
+ "profiles": {
194
+ "production": {
195
+ "host": "your-host",
196
+ "username": "your-username",
197
+ "privateKeyFile": "~/.ssh/id_ed25519"
198
+ }
199
+ },
200
+ "jobs": {
201
+ "deploy": {
202
+ "operation": "upload",
203
+ "profile": "production",
204
+ "source": "./dist",
205
+ "destination": "/var/www/example",
206
+ "recursive": true,
207
+ "overwrite": true
208
+ },
209
+ "download-logs": {
210
+ "operation": "download",
211
+ "profile": "production",
212
+ "source": "/var/log/example",
213
+ "destination": "./logs",
214
+ "recursive": true
215
+ }
216
+ }
217
+ }
218
+ ```
219
+
220
+ Run the configured upload job.
221
+
222
+ ```bash
223
+ scp-next run deploy
224
+ ```
225
+
226
+ Run the configured download job.
227
+
228
+ ```bash
229
+ scp-next run download-logs
230
+ ```
231
+
232
+ The `run` command also supports temporary path overrides.
233
+
234
+ ```bash
235
+ scp-next run deploy ./dist-canary /var/www/canary
236
+ ```
237
+
238
+ Configuration precedence, from highest to lowest, is:
239
+
240
+ 1. Explicit CLI options
241
+ 2. Positional CLI operands
242
+ 3. Environment variables
243
+ 4. Selected configuration profile
244
+ 5. Root-level configuration values
245
+ 6. Configured job values
246
+ 7. Internal defaults
247
+
248
+ Do not commit configuration files that contain real passwords to public repositories. For shared repositories and deployment environments, prefer `SCP_NEXT_PASSWORD`, SSH agent authentication, or protected key files.
249
+
250
+ ## Library API Usage
251
+
252
+ ESM projects can import `upload` directly.
253
+
254
+ ```ts
255
+ import { upload } from "scp-next";
256
+
257
+ await upload({
258
+ host: process.env.SCP_NEXT_HOST,
259
+ username: process.env.SCP_NEXT_USERNAME,
260
+ password: process.env.SCP_NEXT_PASSWORD,
261
+ localPath: "./dist",
262
+ remotePath: "/var/www/example",
263
+ recursive: true,
264
+ overwrite: true
265
+ });
266
+ ```
267
+
268
+ CommonJS projects can use `require`.
269
+
270
+ ```js
271
+ const { download } = require("scp-next");
272
+
273
+ async function main() {
274
+ await download({
275
+ host: process.env.SCP_NEXT_HOST,
276
+ username: process.env.SCP_NEXT_USERNAME,
277
+ password: process.env.SCP_NEXT_PASSWORD,
278
+ remotePath: "/var/log/example.log",
279
+ localPath: "./logs/example.log"
280
+ });
281
+ }
282
+
283
+ main().catch((error) => {
284
+ console.error(error.message);
285
+ process.exitCode = 1;
286
+ });
287
+ ```
288
+
289
+ Create a reusable client when you need multiple operations in one connection lifecycle.
290
+
291
+ ```ts
292
+ import { createClient } from "scp-next";
293
+
294
+ const client = createClient({
295
+ host: process.env.SCP_NEXT_HOST,
296
+ username: process.env.SCP_NEXT_USERNAME,
297
+ password: process.env.SCP_NEXT_PASSWORD
298
+ });
299
+
300
+ try {
301
+ await client.connect();
302
+ await client.upload("./dist", "/var/www/example", { recursive: true });
303
+ await client.download("/var/log/example.log", "./logs/example.log");
304
+ } finally {
305
+ await client.close();
306
+ }
307
+ ```
308
+
309
+ Primary exports include:
310
+
311
+ ```ts
312
+ upload(options: UploadOptions): Promise<void>;
313
+ download(options: DownloadOptions): Promise<void>;
314
+ createClient(options: ScpServerOptions): ScpNextClient;
315
+ copy(options: CopyOptions): Promise<void>;
316
+ ```
317
+
318
+ Public errors include stable `code` values, readable `message` values, and redacted non-sensitive context. Common error types include `ConfigurationError`, `AuthenticationError`, `ConnectionError`, `TransferError`, and `HostVerificationError`.
319
+
320
+ ## Host Verification
321
+
322
+ `scp-next` supports host verification with `hostFingerprint` or `knownHostsFile`. When neither is supplied, it reads `~/.ssh/known_hosts`.
323
+
324
+ For CI or deployment environments without an available known-hosts file, configure `hostFingerprint`. If `scp-next` cannot establish host verification, it fails closed.
325
+
326
+ ## New Engineer Checklist
327
+
328
+ Use this order when onboarding a project that already uses `scp-next`.
329
+
330
+ 1. Confirm that Node.js is 18.18.0 or later.
331
+ 2. Install the CLI with `npm install --global scp-next`.
332
+ 3. Run `scp-next upload ... --dry-run` to validate options and paths.
333
+ 4. Move server details into environment variables or a configuration file.
334
+ 5. Use `scp-next run <job>` for recurring upload or download workflows.
335
+ 6. Use `upload`, `download`, or `createClient` from Node.js code when the project needs library integration.
336
+
337
+ After these pieces are clear, `scp-next` is ready for deployment scripts, log downloads, and Node.js file transfer workflows.
338
+
339
+ **Copyright Notice**
340
+
341
+ This is an original article. The author reserves all rights. Please keep the full content when reposting, and include a hyperlink to the author.
342
+
343
+ Author: [Cheng](https://github.com/chengchuu)
344
+
345
+ <!-- ID: introducing-scp-next-v1.0.19-en -->
346
+
347
+ (End)
@@ -2,7 +2,7 @@
2
2
 
3
3
  ![scp-next](http://blog.mazey.net/wp-content/uploads/2026/07/scp-next-SF-s7x3.jpg)
4
4
 
5
- 介绍 scp-next v1.0.19 的 npm 安装、CLI 上传下载、配置文件、凭据安全、库 API 和新人接手流程。
5
+ 介绍 scp-next v1.0.19 的 npm 安装、CLI 上传下载、配置文件、凭据安全、库 API 和新人使用流程。
6
6
 
7
7
  - [前言](#前言)
8
8
  - [适合谁使用](#适合谁使用)
@@ -49,7 +49,7 @@ npm install scp-next
49
49
 
50
50
  命令行统一使用 `<source> <destination>` 两个位置参数。
51
51
 
52
- ```text
52
+ ```plain
53
53
  scp-next upload <source> <destination> [options]
54
54
  scp-next download <source> <destination> [options]
55
55
  scp-next run <job> [source] [destination] [options]
@@ -151,7 +151,7 @@ scp-next upload ./dist /var/www/example \
151
151
 
152
152
  CLI 会自动查找以下配置文件。
153
153
 
154
- ```text
154
+ ```plain
155
155
  scp-next.config.json
156
156
  .scp-nextrc
157
157
  .scp-nextrc.json
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scp-next",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "A SCP CLI and library for secure SSH file transfers using SFTP.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",