underpost 2.7.1 → 2.7.2
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/.dockerignore +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +582 -661
- package/bin/dns.js +1 -1
- package/bin/file.js +92 -92
- package/bin/index.js +53 -53
- package/bin/install.js +398 -357
- package/bin/shortcut.js +44 -44
- package/bin/ssl.js +65 -64
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -132
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/BlockChain.js +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +46 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -29
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +69 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -94
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +705 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -98
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +180 -180
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -28
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +109 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
package/bin/deploy.js
CHANGED
|
@@ -1,661 +1,582 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import axios from 'axios';
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
};
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
const
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
};
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
}
|
|
236
|
-
const
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
if (
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
const
|
|
482
|
-
const
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
)
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
|
|
584
|
-
originPackage.version = newVersion;
|
|
585
|
-
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
fs.writeFileSync(
|
|
591
|
-
`./docker-compose.yml`,
|
|
592
|
-
fs
|
|
593
|
-
.readFileSync(`./docker-compose.yml`, 'utf8')
|
|
594
|
-
.replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
|
|
595
|
-
'utf8',
|
|
596
|
-
);
|
|
597
|
-
|
|
598
|
-
if (fs.existsSync(`./.github/workflows/docker-image.yml`))
|
|
599
|
-
fs.writeFileSync(
|
|
600
|
-
`./.github/workflows/docker-image.yml`,
|
|
601
|
-
fs
|
|
602
|
-
.readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
|
|
603
|
-
.replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
|
|
604
|
-
'utf8',
|
|
605
|
-
);
|
|
606
|
-
|
|
607
|
-
fs.writeFileSync(
|
|
608
|
-
`./src/client/components/core/Docs.js`,
|
|
609
|
-
fs
|
|
610
|
-
.readFileSync(`./src/client/components/core/Docs.js`, 'utf8')
|
|
611
|
-
.replaceAll(`/engine/${version}`, `/engine/${newVersion}`),
|
|
612
|
-
'utf8',
|
|
613
|
-
);
|
|
614
|
-
|
|
615
|
-
fs.writeFileSync(
|
|
616
|
-
`./src/client/ssr/body-components/CacheControl.js`,
|
|
617
|
-
fs
|
|
618
|
-
.readFileSync(`./src/client/ssr/body-components/CacheControl.js`, 'utf8')
|
|
619
|
-
.replaceAll(`v${version}`, `v${newVersion}`),
|
|
620
|
-
'utf8',
|
|
621
|
-
);
|
|
622
|
-
|
|
623
|
-
fs.writeFileSync(
|
|
624
|
-
`./bin/index.js`,
|
|
625
|
-
fs.readFileSync(`./bin/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
|
|
626
|
-
'utf8',
|
|
627
|
-
);
|
|
628
|
-
}
|
|
629
|
-
break;
|
|
630
|
-
|
|
631
|
-
case 'update-authors': {
|
|
632
|
-
// shellExec(`git log --reverse --format='%aN (<%aE>)' | sort -u`, { stdout: true });
|
|
633
|
-
const logs = await simpleGit().log();
|
|
634
|
-
|
|
635
|
-
fs.writeFileSync(
|
|
636
|
-
'./AUTHORS.md',
|
|
637
|
-
`# Authors
|
|
638
|
-
|
|
639
|
-
#### Ordered by first contribution.
|
|
640
|
-
|
|
641
|
-
${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}](mailto:${log.author_email}))`)).join(`
|
|
642
|
-
`)}
|
|
643
|
-
|
|
644
|
-
#### Generated by [underpost.net](https://underpost.net)`,
|
|
645
|
-
'utf8',
|
|
646
|
-
);
|
|
647
|
-
|
|
648
|
-
// hash: '1c7418ad2f49c7798a6d28d370b34c69d31dce46',
|
|
649
|
-
// date: '2024-09-16T17:10:13-03:00',
|
|
650
|
-
// message: 'update',
|
|
651
|
-
// refs: '',
|
|
652
|
-
// body: '',
|
|
653
|
-
// author_name: 'fcoverdugo',
|
|
654
|
-
// author_email: 'fcoverdugoa@underpost.net'
|
|
655
|
-
}
|
|
656
|
-
default:
|
|
657
|
-
break;
|
|
658
|
-
}
|
|
659
|
-
} catch (error) {
|
|
660
|
-
logger.error(error, error.stack);
|
|
661
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import axios from 'axios';
|
|
3
|
+
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
import plantuml from 'plantuml';
|
|
6
|
+
|
|
7
|
+
import { shellCd, shellExec } from '../src/server/process.js';
|
|
8
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
9
|
+
import {
|
|
10
|
+
Config,
|
|
11
|
+
addApiConf,
|
|
12
|
+
addClientConf,
|
|
13
|
+
buildApiSrc,
|
|
14
|
+
buildClientSrc,
|
|
15
|
+
cloneConf,
|
|
16
|
+
loadConf,
|
|
17
|
+
loadReplicas,
|
|
18
|
+
addWsConf,
|
|
19
|
+
buildWsSrc,
|
|
20
|
+
cloneSrcComponents,
|
|
21
|
+
getDeployGroupId,
|
|
22
|
+
deployRun,
|
|
23
|
+
updateSrc,
|
|
24
|
+
getDataDeploy,
|
|
25
|
+
buildReplicaId,
|
|
26
|
+
Cmd,
|
|
27
|
+
restoreMacroDb,
|
|
28
|
+
} from '../src/server/conf.js';
|
|
29
|
+
import { buildClient } from '../src/server/client-build.js';
|
|
30
|
+
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
31
|
+
import toJsonSchema from 'to-json-schema';
|
|
32
|
+
import simpleGit from 'simple-git';
|
|
33
|
+
|
|
34
|
+
const logger = loggerFactory(import.meta);
|
|
35
|
+
|
|
36
|
+
logger.info('argv', process.argv);
|
|
37
|
+
|
|
38
|
+
const [exe, dir, operator] = process.argv;
|
|
39
|
+
|
|
40
|
+
try {
|
|
41
|
+
switch (operator) {
|
|
42
|
+
case 'save':
|
|
43
|
+
{
|
|
44
|
+
const deployId = process.argv[3];
|
|
45
|
+
const folder = `./engine-private/conf/${deployId}`;
|
|
46
|
+
if (fs.existsSync(folder)) fs.removeSync(folder);
|
|
47
|
+
await Config.build({ folder });
|
|
48
|
+
fs.writeFileSync(`${folder}/.env.production`, fs.readFileSync('./.env.production', 'utf8'), 'utf8');
|
|
49
|
+
fs.writeFileSync(`${folder}/.env.development`, fs.readFileSync('./.env.development', 'utf8'), 'utf8');
|
|
50
|
+
fs.writeFileSync(`${folder}/.env.test`, fs.readFileSync('./.env.test', 'utf8'), 'utf8');
|
|
51
|
+
fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
|
|
52
|
+
}
|
|
53
|
+
break;
|
|
54
|
+
case 'add-nodejs-app-client-conf':
|
|
55
|
+
{
|
|
56
|
+
const toOptions = {
|
|
57
|
+
deployId: process.argv[3],
|
|
58
|
+
clientId: process.argv[4],
|
|
59
|
+
host: process.argv[5],
|
|
60
|
+
path: process.argv[6],
|
|
61
|
+
};
|
|
62
|
+
const fromOptions = { deployId: process.argv[7], clientId: process.argv[8] };
|
|
63
|
+
addClientConf({ toOptions, fromOptions });
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
case 'build-nodejs-conf-app':
|
|
67
|
+
{
|
|
68
|
+
const toOptions = { deployId: process.argv[3], clientId: process.argv[4] };
|
|
69
|
+
const fromOptions = { deployId: process.argv[5], clientId: process.argv[6] };
|
|
70
|
+
cloneConf({ toOptions, fromOptions });
|
|
71
|
+
}
|
|
72
|
+
break;
|
|
73
|
+
case 'clone-nodejs-src-client-components':
|
|
74
|
+
{
|
|
75
|
+
const fromOptions = { componentsFolder: process.argv[3] };
|
|
76
|
+
const toOptions = { componentsFolder: process.argv[4] };
|
|
77
|
+
cloneSrcComponents({ toOptions, fromOptions });
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
case 'build-nodejs-src-app':
|
|
81
|
+
{
|
|
82
|
+
const toOptions = { deployId: process.argv[3], clientId: process.argv[4] };
|
|
83
|
+
const fromOptions = { deployId: process.argv[5], clientId: process.argv[6] };
|
|
84
|
+
buildClientSrc({ toOptions, fromOptions });
|
|
85
|
+
}
|
|
86
|
+
break;
|
|
87
|
+
case 'build-nodejs-conf-api':
|
|
88
|
+
{
|
|
89
|
+
const toOptions = { apiId: process.argv[3], deployId: process.argv[4], clientId: process.argv[5] };
|
|
90
|
+
const fromOptions = { apiId: process.argv[6], deployId: process.argv[7], clientId: process.argv[8] };
|
|
91
|
+
addApiConf({ toOptions, fromOptions });
|
|
92
|
+
}
|
|
93
|
+
break;
|
|
94
|
+
case 'build-nodejs-src-api':
|
|
95
|
+
{
|
|
96
|
+
const toOptions = { apiId: process.argv[3], deployId: process.argv[4], clientId: process.argv[5] };
|
|
97
|
+
const fromOptions = { apiId: process.argv[6], deployId: process.argv[7], clientId: process.argv[8] };
|
|
98
|
+
buildApiSrc({ toOptions, fromOptions });
|
|
99
|
+
}
|
|
100
|
+
break;
|
|
101
|
+
case 'build-nodejs-conf-ws':
|
|
102
|
+
{
|
|
103
|
+
const toOptions = {
|
|
104
|
+
wsId: process.argv[3],
|
|
105
|
+
deployId: process.argv[4],
|
|
106
|
+
host: process.argv[5],
|
|
107
|
+
paths: process.argv[6],
|
|
108
|
+
};
|
|
109
|
+
const fromOptions = {
|
|
110
|
+
wsId: process.argv[7],
|
|
111
|
+
deployId: process.argv[8],
|
|
112
|
+
host: process.argv[9],
|
|
113
|
+
paths: process.argv[10],
|
|
114
|
+
};
|
|
115
|
+
addWsConf({ toOptions, fromOptions });
|
|
116
|
+
}
|
|
117
|
+
break;
|
|
118
|
+
case 'build-nodejs-src-ws':
|
|
119
|
+
{
|
|
120
|
+
const toOptions = {
|
|
121
|
+
wsId: process.argv[3],
|
|
122
|
+
deployId: process.argv[4],
|
|
123
|
+
host: process.argv[5],
|
|
124
|
+
paths: process.argv[6],
|
|
125
|
+
};
|
|
126
|
+
const fromOptions = {
|
|
127
|
+
wsId: process.argv[7],
|
|
128
|
+
deployId: process.argv[8],
|
|
129
|
+
host: process.argv[9],
|
|
130
|
+
paths: process.argv[10],
|
|
131
|
+
};
|
|
132
|
+
buildWsSrc({ toOptions, fromOptions });
|
|
133
|
+
}
|
|
134
|
+
break;
|
|
135
|
+
case 'conf': {
|
|
136
|
+
loadConf(process.argv[3]);
|
|
137
|
+
if (process.argv[4]) fs.writeFileSync(`.env`, fs.readFileSync(`.env.${process.argv[4]}`, 'utf8'), 'utf8');
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
case 'run':
|
|
141
|
+
{
|
|
142
|
+
if (process.argv.includes('replicas')) {
|
|
143
|
+
const deployGroupId = getDeployGroupId();
|
|
144
|
+
const dataDeploy = getDataDeploy({
|
|
145
|
+
deployId: process.argv[3],
|
|
146
|
+
buildSingleReplica: true,
|
|
147
|
+
deployGroupId,
|
|
148
|
+
});
|
|
149
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
150
|
+
updateSrc();
|
|
151
|
+
await deployRun(dataDeploy);
|
|
152
|
+
} else {
|
|
153
|
+
loadConf(process.argv[3]);
|
|
154
|
+
shellExec(`npm start ${process.argv[3]}`);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
break;
|
|
158
|
+
case 'new-nodejs-app':
|
|
159
|
+
{
|
|
160
|
+
const deployId = process.argv[3];
|
|
161
|
+
const clientId = process.argv[4];
|
|
162
|
+
|
|
163
|
+
shellExec(`node bin/deploy build-nodejs-conf-app ${deployId} ${clientId}`);
|
|
164
|
+
|
|
165
|
+
shellExec(`node bin/deploy build-nodejs-src-app ${deployId} ${clientId}`);
|
|
166
|
+
|
|
167
|
+
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
168
|
+
|
|
169
|
+
shellExec(`npm run dev ${deployId}`);
|
|
170
|
+
}
|
|
171
|
+
break;
|
|
172
|
+
case 'test-new-api':
|
|
173
|
+
{
|
|
174
|
+
const port = process.argv[3];
|
|
175
|
+
const apiId = process.argv[4];
|
|
176
|
+
let url = `http://localhost:${port}/api/${apiId}`;
|
|
177
|
+
{
|
|
178
|
+
logger.info(`POST REQUEST`, url);
|
|
179
|
+
const result = await axios.post(url, {});
|
|
180
|
+
url += '/' + result.data.data._id;
|
|
181
|
+
logger.info(`POST RESULT ${url}`, result.data);
|
|
182
|
+
}
|
|
183
|
+
{
|
|
184
|
+
logger.info(`GET REQUEST`, url);
|
|
185
|
+
const result = await axios.get(url);
|
|
186
|
+
logger.info(`GET RESULT ${url}`, result.data);
|
|
187
|
+
}
|
|
188
|
+
{
|
|
189
|
+
logger.info(`DELETE REQUEST`, url);
|
|
190
|
+
const result = await axios.delete(url);
|
|
191
|
+
logger.info(`DELETE RESULT ${url}`, result.data);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
break;
|
|
195
|
+
case 'new-nodejs-api':
|
|
196
|
+
{
|
|
197
|
+
const apiId = process.argv[3];
|
|
198
|
+
const deployId = process.argv[4];
|
|
199
|
+
const clientId = process.argv[5];
|
|
200
|
+
|
|
201
|
+
shellExec(`node bin/deploy build-nodejs-conf-api ${apiId} ${deployId} ${clientId}`);
|
|
202
|
+
|
|
203
|
+
shellExec(`node bin/deploy build-nodejs-src-api ${apiId} ${deployId} ${clientId}`);
|
|
204
|
+
|
|
205
|
+
// shellExec(`npm run dev ${deployId}`);
|
|
206
|
+
}
|
|
207
|
+
break;
|
|
208
|
+
case 'new-nodejs-ws':
|
|
209
|
+
{
|
|
210
|
+
const wsId = process.argv[3];
|
|
211
|
+
const deployId = process.argv[4];
|
|
212
|
+
const host = process.argv[5];
|
|
213
|
+
const paths = process.argv[6];
|
|
214
|
+
|
|
215
|
+
shellExec(`node bin/deploy build-nodejs-conf-ws ${wsId} ${deployId} ${host} ${paths}`);
|
|
216
|
+
|
|
217
|
+
shellExec(`node bin/deploy build-nodejs-src-ws ${wsId} ${deployId} ${host} ${paths}`);
|
|
218
|
+
|
|
219
|
+
shellExec(`npm run dev ${deployId}`);
|
|
220
|
+
}
|
|
221
|
+
break;
|
|
222
|
+
case 'build-full-client':
|
|
223
|
+
{
|
|
224
|
+
const { deployId, folder } = loadConf(process.argv[3]);
|
|
225
|
+
|
|
226
|
+
let argHost = process.argv[4] ? process.argv[4].split(',') : undefined;
|
|
227
|
+
let argPath = process.argv[5] ? process.argv[5].split(',') : undefined;
|
|
228
|
+
let deployIdSingleReplicas = [];
|
|
229
|
+
const serverConf = deployId
|
|
230
|
+
? JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'))
|
|
231
|
+
: Config.default.server;
|
|
232
|
+
if (!deployId) {
|
|
233
|
+
argHost = 'default.net';
|
|
234
|
+
argPath = '/';
|
|
235
|
+
}
|
|
236
|
+
for (const host of Object.keys(serverConf)) {
|
|
237
|
+
for (const path of Object.keys(serverConf[host])) {
|
|
238
|
+
if (argHost && argPath && (!argHost.includes(host) || !argPath.includes(path))) {
|
|
239
|
+
delete serverConf[host][path];
|
|
240
|
+
} else {
|
|
241
|
+
serverConf[host][path].liteBuild = process.argv.includes('l') ? true : false;
|
|
242
|
+
serverConf[host][path].minifyBuild = process.env.NODE_ENV === 'production' ? true : false;
|
|
243
|
+
if (process.env.NODE_ENV === 'development' && process.argv.includes('static')) {
|
|
244
|
+
serverConf[host][path].apiBaseProxyPath = '/';
|
|
245
|
+
serverConf[host][path].apiBaseHost = `localhost:${parseInt(process.env.PORT) + 1}`;
|
|
246
|
+
}
|
|
247
|
+
if (serverConf[host][path].singleReplica && serverConf[host][path].replicas) {
|
|
248
|
+
deployIdSingleReplicas = deployIdSingleReplicas.concat(
|
|
249
|
+
serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
shellExec(Cmd.replica(deployId, host, path));
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
fs.writeFileSync(`./conf/conf.server.json`, JSON.stringify(serverConf, null, 4), 'utf-8');
|
|
258
|
+
await buildClient();
|
|
259
|
+
|
|
260
|
+
for (const replicaDeployId of deployIdSingleReplicas) {
|
|
261
|
+
shellExec(Cmd.conf(replicaDeployId));
|
|
262
|
+
shellExec(Cmd.build(replicaDeployId));
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
break;
|
|
266
|
+
|
|
267
|
+
case 'update-package':
|
|
268
|
+
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
269
|
+
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
270
|
+
for (const relativePath of files) {
|
|
271
|
+
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
272
|
+
if (filePah.split('/').pop() === 'package.json') {
|
|
273
|
+
originPackage.scripts.start = JSON.parse(fs.readFileSync(filePah), 'utf8').scripts.start;
|
|
274
|
+
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
break;
|
|
278
|
+
|
|
279
|
+
case 'run-macro':
|
|
280
|
+
{
|
|
281
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
282
|
+
updateSrc();
|
|
283
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
284
|
+
await deployRun(dataDeploy, true);
|
|
285
|
+
}
|
|
286
|
+
break;
|
|
287
|
+
|
|
288
|
+
case 'run-macro-build':
|
|
289
|
+
{
|
|
290
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
291
|
+
updateSrc();
|
|
292
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
293
|
+
for (const deploy of dataDeploy) {
|
|
294
|
+
shellExec(Cmd.conf(deploy.deployId));
|
|
295
|
+
shellExec(Cmd.build(deploy.deployId));
|
|
296
|
+
}
|
|
297
|
+
await deployRun(dataDeploy, true);
|
|
298
|
+
}
|
|
299
|
+
break;
|
|
300
|
+
case 'prometheus':
|
|
301
|
+
case 'prom':
|
|
302
|
+
{
|
|
303
|
+
const rangePort = [1, 20];
|
|
304
|
+
const promConfigPath = `./engine-private/prometheus/prometheus-service-config.yml`;
|
|
305
|
+
const rawConfig = fs
|
|
306
|
+
.readFileSync(promConfigPath, 'utf8')
|
|
307
|
+
.replaceAll(
|
|
308
|
+
`['']`,
|
|
309
|
+
JSON.stringify(range(...rangePort).map((i) => `host.docker.internal:30${setPad(i, '0', 2)}`)).replaceAll(
|
|
310
|
+
`"`,
|
|
311
|
+
`'`,
|
|
312
|
+
),
|
|
313
|
+
);
|
|
314
|
+
console.log(rawConfig);
|
|
315
|
+
|
|
316
|
+
fs.writeFileSync(promConfigPath, rawConfig, 'utf8');
|
|
317
|
+
|
|
318
|
+
shellExec(`docker-compose -f engine-private/prometheus/prometheus-service.yml up -d`);
|
|
319
|
+
}
|
|
320
|
+
break;
|
|
321
|
+
|
|
322
|
+
case 'sync-env-port':
|
|
323
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], disableSyncEnvPort: true });
|
|
324
|
+
const dataEnv = [
|
|
325
|
+
{ env: 'production', port: 3000 },
|
|
326
|
+
{ env: 'development', port: 4000 },
|
|
327
|
+
{ env: 'test', port: 5000 },
|
|
328
|
+
];
|
|
329
|
+
let port = 0;
|
|
330
|
+
const singleReplicaHosts = [];
|
|
331
|
+
for (const deployIdObj of dataDeploy) {
|
|
332
|
+
const { deployId, replicaHost } = deployIdObj;
|
|
333
|
+
if (replicaHost && !singleReplicaHosts.includes(replicaHost)) singleReplicaHosts.push(replicaHost);
|
|
334
|
+
const proxyInstance = deployId.match('proxy') || deployId.match('cron');
|
|
335
|
+
const baseConfPath = fs.existsSync(`./engine-private/replica/${deployId}`)
|
|
336
|
+
? `./engine-private/replica`
|
|
337
|
+
: `./engine-private/conf`;
|
|
338
|
+
for (const envInstanceObj of dataEnv) {
|
|
339
|
+
const envPath = `${baseConfPath}/${deployId}/.env.${envInstanceObj.env}`;
|
|
340
|
+
const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
341
|
+
envObj.PORT = proxyInstance
|
|
342
|
+
? envInstanceObj.port
|
|
343
|
+
: envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
344
|
+
|
|
345
|
+
fs.writeFileSync(
|
|
346
|
+
envPath,
|
|
347
|
+
Object.keys(envObj)
|
|
348
|
+
.map((key) => `${key}=${envObj[key]}`)
|
|
349
|
+
.join(`\n`),
|
|
350
|
+
'utf8',
|
|
351
|
+
);
|
|
352
|
+
}
|
|
353
|
+
const serverConf = loadReplicas(
|
|
354
|
+
JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
|
|
355
|
+
);
|
|
356
|
+
if (!proxyInstance) for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case 'uml':
|
|
360
|
+
{
|
|
361
|
+
shellExec(`node bin/deploy fix-uml ${process.argv.slice(3).join(' ')}`);
|
|
362
|
+
shellExec(`node bin/deploy build-uml ${process.argv.slice(3).join(' ')}`);
|
|
363
|
+
}
|
|
364
|
+
break;
|
|
365
|
+
|
|
366
|
+
case 'fix-uml': {
|
|
367
|
+
// required: java jdk-11.0.1
|
|
368
|
+
|
|
369
|
+
// comment:
|
|
370
|
+
// '--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'
|
|
371
|
+
// in plantuml.js src
|
|
372
|
+
|
|
373
|
+
// const deployId = process.argv[3];
|
|
374
|
+
// const clientId = process.argv[4];
|
|
375
|
+
// const folder = `./src/client/public/${clientId ? clientId : 'default'}/docs/plantuml`;
|
|
376
|
+
// const privateConfFolder = `./engine-private/conf/${deployId}`;
|
|
377
|
+
// const confData = !deployId
|
|
378
|
+
// ? Config.default
|
|
379
|
+
// : {
|
|
380
|
+
// client: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.client.json`, 'utf8')),
|
|
381
|
+
// ssr: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.ssr.json`, 'utf8')),
|
|
382
|
+
// server: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.server.json`, 'utf8')),
|
|
383
|
+
// cron: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.cron.json`, 'utf8')),
|
|
384
|
+
// };
|
|
385
|
+
|
|
386
|
+
fs.writeFileSync(
|
|
387
|
+
`./node_modules/plantuml/lib/plantuml.js`,
|
|
388
|
+
fs
|
|
389
|
+
.readFileSync(`./node_modules/plantuml/lib/plantuml.js`, 'utf8')
|
|
390
|
+
.replace(`'--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'`, `//`),
|
|
391
|
+
);
|
|
392
|
+
}
|
|
393
|
+
case 'build-uml':
|
|
394
|
+
{
|
|
395
|
+
const host = process.argv[3];
|
|
396
|
+
const path = process.argv[4];
|
|
397
|
+
const folder = `./public/${host}${path}/docs/plantuml`;
|
|
398
|
+
const confData = Config.default;
|
|
399
|
+
|
|
400
|
+
if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true });
|
|
401
|
+
|
|
402
|
+
for (const typeConf of Object.keys(confData)) {
|
|
403
|
+
{
|
|
404
|
+
const svg = await plantuml(`
|
|
405
|
+
@startjson
|
|
406
|
+
${JSON.stringify(confData[typeConf])}
|
|
407
|
+
@endjson
|
|
408
|
+
`);
|
|
409
|
+
fs.writeFileSync(`${folder}/${typeConf}-conf.svg`, svg);
|
|
410
|
+
}
|
|
411
|
+
{
|
|
412
|
+
const svg = await plantuml(`
|
|
413
|
+
@startjson
|
|
414
|
+
${JSON.stringify(toJsonSchema(confData[typeConf]))}
|
|
415
|
+
@endjson
|
|
416
|
+
`);
|
|
417
|
+
fs.writeFileSync(`${folder}/${typeConf}-schema.svg`, svg);
|
|
418
|
+
}
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
break;
|
|
422
|
+
|
|
423
|
+
case 'build-single-replica': {
|
|
424
|
+
const deployId = process.argv[3];
|
|
425
|
+
const host = process.argv[4];
|
|
426
|
+
const path = process.argv[5];
|
|
427
|
+
const serverConf = loadReplicas(
|
|
428
|
+
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
if (serverConf[host][path].replicas) {
|
|
432
|
+
{
|
|
433
|
+
let replicaIndex = -1;
|
|
434
|
+
for (const replica of serverConf[host][path].replicas) {
|
|
435
|
+
replicaIndex++;
|
|
436
|
+
const replicaDeployId = `${deployId}-${serverConf[host][path].replicas[replicaIndex].slice(1)}`;
|
|
437
|
+
// fs.mkdirSync(`./engine-private/replica/${deployId}${replicaIndex}`, { recursive: true });
|
|
438
|
+
await fs.copy(`./engine-private/conf/${deployId}`, `./engine-private/replica/${replicaDeployId}`);
|
|
439
|
+
fs.writeFileSync(
|
|
440
|
+
`./engine-private/replica/${replicaDeployId}/package.json`,
|
|
441
|
+
fs
|
|
442
|
+
.readFileSync(`./engine-private/replica/${replicaDeployId}/package.json`, 'utf8')
|
|
443
|
+
.replaceAll(`--name ${deployId}`, `--name ${replicaDeployId}`),
|
|
444
|
+
'utf8',
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
{
|
|
449
|
+
let replicaIndex = -1;
|
|
450
|
+
for (const replica of serverConf[host][path].replicas) {
|
|
451
|
+
replicaIndex++;
|
|
452
|
+
const replicaDeployId = `${deployId}-${serverConf[host][path].replicas[replicaIndex].slice(1)}`;
|
|
453
|
+
let replicaServerConf = JSON.parse(
|
|
454
|
+
fs.readFileSync(`./engine-private/replica/${replicaDeployId}/conf.server.json`, 'utf8'),
|
|
455
|
+
);
|
|
456
|
+
|
|
457
|
+
const singleReplicaConf = replicaServerConf[host][path];
|
|
458
|
+
singleReplicaConf.replicas = undefined;
|
|
459
|
+
singleReplicaConf.singleReplica = undefined;
|
|
460
|
+
|
|
461
|
+
replicaServerConf = {};
|
|
462
|
+
replicaServerConf[host] = {};
|
|
463
|
+
replicaServerConf[host][replica] = singleReplicaConf;
|
|
464
|
+
|
|
465
|
+
fs.writeFileSync(
|
|
466
|
+
`./engine-private/replica/${replicaDeployId}/conf.server.json`,
|
|
467
|
+
JSON.stringify(replicaServerConf, null, 4),
|
|
468
|
+
'utf8',
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
break;
|
|
474
|
+
}
|
|
475
|
+
case 'build-macro-replica':
|
|
476
|
+
getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
477
|
+
break;
|
|
478
|
+
case 'update-version':
|
|
479
|
+
{
|
|
480
|
+
const newVersion = process.argv[3];
|
|
481
|
+
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
|
482
|
+
const { version } = originPackageJson;
|
|
483
|
+
originPackageJson.version = newVersion;
|
|
484
|
+
fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
|
|
485
|
+
|
|
486
|
+
const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
|
|
487
|
+
originPackageLockJson.version = newVersion;
|
|
488
|
+
originPackageLockJson.packages[''].version = newVersion;
|
|
489
|
+
fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
|
|
490
|
+
|
|
491
|
+
if (fs.existsSync(`./engine-private/conf`)) {
|
|
492
|
+
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
493
|
+
for (const relativePath of files) {
|
|
494
|
+
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
495
|
+
if (filePah.split('/').pop() === 'package.json') {
|
|
496
|
+
const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
|
|
497
|
+
originPackage.version = newVersion;
|
|
498
|
+
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
}
|
|
502
|
+
|
|
503
|
+
fs.writeFileSync(
|
|
504
|
+
`./docker-compose.yml`,
|
|
505
|
+
fs
|
|
506
|
+
.readFileSync(`./docker-compose.yml`, 'utf8')
|
|
507
|
+
.replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
|
|
508
|
+
'utf8',
|
|
509
|
+
);
|
|
510
|
+
|
|
511
|
+
if (fs.existsSync(`./.github/workflows/docker-image.yml`))
|
|
512
|
+
fs.writeFileSync(
|
|
513
|
+
`./.github/workflows/docker-image.yml`,
|
|
514
|
+
fs
|
|
515
|
+
.readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
|
|
516
|
+
.replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
|
|
517
|
+
'utf8',
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
fs.writeFileSync(
|
|
521
|
+
`./src/client/components/core/Docs.js`,
|
|
522
|
+
fs
|
|
523
|
+
.readFileSync(`./src/client/components/core/Docs.js`, 'utf8')
|
|
524
|
+
.replaceAll(`/engine/${version}`, `/engine/${newVersion}`),
|
|
525
|
+
'utf8',
|
|
526
|
+
);
|
|
527
|
+
|
|
528
|
+
fs.writeFileSync(
|
|
529
|
+
`./src/client/ssr/body-components/CacheControl.js`,
|
|
530
|
+
fs
|
|
531
|
+
.readFileSync(`./src/client/ssr/body-components/CacheControl.js`, 'utf8')
|
|
532
|
+
.replaceAll(`v${version}`, `v${newVersion}`),
|
|
533
|
+
'utf8',
|
|
534
|
+
);
|
|
535
|
+
|
|
536
|
+
fs.writeFileSync(
|
|
537
|
+
`./bin/index.js`,
|
|
538
|
+
fs.readFileSync(`./bin/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
|
|
539
|
+
'utf8',
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
break;
|
|
543
|
+
|
|
544
|
+
case 'update-authors': {
|
|
545
|
+
// shellExec(`git log --reverse --format='%aN (<%aE>)' | sort -u`, { stdout: true });
|
|
546
|
+
const logs = await simpleGit().log();
|
|
547
|
+
|
|
548
|
+
fs.writeFileSync(
|
|
549
|
+
'./AUTHORS.md',
|
|
550
|
+
`# Authors
|
|
551
|
+
|
|
552
|
+
#### Ordered by first contribution.
|
|
553
|
+
|
|
554
|
+
${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}](mailto:${log.author_email}))`)).join(`
|
|
555
|
+
`)}
|
|
556
|
+
|
|
557
|
+
#### Generated by [underpost.net](https://underpost.net)`,
|
|
558
|
+
'utf8',
|
|
559
|
+
);
|
|
560
|
+
|
|
561
|
+
// hash: '1c7418ad2f49c7798a6d28d370b34c69d31dce46',
|
|
562
|
+
// date: '2024-09-16T17:10:13-03:00',
|
|
563
|
+
// message: 'update',
|
|
564
|
+
// refs: '',
|
|
565
|
+
// body: '',
|
|
566
|
+
// author_name: 'fcoverdugo',
|
|
567
|
+
// author_email: 'fcoverdugoa@underpost.net'
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
case 'restore-macro-db':
|
|
571
|
+
{
|
|
572
|
+
const deployGroupId = process.argv[3];
|
|
573
|
+
await restoreMacroDb(deployGroupId);
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
break;
|
|
577
|
+
default:
|
|
578
|
+
break;
|
|
579
|
+
}
|
|
580
|
+
} catch (error) {
|
|
581
|
+
logger.error(error, error.stack);
|
|
582
|
+
}
|