@bprotsyk/aso-core 2.0.26 → 2.0.27

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.
@@ -169,11 +169,14 @@ class ServerUtil {
169
169
  async deployLandingPage(host, username, password, remotePath, port, files) {
170
170
  let sftp = new ssh2_sftp_client_1.default();
171
171
  try {
172
- //connection to the server via sftp
173
172
  await sftp.connect({ host, username, password, port });
174
- // Завантажити файли на сервер
173
+ const dirExists = await sftp.exists(remotePath);
174
+ if (!dirExists) {
175
+ await sftp.mkdir(remotePath, true);
176
+ }
175
177
  for (const file of files) {
176
- await sftp.put(Buffer.from(file.content, "base64"), `${remotePath}/${file.name}`);
178
+ const remoteFilePath = `${remotePath}/${file.name}`;
179
+ await sftp.put(Buffer.from(file.content, "base64"), remoteFilePath);
177
180
  }
178
181
  }
179
182
  finally {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bprotsyk/aso-core",
3
- "version": "2.0.26",
3
+ "version": "2.0.27",
4
4
  "main": "lib/index.js",
5
5
  "types": "lib/index.d.ts",
6
6
  "scripts": {
@@ -205,20 +205,22 @@ export class ServerUtil {
205
205
  ): Promise<void> {
206
206
  let sftp = new Client();
207
207
  try {
208
- //connection to the server via sftp
209
- await sftp.connect({ host, username, password, port });
210
-
211
- // Завантажити файли на сервер
212
- for (const file of files) {
213
- await sftp.put(
214
- Buffer.from(file.content, "base64"),
215
- `${remotePath}/${file.name}`
216
- );
217
- }
208
+ await sftp.connect({ host, username, password, port });
209
+
210
+ const dirExists = await sftp.exists(remotePath);
211
+ if (!dirExists) {
212
+ await sftp.mkdir(remotePath, true);
213
+ }
214
+
215
+ for (const file of files) {
216
+ const remoteFilePath = `${remotePath}/${file.name}`;
217
+ await sftp.put(Buffer.from(file.content, "base64"), remoteFilePath);
218
+ }
218
219
  } finally {
219
- sftp.end();
220
+ sftp.end();
220
221
  }
221
222
  }
223
+
222
224
 
223
225
  async generateNginxConfig(domain: string, rootPath: string): Promise<string> {
224
226
  const templatePath = path.join(__dirname, '..', 'templates', 'nginx-template.conf');