@underpostnet/underpost 2.8.1 → 2.8.5
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 +1 -0
- package/.github/workflows/ghpkg.yml +20 -50
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +13 -5
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/.vscode/extensions.json +17 -71
- package/.vscode/settings.json +14 -3
- package/AUTHORS.md +16 -5
- package/CHANGELOG.md +79 -3
- package/Dockerfile +24 -66
- package/README.md +1 -28
- package/bin/build.js +161 -0
- package/bin/db.js +2 -24
- package/bin/deploy.js +111 -82
- package/bin/file.js +59 -16
- package/bin/index.js +168 -58
- package/bin/ssl.js +19 -11
- package/bin/util.js +9 -97
- package/bin/vs.js +25 -2
- package/conf.js +31 -138
- package/docker-compose.yml +1 -1
- package/manifests/core/kustomization.yaml +11 -0
- package/manifests/core/underpost-engine-backup-access.yaml +16 -0
- package/manifests/core/underpost-engine-backup-pv-pvc.yaml +22 -0
- package/manifests/core/underpost-engine-headless-service.yaml +10 -0
- package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +40 -0
- package/manifests/core/underpost-engine-mongodb-configmap.yaml +26 -0
- package/manifests/core/underpost-engine-pv-pvc.yaml +23 -0
- package/manifests/core/underpost-engine-statefulset.yaml +91 -0
- package/manifests/deployment/mongo-express/deployment.yaml +60 -0
- package/manifests/deployment/phpmyadmin/deployment.yaml +54 -0
- package/manifests/kind-config.yaml +12 -0
- package/manifests/letsencrypt-prod.yaml +15 -0
- package/manifests/mariadb/config.yaml +10 -0
- package/manifests/mariadb/kustomization.yaml +9 -0
- package/manifests/mariadb/pv.yaml +12 -0
- package/manifests/mariadb/pvc.yaml +10 -0
- package/manifests/mariadb/secret.yaml +8 -0
- package/manifests/mariadb/service.yaml +10 -0
- package/manifests/mariadb/statefulset.yaml +55 -0
- package/manifests/mongodb/backup-access.yaml +16 -0
- package/manifests/mongodb/backup-cronjob.yaml +42 -0
- package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
- package/manifests/mongodb/configmap.yaml +26 -0
- package/manifests/mongodb/headless-service.yaml +10 -0
- package/manifests/mongodb/kustomization.yaml +11 -0
- package/manifests/mongodb/pv-pvc.yaml +23 -0
- package/manifests/mongodb/statefulset.yaml +125 -0
- package/manifests/valkey/kustomization.yaml +7 -0
- package/manifests/valkey/service.yaml +17 -0
- package/manifests/valkey/statefulset.yaml +39 -0
- package/manifests/valkey/underpost-engine-valkey-service.yaml +17 -0
- package/manifests/valkey/underpost-engine-valkey-statefulset.yaml +39 -0
- package/package.json +26 -31
- package/src/api/core/core.service.js +1 -1
- package/src/api/user/user.model.js +16 -3
- package/src/api/user/user.service.js +1 -1
- package/src/cli/cluster.js +154 -0
- package/src/cli/cron.js +90 -0
- package/src/cli/db.js +148 -0
- package/src/cli/deploy.js +277 -0
- package/src/cli/env.js +52 -0
- package/src/cli/image.js +125 -0
- package/src/cli/repository.js +104 -0
- package/src/cli/script.js +29 -0
- package/src/cli/secrets.js +37 -0
- package/src/cli/test.js +83 -0
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/CalendarCore.js +115 -49
- package/src/client/components/core/CommonJs.js +231 -19
- package/src/client/components/core/Css.js +1 -0
- package/src/client/components/core/CssCore.js +6 -0
- package/src/client/components/core/DropDown.js +5 -1
- package/src/client/components/core/Input.js +18 -4
- package/src/client/components/core/Modal.js +10 -6
- package/src/client/components/core/Panel.js +84 -25
- package/src/client/components/core/PanelForm.js +4 -18
- package/src/client/components/core/Scroll.js +1 -0
- package/src/client/components/core/Translate.js +47 -9
- package/src/client/components/core/Validator.js +9 -1
- package/src/client/components/core/VanillaJs.js +0 -9
- package/src/client/components/core/Worker.js +34 -31
- package/src/client/services/default/default.management.js +4 -2
- package/src/client/ssr/body/CacheControl.js +2 -2
- package/src/db/mongo/MongooseDB.js +13 -1
- package/src/index.js +77 -19
- package/src/runtime/lampp/Lampp.js +1 -13
- package/src/runtime/xampp/Xampp.js +0 -13
- package/src/server/auth.js +3 -3
- package/src/server/backup.js +49 -93
- package/src/server/client-build.js +4 -23
- package/src/server/client-formatted.js +5 -3
- package/src/server/conf.js +193 -45
- package/src/server/dns.js +49 -67
- package/src/server/logger.js +15 -10
- package/src/server/network.js +17 -43
- package/src/server/process.js +25 -2
- package/src/server/proxy.js +4 -26
- package/src/server/runtime.js +14 -29
- package/src/server/ssl.js +1 -1
- package/src/server/valkey.js +2 -0
- package/src/dns.js +0 -22
- package/src/server/prompt-optimizer.js +0 -28
- package/startup.js +0 -11
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/
|
|
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
|
|
|
@@ -67,30 +67,3 @@ 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
|
|
96
|
-
```
|
package/bin/build.js
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
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
|
+
|
|
24
|
+
logger.info('', {
|
|
25
|
+
confName,
|
|
26
|
+
repoName,
|
|
27
|
+
basePath,
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
if (process.argv.includes('clean')) {
|
|
31
|
+
if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
|
|
32
|
+
shellExec(`cd ${basePath} && git checkout .`);
|
|
33
|
+
shellExec(`cd ${basePath} && git clean -f -d`);
|
|
34
|
+
process.exit(0);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
if (process.argv.includes('conf')) {
|
|
38
|
+
for (const _confName of (confName === 'dd'
|
|
39
|
+
? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
|
|
40
|
+
: confName
|
|
41
|
+
).split(',')) {
|
|
42
|
+
const _repoName = `engine-${_confName.split('dd-')[1]}`;
|
|
43
|
+
const privateRepoName = `${_repoName}-private`;
|
|
44
|
+
const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
|
|
45
|
+
|
|
46
|
+
if (!fs.existsSync(`../${privateRepoName}`)) {
|
|
47
|
+
shellExec(`cd .. && underpost clone ${privateGitUri}`, { silent: true });
|
|
48
|
+
} else {
|
|
49
|
+
shellExec(`cd ../${privateRepoName} && underpost pull . ${privateGitUri}`);
|
|
50
|
+
}
|
|
51
|
+
const toPath = `../${privateRepoName}/conf/${_confName}`;
|
|
52
|
+
fs.removeSync(toPath);
|
|
53
|
+
fs.mkdirSync(toPath, { recursive: true });
|
|
54
|
+
fs.copySync(`./engine-private/conf/${_confName}`, toPath);
|
|
55
|
+
if (fs.existsSync(`./engine-private/replica`)) {
|
|
56
|
+
const replicas = await fs.readdir(`./engine-private/replica`);
|
|
57
|
+
for (const replica of replicas)
|
|
58
|
+
if (replica.match(_confName))
|
|
59
|
+
fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
|
|
60
|
+
}
|
|
61
|
+
shellExec(
|
|
62
|
+
`cd ../${privateRepoName}` +
|
|
63
|
+
` && git add .` +
|
|
64
|
+
` && underpost cmt . ci engine-core-conf 'Update ${_confName} conf'` +
|
|
65
|
+
` && underpost push . ${privateGitUri}`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
72
|
+
|
|
73
|
+
{
|
|
74
|
+
for (const host of Object.keys(DefaultConf.server)) {
|
|
75
|
+
for (const path of Object.keys(DefaultConf.server[host])) {
|
|
76
|
+
const { apis, ws } = DefaultConf.server[host][path];
|
|
77
|
+
if (apis)
|
|
78
|
+
for (const api of apis) {
|
|
79
|
+
{
|
|
80
|
+
const originPath = `./src/api/${api}`;
|
|
81
|
+
logger.info(`Build`, originPath);
|
|
82
|
+
fs.copySync(originPath, `${basePath}/src/api/${api}`);
|
|
83
|
+
}
|
|
84
|
+
{
|
|
85
|
+
const originPath = `./src/client/services/${api}`;
|
|
86
|
+
logger.info(`Build`, originPath);
|
|
87
|
+
fs.copySync(originPath, `${basePath}/src/client/services/${api}`);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (ws && ws !== 'core' && ws !== 'default') {
|
|
92
|
+
fs.copySync(`./src/ws/${ws}`, `${basePath}/src/ws/${ws}`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
{
|
|
99
|
+
for (const client of Object.keys(DefaultConf.client)) {
|
|
100
|
+
const capName = getCapVariableName(client);
|
|
101
|
+
for (const component of Object.keys(DefaultConf.client[client].components)) {
|
|
102
|
+
const originPath = `./src/client/components/${component}`;
|
|
103
|
+
if (fs.existsSync(originPath)) {
|
|
104
|
+
logger.info(`Build`, originPath);
|
|
105
|
+
fs.copySync(originPath, `${basePath}/src/client/components/${component}`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
{
|
|
109
|
+
const originPath = `./src/client/${capName}.index.js`;
|
|
110
|
+
if (fs.existsSync(originPath)) {
|
|
111
|
+
logger.info(`Build`, originPath);
|
|
112
|
+
fs.copyFileSync(originPath, `${basePath}/src/client/${capName}.index.js`);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
{
|
|
116
|
+
const originPath = `./src/client/public/${client}`;
|
|
117
|
+
if (fs.existsSync(originPath)) {
|
|
118
|
+
logger.info(`Build`, originPath);
|
|
119
|
+
fs.copySync(originPath, `${basePath}/src/client/public/${client}`);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
{
|
|
126
|
+
for (const client of Object.keys(DefaultConf.ssr)) {
|
|
127
|
+
const ssrPaths = getPathsSSR(DefaultConf.ssr[client]);
|
|
128
|
+
for (const originPath of ssrPaths) {
|
|
129
|
+
if (fs.existsSync(originPath)) {
|
|
130
|
+
logger.info(`Build`, originPath);
|
|
131
|
+
fs.copySync(originPath, `${basePath}/${originPath}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
|
|
137
|
+
fs.copyFileSync(
|
|
138
|
+
`./.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
|
|
139
|
+
`${basePath}/.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const packageJson = JSON.parse(fs.readFileSync(`${basePath}/package.json`, 'utf8'));
|
|
143
|
+
packageJson.name = repoName;
|
|
144
|
+
fs.writeFileSync(
|
|
145
|
+
`${basePath}/package.json`,
|
|
146
|
+
JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
|
|
147
|
+
'utf8',
|
|
148
|
+
);
|
|
149
|
+
|
|
150
|
+
fs.copySync(`./src/cli`, `${basePath}/src/cli`);
|
|
151
|
+
if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
|
|
152
|
+
|
|
153
|
+
const env = process.argv.includes('development') ? 'development' : 'production';
|
|
154
|
+
const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
|
|
155
|
+
// remove engine-private of .dockerignore for local testing
|
|
156
|
+
for (const file of deploymentsFiles) {
|
|
157
|
+
if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
|
|
158
|
+
fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
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
|
-
|
|
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':
|
package/bin/deploy.js
CHANGED
|
@@ -2,9 +2,8 @@ import fs from 'fs-extra';
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import plantuml from 'plantuml';
|
|
6
5
|
|
|
7
|
-
import { shellCd, shellExec } from '../src/server/process.js';
|
|
6
|
+
import { pbcopy, shellCd, shellExec } from '../src/server/process.js';
|
|
8
7
|
import { loggerFactory } from '../src/server/logger.js';
|
|
9
8
|
import {
|
|
10
9
|
Config,
|
|
@@ -26,10 +25,10 @@ import {
|
|
|
26
25
|
restoreMacroDb,
|
|
27
26
|
fixDependencies,
|
|
28
27
|
setUpProxyMaintenanceServer,
|
|
28
|
+
writeEnv,
|
|
29
29
|
} from '../src/server/conf.js';
|
|
30
30
|
import { buildClient } from '../src/server/client-build.js';
|
|
31
31
|
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
32
|
-
import simpleGit from 'simple-git';
|
|
33
32
|
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
34
33
|
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
35
34
|
import { DefaultConf } from '../conf.js';
|
|
@@ -139,8 +138,7 @@ try {
|
|
|
139
138
|
}
|
|
140
139
|
break;
|
|
141
140
|
case 'conf': {
|
|
142
|
-
loadConf(process.argv[3]);
|
|
143
|
-
if (process.argv[4]) fs.writeFileSync(`.env`, fs.readFileSync(`.env.${process.argv[4]}`, 'utf8'), 'utf8');
|
|
141
|
+
loadConf(process.argv[3], process.argv[4]);
|
|
144
142
|
break;
|
|
145
143
|
}
|
|
146
144
|
case 'run':
|
|
@@ -161,10 +159,6 @@ try {
|
|
|
161
159
|
}
|
|
162
160
|
break;
|
|
163
161
|
|
|
164
|
-
case 'remove-await-deploy': {
|
|
165
|
-
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
166
|
-
break;
|
|
167
|
-
}
|
|
168
162
|
case 'new-nodejs-app':
|
|
169
163
|
{
|
|
170
164
|
const deployId = process.argv[3];
|
|
@@ -231,6 +225,7 @@ try {
|
|
|
231
225
|
break;
|
|
232
226
|
case 'build-full-client':
|
|
233
227
|
{
|
|
228
|
+
dotenv.config({ override: true });
|
|
234
229
|
if (!process.argv[3]) process.argv[3] = 'default';
|
|
235
230
|
const { deployId, folder } = loadConf(process.argv[3]);
|
|
236
231
|
|
|
@@ -256,20 +251,7 @@ try {
|
|
|
256
251
|
serverConf[host][path].replicas.map((replica) => buildReplicaId({ deployId, replica })),
|
|
257
252
|
);
|
|
258
253
|
|
|
259
|
-
shellExec(Cmd.replica(deployId, host, path));
|
|
260
|
-
}
|
|
261
|
-
if (serverConf[host][path].db) {
|
|
262
|
-
switch (serverConf[host][path].db.provider) {
|
|
263
|
-
case 'mariadb':
|
|
264
|
-
{
|
|
265
|
-
shellExec(`node bin/db ${host}${path} create ${deployId}`);
|
|
266
|
-
}
|
|
267
|
-
|
|
268
|
-
break;
|
|
269
|
-
|
|
270
|
-
default:
|
|
271
|
-
break;
|
|
272
|
-
}
|
|
254
|
+
// shellExec(Cmd.replica(deployId, host, path));
|
|
273
255
|
}
|
|
274
256
|
}
|
|
275
257
|
}
|
|
@@ -278,7 +260,7 @@ try {
|
|
|
278
260
|
await buildClient();
|
|
279
261
|
|
|
280
262
|
for (const replicaDeployId of deployIdSingleReplicas) {
|
|
281
|
-
shellExec(Cmd.conf(replicaDeployId));
|
|
263
|
+
shellExec(Cmd.conf(replicaDeployId, process.env.NODE_ENV));
|
|
282
264
|
shellExec(Cmd.build(replicaDeployId));
|
|
283
265
|
}
|
|
284
266
|
}
|
|
@@ -307,7 +289,7 @@ try {
|
|
|
307
289
|
}
|
|
308
290
|
|
|
309
291
|
case 'adminer': {
|
|
310
|
-
const directory = '/dd/engine/public/adminer';
|
|
292
|
+
const directory = '/home/dd/engine/public/adminer';
|
|
311
293
|
// const host = '127.0.0.1';
|
|
312
294
|
const host = 'localhost';
|
|
313
295
|
const port = 80;
|
|
@@ -337,7 +319,7 @@ try {
|
|
|
337
319
|
|
|
338
320
|
case 'pma':
|
|
339
321
|
{
|
|
340
|
-
const directory = '/dd/engine/public/phpmyadmin';
|
|
322
|
+
const directory = '/home/dd/engine/public/phpmyadmin';
|
|
341
323
|
// const host = '127.0.0.1';
|
|
342
324
|
const host = 'localhost';
|
|
343
325
|
const port = 80;
|
|
@@ -454,14 +436,16 @@ try {
|
|
|
454
436
|
}
|
|
455
437
|
break;
|
|
456
438
|
|
|
457
|
-
case 'update-
|
|
439
|
+
case 'update-dependencies':
|
|
458
440
|
const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
|
|
459
441
|
const originPackage = JSON.parse(fs.readFileSync(`./package.json`, 'utf8'));
|
|
460
442
|
for (const relativePath of files) {
|
|
461
443
|
const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
|
|
462
444
|
if (filePah.split('/').pop() === 'package.json') {
|
|
463
|
-
|
|
464
|
-
|
|
445
|
+
const deployPackage = JSON.parse(fs.readFileSync(filePah), 'utf8');
|
|
446
|
+
deployPackage.dependencies = originPackage.dependencies;
|
|
447
|
+
deployPackage.devDependencies = originPackage.devDependencies;
|
|
448
|
+
fs.writeFileSync(filePah, JSON.stringify(deployPackage, null, 4), 'utf8');
|
|
465
449
|
}
|
|
466
450
|
}
|
|
467
451
|
break;
|
|
@@ -546,13 +530,7 @@ try {
|
|
|
546
530
|
? envInstanceObj.port
|
|
547
531
|
: envInstanceObj.port + port - singleReplicaHosts.length - (replicaHost ? 1 : 0);
|
|
548
532
|
|
|
549
|
-
|
|
550
|
-
envPath,
|
|
551
|
-
Object.keys(envObj)
|
|
552
|
-
.map((key) => `${key}=${envObj[key]}`)
|
|
553
|
-
.join(`\n`),
|
|
554
|
-
'utf8',
|
|
555
|
-
);
|
|
533
|
+
writeEnv(envPath, envObj);
|
|
556
534
|
}
|
|
557
535
|
const serverConf = loadReplicas(
|
|
558
536
|
JSON.parse(fs.readFileSync(`${baseConfPath}/${deployId}/conf.server.json`, 'utf8')),
|
|
@@ -596,6 +574,7 @@ try {
|
|
|
596
574
|
}
|
|
597
575
|
case 'build-uml':
|
|
598
576
|
{
|
|
577
|
+
const plantuml = await import('plantuml');
|
|
599
578
|
const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
|
|
600
579
|
const confData = Config.default;
|
|
601
580
|
|
|
@@ -731,6 +710,16 @@ try {
|
|
|
731
710
|
originPackage.version = newVersion;
|
|
732
711
|
fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
|
|
733
712
|
}
|
|
713
|
+
if (filePah.split('/').pop() === 'deployment.yaml') {
|
|
714
|
+
fs.writeFileSync(
|
|
715
|
+
filePah,
|
|
716
|
+
fs
|
|
717
|
+
.readFileSync(filePah, 'utf8')
|
|
718
|
+
.replaceAll(`v${version}`, `v${newVersion}`)
|
|
719
|
+
.replaceAll(`engine.version: ${version}`, `engine.version: ${newVersion}`),
|
|
720
|
+
'utf8',
|
|
721
|
+
);
|
|
722
|
+
}
|
|
734
723
|
}
|
|
735
724
|
}
|
|
736
725
|
|
|
@@ -757,41 +746,32 @@ try {
|
|
|
757
746
|
'utf8',
|
|
758
747
|
);
|
|
759
748
|
|
|
760
|
-
shellExec(`node bin/deploy update-
|
|
749
|
+
shellExec(`node bin/deploy update-dependencies`);
|
|
761
750
|
shellExec(`auto-changelog`);
|
|
762
751
|
}
|
|
763
752
|
break;
|
|
764
753
|
|
|
765
754
|
case 'update-authors': {
|
|
766
|
-
//
|
|
767
|
-
const logs = await simpleGit().log();
|
|
768
|
-
|
|
755
|
+
// #### Ordered by first contribution.
|
|
769
756
|
fs.writeFileSync(
|
|
770
757
|
'./AUTHORS.md',
|
|
771
758
|
`# Authors
|
|
772
759
|
|
|
773
|
-
#### Ordered by first contribution.
|
|
774
760
|
|
|
775
|
-
${
|
|
776
|
-
`)}
|
|
761
|
+
${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).join(`\n\n\n`)}
|
|
777
762
|
|
|
778
763
|
#### Generated by [underpost.net](https://underpost.net)`,
|
|
779
764
|
'utf8',
|
|
780
765
|
);
|
|
781
766
|
|
|
782
|
-
|
|
783
|
-
// date: '2024-09-16T17:10:13-03:00',
|
|
784
|
-
// message: 'update',
|
|
785
|
-
// refs: '',
|
|
786
|
-
// body: '',
|
|
787
|
-
// author_name: 'fcoverdugo',
|
|
788
|
-
// author_email: 'fcoverdugoa@underpost.net'
|
|
767
|
+
break;
|
|
789
768
|
}
|
|
790
769
|
|
|
791
770
|
case 'restore-macro-db':
|
|
792
771
|
{
|
|
793
772
|
const deployGroupId = process.argv[3];
|
|
794
|
-
|
|
773
|
+
const deployId = process.argv[4];
|
|
774
|
+
await restoreMacroDb(deployGroupId, deployId);
|
|
795
775
|
}
|
|
796
776
|
|
|
797
777
|
break;
|
|
@@ -826,10 +806,10 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
826
806
|
shellExec(`bin/besu --help`);
|
|
827
807
|
|
|
828
808
|
// Set env path
|
|
829
|
-
// export PATH=$PATH:/dd/besu-24.9.1/bin
|
|
809
|
+
// export PATH=$PATH:/home/dd/besu-24.9.1/bin
|
|
830
810
|
|
|
831
811
|
// Open src
|
|
832
|
-
// shellExec(`sudo code /dd/besu-24.9.1 --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
812
|
+
// shellExec(`sudo code /home/dd/besu-24.9.1 --user-data-dir="/root/.vscode-root" --no-sandbox`);
|
|
833
813
|
}
|
|
834
814
|
|
|
835
815
|
break;
|
|
@@ -847,23 +827,43 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
847
827
|
}
|
|
848
828
|
|
|
849
829
|
case 'update-default-conf': {
|
|
850
|
-
const
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
`,
|
|
865
|
-
'utf8'
|
|
866
|
-
|
|
830
|
+
const defaultServer = DefaultConf.server['default.net']['/'];
|
|
831
|
+
let confName = process.argv[3];
|
|
832
|
+
if (confName === 'ghpkg') {
|
|
833
|
+
confName = undefined;
|
|
834
|
+
const host = 'underpostnet.github.io';
|
|
835
|
+
const path = '/pwa-microservices-template-ghpkg';
|
|
836
|
+
DefaultConf.server = {
|
|
837
|
+
[host]: { [path]: defaultServer },
|
|
838
|
+
};
|
|
839
|
+
DefaultConf.server[host][path].apiBaseProxyPath = '/';
|
|
840
|
+
DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
|
|
841
|
+
} else if (confName) {
|
|
842
|
+
DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
|
|
843
|
+
DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
|
|
844
|
+
DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
|
|
845
|
+
DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
|
|
846
|
+
|
|
847
|
+
for (const host of Object.keys(DefaultConf.server)) {
|
|
848
|
+
for (const path of Object.keys(DefaultConf.server[host])) {
|
|
849
|
+
DefaultConf.server[host][path].db = defaultServer.db;
|
|
850
|
+
DefaultConf.server[host][path].mailer = defaultServer.mailer;
|
|
851
|
+
|
|
852
|
+
delete DefaultConf.server[host][path]._wp_client;
|
|
853
|
+
delete DefaultConf.server[host][path]._wp_git;
|
|
854
|
+
delete DefaultConf.server[host][path]._wp_directory;
|
|
855
|
+
delete DefaultConf.server[host][path].wp;
|
|
856
|
+
delete DefaultConf.server[host][path].git;
|
|
857
|
+
delete DefaultConf.server[host][path].directory;
|
|
858
|
+
}
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
const sepRender = '/**/';
|
|
862
|
+
const confRawPaths = fs.readFileSync('./conf.js', 'utf8').split(sepRender);
|
|
863
|
+
confRawPaths[1] = `${JSON.stringify(DefaultConf)};`;
|
|
864
|
+
const targetConfPath = `./conf${confName ? `.${confName}` : ''}.js`;
|
|
865
|
+
fs.writeFileSync(targetConfPath, confRawPaths.join(sepRender), 'utf8');
|
|
866
|
+
shellExec(`prettier --write ${targetConfPath}`);
|
|
867
867
|
|
|
868
868
|
break;
|
|
869
869
|
}
|
|
@@ -879,7 +879,11 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
879
879
|
}
|
|
880
880
|
case 'ssh-import-client-keys': {
|
|
881
881
|
const host = process.argv[3];
|
|
882
|
-
shellExec(
|
|
882
|
+
shellExec(
|
|
883
|
+
`node bin/deploy set-ssh-keys ./engine-private/deploy/ssh_host_rsa_key ${host ? ` ${host}` : ``} ${
|
|
884
|
+
process.argv.includes('clean') ? 'clean' : ''
|
|
885
|
+
}`,
|
|
886
|
+
);
|
|
883
887
|
break;
|
|
884
888
|
}
|
|
885
889
|
case 'ssh-keys': {
|
|
@@ -944,14 +948,24 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
944
948
|
}
|
|
945
949
|
|
|
946
950
|
case 'ssh': {
|
|
947
|
-
if (
|
|
948
|
-
shellExec(`sudo
|
|
949
|
-
|
|
950
|
-
shellExec(`sudo
|
|
951
|
+
if (process.argv.includes('rocky')) {
|
|
952
|
+
shellExec(`sudo systemctl enable sshd`);
|
|
953
|
+
|
|
954
|
+
shellExec(`sudo systemctl start sshd`);
|
|
955
|
+
|
|
956
|
+
shellExec(`sudo systemctl status sshd`);
|
|
957
|
+
|
|
958
|
+
shellExec(`sudo ss -lt`);
|
|
959
|
+
} else {
|
|
960
|
+
if (!process.argv.includes('server')) {
|
|
961
|
+
shellExec(`sudo apt update`);
|
|
962
|
+
shellExec(`sudo apt install openssh-server -y`);
|
|
963
|
+
shellExec(`sudo apt install ssh-askpass`);
|
|
964
|
+
}
|
|
965
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
966
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
967
|
+
shellExec(`sudo systemctl status ssh`);
|
|
951
968
|
}
|
|
952
|
-
shellExec(`sudo systemctl enable ssh`);
|
|
953
|
-
shellExec(`sudo systemctl restart ssh`);
|
|
954
|
-
shellExec(`sudo systemctl status ssh`);
|
|
955
969
|
// sudo service ssh restart
|
|
956
970
|
shellExec(`ip a`);
|
|
957
971
|
|
|
@@ -1009,11 +1023,26 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
1009
1023
|
|
|
1010
1024
|
case 'valkey': {
|
|
1011
1025
|
if (!process.argv.includes('server')) {
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1026
|
+
if (process.argv.includes('rocky')) {
|
|
1027
|
+
// shellExec(`yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm`);
|
|
1028
|
+
// shellExec(`sudo percona-release enable valkey experimental`);
|
|
1029
|
+
shellExec(`sudo dnf install valkey`);
|
|
1030
|
+
shellExec(`chown -R valkey:valkey /etc/valkey`);
|
|
1031
|
+
shellExec(`chown -R valkey:valkey /var/lib/valkey`);
|
|
1032
|
+
shellExec(`chown -R valkey:valkey /var/log/valkey`);
|
|
1033
|
+
shellExec(`sudo systemctl enable valkey.service`);
|
|
1034
|
+
shellExec(`sudo systemctl start valkey`);
|
|
1035
|
+
shellExec(`valkey-cli ping`);
|
|
1036
|
+
} else {
|
|
1037
|
+
shellExec(`cd /home/dd && git clone https://github.com/valkey-io/valkey.git`);
|
|
1038
|
+
shellExec(`cd /home/dd/valkey && make`);
|
|
1039
|
+
shellExec(`apt install valkey-tools`); // valkey-cli
|
|
1040
|
+
}
|
|
1015
1041
|
}
|
|
1016
|
-
|
|
1042
|
+
if (process.argv.includes('rocky')) {
|
|
1043
|
+
shellExec(`sudo systemctl stop valkey`);
|
|
1044
|
+
shellExec(`sudo systemctl start valkey`);
|
|
1045
|
+
} else shellExec(`cd /home/dd/valkey && ./src/valkey-server`);
|
|
1017
1046
|
|
|
1018
1047
|
break;
|
|
1019
1048
|
}
|