underpost 2.8.521 → 2.8.531

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/CHANGELOG.md CHANGED
@@ -4,6 +4,30 @@ 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.8.521](https://github.com/underpostnet/engine/compare/v2.8.51...v2.8.521)
8
+
9
+ > 4 March 2025
10
+
11
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`5878342`](https://github.com/underpostnet/engine/commit/587834206f07a508b3e12ff5b5727c5979c06499)
12
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.521 [`5fada73`](https://github.com/underpostnet/engine/commit/5fada73abf960567f4ecdc01062a987f4d7b4e79)
13
+ - fix(cli): 🐛 run prod img [`94743ef`](https://github.com/underpostnet/engine/commit/94743efe2cf214f0dbcf4db9f0b83ecf50b396f5)
14
+
15
+ #### [v2.8.51](https://github.com/underpostnet/engine/compare/v2.8.46...v2.8.51)
16
+
17
+ > 4 March 2025
18
+
19
+ - ci: ⚙️ add dd-core-development yamls [`a236466`](https://github.com/underpostnet/engine/commit/a2364666f5ddc0e824fa8b68b203bb9e021cca0c)
20
+ - refactor(cli): 📦 cron jobs management refactor [`8c28689`](https://github.com/underpostnet/engine/commit/8c28689cd514ee0e30a38be22ca3dbd292aa3a8a)
21
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`dd3557b`](https://github.com/underpostnet/engine/commit/dd3557bc52724d9231a0a13a320108758b6a84d2)
22
+
23
+ #### [v2.8.46](https://github.com/underpostnet/engine/compare/v2.8.44...v2.8.46)
24
+
25
+ > 28 February 2025
26
+
27
+ - refactor(add cli module directory): 📦 A code change that neither fixes a bug nor adds a feature [`56eea01`](https://github.com/underpostnet/engine/commit/56eea0121489998945c1b2040c3fc53cf6ee295c)
28
+ - refactor(bin): 📦 static API method access [`dcac59e`](https://github.com/underpostnet/engine/commit/dcac59e0cc3fb3e7eeef490d7ded3adb921f4e7a)
29
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.45 [`11795eb`](https://github.com/underpostnet/engine/commit/11795eb2b57243530bfd027774005a83edbdee3b)
30
+
7
31
  #### [v2.8.44](https://github.com/underpostnet/engine/compare/v2.8.42...v2.8.44)
8
32
 
9
33
  > 18 February 2025
package/bin/deploy.js CHANGED
@@ -672,78 +672,79 @@ try {
672
672
  break;
673
673
  }
674
674
 
675
- case 'update-version':
676
- {
677
- const newVersion = process.argv[3];
678
- const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
679
- const { version } = originPackageJson;
680
- originPackageJson.version = newVersion;
681
- fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
682
-
683
- const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
684
- originPackageLockJson.version = newVersion;
685
- originPackageLockJson.packages[''].version = newVersion;
686
- fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
687
-
688
- if (fs.existsSync(`./engine-private/conf`)) {
689
- const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
690
- for (const relativePath of files) {
691
- const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
692
- if (filePah.split('/').pop() === 'package.json') {
693
- const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
694
- originPackage.version = newVersion;
695
- fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
696
- }
697
- if (filePah.split('/').pop() === 'deployment.yaml') {
698
- fs.writeFileSync(
699
- filePah,
700
- fs
701
- .readFileSync(filePah, 'utf8')
702
- .replaceAll(`v${version}`, `v${newVersion}`)
703
- .replaceAll(`engine.version: ${version}`, `engine.version: ${newVersion}`),
704
- 'utf8',
705
- );
706
- }
675
+ case 'version-build': {
676
+ const newVersion = process.argv[3];
677
+ const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
678
+ const { version } = originPackageJson;
679
+ originPackageJson.version = newVersion;
680
+ fs.writeFileSync(`package.json`, JSON.stringify(originPackageJson, null, 4), 'utf8');
681
+
682
+ const originPackageLockJson = JSON.parse(fs.readFileSync(`package-lock.json`, 'utf8'));
683
+ originPackageLockJson.version = newVersion;
684
+ originPackageLockJson.packages[''].version = newVersion;
685
+ fs.writeFileSync(`package-lock.json`, JSON.stringify(originPackageLockJson, null, 4), 'utf8');
686
+
687
+ if (fs.existsSync(`./engine-private/conf`)) {
688
+ const files = await fs.readdir(`./engine-private/conf`, { recursive: true });
689
+ for (const relativePath of files) {
690
+ const filePah = `./engine-private/conf/${relativePath.replaceAll(`\\`, '/')}`;
691
+ if (filePah.split('/').pop() === 'package.json') {
692
+ const originPackage = JSON.parse(fs.readFileSync(filePah, 'utf8'));
693
+ originPackage.version = newVersion;
694
+ fs.writeFileSync(filePah, JSON.stringify(originPackage, null, 4), 'utf8');
695
+ }
696
+ if (filePah.split('/').pop() === 'deployment.yaml') {
697
+ fs.writeFileSync(
698
+ filePah,
699
+ fs
700
+ .readFileSync(filePah, 'utf8')
701
+ .replaceAll(`v${version}`, `v${newVersion}`)
702
+ .replaceAll(`engine.version: ${version}`, `engine.version: ${newVersion}`),
703
+ 'utf8',
704
+ );
707
705
  }
708
706
  }
707
+ }
708
+
709
+ fs.writeFileSync(
710
+ `./docker-compose.yml`,
711
+ fs
712
+ .readFileSync(`./docker-compose.yml`, 'utf8')
713
+ .replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
714
+ 'utf8',
715
+ );
709
716
 
717
+ if (fs.existsSync(`./.github/workflows/docker-image.yml`))
710
718
  fs.writeFileSync(
711
- `./docker-compose.yml`,
719
+ `./.github/workflows/docker-image.yml`,
712
720
  fs
713
- .readFileSync(`./docker-compose.yml`, 'utf8')
714
- .replaceAll(`engine.version: '${version}'`, `engine.version: '${newVersion}'`),
721
+ .readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
722
+ .replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
715
723
  'utf8',
716
724
  );
717
725
 
718
- if (fs.existsSync(`./.github/workflows/docker-image.yml`))
719
- fs.writeFileSync(
720
- `./.github/workflows/docker-image.yml`,
721
- fs
722
- .readFileSync(`./.github/workflows/docker-image.yml`, 'utf8')
723
- .replaceAll(`underpost-engine:v${version}`, `underpost-engine:v${newVersion}`),
724
- 'utf8',
725
- );
726
+ fs.writeFileSync(
727
+ `./src/index.js`,
728
+ fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
729
+ 'utf8',
730
+ );
726
731
 
727
- fs.writeFileSync(
728
- `./src/index.js`,
729
- fs.readFileSync(`./src/index.js`, 'utf8').replaceAll(`${version}`, `${newVersion}`),
730
- 'utf8',
731
- );
732
+ shellExec(`node bin/deploy update-dependencies`);
733
+ shellExec(`auto-changelog`);
734
+ shellExec(`node bin deploy dd --build-manifest --sync --info-router`);
735
+ shellExec(`node bin deploy dd production --build-manifest --sync --info-router`);
736
+ break;
737
+ }
732
738
 
733
- shellExec(`node bin/deploy update-dependencies`);
734
- shellExec(`auto-changelog`);
735
- shellExec(`underpost deploy dd --build-manifest --sync --info-router`);
736
- shellExec(`underpost deploy dd production --build-manifest --sync --info-router`);
737
- shellExec(`node bin/build dd conf`);
738
- shellExec(`git add . && cd ./engine-private && git add .`);
739
- shellExec(`underpost cmt . ci package-pwa-microservices-template 'update version ${newVersion}'`);
740
- shellExec(
741
- `underpost cmt ./engine-private ci package-pwa-microservices-template 'update version ${newVersion}'`,
742
- );
743
- shellExec(`underpost push . underpostnet/engine`);
744
- shellExec(`cd ./engine-private && underpost push . underpostnet/engine-private`);
745
- }
739
+ case 'version-deploy': {
740
+ shellExec(`node bin/build dd conf`);
741
+ shellExec(`git add . && cd ./engine-private && git add .`);
742
+ shellExec(`node bin cmt . ci package-pwa-microservices-template`);
743
+ shellExec(`node bin cmt ./engine-private ci package-pwa-microservices-template`);
744
+ shellExec(`node bin push . underpostnet/engine`);
745
+ shellExec(`cd ./engine-private && node ../bin push . underpostnet/engine-private`);
746
746
  break;
747
+ }
747
748
 
748
749
  case 'update-authors': {
749
750
  // #### Ordered by first contribution.
package/bin/hwt.js CHANGED
@@ -1,19 +1,9 @@
1
1
  import fs from 'fs-extra';
2
- import axios from 'axios';
3
- import https from 'https';
4
2
 
5
- import dotenv from 'dotenv';
6
- import { shellCd, shellExec } from '../src/server/process.js';
7
3
  import { loggerFactory } from '../src/server/logger.js';
8
4
 
9
5
  const logger = loggerFactory(import.meta);
10
6
 
11
- const httpsAgent = new https.Agent({
12
- rejectUnauthorized: false,
13
- });
14
-
15
- axios.defaults.httpsAgent = httpsAgent;
16
-
17
7
  logger.info('argv', process.argv);
18
8
 
19
9
  const [exe, dir, operator, templateId, publicPath] = process.argv;
package/bin/index.js CHANGED
@@ -2,20 +2,18 @@
2
2
 
3
3
  import dotenv from 'dotenv';
4
4
  import { Command } from 'commander';
5
- import { loggerFactory } from '../src/server/logger.js';
6
5
  import Underpost from '../src/index.js';
7
- import { getNpmRootPath, loadConf } from '../src/server/conf.js';
6
+ import { getUnderpostRootPath, loadConf } from '../src/server/conf.js';
8
7
  import fs from 'fs-extra';
9
8
  import { commitData } from '../src/client/components/core/CommonJs.js';
10
9
  import UnderpostScript from '../src/cli/script.js';
11
10
  import UnderpostDB from '../src/cli/db.js';
12
11
  import UnderpostCron from '../src/cli/cron.js';
13
12
 
14
- const npmRoot = getNpmRootPath();
15
- const underpostRoot = `${npmRoot}/underpost/.env`;
16
- fs.existsSync(underpostRoot) ? dotenv.config({ path: underpostRoot, override: true }) : dotenv.config();
17
-
18
- const logger = loggerFactory(import.meta);
13
+ const underpostRootPath = getUnderpostRootPath();
14
+ fs.existsSync(`${underpostRootPath}/.env`)
15
+ ? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
16
+ : dotenv.config();
19
17
 
20
18
  const program = new Command();
21
19
 
@@ -150,7 +148,7 @@ program
150
148
  .command('install')
151
149
  .description('Fast import underpost npm dependencies')
152
150
  .action(() => {
153
- fs.copySync(`${npmRoot}/underpost/node_modules`, './node_modules');
151
+ fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
154
152
  });
155
153
 
156
154
  program
@@ -165,17 +163,20 @@ program
165
163
  .command('script')
166
164
  .argument('operator', `Options: ${Object.keys(UnderpostScript.API)}`)
167
165
  .argument('<script-name>', 'Script name')
168
- .argument('[script-value]', 'Literal command')
166
+ .argument('[script-value]', 'Literal command, or path')
167
+ .option('--itc', 'Inside container execution context')
168
+ .option('--ns <ns-name>', 'Options name space context')
169
+ .option('--pod-name <pod-name>')
169
170
  .description(
170
171
  'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
171
172
  )
172
- .action((...args) => Underpost.script[args[0]](args[1], args[2]));
173
+ .action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
173
174
 
174
175
  program
175
176
  .command('cron')
176
177
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
177
178
  .argument('[job-list]', `Deploy id list, e.g. ${Object.keys(UnderpostCron.JOB)}, for default all available jobs`)
178
- .option('--disable-kind-cluster', 'Disable kind cluster configuration')
179
+ .option('--itc', 'Inside container execution context')
179
180
  .option('--init', 'Init cron jobs for cron job default deploy id')
180
181
  .description('Cron jobs management')
181
182
  .action(Underpost.cron.callback);
@@ -184,7 +185,7 @@ program
184
185
  .command('test')
185
186
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
186
187
  .description('Manage Test, for default run current underpost default test')
187
- .option('--inside-container', 'Inside container execution context')
188
+ .option('--itc', 'Inside container execution context')
188
189
  .option('--sh', 'Copy to clipboard, container entrypoint shell command')
189
190
  .option('--logs', 'Display container logs')
190
191
  .option('--pod-name <pod-name>')
package/bin/util.js CHANGED
@@ -2,8 +2,6 @@ import fs from 'fs-extra';
2
2
  import si from 'systeminformation';
3
3
  import * as dir from 'path';
4
4
  import { svg } from 'font-awesome-assets';
5
- import axios from 'axios';
6
- import https from 'https';
7
5
 
8
6
  import { loggerFactory } from '../src/server/logger.js';
9
7
  import { pbcopy, shellExec } from '../src/server/process.js';
@@ -12,11 +10,6 @@ import { FileFactory } from '../src/api/file/file.service.js';
12
10
  import { faBase64Png, getBufferPngText } from '../src/server/client-icons.js';
13
11
  import keyword_extractor from 'keyword-extractor';
14
12
 
15
- const httpsAgent = new https.Agent({
16
- rejectUnauthorized: false,
17
- });
18
- axios.defaults.httpsAgent = httpsAgent;
19
-
20
13
  const logger = loggerFactory(import.meta);
21
14
 
22
15
  logger.info('argv', process.argv);
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.521'
61
+ engine.version: '2.8.531'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -0,0 +1,7 @@
1
+ ---
2
+ # kubectl apply -k core/.
3
+ apiVersion: kustomize.config.k8s.io/v1beta1
4
+ kind: Kustomization
5
+ resources:
6
+ - pv-pvc.yaml
7
+ - service-deployment.yaml
@@ -0,0 +1,62 @@
1
+ apiVersion: apps/v1
2
+ kind: Deployment
3
+ metadata:
4
+ name: mongodb-deployment
5
+ namespace: default
6
+ spec:
7
+ selector:
8
+ matchLabels:
9
+ app: mongodb
10
+ replicas: 1
11
+ template:
12
+ metadata:
13
+ labels:
14
+ app: mongodb
15
+ spec:
16
+ hostname: mongo
17
+ containers:
18
+ - name: mongodb
19
+ image: docker.io/library/mongo:4.4
20
+ command: ['mongod', '--replSet', 'rs0', '--bind_ip_all']
21
+ # -- bash
22
+ # mongo
23
+ # use admin
24
+ # rs.initiate()
25
+ ports:
26
+ - containerPort: 27017
27
+
28
+ volumeMounts:
29
+ - name: mongo-persistent-storage
30
+ mountPath: /data/db
31
+
32
+ resources:
33
+ requests:
34
+ memory: '500Mi'
35
+ cpu: '500m'
36
+ volumes:
37
+ - name: mongo-persistent-storage
38
+ persistentVolumeClaim:
39
+ claimName: mongodb-pvc
40
+
41
+ ---
42
+ apiVersion: v1
43
+ kind: Service
44
+ metadata:
45
+ name: mongodb-service
46
+ namespace: default
47
+ spec:
48
+ clusterIP: None
49
+ selector:
50
+ app: mongodb
51
+ ports:
52
+ - protocol: TCP
53
+ port: 27017
54
+ # targetPort: 27017
55
+ # type: ClusterIP
56
+
57
+ # rs.initiate();
58
+ # use admin;
59
+ # db.createUser({user: "your_user",pwd: "your_password", roles: [{role: "userAdminAnyDatabase", db: "admin" },{ role: "readWriteAnyDatabase", db: "admin" }]});
60
+ # cfg = rs.conf();
61
+ # cfg.members[0].host = "127.0.0.1:27027";
62
+ # rs.reconfig(cfg);
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.521",
5
+ "version": "2.8.531",
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",
@@ -1,5 +1,5 @@
1
1
  import { timer } from '../client/components/core/CommonJs.js';
2
- import { cliSpinner } from '../server/conf.js';
2
+ import { cliSpinner, getNpmRootPath } from '../server/conf.js';
3
3
  import { loggerFactory } from '../server/logger.js';
4
4
  import { shellExec } from '../server/process.js';
5
5
  import UnderpostDeploy from './deploy.js';
@@ -23,6 +23,8 @@ class UnderpostCluster {
23
23
  nsUse: '',
24
24
  },
25
25
  ) {
26
+ const npmRoot = getNpmRootPath();
27
+ const underpostRoot = `${npmRoot}/underpost`;
26
28
  if (options.reset === true) return await UnderpostCluster.API.reset();
27
29
  if (options.listPods === true) return console.table(UnderpostDeploy.API.getPods(podName ?? undefined));
28
30
 
@@ -72,13 +74,15 @@ class UnderpostCluster {
72
74
  // shellExec(`cp /etc/kubernetes/admin.conf ~/.kube/config`);
73
75
  shellExec(`sudo systemctl restart kubelet`);
74
76
  shellExec(`sudo service docker restart`);
75
- shellExec(`cd ./manifests && kind create cluster --config kind-config.yaml`);
77
+ shellExec(`sudo systemctl enable --now containerd.service`);
78
+ shellExec(`sudo systemctl restart containerd`);
79
+ shellExec(`cd ${underpostRoot}/manifests && kind create cluster --config kind-config.yaml`);
76
80
  shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
77
81
  } else logger.warn('Cluster already initialized');
78
82
 
79
83
  if (options.full || options.valkey) {
80
84
  shellExec(`kubectl delete statefulset service-valkey`);
81
- shellExec(`kubectl apply -k ./manifests/valkey`);
85
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/valkey`);
82
86
  }
83
87
  if (options.full || options.mariadb) {
84
88
  shellExec(
@@ -88,7 +92,7 @@ class UnderpostCluster {
88
92
  `sudo kubectl create secret generic github-secret --from-literal=GITHUB_TOKEN=${process.env.GITHUB_TOKEN}`,
89
93
  );
90
94
  shellExec(`kubectl delete statefulset mariadb-statefulset`);
91
- shellExec(`kubectl apply -k ./manifests/mariadb`);
95
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/mariadb`);
92
96
  }
93
97
  if (options.full || options.mongodb) {
94
98
  shellExec(
@@ -98,7 +102,7 @@ class UnderpostCluster {
98
102
  `sudo kubectl create secret generic mongodb-secret --from-file=username=/home/dd/engine/engine-private/mongodb-username --from-file=password=/home/dd/engine/engine-private/mongodb-password`,
99
103
  );
100
104
  shellExec(`kubectl delete statefulset mongodb`);
101
- shellExec(`kubectl apply -k ./manifests/mongodb`);
105
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/mongodb`);
102
106
 
103
107
  await UnderpostTest.API.podStatusMonitor('mongodb-1');
104
108
 
@@ -135,7 +139,7 @@ class UnderpostCluster {
135
139
 
136
140
  const letsEncName = 'letsencrypt-prod';
137
141
  shellExec(`sudo kubectl delete ClusterIssuer ${letsEncName}`);
138
- shellExec(`sudo kubectl apply -f ./manifests/${letsEncName}.yaml`);
142
+ shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/${letsEncName}.yaml`);
139
143
  }
140
144
  },
141
145
  reset() {
package/src/cli/cron.js CHANGED
@@ -46,7 +46,7 @@ class UnderpostCron {
46
46
  callback: async function (
47
47
  deployList = 'default',
48
48
  jobList = Object.keys(UnderpostCron.JOB),
49
- options = { disableKindCluster: false, init: false },
49
+ options = { itc: false, init: false },
50
50
  ) {
51
51
  if (options.init === true) {
52
52
  await Underpost.test.setUpInfo();
package/src/cli/image.js CHANGED
@@ -54,23 +54,6 @@ class UnderpostImage {
54
54
  {
55
55
  const lamppPublicPath = '/xampp/htdocs/online';
56
56
  shellExec(`sudo mkdir -p ${lamppPublicPath}`);
57
-
58
- {
59
- shellExec(
60
- `cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_0}`,
61
- );
62
-
63
- shellExec(`cd ${lamppPublicPath} && sudo ${process.env.DD_LAMPP_SCRIPT_0}`);
64
-
65
- shellExec(
66
- `sudo sed -i -e "s@define( 'DB_HOST', 'localhost' );@define( 'DB_HOST', '${process.env.MARIADB_HOST}' );@g" ${lamppPublicPath}/${process.env.DD_LAMPP_REPO_0_FOLDER}/wp-config.php`,
67
- );
68
- }
69
- {
70
- shellExec(
71
- `cd ${lamppPublicPath} && git clone https://${process.env.GITHUB_TOKEN}@github.com/${process.env.DD_LAMPP_REPO_1}`,
72
- );
73
- }
74
57
  }
75
58
  break;
76
59
 
package/src/cli/script.js CHANGED
@@ -2,6 +2,7 @@ import { getNpmRootPath } from '../server/conf.js';
2
2
  import { loggerFactory } from '../server/logger.js';
3
3
  import { shellExec } from '../server/process.js';
4
4
  import fs from 'fs-extra';
5
+ import UnderpostDeploy from './deploy.js';
5
6
 
6
7
  const logger = loggerFactory(import.meta);
7
8
 
@@ -13,8 +14,25 @@ class UnderpostScript {
13
14
  packageJson.scripts[key] = value;
14
15
  fs.writeFileSync(`${npmRoot}/package.json`, JSON.stringify(packageJson, null, 4));
15
16
  },
16
- run(key) {
17
+ run(key, value, options) {
17
18
  const npmRoot = `${getNpmRootPath()}/underpost`;
19
+ const packageJson = JSON.parse(fs.readFileSync(`${npmRoot}/package.json`, 'utf8'));
20
+ if (options.itc === true) {
21
+ value = packageJson.scripts[key];
22
+ if (fs.existsSync(`${value}`)) {
23
+ const podScriptPath = `/${value.split('/').pop()}`;
24
+ const nameSpace = options.ns && typeof options.ns === 'string' ? options.ns : 'default';
25
+ const podMatch = options.podName && typeof options.podName === 'string' ? options.podName : key;
26
+
27
+ for (const pod of UnderpostDeploy.API.getPods(podMatch)) {
28
+ shellExec(`sudo kubectl cp ${value} ${nameSpace}/${pod.NAME}:${podScriptPath}`);
29
+ const cmd = `cd / && node ${podScriptPath}`;
30
+ shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${cmd}"`);
31
+ }
32
+ }
33
+
34
+ return;
35
+ }
18
36
  shellExec(`cd ${npmRoot} && npm run ${key}`);
19
37
  },
20
38
  get(key) {
package/src/cli/test.js CHANGED
@@ -29,7 +29,7 @@ class UnderpostTest {
29
29
  actionInitLog();
30
30
  shellExec(`cd ${getNpmRootPath()}/underpost && npm run test`);
31
31
  },
32
- async callback(deployList = '', options = { insideContainer: false, sh: false, logs: false }) {
32
+ async callback(deployList = '', options = { itc: false, sh: false, logs: false }) {
33
33
  if (
34
34
  options.podName &&
35
35
  typeof options.podName === 'string' &&
@@ -50,7 +50,7 @@ class UnderpostTest {
50
50
  for (const _deployId of deployList.split(',')) {
51
51
  const deployId = _deployId.trim();
52
52
  if (!deployId) continue;
53
- if (options.insideContainer === true)
53
+ if (options.itc === true)
54
54
  switch (deployId) {
55
55
  case 'dd-lampp':
56
56
  {
@@ -79,7 +79,19 @@ const MongooseDB = {
79
79
  if (process.argv.includes('rocky')) {
80
80
  // https://github.com/mongodb/mongodb-selinux
81
81
  // https://www.mongodb.com/docs/v7.0/tutorial/install-mongodb-enterprise-on-red-hat/
82
- shellExec(`sudo chown -R mongod:mongod /var/lib/mongo`);
82
+ // https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-red-hat/
83
+ // https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-red-hat/
84
+ // dnf install selinux-policy-devel
85
+ // git clone https://github.com/mongodb/mongodb-selinux
86
+ // cd mongodb-selinux
87
+ // make
88
+ // sudo make install
89
+ // yum list installed | grep mongo
90
+ // sudo yum erase $(rpm -qa | grep mongodb)
91
+ // remove service
92
+ // sudo systemctl reset-failed
93
+ // MongoDB 5.0+ requires a CPU with AVX support
94
+ // check: grep avx /proc/cpuinfo
83
95
  }
84
96
  logger.info('install legacy 4.4');
85
97
  shellExec(`wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -`);
@@ -112,9 +124,13 @@ const MongooseDB = {
112
124
  shellExec(`sudo systemctl unmask mongod`);
113
125
  shellExec(`sudo pkill -f mongod`);
114
126
  shellExec(`sudo systemctl enable mongod.service`);
127
+
115
128
  shellExec(`sudo chown -R mongodb:mongodb /var/lib/mongodb`);
116
129
  shellExec(`sudo chown mongodb:mongodb /tmp/mongodb-27017.sock`);
117
130
 
131
+ shellExec(`sudo chown -R mongod:mongod /var/lib/mongodb`);
132
+ shellExec(`sudo chown mongod:mongod /tmp/mongodb-27017.sock`);
133
+
118
134
  logger.info('run server');
119
135
  shellExec(`sudo service mongod restart`);
120
136
 
package/src/index.js CHANGED
@@ -27,7 +27,7 @@ class Underpost {
27
27
  * @type {String}
28
28
  * @memberof Underpost
29
29
  */
30
- static version = 'v2.8.521';
30
+ static version = 'v2.8.531';
31
31
  /**
32
32
  * Repository cli API
33
33
  * @static
@@ -9,7 +9,7 @@ dotenv.config();
9
9
  const logger = loggerFactory(import.meta);
10
10
 
11
11
  class BackUp {
12
- static callback = async function (deployList, options = { disableKindCluster: false }) {
12
+ static callback = async function (deployList, options = { itc: false }) {
13
13
  if ((!deployList || deployList === 'dd') && fs.existsSync(`./engine-private/deploy/dd.router`))
14
14
  deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
15
15
 
@@ -25,7 +25,7 @@ class BackUp {
25
25
  const deployId = _deployId.trim();
26
26
  if (!deployId) continue;
27
27
 
28
- if (options.disableKindCluster !== true) {
28
+ if (!(options.itc === true)) {
29
29
  shellExec(`underpost db --export ${deployId}`);
30
30
  continue;
31
31
  }
@@ -19,17 +19,8 @@ import { DefaultConf } from '../../conf.js';
19
19
  import read from 'read';
20
20
  import splitFile from 'split-file';
21
21
  import axios from 'axios';
22
- import https from 'https';
23
22
  import { ssrFactory } from './client-formatted.js';
24
23
 
25
- // axios.defaults.baseURL = BASE_URL;
26
-
27
- // const httpsAgent = new https.Agent({
28
- // rejectUnauthorized: false,
29
- // });
30
-
31
- // axios.defaults.httpsAgent = httpsAgent;
32
-
33
24
  colors.enable();
34
25
 
35
26
  dotenv.config();
@@ -1004,7 +995,7 @@ const Cmd = {
1004
995
  syncPorts: (deployGroupId) => `node bin/deploy sync-env-port ${deployGroupId}`,
1005
996
  cron: (deployList, jobList, name, expression, options) =>
1006
997
  `pm2 start ./bin/index.js --no-autorestart --instances 1 --cron "${expression}" --name ${name} -- cron ${
1007
- options?.disableKindCluster ? `--disable-kind-cluster ` : ''
998
+ options?.itc ? `--itc ` : ''
1008
999
  }${deployList} ${jobList}`,
1009
1000
  };
1010
1001
 
@@ -1082,6 +1073,8 @@ const getNpmRootPath = () =>
1082
1073
  silent: true,
1083
1074
  }).trim();
1084
1075
 
1076
+ const getUnderpostRootPath = () => `${getNpmRootPath()}/underpost`;
1077
+
1085
1078
  const writeEnv = (envPath, envObj) =>
1086
1079
  fs.writeFileSync(
1087
1080
  envPath,
@@ -1127,5 +1120,6 @@ export {
1127
1120
  buildPortProxyRouter,
1128
1121
  splitFileFactory,
1129
1122
  getNpmRootPath,
1123
+ getUnderpostRootPath,
1130
1124
  writeEnv,
1131
1125
  };
package/src/server/dns.js CHANGED
@@ -1,17 +1,10 @@
1
1
  import axios from 'axios';
2
2
  import dotenv from 'dotenv';
3
3
  import fs from 'fs';
4
- import https from 'https';
5
4
  import validator from 'validator';
6
5
  import { ip } from './network.js';
7
6
  import { loggerFactory } from './logger.js';
8
- import { shellExec } from './process.js';
9
-
10
- const httpsAgent = new https.Agent({
11
- rejectUnauthorized: false,
12
- });
13
-
14
- axios.defaults.httpsAgent = httpsAgent;
7
+ import UnderpostRootEnv from '../cli/env.js';
15
8
 
16
9
  dotenv.config();
17
10
 
@@ -30,47 +23,47 @@ class Dns {
30
23
  // Forward the router's TCP/UDP ports to the LAN device's IP address
31
24
  for (const _deployId of deployList.split(',')) {
32
25
  const deployId = _deployId.trim();
33
- const privateCronConfPath = `./engine-private/conf/${deployId}/conf.cron.json`;
34
- const confCronPath = fs.existsSync(privateCronConfPath) ? privateCronConfPath : './conf/conf.cron.json';
35
- const confCronData = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
26
+ const privateCronConfPath = `./engine-private/conf/${deployId}/conf.cron.json`;
27
+ const confCronPath = fs.existsSync(privateCronConfPath) ? privateCronConfPath : './conf/conf.cron.json';
28
+ const confCronData = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
36
29
 
37
- let testIp;
30
+ let testIp;
38
31
 
39
- try {
40
- testIp = await ip.public.ipv4();
41
- } catch (error) {
42
- logger.error(error, { testIp, stack: error.stack });
43
- }
44
- const ipFileName = `${deployId}.ip`;
45
- const currentIp = fs.existsSync(`./engine-private/deploy/${ipFileName}`)
46
- ? fs.readFileSync(`./engine-private/deploy/${ipFileName}`, 'utf8')
47
- : undefined;
32
+ try {
33
+ testIp = await ip.public.ipv4();
34
+ } catch (error) {
35
+ logger.error(error, { testIp, stack: error.stack });
36
+ }
37
+
38
+ const currentIp = UnderpostRootEnv.API.get('ip');
48
39
 
49
- if (testIp && typeof testIp === 'string' && validator.isIP(testIp) && currentIp !== testIp) {
50
- logger.info(`new ip`, testIp);
51
- for (const recordType of Object.keys(confCronData.records)) {
52
- switch (recordType) {
53
- case 'A':
54
- for (const dnsProvider of confCronData.records[recordType]) {
55
- if (typeof Dns.services.updateIp[dnsProvider.dns] === 'function')
56
- await Dns.services.updateIp[dnsProvider.dns]({ ...dnsProvider, ip: testIp });
57
- }
58
- break;
40
+ if (testIp && typeof testIp === 'string' && validator.isIP(testIp) && currentIp !== testIp) {
41
+ logger.info(`new ip`, testIp);
42
+ for (const recordType of Object.keys(confCronData.records)) {
43
+ switch (recordType) {
44
+ case 'A':
45
+ for (const dnsProvider of confCronData.records[recordType]) {
46
+ if (typeof Dns.services.updateIp[dnsProvider.dns] === 'function')
47
+ await Dns.services.updateIp[dnsProvider.dns]({ ...dnsProvider, ip: testIp });
48
+ }
49
+ break;
59
50
 
60
- default:
61
- break;
51
+ default:
52
+ break;
53
+ }
62
54
  }
63
- }
64
- try {
65
- const ipUrlTest = `https://${process.env.DEFAULT_DEPLOY_HOST}`;
66
- const response = await axios.get(ipUrlTest);
67
- const verifyIp = response.request.socket.remoteAddress;
68
- logger.info(ipUrlTest + ' IP', verifyIp);
69
- if (verifyIp === testIp) {
70
- fs.writeFileSync(`./engine-private/deploy/${ipFileName}`, testIp, 'utf8');
71
- } else logger.error('ip not updated');
72
- } catch (error) {
73
- logger.error(error), 'ip not updated';
55
+ try {
56
+ const ipUrlTest = `https://${process.env.DEFAULT_DEPLOY_HOST}`;
57
+ const response = await axios.get(ipUrlTest);
58
+ const verifyIp = response.request.socket.remoteAddress;
59
+ logger.info(ipUrlTest + ' verify ip', verifyIp);
60
+ if (verifyIp === testIp) {
61
+ logger.info('ip updated successfully', testIp);
62
+ UnderpostRootEnv.API.set('ip', testIp);
63
+ } else logger.error('ip not updated', testIp);
64
+ } catch (error) {
65
+ logger.error(error, error.stack);
66
+ logger.error('ip not updated', testIp);
74
67
  }
75
68
  }
76
69
  }
@@ -2,16 +2,8 @@ import axios from 'axios';
2
2
  import fs from 'fs';
3
3
  import { loggerFactory } from './logger.js';
4
4
  import dotenv from 'dotenv';
5
- import https from 'https';
6
-
7
5
  dotenv.config();
8
6
 
9
- const httpsAgent = new https.Agent({
10
- rejectUnauthorized: false,
11
- });
12
-
13
- axios.defaults.httpsAgent = httpsAgent;
14
-
15
7
  const logger = loggerFactory(import.meta);
16
8
 
17
9
  const Downloader = (url, fullPath, options = { method: 'get', responseType: 'stream' }) =>
package/test/api.test.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  import axios from 'axios';
4
4
  import dotenv from 'dotenv';
5
- import https from 'https';
6
5
 
7
6
  import { expect } from 'chai';
8
7
  import { loggerFactory } from '../src/server/logger.js';
@@ -20,13 +19,6 @@ const BASE_URL =
20
19
  ? `http://localhost:${PORT}/${process.env.BASE_API}`
21
20
  : `https://www.nexodev.org/api`;
22
21
 
23
- axios.defaults.baseURL = BASE_URL;
24
-
25
- const httpsAgent = new https.Agent({
26
- rejectUnauthorized: false,
27
- });
28
- axios.defaults.httpsAgent = httpsAgent;
29
-
30
22
  describe(`GET 'Test' API Request `, async () => {
31
23
  {
32
24
  const url = `${BASE_URL}/test/youtube-id/?url=https://www.youtube.com/watch?v=o4f42SbyDMk`;
@@ -1,11 +0,0 @@
1
- ---
2
- # kubectl apply -k core/.
3
- apiVersion: kustomize.config.k8s.io/v1beta1
4
- kind: Kustomization
5
- resources:
6
- - underpost-engine-pv-pvc.yaml
7
- - underpost-engine-headless-service.yaml
8
- - underpost-engine-statefulset.yaml
9
- - underpost-engine-backup-pv-pvc.yaml
10
- - underpost-engine-mongodb-backup-cronjob.yaml
11
- - underpost-engine-backup-access.yaml
@@ -1,16 +0,0 @@
1
- apiVersion: v1
2
- kind: Pod
3
- metadata:
4
- name: backup-access
5
- spec:
6
- containers:
7
- - name: busybox
8
- image: busybox
9
- command: ['sh', '-c', 'sleep 3600']
10
- volumeMounts:
11
- - name: backup-storage
12
- mountPath: /backup
13
- volumes:
14
- - name: backup-storage
15
- persistentVolumeClaim:
16
- claimName: backup-pvc
@@ -1,22 +0,0 @@
1
- apiVersion: v1
2
- kind: PersistentVolume
3
- metadata:
4
- name: backup-pv
5
- spec:
6
- capacity:
7
- storage: 5Gi
8
- accessModes:
9
- - ReadWriteOnce
10
- hostPath:
11
- path: /mnt/backup
12
- ---
13
- apiVersion: v1
14
- kind: PersistentVolumeClaim
15
- metadata:
16
- name: backup-pvc
17
- spec:
18
- accessModes:
19
- - ReadWriteOnce
20
- resources:
21
- requests:
22
- storage: 5Gi
@@ -1,10 +0,0 @@
1
- apiVersion: v1
2
- kind: Service
3
- metadata:
4
- name: mongodb-service
5
- spec:
6
- clusterIP: None
7
- selector:
8
- app: mongodb
9
- ports:
10
- - port: 27017
@@ -1,40 +0,0 @@
1
- apiVersion: batch/v1
2
- kind: CronJob
3
- metadata:
4
- name: mongodb-backup
5
- spec:
6
- schedule: '*/5 * * * *' # Runs backup every five minutes
7
- jobTemplate:
8
- spec:
9
- template:
10
- spec:
11
- containers:
12
- - name: mongodump
13
- image: docker.io/library/mongo:latest
14
- command:
15
- - sh
16
- - -c
17
- - |
18
- # Perform backup
19
- mongodump -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --host=mongodb-service --port=27017 --out=/backup/$(date +\%Y-\%m-\%dT\%H-\%M-\%S)
20
- # Remove backups older than 7 days
21
- find /backup -type d -mtime +7 -exec rm -rf {} +
22
- volumeMounts:
23
- - name: backup-storage
24
- mountPath: /backup
25
- env:
26
- - name: MONGO_INITDB_ROOT_USERNAME
27
- valueFrom:
28
- secretKeyRef:
29
- name: mongodb-secret
30
- key: username
31
- - name: MONGO_INITDB_ROOT_PASSWORD
32
- valueFrom:
33
- secretKeyRef:
34
- name: mongodb-secret
35
- key: password
36
- restartPolicy: Never
37
- volumes:
38
- - name: backup-storage
39
- persistentVolumeClaim:
40
- claimName: backup-pvc
@@ -1,26 +0,0 @@
1
- # origin conf: /etc/mongod.conf
2
- apiVersion: v1
3
- kind: ConfigMap
4
- metadata:
5
- name: mongodb-config-file
6
- namespace: default
7
- data:
8
- mongod.conf: |
9
- storage:
10
- dbPath: /data/db
11
- systemLog:
12
- destination: file
13
- logAppend: true
14
- path: /var/log/mongodb/mongod.log
15
- replication:
16
- replSetName: rs0
17
- net:
18
- bindIp: 127.0.0.1
19
- port: 27017
20
- processManagement:
21
- fork: true
22
- setParameter:
23
- enableLocalhostAuthBypass: false
24
- security:
25
- authorization: enabled
26
- keyFile: /etc/mongodb-keyfile
@@ -1,91 +0,0 @@
1
- apiVersion: apps/v1
2
- kind: StatefulSet
3
- metadata:
4
- name: mongodb # Specifies the name of the statefulset
5
- spec:
6
- serviceName: 'mongodb-service' # Specifies the service to use
7
- replicas: 2
8
- selector:
9
- matchLabels:
10
- app: mongodb
11
- template:
12
- metadata:
13
- labels:
14
- app: mongodb
15
- spec:
16
- containers:
17
- - name: mongodb
18
- image: docker.io/library/mongo:latest
19
- command:
20
- - mongod
21
- - '--replSet'
22
- - 'rs0'
23
- # - '--config'
24
- # - '-f'
25
- # - '/etc/mongod.conf'
26
- # - '--auth'
27
- # - '--clusterAuthMode'
28
- # - 'keyFile'
29
- # - '--keyFile'
30
- # - '/etc/mongodb-keyfile'
31
- # - '--interleave'
32
- # - 'all'
33
- # - '--wiredTigerCacheSizeGB'
34
- # - '0.25'
35
- # - '--setParameter'
36
- # - 'authenticationMechanisms=SCRAM-SHA-1'
37
- # - '--fork'
38
- - '--logpath'
39
- - '/var/log/mongodb/mongod.log'
40
- - '--bind_ip_all'
41
- ports:
42
- - containerPort: 27017
43
- volumeMounts:
44
- - name: mongodb-storage
45
- mountPath: /data/db
46
- - name: keyfile
47
- mountPath: /etc/mongodb-keyfile
48
- readOnly: true
49
- # - name: mongodb-configuration-file
50
- # mountPath: /etc/mongod.conf
51
- # subPath: mongod.conf
52
- # readOnly: true
53
- # - name: mongodb-config
54
- # mountPath: /config
55
- env:
56
- - name: MONGO_INITDB_ROOT_USERNAME
57
- valueFrom:
58
- secretKeyRef:
59
- name: mongodb-secret
60
- key: username
61
- - name: MONGO_INITDB_ROOT_PASSWORD
62
- valueFrom:
63
- secretKeyRef:
64
- name: mongodb-secret
65
- key: password
66
- resources:
67
- requests:
68
- cpu: '100m'
69
- memory: '256Mi'
70
- limits:
71
- cpu: '500m'
72
- memory: '512Mi'
73
- volumes:
74
- - name: keyfile
75
- secret:
76
- secretName: mongodb-keyfile
77
- defaultMode: 0400
78
- # - name: mongodb-configuration-file
79
- # configMap:
80
- # name: mongodb-config-file
81
- # - name: mongodb-config
82
- # configMap:
83
- # name: mongodb-config
84
- volumeClaimTemplates:
85
- - metadata:
86
- name: mongodb-storage
87
- spec:
88
- accessModes: ['ReadWriteOnce']
89
- resources:
90
- requests:
91
- storage: 5Gi