@bprotsyk/aso-core 2.0.34 → 2.0.35

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,6 +30,7 @@ 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
35
  extractUploadedZip(name: string, file: any): Promise<void>;
35
36
  ensureDirectoryExistsViaSSH(sshConfig: ISFTP, remoteDir: string): Promise<void>;
@@ -201,6 +201,11 @@ 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");
@@ -212,7 +217,7 @@ class ServerUtil {
212
217
  const outputDir = path_1.default.join(__dirname, '..', 'uploads', 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.0.34",
3
+ "version": "2.0.35",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -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,
@@ -268,7 +274,7 @@ export class ServerUtil {
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
- function ensureDirectoryExistence(outputDir: string) {
328
- throw new Error("Function not implemented.");
329
- }
333
+
330
334