@bprotsyk/aso-core 2.0.34 → 2.0.36
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.
|
@@ -30,8 +30,9 @@ export declare class ServerUtil {
|
|
|
30
30
|
setupSSL(email: string, host: string): Promise<void>;
|
|
31
31
|
refresh(): Promise<boolean>;
|
|
32
32
|
uploadDirectoryToSftp(localDir: string, remoteDir: string, sftpConfig: any): Promise<void>;
|
|
33
|
+
ensureDirectoryExistence(dirPath: string): void;
|
|
33
34
|
generateNginxConfig(domain: string, rootPath: string): Promise<string>;
|
|
34
|
-
extractUploadedZip(name: string, file: any): Promise<void>;
|
|
35
|
+
extractUploadedZip(name: string, file: any, extractToPath: string): Promise<void>;
|
|
35
36
|
ensureDirectoryExistsViaSSH(sshConfig: ISFTP, remoteDir: string): Promise<void>;
|
|
36
37
|
}
|
|
37
38
|
export {};
|
package/lib/utils/server-util.js
CHANGED
|
@@ -201,18 +201,23 @@ class ServerUtil {
|
|
|
201
201
|
await sftp.end();
|
|
202
202
|
}
|
|
203
203
|
}
|
|
204
|
+
ensureDirectoryExistence(dirPath) {
|
|
205
|
+
if (!fs_1.default.existsSync(dirPath)) {
|
|
206
|
+
fs_1.default.mkdirSync(dirPath, { recursive: true });
|
|
207
|
+
}
|
|
208
|
+
}
|
|
204
209
|
async generateNginxConfig(domain, rootPath) {
|
|
205
210
|
const templatePath = path_1.default.join(__dirname, "..", "templates", "nginx-template.conf");
|
|
206
211
|
const template = fs_1.default.readFileSync(templatePath, "utf8");
|
|
207
212
|
const config = mustache_1.default.render(template, { domain, rootPath });
|
|
208
213
|
return config;
|
|
209
214
|
}
|
|
210
|
-
async extractUploadedZip(name, file) {
|
|
215
|
+
async extractUploadedZip(name, file, extractToPath) {
|
|
211
216
|
const zipFilePath = file.path;
|
|
212
|
-
const outputDir = path_1.default.join(
|
|
217
|
+
const outputDir = path_1.default.join(extractToPath, name);
|
|
213
218
|
console.log('Looking for ZIP file at:', zipFilePath);
|
|
214
219
|
console.log('Extracting to:', outputDir);
|
|
215
|
-
ensureDirectoryExistence(outputDir);
|
|
220
|
+
this.ensureDirectoryExistence(outputDir);
|
|
216
221
|
if (!fs_1.default.existsSync(zipFilePath)) {
|
|
217
222
|
console.error('Error: File not found:', zipFilePath);
|
|
218
223
|
return;
|
|
@@ -225,10 +230,10 @@ class ServerUtil {
|
|
|
225
230
|
// Видаляємо перший сегмент шляху, щоб уникнути кореневої директорії
|
|
226
231
|
const entryPath = path_1.default.join(outputDir, ...entry.path.split('/').slice(1));
|
|
227
232
|
if (entry.type === 'Directory') {
|
|
228
|
-
ensureDirectoryExistence(entryPath);
|
|
233
|
+
this.ensureDirectoryExistence(entryPath);
|
|
229
234
|
}
|
|
230
235
|
else {
|
|
231
|
-
ensureDirectoryExistence(path_1.default.dirname(entryPath));
|
|
236
|
+
this.ensureDirectoryExistence(path_1.default.dirname(entryPath));
|
|
232
237
|
entry.pipe(fs_1.default.createWriteStream(entryPath));
|
|
233
238
|
}
|
|
234
239
|
})
|
|
@@ -260,6 +265,3 @@ class ServerUtil {
|
|
|
260
265
|
}
|
|
261
266
|
}
|
|
262
267
|
exports.ServerUtil = ServerUtil;
|
|
263
|
-
function ensureDirectoryExistence(outputDir) {
|
|
264
|
-
throw new Error("Function not implemented.");
|
|
265
|
-
}
|
package/package.json
CHANGED
package/src/utils/server-util.ts
CHANGED
|
@@ -248,6 +248,12 @@ export class ServerUtil {
|
|
|
248
248
|
}
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
ensureDirectoryExistence(dirPath:string) {
|
|
252
|
+
if (!fs.existsSync(dirPath)) {
|
|
253
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
251
257
|
async generateNginxConfig(domain: string, rootPath: string): Promise<string> {
|
|
252
258
|
const templatePath = path.join(
|
|
253
259
|
__dirname,
|
|
@@ -261,14 +267,14 @@ export class ServerUtil {
|
|
|
261
267
|
}
|
|
262
268
|
|
|
263
269
|
|
|
264
|
-
async extractUploadedZip(name:string, file:any) {
|
|
270
|
+
async extractUploadedZip(name:string, file:any, extractToPath:string ) {
|
|
265
271
|
const zipFilePath = file.path;
|
|
266
|
-
const outputDir = path.join(
|
|
272
|
+
const outputDir = path.join(extractToPath, name);
|
|
267
273
|
|
|
268
274
|
console.log('Looking for ZIP file at:', zipFilePath);
|
|
269
275
|
console.log('Extracting to:', outputDir);
|
|
270
276
|
|
|
271
|
-
ensureDirectoryExistence(outputDir);
|
|
277
|
+
this.ensureDirectoryExistence(outputDir);
|
|
272
278
|
|
|
273
279
|
if (!fs.existsSync(zipFilePath)) {
|
|
274
280
|
console.error('Error: File not found:', zipFilePath);
|
|
@@ -287,9 +293,9 @@ export class ServerUtil {
|
|
|
287
293
|
);
|
|
288
294
|
|
|
289
295
|
if (entry.type === 'Directory') {
|
|
290
|
-
ensureDirectoryExistence(entryPath);
|
|
296
|
+
this.ensureDirectoryExistence(entryPath);
|
|
291
297
|
} else {
|
|
292
|
-
ensureDirectoryExistence(path.dirname(entryPath));
|
|
298
|
+
this.ensureDirectoryExistence(path.dirname(entryPath));
|
|
293
299
|
entry.pipe(fs.createWriteStream(entryPath));
|
|
294
300
|
}
|
|
295
301
|
})
|
|
@@ -324,7 +330,5 @@ export class ServerUtil {
|
|
|
324
330
|
}
|
|
325
331
|
}
|
|
326
332
|
}
|
|
327
|
-
|
|
328
|
-
throw new Error("Function not implemented.");
|
|
329
|
-
}
|
|
333
|
+
|
|
330
334
|
|