@underpostnet/underpost 2.7.9
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 +14 -0
- package/.env.development +6 -0
- package/.env.production +6 -0
- package/.env.test +6 -0
- package/.github/workflows/ghpkg.yml +115 -0
- package/.github/workflows/publish.yml +84 -0
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.github/workflows/pwa-microservices-template.test.yml +30 -0
- package/.nycrc +9 -0
- package/.prettierignore +13 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +72 -0
- package/.vscode/settings.json +106 -0
- package/AUTHORS.md +10 -0
- package/CHANGELOG.md +85 -0
- package/Dockerfile +90 -0
- package/LICENSE +21 -0
- package/README.md +96 -0
- package/bin/cron.js +47 -0
- package/bin/db.js +180 -0
- package/bin/deploy.js +859 -0
- package/bin/file.js +109 -0
- package/bin/index.js +82 -0
- package/bin/ssl.js +55 -0
- package/bin/util.js +204 -0
- package/bin/vs.js +35 -0
- package/conf.js +265 -0
- package/docker-compose.yml +67 -0
- package/jsconfig.json +7 -0
- package/jsdoc.json +32 -0
- package/nodemon.json +6 -0
- package/package.json +134 -0
- package/prometheus.yml +36 -0
- package/src/api/core/core.controller.js +69 -0
- package/src/api/core/core.model.js +11 -0
- package/src/api/core/core.router.js +23 -0
- package/src/api/core/core.service.js +31 -0
- package/src/api/crypto/crypto.controller.js +51 -0
- package/src/api/crypto/crypto.model.js +23 -0
- package/src/api/crypto/crypto.router.js +20 -0
- package/src/api/crypto/crypto.service.js +64 -0
- package/src/api/default/default.controller.js +69 -0
- package/src/api/default/default.model.js +20 -0
- package/src/api/default/default.router.js +23 -0
- package/src/api/default/default.service.js +31 -0
- package/src/api/file/file.controller.js +53 -0
- package/src/api/file/file.model.js +19 -0
- package/src/api/file/file.router.js +21 -0
- package/src/api/file/file.service.js +80 -0
- package/src/api/instance/instance.controller.js +69 -0
- package/src/api/instance/instance.model.js +36 -0
- package/src/api/instance/instance.router.js +33 -0
- package/src/api/instance/instance.service.js +48 -0
- package/src/api/test/test.controller.js +59 -0
- package/src/api/test/test.model.js +14 -0
- package/src/api/test/test.router.js +21 -0
- package/src/api/test/test.service.js +35 -0
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -0
- package/src/api/user/user.model.js +65 -0
- package/src/api/user/user.router.js +345 -0
- package/src/api/user/user.service.js +479 -0
- package/src/api.js +23 -0
- package/src/client/Default.index.js +40 -0
- package/src/client/components/core/Account.js +290 -0
- package/src/client/components/core/AgGrid.js +160 -0
- package/src/client/components/core/Auth.js +19 -0
- package/src/client/components/core/Badge.js +32 -0
- package/src/client/components/core/Blockchain.js +41 -0
- package/src/client/components/core/Blog.js +9 -0
- package/src/client/components/core/BtnIcon.js +101 -0
- package/src/client/components/core/CalendarCore.js +458 -0
- package/src/client/components/core/Chat.js +64 -0
- package/src/client/components/core/ColorPalette.js +5267 -0
- package/src/client/components/core/CommonJs.js +742 -0
- package/src/client/components/core/Content.js +193 -0
- package/src/client/components/core/Css.js +846 -0
- package/src/client/components/core/CssCore.js +844 -0
- package/src/client/components/core/D3Chart.js +44 -0
- package/src/client/components/core/Docs.js +331 -0
- package/src/client/components/core/DropDown.js +164 -0
- package/src/client/components/core/EventsUI.js +46 -0
- package/src/client/components/core/FileExplorer.js +699 -0
- package/src/client/components/core/FullScreen.js +45 -0
- package/src/client/components/core/Input.js +346 -0
- package/src/client/components/core/JoyStick.js +77 -0
- package/src/client/components/core/Keyboard.js +73 -0
- package/src/client/components/core/LoadingAnimation.js +178 -0
- package/src/client/components/core/LogIn.js +187 -0
- package/src/client/components/core/LogOut.js +58 -0
- package/src/client/components/core/Logger.js +26 -0
- package/src/client/components/core/Modal.js +1814 -0
- package/src/client/components/core/NotificationManager.js +84 -0
- package/src/client/components/core/Panel.js +613 -0
- package/src/client/components/core/PanelForm.js +469 -0
- package/src/client/components/core/Polyhedron.js +162 -0
- package/src/client/components/core/Recover.js +204 -0
- package/src/client/components/core/Responsive.js +68 -0
- package/src/client/components/core/RichText.js +53 -0
- package/src/client/components/core/Router.js +76 -0
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -0
- package/src/client/components/core/SocketIo.js +72 -0
- package/src/client/components/core/Stream.js +113 -0
- package/src/client/components/core/ToggleSwitch.js +87 -0
- package/src/client/components/core/ToolTip.js +26 -0
- package/src/client/components/core/Translate.js +446 -0
- package/src/client/components/core/Validator.js +100 -0
- package/src/client/components/core/VanillaJs.js +463 -0
- package/src/client/components/core/Wallet.js +106 -0
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Webhook.js +25 -0
- package/src/client/components/core/Worker.js +280 -0
- package/src/client/components/default/CommonDefault.js +29 -0
- package/src/client/components/default/CssDefault.js +13 -0
- package/src/client/components/default/ElementsDefault.js +38 -0
- package/src/client/components/default/LogInDefault.js +41 -0
- package/src/client/components/default/LogOutDefault.js +28 -0
- package/src/client/components/default/MenuDefault.js +389 -0
- package/src/client/components/default/RoutesDefault.js +48 -0
- package/src/client/components/default/SettingsDefault.js +16 -0
- package/src/client/components/default/SignUpDefault.js +9 -0
- package/src/client/components/default/SocketIoDefault.js +54 -0
- package/src/client/components/default/TranslateDefault.js +7 -0
- package/src/client/public/default/android-chrome-144x144.png +0 -0
- package/src/client/public/default/android-chrome-192x192.png +0 -0
- package/src/client/public/default/android-chrome-256x256.png +0 -0
- package/src/client/public/default/android-chrome-36x36.png +0 -0
- package/src/client/public/default/android-chrome-384x384.png +0 -0
- package/src/client/public/default/android-chrome-48x48.png +0 -0
- package/src/client/public/default/android-chrome-512x512.png +0 -0
- package/src/client/public/default/android-chrome-72x72.png +0 -0
- package/src/client/public/default/android-chrome-96x96.png +0 -0
- package/src/client/public/default/apple-touch-icon-1024x1024.png +0 -0
- package/src/client/public/default/apple-touch-icon-114x114.png +0 -0
- package/src/client/public/default/apple-touch-icon-120x120.png +0 -0
- package/src/client/public/default/apple-touch-icon-144x144.png +0 -0
- package/src/client/public/default/apple-touch-icon-152x152.png +0 -0
- package/src/client/public/default/apple-touch-icon-167x167.png +0 -0
- package/src/client/public/default/apple-touch-icon-180x180.png +0 -0
- package/src/client/public/default/apple-touch-icon-57x57.png +0 -0
- package/src/client/public/default/apple-touch-icon-60x60.png +0 -0
- package/src/client/public/default/apple-touch-icon-72x72.png +0 -0
- package/src/client/public/default/apple-touch-icon-76x76.png +0 -0
- package/src/client/public/default/apple-touch-icon-precomposed.png +0 -0
- package/src/client/public/default/apple-touch-icon.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1125x2436.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1136x640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1170x2532.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1179x2556.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2208.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1242x2688.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1284x2778.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1290x2796.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1334x750.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1488x2266.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1536x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1620x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1640x2160.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2224.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1668x2388.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-1792x828.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x1536.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2048x2732.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1620.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2160x1640.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2208x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2224x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2266x1488.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2388x1668.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2436x1125.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2532x1170.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2556x1179.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2688x1242.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2732x2048.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2778x1284.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-2796x1290.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-640x1136.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-750x1334.png +0 -0
- package/src/client/public/default/apple-touch-startup-image-828x1792.png +0 -0
- package/src/client/public/default/assets/background/white.jpg +0 -0
- package/src/client/public/default/assets/background/white0-min.jpg +0 -0
- package/src/client/public/default/assets/background/white0.jpg +0 -0
- package/src/client/public/default/assets/logo/base-icon.png +0 -0
- 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 +12 -0
- package/src/client/public/default/favicon-16x16.png +0 -0
- package/src/client/public/default/favicon-32x32.png +0 -0
- package/src/client/public/default/favicon-48x48.png +0 -0
- package/src/client/public/default/favicon.ico +0 -0
- package/src/client/public/default/manifest.webmanifest +69 -0
- package/src/client/public/default/mstile-144x144.png +0 -0
- package/src/client/public/default/mstile-150x150.png +0 -0
- package/src/client/public/default/mstile-310x150.png +0 -0
- package/src/client/public/default/mstile-310x310.png +0 -0
- package/src/client/public/default/mstile-70x70.png +0 -0
- 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/site.webmanifest +69 -0
- package/src/client/public/default/sitemap +148 -0
- package/src/client/public/default/yandex-browser-50x50.png +0 -0
- package/src/client/public/default/yandex-browser-manifest.json +9 -0
- package/src/client/public/doc/favicon.ico +0 -0
- package/src/client/public/doc/sitemap +148 -0
- package/src/client/public/test/favicon.ico +0 -0
- package/src/client/public/test/sitemap +148 -0
- package/src/client/services/core/core.service.js +170 -0
- package/src/client/services/crypto/crypto.service.js +70 -0
- package/src/client/services/default/default.management.js +343 -0
- package/src/client/services/default/default.service.js +89 -0
- package/src/client/services/file/file.service.js +70 -0
- package/src/client/services/instance/instance.management.js +74 -0
- package/src/client/services/instance/instance.service.js +89 -0
- package/src/client/services/test/test.service.js +70 -0
- package/src/client/services/user/user.management.js +50 -0
- package/src/client/services/user/user.service.js +89 -0
- package/src/client/ssr/Render.js +237 -0
- package/src/client/ssr/common/Alert.js +75 -0
- package/src/client/ssr/common/SsrCore.js +91 -0
- package/src/client/ssr/common/Translate.js +26 -0
- package/src/client/ssr/common/Worker.js +28 -0
- package/src/client/ssr/components/body/CacheControl.js +114 -0
- package/src/client/ssr/components/body/DefaultSplashScreen.js +90 -0
- package/src/client/ssr/components/email/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/components/email/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/components/head/Css.js +241 -0
- package/src/client/ssr/components/head/DefaultScripts.js +3 -0
- package/src/client/ssr/components/head/Production.js +1 -0
- package/src/client/ssr/components/head/Pwa.js +146 -0
- package/src/client/ssr/components/head/PwaDefault.js +60 -0
- package/src/client/ssr/components/head/Seo.js +14 -0
- package/src/client/ssr/pages/404.js +12 -0
- package/src/client/ssr/pages/500.js +12 -0
- package/src/client/ssr/pages/maintenance.js +14 -0
- package/src/client/ssr/pages/offline.js +21 -0
- package/src/client/sw/default.sw.js +205 -0
- package/src/client/sw/template.sw.js +84 -0
- package/src/client.build.js +22 -0
- package/src/client.dev.js +21 -0
- package/src/db/DataBaseProvider.js +45 -0
- package/src/db/mariadb/MariaDB.js +33 -0
- package/src/db/mongo/MongooseDB.js +124 -0
- package/src/dns.js +22 -0
- package/src/index.js +43 -0
- package/src/mailer/EmailRender.js +69 -0
- package/src/mailer/MailerProvider.js +96 -0
- package/src/proxy.js +22 -0
- package/src/runtime/lampp/Lampp.js +115 -0
- package/src/runtime/nginx/Nginx.js +3 -0
- package/src/runtime/xampp/Xampp.js +49 -0
- package/src/server/auth.js +235 -0
- package/src/server/backup.js +120 -0
- package/src/server/client-build-live.js +98 -0
- package/src/server/client-build.js +754 -0
- package/src/server/client-dev-server.js +60 -0
- package/src/server/client-formatted.js +58 -0
- package/src/server/client-icons.js +151 -0
- package/src/server/conf.js +929 -0
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +118 -0
- package/src/server/downloader.js +42 -0
- package/src/server/logger.js +190 -0
- package/src/server/network.js +209 -0
- package/src/server/peer.js +33 -0
- package/src/server/process.js +66 -0
- package/src/server/prompt-optimizer.js +28 -0
- package/src/server/proxy.js +118 -0
- package/src/server/runtime.js +463 -0
- package/src/server/ssl.js +120 -0
- package/src/server.js +25 -0
- package/src/ws/IoInterface.js +45 -0
- package/src/ws/IoServer.js +39 -0
- package/src/ws/core/channels/core.ws.chat.js +23 -0
- package/src/ws/core/channels/core.ws.mailer.js +35 -0
- package/src/ws/core/channels/core.ws.stream.js +31 -0
- package/src/ws/core/core.ws.connection.js +28 -0
- package/src/ws/core/core.ws.emit.js +14 -0
- package/src/ws/core/core.ws.server.js +24 -0
- package/src/ws/core/management/core.ws.chat.js +8 -0
- package/src/ws/core/management/core.ws.mailer.js +16 -0
- package/src/ws/core/management/core.ws.stream.js +8 -0
- package/src/ws/default/channels/default.ws.main.js +16 -0
- package/src/ws/default/default.ws.connection.js +22 -0
- package/src/ws/default/default.ws.emit.js +14 -0
- package/src/ws/default/default.ws.server.js +20 -0
- package/src/ws/default/management/default.ws.main.js +8 -0
- package/startup.js +11 -0
- package/supervisord-openssh-server.conf +5 -0
- package/test/api.test.js +60 -0
package/bin/deploy.js
ADDED
|
@@ -0,0 +1,859 @@
|
|
|
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
|
+
getDataDeploy,
|
|
24
|
+
buildReplicaId,
|
|
25
|
+
Cmd,
|
|
26
|
+
restoreMacroDb,
|
|
27
|
+
fixDependencies,
|
|
28
|
+
setUpProxyMaintenanceServer,
|
|
29
|
+
} from '../src/server/conf.js';
|
|
30
|
+
import { buildClient } from '../src/server/client-build.js';
|
|
31
|
+
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
32
|
+
import toJsonSchema from 'to-json-schema';
|
|
33
|
+
import simpleGit from 'simple-git';
|
|
34
|
+
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
35
|
+
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
36
|
+
import { DefaultConf } from '../conf.js';
|
|
37
|
+
import { JSONweb } from '../src/server/client-formatted.js';
|
|
38
|
+
|
|
39
|
+
const logger = loggerFactory(import.meta);
|
|
40
|
+
|
|
41
|
+
logger.info('argv', process.argv);
|
|
42
|
+
|
|
43
|
+
const [exe, dir, operator] = process.argv;
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
switch (operator) {
|
|
47
|
+
case 'save':
|
|
48
|
+
{
|
|
49
|
+
const deployId = process.argv[3];
|
|
50
|
+
const folder = `./engine-private/conf/${deployId}`;
|
|
51
|
+
if (fs.existsSync(folder)) fs.removeSync(folder);
|
|
52
|
+
await Config.build({ folder });
|
|
53
|
+
fs.writeFileSync(`${folder}/.env.production`, fs.readFileSync('./.env.production', 'utf8'), 'utf8');
|
|
54
|
+
fs.writeFileSync(`${folder}/.env.development`, fs.readFileSync('./.env.development', 'utf8'), 'utf8');
|
|
55
|
+
fs.writeFileSync(`${folder}/.env.test`, fs.readFileSync('./.env.test', 'utf8'), 'utf8');
|
|
56
|
+
fs.writeFileSync(`${folder}/package.json`, fs.readFileSync('./package.json', 'utf8'), 'utf8');
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
case 'add-nodejs-app-client-conf':
|
|
60
|
+
{
|
|
61
|
+
const toOptions = {
|
|
62
|
+
deployId: process.argv[3],
|
|
63
|
+
clientId: process.argv[4],
|
|
64
|
+
host: process.argv[5],
|
|
65
|
+
path: process.argv[6],
|
|
66
|
+
};
|
|
67
|
+
const fromOptions = { deployId: process.argv[7], clientId: process.argv[8] };
|
|
68
|
+
addClientConf({ toOptions, fromOptions });
|
|
69
|
+
}
|
|
70
|
+
break;
|
|
71
|
+
case 'build-nodejs-conf-app':
|
|
72
|
+
{
|
|
73
|
+
const toOptions = { deployId: process.argv[3], clientId: process.argv[4] };
|
|
74
|
+
const fromOptions = { deployId: process.argv[5], clientId: process.argv[6] };
|
|
75
|
+
cloneConf({ toOptions, fromOptions });
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case 'clone-nodejs-src-client-components':
|
|
79
|
+
{
|
|
80
|
+
const fromOptions = { componentsFolder: process.argv[3] };
|
|
81
|
+
const toOptions = { componentsFolder: process.argv[4] };
|
|
82
|
+
cloneSrcComponents({ toOptions, fromOptions });
|
|
83
|
+
}
|
|
84
|
+
break;
|
|
85
|
+
case 'build-nodejs-src-app':
|
|
86
|
+
{
|
|
87
|
+
const toOptions = { deployId: process.argv[3], clientId: process.argv[4] };
|
|
88
|
+
const fromOptions = { deployId: process.argv[5], clientId: process.argv[6] };
|
|
89
|
+
buildClientSrc({ toOptions, fromOptions });
|
|
90
|
+
}
|
|
91
|
+
break;
|
|
92
|
+
case 'build-nodejs-conf-api':
|
|
93
|
+
{
|
|
94
|
+
const toOptions = { apiId: process.argv[3], deployId: process.argv[4], clientId: process.argv[5] };
|
|
95
|
+
const fromOptions = { apiId: process.argv[6], deployId: process.argv[7], clientId: process.argv[8] };
|
|
96
|
+
addApiConf({ toOptions, fromOptions });
|
|
97
|
+
}
|
|
98
|
+
break;
|
|
99
|
+
case 'build-nodejs-src-api':
|
|
100
|
+
{
|
|
101
|
+
const toOptions = { apiId: process.argv[3], deployId: process.argv[4], clientId: process.argv[5] };
|
|
102
|
+
const fromOptions = { apiId: process.argv[6], deployId: process.argv[7], clientId: process.argv[8] };
|
|
103
|
+
buildApiSrc({ toOptions, fromOptions });
|
|
104
|
+
}
|
|
105
|
+
break;
|
|
106
|
+
case 'build-nodejs-conf-ws':
|
|
107
|
+
{
|
|
108
|
+
const toOptions = {
|
|
109
|
+
wsId: process.argv[3],
|
|
110
|
+
deployId: process.argv[4],
|
|
111
|
+
host: process.argv[5],
|
|
112
|
+
paths: process.argv[6],
|
|
113
|
+
};
|
|
114
|
+
const fromOptions = {
|
|
115
|
+
wsId: process.argv[7],
|
|
116
|
+
deployId: process.argv[8],
|
|
117
|
+
host: process.argv[9],
|
|
118
|
+
paths: process.argv[10],
|
|
119
|
+
};
|
|
120
|
+
addWsConf({ toOptions, fromOptions });
|
|
121
|
+
}
|
|
122
|
+
break;
|
|
123
|
+
case 'build-nodejs-src-ws':
|
|
124
|
+
{
|
|
125
|
+
const toOptions = {
|
|
126
|
+
wsId: process.argv[3],
|
|
127
|
+
deployId: process.argv[4],
|
|
128
|
+
host: process.argv[5],
|
|
129
|
+
paths: process.argv[6],
|
|
130
|
+
};
|
|
131
|
+
const fromOptions = {
|
|
132
|
+
wsId: process.argv[7],
|
|
133
|
+
deployId: process.argv[8],
|
|
134
|
+
host: process.argv[9],
|
|
135
|
+
paths: process.argv[10],
|
|
136
|
+
};
|
|
137
|
+
buildWsSrc({ toOptions, fromOptions });
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
case 'conf': {
|
|
141
|
+
loadConf(process.argv[3]);
|
|
142
|
+
if (process.argv[4]) fs.writeFileSync(`.env`, fs.readFileSync(`.env.${process.argv[4]}`, 'utf8'), 'utf8');
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case 'run':
|
|
146
|
+
{
|
|
147
|
+
if (process.argv.includes('replicas')) {
|
|
148
|
+
const deployGroupId = getDeployGroupId();
|
|
149
|
+
const dataDeploy = getDataDeploy({
|
|
150
|
+
deployId: process.argv[3],
|
|
151
|
+
buildSingleReplica: true,
|
|
152
|
+
deployGroupId,
|
|
153
|
+
});
|
|
154
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
155
|
+
await deployRun(dataDeploy);
|
|
156
|
+
} else {
|
|
157
|
+
loadConf(process.argv[3]);
|
|
158
|
+
shellExec(`npm start ${process.argv.includes('maintenance') ? 'maintenance' : ''}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
break;
|
|
162
|
+
|
|
163
|
+
case 'remove-await-deploy': {
|
|
164
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
case 'new-nodejs-app':
|
|
168
|
+
{
|
|
169
|
+
const deployId = process.argv[3];
|
|
170
|
+
const clientId = process.argv[4];
|
|
171
|
+
|
|
172
|
+
shellExec(`node bin/deploy build-nodejs-conf-app ${deployId} ${clientId}`);
|
|
173
|
+
|
|
174
|
+
shellExec(`node bin/deploy build-nodejs-src-app ${deployId} ${clientId}`);
|
|
175
|
+
|
|
176
|
+
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
177
|
+
|
|
178
|
+
shellExec(`npm run dev ${deployId}`);
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
case 'test-new-api':
|
|
182
|
+
{
|
|
183
|
+
const port = process.argv[3];
|
|
184
|
+
const apiId = process.argv[4];
|
|
185
|
+
let url = `http://localhost:${port}/api/${apiId}`;
|
|
186
|
+
{
|
|
187
|
+
logger.info(`POST REQUEST`, url);
|
|
188
|
+
const result = await axios.post(url, {});
|
|
189
|
+
url += '/' + result.data.data._id;
|
|
190
|
+
logger.info(`POST RESULT ${url}`, result.data);
|
|
191
|
+
}
|
|
192
|
+
{
|
|
193
|
+
logger.info(`GET REQUEST`, url);
|
|
194
|
+
const result = await axios.get(url);
|
|
195
|
+
logger.info(`GET RESULT ${url}`, result.data);
|
|
196
|
+
}
|
|
197
|
+
{
|
|
198
|
+
logger.info(`DELETE REQUEST`, url);
|
|
199
|
+
const result = await axios.delete(url);
|
|
200
|
+
logger.info(`DELETE RESULT ${url}`, result.data);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
break;
|
|
204
|
+
case 'new-nodejs-api':
|
|
205
|
+
{
|
|
206
|
+
const apiId = process.argv[3];
|
|
207
|
+
const deployId = process.argv[4];
|
|
208
|
+
const clientId = process.argv[5];
|
|
209
|
+
|
|
210
|
+
shellExec(`node bin/deploy build-nodejs-conf-api ${apiId} ${deployId} ${clientId}`);
|
|
211
|
+
|
|
212
|
+
shellExec(`node bin/deploy build-nodejs-src-api ${apiId} ${deployId} ${clientId}`);
|
|
213
|
+
|
|
214
|
+
// shellExec(`npm run dev ${deployId}`);
|
|
215
|
+
}
|
|
216
|
+
break;
|
|
217
|
+
case 'new-nodejs-ws':
|
|
218
|
+
{
|
|
219
|
+
const wsId = process.argv[3];
|
|
220
|
+
const deployId = process.argv[4];
|
|
221
|
+
const host = process.argv[5];
|
|
222
|
+
const paths = process.argv[6];
|
|
223
|
+
|
|
224
|
+
shellExec(`node bin/deploy build-nodejs-conf-ws ${wsId} ${deployId} ${host} ${paths}`);
|
|
225
|
+
|
|
226
|
+
shellExec(`node bin/deploy build-nodejs-src-ws ${wsId} ${deployId} ${host} ${paths}`);
|
|
227
|
+
|
|
228
|
+
shellExec(`npm run dev ${deployId}`);
|
|
229
|
+
}
|
|
230
|
+
break;
|
|
231
|
+
case 'build-full-client':
|
|
232
|
+
{
|
|
233
|
+
if (!process.argv[3]) process.argv[3] = 'default';
|
|
234
|
+
const { deployId, folder } = loadConf(process.argv[3]);
|
|
235
|
+
|
|
236
|
+
let argHost = process.argv[4] ? process.argv[4].split(',') : [];
|
|
237
|
+
let argPath = process.argv[5] ? process.argv[5].split(',') : [];
|
|
238
|
+
let deployIdSingleReplicas = [];
|
|
239
|
+
const serverConf = deployId
|
|
240
|
+
? JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'))
|
|
241
|
+
: Config.default.server;
|
|
242
|
+
for (const host of Object.keys(serverConf)) {
|
|
243
|
+
for (const path of Object.keys(serverConf[host])) {
|
|
244
|
+
if (argHost.length && argPath.length && (!argHost.includes(host) || !argPath.includes(path))) {
|
|
245
|
+
delete serverConf[host][path];
|
|
246
|
+
} else {
|
|
247
|
+
serverConf[host][path].liteBuild = process.argv.includes('l') ? true : false;
|
|
248
|
+
serverConf[host][path].minifyBuild = process.env.NODE_ENV === 'production' ? true : false;
|
|
249
|
+
if (process.env.NODE_ENV === 'development' && process.argv.includes('static')) {
|
|
250
|
+
serverConf[host][path].apiBaseProxyPath = '/';
|
|
251
|
+
serverConf[host][path].apiBaseHost = `localhost:${parseInt(process.env.PORT) + 1}`;
|
|
252
|
+
}
|
|
253
|
+
if (serverConf[host][path].singleReplica && serverConf[host][path].replicas) {
|
|
254
|
+
deployIdSingleReplicas = deployIdSingleReplicas.concat(
|
|
255
|
+
serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
shellExec(Cmd.replica(deployId, host, path));
|
|
259
|
+
}
|
|
260
|
+
if (serverConf[host][path].db) {
|
|
261
|
+
switch (serverConf[host][path].db.provider) {
|
|
262
|
+
case 'mariadb':
|
|
263
|
+
{
|
|
264
|
+
shellExec(`node bin/db ${host}${path} create ${deployId}`);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
break;
|
|
268
|
+
|
|
269
|
+
default:
|
|
270
|
+
break;
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
fs.writeFileSync(`./conf/conf.server.json`, JSON.stringify(serverConf, null, 4), 'utf-8');
|
|
277
|
+
await buildClient();
|
|
278
|
+
|
|
279
|
+
for (const replicaDeployId of deployIdSingleReplicas) {
|
|
280
|
+
shellExec(Cmd.conf(replicaDeployId));
|
|
281
|
+
shellExec(Cmd.build(replicaDeployId));
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
break;
|
|
285
|
+
|
|
286
|
+
case 'update-package':
|
|
287
|
+
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
288
|
+
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
289
|
+
for (const relativePath of files) {
|
|
290
|
+
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
291
|
+
if (filePah.split('/').pop() === 'package.json') {
|
|
292
|
+
originPackage.scripts.start = JSON.parse(fs.readFileSync(filePah), 'utf8').scripts.start;
|
|
293
|
+
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
break;
|
|
297
|
+
|
|
298
|
+
case 'run-single-build': {
|
|
299
|
+
const deployId = process.argv[3];
|
|
300
|
+
shellExec(Cmd.conf(deployId));
|
|
301
|
+
shellExec(Cmd.build(deployId));
|
|
302
|
+
shellExec(Cmd.delete(deployId));
|
|
303
|
+
shellExec(Cmd.run(deployId));
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
case 'run-single': {
|
|
308
|
+
const deployId = process.argv[3];
|
|
309
|
+
shellExec(Cmd.delete(deployId));
|
|
310
|
+
shellExec(Cmd.conf(deployId));
|
|
311
|
+
shellExec(Cmd.run(deployId));
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
case 'run-macro':
|
|
316
|
+
{
|
|
317
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
318
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
319
|
+
await setUpProxyMaintenanceServer({ deployGroupId: process.argv[3] });
|
|
320
|
+
await deployRun(dataDeploy, true);
|
|
321
|
+
}
|
|
322
|
+
break;
|
|
323
|
+
|
|
324
|
+
case 'run-macro-build':
|
|
325
|
+
{
|
|
326
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
327
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
328
|
+
for (const deploy of dataDeploy) {
|
|
329
|
+
shellExec(Cmd.conf(deploy.deployId));
|
|
330
|
+
shellExec(Cmd.build(deploy.deployId));
|
|
331
|
+
}
|
|
332
|
+
await setUpProxyMaintenanceServer({ deployGroupId: process.argv[3] });
|
|
333
|
+
await deployRun(dataDeploy, true);
|
|
334
|
+
}
|
|
335
|
+
break;
|
|
336
|
+
case 'prometheus':
|
|
337
|
+
case 'prom':
|
|
338
|
+
{
|
|
339
|
+
const rangePort = [1, 20];
|
|
340
|
+
const promConfigPath = `./engine-private/prometheus/prometheus-service-config.yml`;
|
|
341
|
+
const rawConfig = fs
|
|
342
|
+
.readFileSync(promConfigPath, 'utf8')
|
|
343
|
+
.replaceAll(
|
|
344
|
+
`['']`,
|
|
345
|
+
JSON.stringify(range(...rangePort).map((i) => `host.docker.internal:30${setPad(i, '0', 2)}`)).replaceAll(
|
|
346
|
+
`"`,
|
|
347
|
+
`'`,
|
|
348
|
+
),
|
|
349
|
+
);
|
|
350
|
+
console.log(rawConfig);
|
|
351
|
+
|
|
352
|
+
fs.writeFileSync(promConfigPath, rawConfig, 'utf8');
|
|
353
|
+
|
|
354
|
+
shellExec(`docker-compose -f engine-private/prometheus/prometheus-service.yml up -d`);
|
|
355
|
+
}
|
|
356
|
+
break;
|
|
357
|
+
|
|
358
|
+
case 'sync-env-port':
|
|
359
|
+
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], disableSyncEnvPort: true });
|
|
360
|
+
const dataEnv = [
|
|
361
|
+
{ env: 'production', port: 3000 },
|
|
362
|
+
{ env: 'development', port: 4000 },
|
|
363
|
+
{ env: 'test', port: 5000 },
|
|
364
|
+
];
|
|
365
|
+
let port = 0;
|
|
366
|
+
const singleReplicaHosts = [];
|
|
367
|
+
for (const deployIdObj of dataDeploy) {
|
|
368
|
+
const { deployId, replicaHost } = deployIdObj;
|
|
369
|
+
if (replicaHost && !singleReplicaHosts.includes(replicaHost)) singleReplicaHosts.push(replicaHost);
|
|
370
|
+
const proxyInstance = deployId.match('proxy') || deployId.match('cron');
|
|
371
|
+
const baseConfPath = fs.existsSync(`./engine-private/replica/${deployId}`)
|
|
372
|
+
? `./engine-private/replica`
|
|
373
|
+
: `./engine-private/conf`;
|
|
374
|
+
for (const envInstanceObj of dataEnv) {
|
|
375
|
+
const envPath = `${baseConfPath}/${deployId}/.env.${envInstanceObj.env}`;
|
|
376
|
+
const envObj = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
|
|
377
|
+
envObj.PORT = proxyInstance
|
|
378
|
+
? envInstanceObj.port
|
|
379
|
+
: envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
380
|
+
|
|
381
|
+
fs.writeFileSync(
|
|
382
|
+
envPath,
|
|
383
|
+
Object.keys(envObj)
|
|
384
|
+
.map((key) => `${key}=${envObj[key]}`)
|
|
385
|
+
.join(`\n`),
|
|
386
|
+
'utf8',
|
|
387
|
+
);
|
|
388
|
+
}
|
|
389
|
+
const serverConf = loadReplicas(
|
|
390
|
+
JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
|
|
391
|
+
);
|
|
392
|
+
if (!proxyInstance) for (const host of Object.keys(serverConf)) port += Object.keys(serverConf[host]).length;
|
|
393
|
+
}
|
|
394
|
+
break;
|
|
395
|
+
case 'uml':
|
|
396
|
+
{
|
|
397
|
+
shellExec(`node bin/deploy fix-uml ${process.argv.slice(3).join(' ')}`);
|
|
398
|
+
shellExec(`node bin/deploy build-uml ${process.argv.slice(3).join(' ')}`);
|
|
399
|
+
}
|
|
400
|
+
break;
|
|
401
|
+
|
|
402
|
+
case 'fix-uml': {
|
|
403
|
+
// required: java jdk-11.0.1
|
|
404
|
+
|
|
405
|
+
// comment:
|
|
406
|
+
// '--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'
|
|
407
|
+
// in plantuml.js src
|
|
408
|
+
|
|
409
|
+
// const deployId = process.argv[3];
|
|
410
|
+
// const clientId = process.argv[4];
|
|
411
|
+
// const folder = `./src/client/public/${clientId ? clientId : 'default'}/docs/plantuml`;
|
|
412
|
+
// const privateConfFolder = `./engine-private/conf/${deployId}`;
|
|
413
|
+
// const confData = !deployId
|
|
414
|
+
// ? Config.default
|
|
415
|
+
// : {
|
|
416
|
+
// client: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.client.json`, 'utf8')),
|
|
417
|
+
// ssr: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.ssr.json`, 'utf8')),
|
|
418
|
+
// server: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.server.json`, 'utf8')),
|
|
419
|
+
// cron: JSON.parse(fs.readFileSync(`${privateConfFolder}/conf.cron.json`, 'utf8')),
|
|
420
|
+
// };
|
|
421
|
+
|
|
422
|
+
fs.writeFileSync(
|
|
423
|
+
`./node_modules/plantuml/lib/plantuml.js`,
|
|
424
|
+
fs
|
|
425
|
+
.readFileSync(`./node_modules/plantuml/lib/plantuml.js`, 'utf8')
|
|
426
|
+
.replace(`'--add-opens=java.xml/com.sun.org.apache.xalan.internal.xsltc.trax="ALL-UNNAMED"'`, `//`),
|
|
427
|
+
);
|
|
428
|
+
}
|
|
429
|
+
case 'build-uml':
|
|
430
|
+
{
|
|
431
|
+
const host = process.argv[3];
|
|
432
|
+
const path = process.argv[4];
|
|
433
|
+
const folder = `./public/${host}${path}/docs/plantuml`;
|
|
434
|
+
const confData = Config.default;
|
|
435
|
+
|
|
436
|
+
if (!fs.existsSync(folder)) fs.mkdirSync(folder, { recursive: true });
|
|
437
|
+
|
|
438
|
+
for (const typeConf of Object.keys(confData)) {
|
|
439
|
+
{
|
|
440
|
+
const svg = await plantuml(`
|
|
441
|
+
@startjson
|
|
442
|
+
${JSON.stringify(confData[typeConf])}
|
|
443
|
+
@endjson
|
|
444
|
+
`);
|
|
445
|
+
fs.writeFileSync(`${folder}/${typeConf}-conf.svg`, svg);
|
|
446
|
+
}
|
|
447
|
+
{
|
|
448
|
+
const svg = await plantuml(`
|
|
449
|
+
@startjson
|
|
450
|
+
${JSON.stringify(toJsonSchema(confData[typeConf]))}
|
|
451
|
+
@endjson
|
|
452
|
+
`);
|
|
453
|
+
fs.writeFileSync(`${folder}/${typeConf}-schema.svg`, svg);
|
|
454
|
+
}
|
|
455
|
+
}
|
|
456
|
+
}
|
|
457
|
+
break;
|
|
458
|
+
|
|
459
|
+
case 'build-single-replica': {
|
|
460
|
+
const deployId = process.argv[3];
|
|
461
|
+
const host = process.argv[4];
|
|
462
|
+
const path = process.argv[5];
|
|
463
|
+
const serverConf = loadReplicas(
|
|
464
|
+
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
465
|
+
);
|
|
466
|
+
|
|
467
|
+
if (serverConf[host][path].replicas) {
|
|
468
|
+
{
|
|
469
|
+
let replicaIndex = -1;
|
|
470
|
+
for (const replica of serverConf[host][path].replicas) {
|
|
471
|
+
replicaIndex++;
|
|
472
|
+
const replicaDeployId = `${deployId}-${serverConf[host][path].replicas[replicaIndex].slice(1)}`;
|
|
473
|
+
// fs.mkdirSync(`./engine-private/replica/${deployId}${replicaIndex}`, { recursive: true });
|
|
474
|
+
await fs.copy(`./engine-private/conf/${deployId}`, `./engine-private/replica/${replicaDeployId}`);
|
|
475
|
+
fs.writeFileSync(
|
|
476
|
+
`./engine-private/replica/${replicaDeployId}/package.json`,
|
|
477
|
+
fs
|
|
478
|
+
.readFileSync(`./engine-private/replica/${replicaDeployId}/package.json`, 'utf8')
|
|
479
|
+
.replaceAll(`${deployId}`, `${replicaDeployId}`),
|
|
480
|
+
'utf8',
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
{
|
|
485
|
+
let replicaIndex = -1;
|
|
486
|
+
for (const replica of serverConf[host][path].replicas) {
|
|
487
|
+
replicaIndex++;
|
|
488
|
+
const replicaDeployId = `${deployId}-${serverConf[host][path].replicas[replicaIndex].slice(1)}`;
|
|
489
|
+
let replicaServerConf = JSON.parse(
|
|
490
|
+
fs.readFileSync(`./engine-private/replica/${replicaDeployId}/conf.server.json`, 'utf8'),
|
|
491
|
+
);
|
|
492
|
+
|
|
493
|
+
const singleReplicaConf = replicaServerConf[host][path];
|
|
494
|
+
singleReplicaConf.replicas = undefined;
|
|
495
|
+
singleReplicaConf.singleReplica = undefined;
|
|
496
|
+
|
|
497
|
+
replicaServerConf = {};
|
|
498
|
+
replicaServerConf[host] = {};
|
|
499
|
+
replicaServerConf[host][replica] = singleReplicaConf;
|
|
500
|
+
|
|
501
|
+
fs.writeFileSync(
|
|
502
|
+
`./engine-private/replica/${replicaDeployId}/conf.server.json`,
|
|
503
|
+
JSON.stringify(replicaServerConf, null, 4),
|
|
504
|
+
'utf8',
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
case 'build-macro-replica':
|
|
512
|
+
getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
513
|
+
break;
|
|
514
|
+
|
|
515
|
+
case 'rename-package': {
|
|
516
|
+
const name = process.argv[3];
|
|
517
|
+
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
518
|
+
originPackage.name = name;
|
|
519
|
+
fs.writeFileSync(`./package.json`, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
520
|
+
|
|
521
|
+
const originPackageLockJson = JSON.parse(fs.readFileSync(`./package-lock.json`, 'utf8'));
|
|
522
|
+
originPackageLockJson.name = name;
|
|
523
|
+
originPackageLockJson.packages[''].name = name;
|
|
524
|
+
fs.writeFileSync(`./package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
|
|
525
|
+
|
|
526
|
+
break;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
case 'set-repo': {
|
|
530
|
+
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
531
|
+
originPackage.repository = {
|
|
532
|
+
type: 'git',
|
|
533
|
+
url: `git+https://github.com/${process.argv[3]}.git`,
|
|
534
|
+
};
|
|
535
|
+
fs.writeFileSync(`./package.json`, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
536
|
+
|
|
537
|
+
break;
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
case 'update-version':
|
|
541
|
+
{
|
|
542
|
+
const newVersion = process.argv[3];
|
|
543
|
+
const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
|
|
544
|
+
const { version } = originPackageJson;
|
|
545
|
+
originPackageJson.version = newVersion;
|
|
546
|
+
fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
|
|
547
|
+
|
|
548
|
+
const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
|
|
549
|
+
originPackageLockJson.version = newVersion;
|
|
550
|
+
originPackageLockJson.packages[''].version = newVersion;
|
|
551
|
+
fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
|
|
552
|
+
|
|
553
|
+
if (fs.existsSync(`./engine-private/conf`)) {
|
|
554
|
+
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
555
|
+
for (const relativePath of files) {
|
|
556
|
+
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
557
|
+
if (filePah.split('/').pop() === 'package.json') {
|
|
558
|
+
const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
|
|
559
|
+
originPackage.version = newVersion;
|
|
560
|
+
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
fs.writeFileSync(
|
|
566
|
+
`./docker-compose.yml`,
|
|
567
|
+
fs
|
|
568
|
+
.readFileSync(`./docker-compose.yml`, 'utf8')
|
|
569
|
+
.replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
|
|
570
|
+
'utf8',
|
|
571
|
+
);
|
|
572
|
+
|
|
573
|
+
if (fs.existsSync(`./.github/workflows/docker-image.yml`))
|
|
574
|
+
fs.writeFileSync(
|
|
575
|
+
`./.github/workflows/docker-image.yml`,
|
|
576
|
+
fs
|
|
577
|
+
.readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
|
|
578
|
+
.replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
|
|
579
|
+
'utf8',
|
|
580
|
+
);
|
|
581
|
+
|
|
582
|
+
fs.writeFileSync(
|
|
583
|
+
`./src/client/components/core/Docs.js`,
|
|
584
|
+
fs
|
|
585
|
+
.readFileSync(`./src/client/components/core/Docs.js`, 'utf8')
|
|
586
|
+
.replaceAll(`/engine/${version}`, `/engine/${newVersion}`),
|
|
587
|
+
'utf8',
|
|
588
|
+
);
|
|
589
|
+
|
|
590
|
+
fs.writeFileSync(
|
|
591
|
+
`./src/client/ssr/components/body/CacheControl.js`,
|
|
592
|
+
fs
|
|
593
|
+
.readFileSync(`./src/client/ssr/components/body/CacheControl.js`, 'utf8')
|
|
594
|
+
.replaceAll(`v${version}`, `v${newVersion}`),
|
|
595
|
+
'utf8',
|
|
596
|
+
);
|
|
597
|
+
|
|
598
|
+
fs.writeFileSync(
|
|
599
|
+
`./bin/index.js`,
|
|
600
|
+
fs.readFileSync(`./bin/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
|
|
601
|
+
'utf8',
|
|
602
|
+
);
|
|
603
|
+
|
|
604
|
+
shellExec(`node bin/deploy update-package`);
|
|
605
|
+
shellExec(`auto-changelog`);
|
|
606
|
+
}
|
|
607
|
+
break;
|
|
608
|
+
|
|
609
|
+
case 'update-authors': {
|
|
610
|
+
// shellExec(`git log --reverse --format='%aN (<%aE>)' | sort -u`, { stdout: true });
|
|
611
|
+
const logs = await simpleGit().log();
|
|
612
|
+
|
|
613
|
+
fs.writeFileSync(
|
|
614
|
+
'./AUTHORS.md',
|
|
615
|
+
`# Authors
|
|
616
|
+
|
|
617
|
+
#### Ordered by first contribution.
|
|
618
|
+
|
|
619
|
+
${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}](mailto:${log.author_email}))`)).join(`
|
|
620
|
+
`)}
|
|
621
|
+
|
|
622
|
+
#### Generated by [underpost.net](https://underpost.net)`,
|
|
623
|
+
'utf8',
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
// hash: '1c7418ad2f49c7798a6d28d370b34c69d31dce46',
|
|
627
|
+
// date: '2024-09-16T17:10:13-03:00',
|
|
628
|
+
// message: 'update',
|
|
629
|
+
// refs: '',
|
|
630
|
+
// body: '',
|
|
631
|
+
// author_name: 'fcoverdugo',
|
|
632
|
+
// author_email: 'fcoverdugoa@underpost.net'
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
case 'restore-macro-db':
|
|
636
|
+
{
|
|
637
|
+
const deployGroupId = process.argv[3];
|
|
638
|
+
await restoreMacroDb(deployGroupId);
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
break;
|
|
642
|
+
|
|
643
|
+
case 'mongo': {
|
|
644
|
+
await MongooseDB.server();
|
|
645
|
+
break;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
case 'lampp': {
|
|
649
|
+
await Lampp.install();
|
|
650
|
+
break;
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
case 'heb': {
|
|
654
|
+
// https://besu.hyperledger.org/
|
|
655
|
+
// https://github.com/hyperledger/besu/archive/refs/tags/24.9.1.tar.gz
|
|
656
|
+
|
|
657
|
+
switch (process.platform) {
|
|
658
|
+
case 'linux':
|
|
659
|
+
{
|
|
660
|
+
shellCd(`..`);
|
|
661
|
+
|
|
662
|
+
// Download the Linux binary
|
|
663
|
+
shellExec(`wget https://github.com/hyperledger/besu/releases/download/24.9.1/besu-24.9.1.tar.gz`);
|
|
664
|
+
|
|
665
|
+
// Unzip the file:
|
|
666
|
+
shellExec(`tar -xvzf besu-24.9.1.tar.gz`);
|
|
667
|
+
|
|
668
|
+
shellCd(`besu-24.9.1`);
|
|
669
|
+
|
|
670
|
+
shellExec(`bin/besu --help`);
|
|
671
|
+
|
|
672
|
+
// Set env path
|
|
673
|
+
// export PATH=$PATH:/dd/besu-24.9.1/bin
|
|
674
|
+
|
|
675
|
+
// Open src
|
|
676
|
+
// shellExec(`sudo code /dd/besu-24.9.1 --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
677
|
+
}
|
|
678
|
+
|
|
679
|
+
break;
|
|
680
|
+
|
|
681
|
+
default:
|
|
682
|
+
break;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
break;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
case 'fix-deps': {
|
|
689
|
+
await fixDependencies();
|
|
690
|
+
break;
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
case 'update-default-conf': {
|
|
694
|
+
const host = process.argv[3] ? process.argv[3] : 'underpostnet.github.io';
|
|
695
|
+
const path = process.argv[4] ? process.argv[4] : '/pwa-microservices-template-ghpkg';
|
|
696
|
+
DefaultConf.server = {
|
|
697
|
+
[host]: { [path]: DefaultConf.server['default.net']['/'] },
|
|
698
|
+
};
|
|
699
|
+
DefaultConf.server[host][path].apiBaseProxyPath = '/';
|
|
700
|
+
DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
|
|
701
|
+
fs.writeFileSync(
|
|
702
|
+
'./conf.js',
|
|
703
|
+
`
|
|
704
|
+
const DefaultConf = ${JSONweb(DefaultConf)};
|
|
705
|
+
|
|
706
|
+
export { DefaultConf }
|
|
707
|
+
|
|
708
|
+
`,
|
|
709
|
+
'utf8',
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
case 'ssh-export-server-keys': {
|
|
715
|
+
fs.copyFile('/etc/ssh/ssh_host_rsa_key', './engine-private/deploy/ssh_host_rsa_key');
|
|
716
|
+
fs.copyFile('/etc/ssh/ssh_host_rsa_key.pub', './engine-private/deploy/ssh_host_rsa_key.pub');
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case 'ssh-import-server-keys': {
|
|
720
|
+
fs.copyFile('./engine-private/deploy/ssh_host_rsa_key', '/etc/ssh/ssh_host_rsa_key');
|
|
721
|
+
fs.copyFile('./engine-private/deploy/ssh_host_rsa_key.pub', '/etc/ssh/ssh_host_rsa_key.pub');
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
case 'ssh-import-client-keys': {
|
|
725
|
+
const host = process.argv[3];
|
|
726
|
+
shellExec(`node bin/deploy set-ssh-keys ./engine-private/deploy/ssh_host_rsa_key${host ? ` ${host}` : ``} clean`);
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
case 'ssh-keys': {
|
|
730
|
+
// create ssh keys
|
|
731
|
+
const sshAccount = process.argv[3]; // [sudo username]@[host/ip]
|
|
732
|
+
const destPath = process.argv[4];
|
|
733
|
+
// shellExec(`ssh-keygen -t ed25519 -C "${sshAccount}" -f ${destPath}`);
|
|
734
|
+
if (fs.existsSync(destPath)) {
|
|
735
|
+
fs.removeSync(destPath);
|
|
736
|
+
fs.removeSync(destPath + '.pub');
|
|
737
|
+
}
|
|
738
|
+
shellExec(`ssh-keygen -t rsa -b 4096 -C "${sshAccount}" -f ${destPath}`);
|
|
739
|
+
// add host to keyscan
|
|
740
|
+
// shellExec(`ssh-keyscan -t rsa ${sshAccount.split(`@`)[1]} >> ~/.ssh/known_hosts`);
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
case 'set-ssh-keys': {
|
|
745
|
+
const files = ['authorized_keys', 'id_rsa', 'id_rsa.pub', 'known_hosts ', 'known_hosts.old'];
|
|
746
|
+
|
|
747
|
+
// > write
|
|
748
|
+
// >> append
|
|
749
|
+
|
|
750
|
+
// /root/.ssh/id_rsa
|
|
751
|
+
// /root/.ssh/id_rsa.pub
|
|
752
|
+
if (process.argv.includes('clean')) {
|
|
753
|
+
for (const file of files) {
|
|
754
|
+
if (fs.existsSync(`/root/.ssh/${file}`)) {
|
|
755
|
+
logger.info('remove', `/root/.ssh/${file}`);
|
|
756
|
+
fs.removeSync(`/root/.ssh/${file}`);
|
|
757
|
+
}
|
|
758
|
+
fs.writeFileSync(`/root/.ssh/${file}`, '', 'utf8');
|
|
759
|
+
}
|
|
760
|
+
shellExec('eval `ssh-agent -s`' + ` && ssh-add -D`);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const destPath = process.argv[3];
|
|
764
|
+
const sshAuthKeyTarget = '/root/.ssh/authorized_keys';
|
|
765
|
+
if (!fs.existsSync(sshAuthKeyTarget)) shellExec(`touch ${sshAuthKeyTarget}`);
|
|
766
|
+
shellExec(`cat ${destPath}.pub > ${sshAuthKeyTarget}`);
|
|
767
|
+
shellExec(`cat ${destPath} >> ${sshAuthKeyTarget}`);
|
|
768
|
+
|
|
769
|
+
if (!fs.existsSync('/root/.ssh/id_rsa')) shellExec(`touch ${'/root/.ssh/id_rsa'}`);
|
|
770
|
+
shellExec(`cat ${destPath} > ${'/root/.ssh/id_rsa'}`);
|
|
771
|
+
|
|
772
|
+
if (!fs.existsSync('/root/.ssh/id_rsa.pub')) shellExec(`touch ${'/root/.ssh/id_rsa.pub'}`);
|
|
773
|
+
shellExec(`cat ${destPath}.pub > ${'/root/.ssh/id_rsa.pub'}`);
|
|
774
|
+
|
|
775
|
+
shellExec(`chmod 700 /root/.ssh/`);
|
|
776
|
+
for (const file of files) {
|
|
777
|
+
shellExec(`chmod 600 /root/.ssh/${file}`);
|
|
778
|
+
}
|
|
779
|
+
const host = process.argv[4];
|
|
780
|
+
// add key
|
|
781
|
+
shellExec('eval `ssh-agent -s`' + ' && ssh-add /root/.ssh/id_rsa' + ' && ssh-add -l');
|
|
782
|
+
if (host) shellExec(`ssh-keyscan -H ${host} >> ~/.ssh/known_hosts`);
|
|
783
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
784
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
785
|
+
shellExec(`sudo systemctl status ssh`);
|
|
786
|
+
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
case 'ssh': {
|
|
791
|
+
if (!process.argv.includes('server')) {
|
|
792
|
+
shellExec(`sudo apt update`);
|
|
793
|
+
shellExec(`sudo apt install openssh-server -y`);
|
|
794
|
+
shellExec(`sudo apt install ssh-askpass`);
|
|
795
|
+
}
|
|
796
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
797
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
798
|
+
shellExec(`sudo systemctl status ssh`);
|
|
799
|
+
// sudo service ssh restart
|
|
800
|
+
shellExec(`ip a`);
|
|
801
|
+
|
|
802
|
+
// adduser newuser
|
|
803
|
+
// usermod -aG sudo newuser
|
|
804
|
+
|
|
805
|
+
// ssh -i '/path/to/keyfile' username@server
|
|
806
|
+
|
|
807
|
+
// ssh-keygen -t ed25519 -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
|
808
|
+
|
|
809
|
+
// legacy: ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
|
810
|
+
|
|
811
|
+
// vi .ssh/authorized_keys
|
|
812
|
+
// chmod 700 .ssh
|
|
813
|
+
// chmod 600 authorized_keys
|
|
814
|
+
|
|
815
|
+
// cat id_rsa.pub > .ssh/authorized_keys
|
|
816
|
+
|
|
817
|
+
// add public key to authorized keys
|
|
818
|
+
// cat .ssh/id_ed25519.pub | ssh [sudo username]@[host/ip] 'cat >> .ssh/authorized_keys'
|
|
819
|
+
|
|
820
|
+
// 2. Open /etc/ssh/sshd_config file
|
|
821
|
+
// nano /etc/ssh/sshd_config
|
|
822
|
+
|
|
823
|
+
// 3. add example code to last line of file
|
|
824
|
+
// Match User newuser
|
|
825
|
+
// PasswordAuthentication yes
|
|
826
|
+
|
|
827
|
+
// ssh [sudo username]@[host/ip]
|
|
828
|
+
// open port 22
|
|
829
|
+
|
|
830
|
+
// init ssh agent service
|
|
831
|
+
// eval `ssh-agent -s`
|
|
832
|
+
|
|
833
|
+
// list keys
|
|
834
|
+
// ssh-add -l
|
|
835
|
+
|
|
836
|
+
// add key
|
|
837
|
+
// ssh-add /root/.ssh/id_rsa
|
|
838
|
+
|
|
839
|
+
// remove
|
|
840
|
+
// ssh-add -d /path/to/private/key
|
|
841
|
+
|
|
842
|
+
// remove all
|
|
843
|
+
// ssh-add -D
|
|
844
|
+
|
|
845
|
+
// sshpass -p ${{ secrets.PSWD }} ssh -o StrictHostKeyChecking=no -p 22 ${{ secrets.USER}}@${{ secrets.VPS_IP }} 'cd /home/adam && ./deploy.sh'
|
|
846
|
+
|
|
847
|
+
// copies the public key of your default identity (use -i identity_file for other identities) to the remote host.
|
|
848
|
+
// ssh-copy-id user@hostname.example.com
|
|
849
|
+
// ssh-copy-id "user@hostname.example.com -p <port-number>"
|
|
850
|
+
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
|
|
854
|
+
default:
|
|
855
|
+
break;
|
|
856
|
+
}
|
|
857
|
+
} catch (error) {
|
|
858
|
+
logger.error(error, error.stack);
|
|
859
|
+
}
|