@dnax/core 0.78.0 → 0.78.1

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.
Files changed (2) hide show
  1. package/lib/media/sftp.ts +29 -0
  2. package/package.json +1 -1
package/lib/media/sftp.ts CHANGED
@@ -8,6 +8,33 @@ import type { Collection } from "../../types";
8
8
  import consola from "consola";
9
9
  const BASE_DIR = "/uploads/";
10
10
 
11
+ // ============================================================================
12
+ // EXPECT DEPENDENCY CHECK
13
+ // ============================================================================
14
+
15
+ function getExpectInstallMessage(): string {
16
+ return [
17
+ "Linux (Debian/Ubuntu) : sudo apt-get install expect",
18
+ "Linux (RHEL/CentOS) : sudo yum install expect",
19
+ "Linux (Fedora) : sudo dnf install expect",
20
+ "macOS : brew install expect",
21
+ "Windows (Chocolatey) : choco install expect",
22
+ "Windows (autrement) : utilisez WSL ou Cygwin pour avoir expect.",
23
+ ].join("\n");
24
+ }
25
+
26
+ async function checkExpectInstalled(): Promise<void> {
27
+ try {
28
+ await $`expect -c "exit 0"`.quiet();
29
+ } catch {
30
+ const instructions = getExpectInstallMessage();
31
+ throw new Error(
32
+ `La commande "expect" n'est pas installée sur cette machine. Elle est requise pour l'authentification par mot de passe SFTP/SSH.\n\n` +
33
+ `Installation : ${instructions}`
34
+ );
35
+ }
36
+ }
37
+
11
38
  // ============================================================================
12
39
  // TYPES & INTERFACES
13
40
  // ============================================================================
@@ -147,6 +174,8 @@ class FilesystemSftpAdapter {
147
174
  return result.text();
148
175
  }
149
176
 
177
+ await checkExpectInstalled();
178
+
150
179
  const expectScript = `
151
180
  set timeout 30
152
181
  spawn sh -c "${command.replace(/"/g, '\\"')}"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dnax/core",
3
- "version": "0.78.0",
3
+ "version": "0.78.1",
4
4
  "module": "index.ts",
5
5
  "type": "module",
6
6
  "bin": {},