underpost 2.7.8 → 2.7.9
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 +41 -1
- package/.github/workflows/publish.yml +17 -18
- package/.github/workflows/pwa-microservices-template.page.yml +54 -0
- package/.vscode/settings.json +6 -0
- package/CHANGELOG.md +64 -16
- package/bin/cron.js +47 -0
- package/bin/db.js +9 -1
- package/bin/deploy.js +194 -9
- package/bin/file.js +17 -1
- package/bin/index.js +1 -1
- package/bin/util.js +22 -0
- package/conf.js +18 -4
- package/docker-compose.yml +1 -1
- package/package.json +3 -3
- package/src/api/core/core.router.js +9 -9
- package/src/api/core/core.service.js +6 -4
- package/src/api/default/default.service.js +4 -4
- package/src/api/file/file.service.js +3 -3
- package/src/api/user/user.service.js +7 -7
- package/src/client/components/core/CssCore.js +30 -3
- package/src/client/components/core/Docs.js +110 -10
- package/src/client/components/core/Modal.js +224 -22
- package/src/client/components/core/Panel.js +1 -1
- package/src/client/components/core/PanelForm.js +2 -1
- package/src/client/components/core/Responsive.js +15 -0
- package/src/client/components/core/RichText.js +4 -2
- package/src/client/components/core/WebComponent.js +44 -0
- package/src/client/components/core/Worker.js +10 -12
- package/src/client/public/default/plantuml/client-conf.svg +1 -1
- package/src/client/public/default/plantuml/client-schema.svg +1 -1
- package/src/client/public/default/plantuml/cron-conf.svg +1 -1
- package/src/client/public/default/plantuml/cron-schema.svg +1 -1
- package/src/client/public/default/plantuml/server-conf.svg +1 -1
- package/src/client/public/default/plantuml/server-schema.svg +1 -1
- package/src/client/public/default/plantuml/ssr-conf.svg +1 -1
- package/src/client/public/default/plantuml/ssr-schema.svg +1 -1
- package/src/client/public/default/site.webmanifest +69 -0
- package/src/client/ssr/components/body/CacheControl.js +1 -1
- package/src/client/ssr/components/head/Production.js +1 -0
- package/src/client/ssr/components/head/Pwa.js +146 -0
- package/src/client/ssr/components/head/Seo.js +14 -0
- package/src/client/ssr/pages/maintenance.js +14 -0
- package/src/client/ssr/pages/offline.js +21 -0
- package/src/client/sw/default.sw.js +4 -2
- package/src/db/DataBaseProvider.js +12 -1
- package/src/db/mongo/MongooseDB.js +0 -1
- package/src/server/backup.js +82 -70
- package/src/server/client-build.js +23 -90
- package/src/server/conf.js +51 -5
- package/src/server/crypto.js +91 -0
- package/src/server/dns.js +42 -13
- package/src/server/network.js +94 -7
- package/src/server/proxy.js +27 -27
- package/src/server/runtime.js +3 -1
- package/src/client/ssr/offline/default.index.js +0 -31
- package/src/cron.js +0 -30
- package/src/server/cron.js +0 -35
|
@@ -9,7 +9,47 @@ permissions:
|
|
|
9
9
|
packages: write
|
|
10
10
|
id-token: write
|
|
11
11
|
jobs:
|
|
12
|
-
|
|
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
|
+
- uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: '22.x'
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: |
|
|
28
|
+
npm install
|
|
29
|
+
|
|
30
|
+
- name: Set git credentials
|
|
31
|
+
run: |
|
|
32
|
+
git config --global credential.helper ""
|
|
33
|
+
git config credential.helper ""
|
|
34
|
+
git config --global user.name 'underpostnet'
|
|
35
|
+
git config --global user.email 'fcoverdugoa@underpost.net'
|
|
36
|
+
git config --global credential.interactive always
|
|
37
|
+
git config user.name 'underpostnet'
|
|
38
|
+
git config user.email 'fcoverdugoa@underpost.net'
|
|
39
|
+
git config credential.interactive always
|
|
40
|
+
|
|
41
|
+
- name: Clone github package repository
|
|
42
|
+
run: |
|
|
43
|
+
cd .. && git clone https://github.com/underpostnet/pwa-microservices-template.git
|
|
44
|
+
cd engine
|
|
45
|
+
npm run update-template
|
|
46
|
+
cd ../pwa-microservices-template
|
|
47
|
+
git remote set-url origin git@github.com:underpostnet/pwa-microservices-template.git
|
|
48
|
+
git add .
|
|
49
|
+
git commit -m "Update github repo package"
|
|
50
|
+
git push https://${{ secrets.GIT_AUTH_TOKEN }}@github.com/underpostnet/pwa-microservices-template.git
|
|
51
|
+
|
|
52
|
+
pwa-microservices-template-ghpk:
|
|
13
53
|
if: github.repository == 'underpostnet/pwa-microservices-template'
|
|
14
54
|
name: Update github repo package Jobs
|
|
15
55
|
runs-on: ubuntu-latest
|
|
@@ -34,25 +34,24 @@ jobs:
|
|
|
34
34
|
name: Publish to npm
|
|
35
35
|
run: npm publish --provenance --access public
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
37
|
+
build-and-publish-ghpkg:
|
|
38
|
+
# prevents this action from running on forks
|
|
39
|
+
if: github.repository == 'underpostnet/pwa-microservices-template-ghpkg'
|
|
40
|
+
runs-on: ubuntu-latest
|
|
41
|
+
permissions:
|
|
42
|
+
contents: read
|
|
43
|
+
id-token: write
|
|
44
|
+
steps:
|
|
45
|
+
- uses: actions/checkout@v4
|
|
46
|
+
- uses: actions/setup-node@v4
|
|
47
|
+
with:
|
|
48
|
+
node-version: '22.x'
|
|
49
|
+
registry-url: 'https://registry.npmjs.org'
|
|
45
50
|
|
|
46
|
-
- name:
|
|
47
|
-
run:
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
git config --global user.name 'underpostnet'
|
|
51
|
-
git config --global user.email 'fcoverdugoa@underpost.net'
|
|
52
|
-
git config --global credential.interactive always
|
|
53
|
-
git config user.name 'underpostnet'
|
|
54
|
-
git config user.email 'fcoverdugoa@underpost.net'
|
|
55
|
-
git config credential.interactive always
|
|
51
|
+
- name: Install Dependencies
|
|
52
|
+
run: npm install
|
|
53
|
+
|
|
54
|
+
- run: npm ci
|
|
56
55
|
|
|
57
56
|
# Publish to npm git hub package
|
|
58
57
|
- uses: actions/setup-node@v4
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# Simple workflow for deploying static content to GitHub Pages
|
|
2
|
+
name: Deploy static content to Pages
|
|
3
|
+
|
|
4
|
+
on:
|
|
5
|
+
# Runs on pushes targeting the default branch
|
|
6
|
+
push:
|
|
7
|
+
branches: ['main']
|
|
8
|
+
|
|
9
|
+
# Allows you to run this workflow manually from the Actions tab
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
|
13
|
+
permissions:
|
|
14
|
+
contents: read
|
|
15
|
+
pages: write
|
|
16
|
+
id-token: write
|
|
17
|
+
|
|
18
|
+
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
19
|
+
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
20
|
+
concurrency:
|
|
21
|
+
group: 'pages'
|
|
22
|
+
cancel-in-progress: false
|
|
23
|
+
|
|
24
|
+
jobs:
|
|
25
|
+
# Single deploy job since we're just deploying
|
|
26
|
+
deploy:
|
|
27
|
+
if: github.repository == 'underpostnet/pwa-microservices-template-ghpkg'
|
|
28
|
+
environment:
|
|
29
|
+
name: github-pages
|
|
30
|
+
url: ${{ steps.deployment.outputs.page_url }}
|
|
31
|
+
runs-on: ubuntu-latest
|
|
32
|
+
steps:
|
|
33
|
+
- name: Checkout
|
|
34
|
+
uses: actions/checkout@v4
|
|
35
|
+
- uses: actions/setup-node@v4
|
|
36
|
+
with:
|
|
37
|
+
node-version: '22.x'
|
|
38
|
+
|
|
39
|
+
- name: Build the site
|
|
40
|
+
run: |
|
|
41
|
+
npm install
|
|
42
|
+
node bin/deploy update-default-conf
|
|
43
|
+
npm run build-production github-pages underpostnet.github.io /pwa-microservices-template-ghpkg
|
|
44
|
+
|
|
45
|
+
- name: Setup Pages
|
|
46
|
+
uses: actions/configure-pages@v5
|
|
47
|
+
- name: Upload artifact
|
|
48
|
+
uses: actions/upload-pages-artifact@v3
|
|
49
|
+
with:
|
|
50
|
+
# Upload entire repository
|
|
51
|
+
path: './public/underpostnet.github.io/pwa-microservices-template-ghpkg/'
|
|
52
|
+
- name: Deploy to GitHub Pages
|
|
53
|
+
id: deployment
|
|
54
|
+
uses: actions/deploy-pages@v4
|
package/.vscode/settings.json
CHANGED
|
@@ -30,12 +30,14 @@
|
|
|
30
30
|
"fileupload",
|
|
31
31
|
"fontawesome",
|
|
32
32
|
"fortawesome",
|
|
33
|
+
"gameplay",
|
|
33
34
|
"googlebot",
|
|
34
35
|
"Hexa",
|
|
35
36
|
"htdocs",
|
|
36
37
|
"htmls",
|
|
37
38
|
"inlt",
|
|
38
39
|
"ipfs",
|
|
40
|
+
"Itemledger",
|
|
39
41
|
"jsonld",
|
|
40
42
|
"lampp",
|
|
41
43
|
"loadingio",
|
|
@@ -54,6 +56,7 @@
|
|
|
54
56
|
"Scatterplot",
|
|
55
57
|
"sortablejs",
|
|
56
58
|
"supervisord",
|
|
59
|
+
"Tokenomics",
|
|
57
60
|
"underpost",
|
|
58
61
|
"Unequip",
|
|
59
62
|
"webroot",
|
|
@@ -96,5 +99,8 @@
|
|
|
96
99
|
"prometheus_data": true,
|
|
97
100
|
"grafana_data": true,
|
|
98
101
|
".nyc_output": true
|
|
102
|
+
},
|
|
103
|
+
"[solidity]": {
|
|
104
|
+
"editor.defaultFormatter": "JuanBlanco.solidity"
|
|
99
105
|
}
|
|
100
106
|
}
|
package/CHANGELOG.md
CHANGED
|
@@ -4,34 +4,82 @@ All notable changes to this project will be documented in this file. Dates are d
|
|
|
4
4
|
|
|
5
5
|
Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
|
|
6
6
|
|
|
7
|
-
#### [v2.7.
|
|
7
|
+
#### [v2.7.83](https://github.com/underpostnet/engine/compare/v2.7.7...v2.7.83)
|
|
8
|
+
|
|
9
|
+
> 28 October 2024
|
|
10
|
+
|
|
11
|
+
- update version 2.7.83 [`3d22671`](https://github.com/underpostnet/engine/commit/3d22671a23f25767cc01c244090e237ab3a300da)
|
|
12
|
+
- ssr refactor [`836b848`](https://github.com/underpostnet/engine/commit/836b8488b8b5156c4c5d376fefd592e25071a212)
|
|
13
|
+
- fix pixi js render [`93aaee3`](https://github.com/underpostnet/engine/commit/93aaee3683b070874b65ca2c00d27f2a787a0a5d)
|
|
14
|
+
|
|
15
|
+
#### [v2.7.7](https://github.com/underpostnet/engine/compare/v2.7.6...v2.7.7)
|
|
16
|
+
|
|
17
|
+
> 25 October 2024
|
|
18
|
+
|
|
19
|
+
- update version 2.7.7 [`df31617`](https://github.com/underpostnet/engine/commit/df316174ca563251fbaca62a6717771f3056e59b)
|
|
20
|
+
- cyberia ssr lore advance [`ad1f214`](https://github.com/underpostnet/engine/commit/ad1f2144bdd2f3b5b1f2ebc4b9f6b83716df800a)
|
|
21
|
+
- advance ssr lore cyberia [`03b2292`](https://github.com/underpostnet/engine/commit/03b2292f6e092fc9b98cfb6aba9eee6eb0f21a06)
|
|
22
|
+
|
|
23
|
+
#### [v2.7.6](https://github.com/underpostnet/engine/compare/v2.7.5...v2.7.6)
|
|
24
|
+
|
|
25
|
+
> 17 October 2024
|
|
26
|
+
|
|
27
|
+
- update version v2.7.6 [`ddbc2c4`](https://github.com/underpostnet/engine/commit/ddbc2c4bd366e75b580be288c28c68830ed390d5)
|
|
28
|
+
- update node version 22.9.0 and hardhat refactor [`8ba9281`](https://github.com/underpostnet/engine/commit/8ba92818cd67438359dd1aa0938fd33bb932e718)
|
|
29
|
+
- remove pinata [`e231b00`](https://github.com/underpostnet/engine/commit/e231b00919d9d0e31c9718d4dc512384779cf2bb)
|
|
30
|
+
|
|
31
|
+
#### [v2.7.5](https://github.com/underpostnet/engine/compare/v2.7.2...v2.7.5)
|
|
32
|
+
|
|
33
|
+
> 10 October 2024
|
|
34
|
+
|
|
35
|
+
- remove os switchs [`78f7c17`](https://github.com/underpostnet/engine/commit/78f7c17bdaa1789101bf3038544d105b51f25309)
|
|
36
|
+
- update version 2.7.5 [`ca059d9`](https://github.com/underpostnet/engine/commit/ca059d99f95121cbd51f4582c60458734e21b70d)
|
|
37
|
+
- add mondo db server daemon [`b3bab7e`](https://github.com/underpostnet/engine/commit/b3bab7e8ba4204da459660d5fdba25c076c6cd33)
|
|
38
|
+
|
|
39
|
+
#### [v2.7.2](https://github.com/underpostnet/engine/compare/v2.7.1...v2.7.2)
|
|
8
40
|
|
|
9
41
|
> 8 October 2024
|
|
10
42
|
|
|
11
|
-
-
|
|
12
|
-
-
|
|
13
|
-
-
|
|
43
|
+
- underpost panel advance [`60087d5`](https://github.com/underpostnet/engine/commit/60087d55920ae9ddf7d7a3396606088d028cc996)
|
|
44
|
+
- file explorer content ui ux refactor [`38e87a0`](https://github.com/underpostnet/engine/commit/38e87a0f0bd222e1d8c9d76904d086aa9d2125ea)
|
|
45
|
+
- add macro db restore logic [`9cfd41c`](https://github.com/underpostnet/engine/commit/9cfd41c5d7adcd309976e7d327af800ffcf92dac)
|
|
14
46
|
|
|
15
|
-
#### [v2.7.1](https://github.com/underpostnet/
|
|
47
|
+
#### [v2.7.1](https://github.com/underpostnet/engine/compare/v2.6.3...v2.7.1)
|
|
16
48
|
|
|
17
49
|
> 19 September 2024
|
|
18
50
|
|
|
19
|
-
-
|
|
20
|
-
- update
|
|
21
|
-
-
|
|
51
|
+
- update version 2.7.0 [`03c5c35`](https://github.com/underpostnet/engine/commit/03c5c35a71e7ffb35203a668bfa2f8e2f86125e0)
|
|
52
|
+
- update [`d410da6`](https://github.com/underpostnet/engine/commit/d410da62fadbbb841eb9dcfa5922f105d35ad81d)
|
|
53
|
+
- add changelog generator [`28b3256`](https://github.com/underpostnet/engine/commit/28b3256ab9cebaa9caf2b52426e48f0b3105c8b7)
|
|
22
54
|
|
|
23
|
-
#### [v2.6.3](https://github.com/underpostnet/
|
|
55
|
+
#### [v2.6.3](https://github.com/underpostnet/engine/compare/v2.6.2...v2.6.3)
|
|
24
56
|
|
|
25
57
|
> 14 September 2024
|
|
26
58
|
|
|
27
|
-
- update version 2.6.3 [`
|
|
28
|
-
- update [`
|
|
29
|
-
- update [`
|
|
59
|
+
- update version 2.6.3 [`85c585d`](https://github.com/underpostnet/engine/commit/85c585d1cce30de4389772605cf56e774e2b7d3c)
|
|
60
|
+
- update refactor docs and coverage [`b455016`](https://github.com/underpostnet/engine/commit/b455016f5f2b2bdc142aacb4dfd66ab890125662)
|
|
61
|
+
- update [`b8f01f2`](https://github.com/underpostnet/engine/commit/b8f01f258999c9ebc1173b0616f0f7b8f7171048)
|
|
30
62
|
|
|
31
|
-
#### v2.6.2
|
|
63
|
+
#### [v2.6.2](https://github.com/underpostnet/engine/compare/v2.5.1...v2.6.2)
|
|
32
64
|
|
|
33
65
|
> 13 September 2024
|
|
34
66
|
|
|
35
|
-
-
|
|
36
|
-
-
|
|
37
|
-
- update
|
|
67
|
+
- update version 2.6.2 [`0895afb`](https://github.com/underpostnet/engine/commit/0895afbde42dd5a573507ccfcb07c328648b4eb0)
|
|
68
|
+
- update version 2.5.6 [`ca57b87`](https://github.com/underpostnet/engine/commit/ca57b87c56a544e7b7e53baa5a6e15415e16b99b)
|
|
69
|
+
- update [`eec4943`](https://github.com/underpostnet/engine/commit/eec49433f50b4dfa7b7bbff48891a60f5be25545)
|
|
70
|
+
|
|
71
|
+
#### [v2.5.1](https://github.com/underpostnet/engine/compare/v2.0.0...v2.5.1)
|
|
72
|
+
|
|
73
|
+
> 27 August 2024
|
|
74
|
+
|
|
75
|
+
- css refactor [`49b1904`](https://github.com/underpostnet/engine/commit/49b1904e83162f9066fbf843ced37d4e87db5581)
|
|
76
|
+
- refactor [`dad4f95`](https://github.com/underpostnet/engine/commit/dad4f9567629b737254702ce8be6b243e68fb01e)
|
|
77
|
+
- add sitemap builder [`53d05a6`](https://github.com/underpostnet/engine/commit/53d05a62d03ea327df3d37181a4b5c272d417289)
|
|
78
|
+
|
|
79
|
+
#### v2.0.0
|
|
80
|
+
|
|
81
|
+
> 30 March 2024
|
|
82
|
+
|
|
83
|
+
- seed-city assets [`6d9decb`](https://github.com/underpostnet/engine/commit/6d9decbae96b828aa001777f96dd75aab3fc71d1)
|
|
84
|
+
- update [`1069fc5`](https://github.com/underpostnet/engine/commit/1069fc5268aa5ef7c101695393de59edfc14daf8)
|
|
85
|
+
- update [`41ae7d4`](https://github.com/underpostnet/engine/commit/41ae7d4c969cce0608171c820e05ebab42610a7f)
|
package/bin/cron.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { BackUpManagement } from '../src/server/backup.js';
|
|
2
|
+
import { Cmd } from '../src/server/conf.js';
|
|
3
|
+
import { Dns } from '../src/server/dns.js';
|
|
4
|
+
import { loggerFactory } from '../src/server/logger.js';
|
|
5
|
+
import { netWorkCron, saveRuntimeCron } from '../src/server/network.js';
|
|
6
|
+
import { shellExec } from '../src/server/process.js';
|
|
7
|
+
import fs from 'fs-extra';
|
|
8
|
+
|
|
9
|
+
const logger = loggerFactory(import.meta);
|
|
10
|
+
|
|
11
|
+
await logger.setUpInfo();
|
|
12
|
+
|
|
13
|
+
switch (process.argv[2]) {
|
|
14
|
+
case 'backups':
|
|
15
|
+
{
|
|
16
|
+
await BackUpManagement.Init({ deployId: process.argv[3] });
|
|
17
|
+
}
|
|
18
|
+
break;
|
|
19
|
+
case 'dns':
|
|
20
|
+
{
|
|
21
|
+
await Dns.InitIpDaemon({ deployId: process.argv[3] });
|
|
22
|
+
}
|
|
23
|
+
break;
|
|
24
|
+
|
|
25
|
+
case 'run': {
|
|
26
|
+
const confCronConfig = JSON.parse(fs.readFileSync(`./engine-private/conf/${process.argv[3]}/conf.cron.json`));
|
|
27
|
+
if (confCronConfig.jobs && Object.keys(confCronConfig.jobs).length > 0) {
|
|
28
|
+
shellExec(`node bin/deploy conf ${process.argv[3]} production`);
|
|
29
|
+
for (const job of Object.keys(confCronConfig.jobs)) {
|
|
30
|
+
if (confCronConfig.jobs[job].enabled) {
|
|
31
|
+
shellExec(Cmd.cron(process.argv[3], job, confCronConfig.jobs[job].expression));
|
|
32
|
+
netWorkCron.push({
|
|
33
|
+
deployId: process.argv[3],
|
|
34
|
+
jobId: job,
|
|
35
|
+
expression: confCronConfig.jobs[job].expression,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
await saveRuntimeCron();
|
|
41
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
default:
|
|
46
|
+
break;
|
|
47
|
+
}
|
package/bin/db.js
CHANGED
|
@@ -113,7 +113,7 @@ try {
|
|
|
113
113
|
case 'update':
|
|
114
114
|
{
|
|
115
115
|
await DataBaseProvider.load({ apis: [arg0], host, path, db });
|
|
116
|
-
const models = DataBaseProvider.instance[`${host}${path}`].mongoose[getCapVariableName(arg0)];
|
|
116
|
+
const models = DataBaseProvider.instance[`${host}${path}`].mongoose.models[getCapVariableName(arg0)];
|
|
117
117
|
|
|
118
118
|
const select = JSON.parse(arg1.replaceAll("'", `"`));
|
|
119
119
|
const update = JSON.parse(arg2.replaceAll("'", `"`));
|
|
@@ -133,6 +133,7 @@ try {
|
|
|
133
133
|
runValidators: true,
|
|
134
134
|
});
|
|
135
135
|
logger.info(`successfully updated doc`, doc._doc);
|
|
136
|
+
await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
136
137
|
} else throw new Error(`no doc found`);
|
|
137
138
|
}
|
|
138
139
|
break;
|
|
@@ -143,6 +144,13 @@ try {
|
|
|
143
144
|
case 'create':
|
|
144
145
|
break;
|
|
145
146
|
case 'delete':
|
|
147
|
+
{
|
|
148
|
+
await DataBaseProvider.load({ apis: [arg0], host, path, db });
|
|
149
|
+
const models = DataBaseProvider.instance[`${host}${path}`].mongoose.models[getCapVariableName(arg0)];
|
|
150
|
+
await models.collection.drop();
|
|
151
|
+
logger.info(`successfully drop collection`, arg0);
|
|
152
|
+
await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
|
|
153
|
+
}
|
|
146
154
|
break;
|
|
147
155
|
case 'export':
|
|
148
156
|
// mongodump -d <database_name> -o <directory_backup>
|
package/bin/deploy.js
CHANGED
|
@@ -25,6 +25,7 @@ import {
|
|
|
25
25
|
Cmd,
|
|
26
26
|
restoreMacroDb,
|
|
27
27
|
fixDependencies,
|
|
28
|
+
setUpProxyMaintenanceServer,
|
|
28
29
|
} from '../src/server/conf.js';
|
|
29
30
|
import { buildClient } from '../src/server/client-build.js';
|
|
30
31
|
import { range, setPad, timer, uniqueArray } from '../src/client/components/core/CommonJs.js';
|
|
@@ -32,6 +33,8 @@ import toJsonSchema from 'to-json-schema';
|
|
|
32
33
|
import simpleGit from 'simple-git';
|
|
33
34
|
import { MongooseDB } from '../src/db/mongo/MongooseDB.js';
|
|
34
35
|
import { Lampp } from '../src/runtime/lampp/Lampp.js';
|
|
36
|
+
import { DefaultConf } from '../conf.js';
|
|
37
|
+
import { JSONweb } from '../src/server/client-formatted.js';
|
|
35
38
|
|
|
36
39
|
const logger = loggerFactory(import.meta);
|
|
37
40
|
|
|
@@ -152,10 +155,15 @@ try {
|
|
|
152
155
|
await deployRun(dataDeploy);
|
|
153
156
|
} else {
|
|
154
157
|
loadConf(process.argv[3]);
|
|
155
|
-
shellExec(`npm start ${process.argv
|
|
158
|
+
shellExec(`npm start ${process.argv.includes('maintenance') ? 'maintenance' : ''}`);
|
|
156
159
|
}
|
|
157
160
|
}
|
|
158
161
|
break;
|
|
162
|
+
|
|
163
|
+
case 'remove-await-deploy': {
|
|
164
|
+
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
159
167
|
case 'new-nodejs-app':
|
|
160
168
|
{
|
|
161
169
|
const deployId = process.argv[3];
|
|
@@ -222,21 +230,18 @@ try {
|
|
|
222
230
|
break;
|
|
223
231
|
case 'build-full-client':
|
|
224
232
|
{
|
|
233
|
+
if (!process.argv[3]) process.argv[3] = 'default';
|
|
225
234
|
const { deployId, folder } = loadConf(process.argv[3]);
|
|
226
235
|
|
|
227
|
-
let argHost = process.argv[4] ? process.argv[4].split(',') :
|
|
228
|
-
let argPath = process.argv[5] ? process.argv[5].split(',') :
|
|
236
|
+
let argHost = process.argv[4] ? process.argv[4].split(',') : [];
|
|
237
|
+
let argPath = process.argv[5] ? process.argv[5].split(',') : [];
|
|
229
238
|
let deployIdSingleReplicas = [];
|
|
230
239
|
const serverConf = deployId
|
|
231
240
|
? JSON.parse(fs.readFileSync(`./conf/conf.server.json`, 'utf8'))
|
|
232
241
|
: Config.default.server;
|
|
233
|
-
if (!deployId) {
|
|
234
|
-
argHost = 'default.net';
|
|
235
|
-
argPath = '/';
|
|
236
|
-
}
|
|
237
242
|
for (const host of Object.keys(serverConf)) {
|
|
238
243
|
for (const path of Object.keys(serverConf[host])) {
|
|
239
|
-
if (argHost && argPath && (!argHost.includes(host) || !argPath.includes(path))) {
|
|
244
|
+
if (argHost.length && argPath.length && (!argHost.includes(host) || !argPath.includes(path))) {
|
|
240
245
|
delete serverConf[host][path];
|
|
241
246
|
} else {
|
|
242
247
|
serverConf[host][path].liteBuild = process.argv.includes('l') ? true : false;
|
|
@@ -290,10 +295,28 @@ try {
|
|
|
290
295
|
}
|
|
291
296
|
break;
|
|
292
297
|
|
|
298
|
+
case 'run-single-build': {
|
|
299
|
+
const deployId = process.argv[3];
|
|
300
|
+
shellExec(Cmd.conf(deployId));
|
|
301
|
+
shellExec(Cmd.build(deployId));
|
|
302
|
+
shellExec(Cmd.delete(deployId));
|
|
303
|
+
shellExec(Cmd.run(deployId));
|
|
304
|
+
break;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
case 'run-single': {
|
|
308
|
+
const deployId = process.argv[3];
|
|
309
|
+
shellExec(Cmd.delete(deployId));
|
|
310
|
+
shellExec(Cmd.conf(deployId));
|
|
311
|
+
shellExec(Cmd.run(deployId));
|
|
312
|
+
break;
|
|
313
|
+
}
|
|
314
|
+
|
|
293
315
|
case 'run-macro':
|
|
294
316
|
{
|
|
295
317
|
if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
|
|
296
318
|
const dataDeploy = getDataDeploy({ deployGroupId: process.argv[3], buildSingleReplica: true });
|
|
319
|
+
await setUpProxyMaintenanceServer({ deployGroupId: process.argv[3] });
|
|
297
320
|
await deployRun(dataDeploy, true);
|
|
298
321
|
}
|
|
299
322
|
break;
|
|
@@ -306,6 +329,7 @@ try {
|
|
|
306
329
|
shellExec(Cmd.conf(deploy.deployId));
|
|
307
330
|
shellExec(Cmd.build(deploy.deployId));
|
|
308
331
|
}
|
|
332
|
+
await setUpProxyMaintenanceServer({ deployGroupId: process.argv[3] });
|
|
309
333
|
await deployRun(dataDeploy, true);
|
|
310
334
|
}
|
|
311
335
|
break;
|
|
@@ -452,7 +476,7 @@ try {
|
|
|
452
476
|
`./engine-private/replica/${replicaDeployId}/package.json`,
|
|
453
477
|
fs
|
|
454
478
|
.readFileSync(`./engine-private/replica/${replicaDeployId}/package.json`, 'utf8')
|
|
455
|
-
.replaceAll(
|
|
479
|
+
.replaceAll(`${deployId}`, `${replicaDeployId}`),
|
|
456
480
|
'utf8',
|
|
457
481
|
);
|
|
458
482
|
}
|
|
@@ -666,6 +690,167 @@ ${uniqueArray(logs.all.map((log) => `- ${log.author_name} ([${log.author_email}]
|
|
|
666
690
|
break;
|
|
667
691
|
}
|
|
668
692
|
|
|
693
|
+
case 'update-default-conf': {
|
|
694
|
+
const host = process.argv[3] ? process.argv[3] : 'underpostnet.github.io';
|
|
695
|
+
const path = process.argv[4] ? process.argv[4] : '/pwa-microservices-template-ghpkg';
|
|
696
|
+
DefaultConf.server = {
|
|
697
|
+
[host]: { [path]: DefaultConf.server['default.net']['/'] },
|
|
698
|
+
};
|
|
699
|
+
DefaultConf.server[host][path].apiBaseProxyPath = '/';
|
|
700
|
+
DefaultConf.server[host][path].apiBaseHost = 'www.nexodev.org';
|
|
701
|
+
fs.writeFileSync(
|
|
702
|
+
'./conf.js',
|
|
703
|
+
`
|
|
704
|
+
const DefaultConf = ${JSONweb(DefaultConf)};
|
|
705
|
+
|
|
706
|
+
export { DefaultConf }
|
|
707
|
+
|
|
708
|
+
`,
|
|
709
|
+
'utf8',
|
|
710
|
+
);
|
|
711
|
+
|
|
712
|
+
break;
|
|
713
|
+
}
|
|
714
|
+
case 'ssh-export-server-keys': {
|
|
715
|
+
fs.copyFile('/etc/ssh/ssh_host_rsa_key', './engine-private/deploy/ssh_host_rsa_key');
|
|
716
|
+
fs.copyFile('/etc/ssh/ssh_host_rsa_key.pub', './engine-private/deploy/ssh_host_rsa_key.pub');
|
|
717
|
+
break;
|
|
718
|
+
}
|
|
719
|
+
case 'ssh-import-server-keys': {
|
|
720
|
+
fs.copyFile('./engine-private/deploy/ssh_host_rsa_key', '/etc/ssh/ssh_host_rsa_key');
|
|
721
|
+
fs.copyFile('./engine-private/deploy/ssh_host_rsa_key.pub', '/etc/ssh/ssh_host_rsa_key.pub');
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
case 'ssh-import-client-keys': {
|
|
725
|
+
const host = process.argv[3];
|
|
726
|
+
shellExec(`node bin/deploy set-ssh-keys ./engine-private/deploy/ssh_host_rsa_key${host ? ` ${host}` : ``} clean`);
|
|
727
|
+
break;
|
|
728
|
+
}
|
|
729
|
+
case 'ssh-keys': {
|
|
730
|
+
// create ssh keys
|
|
731
|
+
const sshAccount = process.argv[3]; // [sudo username]@[host/ip]
|
|
732
|
+
const destPath = process.argv[4];
|
|
733
|
+
// shellExec(`ssh-keygen -t ed25519 -C "${sshAccount}" -f ${destPath}`);
|
|
734
|
+
if (fs.existsSync(destPath)) {
|
|
735
|
+
fs.removeSync(destPath);
|
|
736
|
+
fs.removeSync(destPath + '.pub');
|
|
737
|
+
}
|
|
738
|
+
shellExec(`ssh-keygen -t rsa -b 4096 -C "${sshAccount}" -f ${destPath}`);
|
|
739
|
+
// add host to keyscan
|
|
740
|
+
// shellExec(`ssh-keyscan -t rsa ${sshAccount.split(`@`)[1]} >> ~/.ssh/known_hosts`);
|
|
741
|
+
break;
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
case 'set-ssh-keys': {
|
|
745
|
+
const files = ['authorized_keys', 'id_rsa', 'id_rsa.pub', 'known_hosts ', 'known_hosts.old'];
|
|
746
|
+
|
|
747
|
+
// > write
|
|
748
|
+
// >> append
|
|
749
|
+
|
|
750
|
+
// /root/.ssh/id_rsa
|
|
751
|
+
// /root/.ssh/id_rsa.pub
|
|
752
|
+
if (process.argv.includes('clean')) {
|
|
753
|
+
for (const file of files) {
|
|
754
|
+
if (fs.existsSync(`/root/.ssh/${file}`)) {
|
|
755
|
+
logger.info('remove', `/root/.ssh/${file}`);
|
|
756
|
+
fs.removeSync(`/root/.ssh/${file}`);
|
|
757
|
+
}
|
|
758
|
+
fs.writeFileSync(`/root/.ssh/${file}`, '', 'utf8');
|
|
759
|
+
}
|
|
760
|
+
shellExec('eval `ssh-agent -s`' + ` && ssh-add -D`);
|
|
761
|
+
}
|
|
762
|
+
|
|
763
|
+
const destPath = process.argv[3];
|
|
764
|
+
const sshAuthKeyTarget = '/root/.ssh/authorized_keys';
|
|
765
|
+
if (!fs.existsSync(sshAuthKeyTarget)) shellExec(`touch ${sshAuthKeyTarget}`);
|
|
766
|
+
shellExec(`cat ${destPath}.pub > ${sshAuthKeyTarget}`);
|
|
767
|
+
shellExec(`cat ${destPath} >> ${sshAuthKeyTarget}`);
|
|
768
|
+
|
|
769
|
+
if (!fs.existsSync('/root/.ssh/id_rsa')) shellExec(`touch ${'/root/.ssh/id_rsa'}`);
|
|
770
|
+
shellExec(`cat ${destPath} > ${'/root/.ssh/id_rsa'}`);
|
|
771
|
+
|
|
772
|
+
if (!fs.existsSync('/root/.ssh/id_rsa.pub')) shellExec(`touch ${'/root/.ssh/id_rsa.pub'}`);
|
|
773
|
+
shellExec(`cat ${destPath}.pub > ${'/root/.ssh/id_rsa.pub'}`);
|
|
774
|
+
|
|
775
|
+
shellExec(`chmod 700 /root/.ssh/`);
|
|
776
|
+
for (const file of files) {
|
|
777
|
+
shellExec(`chmod 600 /root/.ssh/${file}`);
|
|
778
|
+
}
|
|
779
|
+
const host = process.argv[4];
|
|
780
|
+
// add key
|
|
781
|
+
shellExec('eval `ssh-agent -s`' + ' && ssh-add /root/.ssh/id_rsa' + ' && ssh-add -l');
|
|
782
|
+
if (host) shellExec(`ssh-keyscan -H ${host} >> ~/.ssh/known_hosts`);
|
|
783
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
784
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
785
|
+
shellExec(`sudo systemctl status ssh`);
|
|
786
|
+
|
|
787
|
+
break;
|
|
788
|
+
}
|
|
789
|
+
|
|
790
|
+
case 'ssh': {
|
|
791
|
+
if (!process.argv.includes('server')) {
|
|
792
|
+
shellExec(`sudo apt update`);
|
|
793
|
+
shellExec(`sudo apt install openssh-server -y`);
|
|
794
|
+
shellExec(`sudo apt install ssh-askpass`);
|
|
795
|
+
}
|
|
796
|
+
shellExec(`sudo systemctl enable ssh`);
|
|
797
|
+
shellExec(`sudo systemctl restart ssh`);
|
|
798
|
+
shellExec(`sudo systemctl status ssh`);
|
|
799
|
+
// sudo service ssh restart
|
|
800
|
+
shellExec(`ip a`);
|
|
801
|
+
|
|
802
|
+
// adduser newuser
|
|
803
|
+
// usermod -aG sudo newuser
|
|
804
|
+
|
|
805
|
+
// ssh -i '/path/to/keyfile' username@server
|
|
806
|
+
|
|
807
|
+
// ssh-keygen -t ed25519 -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
|
808
|
+
|
|
809
|
+
// legacy: ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f $HOME/.ssh/id_rsa
|
|
810
|
+
|
|
811
|
+
// vi .ssh/authorized_keys
|
|
812
|
+
// chmod 700 .ssh
|
|
813
|
+
// chmod 600 authorized_keys
|
|
814
|
+
|
|
815
|
+
// cat id_rsa.pub > .ssh/authorized_keys
|
|
816
|
+
|
|
817
|
+
// add public key to authorized keys
|
|
818
|
+
// cat .ssh/id_ed25519.pub | ssh [sudo username]@[host/ip] 'cat >> .ssh/authorized_keys'
|
|
819
|
+
|
|
820
|
+
// 2. Open /etc/ssh/sshd_config file
|
|
821
|
+
// nano /etc/ssh/sshd_config
|
|
822
|
+
|
|
823
|
+
// 3. add example code to last line of file
|
|
824
|
+
// Match User newuser
|
|
825
|
+
// PasswordAuthentication yes
|
|
826
|
+
|
|
827
|
+
// ssh [sudo username]@[host/ip]
|
|
828
|
+
// open port 22
|
|
829
|
+
|
|
830
|
+
// init ssh agent service
|
|
831
|
+
// eval `ssh-agent -s`
|
|
832
|
+
|
|
833
|
+
// list keys
|
|
834
|
+
// ssh-add -l
|
|
835
|
+
|
|
836
|
+
// add key
|
|
837
|
+
// ssh-add /root/.ssh/id_rsa
|
|
838
|
+
|
|
839
|
+
// remove
|
|
840
|
+
// ssh-add -d /path/to/private/key
|
|
841
|
+
|
|
842
|
+
// remove all
|
|
843
|
+
// ssh-add -D
|
|
844
|
+
|
|
845
|
+
// sshpass -p ${{ secrets.PSWD }} ssh -o StrictHostKeyChecking=no -p 22 ${{ secrets.USER}}@${{ secrets.VPS_IP }} 'cd /home/adam && ./deploy.sh'
|
|
846
|
+
|
|
847
|
+
// copies the public key of your default identity (use -i identity_file for other identities) to the remote host.
|
|
848
|
+
// ssh-copy-id user@hostname.example.com
|
|
849
|
+
// ssh-copy-id "user@hostname.example.com -p <port-number>"
|
|
850
|
+
|
|
851
|
+
break;
|
|
852
|
+
}
|
|
853
|
+
|
|
669
854
|
default:
|
|
670
855
|
break;
|
|
671
856
|
}
|
package/bin/file.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from 'fs-extra';
|
|
|
2
2
|
|
|
3
3
|
import { loggerFactory } from '../src/server/logger.js';
|
|
4
4
|
import { cap, getCapVariableName, getDirname } from '../src/client/components/core/CommonJs.js';
|
|
5
|
-
import { shellExec } from '../src/server/process.js';
|
|
5
|
+
import { shellCd, shellExec } from '../src/server/process.js';
|
|
6
6
|
import walk from 'ignore-walk';
|
|
7
7
|
import { validateTemplatePath } from '../src/server/conf.js';
|
|
8
8
|
|
|
@@ -76,6 +76,22 @@ try {
|
|
|
76
76
|
fs.copySync(`./.vscode`, `../pwa-microservices-template/.vscode`);
|
|
77
77
|
fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
|
|
78
78
|
fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
|
|
79
|
+
|
|
80
|
+
shellCd('../pwa-microservices-template');
|
|
81
|
+
for (const deletePath of ['CHANGELOG.md', 'README.md', 'package-lock.json', 'package.json']) {
|
|
82
|
+
shellExec(`git checkout ${deletePath}`);
|
|
83
|
+
}
|
|
84
|
+
for (const deletePath of [
|
|
85
|
+
'.github/workflows/coverall.yml',
|
|
86
|
+
'.github/workflows/docker-image.yml',
|
|
87
|
+
'.github/workflows/deploy.ssh.yml',
|
|
88
|
+
'.github/workflows/deploy.api-rest.yml',
|
|
89
|
+
'bin/web3.js',
|
|
90
|
+
'src/ipfs.js',
|
|
91
|
+
'src/k8s.js',
|
|
92
|
+
]) {
|
|
93
|
+
fs.removeSync('../pwa-microservices-template/' + deletePath);
|
|
94
|
+
}
|
|
79
95
|
}
|
|
80
96
|
|
|
81
97
|
break;
|