@bprotsyk/aso-core 2.0.30 → 2.0.32
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/lib/utils/server-util.js
CHANGED
|
@@ -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 =
|
|
176
|
+
const remotePath = `${remoteDir}/${item.name}`;
|
|
177
177
|
if (item.isDirectory()) {
|
|
178
178
|
// Якщо це директорія, створюємо її на сервері
|
|
179
179
|
await sftp.mkdir(remotePath, true);
|
package/package.json
CHANGED
package/src/utils/server-util.ts
CHANGED
|
@@ -18,7 +18,7 @@ interface FileObject {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
interface ISFTP{
|
|
21
|
-
|
|
21
|
+
host:string ,
|
|
22
22
|
port: number,
|
|
23
23
|
username: string,
|
|
24
24
|
password: string;
|
|
@@ -207,40 +207,44 @@ export class ServerUtil {
|
|
|
207
207
|
|
|
208
208
|
|
|
209
209
|
|
|
210
|
-
async
|
|
210
|
+
async uploadDirectoryToSftp(
|
|
211
|
+
localDir: string,
|
|
212
|
+
remoteDir: string,
|
|
213
|
+
sftpConfig: ISFTP
|
|
214
|
+
) {
|
|
211
215
|
const sftp = new Client();
|
|
212
|
-
|
|
216
|
+
|
|
213
217
|
try {
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
console.log('Усі файли та папки успішно передані.');
|
|
237
241
|
} catch (err) {
|
|
238
|
-
|
|
242
|
+
console.error('Помилка під час передавання файлів через SFTP:', err);
|
|
239
243
|
} finally {
|
|
240
|
-
|
|
241
|
-
|
|
244
|
+
// Закриваємо підключення до SFTP
|
|
245
|
+
await sftp.end();
|
|
242
246
|
}
|
|
243
|
-
}
|
|
247
|
+
}
|
|
244
248
|
|
|
245
249
|
|
|
246
250
|
async generateNginxConfig(domain: string, rootPath: string): Promise<string> {
|