underpost 2.8.1 → 2.8.7

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.
Files changed (145) hide show
  1. package/.dockerignore +1 -0
  2. package/.github/workflows/ghpkg.yml +19 -49
  3. package/.github/workflows/npmpkg.yml +67 -0
  4. package/.github/workflows/publish.yml +5 -5
  5. package/.github/workflows/pwa-microservices-template.page.yml +12 -4
  6. package/.github/workflows/pwa-microservices-template.test.yml +2 -2
  7. package/.vscode/extensions.json +18 -71
  8. package/.vscode/settings.json +20 -3
  9. package/AUTHORS.md +16 -5
  10. package/CHANGELOG.md +123 -3
  11. package/Dockerfile +27 -70
  12. package/README.md +39 -29
  13. package/bin/build.js +186 -0
  14. package/bin/db.js +2 -24
  15. package/bin/deploy.js +1467 -236
  16. package/bin/file.js +67 -16
  17. package/bin/hwt.js +0 -10
  18. package/bin/index.js +1 -77
  19. package/bin/ssl.js +19 -11
  20. package/bin/util.js +9 -104
  21. package/bin/vs.js +26 -2
  22. package/cli.md +451 -0
  23. package/conf.js +29 -138
  24. package/docker-compose.yml +1 -1
  25. package/jsdoc.json +1 -1
  26. package/manifests/calico-custom-resources.yaml +25 -0
  27. package/manifests/deployment/adminer/deployment.yaml +32 -0
  28. package/manifests/deployment/adminer/kustomization.yaml +7 -0
  29. package/manifests/deployment/adminer/service.yaml +13 -0
  30. package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
  31. package/manifests/deployment/fastapi/backend-service.yml +19 -0
  32. package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
  33. package/manifests/deployment/fastapi/frontend-service.yml +15 -0
  34. package/manifests/deployment/kafka/deployment.yaml +69 -0
  35. package/manifests/deployment/mongo-express/deployment.yaml +60 -0
  36. package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
  37. package/manifests/kind-config-dev.yaml +12 -0
  38. package/manifests/kind-config.yaml +12 -0
  39. package/manifests/kubeadm-calico-config.yaml +119 -0
  40. package/manifests/letsencrypt-prod.yaml +15 -0
  41. package/manifests/mariadb/config.yaml +10 -0
  42. package/manifests/mariadb/kustomization.yaml +9 -0
  43. package/manifests/mariadb/pv.yaml +12 -0
  44. package/manifests/mariadb/pvc.yaml +10 -0
  45. package/manifests/mariadb/secret.yaml +8 -0
  46. package/manifests/mariadb/service.yaml +10 -0
  47. package/manifests/mariadb/statefulset.yaml +55 -0
  48. package/manifests/mongodb/backup-access.yaml +16 -0
  49. package/manifests/mongodb/backup-cronjob.yaml +42 -0
  50. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  51. package/manifests/mongodb/configmap.yaml +26 -0
  52. package/manifests/mongodb/headless-service.yaml +10 -0
  53. package/manifests/mongodb/kustomization.yaml +11 -0
  54. package/manifests/mongodb/pv-pvc.yaml +23 -0
  55. package/manifests/mongodb/statefulset.yaml +125 -0
  56. package/manifests/mongodb-4.4/kustomization.yaml +7 -0
  57. package/manifests/mongodb-4.4/pv-pvc.yaml +23 -0
  58. package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
  59. package/manifests/postgresql/configmap.yaml +9 -0
  60. package/manifests/postgresql/kustomization.yaml +10 -0
  61. package/manifests/postgresql/pv.yaml +15 -0
  62. package/manifests/postgresql/pvc.yaml +13 -0
  63. package/manifests/postgresql/service.yaml +10 -0
  64. package/manifests/postgresql/statefulset.yaml +37 -0
  65. package/manifests/valkey/kustomization.yaml +7 -0
  66. package/manifests/valkey/service.yaml +17 -0
  67. package/manifests/valkey/statefulset.yaml +41 -0
  68. package/package.json +127 -136
  69. package/src/api/core/core.service.js +1 -1
  70. package/src/api/default/default.service.js +1 -1
  71. package/src/api/user/user.model.js +16 -3
  72. package/src/api/user/user.service.js +15 -12
  73. package/src/cli/cluster.js +389 -0
  74. package/src/cli/cron.js +121 -0
  75. package/src/cli/db.js +222 -0
  76. package/src/cli/deploy.js +487 -0
  77. package/src/cli/env.js +58 -0
  78. package/src/cli/fs.js +161 -0
  79. package/src/cli/image.js +66 -0
  80. package/src/cli/index.js +312 -0
  81. package/src/cli/monitor.js +236 -0
  82. package/src/cli/repository.js +128 -0
  83. package/src/cli/script.js +53 -0
  84. package/src/cli/secrets.js +37 -0
  85. package/src/cli/test.js +118 -0
  86. package/src/client/components/core/Account.js +28 -24
  87. package/src/client/components/core/Auth.js +22 -4
  88. package/src/client/components/core/Blockchain.js +1 -1
  89. package/src/client/components/core/CalendarCore.js +128 -121
  90. package/src/client/components/core/CommonJs.js +283 -19
  91. package/src/client/components/core/CssCore.js +16 -4
  92. package/src/client/components/core/Docs.js +1 -2
  93. package/src/client/components/core/DropDown.js +5 -1
  94. package/src/client/components/core/EventsUI.js +3 -3
  95. package/src/client/components/core/FileExplorer.js +86 -78
  96. package/src/client/components/core/Input.js +22 -6
  97. package/src/client/components/core/JoyStick.js +2 -2
  98. package/src/client/components/core/LoadingAnimation.js +3 -12
  99. package/src/client/components/core/LogIn.js +3 -3
  100. package/src/client/components/core/LogOut.js +1 -1
  101. package/src/client/components/core/Modal.js +54 -20
  102. package/src/client/components/core/Panel.js +109 -90
  103. package/src/client/components/core/PanelForm.js +23 -30
  104. package/src/client/components/core/Recover.js +3 -3
  105. package/src/client/components/core/RichText.js +1 -11
  106. package/src/client/components/core/Router.js +3 -1
  107. package/src/client/components/core/Scroll.js +1 -0
  108. package/src/client/components/core/SignUp.js +2 -2
  109. package/src/client/components/core/Translate.js +47 -9
  110. package/src/client/components/core/Validator.js +9 -1
  111. package/src/client/components/core/VanillaJs.js +0 -9
  112. package/src/client/components/core/Worker.js +34 -31
  113. package/src/client/components/default/RoutesDefault.js +3 -2
  114. package/src/client/services/core/core.service.js +15 -10
  115. package/src/client/services/default/default.management.js +46 -37
  116. package/src/client/ssr/Render.js +6 -1
  117. package/src/client/ssr/body/CacheControl.js +2 -3
  118. package/src/client/sw/default.sw.js +3 -3
  119. package/src/db/mongo/MongooseDB.js +29 -1
  120. package/src/index.js +101 -19
  121. package/src/mailer/MailerProvider.js +3 -0
  122. package/src/runtime/lampp/Dockerfile +65 -0
  123. package/src/runtime/lampp/Lampp.js +1 -13
  124. package/src/runtime/xampp/Xampp.js +0 -13
  125. package/src/server/auth.js +3 -3
  126. package/src/server/backup.js +49 -93
  127. package/src/server/client-build.js +49 -46
  128. package/src/server/client-formatted.js +6 -3
  129. package/src/server/conf.js +297 -55
  130. package/src/server/dns.js +75 -62
  131. package/src/server/downloader.js +0 -8
  132. package/src/server/json-schema.js +77 -0
  133. package/src/server/logger.js +15 -10
  134. package/src/server/network.js +20 -161
  135. package/src/server/peer.js +2 -2
  136. package/src/server/process.js +25 -2
  137. package/src/server/proxy.js +7 -29
  138. package/src/server/runtime.js +53 -40
  139. package/src/server/ssl.js +1 -1
  140. package/src/server/start.js +122 -0
  141. package/src/server/valkey.js +27 -11
  142. package/test/api.test.js +0 -8
  143. package/src/dns.js +0 -22
  144. package/src/server/prompt-optimizer.js +0 -28
  145. package/startup.js +0 -11
package/Dockerfile CHANGED
@@ -1,90 +1,47 @@
1
1
  ARG BASE_DEBIAN=buster
2
2
 
3
- FROM debian:${BASE_DEBIAN}
3
+ # USER root
4
4
 
5
- ENV DEBIAN_FRONTEND noninteractive
5
+ FROM debian:${BASE_DEBIAN}
6
6
 
7
- WORKDIR /code
7
+ ENV DEBIAN_FRONTEND=noninteractive
8
8
 
9
9
  # Set root password to root, format is 'user:password'.
10
10
  RUN echo 'root:root' | chpasswd
11
11
 
12
- RUN apt-get update --fix-missing && \
13
- apt-get upgrade -y && \
14
- # install sudo
15
- apt-get -y install sudo && \
16
- # net-tools provides netstat commands
17
- apt-get -y install curl net-tools && \
18
- apt-get -yq install openssh-server supervisor && \
19
- # Few handy utilities which are nice to have
20
- apt-get -y install nano vim less --no-install-recommends && \
21
- apt-get clean
12
+ RUN apt-get update --fix-missing
13
+ RUN apt-get upgrade -y
14
+ # install sudo
15
+ RUN apt-get -y install sudo
16
+ # net-tools provides netstat commands
17
+ RUN apt-get -y install curl net-tools
18
+ RUN apt-get -yq install openssh-server supervisor
19
+ # Few handy utilities which are nice to have
20
+ RUN apt-get -y install nano vim less --no-install-recommends
21
+ RUN apt-get clean
22
22
 
23
23
  # install ssh
24
- RUN mkdir -p /var/run/sshd && \
25
- # Allow root login via password
26
- sed -ri 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
27
-
28
- # copy supervisor config file to start openssh-server
29
- COPY supervisord-openssh-server.conf /etc/supervisor/conf.d/supervisord-openssh-server.conf
24
+ RUN mkdir -p /var/run/sshd
25
+ # Allow root login via password
26
+ RUN sed -ri 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/g' /etc/ssh/sshd_config
30
27
 
31
28
  # install open ssl git and others tools
32
- RUN apt-get install -yq --no-install-recommends \
33
- libssl-dev \
34
- curl \
35
- wget \
36
- git \
37
- gnupg
29
+ RUN apt-get install -yq --no-install-recommends libssl-dev curl wget git gnupg
38
30
 
39
31
  # install nodejs https://github.com/nodesource/distributions/blob/master/README.md#deb
40
- RUN curl -fsSL https://deb.nodesource.com/setup_22.x | bash - && \
41
- apt-get install -y nodejs \
42
- build-essential && \
43
- node --version && \
44
- npm --version
45
-
46
-
47
- # install lampp
48
- RUN curl -Lo xampp-linux-installer.run https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/7.4.30/xampp-linux-x64-7.4.30-1-installer.run?from_af=true && \
49
- chmod +x xampp-linux-installer.run && \
50
- bash -c './xampp-linux-installer.run' && \
51
- ln -sf /opt/lampp/lampp /usr/bin/lampp && \
52
- # Enable XAMPP web interface(remove security checks)
53
- sed -i.bak s'/Require local/Require all granted/g' /opt/lampp/etc/extra/httpd-xampp.conf && \
54
- # Enable error display in php
55
- sed -i.bak s'/display_errors=Off/display_errors=On/g' /opt/lampp/etc/php.ini && \
56
- # Enable includes of several configuration files
57
- mkdir /opt/lampp/apache2/conf.d && \
58
- echo "IncludeOptional /opt/lampp/apache2/conf.d/*.conf" >> /opt/lampp/etc/httpd.conf && \
59
- # Create a /www folder and a symbolic link to it in /opt/lampp/htdocs. It'll be accessible via http://localhost:[port]/www/
60
- # This is convenient because it doesn't interfere with xampp, phpmyadmin or other tools in /opt/lampp/htdocs
61
- # /opt/lampp/etc/httpd.conf
62
- mkdir /www && \
63
- ln -s /www /opt/lampp/htdocs
64
-
65
-
66
- # Install mongodb necessary libs
67
- RUN apt-get update && apt-get install -y apt-utils wget gnupg gnupg2 curl
68
-
69
- # Install mongodb
70
- RUN wget -qO - https://www.mongodb.org/static/pgp/server-4.2.asc | apt-key add -
71
- RUN echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.2 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.2.list
72
- RUN apt-get update
73
- RUN apt-get install -y mongodb-org
74
-
75
- # BIND TO ALL ADAPTERS IN CONTAINER
76
- RUN sed -i "s,\\(^[[:blank:]]*bindIp:\\) .*,\\1 0.0.0.0," /etc/mongod.conf
32
+ RUN curl -fsSL https://deb.nodesource.com/setup_23.x | bash -
33
+ RUN apt-get install -y nodejs build-essential
34
+ RUN node --version
35
+ RUN npm --version
77
36
 
78
- # Bundle app source
79
- # COPY . .
37
+ WORKDIR /home/dd
80
38
 
81
- # Install underpost cli
82
- RUN npm install -g underpost
39
+ EXPOSE 22
83
40
 
41
+ EXPOSE 80
84
42
 
85
- VOLUME [ "/code/app/logs" ]
43
+ EXPOSE 443
86
44
 
87
- EXPOSE 22 80 443 3306 27017
88
- EXPOSE 3000-3020
45
+ EXPOSE 3000-3100
89
46
 
90
- CMD [ "node", "startup" ]
47
+ EXPOSE 4000-4100
package/README.md CHANGED
@@ -16,7 +16,7 @@ template
16
16
 
17
17
  <div align="center">
18
18
 
19
- <a target="_top" href='https://www.npmjs.com/package/npm/v/10.2.3' ><img alt='npm' src='https://img.shields.io/badge/npm v10.2.3-100000?style=flat&logo=npm&logoColor=white&labelColor=CB3837&color=727273'/></a> <a target="_top" href='https://nodejs.org/download/release/v22.9.0/' ><img alt='nodedotjs' src='https://img.shields.io/badge/node v22.9.0-100000?style=flat&logo=nodedotjs&logoColor=white&labelColor=5FA04E&color=727273'/></a> <a target="_top" href='https://pgp.mongodb.com/' ><img alt='mongodb' src='https://img.shields.io/badge/mongodb_server v7.0-100000?style=flat&logo=mongodb&logoColor=white&labelColor=47A248&color=727273'/></a>
19
+ <a target="_top" href='https://www.npmjs.com/package/npm/v/11.1.0' ><img alt='npm' src='https://img.shields.io/badge/npm v11.1.0-100000?style=flat&logo=npm&logoColor=white&labelColor=CB3837&color=727273'/></a> <a target="_top" href='https://nodejs.org/download/release/v22.9.0/' ><img alt='nodedotjs' src='https://img.shields.io/badge/node v23.8.0-100000?style=flat&logo=nodedotjs&logoColor=white&labelColor=5FA04E&color=727273'/></a> <a target="_top" href='https://pgp.mongodb.com/' ><img alt='mongodb' src='https://img.shields.io/badge/mongodb_server v7.0-100000?style=flat&logo=mongodb&logoColor=white&labelColor=47A248&color=727273'/></a>
20
20
 
21
21
  </div>
22
22
 
@@ -38,7 +38,7 @@ Develop, build, deploy, test, monitor, and manage multiple runtime applications
38
38
  <!-- https://kapasia-dev-ed.my.site.com/Badges4Me/s/ -->
39
39
  <!-- https://simpleicons.org/ -->
40
40
 
41
- #### Create a new project
41
+ ## Create a new project
42
42
 
43
43
  ```bash
44
44
  npm install -g underpost
@@ -50,7 +50,7 @@ underpost new app-name
50
50
 
51
51
  After template installation, the server will be running on [http://localhost:4001](http://localhost:4001)
52
52
 
53
- #### Usage
53
+ ## Usage
54
54
 
55
55
  ```bash
56
56
  cd app-name
@@ -67,30 +67,40 @@ Run dev client server
67
67
  ```bash
68
68
  npm run dev
69
69
  ```
70
-
71
- Run dev api server
72
-
73
- ```bash
74
- npm run dev-api
75
- ```
76
-
77
- Run on `pm2`
78
-
79
- ```bash
80
- npm run pm2
81
- ```
82
-
83
- Run on `docker-compose`
84
-
85
- ```bash
86
- npm run start:docker
87
- ```
88
-
89
- Run on `docker`
90
-
91
- ```bash
92
- # build image
93
- docker build . -t app-name
94
- # run image
95
- docker run --name app-name-instance -p 41061:3001 -p 41062:3002 app-name
70
+ <!-- -->
71
+ ## underpost ci/cd cli v2.8.7
72
+
73
+ ### Usage: `underpost [options] [command]`
74
+ ```
75
+ Options:
76
+ -V, --version output the version number
77
+ -h, --help display help for command
78
+
79
+ Commands:
80
+ new <app-name> Create a new project
81
+ start [options] <deploy-id> [env] Start up server, build pipelines, or services
82
+ clone [options] <uri> Clone github repository
83
+ pull <path> <uri> Pull github repository
84
+ cmt [options] <path> <commit-type> [module-tag] [message] Commit github repository
85
+ push [options] <path> <uri> Push github repository
86
+ env <deploy-id> [env] Set environment variables files and conf related to <deploy-id>
87
+ config <operator> [key] [value] Manage configuration, operators
88
+ root Get npm root path
89
+ cluster [options] [pod-name] Manage cluster, for default initialization base kind cluster
90
+ deploy [options] <deploy-list> [env] Manage deployment, for default deploy development pods
91
+ secret [options] <platform> Manage secrets
92
+ dockerfile-image-build [options] Build image from Dockerfile
93
+ dockerfile-pull-base-images Pull underpost dockerfile images requirements
94
+ install Fast import underpost npm dependencies
95
+ db [options] <deploy-list> Manage databases
96
+ script [options] <operator> <script-name> [script-value] Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts
97
+ cron [options] [deploy-list] [job-list] Cron jobs management
98
+ fs [options] [path] File storage management, for default upload file
99
+ test [options] [deploy-list] Manage Test, for default run current underpost default test
100
+ monitor [options] <deploy-id> [env] Monitor health server management
101
+ help [command] display help for command
102
+
96
103
  ```
104
+
105
+ <a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
106
+
package/bin/build.js ADDED
@@ -0,0 +1,186 @@
1
+ import fs from 'fs-extra';
2
+ import { loggerFactory } from '../src/server/logger.js';
3
+ import { shellExec } from '../src/server/process.js';
4
+ import dotenv from 'dotenv';
5
+ import { getCapVariableName } from '../src/client/components/core/CommonJs.js';
6
+ import { getPathsSSR } from '../src/server/conf.js';
7
+
8
+ const baseConfPath = './engine-private/conf/dd-cron/.env.production';
9
+ if (fs.existsSync(baseConfPath)) dotenv.config({ path: baseConfPath, override: true });
10
+
11
+ const logger = loggerFactory(import.meta);
12
+
13
+ // (async () => {
14
+ // return;
15
+ // const files = await fs.readdir(`./src`);
16
+ // for (const relativePath of files) {
17
+ // }
18
+ // })();
19
+
20
+ const confName = process.argv[2];
21
+ const basePath = '../pwa-microservices-template';
22
+ const repoName = `engine-${confName.split('dd-')[1]}`;
23
+ const deployList = (confName === 'dd' ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8') : confName).split(
24
+ ',',
25
+ );
26
+
27
+ logger.info('', {
28
+ confName,
29
+ repoName,
30
+ basePath,
31
+ deployList,
32
+ });
33
+
34
+ if (process.argv.includes('clean')) {
35
+ if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
36
+ shellExec(`cd ${basePath} && git checkout .`);
37
+ shellExec(`cd ${basePath} && git clean -f -d`);
38
+ process.exit(0);
39
+ }
40
+
41
+ if (process.argv.includes('conf')) {
42
+ for (const _confName of deployList) {
43
+ const _repoName = `engine-${_confName.split('dd-')[1]}`;
44
+ const privateRepoName = `${_repoName}-private`;
45
+ const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
46
+
47
+ if (!fs.existsSync(`../${privateRepoName}`)) {
48
+ shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
49
+ } else {
50
+ shellExec(`cd ../${privateRepoName} && git checkout . && git clean -f -d && underpost pull . ${privateGitUri}`);
51
+ }
52
+ const toPath = `../${privateRepoName}/conf/${_confName}`;
53
+ fs.removeSync(toPath);
54
+ fs.mkdirSync(toPath, { recursive: true });
55
+ fs.copySync(`./engine-private/conf/${_confName}`, toPath);
56
+ if (fs.existsSync(`./engine-private/replica`)) {
57
+ const replicas = await fs.readdir(`./engine-private/replica`);
58
+ for (const replica of replicas)
59
+ if (replica.match(_confName))
60
+ fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
61
+ }
62
+ if (fs.existsSync(`./engine-private/itc-scripts`)) {
63
+ const itcScripts = await fs.readdir(`./engine-private/itc-scripts`);
64
+ for (const itcScript of itcScripts)
65
+ if (itcScript.match(_confName))
66
+ fs.copySync(`./engine-private/itc-scripts/${itcScript}`, `../${privateRepoName}/itc-scripts/${itcScript}`);
67
+ }
68
+ shellExec(
69
+ `cd ../${privateRepoName}` +
70
+ ` && git add .` +
71
+ ` && underpost cmt . ci engine-core-conf 'Update ${_confName} conf'` +
72
+ ` && underpost push . ${privateGitUri}`,
73
+ );
74
+ }
75
+ process.exit(0);
76
+ }
77
+
78
+ if (confName === 'dd') {
79
+ for (const _confName of deployList) {
80
+ shellExec(`node bin/build ${_confName}`);
81
+ }
82
+ process.exit(0);
83
+ }
84
+
85
+ const { DefaultConf } = await import(`../conf.${confName}.js`);
86
+
87
+ {
88
+ for (const host of Object.keys(DefaultConf.server)) {
89
+ for (const path of Object.keys(DefaultConf.server[host])) {
90
+ const { apis, ws } = DefaultConf.server[host][path];
91
+ if (apis)
92
+ for (const api of apis) {
93
+ {
94
+ const originPath = `./src/api/${api}`;
95
+ logger.info(`Build`, originPath);
96
+ fs.copySync(originPath, `${basePath}/src/api/${api}`);
97
+ }
98
+ {
99
+ const originPath = `./src/client/services/${api}`;
100
+ logger.info(`Build`, originPath);
101
+ fs.copySync(originPath, `${basePath}/src/client/services/${api}`);
102
+ }
103
+ }
104
+
105
+ if (ws && ws !== 'core' && ws !== 'default') {
106
+ fs.copySync(`./src/ws/${ws}`, `${basePath}/src/ws/${ws}`);
107
+ }
108
+ }
109
+ }
110
+ }
111
+
112
+ {
113
+ for (const client of Object.keys(DefaultConf.client)) {
114
+ const capName = getCapVariableName(client);
115
+ for (const component of Object.keys(DefaultConf.client[client].components)) {
116
+ const originPath = `./src/client/components/${component}`;
117
+ if (fs.existsSync(originPath)) {
118
+ logger.info(`Build`, originPath);
119
+ fs.copySync(originPath, `${basePath}/src/client/components/${component}`);
120
+ }
121
+ }
122
+ {
123
+ const originPath = `./src/client/${capName}.index.js`;
124
+ if (fs.existsSync(originPath)) {
125
+ logger.info(`Build`, originPath);
126
+ fs.copyFileSync(originPath, `${basePath}/src/client/${capName}.index.js`);
127
+ }
128
+ }
129
+ {
130
+ const originPath = `./src/client/public/${client}`;
131
+ if (fs.existsSync(originPath)) {
132
+ logger.info(`Build`, originPath);
133
+ fs.copySync(originPath, `${basePath}/src/client/public/${client}`);
134
+ }
135
+ }
136
+ }
137
+ }
138
+
139
+ {
140
+ for (const client of Object.keys(DefaultConf.ssr)) {
141
+ const ssrPaths = getPathsSSR(DefaultConf.ssr[client]);
142
+ for (const originPath of ssrPaths) {
143
+ if (fs.existsSync(originPath)) {
144
+ logger.info(`Build`, originPath);
145
+ fs.copySync(originPath, `${basePath}/${originPath}`);
146
+ }
147
+ }
148
+ }
149
+
150
+ shellExec(`node bin/deploy update-default-conf ${confName}`);
151
+
152
+ fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
153
+ fs.copyFileSync(
154
+ `./.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
155
+ `${basePath}/.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
156
+ );
157
+
158
+ switch (confName) {
159
+ case 'dd-cyberia':
160
+ fs.copyFileSync(`./bin/cyberia.js`, `${basePath}/bin/cyberia.js`);
161
+ break;
162
+
163
+ default:
164
+ break;
165
+ }
166
+
167
+ const packageJson = JSON.parse(fs.readFileSync(`${basePath}/package.json`, 'utf8'));
168
+ packageJson.name = repoName;
169
+ fs.writeFileSync(
170
+ `${basePath}/package.json`,
171
+ JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
172
+ 'utf8',
173
+ );
174
+
175
+ fs.copySync(`./src/cli`, `${basePath}/src/cli`);
176
+ if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
177
+
178
+ const env = process.argv.includes('development') ? 'development' : 'production';
179
+ const deploymentsFiles = ['proxy.yaml', 'deployment.yaml', 'secret.yaml'];
180
+ // remove engine-private of .dockerignore for local testing
181
+ for (const file of deploymentsFiles) {
182
+ if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
183
+ fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
184
+ }
185
+ }
186
+ }
package/bin/db.js CHANGED
@@ -4,10 +4,9 @@ import { loggerFactory } from '../src/server/logger.js';
4
4
  import { MariaDB } from '../src/db/mariadb/MariaDB.js';
5
5
  import { Xampp } from '../src/runtime/xampp/Xampp.js';
6
6
  import { Lampp } from '../src/runtime/lampp/Lampp.js';
7
- import { getCapVariableName, getRestoreCronCmd, loadConf } from '../src/server/conf.js';
7
+ import { getCapVariableName, getRestoreCronCmd, loadConf, splitFileFactory } from '../src/server/conf.js';
8
8
  import { DataBaseProvider } from '../src/db/DataBaseProvider.js';
9
9
  import { hashPassword } from '../src/server/auth.js';
10
- import splitFile from 'split-file';
11
10
 
12
11
  const logger = loggerFactory(import.meta);
13
12
 
@@ -101,28 +100,7 @@ try {
101
100
 
102
101
  cmd = `mysqldump -u ${user} -p${password} ${name} > ${cmdBackupPath}`;
103
102
  shellExec(cmd);
104
- const stats = fs.statSync(cmdBackupPath);
105
- const maxSizeInBytes = 1024 * 1024 * 50; // 50 mb
106
- const fileSizeInBytes = stats.size;
107
- if (fileSizeInBytes > maxSizeInBytes) {
108
- await new Promise((resolve) => {
109
- splitFile
110
- .splitFileBySize(cmdBackupPath, maxSizeInBytes) // 50 mb
111
- .then((names) => {
112
- fs.writeFileSync(
113
- `${cmdBackupPath.split('/').slice(0, -1).join('/')}/${name}-parths.json`,
114
- JSON.stringify(names, null, 4),
115
- 'utf8',
116
- );
117
- resolve();
118
- })
119
- .catch((err) => {
120
- console.log('Error: ', err);
121
- resolve();
122
- });
123
- });
124
- fs.removeSync(cmdBackupPath);
125
- }
103
+ await splitFileFactory(name, cmdBackupPath);
126
104
  }
127
105
  break;
128
106
  case 'import':