underpost 2.6.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 +14 -0
- package/.env.development +8 -0
- package/.env.production +8 -0
- package/.env.test +8 -0
- package/.nycrc +9 -0
- package/.prettierignore +13 -0
- package/.prettierrc +9 -0
- package/.vscode/extensions.json +72 -0
- package/.vscode/settings.json +99 -0
- package/Dockerfile +88 -0
- package/LICENSE +21 -0
- package/README.md +51 -0
- package/bin/db.js +119 -0
- package/bin/deploy.js +600 -0
- package/bin/dns.js +1 -0
- package/bin/file.js +92 -0
- package/bin/help.js +110 -0
- package/bin/index.js +29 -0
- package/bin/install.js +357 -0
- package/bin/shortcut.js +44 -0
- package/bin/ssl.js +61 -0
- package/bin/util.js +182 -0
- package/bin/vs.js +35 -0
- package/conf.js +244 -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 +128 -0
- package/prometheus.yml +36 -0
- package/setup.sh +25 -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 +29 -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 +51 -0
- package/src/api/file/file.model.js +19 -0
- package/src/api/file/file.router.js +20 -0
- package/src/api/file/file.service.js +70 -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.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 +91 -0
- package/src/client/components/core/CalendarCore.js +319 -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 +708 -0
- package/src/client/components/core/Content.js +49 -0
- package/src/client/components/core/Css.js +1027 -0
- package/src/client/components/core/CssCore.js +792 -0
- package/src/client/components/core/D3Chart.js +44 -0
- package/src/client/components/core/Docs.js +130 -0
- package/src/client/components/core/DropDown.js +164 -0
- package/src/client/components/core/EventsUI.js +54 -0
- package/src/client/components/core/FileExplorer.js +624 -0
- package/src/client/components/core/FullScreen.js +45 -0
- package/src/client/components/core/Input.js +259 -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 +157 -0
- package/src/client/components/core/LogIn.js +181 -0
- package/src/client/components/core/LogOut.js +52 -0
- package/src/client/components/core/Logger.js +26 -0
- package/src/client/components/core/Modal.js +1596 -0
- package/src/client/components/core/NotificationManager.js +84 -0
- package/src/client/components/core/Panel.js +413 -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 +53 -0
- package/src/client/components/core/RichText.js +27 -0
- package/src/client/components/core/Router.js +77 -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 +408 -0
- package/src/client/components/core/Validator.js +100 -0
- package/src/client/components/core/VanillaJs.js +454 -0
- package/src/client/components/core/Wallet.js +106 -0
- package/src/client/components/core/Webhook.js +25 -0
- package/src/client/components/core/Worker.js +272 -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/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/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 +152 -0
- package/src/client/services/crypto/crypto.service.js +70 -0
- package/src/client/services/default/default.management.js +345 -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 +16 -0
- package/src/client/ssr/body-components/CacheControl.js +113 -0
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -0
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -0
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -0
- package/src/client/ssr/head-components/Css.js +241 -0
- package/src/client/ssr/head-components/DefaultScripts.js +3 -0
- package/src/client/ssr/head-components/Microdata.js +11 -0
- package/src/client/ssr/head-components/Production.js +1 -0
- package/src/client/ssr/head-components/PwaDefault.js +60 -0
- package/src/client/ssr/head-components/Seo.js +14 -0
- package/src/client/sw/default.sw.js +201 -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/cron.js +25 -0
- package/src/db/DataBaseProvider.js +34 -0
- package/src/db/mariadb/MariaDB.js +33 -0
- package/src/db/mongo/MongooseDB.js +46 -0
- package/src/dns.js +22 -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 +44 -0
- package/src/runtime/nginx/Nginx.js +3 -0
- package/src/runtime/xampp/Xampp.js +49 -0
- package/src/server/auth.js +204 -0
- package/src/server/backup.js +83 -0
- package/src/server/client-build-live.js +72 -0
- package/src/server/client-build.js +688 -0
- package/src/server/client-dev-server.js +58 -0
- package/src/server/client-formatted.js +48 -0
- package/src/server/client-icons.js +150 -0
- package/src/server/conf.js +611 -0
- package/src/server/dns.js +87 -0
- package/src/server/downloader.js +42 -0
- package/src/server/logger.js +135 -0
- package/src/server/network.js +122 -0
- package/src/server/peer.js +33 -0
- package/src/server/process.js +66 -0
- package/src/server/proxy.js +118 -0
- package/src/server/runtime.js +393 -0
- package/src/server/ssl.js +107 -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/help.js
ADDED
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
2
|
+
import colors from 'colors';
|
|
3
|
+
|
|
4
|
+
colors.enable();
|
|
5
|
+
|
|
6
|
+
const logger = loggerFactory(import.meta);
|
|
7
|
+
|
|
8
|
+
// backup: `node bin/db <host><path> export <deploy-id>`
|
|
9
|
+
// restore: `node bin/db <host><path> import <deploy-id>`
|
|
10
|
+
// new-api-src: `node bin/deploy build-nodejs-src-api <api-id>`
|
|
11
|
+
// text-to-image: `node bin/util text-to-image 's4()' white black 100x100`
|
|
12
|
+
// sync-packages: `node bin/deploy update-package`
|
|
13
|
+
// ssl: `npm run ssl <os> <deploy-id> <host>`
|
|
14
|
+
// clean empty folder: `node bin/util delete-empty-folder`
|
|
15
|
+
// sync env port: `node bin/deploy sync-env-port <deployId>`
|
|
16
|
+
// node bin/vs import
|
|
17
|
+
// node bin/vs export
|
|
18
|
+
// build macro replica: `node bin/deploy build-macro-replica dd`
|
|
19
|
+
// node bin/deploy update-version 2.5.2
|
|
20
|
+
|
|
21
|
+
const data = {
|
|
22
|
+
help: `
|
|
23
|
+
---------------------------------------------------------------
|
|
24
|
+
${`Help`.white}
|
|
25
|
+
---------------------------------------------------------------
|
|
26
|
+
|
|
27
|
+
Arguments:
|
|
28
|
+
|
|
29
|
+
> [optional] section: help | install | ssl
|
|
30
|
+
> [optional] sections: section,section,...
|
|
31
|
+
|
|
32
|
+
Command Line:
|
|
33
|
+
|
|
34
|
+
> ${`node bin/help <section/s>`.yellow}
|
|
35
|
+
`,
|
|
36
|
+
install: `
|
|
37
|
+
---------------------------------------------------------------
|
|
38
|
+
${`Programs installer`.white}
|
|
39
|
+
---------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
Arguments:
|
|
42
|
+
|
|
43
|
+
> [required] os: windows
|
|
44
|
+
> [required] program: certbot | xampp | docker | wordpress
|
|
45
|
+
> [required] host/path: example.com | example.com/path | www.example.com
|
|
46
|
+
|
|
47
|
+
Command Line:
|
|
48
|
+
|
|
49
|
+
> ${`node bin/install <os> <program> <host/path>`.yellow}
|
|
50
|
+
`,
|
|
51
|
+
ssl: `
|
|
52
|
+
---------------------------------------------------------------
|
|
53
|
+
${`SSL management`.white}
|
|
54
|
+
---------------------------------------------------------------
|
|
55
|
+
|
|
56
|
+
Arguments:
|
|
57
|
+
|
|
58
|
+
> [required] os: windows
|
|
59
|
+
> [required] hosts: example.com,www.example.com
|
|
60
|
+
|
|
61
|
+
Command Line:
|
|
62
|
+
|
|
63
|
+
> ${`node bin/ssl <os> <hosts>`.yellow}
|
|
64
|
+
`,
|
|
65
|
+
mariadb: `
|
|
66
|
+
---------------------------------------------------------------
|
|
67
|
+
${`DataBase management`.white}
|
|
68
|
+
---------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
Arguments:
|
|
71
|
+
|
|
72
|
+
> [required] operator: show | create | delete | import | export
|
|
73
|
+
> [required] host/path: example.com | example.com/path | www.example.com
|
|
74
|
+
|
|
75
|
+
Command Line:
|
|
76
|
+
|
|
77
|
+
> ${`node bin/db <host/path> <operator>`.yellow}
|
|
78
|
+
`,
|
|
79
|
+
shortcut: `
|
|
80
|
+
---------------------------------------------------------------
|
|
81
|
+
${`Shortcut Generator`.white}
|
|
82
|
+
---------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
Arguments:
|
|
85
|
+
|
|
86
|
+
> [required] os: windows | linux
|
|
87
|
+
> [required] env: development | production | test
|
|
88
|
+
|
|
89
|
+
Command Line:
|
|
90
|
+
|
|
91
|
+
> ${`node bin/shortcut <os> <env>`.yellow}
|
|
92
|
+
`,
|
|
93
|
+
end: '---------------------------------------------------------------',
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
logger.info('argv', process.argv);
|
|
97
|
+
|
|
98
|
+
const [exe, dir, sections] = process.argv;
|
|
99
|
+
|
|
100
|
+
try {
|
|
101
|
+
let out = '';
|
|
102
|
+
if (!sections) Object.keys(data).map((section) => (out += data[section]));
|
|
103
|
+
else {
|
|
104
|
+
for (const section of sections.split(',')) out += data[section];
|
|
105
|
+
out += data['end'];
|
|
106
|
+
}
|
|
107
|
+
logger.info(out);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
logger.error(error, error.stack);
|
|
110
|
+
}
|
package/bin/index.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#! /usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
import { shellCd, shellExec } from '../src/server/process.js';
|
|
6
|
+
import fs from 'fs-extra';
|
|
7
|
+
|
|
8
|
+
dotenv.config();
|
|
9
|
+
|
|
10
|
+
const logger = loggerFactory(import.meta);
|
|
11
|
+
|
|
12
|
+
await logger.setUpInfo();
|
|
13
|
+
|
|
14
|
+
switch (process.argv[2]) {
|
|
15
|
+
case 'new':
|
|
16
|
+
{
|
|
17
|
+
const projectName = process.argv[3] || 'my-project';
|
|
18
|
+
const globalBinFolder = shellExec(`npm root -g`, { stdout: true, silent: true }).trim();
|
|
19
|
+
const destFolder = `${process.cwd()}/${projectName}`;
|
|
20
|
+
fs.mkdirSync(destFolder, { recursive: true });
|
|
21
|
+
fs.copySync(`${globalBinFolder}/underpost`, destFolder);
|
|
22
|
+
shellCd(`${destFolder}`);
|
|
23
|
+
shellExec(`npm run install-template`);
|
|
24
|
+
shellExec(`npm run dev`);
|
|
25
|
+
}
|
|
26
|
+
break;
|
|
27
|
+
default:
|
|
28
|
+
break;
|
|
29
|
+
}
|
package/bin/install.js
ADDED
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import AdmZip from 'adm-zip';
|
|
3
|
+
import axios from 'axios';
|
|
4
|
+
import { Downloader } from '../src/server/downloader.js';
|
|
5
|
+
import { getRootDirectory, shellCd, shellExec } from '../src/server/process.js';
|
|
6
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
7
|
+
import { s4 } from '../src/client/components/core/CommonJs.js';
|
|
8
|
+
|
|
9
|
+
const logger = loggerFactory(import.meta);
|
|
10
|
+
|
|
11
|
+
logger.info('argv', process.argv);
|
|
12
|
+
|
|
13
|
+
const [exe, dir, os, program, hostPath = '', deployId] = process.argv;
|
|
14
|
+
const [host, path = ''] = hostPath.split('/');
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
let cmd;
|
|
18
|
+
switch (program) {
|
|
19
|
+
case 'certbot':
|
|
20
|
+
switch (os) {
|
|
21
|
+
case 'windows':
|
|
22
|
+
await (async () => {
|
|
23
|
+
const urlDownload =
|
|
24
|
+
'https://github.com/certbot/certbot/releases/latest/download/certbot-beta-installer-win_amd64_signed.exe';
|
|
25
|
+
const folderPath = `./engine-private/setup`;
|
|
26
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
27
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
28
|
+
logger.info('destination', fullPath);
|
|
29
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
30
|
+
cmd = `PowerShell Start-Process -FilePath "${fullPath}" -ArgumentList "/S" -Wait`;
|
|
31
|
+
shellExec(cmd);
|
|
32
|
+
})();
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
36
|
+
}
|
|
37
|
+
break;
|
|
38
|
+
case 'xampp':
|
|
39
|
+
switch (os) {
|
|
40
|
+
case 'windows':
|
|
41
|
+
await (async () => {
|
|
42
|
+
const versions = {
|
|
43
|
+
'7.4.13-0':
|
|
44
|
+
'https://ufpr.dl.sourceforge.net/project/xampp/XAMPP%20Windows/7.4.13/xampp-windows-x64-7.4.13-0-VC15-installer.exe',
|
|
45
|
+
'7.4.13-1':
|
|
46
|
+
'https://ufpr.dl.sourceforge.net/project/xampp/XAMPP%20Windows/7.4.13/xampp-portable-windows-x64-7.4.13-1-VC15-installer.exe',
|
|
47
|
+
'8.0.28':
|
|
48
|
+
'https://sitsa.dl.sourceforge.net/project/xampp/XAMPP%20Windows/8.0.28/xampp-windows-x64-8.0.28-0-VS16-installer.exe',
|
|
49
|
+
};
|
|
50
|
+
const urlDownload = versions['7.4.13-1'];
|
|
51
|
+
const folderPath = `./engine-private/setup`;
|
|
52
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
53
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
54
|
+
logger.info('destination', fullPath);
|
|
55
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
56
|
+
cmd = `${getRootDirectory()}${fullPath.slice(1)} --mode unattended`;
|
|
57
|
+
if (!fs.existsSync(`C:/xampp/apache`)) shellExec(cmd);
|
|
58
|
+
fs.writeFileSync(
|
|
59
|
+
`C:/xampp/apache/conf/httpd.template.conf`,
|
|
60
|
+
fs.readFileSync(`C:/xampp/apache/conf/httpd.conf`, 'utf8'),
|
|
61
|
+
'utf8',
|
|
62
|
+
);
|
|
63
|
+
fs.writeFileSync(
|
|
64
|
+
`C:/xampp/apache/conf/extra/httpd-ssl.template.conf`,
|
|
65
|
+
fs.readFileSync(`C:/xampp/apache/conf/extra/httpd-ssl.conf`, 'utf8'),
|
|
66
|
+
'utf8',
|
|
67
|
+
);
|
|
68
|
+
fs.writeFileSync(`C:/xampp/.gitignore`, `/htdocs`, 'utf8');
|
|
69
|
+
shellCd(`c:/xampp`);
|
|
70
|
+
shellExec(`git init && git add . && git commit -m "update"`);
|
|
71
|
+
shellCd(getRootDirectory());
|
|
72
|
+
})();
|
|
73
|
+
break;
|
|
74
|
+
default:
|
|
75
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
case 'docker':
|
|
79
|
+
switch (os) {
|
|
80
|
+
case 'windows':
|
|
81
|
+
await (async () => {
|
|
82
|
+
const urlDownload = `https://desktop.docker.com/win/main/amd64/Docker%20Desktop%20Installer.exe`;
|
|
83
|
+
const folderPath = `./engine-private/setup`;
|
|
84
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
85
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
86
|
+
logger.info('destination', fullPath);
|
|
87
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
88
|
+
logger.warn('You must have WSL, install with the following command', `wsl --install`);
|
|
89
|
+
cmd = `${getRootDirectory()}${fullPath.slice(1)} install --quiet --accept-license`;
|
|
90
|
+
if (!fs.existsSync(`C:/Program Files/Docker/Docker`)) shellExec(cmd);
|
|
91
|
+
})();
|
|
92
|
+
break;
|
|
93
|
+
|
|
94
|
+
default:
|
|
95
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
96
|
+
}
|
|
97
|
+
break;
|
|
98
|
+
case 'wordpress':
|
|
99
|
+
await (async () => {
|
|
100
|
+
const urlDownload = `https://wordpress.org/latest.zip`;
|
|
101
|
+
const folderPath = `./engine-private/setup`;
|
|
102
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
103
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
104
|
+
logger.info('destination', fullPath);
|
|
105
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
106
|
+
const confServer = JSON.parse(
|
|
107
|
+
fs.readFileSync(
|
|
108
|
+
deployId ? `./engine-private/conf/${deployId}/conf.server.json` : `./conf/conf.server.json`,
|
|
109
|
+
'utf8',
|
|
110
|
+
),
|
|
111
|
+
);
|
|
112
|
+
const { directory, db } = confServer[host][`/${path}`];
|
|
113
|
+
logger.info('client found', confServer[host][`/${path}`]);
|
|
114
|
+
const zipTargetPath = directory ? directory : `./public/${path ? `${host}/${path}` : host}`;
|
|
115
|
+
if (!fs.existsSync(zipTargetPath)) fs.mkdirSync(zipTargetPath, { recursive: true });
|
|
116
|
+
const tmpFolderExtract = s4() + s4();
|
|
117
|
+
fs.mkdirSync(`./public/${tmpFolderExtract}`, { recursive: true });
|
|
118
|
+
logger.info(`Please wait, zip extract to`, zipTargetPath);
|
|
119
|
+
new AdmZip(fullPath).extractAllTo(/*target path*/ `./public/${tmpFolderExtract}`, /*overwrite*/ true);
|
|
120
|
+
fs.moveSync(`./public/${tmpFolderExtract}/wordpress`, zipTargetPath, { overwrite: true });
|
|
121
|
+
// https://wordpress.org/documentation/article/htaccess/
|
|
122
|
+
// https://github.com/chimurai/http-proxy-middleware/issues/785
|
|
123
|
+
let htaccess = ``;
|
|
124
|
+
if (host.split('.')[2]) {
|
|
125
|
+
// sub domain
|
|
126
|
+
htaccess += `# BEGIN WordPress Multisite
|
|
127
|
+
# Using subdomain network type: https://wordpress.org/documentation/article/htaccess/#multisite
|
|
128
|
+
|
|
129
|
+
RewriteEngine On
|
|
130
|
+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
131
|
+
RewriteBase /
|
|
132
|
+
RewriteRule ^index\.php$ - [L]
|
|
133
|
+
|
|
134
|
+
# add a trailing slash to /wp-admin
|
|
135
|
+
RewriteRule ^wp-admin$ wp-admin/ [R=301,L]
|
|
136
|
+
|
|
137
|
+
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
138
|
+
RewriteCond %{REQUEST_FILENAME} -d
|
|
139
|
+
RewriteRule ^ - [L]
|
|
140
|
+
RewriteRule ^(wp-(content|admin|includes).*) $1 [L]
|
|
141
|
+
RewriteRule ^(.*\.php)$ $1 [L]
|
|
142
|
+
RewriteRule . index.php [L]
|
|
143
|
+
|
|
144
|
+
# END WordPress Multisite
|
|
145
|
+
`;
|
|
146
|
+
} else if (path) {
|
|
147
|
+
// sub folder
|
|
148
|
+
htaccess += `# BEGIN WordPress Multisite
|
|
149
|
+
# Using subfolder network type: https://wordpress.org/documentation/article/htaccess/#multisite
|
|
150
|
+
|
|
151
|
+
RewriteEngine On
|
|
152
|
+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
153
|
+
RewriteBase /
|
|
154
|
+
RewriteRule ^index\.php$ - [L]
|
|
155
|
+
|
|
156
|
+
# add a trailing slash to /wp-admin
|
|
157
|
+
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
|
|
158
|
+
|
|
159
|
+
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
160
|
+
RewriteCond %{REQUEST_FILENAME} -d
|
|
161
|
+
RewriteRule ^ - [L]
|
|
162
|
+
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) $2 [L]
|
|
163
|
+
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ $2 [L]
|
|
164
|
+
RewriteRule . index.php [L]
|
|
165
|
+
|
|
166
|
+
# END WordPress Multisite
|
|
167
|
+
`;
|
|
168
|
+
} else {
|
|
169
|
+
// main domain
|
|
170
|
+
htaccess += `
|
|
171
|
+
# BEGIN WordPress
|
|
172
|
+
|
|
173
|
+
RewriteEngine On
|
|
174
|
+
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
|
|
175
|
+
RewriteBase /
|
|
176
|
+
RewriteRule ^index\.php$ - [L]
|
|
177
|
+
RewriteCond %{REQUEST_FILENAME} !-f
|
|
178
|
+
RewriteCond %{REQUEST_FILENAME} !-d
|
|
179
|
+
RewriteRule . /index.php [L]
|
|
180
|
+
|
|
181
|
+
# END WordPress
|
|
182
|
+
`;
|
|
183
|
+
}
|
|
184
|
+
// fs.writeFileSync(`${zipTargetPath}/.htaccess`, htaccess, 'utf8');
|
|
185
|
+
const secretKeyResult = await axios.get(`https://api.wordpress.org/secret-key/1.1/salt/`);
|
|
186
|
+
logger.info('wordpress secret Key Result', secretKeyResult.data);
|
|
187
|
+
fs.writeFileSync(
|
|
188
|
+
`${zipTargetPath}/wp-config.php`,
|
|
189
|
+
fs
|
|
190
|
+
.readFileSync(`${zipTargetPath}/wp-config-sample.php`, 'utf8')
|
|
191
|
+
.replaceAll(`define( 'AUTH_KEY', 'put your unique phrase here' );`, '')
|
|
192
|
+
.replaceAll(`define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );`, '')
|
|
193
|
+
.replaceAll(`define( 'LOGGED_IN_KEY', 'put your unique phrase here' );`, '')
|
|
194
|
+
.replaceAll(`define( 'NONCE_KEY', 'put your unique phrase here' );`, '')
|
|
195
|
+
.replaceAll(`define( 'AUTH_SALT', 'put your unique phrase here' );`, '')
|
|
196
|
+
.replaceAll(`define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );`, '')
|
|
197
|
+
.replaceAll(`define( 'LOGGED_IN_SALT', 'put your unique phrase here' );`, '')
|
|
198
|
+
.replaceAll(`define( 'NONCE_SALT', 'put your unique phrase here' );`, '')
|
|
199
|
+
.replaceAll(
|
|
200
|
+
`/**#@-*/`,
|
|
201
|
+
`${secretKeyResult.data}
|
|
202
|
+
|
|
203
|
+
/**#@-*/`,
|
|
204
|
+
)
|
|
205
|
+
.replaceAll('database_name_here', db.name)
|
|
206
|
+
.replaceAll('username_here', db.user)
|
|
207
|
+
.replaceAll('password_here', db.password)
|
|
208
|
+
.replaceAll(`$table_prefix = 'wp_';`, `$table_prefix = 'wp_${db.name}_';`),
|
|
209
|
+
'utf8',
|
|
210
|
+
);
|
|
211
|
+
const rootDirectory = getRootDirectory();
|
|
212
|
+
shellCd(zipTargetPath);
|
|
213
|
+
shellExec(`git init && git add . && git commit -m "update"`);
|
|
214
|
+
shellCd(rootDirectory);
|
|
215
|
+
fs.rmSync(`./public/${tmpFolderExtract}`, { recursive: true, force: true });
|
|
216
|
+
const wpHtaccess = `
|
|
217
|
+
# BEGIN WordPress
|
|
218
|
+
<IfModule mod_rewrite.c>
|
|
219
|
+
RewriteEngine On
|
|
220
|
+
RewriteRule ^index\.php$ - [L]
|
|
221
|
+
RewriteCond $1 ^(index\.php)?$ [OR]
|
|
222
|
+
# RewriteCond $1 \.(gif|jpg|png|ico|css|js|php)$ [NC,OR]
|
|
223
|
+
RewriteCond $1 \.(.*) [NC,OR]
|
|
224
|
+
RewriteCond %{REQUEST_FILENAME} -f [OR]
|
|
225
|
+
RewriteCond %{REQUEST_FILENAME} -d
|
|
226
|
+
RewriteRule ^(.*)$ - [S=1]
|
|
227
|
+
RewriteRule . /index.php [L]
|
|
228
|
+
</IfModule>
|
|
229
|
+
# END wordpress
|
|
230
|
+
`;
|
|
231
|
+
})();
|
|
232
|
+
break;
|
|
233
|
+
case 'nginx':
|
|
234
|
+
// https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mariadb-php-lemp-stack-on-debian-10
|
|
235
|
+
// https://github.com/pothi/wordpress-nginx/
|
|
236
|
+
// https://github.com/digitalocean/nginxconfig.io
|
|
237
|
+
break;
|
|
238
|
+
case 'mongodb':
|
|
239
|
+
switch (os) {
|
|
240
|
+
case 'windows':
|
|
241
|
+
await (async () => {
|
|
242
|
+
const versions = {
|
|
243
|
+
'6.0': 'https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-6.0.11-signed.msi',
|
|
244
|
+
'7.0': `https://fastdl.mongodb.org/windows/mongodb-windows-x86_64-7.0.3-signed.msi`,
|
|
245
|
+
};
|
|
246
|
+
const version = '6.0';
|
|
247
|
+
const urlDownload = versions[version];
|
|
248
|
+
const folderPath = `./engine-private/setup`;
|
|
249
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
250
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
251
|
+
logger.info('destination', fullPath);
|
|
252
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
253
|
+
// https://www.mongodb.com/docs/manual/tutorial/install-mongodb-on-windows-unattended/
|
|
254
|
+
// msiexec.exe /i <path_to_package> [/quiet][/passive][/q{n|b|r|f}]
|
|
255
|
+
// /quiet - quiet mode (there is no user interaction)
|
|
256
|
+
// /passive - unattended mode (the installation shows only a progress bar)
|
|
257
|
+
// /q - set the UI level:
|
|
258
|
+
// n - no UI
|
|
259
|
+
// n+ - no UI except for a modal dialog box displayed at the end.
|
|
260
|
+
// b - basic UI
|
|
261
|
+
// b+ - basic UI with a modal dialog box displayed at the end. The modal box is not displayed if the user cancels the installation. Use qb+! or qb!+ to hide the [ Cancel ] button.
|
|
262
|
+
// b- - basic UI with no modal dialog boxes. Please note that /qb+- is not a supported UI level. Use qb-! or qb!- to hide the [ Cancel ] button.
|
|
263
|
+
// r - reduced UI
|
|
264
|
+
// f - full UI
|
|
265
|
+
// cmd = `msiexec.exe /i ${getRootDirectory()}${fullPath.slice(1)} /qn`;
|
|
266
|
+
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
267
|
+
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} ^ SHOULD_INSTALL_COMPASS="1" /qn`;
|
|
268
|
+
if (!fs.existsSync(`C:/Program Files/MongoDB/Server`)) shellExec(cmd);
|
|
269
|
+
const dbPath = `c:/mongodb/data`;
|
|
270
|
+
if (!fs.existsSync(dbPath)) fs.mkdirSync(dbPath, { recursive: true });
|
|
271
|
+
// https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-windows/
|
|
272
|
+
// https://medium.com/stackfame/run-mongodb-as-a-service-in-windows-b0acd3a4b712
|
|
273
|
+
// shellCd(`C:/Program Files/MongoDB/Server/${version}/bin/`);
|
|
274
|
+
// shellExec(`mongos.exe --dbpath="${dbPath}"`);
|
|
275
|
+
// shellExec(`"C:/Program Files/MongoDB/Server/${version}/bin/mongos.exe" --dbpath "${dbPath}"`);
|
|
276
|
+
})();
|
|
277
|
+
break;
|
|
278
|
+
|
|
279
|
+
default:
|
|
280
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
281
|
+
}
|
|
282
|
+
break;
|
|
283
|
+
case 'mongodb-op-cli':
|
|
284
|
+
switch (os) {
|
|
285
|
+
case 'windows':
|
|
286
|
+
await (async () => {
|
|
287
|
+
// https://www.mongodb.com/try/download/mongocli
|
|
288
|
+
const urlDownload = `https://fastdl.mongodb.org/mongocli/mongocli_1.31.0_windows_x86_64.msi`;
|
|
289
|
+
const folderPath = `./engine-private/setup`;
|
|
290
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
291
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
292
|
+
logger.info('destination', fullPath);
|
|
293
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
294
|
+
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
295
|
+
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
296
|
+
shellExec(cmd);
|
|
297
|
+
})();
|
|
298
|
+
break;
|
|
299
|
+
|
|
300
|
+
default:
|
|
301
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
break;
|
|
305
|
+
case 'mongodb-op-tools':
|
|
306
|
+
switch (os) {
|
|
307
|
+
case 'windows':
|
|
308
|
+
await (async () => {
|
|
309
|
+
// env export import
|
|
310
|
+
// https://www.mongodb.com/try/download/database-tools
|
|
311
|
+
const urlDownload = `https://fastdl.mongodb.org/tools/db/mongodb-database-tools-windows-x86_64-100.9.3.msi`;
|
|
312
|
+
const folderPath = `./engine-private/setup`;
|
|
313
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
314
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
315
|
+
logger.info('destination', fullPath);
|
|
316
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
317
|
+
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
318
|
+
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
319
|
+
shellExec(cmd);
|
|
320
|
+
})();
|
|
321
|
+
break;
|
|
322
|
+
|
|
323
|
+
default:
|
|
324
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
break;
|
|
328
|
+
case 'mongodb-shell':
|
|
329
|
+
switch (os) {
|
|
330
|
+
case 'windows':
|
|
331
|
+
await (async () => {
|
|
332
|
+
// https://www.mongodb.com/try/download/shell
|
|
333
|
+
const urlDownload = `https://downloads.mongodb.com/compass/mongosh-2.1.0-x64.msi`;
|
|
334
|
+
const folderPath = `./engine-private/setup`;
|
|
335
|
+
if (!fs.existsSync(folderPath)) fs.mkdirSync(folderPath, { recursive: true });
|
|
336
|
+
const fullPath = `${folderPath}/${urlDownload.split('/').pop()}`;
|
|
337
|
+
logger.info('destination', fullPath);
|
|
338
|
+
if (!fs.existsSync(fullPath)) await Downloader(urlDownload, fullPath);
|
|
339
|
+
shellCd(`${getRootDirectory()}${folderPath.slice(1)}`);
|
|
340
|
+
cmd = `msiexec.exe /i ${urlDownload.split('/').pop()} /qn`;
|
|
341
|
+
shellExec(cmd);
|
|
342
|
+
})();
|
|
343
|
+
break;
|
|
344
|
+
|
|
345
|
+
default:
|
|
346
|
+
throw new Error(`Os not found: ${os} for program ${program}`);
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
break;
|
|
350
|
+
|
|
351
|
+
default:
|
|
352
|
+
throw new Error(`Program not found: ${program}`);
|
|
353
|
+
}
|
|
354
|
+
logger.info(`end install ${program} on ${os}`);
|
|
355
|
+
} catch (error) {
|
|
356
|
+
logger.error(error, error.stack);
|
|
357
|
+
}
|
package/bin/shortcut.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import { getRootDirectory, shellExec } from '../src/server/process.js';
|
|
3
|
+
import os from 'os';
|
|
4
|
+
|
|
5
|
+
const [exe, dir, oS, env] = process.argv;
|
|
6
|
+
|
|
7
|
+
switch (oS) {
|
|
8
|
+
case 'windows':
|
|
9
|
+
switch (env) {
|
|
10
|
+
case 'development':
|
|
11
|
+
(() => {
|
|
12
|
+
const desktopDir = `${os.homedir()}/desktop`.replaceAll('\\', '/');
|
|
13
|
+
fs.writeFileSync(
|
|
14
|
+
`./bin/shortcut.ps1`,
|
|
15
|
+
`
|
|
16
|
+
$DesktopPath = [Environment]::GetFolderPath("Desktop") + "/${env}-engine.lnk"
|
|
17
|
+
|
|
18
|
+
$WshShell = New-Object -comObject WScript.Shell
|
|
19
|
+
|
|
20
|
+
$Shortcut = $WshShell.CreateShortcut($DesktopPath)
|
|
21
|
+
|
|
22
|
+
$Shortcut.TargetPath = "cmd.exe"
|
|
23
|
+
|
|
24
|
+
$Shortcut.Arguments = "PowerShell Start-Process cmd -Verb RunAs -ArgumentList '/k cd ${getRootDirectory()} && npm run dev"
|
|
25
|
+
|
|
26
|
+
$Shortcut.IconLocation = "${getRootDirectory()}/src/client/public/doc/favicon.ico"
|
|
27
|
+
|
|
28
|
+
$Shortcut.Save()
|
|
29
|
+
`,
|
|
30
|
+
);
|
|
31
|
+
shellExec(`PowerShell bin/shortcut.ps1`);
|
|
32
|
+
fs.unlinkSync(`./bin/shortcut.ps1`);
|
|
33
|
+
})();
|
|
34
|
+
break;
|
|
35
|
+
|
|
36
|
+
default:
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
break;
|
|
41
|
+
|
|
42
|
+
default:
|
|
43
|
+
break;
|
|
44
|
+
}
|
package/bin/ssl.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import read from 'read';
|
|
3
|
+
import ncp from 'copy-paste';
|
|
4
|
+
import dotenv from 'dotenv';
|
|
5
|
+
|
|
6
|
+
import { getRootDirectory } from '../src/server/process.js';
|
|
7
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
8
|
+
import { loadConf } from '../src/server/conf.js';
|
|
9
|
+
import { buildSSL } from '../src/server/ssl.js';
|
|
10
|
+
|
|
11
|
+
dotenv.config();
|
|
12
|
+
|
|
13
|
+
const logger = loggerFactory(import.meta);
|
|
14
|
+
|
|
15
|
+
await logger.setUpInfo();
|
|
16
|
+
|
|
17
|
+
// usage
|
|
18
|
+
// node bin/ssl windows <deploy-id> www.example.com
|
|
19
|
+
|
|
20
|
+
const [exe, dir, os, deployId, hosts] = process.argv;
|
|
21
|
+
|
|
22
|
+
try {
|
|
23
|
+
let cmd;
|
|
24
|
+
await loadConf(deployId);
|
|
25
|
+
const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
|
|
26
|
+
for (const host of hosts.split(',')) {
|
|
27
|
+
if (host in confServer) {
|
|
28
|
+
const directory = confServer[host]['/']?.['directory'] ? confServer[host]['/']['directory'] : undefined;
|
|
29
|
+
cmd = `certbot certonly --webroot --webroot-path ${
|
|
30
|
+
directory ? directory : `${getRootDirectory()}/public/${host}`
|
|
31
|
+
} -d ${host}`;
|
|
32
|
+
// You can get multi domain cert by specifying (extra) -d
|
|
33
|
+
// For example
|
|
34
|
+
// certbot -d example.com -d example.net -d www.example.org
|
|
35
|
+
|
|
36
|
+
// delete all file (no increment live folder)
|
|
37
|
+
// certbot delete --cert-name <domain>
|
|
38
|
+
|
|
39
|
+
logger.info(`Run the following command`, cmd);
|
|
40
|
+
await ncp.copy(cmd);
|
|
41
|
+
await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
|
|
42
|
+
// Certificate
|
|
43
|
+
switch (os) {
|
|
44
|
+
case 'windows':
|
|
45
|
+
await buildSSL(host);
|
|
46
|
+
break;
|
|
47
|
+
|
|
48
|
+
default:
|
|
49
|
+
break;
|
|
50
|
+
}
|
|
51
|
+
logger.info('Certificate saved', host);
|
|
52
|
+
} else throw new Error(`host not found: ${host}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
cmd = `certbot renew --dry-run`;
|
|
56
|
+
await ncp.copy(cmd);
|
|
57
|
+
logger.info(`run the following command for renewal. Command copy to clipboard`, cmd);
|
|
58
|
+
logger.info(`success install SLL`, hosts);
|
|
59
|
+
} catch (error) {
|
|
60
|
+
logger.error(error, error.stack);
|
|
61
|
+
}
|