underpost 2.6.3 → 2.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.dockerignore +13 -13
- package/.env.development +7 -7
- package/.env.production +7 -7
- package/.env.test +7 -7
- package/.github/workflows/publish.yml +26 -0
- package/.nycrc +9 -9
- package/.prettierignore +12 -12
- package/.prettierrc +9 -9
- package/.vscode/extensions.json +72 -72
- package/.vscode/settings.json +100 -99
- package/AUTHORS.md +10 -0
- package/CHANGELOG.md +91 -0
- package/Dockerfile +89 -89
- package/LICENSE +21 -21
- package/README.md +96 -96
- package/bin/db.js +172 -119
- package/bin/deploy.js +582 -626
- package/bin/dns.js +1 -1
- package/bin/file.js +92 -92
- package/bin/index.js +53 -34
- package/bin/install.js +398 -357
- package/bin/shortcut.js +44 -44
- package/bin/ssl.js +65 -61
- package/bin/util.js +182 -182
- package/bin/vs.js +35 -35
- package/conf.js +251 -249
- package/docker-compose.yml +67 -67
- package/jsconfig.json +7 -7
- package/jsdoc.json +32 -32
- package/nodemon.json +6 -6
- package/package.json +137 -128
- package/prometheus.yml +36 -36
- package/setup.sh +24 -24
- package/src/api/core/core.controller.js +69 -69
- package/src/api/core/core.model.js +11 -11
- package/src/api/core/core.router.js +23 -23
- package/src/api/core/core.service.js +29 -29
- package/src/api/crypto/crypto.controller.js +51 -51
- package/src/api/crypto/crypto.model.js +23 -23
- package/src/api/crypto/crypto.router.js +20 -20
- package/src/api/crypto/crypto.service.js +64 -64
- package/src/api/default/default.controller.js +69 -69
- package/src/api/default/default.model.js +20 -20
- package/src/api/default/default.router.js +23 -23
- package/src/api/default/default.service.js +31 -31
- package/src/api/file/file.controller.js +53 -51
- package/src/api/file/file.model.js +19 -19
- package/src/api/file/file.router.js +21 -20
- package/src/api/file/file.service.js +76 -70
- package/src/api/instance/instance.controller.js +69 -69
- package/src/api/instance/instance.model.js +36 -36
- package/src/api/instance/instance.router.js +33 -33
- package/src/api/instance/instance.service.js +48 -48
- package/src/api/test/test.controller.js +59 -59
- package/src/api/test/test.model.js +14 -14
- package/src/api/test/test.router.js +21 -21
- package/src/api/test/test.service.js +35 -35
- package/src/api/user/user.build.js +16 -0
- package/src/api/user/user.controller.js +70 -70
- package/src/api/user/user.model.js +65 -65
- package/src/api/user/user.router.js +345 -345
- package/src/api/user/user.service.js +479 -479
- package/src/api.js +23 -23
- package/src/client/Default.index.js +40 -40
- package/src/client/components/core/Account.js +290 -290
- package/src/client/components/core/AgGrid.js +160 -160
- package/src/client/components/core/Auth.js +19 -19
- package/src/client/components/core/Badge.js +32 -32
- package/src/client/components/core/BlockChain.js +41 -41
- package/src/client/components/core/Blog.js +9 -9
- package/src/client/components/core/BtnIcon.js +101 -94
- package/src/client/components/core/CalendarCore.js +458 -319
- package/src/client/components/core/Chat.js +64 -64
- package/src/client/components/core/ColorPalette.js +5267 -5267
- package/src/client/components/core/CommonJs.js +735 -732
- package/src/client/components/core/Content.js +193 -49
- package/src/client/components/core/Css.js +1064 -1027
- package/src/client/components/core/CssCore.js +817 -796
- package/src/client/components/core/D3Chart.js +44 -44
- package/src/client/components/core/Docs.js +229 -229
- package/src/client/components/core/DropDown.js +164 -164
- package/src/client/components/core/EventsUI.js +46 -54
- package/src/client/components/core/FileExplorer.js +699 -624
- package/src/client/components/core/FullScreen.js +45 -45
- package/src/client/components/core/Input.js +346 -259
- package/src/client/components/core/JoyStick.js +77 -77
- package/src/client/components/core/Keyboard.js +73 -73
- package/src/client/components/core/LoadingAnimation.js +179 -157
- package/src/client/components/core/LogIn.js +187 -181
- package/src/client/components/core/LogOut.js +58 -52
- package/src/client/components/core/Logger.js +26 -26
- package/src/client/components/core/Modal.js +1612 -1596
- package/src/client/components/core/NotificationManager.js +84 -84
- package/src/client/components/core/Panel.js +613 -413
- package/src/client/components/core/PanelForm.js +468 -0
- package/src/client/components/core/Polyhedron.js +162 -162
- package/src/client/components/core/Recover.js +204 -204
- package/src/client/components/core/Responsive.js +53 -53
- package/src/client/components/core/RichText.js +51 -27
- package/src/client/components/core/Router.js +76 -77
- package/src/client/components/core/Scroll.js +34 -0
- package/src/client/components/core/SignUp.js +125 -125
- package/src/client/components/core/SocketIo.js +72 -72
- package/src/client/components/core/Stream.js +113 -113
- package/src/client/components/core/ToggleSwitch.js +87 -87
- package/src/client/components/core/ToolTip.js +26 -26
- package/src/client/components/core/Translate.js +437 -408
- package/src/client/components/core/Validator.js +100 -100
- package/src/client/components/core/VanillaJs.js +460 -457
- package/src/client/components/core/Wallet.js +106 -106
- package/src/client/components/core/Webhook.js +25 -25
- package/src/client/components/core/Worker.js +272 -272
- package/src/client/components/default/CommonDefault.js +29 -29
- package/src/client/components/default/CssDefault.js +13 -13
- package/src/client/components/default/ElementsDefault.js +38 -38
- package/src/client/components/default/LogInDefault.js +41 -41
- package/src/client/components/default/LogOutDefault.js +28 -28
- package/src/client/components/default/MenuDefault.js +389 -389
- package/src/client/components/default/RoutesDefault.js +48 -48
- package/src/client/components/default/SettingsDefault.js +16 -16
- package/src/client/components/default/SignUpDefault.js +9 -9
- package/src/client/components/default/SocketIoDefault.js +54 -54
- package/src/client/components/default/TranslateDefault.js +7 -7
- package/src/client/public/default/assets/mailer/api-user-check.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-invalid-token.png +0 -0
- package/src/client/public/default/assets/mailer/api-user-recover.png +0 -0
- package/src/client/public/default/browserconfig.xml +11 -11
- package/src/client/public/default/manifest.webmanifest +68 -68
- package/src/client/public/default/plantuml/client-conf.svg +1 -0
- package/src/client/public/default/plantuml/client-schema.svg +1 -0
- package/src/client/public/default/plantuml/cron-conf.svg +1 -0
- package/src/client/public/default/plantuml/cron-schema.svg +1 -0
- package/src/client/public/default/plantuml/server-conf.svg +1 -0
- package/src/client/public/default/plantuml/server-schema.svg +1 -0
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -0
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -0
- package/src/client/public/default/sitemap +147 -147
- package/src/client/public/default/yandex-browser-manifest.json +8 -8
- package/src/client/public/doc/sitemap +147 -147
- package/src/client/public/test/sitemap +147 -147
- package/src/client/services/core/core.service.js +170 -152
- package/src/client/services/crypto/crypto.service.js +70 -70
- package/src/client/services/default/default.management.js +345 -345
- package/src/client/services/default/default.service.js +89 -89
- package/src/client/services/file/file.service.js +70 -70
- package/src/client/services/instance/instance.management.js +74 -74
- package/src/client/services/instance/instance.service.js +89 -89
- package/src/client/services/test/test.service.js +70 -70
- package/src/client/services/user/user.management.js +50 -50
- package/src/client/services/user/user.service.js +89 -89
- package/src/client/ssr/Render.js +16 -16
- package/src/client/ssr/body-components/CacheControl.js +114 -113
- package/src/client/ssr/body-components/DefaultSplashScreen.js +79 -79
- package/src/client/ssr/email-components/DefaultRecoverEmail.js +21 -21
- package/src/client/ssr/email-components/DefaultVerifyEmail.js +17 -17
- package/src/client/ssr/head-components/Css.js +241 -241
- package/src/client/ssr/head-components/DefaultScripts.js +3 -3
- package/src/client/ssr/head-components/Microdata.js +11 -11
- package/src/client/ssr/head-components/Production.js +1 -1
- package/src/client/ssr/head-components/PwaDefault.js +59 -59
- package/src/client/ssr/head-components/Seo.js +14 -14
- package/src/client/sw/default.sw.js +201 -201
- package/src/client/sw/template.sw.js +84 -84
- package/src/client.build.js +22 -22
- package/src/client.dev.js +21 -21
- package/src/cron.js +25 -25
- package/src/db/DataBaseProvider.js +34 -34
- package/src/db/mariadb/MariaDB.js +33 -33
- package/src/db/mongo/MongooseDB.js +46 -46
- package/src/dns.js +22 -22
- package/src/index.js +42 -0
- package/src/mailer/EmailRender.js +69 -69
- package/src/mailer/MailerProvider.js +96 -96
- package/src/proxy.js +22 -22
- package/src/runtime/lampp/Lampp.js +69 -44
- package/src/runtime/nginx/Nginx.js +3 -3
- package/src/runtime/xampp/Xampp.js +49 -49
- package/src/server/auth.js +235 -204
- package/src/server/backup.js +101 -84
- package/src/server/client-build-live.js +72 -72
- package/src/server/client-build.js +705 -699
- package/src/server/client-dev-server.js +60 -58
- package/src/server/client-formatted.js +48 -48
- package/src/server/client-icons.js +149 -150
- package/src/server/conf.js +860 -611
- package/src/server/dns.js +98 -87
- package/src/server/downloader.js +42 -42
- package/src/server/logger.js +180 -135
- package/src/server/network.js +122 -122
- package/src/server/peer.js +33 -33
- package/src/server/process.js +66 -66
- package/src/server/prompt-optimizer.js +28 -0
- package/src/server/proxy.js +118 -118
- package/src/server/runtime.js +444 -393
- package/src/server/ssl.js +109 -107
- package/src/server.js +25 -25
- package/src/ws/IoInterface.js +45 -45
- package/src/ws/IoServer.js +39 -39
- package/src/ws/core/channels/core.ws.chat.js +23 -23
- package/src/ws/core/channels/core.ws.mailer.js +35 -35
- package/src/ws/core/channels/core.ws.stream.js +31 -31
- package/src/ws/core/core.ws.connection.js +28 -28
- package/src/ws/core/core.ws.emit.js +14 -14
- package/src/ws/core/core.ws.server.js +24 -24
- package/src/ws/core/management/core.ws.chat.js +8 -8
- package/src/ws/core/management/core.ws.mailer.js +16 -16
- package/src/ws/core/management/core.ws.stream.js +8 -8
- package/src/ws/default/channels/default.ws.main.js +16 -16
- package/src/ws/default/default.ws.connection.js +22 -22
- package/src/ws/default/default.ws.emit.js +14 -14
- package/src/ws/default/default.ws.server.js +20 -20
- package/src/ws/default/management/default.ws.main.js +8 -8
- package/startup.js +11 -11
- package/supervisord-openssh-server.conf +4 -4
- package/test/api.test.js +60 -60
- package/bin/help.js +0 -110
package/bin/shortcut.js
CHANGED
|
@@ -1,44 +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
|
-
}
|
|
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
CHANGED
|
@@ -1,61 +1,65 @@
|
|
|
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
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
//
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
//
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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, shellExec } from '../src/server/process.js';
|
|
7
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
8
|
+
import { Cmd, 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
|
+
shellExec(Cmd.conf(deployId));
|
|
26
|
+
const confServer = JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'));
|
|
27
|
+
for (const host of hosts.split(',')) {
|
|
28
|
+
if (host in confServer) {
|
|
29
|
+
const directory = confServer[host]['/']?.['directory'] ? confServer[host]['/']['directory'] : undefined;
|
|
30
|
+
cmd = `certbot certonly --webroot --webroot-path ${
|
|
31
|
+
directory ? directory : `${getRootDirectory()}/public/${host}`
|
|
32
|
+
} -d ${host}`;
|
|
33
|
+
// directory ? directory : `${getRootDirectory()}/public/${host}`
|
|
34
|
+
// directory ? directory : `${getRootDirectory()}/public/www.${host.split('.').slice(-2).join('.')}`
|
|
35
|
+
|
|
36
|
+
// You can get multi domain cert by specifying (extra) -d
|
|
37
|
+
// For example
|
|
38
|
+
// certbot -d example.com -d example.net -d www.example.org
|
|
39
|
+
|
|
40
|
+
// delete all file (no increment live folder)
|
|
41
|
+
// certbot delete --cert-name <domain>
|
|
42
|
+
|
|
43
|
+
logger.info(`Run the following command`, cmd);
|
|
44
|
+
await ncp.copy(cmd);
|
|
45
|
+
await read({ prompt: 'Command copy to clipboard, press enter to continue.\n' });
|
|
46
|
+
// Certificate
|
|
47
|
+
switch (os) {
|
|
48
|
+
case 'windows':
|
|
49
|
+
await buildSSL(host);
|
|
50
|
+
break;
|
|
51
|
+
|
|
52
|
+
default:
|
|
53
|
+
break;
|
|
54
|
+
}
|
|
55
|
+
logger.info('Certificate saved', host);
|
|
56
|
+
} else throw new Error(`host not found: ${host}`);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
cmd = `certbot renew --dry-run`;
|
|
60
|
+
await ncp.copy(cmd);
|
|
61
|
+
logger.info(`run the following command for renewal. Command copy to clipboard`, cmd);
|
|
62
|
+
logger.info(`success install SLL`, hosts);
|
|
63
|
+
} catch (error) {
|
|
64
|
+
logger.error(error, error.stack);
|
|
65
|
+
}
|
package/bin/util.js
CHANGED
|
@@ -1,182 +1,182 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import merge from 'deepmerge';
|
|
3
|
-
import si from 'systeminformation';
|
|
4
|
-
import * as dir from 'path';
|
|
5
|
-
import { svg } from 'font-awesome-assets';
|
|
6
|
-
|
|
7
|
-
import { loggerFactory } from '../src/server/logger.js';
|
|
8
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
9
|
-
import { range, s4 } from '../src/client/components/core/CommonJs.js';
|
|
10
|
-
import { network } from '../src/server/network.js';
|
|
11
|
-
import { Config } from '../src/server/conf.js';
|
|
12
|
-
import { FileFactory } from '../src/api/file/file.service.js';
|
|
13
|
-
import { buildTextImg, faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
|
|
14
|
-
|
|
15
|
-
const logger = loggerFactory(import.meta);
|
|
16
|
-
|
|
17
|
-
logger.info('argv', process.argv);
|
|
18
|
-
|
|
19
|
-
const operator = process.argv[2];
|
|
20
|
-
|
|
21
|
-
try {
|
|
22
|
-
// let cmd;
|
|
23
|
-
switch (operator) {
|
|
24
|
-
case 'cls':
|
|
25
|
-
fs.removeSync('./public');
|
|
26
|
-
fs.removeSync('./logs');
|
|
27
|
-
fs.removeSync('./conf');
|
|
28
|
-
// fs.removeSync('./engine-private');
|
|
29
|
-
// fs.removeSync('./node_modules');
|
|
30
|
-
break;
|
|
31
|
-
case 'log':
|
|
32
|
-
(() => {
|
|
33
|
-
const logPath = `./logs/${process.argv[3]}/${process.argv[4]}.log`;
|
|
34
|
-
logger.info('Read', logPath);
|
|
35
|
-
console.log(fs.readFileSync(logPath, 'utf8'));
|
|
36
|
-
})();
|
|
37
|
-
break;
|
|
38
|
-
case 'kill-ports':
|
|
39
|
-
if (!process.argv[3]) process.argv[3] = '22,80,443,3000-3020';
|
|
40
|
-
for (const port of process.argv[3].split(',')) {
|
|
41
|
-
const rangePort = port.split('-');
|
|
42
|
-
if (rangePort[1])
|
|
43
|
-
for (const port of range(parseInt(rangePort[0]), parseInt(rangePort[1]))) {
|
|
44
|
-
logger.info('clean port', port);
|
|
45
|
-
await network.port.portClean(port);
|
|
46
|
-
}
|
|
47
|
-
else {
|
|
48
|
-
logger.info('clean port', parseInt(port));
|
|
49
|
-
await network.port.portClean(port);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
break;
|
|
53
|
-
case 'system-info':
|
|
54
|
-
await (async () => {
|
|
55
|
-
for (const infoKey of Object.keys(si)) {
|
|
56
|
-
if (typeof si[infoKey] === 'function') {
|
|
57
|
-
// 'dockerInfo', 'vboxInfo'
|
|
58
|
-
if (!['osInfo', 'graphics', 'cpu'].includes(infoKey)) continue;
|
|
59
|
-
try {
|
|
60
|
-
const infoInstance = await si[infoKey]();
|
|
61
|
-
logger.info(infoKey, infoInstance);
|
|
62
|
-
} catch (error) {
|
|
63
|
-
logger.info('Not valid info function', infoKey);
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
})();
|
|
68
|
-
break;
|
|
69
|
-
case 'export-git-changes':
|
|
70
|
-
{
|
|
71
|
-
const baseFrom = process.argv[3];
|
|
72
|
-
const baseTo = process.argv[4];
|
|
73
|
-
// if (fs.existsSync(baseTo)) fs.removeSync(baseTo);
|
|
74
|
-
shellCd(baseFrom);
|
|
75
|
-
{
|
|
76
|
-
try {
|
|
77
|
-
let output = shellExec('git status', { silent: true, stdout: true });
|
|
78
|
-
console.log('output:', output);
|
|
79
|
-
output = output
|
|
80
|
-
.split(`to discard changes in working directory)`)[1]
|
|
81
|
-
.split(`Untracked files:`)[0]
|
|
82
|
-
.split('modified:')
|
|
83
|
-
.map((c) => c.trim().replaceAll(`\n`, ''));
|
|
84
|
-
output[output.length - 1] = output[output.length - 1].split('no changes added to commit')[0];
|
|
85
|
-
output.shift();
|
|
86
|
-
for (const fromPath of output) {
|
|
87
|
-
const from = `${baseFrom}/${fromPath}`;
|
|
88
|
-
const to = `${baseTo}/${fromPath}`;
|
|
89
|
-
logger.info('Copy path', { from, to });
|
|
90
|
-
fs.copySync(from, to);
|
|
91
|
-
}
|
|
92
|
-
} catch (error) {
|
|
93
|
-
logger.error(error);
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
{
|
|
97
|
-
try {
|
|
98
|
-
let output = shellExec('git status', { silent: true, stdout: true });
|
|
99
|
-
console.log('output:', output);
|
|
100
|
-
output = output
|
|
101
|
-
.split(`to include in what will be committed)`)[1]
|
|
102
|
-
.split(`no changes added to commit`)[0]
|
|
103
|
-
.split(`\n`)
|
|
104
|
-
.map((l) => l.trim())
|
|
105
|
-
.filter((l) => l);
|
|
106
|
-
|
|
107
|
-
for (const fromPath of output) {
|
|
108
|
-
const from = `${baseFrom}/${fromPath}`;
|
|
109
|
-
const to = `${baseTo}/${fromPath}`;
|
|
110
|
-
logger.info('Copy path', { from, to });
|
|
111
|
-
fs.copySync(from, to);
|
|
112
|
-
}
|
|
113
|
-
} catch (error) {
|
|
114
|
-
logger.error(error);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
break;
|
|
119
|
-
case 'delete-empty-folder':
|
|
120
|
-
function cleanEmptyFoldersRecursively(folder) {
|
|
121
|
-
const isDir = fs.statSync(folder).isDirectory();
|
|
122
|
-
if (!isDir) return;
|
|
123
|
-
|
|
124
|
-
let files = fs.readdirSync(folder);
|
|
125
|
-
if (files.length > 0) {
|
|
126
|
-
files.forEach(function (file) {
|
|
127
|
-
const fullPath = dir.join(folder, file);
|
|
128
|
-
cleanEmptyFoldersRecursively(fullPath);
|
|
129
|
-
});
|
|
130
|
-
|
|
131
|
-
// re-evaluate files; after deleting subfolder
|
|
132
|
-
// we may have parent folder empty now
|
|
133
|
-
files = fs.readdirSync(folder);
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
if (files.length === 0) {
|
|
137
|
-
console.log('removing: ', folder);
|
|
138
|
-
fs.rmdirSync(folder);
|
|
139
|
-
return;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
cleanEmptyFoldersRecursively('./');
|
|
143
|
-
break;
|
|
144
|
-
|
|
145
|
-
case 'text-to-image': {
|
|
146
|
-
const buffer = await getBufferPngText({
|
|
147
|
-
text: process.argv[3],
|
|
148
|
-
textColor: process.argv[4],
|
|
149
|
-
bgColor: process.argv[5],
|
|
150
|
-
size: process.argv[6],
|
|
151
|
-
debugFilename: process.argv[7],
|
|
152
|
-
});
|
|
153
|
-
fs.writeFileSync(`./text-to-image.png`, buffer);
|
|
154
|
-
break;
|
|
155
|
-
}
|
|
156
|
-
case 'fa-image':
|
|
157
|
-
const faId = process.argv[3] ? process.argv[3] : 'user';
|
|
158
|
-
const color = process.argv[4] ? process.argv[4] : '#5f5f5f';
|
|
159
|
-
const path = process.argv[5] ? process.argv[5] : './';
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
fs.writeFileSync(`./tmp/${faId}.svg`, svg(faId, color), 'utf8');
|
|
163
|
-
const data = fs.readFileSync(`./tmp/${faId}.svg`);
|
|
164
|
-
console.log(FileFactory.svg(data, `${faId}.svg`));
|
|
165
|
-
fs.removeSync(`${path}${faId}.svg`);
|
|
166
|
-
}
|
|
167
|
-
{
|
|
168
|
-
fs.writeFileSync(`${path}${faId}.png`, Buffer.from(faBase64Png(faId, 100, 100, color), 'base64'));
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
break;
|
|
172
|
-
|
|
173
|
-
case 'b64-image':
|
|
174
|
-
fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
|
|
175
|
-
break;
|
|
176
|
-
|
|
177
|
-
default:
|
|
178
|
-
break;
|
|
179
|
-
}
|
|
180
|
-
} catch (error) {
|
|
181
|
-
logger.error(error, error.stack);
|
|
182
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import merge from 'deepmerge';
|
|
3
|
+
import si from 'systeminformation';
|
|
4
|
+
import * as dir from 'path';
|
|
5
|
+
import { svg } from 'font-awesome-assets';
|
|
6
|
+
|
|
7
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
8
|
+
import { shellCd, shellExec } from '../src/server/process.js';
|
|
9
|
+
import { range, s4 } from '../src/client/components/core/CommonJs.js';
|
|
10
|
+
import { network } from '../src/server/network.js';
|
|
11
|
+
import { Config } from '../src/server/conf.js';
|
|
12
|
+
import { FileFactory } from '../src/api/file/file.service.js';
|
|
13
|
+
import { buildTextImg, faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
|
|
14
|
+
|
|
15
|
+
const logger = loggerFactory(import.meta);
|
|
16
|
+
|
|
17
|
+
logger.info('argv', process.argv);
|
|
18
|
+
|
|
19
|
+
const operator = process.argv[2];
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
// let cmd;
|
|
23
|
+
switch (operator) {
|
|
24
|
+
case 'cls':
|
|
25
|
+
fs.removeSync('./public');
|
|
26
|
+
fs.removeSync('./logs');
|
|
27
|
+
fs.removeSync('./conf');
|
|
28
|
+
// fs.removeSync('./engine-private');
|
|
29
|
+
// fs.removeSync('./node_modules');
|
|
30
|
+
break;
|
|
31
|
+
case 'log':
|
|
32
|
+
(() => {
|
|
33
|
+
const logPath = `./logs/${process.argv[3]}/${process.argv[4]}.log`;
|
|
34
|
+
logger.info('Read', logPath);
|
|
35
|
+
console.log(fs.readFileSync(logPath, 'utf8'));
|
|
36
|
+
})();
|
|
37
|
+
break;
|
|
38
|
+
case 'kill-ports':
|
|
39
|
+
if (!process.argv[3]) process.argv[3] = '22,80,443,3000-3020';
|
|
40
|
+
for (const port of process.argv[3].split(',')) {
|
|
41
|
+
const rangePort = port.split('-');
|
|
42
|
+
if (rangePort[1])
|
|
43
|
+
for (const port of range(parseInt(rangePort[0]), parseInt(rangePort[1]))) {
|
|
44
|
+
logger.info('clean port', port);
|
|
45
|
+
await network.port.portClean(port);
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
logger.info('clean port', parseInt(port));
|
|
49
|
+
await network.port.portClean(port);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
break;
|
|
53
|
+
case 'system-info':
|
|
54
|
+
await (async () => {
|
|
55
|
+
for (const infoKey of Object.keys(si)) {
|
|
56
|
+
if (typeof si[infoKey] === 'function') {
|
|
57
|
+
// 'dockerInfo', 'vboxInfo'
|
|
58
|
+
if (!['osInfo', 'graphics', 'cpu'].includes(infoKey)) continue;
|
|
59
|
+
try {
|
|
60
|
+
const infoInstance = await si[infoKey]();
|
|
61
|
+
logger.info(infoKey, infoInstance);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
logger.info('Not valid info function', infoKey);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
break;
|
|
69
|
+
case 'export-git-changes':
|
|
70
|
+
{
|
|
71
|
+
const baseFrom = process.argv[3];
|
|
72
|
+
const baseTo = process.argv[4];
|
|
73
|
+
// if (fs.existsSync(baseTo)) fs.removeSync(baseTo);
|
|
74
|
+
shellCd(baseFrom);
|
|
75
|
+
{
|
|
76
|
+
try {
|
|
77
|
+
let output = shellExec('git status', { silent: true, stdout: true });
|
|
78
|
+
console.log('output:', output);
|
|
79
|
+
output = output
|
|
80
|
+
.split(`to discard changes in working directory)`)[1]
|
|
81
|
+
.split(`Untracked files:`)[0]
|
|
82
|
+
.split('modified:')
|
|
83
|
+
.map((c) => c.trim().replaceAll(`\n`, ''));
|
|
84
|
+
output[output.length - 1] = output[output.length - 1].split('no changes added to commit')[0];
|
|
85
|
+
output.shift();
|
|
86
|
+
for (const fromPath of output) {
|
|
87
|
+
const from = `${baseFrom}/${fromPath}`;
|
|
88
|
+
const to = `${baseTo}/${fromPath}`;
|
|
89
|
+
logger.info('Copy path', { from, to });
|
|
90
|
+
fs.copySync(from, to);
|
|
91
|
+
}
|
|
92
|
+
} catch (error) {
|
|
93
|
+
logger.error(error);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
{
|
|
97
|
+
try {
|
|
98
|
+
let output = shellExec('git status', { silent: true, stdout: true });
|
|
99
|
+
console.log('output:', output);
|
|
100
|
+
output = output
|
|
101
|
+
.split(`to include in what will be committed)`)[1]
|
|
102
|
+
.split(`no changes added to commit`)[0]
|
|
103
|
+
.split(`\n`)
|
|
104
|
+
.map((l) => l.trim())
|
|
105
|
+
.filter((l) => l);
|
|
106
|
+
|
|
107
|
+
for (const fromPath of output) {
|
|
108
|
+
const from = `${baseFrom}/${fromPath}`;
|
|
109
|
+
const to = `${baseTo}/${fromPath}`;
|
|
110
|
+
logger.info('Copy path', { from, to });
|
|
111
|
+
fs.copySync(from, to);
|
|
112
|
+
}
|
|
113
|
+
} catch (error) {
|
|
114
|
+
logger.error(error);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case 'delete-empty-folder':
|
|
120
|
+
function cleanEmptyFoldersRecursively(folder) {
|
|
121
|
+
const isDir = fs.statSync(folder).isDirectory();
|
|
122
|
+
if (!isDir) return;
|
|
123
|
+
|
|
124
|
+
let files = fs.readdirSync(folder);
|
|
125
|
+
if (files.length > 0) {
|
|
126
|
+
files.forEach(function (file) {
|
|
127
|
+
const fullPath = dir.join(folder, file);
|
|
128
|
+
cleanEmptyFoldersRecursively(fullPath);
|
|
129
|
+
});
|
|
130
|
+
|
|
131
|
+
// re-evaluate files; after deleting subfolder
|
|
132
|
+
// we may have parent folder empty now
|
|
133
|
+
files = fs.readdirSync(folder);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (files.length === 0) {
|
|
137
|
+
console.log('removing: ', folder);
|
|
138
|
+
fs.rmdirSync(folder);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
cleanEmptyFoldersRecursively('./');
|
|
143
|
+
break;
|
|
144
|
+
|
|
145
|
+
case 'text-to-image': {
|
|
146
|
+
const buffer = await getBufferPngText({
|
|
147
|
+
text: process.argv[3],
|
|
148
|
+
textColor: process.argv[4],
|
|
149
|
+
bgColor: process.argv[5],
|
|
150
|
+
size: process.argv[6],
|
|
151
|
+
debugFilename: process.argv[7],
|
|
152
|
+
});
|
|
153
|
+
fs.writeFileSync(`./text-to-image.png`, buffer);
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case 'fa-image':
|
|
157
|
+
const faId = process.argv[3] ? process.argv[3] : 'user';
|
|
158
|
+
const color = process.argv[4] ? process.argv[4] : '#5f5f5f';
|
|
159
|
+
const path = process.argv[5] ? process.argv[5] : './';
|
|
160
|
+
|
|
161
|
+
{
|
|
162
|
+
fs.writeFileSync(`./tmp/${faId}.svg`, svg(faId, color), 'utf8');
|
|
163
|
+
const data = fs.readFileSync(`./tmp/${faId}.svg`);
|
|
164
|
+
console.log(FileFactory.svg(data, `${faId}.svg`));
|
|
165
|
+
fs.removeSync(`${path}${faId}.svg`);
|
|
166
|
+
}
|
|
167
|
+
{
|
|
168
|
+
fs.writeFileSync(`${path}${faId}.png`, Buffer.from(faBase64Png(faId, 100, 100, color), 'base64'));
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
break;
|
|
172
|
+
|
|
173
|
+
case 'b64-image':
|
|
174
|
+
fs.writeFileSync('b64-image', `data:image/jpg;base64,${fs.readFileSync(process.argv[3]).toString('base64')}`);
|
|
175
|
+
break;
|
|
176
|
+
|
|
177
|
+
default:
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
} catch (error) {
|
|
181
|
+
logger.error(error, error.stack);
|
|
182
|
+
}
|
package/bin/vs.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
import fs from 'fs-extra';
|
|
2
|
-
import { shellExec } from '../src/server/process.js';
|
|
3
|
-
|
|
4
|
-
switch (process.argv[2]) {
|
|
5
|
-
case 'import':
|
|
6
|
-
{
|
|
7
|
-
const extensions = JSON.parse(fs.readFileSync(`./.vscode/extensions.json`, 'utf8'));
|
|
8
|
-
extensions.recommendations.map((extension) => {
|
|
9
|
-
if (extension) shellExec(`code --install-extension ${extension}`);
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
break;
|
|
13
|
-
case 'export':
|
|
14
|
-
{
|
|
15
|
-
shellExec(`code --list-extensions > vs-extensions.txt`);
|
|
16
|
-
fs.writeFileSync(
|
|
17
|
-
`./.vscode/extensions.json`,
|
|
18
|
-
JSON.stringify(
|
|
19
|
-
{
|
|
20
|
-
recommendations: fs
|
|
21
|
-
.readFileSync(`./vs-extensions.txt`, 'utf8')
|
|
22
|
-
.split(`\n`)
|
|
23
|
-
.filter((ext) => ext.trim()),
|
|
24
|
-
},
|
|
25
|
-
null,
|
|
26
|
-
4,
|
|
27
|
-
),
|
|
28
|
-
'utf8',
|
|
29
|
-
);
|
|
30
|
-
fs.removeSync(`./vs-extensions.txt`);
|
|
31
|
-
}
|
|
32
|
-
break;
|
|
33
|
-
default:
|
|
34
|
-
break;
|
|
35
|
-
}
|
|
1
|
+
import fs from 'fs-extra';
|
|
2
|
+
import { shellExec } from '../src/server/process.js';
|
|
3
|
+
|
|
4
|
+
switch (process.argv[2]) {
|
|
5
|
+
case 'import':
|
|
6
|
+
{
|
|
7
|
+
const extensions = JSON.parse(fs.readFileSync(`./.vscode/extensions.json`, 'utf8'));
|
|
8
|
+
extensions.recommendations.map((extension) => {
|
|
9
|
+
if (extension) shellExec(`code --install-extension ${extension}`);
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
break;
|
|
13
|
+
case 'export':
|
|
14
|
+
{
|
|
15
|
+
shellExec(`code --list-extensions > vs-extensions.txt`);
|
|
16
|
+
fs.writeFileSync(
|
|
17
|
+
`./.vscode/extensions.json`,
|
|
18
|
+
JSON.stringify(
|
|
19
|
+
{
|
|
20
|
+
recommendations: fs
|
|
21
|
+
.readFileSync(`./vs-extensions.txt`, 'utf8')
|
|
22
|
+
.split(`\n`)
|
|
23
|
+
.filter((ext) => ext.trim()),
|
|
24
|
+
},
|
|
25
|
+
null,
|
|
26
|
+
4,
|
|
27
|
+
),
|
|
28
|
+
'utf8',
|
|
29
|
+
);
|
|
30
|
+
fs.removeSync(`./vs-extensions.txt`);
|
|
31
|
+
}
|
|
32
|
+
break;
|
|
33
|
+
default:
|
|
34
|
+
break;
|
|
35
|
+
}
|