underpost 2.8.45 → 2.8.46
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/.github/workflows/ghpkg.yml +13 -46
- package/.github/workflows/npmpkg.yml +67 -0
- package/.github/workflows/publish.yml +5 -5
- package/.github/workflows/pwa-microservices-template.page.yml +3 -2
- package/.github/workflows/pwa-microservices-template.test.yml +2 -2
- package/bin/build.js +9 -3
- package/bin/deploy.js +1 -14
- package/bin/file.js +4 -0
- package/bin/index.js +18 -0
- package/docker-compose.yml +1 -1
- package/package.json +17 -3
- package/src/cli/cluster.js +2 -2
- package/src/cli/db.js +98 -0
- package/src/cli/image.js +1 -1
- package/src/cli/repository.js +6 -6
- package/src/client/components/core/Auth.js +22 -4
- package/src/client/components/core/Translate.js +4 -0
- package/src/index.js +9 -1
- package/src/server/conf.js +4 -2
- package/src/server/logger.js +1 -0
- package/src/server/network.js +1 -1
|
@@ -9,47 +9,6 @@ permissions:
|
|
|
9
9
|
packages: write
|
|
10
10
|
id-token: write
|
|
11
11
|
jobs:
|
|
12
|
-
pwa-microservices-template:
|
|
13
|
-
if: github.repository == 'underpostnet/engine' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template)')
|
|
14
|
-
name: Update github repo package Jobs
|
|
15
|
-
runs-on: ubuntu-latest
|
|
16
|
-
permissions:
|
|
17
|
-
contents: write
|
|
18
|
-
packages: write
|
|
19
|
-
id-token: write
|
|
20
|
-
steps:
|
|
21
|
-
- uses: actions/checkout@v3
|
|
22
|
-
|
|
23
|
-
- uses: actions/setup-node@v4
|
|
24
|
-
with:
|
|
25
|
-
node-version: '22.x'
|
|
26
|
-
|
|
27
|
-
- name: Install dependencies
|
|
28
|
-
run: |
|
|
29
|
-
npm install
|
|
30
|
-
|
|
31
|
-
- name: Set git credentials
|
|
32
|
-
run: |
|
|
33
|
-
git config --global credential.helper ""
|
|
34
|
-
git config credential.helper ""
|
|
35
|
-
git config --global user.name 'underpostnet'
|
|
36
|
-
git config --global user.email 'development@underpost.net'
|
|
37
|
-
git config --global credential.interactive always
|
|
38
|
-
git config user.name 'underpostnet'
|
|
39
|
-
git config user.email 'development@underpost.net'
|
|
40
|
-
git config credential.interactive always
|
|
41
|
-
|
|
42
|
-
- name: Clone github package repository
|
|
43
|
-
run: |
|
|
44
|
-
cd .. && git clone https://github.com/underpostnet/pwa-microservices-template.git
|
|
45
|
-
cd engine
|
|
46
|
-
npm run update-template
|
|
47
|
-
cd ../pwa-microservices-template
|
|
48
|
-
git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
|
|
49
|
-
git add .
|
|
50
|
-
git commit -m "ci(package-pwa-microservices-template-ghpkg): ⚙️ Update github repo package"
|
|
51
|
-
git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template.git
|
|
52
|
-
|
|
53
12
|
pwa-microservices-template-ghpk:
|
|
54
13
|
if: github.repository == 'underpostnet/pwa-microservices-template' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template-ghpkg)')
|
|
55
14
|
name: Update github repo package Jobs
|
|
@@ -63,7 +22,7 @@ jobs:
|
|
|
63
22
|
|
|
64
23
|
- uses: actions/setup-node@v4
|
|
65
24
|
with:
|
|
66
|
-
node-version: '
|
|
25
|
+
node-version: '23.x'
|
|
67
26
|
|
|
68
27
|
# - name: Get npm root
|
|
69
28
|
# run: sudo npm root -g
|
|
@@ -82,13 +41,15 @@ jobs:
|
|
|
82
41
|
|
|
83
42
|
- name: Install dependencies and set repo configuration
|
|
84
43
|
run: |
|
|
85
|
-
npm install
|
|
44
|
+
npm install -g underpost
|
|
45
|
+
underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }}
|
|
46
|
+
underpost install
|
|
86
47
|
node ./bin/deploy rename-package @underpostnet/underpost
|
|
87
48
|
node ./bin/deploy set-repo underpostnet/pwa-microservices-template-ghpkg
|
|
88
49
|
|
|
89
50
|
- name: Clone github package repository
|
|
90
51
|
run: |
|
|
91
|
-
|
|
52
|
+
underpost clone --bare underpostnet/pwa-microservices-template-ghpkg
|
|
92
53
|
rm -rf ./.git
|
|
93
54
|
cp -rf -a ./pwa-microservices-template-ghpkg.git ./.git
|
|
94
55
|
rm -rf ./pwa-microservices-template-ghpkg.git
|
|
@@ -111,8 +72,14 @@ jobs:
|
|
|
111
72
|
git status
|
|
112
73
|
git remote set-url origin git@github.com:underpostnet/pwa-microservices-template-ghpkg.git
|
|
113
74
|
git add .
|
|
114
|
-
|
|
115
|
-
|
|
75
|
+
underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update github repo package'
|
|
76
|
+
underpost push . underpostnet/pwa-microservices-template-ghpkg
|
|
77
|
+
|
|
78
|
+
# git clone --bare https://github.com/underpostnet/engine.git
|
|
79
|
+
# mkdir engine
|
|
80
|
+
# mv ./engine.git ./engine/.git
|
|
81
|
+
# cd engine
|
|
82
|
+
# git init
|
|
116
83
|
|
|
117
84
|
# git push -u origin https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template-ghpkg.git
|
|
118
85
|
# git push -u origin master
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Update npm repo package
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches: ['master']
|
|
5
|
+
pull_request:
|
|
6
|
+
branches: ['master']
|
|
7
|
+
permissions:
|
|
8
|
+
contents: write
|
|
9
|
+
packages: write
|
|
10
|
+
id-token: write
|
|
11
|
+
jobs:
|
|
12
|
+
pwa-microservices-template:
|
|
13
|
+
if: github.repository == 'underpostnet/engine' && startsWith(github.event.head_commit.message, 'ci(package-pwa-microservices-template)')
|
|
14
|
+
name: Update npm repo package Jobs
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
permissions:
|
|
17
|
+
contents: write
|
|
18
|
+
packages: write
|
|
19
|
+
id-token: write
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v3
|
|
22
|
+
|
|
23
|
+
- uses: actions/setup-node@v4
|
|
24
|
+
with:
|
|
25
|
+
node-version: '23.x'
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: |
|
|
29
|
+
npm install -g underpost
|
|
30
|
+
underpost config set GITHUB_TOKEN ${{ secrets.GIT_AUTH_TOKEN }}
|
|
31
|
+
underpost install
|
|
32
|
+
|
|
33
|
+
- name: Set git credentials
|
|
34
|
+
run: |
|
|
35
|
+
git config --global credential.helper ""
|
|
36
|
+
git config credential.helper ""
|
|
37
|
+
git config --global user.name 'underpostnet'
|
|
38
|
+
git config --global user.email 'development@underpost.net'
|
|
39
|
+
git config --global credential.interactive always
|
|
40
|
+
git config user.name 'underpostnet'
|
|
41
|
+
git config user.email 'development@underpost.net'
|
|
42
|
+
git config credential.interactive always
|
|
43
|
+
|
|
44
|
+
- name: Clone github package repository
|
|
45
|
+
run: |
|
|
46
|
+
cd .. && underpost clone underpostnet/pwa-microservices-template
|
|
47
|
+
cd engine
|
|
48
|
+
npm run update-template
|
|
49
|
+
cd ../pwa-microservices-template
|
|
50
|
+
git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
|
|
51
|
+
git add .
|
|
52
|
+
underpost cmt . ci package-pwa-microservices-template-ghpkg 'Update npm repo package'
|
|
53
|
+
underpost push . underpostnet/pwa-microservices-template
|
|
54
|
+
# cd ../engine
|
|
55
|
+
# git commit --allow-empty -m "ci(engine-core-repo-build): ⚙️ Update engine core repository"
|
|
56
|
+
# git commit --allow-empty -m "ci(engine-cyberia-repo-build): ⚙️ Update engine cyberia repository"
|
|
57
|
+
# git commit --allow-empty -m "ci(engine-lampp-repo-build): ⚙️ Update engine lampp repository"
|
|
58
|
+
# git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/engine.git
|
|
59
|
+
|
|
60
|
+
# git clone --bare https://github.com/underpostnet/engine.git
|
|
61
|
+
# mkdir engine
|
|
62
|
+
# mv ./engine.git ./engine/.git
|
|
63
|
+
# cd engine
|
|
64
|
+
# git init
|
|
65
|
+
|
|
66
|
+
# git push -u origin https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template-ghpkg.git
|
|
67
|
+
# git push -u origin master
|
|
@@ -14,7 +14,7 @@ jobs:
|
|
|
14
14
|
- uses: actions/checkout@v4
|
|
15
15
|
- uses: actions/setup-node@v4
|
|
16
16
|
with:
|
|
17
|
-
node-version: '
|
|
17
|
+
node-version: '23.x'
|
|
18
18
|
registry-url: 'https://registry.npmjs.org'
|
|
19
19
|
|
|
20
20
|
- name: Install Dependencies
|
|
@@ -25,7 +25,7 @@ jobs:
|
|
|
25
25
|
# Publish to npm
|
|
26
26
|
- uses: actions/setup-node@v4
|
|
27
27
|
with:
|
|
28
|
-
node-version: '
|
|
28
|
+
node-version: '23.x'
|
|
29
29
|
registry-url: 'https://registry.npmjs.org'
|
|
30
30
|
# Defaults to the user or organization that owns the workflow file
|
|
31
31
|
# scope: '@underpostnet'
|
|
@@ -45,7 +45,7 @@ jobs:
|
|
|
45
45
|
- uses: actions/checkout@v4
|
|
46
46
|
- uses: actions/setup-node@v4
|
|
47
47
|
with:
|
|
48
|
-
node-version: '
|
|
48
|
+
node-version: '23.x'
|
|
49
49
|
registry-url: 'https://registry.npmjs.org'
|
|
50
50
|
|
|
51
51
|
- name: Install Dependencies
|
|
@@ -56,7 +56,7 @@ jobs:
|
|
|
56
56
|
# Publish to npm git hub package
|
|
57
57
|
- uses: actions/setup-node@v4
|
|
58
58
|
with:
|
|
59
|
-
node-version: '
|
|
59
|
+
node-version: '23.x'
|
|
60
60
|
registry-url: 'https://registry.npmjs.org'
|
|
61
61
|
# Defaults to the user or organization that owns the workflow file
|
|
62
62
|
scope: '@underpostnet'
|
|
@@ -70,7 +70,7 @@ jobs:
|
|
|
70
70
|
- name: Setup node to publish to GitHub Packages
|
|
71
71
|
uses: actions/setup-node@v4
|
|
72
72
|
with:
|
|
73
|
-
node-version:
|
|
73
|
+
node-version: 23.x
|
|
74
74
|
registry-url: 'https://npm.pkg.github.com'
|
|
75
75
|
# Defaults to the user or organization that owns the workflow file
|
|
76
76
|
scope: '@underpostnet'
|
|
@@ -38,11 +38,12 @@ jobs:
|
|
|
38
38
|
# run: git lfs checkout
|
|
39
39
|
- uses: actions/setup-node@v4
|
|
40
40
|
with:
|
|
41
|
-
node-version: '
|
|
41
|
+
node-version: '23.x'
|
|
42
42
|
|
|
43
43
|
- name: Build the site
|
|
44
44
|
run: |
|
|
45
|
-
npm install
|
|
45
|
+
npm install -g underpost
|
|
46
|
+
underpost install
|
|
46
47
|
node bin/deploy update-default-conf ghpkg
|
|
47
48
|
env-cmd -f .env.production node bin/deploy build-full-client github-pages underpostnet.github.io /pwa-microservices-template-ghpkg
|
|
48
49
|
# git lfs install
|
|
@@ -2,12 +2,12 @@ name: Test
|
|
|
2
2
|
on: [push]
|
|
3
3
|
jobs:
|
|
4
4
|
test:
|
|
5
|
-
if: (github.repository == 'underpostnet/pwa-microservices-template') || (github.repository == 'underpostnet/pwa-microservices-template-ghpkg')
|
|
5
|
+
# if: (github.repository == 'underpostnet/pwa-microservices-template') || (github.repository == 'underpostnet/pwa-microservices-template-ghpkg')
|
|
6
6
|
name: Node ${{ matrix.node }} on ${{ matrix.os }}
|
|
7
7
|
runs-on: ${{ matrix.os }}
|
|
8
8
|
strategy:
|
|
9
9
|
matrix:
|
|
10
|
-
node-version: [
|
|
10
|
+
node-version: [23.x]
|
|
11
11
|
os: [ubuntu-latest]
|
|
12
12
|
# os: [ubuntu-latest, windows-latest]
|
|
13
13
|
|
package/bin/build.js
CHANGED
|
@@ -292,16 +292,16 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
|
292
292
|
if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
|
|
293
293
|
|
|
294
294
|
const env = process.argv.includes('development') ? 'development' : 'production';
|
|
295
|
-
|
|
295
|
+
const deploymentsFiles = ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml'];
|
|
296
296
|
// remove engine-private of .dockerignore for local testing
|
|
297
297
|
|
|
298
|
-
{
|
|
298
|
+
if (process.argv.includes('engine')) {
|
|
299
299
|
fs.removeSync(`${basePath}/manifests/deployment`);
|
|
300
300
|
|
|
301
301
|
if (!fs.existsSync(`./manifests/deployment/${confName}-${env}`))
|
|
302
302
|
fs.mkdirSync(`./manifests/deployment/${confName}-${env}`);
|
|
303
303
|
|
|
304
|
-
for (const file of
|
|
304
|
+
for (const file of deploymentsFiles) {
|
|
305
305
|
if (fs.existsSync(`./engine-private/conf/${confName}/build/${env}/${file}`)) {
|
|
306
306
|
fs.copyFileSync(`./engine-private/conf/${confName}/build/${env}/${file}`, `${basePath}/${file}`);
|
|
307
307
|
fs.copyFileSync(
|
|
@@ -310,5 +310,11 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
|
310
310
|
);
|
|
311
311
|
}
|
|
312
312
|
}
|
|
313
|
+
} else {
|
|
314
|
+
for (const file of deploymentsFiles) {
|
|
315
|
+
if (fs.existsSync(`./manifests/deployment/${confName}-${env}/${file}`)) {
|
|
316
|
+
fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
313
319
|
}
|
|
314
320
|
}
|
package/bin/deploy.js
CHANGED
|
@@ -2,7 +2,6 @@ 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
6
|
import { pbcopy, shellCd, shellExec } from '../src/server/process.js';
|
|
8
7
|
import { loggerFactory } from '../src/server/logger.js';
|
|
@@ -257,19 +256,6 @@ try {
|
|
|
257
256
|
|
|
258
257
|
shellExec(Cmd.replica(deployId, host, path));
|
|
259
258
|
}
|
|
260
|
-
if (serverConf[host][path].db) {
|
|
261
|
-
switch (serverConf[host][path].db.provider) {
|
|
262
|
-
case 'mariadb':
|
|
263
|
-
{
|
|
264
|
-
shellExec(`node bin/db ${host}${path} create ${deployId}`);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
break;
|
|
268
|
-
|
|
269
|
-
default:
|
|
270
|
-
break;
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
259
|
}
|
|
274
260
|
}
|
|
275
261
|
}
|
|
@@ -591,6 +577,7 @@ try {
|
|
|
591
577
|
}
|
|
592
578
|
case 'build-uml':
|
|
593
579
|
{
|
|
580
|
+
const plantuml = await import('plantuml');
|
|
594
581
|
const folder = process.argv[3] ? process.argv[3] : `./src/client/public/default/plantuml`;
|
|
595
582
|
const confData = Config.default;
|
|
596
583
|
|
package/bin/file.js
CHANGED
|
@@ -80,6 +80,7 @@ try {
|
|
|
80
80
|
'.github/workflows/engine.lampp.ci.yml',
|
|
81
81
|
'.github/workflows/engine.core.ci.yml',
|
|
82
82
|
'.github/workflows/engine.cyberia.ci.yml',
|
|
83
|
+
'./manifests/deployment/dd-lampp-development',
|
|
83
84
|
'bin/web3.js',
|
|
84
85
|
'bin/cyberia.js',
|
|
85
86
|
]) {
|
|
@@ -101,6 +102,9 @@ try {
|
|
|
101
102
|
templatePackageJson.description = description;
|
|
102
103
|
templatePackageJson.scripts.dev = dev;
|
|
103
104
|
templatePackageJson.scripts.build = build;
|
|
105
|
+
templatePackageJson.keywords = ['pwa', 'microservices', 'template', 'builder'].concat(
|
|
106
|
+
templatePackageJson.keywords,
|
|
107
|
+
);
|
|
104
108
|
delete templatePackageJson.scripts['update-template'];
|
|
105
109
|
fs.writeFileSync(
|
|
106
110
|
'../pwa-microservices-template/package.json',
|
package/bin/index.js
CHANGED
|
@@ -8,6 +8,8 @@ import { getNpmRootPath, loadConf } from '../src/server/conf.js';
|
|
|
8
8
|
import fs from 'fs-extra';
|
|
9
9
|
import { commitData } from '../src/client/components/core/CommonJs.js';
|
|
10
10
|
import UnderpostScript from '../src/cli/script.js';
|
|
11
|
+
import { shellExec } from '../src/server/process.js';
|
|
12
|
+
import UnderpostDB from '../src/cli/db.js';
|
|
11
13
|
|
|
12
14
|
const npmRoot = getNpmRootPath();
|
|
13
15
|
const underpostRoot = `${npmRoot}/underpost/.env`;
|
|
@@ -28,6 +30,7 @@ program
|
|
|
28
30
|
program
|
|
29
31
|
.command('clone')
|
|
30
32
|
.argument(`<uri>`, 'e.g. username/repository')
|
|
33
|
+
.option('--bare', 'Clone only .git files')
|
|
31
34
|
.description('Clone github repository')
|
|
32
35
|
.action(Underpost.repo.clone);
|
|
33
36
|
|
|
@@ -130,6 +133,21 @@ program
|
|
|
130
133
|
.description('Pull underpost dockerfile images requirements')
|
|
131
134
|
.action(Underpost.image.dockerfile.pullBaseImages);
|
|
132
135
|
|
|
136
|
+
program
|
|
137
|
+
.command('install')
|
|
138
|
+
.description('Fast import underpost npm dependencies')
|
|
139
|
+
.action(() => {
|
|
140
|
+
fs.copySync(`${npmRoot}/underpost/node_modules`, './node_modules');
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
program
|
|
144
|
+
.command('db')
|
|
145
|
+
.option('--import <deploy-id-list>', 'Import databases to containers from deploy id list, e.g. default-a, default-b')
|
|
146
|
+
.description('Manage databases')
|
|
147
|
+
.action((...args) => {
|
|
148
|
+
if (args && args[0].import) return UnderpostDB.API.import(...args);
|
|
149
|
+
});
|
|
150
|
+
|
|
133
151
|
program
|
|
134
152
|
.command('script')
|
|
135
153
|
.argument('operator', `Options: ${Object.keys(UnderpostScript.API)}`)
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.46",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
"docs": "jsdoc -c jsdoc.json",
|
|
17
17
|
"install-global": "npm install -g pm2 && npm install -g jsdoc && npm install -g prettier && npm install -g env-cmd && npm install -g yarn && npm install -g auto-changelog",
|
|
18
18
|
"install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
|
|
19
|
+
"install-underpost": "cp -a $(npm root -g)/underpost/node_modules ./node_modules && npm install --only=dev --ignore-scripts",
|
|
19
20
|
"install": "npm run install-global && npm run install-test",
|
|
20
21
|
"docker:start": "docker-compose up",
|
|
21
22
|
"prettier": "prettier --write .",
|
|
@@ -31,6 +32,14 @@
|
|
|
31
32
|
"url": "git+https://github.com/underpostnet/pwa-microservices-template.git"
|
|
32
33
|
},
|
|
33
34
|
"keywords": [
|
|
35
|
+
"pwa",
|
|
36
|
+
"microservices",
|
|
37
|
+
"template",
|
|
38
|
+
"builder",
|
|
39
|
+
"pwa",
|
|
40
|
+
"microservices",
|
|
41
|
+
"template",
|
|
42
|
+
"builder",
|
|
34
43
|
"engine",
|
|
35
44
|
"server",
|
|
36
45
|
"proxy",
|
|
@@ -105,12 +114,17 @@
|
|
|
105
114
|
"uglify-js": "^3.17.4",
|
|
106
115
|
"validator": "^13.11.0",
|
|
107
116
|
"vanilla-jsoneditor": "^2.3.2",
|
|
108
|
-
"winston": "^3.11.0"
|
|
117
|
+
"winston": "^3.11.0",
|
|
118
|
+
"clean-jsdoc-theme": "^4.3.0",
|
|
119
|
+
"easy-json-schema": "^0.0.2-beta",
|
|
120
|
+
"mocha": "^10.8.2",
|
|
121
|
+
"plantuml": "^0.0.2",
|
|
122
|
+
"swagger-autogen": "^2.23.7"
|
|
109
123
|
},
|
|
110
124
|
"devDependencies": {
|
|
111
125
|
"clean-jsdoc-theme": "^4.3.0",
|
|
112
126
|
"easy-json-schema": "^0.0.2-beta",
|
|
113
|
-
"mocha": "^10.
|
|
127
|
+
"mocha": "^10.8.2",
|
|
114
128
|
"plantuml": "^0.0.2",
|
|
115
129
|
"swagger-autogen": "^2.23.7"
|
|
116
130
|
},
|
package/src/cli/cluster.js
CHANGED
|
@@ -93,7 +93,7 @@ class UnderpostCluster {
|
|
|
93
93
|
silent: true,
|
|
94
94
|
stdout: true,
|
|
95
95
|
disableLog: true,
|
|
96
|
-
}).match(`mongodb-
|
|
96
|
+
}).match(`mongodb-1 1/1 Running`)
|
|
97
97
|
)
|
|
98
98
|
return resolve();
|
|
99
99
|
return monitor();
|
|
@@ -110,7 +110,7 @@ class UnderpostCluster {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
shellExec(
|
|
113
|
-
`kubectl exec -i mongodb-0 -- mongosh --quiet --json=relaxed \
|
|
113
|
+
`sudo kubectl exec -i mongodb-0 -- mongosh --quiet --json=relaxed \
|
|
114
114
|
--eval 'use admin' \
|
|
115
115
|
--eval 'rs.initiate(${JSON.stringify(mongoConfig)})' \
|
|
116
116
|
--eval 'rs.status()'`,
|
package/src/cli/db.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { mergeFile } from '../server/conf.js';
|
|
2
|
+
import { loggerFactory } from '../server/logger.js';
|
|
3
|
+
import { shellExec } from '../server/process.js';
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
|
|
6
|
+
const logger = loggerFactory(import.meta);
|
|
7
|
+
|
|
8
|
+
class UnderpostDB {
|
|
9
|
+
static API = {
|
|
10
|
+
async import(options = { import: 'default' }) {
|
|
11
|
+
for (const _deployId of options.import.split(',')) {
|
|
12
|
+
const deployId = _deployId.trim();
|
|
13
|
+
if (!deployId) continue;
|
|
14
|
+
const dbs = {};
|
|
15
|
+
const repoName = `engine-${deployId.split('dd-')[1]}-cron-backups`;
|
|
16
|
+
|
|
17
|
+
const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'));
|
|
18
|
+
for (const host of Object.keys(confServer)) {
|
|
19
|
+
for (const path of Object.keys(confServer[host])) {
|
|
20
|
+
const { db } = confServer[host][path];
|
|
21
|
+
if (db) {
|
|
22
|
+
const { provider, name, user, password } = db;
|
|
23
|
+
if (!dbs[provider]) dbs[provider] = {};
|
|
24
|
+
|
|
25
|
+
if (!(name in dbs[provider]))
|
|
26
|
+
dbs[provider][name] = { user, password, hostFolder: host + path.replaceAll('/', '-') };
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (!fs.existsSync(`../${repoName}`)) {
|
|
32
|
+
shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}`);
|
|
33
|
+
} else {
|
|
34
|
+
shellExec(`cd ../${repoName} && underpost pull . ${process.env.GITHUB_USERNAME}/${repoName}`);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
for (const provider of Object.keys(dbs)) {
|
|
38
|
+
for (const dbName of Object.keys(dbs[provider])) {
|
|
39
|
+
const { hostFolder, user, password } = dbs[provider][dbName];
|
|
40
|
+
if (hostFolder) {
|
|
41
|
+
logger.info('import', { hostFolder, provider, dbName });
|
|
42
|
+
|
|
43
|
+
const backUpPath = `../${repoName}/${hostFolder}`;
|
|
44
|
+
const times = await fs.readdir(backUpPath);
|
|
45
|
+
const currentBackupTimestamp = Math.max(...times.map((t) => parseInt(t)));
|
|
46
|
+
dbs[provider][dbName].currentBackupTimestamp = currentBackupTimestamp;
|
|
47
|
+
|
|
48
|
+
const _fromPartsParts = `../${repoName}/${hostFolder}/${currentBackupTimestamp}/${dbName}-parths.json`;
|
|
49
|
+
const _toSqlPath = `../${repoName}/${hostFolder}/${currentBackupTimestamp}/${dbName}.sql`;
|
|
50
|
+
const _toBsonPath = `../${repoName}/${hostFolder}/${currentBackupTimestamp}/${dbName}`;
|
|
51
|
+
|
|
52
|
+
if (fs.existsSync(_fromPartsParts) && !fs.existsSync(_toSqlPath)) {
|
|
53
|
+
const names = JSON.parse(fs.readFileSync(_fromPartsParts, 'utf8')).map((_path) => {
|
|
54
|
+
return `../${repoName}/${hostFolder}/${currentBackupTimestamp}/${_path.split('/').pop()}`;
|
|
55
|
+
});
|
|
56
|
+
logger.info('merge Back Up paths', {
|
|
57
|
+
_fromPartsParts,
|
|
58
|
+
_toSqlPath,
|
|
59
|
+
names,
|
|
60
|
+
});
|
|
61
|
+
await mergeFile(names, _toSqlPath);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
switch (provider) {
|
|
65
|
+
case 'mariadb': {
|
|
66
|
+
const podName = `mariadb-statefulset-0`;
|
|
67
|
+
const nameSpace = 'default';
|
|
68
|
+
const serviceName = 'mariadb';
|
|
69
|
+
shellExec(`sudo kubectl cp ${_toSqlPath} ${nameSpace}/${podName}:/${dbName}.sql`);
|
|
70
|
+
const cmd = `mariadb -u ${user} -p${password} ${dbName} < /${dbName}.sql`;
|
|
71
|
+
shellExec(
|
|
72
|
+
`kubectl exec -i ${podName} -- ${serviceName} -p${password} -e 'CREATE DATABASE ${dbName};'`,
|
|
73
|
+
);
|
|
74
|
+
shellExec(`sudo kubectl exec -i ${podName} -- sh -c "${cmd}"`);
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
case 'mongoose': {
|
|
79
|
+
const podName = `mongodb-0`;
|
|
80
|
+
const nameSpace = 'default';
|
|
81
|
+
shellExec(`sudo kubectl cp ${_toBsonPath} ${nameSpace}/${podName}:/${dbName}`);
|
|
82
|
+
const cmd = `mongorestore -d ${dbName} /${dbName}`;
|
|
83
|
+
shellExec(`sudo kubectl exec -i ${podName} -- sh -c "${cmd}"`);
|
|
84
|
+
break;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
default:
|
|
88
|
+
break;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export default UnderpostDB;
|
package/src/cli/image.js
CHANGED
|
@@ -19,7 +19,7 @@ class UnderpostImage {
|
|
|
19
19
|
const imagesStoragePath = `./images`;
|
|
20
20
|
const tarFile = `${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
|
|
21
21
|
|
|
22
|
-
let secrets = '';
|
|
22
|
+
let secrets = ' ';
|
|
23
23
|
let secretDockerInput = '';
|
|
24
24
|
|
|
25
25
|
const envObj = dotenv.parse(fs.readFileSync(`${getNpmRootPath()}/underpost/.env`, 'utf8'));
|
package/src/cli/repository.js
CHANGED
|
@@ -11,11 +11,13 @@ const logger = loggerFactory(import.meta);
|
|
|
11
11
|
|
|
12
12
|
class UnderpostRepository {
|
|
13
13
|
static API = {
|
|
14
|
-
clone(gitUri = 'underpostnet/pwa-microservices-template') {
|
|
14
|
+
clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false }) {
|
|
15
15
|
const repoName = gitUri.split('/').pop();
|
|
16
16
|
if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
|
|
17
17
|
return shellExec(
|
|
18
|
-
`git clone
|
|
18
|
+
`git clone ${options?.bare === true ? ` --bare ` : ''}https://${
|
|
19
|
+
process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
|
|
20
|
+
}github.com/${gitUri}.git`,
|
|
19
21
|
{
|
|
20
22
|
disableLog: true,
|
|
21
23
|
},
|
|
@@ -81,18 +83,16 @@ class UnderpostRepository {
|
|
|
81
83
|
return new Promise(async (resolve, reject) => {
|
|
82
84
|
try {
|
|
83
85
|
const exeRootPath = `${getNpmRootPath()}/underpost`;
|
|
84
|
-
// const exeRootPath = '/home/dd/pwa-microservices-template';
|
|
85
86
|
actionInitLog();
|
|
86
87
|
await logger.setUpInfo();
|
|
87
|
-
const destFolder =
|
|
88
|
+
const destFolder = `./${repositoryName}`;
|
|
88
89
|
logger.info('Note: This process may take several minutes to complete');
|
|
89
90
|
logger.info('build app', { destFolder });
|
|
91
|
+
if (fs.existsSync(destFolder)) fs.removeSync(destFolder);
|
|
90
92
|
fs.mkdirSync(destFolder, { recursive: true });
|
|
91
93
|
fs.copySync(exeRootPath, destFolder);
|
|
92
|
-
if (fs.existsSync(`${destFolder}/node_modules`)) fs.removeSync(`${destFolder}/node_modules`);
|
|
93
94
|
fs.writeFileSync(`${destFolder}/.gitignore`, fs.readFileSync(`${exeRootPath}/.dockerignore`, 'utf8'), 'utf8');
|
|
94
95
|
shellExec(`cd ${destFolder} && git init && git add . && git commit -m "Base template implementation"`);
|
|
95
|
-
shellExec(`cd ${destFolder} && npm install`);
|
|
96
96
|
shellExec(`cd ${destFolder} && npm run build`);
|
|
97
97
|
shellExec(`cd ${destFolder} && npm run dev`);
|
|
98
98
|
return resolve();
|
|
@@ -3,7 +3,10 @@ import { Account } from './Account.js';
|
|
|
3
3
|
import { loggerFactory } from './Logger.js';
|
|
4
4
|
import { LogIn } from './LogIn.js';
|
|
5
5
|
import { LogOut } from './LogOut.js';
|
|
6
|
+
import { NotificationManager } from './NotificationManager.js';
|
|
6
7
|
import { SignUp } from './SignUp.js';
|
|
8
|
+
import { Translate } from './Translate.js';
|
|
9
|
+
import { s } from './VanillaJs.js';
|
|
7
10
|
|
|
8
11
|
const logger = loggerFactory(import.meta);
|
|
9
12
|
|
|
@@ -65,6 +68,7 @@ const Auth = {
|
|
|
65
68
|
const _result = await UserService.get({ id: 'auth' });
|
|
66
69
|
return {
|
|
67
70
|
status: _result.status,
|
|
71
|
+
message: _result.message,
|
|
68
72
|
data: {
|
|
69
73
|
user: _result.data,
|
|
70
74
|
},
|
|
@@ -77,6 +81,15 @@ const Auth = {
|
|
|
77
81
|
await Account.updateForm(data.user);
|
|
78
82
|
return { user: data.user };
|
|
79
83
|
}
|
|
84
|
+
if (message && message.match('expired'))
|
|
85
|
+
setTimeout(() => {
|
|
86
|
+
s(`.main-btn-log-in`).click();
|
|
87
|
+
NotificationManager.Push({
|
|
88
|
+
html: Translate.Render(`expired-session`),
|
|
89
|
+
status: 'warning',
|
|
90
|
+
});
|
|
91
|
+
});
|
|
92
|
+
return await Auth.sessionOut();
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
// anon guest session
|
|
@@ -92,20 +105,25 @@ const Auth = {
|
|
|
92
105
|
|
|
93
106
|
this.setGuestToken(guestToken);
|
|
94
107
|
let { data, status, message } = await UserService.get({ id: 'auth' });
|
|
95
|
-
if (status === 'error')
|
|
108
|
+
if (status === 'error') {
|
|
109
|
+
if (message && message.match('expired')) {
|
|
110
|
+
localStorage.removeItem('jwt.g');
|
|
111
|
+
return await Auth.sessionOut();
|
|
112
|
+
} else throw new Error(message);
|
|
113
|
+
}
|
|
96
114
|
await Account.updateForm(data);
|
|
97
115
|
return { user: data };
|
|
98
116
|
} catch (error) {
|
|
99
117
|
logger.error(error);
|
|
100
|
-
localStorage.removeItem('jwt');
|
|
101
|
-
localStorage.removeItem('jwt.g');
|
|
102
118
|
return { user: UserMock.default };
|
|
103
119
|
}
|
|
104
120
|
},
|
|
105
121
|
sessionOut: async function () {
|
|
106
122
|
this.deleteToken();
|
|
107
123
|
localStorage.removeItem('jwt');
|
|
108
|
-
|
|
124
|
+
const result = await this.sessionIn();
|
|
125
|
+
await LogOut.Trigger(result);
|
|
126
|
+
return result;
|
|
109
127
|
},
|
|
110
128
|
};
|
|
111
129
|
|
|
@@ -508,6 +508,10 @@ const TranslateCore = {
|
|
|
508
508
|
en: 'Invalid identity document',
|
|
509
509
|
es: 'Documento de identidad inválido',
|
|
510
510
|
};
|
|
511
|
+
Translate.Data['expired-session'] = {
|
|
512
|
+
en: 'Your session has expired. Please log in again.',
|
|
513
|
+
es: 'Su sesión ha expirado. Por favor, inicie sesión de nuevo.',
|
|
514
|
+
};
|
|
511
515
|
},
|
|
512
516
|
};
|
|
513
517
|
|
package/src/index.js
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
7
|
import UnderpostCluster from './cli/cluster.js';
|
|
8
|
+
import UnderpostDB from './cli/db.js';
|
|
8
9
|
import UnderpostRootEnv from './cli/env.js';
|
|
9
10
|
import UnderpostImage from './cli/image.js';
|
|
10
11
|
import UnderpostRepository from './cli/repository.js';
|
|
@@ -24,7 +25,7 @@ class Underpost {
|
|
|
24
25
|
* @type {String}
|
|
25
26
|
* @memberof Underpost
|
|
26
27
|
*/
|
|
27
|
-
static version = 'v2.8.
|
|
28
|
+
static version = 'v2.8.46';
|
|
28
29
|
/**
|
|
29
30
|
* Repository cli API
|
|
30
31
|
* @static
|
|
@@ -74,6 +75,13 @@ class Underpost {
|
|
|
74
75
|
* @memberof Underpost
|
|
75
76
|
*/
|
|
76
77
|
static script = UnderpostScript.API;
|
|
78
|
+
/**
|
|
79
|
+
* Database cli API
|
|
80
|
+
* @static
|
|
81
|
+
* @type {UnderpostDB.API}
|
|
82
|
+
* @memberof Underpost
|
|
83
|
+
*/
|
|
84
|
+
static db = UnderpostDB.API;
|
|
77
85
|
}
|
|
78
86
|
|
|
79
87
|
const up = Underpost;
|
package/src/server/conf.js
CHANGED
|
@@ -525,9 +525,11 @@ const buildPortProxyRouter = (port, proxyRouter) => {
|
|
|
525
525
|
|
|
526
526
|
if (Object.keys(router).length === 0) return router;
|
|
527
527
|
|
|
528
|
+
const reOrderRouter = {};
|
|
528
529
|
for (const absoluteHostKey of orderArrayFromAttrInt(Object.keys(router), 'length'))
|
|
529
|
-
|
|
530
|
-
|
|
530
|
+
reOrderRouter[absoluteHostKey] = router[absoluteHostKey];
|
|
531
|
+
|
|
532
|
+
return reOrderRouter;
|
|
531
533
|
};
|
|
532
534
|
|
|
533
535
|
const cliBar = async (time = 5000) => {
|
package/src/server/logger.js
CHANGED
|
@@ -85,6 +85,7 @@ const format = (meta) =>
|
|
|
85
85
|
*/
|
|
86
86
|
const setUpInfo = async (logger = new winston.Logger()) => {
|
|
87
87
|
logger.info('argv', process.argv);
|
|
88
|
+
logger.info('cwd', process.cwd());
|
|
88
89
|
logger.info('platform', process.platform);
|
|
89
90
|
logger.info('env', process.env.NODE_ENV);
|
|
90
91
|
logger.info('--max-old-space-size', {
|
package/src/server/network.js
CHANGED
|
@@ -39,7 +39,7 @@ const saveRuntimeRouter = async () => {
|
|
|
39
39
|
const host = process.env.DEFAULT_DEPLOY_HOST;
|
|
40
40
|
const path = process.env.DEFAULT_DEPLOY_PATH;
|
|
41
41
|
const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
|
|
42
|
-
if (!deployId || !host || !path) {
|
|
42
|
+
if (!deployId || !host || !path || !fs.existsSync(confServerPath)) {
|
|
43
43
|
// logger.warn('default deploy instance not found');
|
|
44
44
|
return;
|
|
45
45
|
}
|