scp-next 1.0.20 → 1.1.3
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/CHANGELOG.md +12 -1
- package/README.md +81 -27
- package/dist/cli/index.js +1732 -1371
- package/dist/cli/index.js.map +1 -1
- package/dist/index.cjs +1204 -928
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +50 -5
- package/dist/index.d.ts +50 -5
- package/dist/index.js +1193 -883
- package/dist/index.js.map +1 -1
- package/guides/ARCHITECTURE.md +88 -0
- package/guides/mazey-candidates.md +364 -0
- package/package.json +44 -12
- package/docs/ARCHITECTURE.md +0 -55
- /package/{docs → guides}/release-notes/introducing-scp-next-v1.0.14.md +0 -0
- /package/{docs → guides}/release-notes/introducing-scp-next-v1.0.19-en.md +0 -0
- /package/{docs → guides}/release-notes/introducing-scp-next-v1.0.19-zh.md +0 -0
- /package/{docs → guides}/release-notes/introducing-scp-next-v1.0.2.md +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## Unreleased
|
|
4
|
+
|
|
5
|
+
- Added opt-in, repeatable `--post-upload-command` commands for CLI uploads and configured
|
|
6
|
+
upload jobs.
|
|
7
|
+
- Added library `postUploadCommands`, `client.exec()`, `ExecResult`, and typed
|
|
8
|
+
`RemoteCommandError` APIs.
|
|
9
|
+
- Kept remote command execution separate from SFTP, sequential, disabled for downloads and dry
|
|
10
|
+
runs, and fail-fast on non-zero exit codes.
|
|
11
|
+
- Added bounded command output capture, CLI failure propagation, secret redaction, and mock-based
|
|
12
|
+
coverage for upload failure, ordering, command failure, dry-run, and connection cleanup.
|
|
13
|
+
|
|
3
14
|
## 1.0.19
|
|
4
15
|
|
|
5
16
|
- Refined README structure for clearer installation, quick start, basic usage, advanced usage,
|
|
@@ -9,7 +20,7 @@
|
|
|
9
20
|
- Clarified SSH agent usage, `SSH_AUTH_SOCK`, timeout behavior, and configuration-file
|
|
10
21
|
recommendations.
|
|
11
22
|
- Expanded GitHub Pages documentation with CLI, library, and configuration options.
|
|
12
|
-
- Moved release notes under `
|
|
23
|
+
- Moved release notes under `guides/release-notes/` for cleaner documentation organization.
|
|
13
24
|
|
|
14
25
|
## 1.0.14
|
|
15
26
|
|
package/README.md
CHANGED
|
@@ -18,6 +18,9 @@
|
|
|
18
18
|
`scp-next` is an SCP-style command-line tool and library for secure file transfers over SSH.
|
|
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
|
+
Use the [interactive examples](https://chengchuu.github.io/scp-next/examples/) to generate
|
|
22
|
+
CLI and TypeScript transfer snippets, or browse the
|
|
23
|
+
[API documentation](https://chengchuu.github.io/scp-next/api/).
|
|
21
24
|
|
|
22
25
|
## Features
|
|
23
26
|
|
|
@@ -26,6 +29,7 @@ Developer documentation is available at [GitHub Pages](https://chengchuu.github.
|
|
|
26
29
|
- ESM `import` and CommonJS `require` support.
|
|
27
30
|
- JSON configuration files, named profiles, and configured jobs.
|
|
28
31
|
- Reusable transfer client.
|
|
32
|
+
- Optional sequential remote commands after a successful upload.
|
|
29
33
|
|
|
30
34
|
## Contents
|
|
31
35
|
|
|
@@ -145,6 +149,21 @@ scp-next upload ./dist /var/www/example \
|
|
|
145
149
|
--verbose
|
|
146
150
|
```
|
|
147
151
|
|
|
152
|
+
Run commands after a successful upload:
|
|
153
|
+
|
|
154
|
+
```bash
|
|
155
|
+
scp-next upload ./dist /var/www/example \
|
|
156
|
+
--host your-host \
|
|
157
|
+
--username your-username \
|
|
158
|
+
--recursive \
|
|
159
|
+
--post-upload-command "cd /var/www/example && npm install --omit=dev" \
|
|
160
|
+
--post-upload-command "pm2 reload example"
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
`--post-upload-command` is repeatable and upload-only. Commands run sequentially on the
|
|
164
|
+
remote server with the SSH user's permissions. The first non-zero exit code stops the sequence
|
|
165
|
+
and makes the CLI exit non-zero. A missing exit status is also treated as failure.
|
|
166
|
+
|
|
148
167
|
Use an encrypted private key:
|
|
149
168
|
|
|
150
169
|
```bash
|
|
@@ -202,6 +221,7 @@ scp-next run download-logs --config ./scp-next.config.json
|
|
|
202
221
|
| `--create-directories` | Create missing destination directories. Enabled by default. |
|
|
203
222
|
| `--no-create-directories` | Disable automatic destination directory creation. |
|
|
204
223
|
| `--dry-run` | Resolve and validate the operation without connecting or transferring. |
|
|
224
|
+
| `--post-upload-command <command>` | Run a remote command after a successful upload. Repeatable. |
|
|
205
225
|
| `--timeout <milliseconds>` | SSH connection ready timeout in milliseconds. |
|
|
206
226
|
| `--verbose` | Print non-sensitive diagnostic details. |
|
|
207
227
|
| `--quiet` | Disable progress and non-error output. |
|
|
@@ -224,7 +244,11 @@ await upload({
|
|
|
224
244
|
localPath: "./dist",
|
|
225
245
|
remotePath: "/var/www/example",
|
|
226
246
|
recursive: true,
|
|
227
|
-
overwrite: true
|
|
247
|
+
overwrite: true,
|
|
248
|
+
postUploadCommands: [
|
|
249
|
+
"cd /var/www/example && npm install --omit=dev",
|
|
250
|
+
"pm2 reload example"
|
|
251
|
+
]
|
|
228
252
|
});
|
|
229
253
|
```
|
|
230
254
|
|
|
@@ -263,6 +287,8 @@ const client = createClient({
|
|
|
263
287
|
try {
|
|
264
288
|
await client.connect();
|
|
265
289
|
await client.upload("./dist", "/var/www/example", { recursive: true });
|
|
290
|
+
const result = await client.exec("pm2 reload example");
|
|
291
|
+
console.log(result.stdout);
|
|
266
292
|
await client.download("/var/log/example.log", "./logs/example.log");
|
|
267
293
|
} finally {
|
|
268
294
|
await client.close();
|
|
@@ -293,26 +319,33 @@ await upload({
|
|
|
293
319
|
|
|
294
320
|
### Library Options
|
|
295
321
|
|
|
296
|
-
| Field
|
|
297
|
-
|
|
|
298
|
-
| `host`
|
|
299
|
-
| `port`
|
|
300
|
-
| `username`
|
|
301
|
-
| `password`
|
|
302
|
-
| `privateKey`
|
|
303
|
-
| `privateKeyFile`
|
|
304
|
-
| `passphrase`
|
|
305
|
-
| `agent`
|
|
306
|
-
| `hostFingerprint`
|
|
307
|
-
| `knownHostsFile`
|
|
308
|
-
| `localPath`
|
|
309
|
-
| `remotePath`
|
|
310
|
-
| `recursive`
|
|
311
|
-
| `overwrite`
|
|
312
|
-
| `createDirectories`
|
|
313
|
-
| `dryRun`
|
|
314
|
-
| `timeout`
|
|
315
|
-
| `
|
|
322
|
+
| Field | Used by | Description |
|
|
323
|
+
| -------------------- | --------------- | ------------------------------------------------------------ |
|
|
324
|
+
| `host` | server | SSH server host. |
|
|
325
|
+
| `port` | server | SSH server port. Defaults to `22`. |
|
|
326
|
+
| `username` | server | SSH username. |
|
|
327
|
+
| `password` | server | SSH password. |
|
|
328
|
+
| `privateKey` | server | Private-key content as a string or Buffer. |
|
|
329
|
+
| `privateKeyFile` | server | Private-key file path. |
|
|
330
|
+
| `passphrase` | server | Passphrase for an encrypted private key. |
|
|
331
|
+
| `agent` | server | SSH agent socket path. |
|
|
332
|
+
| `hostFingerprint` | server | Expected server host-key SHA-256 fingerprint. |
|
|
333
|
+
| `knownHostsFile` | server | Known-hosts file for host verification. |
|
|
334
|
+
| `localPath` | upload/download | Local source for upload or local destination for download. |
|
|
335
|
+
| `remotePath` | upload/download | Remote destination for upload or remote source for download. |
|
|
336
|
+
| `recursive` | transfer | Transfer directories recursively. Defaults to `false`. |
|
|
337
|
+
| `overwrite` | transfer | Allow replacing existing files. |
|
|
338
|
+
| `createDirectories` | transfer | Create missing destination directories. Defaults to `true`. |
|
|
339
|
+
| `dryRun` | transfer | Validate and plan without modifying local or remote files. |
|
|
340
|
+
| `timeout` | server/transfer | SSH connection ready timeout in milliseconds. |
|
|
341
|
+
| `postUploadCommands` | upload | Remote command strings run sequentially after success. |
|
|
342
|
+
| `onProgress` | transfer | Progress callback for file and directory transfers. |
|
|
343
|
+
|
|
344
|
+
`client.exec(command, options)` returns `ExecResult` with `stdout`, `stderr`, `exitCode`,
|
|
345
|
+
and an optional signal. Its optional `timeout` is command-specific; `failOnStderr` can treat
|
|
346
|
+
stderr output as failure even when the exit code is zero. `maxBuffer` limits combined captured
|
|
347
|
+
output and defaults to 10 MiB. A timeout closes the SSH channel; whether the remote process is
|
|
348
|
+
terminated depends on the SSH server.
|
|
316
349
|
|
|
317
350
|
## Advanced Usage
|
|
318
351
|
|
|
@@ -418,7 +451,11 @@ Jobs use `source` and `destination`; the `operation` determines which path is lo
|
|
|
418
451
|
"source": "./dist",
|
|
419
452
|
"destination": "/var/www/example",
|
|
420
453
|
"recursive": true,
|
|
421
|
-
"overwrite": true
|
|
454
|
+
"overwrite": true,
|
|
455
|
+
"postUploadCommands": [
|
|
456
|
+
"cd /var/www/example && npm install --omit=dev",
|
|
457
|
+
"pm2 reload example"
|
|
458
|
+
]
|
|
422
459
|
},
|
|
423
460
|
"download-logs": {
|
|
424
461
|
"operation": "download",
|
|
@@ -533,7 +570,7 @@ Interactive terminals display concise progress. Progress is disabled with `--qui
|
|
|
533
570
|
|
|
534
571
|
### Dry Run
|
|
535
572
|
|
|
536
|
-
`--dry-run` resolves configuration and validates local paths and transfer direction without connecting to the remote server or
|
|
573
|
+
`--dry-run` resolves configuration and validates local paths and transfer direction without connecting to the remote server, transferring files, or executing post-upload commands. Planned post-upload commands are shown with known and recognizable secret values redacted.
|
|
537
574
|
|
|
538
575
|
```text
|
|
539
576
|
Dry run: upload
|
|
@@ -541,6 +578,10 @@ Source: ./dist
|
|
|
541
578
|
Destination: your-username@your-host:/var/www/example
|
|
542
579
|
Recursive: yes
|
|
543
580
|
Overwrite: yes
|
|
581
|
+
|
|
582
|
+
Post-upload commands:
|
|
583
|
+
1. cd /var/www/example && npm install --omit=dev
|
|
584
|
+
2. pm2 reload example
|
|
544
585
|
```
|
|
545
586
|
|
|
546
587
|
## Error Handling
|
|
@@ -553,6 +594,7 @@ Public typed errors:
|
|
|
553
594
|
- `AuthenticationError`
|
|
554
595
|
- `ConnectionError`
|
|
555
596
|
- `TransferError`
|
|
597
|
+
- `RemoteCommandError`
|
|
556
598
|
- `FileSystemError`
|
|
557
599
|
- `HostVerificationError`
|
|
558
600
|
|
|
@@ -582,7 +624,7 @@ try {
|
|
|
582
624
|
Primary functions:
|
|
583
625
|
|
|
584
626
|
```ts
|
|
585
|
-
upload(options: UploadOptions): Promise<
|
|
627
|
+
upload(options: UploadOptions): Promise<ExecResult[]>
|
|
586
628
|
download(options: DownloadOptions): Promise<void>
|
|
587
629
|
createClient(options: ScpServerOptions): ScpNextClient
|
|
588
630
|
copy(options: CopyOptions): Promise<void>
|
|
@@ -590,11 +632,18 @@ copy(options: CopyOptions): Promise<void>
|
|
|
590
632
|
|
|
591
633
|
Upload and download APIs use explicit `localPath` and `remotePath` names.
|
|
592
634
|
The optional generic `copy()` API accepts typed local/remote endpoint objects.
|
|
635
|
+
`ScpNextClient.exec(command, options)` executes one command directly through SSH.
|
|
636
|
+
|
|
637
|
+
Post-upload execution is disabled unless `postUploadCommands` is present. Commands are sent
|
|
638
|
+
directly to the remote SSH server, never through a local shell, and never run for downloads or
|
|
639
|
+
dry runs. Do not put passwords, tokens, or other secrets directly in command strings; command
|
|
640
|
+
output may also contain application data. `scp-next` redacts known credentials and common secret
|
|
641
|
+
assignment forms from CLI logs and errors.
|
|
593
642
|
|
|
594
643
|
## User Guides
|
|
595
644
|
|
|
596
|
-
- [English](https://github.com/chengchuu/scp-next/blob/main/
|
|
597
|
-
- [简体中文](https://github.com/chengchuu/scp-next/blob/main/
|
|
645
|
+
- [English](https://github.com/chengchuu/scp-next/blob/main/guides/release-notes/introducing-scp-next-v1.0.19-en.md)
|
|
646
|
+
- [简体中文](https://github.com/chengchuu/scp-next/blob/main/guides/release-notes/introducing-scp-next-v1.0.19-zh.md)
|
|
598
647
|
|
|
599
648
|
## Development
|
|
600
649
|
|
|
@@ -604,6 +653,8 @@ npm run typecheck
|
|
|
604
653
|
npm run lint
|
|
605
654
|
npm test
|
|
606
655
|
npm run build
|
|
656
|
+
npm run docs:links
|
|
657
|
+
npm run docs
|
|
607
658
|
npm pack --dry-run
|
|
608
659
|
```
|
|
609
660
|
|
|
@@ -611,7 +662,10 @@ npm pack --dry-run
|
|
|
611
662
|
|
|
612
663
|
## Publishing
|
|
613
664
|
|
|
614
|
-
The published package includes `dist`, README, license, changelog, and
|
|
665
|
+
The published package includes `dist`, README, license, changelog, and handwritten guides. The CLI
|
|
666
|
+
entry is `dist/cli/index.js` and contains a Node.js shebang. `npm run docs` generates TypeDoc,
|
|
667
|
+
builds the website and examples with Webpack, assembles the GitHub Pages artifact under `docs/`,
|
|
668
|
+
and validates its SEO and PWA metadata. Do not edit or commit generated output directly.
|
|
615
669
|
|
|
616
670
|
## Transfer Mechanism
|
|
617
671
|
|