@bprotsyk/aso-core 2.0.30 → 2.0.31

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.
@@ -3,12 +3,6 @@ export declare let IP: string;
3
3
  export declare let PASSWORD: string;
4
4
  export declare let HOST: string;
5
5
  export declare let PORT: number;
6
- interface ISFTP {
7
- ip: string;
8
- port: number;
9
- username: string;
10
- password: string;
11
- }
12
6
  export declare class ServerUtil {
13
7
  DOMAIN_HOME: string;
14
8
  ssh?: NodeSSH;
@@ -29,7 +23,6 @@ export declare class ServerUtil {
29
23
  setupCertbot(): Promise<boolean>;
30
24
  setupSSL(email: string, host: string): Promise<void>;
31
25
  refresh(): Promise<boolean>;
32
- uploadDirectoryToSftp(localDir: string, remoteDir: string, sftpConfig: ISFTP): Promise<void>;
26
+ uploadDirectoryToSftp(localDir: string, remoteDir: string, sftpConfig: any): Promise<void>;
33
27
  generateNginxConfig(domain: string, rootPath: string): Promise<string>;
34
28
  }
35
- export {};
@@ -173,7 +173,7 @@ class ServerUtil {
173
173
  // Перебираємо кожен елемент (файл чи папку)
174
174
  for (const item of items) {
175
175
  const localPath = path_1.default.join(localDir, item.name);
176
- const remotePath = path_1.default.join(remoteDir, item.name);
176
+ const remotePath = `${remoteDir}/${item.name}`;
177
177
  if (item.isDirectory()) {
178
178
  // Якщо це директорія, створюємо її на сервері
179
179
  await sftp.mkdir(remotePath, true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.0.30",
3
+ "version": "2.0.31",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -207,40 +207,44 @@ export class ServerUtil {
207
207
 
208
208
 
209
209
 
210
- async uploadDirectoryToSftp(localDir:string, remoteDir:string, sftpConfig:ISFTP) {
210
+ async uploadDirectoryToSftp(
211
+ localDir: string,
212
+ remoteDir: string,
213
+ sftpConfig: any
214
+ ) {
211
215
  const sftp = new Client();
212
-
216
+
213
217
  try {
214
- await sftp.connect(sftpConfig);
215
-
216
- const items = fs.readdirSync(localDir, { withFileTypes: true });
217
-
218
- // Перебираємо кожен елемент (файл чи папку)
219
- for (const item of items) {
220
- const localPath = path.join(localDir, item.name);
221
- const remotePath = path.join(remoteDir, item.name);
222
-
223
- if (item.isDirectory()) {
224
- // Якщо це директорія, створюємо її на сервері
225
- await sftp.mkdir(remotePath, true);
226
-
227
- // Рекурсивно передаємо вміст цієї директорії
228
- await this.uploadDirectoryToSftp(localPath, remotePath, sftpConfig);
229
- } else {
230
- // Якщо це файл, передаємо його на сервер
231
- await sftp.put(localPath, remotePath);
232
- console.log(`Передано файл: ${localPath} -> ${remotePath}`);
233
- }
218
+ await sftp.connect(sftpConfig);
219
+
220
+ const items = fs.readdirSync(localDir, { withFileTypes: true });
221
+
222
+ // Перебираємо кожен елемент (файл чи папку)
223
+ for (const item of items) {
224
+ const localPath = path.join(localDir, item.name);
225
+ const remotePath = `${remoteDir}/${item.name}`;
226
+
227
+ if (item.isDirectory()) {
228
+ // Якщо це директорія, створюємо її на сервері
229
+ await sftp.mkdir(remotePath, true);
230
+
231
+ // Рекурсивно передаємо вміст цієї директорії
232
+ await this.uploadDirectoryToSftp(localPath, remotePath, sftpConfig);
233
+ } else {
234
+ // Якщо це файл, передаємо його на сервер
235
+ await sftp.put(localPath, remotePath);
236
+ console.log(`Передано файл: ${localPath} -> ${remotePath}`);
234
237
  }
235
-
236
- console.log('Усі файли та папки успішно передані.');
238
+ }
239
+
240
+ console.log('Усі файли та папки успішно передані.');
237
241
  } catch (err) {
238
- console.error('Помилка під час передавання файлів через SFTP:', err);
242
+ console.error('Помилка під час передавання файлів через SFTP:', err);
239
243
  } finally {
240
- // Закриваємо підключення до SFTP
241
- await sftp.end();
244
+ // Закриваємо підключення до SFTP
245
+ await sftp.end();
242
246
  }
243
- }
247
+ }
244
248
 
245
249
 
246
250
  async generateNginxConfig(domain: string, rootPath: string): Promise<string> {