scp-next 1.0.20 → 1.1.2

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 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 `docs/release-notes/` for cleaner documentation organization.
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
@@ -26,6 +26,7 @@ Developer documentation is available at [GitHub Pages](https://chengchuu.github.
26
26
  - ESM `import` and CommonJS `require` support.
27
27
  - JSON configuration files, named profiles, and configured jobs.
28
28
  - Reusable transfer client.
29
+ - Optional sequential remote commands after a successful upload.
29
30
 
30
31
  ## Contents
31
32
 
@@ -145,6 +146,21 @@ scp-next upload ./dist /var/www/example \
145
146
  --verbose
146
147
  ```
147
148
 
149
+ Run commands after a successful upload:
150
+
151
+ ```bash
152
+ scp-next upload ./dist /var/www/example \
153
+ --host your-host \
154
+ --username your-username \
155
+ --recursive \
156
+ --post-upload-command "cd /var/www/example && npm install --omit=dev" \
157
+ --post-upload-command "pm2 reload example"
158
+ ```
159
+
160
+ `--post-upload-command` is repeatable and upload-only. Commands run sequentially on the
161
+ remote server with the SSH user's permissions. The first non-zero exit code stops the sequence
162
+ and makes the CLI exit non-zero. A missing exit status is also treated as failure.
163
+
148
164
  Use an encrypted private key:
149
165
 
150
166
  ```bash
@@ -202,6 +218,7 @@ scp-next run download-logs --config ./scp-next.config.json
202
218
  | `--create-directories` | Create missing destination directories. Enabled by default. |
203
219
  | `--no-create-directories` | Disable automatic destination directory creation. |
204
220
  | `--dry-run` | Resolve and validate the operation without connecting or transferring. |
221
+ | `--post-upload-command <command>` | Run a remote command after a successful upload. Repeatable. |
205
222
  | `--timeout <milliseconds>` | SSH connection ready timeout in milliseconds. |
206
223
  | `--verbose` | Print non-sensitive diagnostic details. |
207
224
  | `--quiet` | Disable progress and non-error output. |
@@ -224,7 +241,11 @@ await upload({
224
241
  localPath: "./dist",
225
242
  remotePath: "/var/www/example",
226
243
  recursive: true,
227
- overwrite: true
244
+ overwrite: true,
245
+ postUploadCommands: [
246
+ "cd /var/www/example && npm install --omit=dev",
247
+ "pm2 reload example"
248
+ ]
228
249
  });
229
250
  ```
230
251
 
@@ -263,6 +284,8 @@ const client = createClient({
263
284
  try {
264
285
  await client.connect();
265
286
  await client.upload("./dist", "/var/www/example", { recursive: true });
287
+ const result = await client.exec("pm2 reload example");
288
+ console.log(result.stdout);
266
289
  await client.download("/var/log/example.log", "./logs/example.log");
267
290
  } finally {
268
291
  await client.close();
@@ -312,8 +335,15 @@ await upload({
312
335
  | `createDirectories` | transfer | Create missing destination directories. Defaults to `true`. |
313
336
  | `dryRun` | transfer | Validate and plan without modifying local or remote files. |
314
337
  | `timeout` | server/transfer | SSH connection ready timeout in milliseconds. |
338
+ | `postUploadCommands` | upload | Remote command strings run sequentially after success. |
315
339
  | `onProgress` | transfer | Progress callback for file and directory transfers. |
316
340
 
341
+ `client.exec(command, options)` returns `ExecResult` with `stdout`, `stderr`, `exitCode`,
342
+ and an optional signal. Its optional `timeout` is command-specific; `failOnStderr` can treat
343
+ stderr output as failure even when the exit code is zero. `maxBuffer` limits combined captured
344
+ output and defaults to 10 MiB. A timeout closes the SSH channel; whether the remote process is
345
+ terminated depends on the SSH server.
346
+
317
347
  ## Advanced Usage
318
348
 
319
349
  ### Configuration Files
@@ -418,7 +448,11 @@ Jobs use `source` and `destination`; the `operation` determines which path is lo
418
448
  "source": "./dist",
419
449
  "destination": "/var/www/example",
420
450
  "recursive": true,
421
- "overwrite": true
451
+ "overwrite": true,
452
+ "postUploadCommands": [
453
+ "cd /var/www/example && npm install --omit=dev",
454
+ "pm2 reload example"
455
+ ]
422
456
  },
423
457
  "download-logs": {
424
458
  "operation": "download",
@@ -533,7 +567,7 @@ Interactive terminals display concise progress. Progress is disabled with `--qui
533
567
 
534
568
  ### Dry Run
535
569
 
536
- `--dry-run` resolves configuration and validates local paths and transfer direction without connecting to the remote server or modifying local/remote files.
570
+ `--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
571
 
538
572
  ```text
539
573
  Dry run: upload
@@ -541,6 +575,10 @@ Source: ./dist
541
575
  Destination: your-username@your-host:/var/www/example
542
576
  Recursive: yes
543
577
  Overwrite: yes
578
+
579
+ Post-upload commands:
580
+ 1. cd /var/www/example && npm install --omit=dev
581
+ 2. pm2 reload example
544
582
  ```
545
583
 
546
584
  ## Error Handling
@@ -553,6 +591,7 @@ Public typed errors:
553
591
  - `AuthenticationError`
554
592
  - `ConnectionError`
555
593
  - `TransferError`
594
+ - `RemoteCommandError`
556
595
  - `FileSystemError`
557
596
  - `HostVerificationError`
558
597
 
@@ -582,7 +621,7 @@ try {
582
621
  Primary functions:
583
622
 
584
623
  ```ts
585
- upload(options: UploadOptions): Promise<void>
624
+ upload(options: UploadOptions): Promise<ExecResult[]>
586
625
  download(options: DownloadOptions): Promise<void>
587
626
  createClient(options: ScpServerOptions): ScpNextClient
588
627
  copy(options: CopyOptions): Promise<void>
@@ -590,11 +629,18 @@ copy(options: CopyOptions): Promise<void>
590
629
 
591
630
  Upload and download APIs use explicit `localPath` and `remotePath` names.
592
631
  The optional generic `copy()` API accepts typed local/remote endpoint objects.
632
+ `ScpNextClient.exec(command, options)` executes one command directly through SSH.
633
+
634
+ Post-upload execution is disabled unless `postUploadCommands` is present. Commands are sent
635
+ directly to the remote SSH server, never through a local shell, and never run for downloads or
636
+ dry runs. Do not put passwords, tokens, or other secrets directly in command strings; command
637
+ output may also contain application data. `scp-next` redacts known credentials and common secret
638
+ assignment forms from CLI logs and errors.
593
639
 
594
640
  ## User Guides
595
641
 
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)
642
+ - [English](https://github.com/chengchuu/scp-next/blob/main/guides/release-notes/introducing-scp-next-v1.0.19-en.md)
643
+ - [简体中文](https://github.com/chengchuu/scp-next/blob/main/guides/release-notes/introducing-scp-next-v1.0.19-zh.md)
598
644
 
599
645
  ## Development
600
646
 
@@ -604,6 +650,8 @@ npm run typecheck
604
650
  npm run lint
605
651
  npm test
606
652
  npm run build
653
+ npm run docs:links
654
+ npm run docs:build
607
655
  npm pack --dry-run
608
656
  ```
609
657
 
@@ -611,7 +659,9 @@ npm pack --dry-run
611
659
 
612
660
  ## Publishing
613
661
 
614
- The published package includes `dist`, README, license, changelog, and docs. The CLI entry is `dist/cli/index.js` and contains a Node.js shebang.
662
+ The published package includes `dist`, README, license, changelog, and handwritten guides. The CLI
663
+ entry is `dist/cli/index.js` and contains a Node.js shebang. `npm run docs:build` generates the
664
+ GitHub Pages artifact under `docs/`; do not edit or commit that output directly.
615
665
 
616
666
  ## Transfer Mechanism
617
667