@bprotsyk/aso-core 2.0.26 → 2.0.28
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,6 +3,10 @@ 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 FileObject {
|
|
7
|
+
name: string;
|
|
8
|
+
content: string;
|
|
9
|
+
}
|
|
6
10
|
export declare class ServerUtil {
|
|
7
11
|
DOMAIN_HOME: string;
|
|
8
12
|
ssh?: NodeSSH;
|
|
@@ -23,7 +27,8 @@ export declare class ServerUtil {
|
|
|
23
27
|
setupCertbot(): Promise<boolean>;
|
|
24
28
|
setupSSL(email: string, host: string): Promise<void>;
|
|
25
29
|
refresh(): Promise<boolean>;
|
|
26
|
-
deployLandingPage(host: string, username: string, password: string, remotePath: string, port: number, files:
|
|
30
|
+
deployLandingPage(host: string, username: string, password: string, remotePath: string, port: number, files: FileObject[]): Promise<void>;
|
|
27
31
|
generateNginxConfig(domain: string, rootPath: string): Promise<string>;
|
|
28
32
|
serverConect(IP: string): Promise<boolean>;
|
|
29
33
|
}
|
|
34
|
+
export {};
|
package/lib/utils/server-util.js
CHANGED
|
@@ -169,11 +169,15 @@ 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
|
-
|
|
178
|
+
const normalizedFileName = path_1.default.basename(file.name);
|
|
179
|
+
const remoteFilePath = path_1.default.join(remotePath, normalizedFileName);
|
|
180
|
+
await sftp.put(Buffer.from(file.content, "base64"), remoteFilePath);
|
|
177
181
|
}
|
|
178
182
|
}
|
|
179
183
|
finally {
|
package/package.json
CHANGED
package/src/utils/server-util.ts
CHANGED
|
@@ -12,6 +12,11 @@ export let PASSWORD = "xUA3oOX06Kfc9m12rZ";
|
|
|
12
12
|
export let HOST = "cg-main-server.com";
|
|
13
13
|
export let PORT = 56777;
|
|
14
14
|
|
|
15
|
+
interface FileObject {
|
|
16
|
+
name: string;
|
|
17
|
+
content: string; // Це буде Base64 закодовані дані
|
|
18
|
+
}
|
|
19
|
+
|
|
15
20
|
export class ServerUtil {
|
|
16
21
|
DOMAIN_HOME = "/etc/nginx/sites-enabled";
|
|
17
22
|
|
|
@@ -192,6 +197,7 @@ export class ServerUtil {
|
|
|
192
197
|
|
|
193
198
|
return true;
|
|
194
199
|
}
|
|
200
|
+
|
|
195
201
|
|
|
196
202
|
|
|
197
203
|
|
|
@@ -201,24 +207,27 @@ export class ServerUtil {
|
|
|
201
207
|
password: string,
|
|
202
208
|
remotePath: string,
|
|
203
209
|
port: number,
|
|
204
|
-
files:
|
|
210
|
+
files: FileObject[]
|
|
205
211
|
): Promise<void> {
|
|
206
212
|
let sftp = new Client();
|
|
207
213
|
try {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
214
|
+
await sftp.connect({ host, username, password, port });
|
|
215
|
+
|
|
216
|
+
const dirExists = await sftp.exists(remotePath);
|
|
217
|
+
if (!dirExists) {
|
|
218
|
+
await sftp.mkdir(remotePath, true);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
for (const file of files) {
|
|
222
|
+
const normalizedFileName = path.basename(file.name);
|
|
223
|
+
const remoteFilePath = path.join(remotePath, normalizedFileName);
|
|
224
|
+
await sftp.put(Buffer.from(file.content, "base64"), remoteFilePath);
|
|
225
|
+
}
|
|
218
226
|
} finally {
|
|
219
|
-
|
|
227
|
+
sftp.end();
|
|
220
228
|
}
|
|
221
229
|
}
|
|
230
|
+
|
|
222
231
|
|
|
223
232
|
async generateNginxConfig(domain: string, rootPath: string): Promise<string> {
|
|
224
233
|
const templatePath = path.join(__dirname, '..', 'templates', 'nginx-template.conf');
|