underpost 2.8.51 → 2.8.55

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.
@@ -42,6 +42,7 @@
42
42
  "Itemledger",
43
43
  "jsonld",
44
44
  "lampp",
45
+ "letsencrypt",
45
46
  "loadingio",
46
47
  "Longname",
47
48
  "metanarrative",
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/build.js CHANGED
@@ -20,11 +20,15 @@ const logger = loggerFactory(import.meta);
20
20
  const confName = process.argv[2];
21
21
  const basePath = '../pwa-microservices-template';
22
22
  const repoName = `engine-${confName.split('dd-')[1]}`;
23
+ const deployList = (confName === 'dd' ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8') : confName).split(
24
+ ',',
25
+ );
23
26
 
24
27
  logger.info('', {
25
28
  confName,
26
29
  repoName,
27
30
  basePath,
31
+ deployList,
28
32
  });
29
33
 
30
34
  if (process.argv.includes('clean')) {
@@ -35,10 +39,7 @@ if (process.argv.includes('clean')) {
35
39
  }
36
40
 
37
41
  if (process.argv.includes('conf')) {
38
- for (const _confName of (confName === 'dd'
39
- ? fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
40
- : confName
41
- ).split(',')) {
42
+ for (const _confName of deployList) {
42
43
  const _repoName = `engine-${_confName.split('dd-')[1]}`;
43
44
  const privateRepoName = `${_repoName}-private`;
44
45
  const privateGitUri = `${process.env.GITHUB_USERNAME}/${privateRepoName}`;
@@ -58,6 +59,12 @@ if (process.argv.includes('conf')) {
58
59
  if (replica.match(_confName))
59
60
  fs.copySync(`./engine-private/replica/${replica}`, `../${privateRepoName}/replica/${replica}`);
60
61
  }
62
+ if (fs.existsSync(`./engine-private/itc-scripts`)) {
63
+ const itcScripts = await fs.readdir(`./engine-private/itc-scripts`);
64
+ for (const itcScript of itcScripts)
65
+ if (itcScript.match(_confName))
66
+ fs.copySync(`./engine-private/itc-scripts/${itcScript}`, `../${privateRepoName}/itc-scripts/${itcScript}`);
67
+ }
61
68
  shellExec(
62
69
  `cd ../${privateRepoName}` +
63
70
  ` && git add .` +
@@ -68,6 +75,13 @@ if (process.argv.includes('conf')) {
68
75
  process.exit(0);
69
76
  }
70
77
 
78
+ if (confName === 'dd') {
79
+ for (const _confName of deployList) {
80
+ shellExec(`node bin/build ${_confName}`);
81
+ }
82
+ process.exit(0);
83
+ }
84
+
71
85
  const { DefaultConf } = await import(`../conf.${confName}.js`);
72
86
 
73
87
  {
@@ -133,6 +147,8 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
133
147
  }
134
148
  }
135
149
 
150
+ shellExec(`node bin/deploy update-default-conf ${confName}`);
151
+
136
152
  fs.copyFileSync(`./conf.${confName}.js`, `${basePath}/conf.js`);
137
153
  fs.copyFileSync(
138
154
  `./.github/workflows/engine.${confName.split('dd-')[1]}.ci.yml`,
package/bin/deploy.js CHANGED
@@ -672,68 +672,80 @@ 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
+ }
709
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
+ );
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/build dd`);
735
+ shellExec(`node bin deploy dd --build-manifest --sync --info-router`);
736
+ shellExec(`node bin deploy dd production --build-manifest --sync --info-router`);
737
+ break;
738
+ }
732
739
 
733
- shellExec(`node bin/deploy update-dependencies`);
734
- shellExec(`auto-changelog`);
735
- }
740
+ case 'version-deploy': {
741
+ shellExec(`node bin/build dd conf`);
742
+ shellExec(`git add . && cd ./engine-private && git add .`);
743
+ shellExec(`node bin cmt . ci package-pwa-microservices-template`);
744
+ shellExec(`node bin cmt ./engine-private ci package-pwa-microservices-template`);
745
+ shellExec(`node bin push . underpostnet/engine`);
746
+ shellExec(`cd ./engine-private && node ../bin push . underpostnet/engine-private`);
736
747
  break;
748
+ }
737
749
 
738
750
  case 'update-authors': {
739
751
  // #### Ordered by first contribution.
@@ -826,7 +838,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
826
838
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
827
839
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
828
840
  DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
829
- DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
841
+ // DefaultConf.cron = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.cron.json`, 'utf8'));
830
842
 
831
843
  for (const host of Object.keys(DefaultConf.server)) {
832
844
  for (const path of Object.keys(DefaultConf.server[host])) {
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
 
@@ -83,18 +81,18 @@ program
83
81
 
84
82
  program
85
83
  .command('cluster')
84
+ .argument('[pod-name]', 'Optional pod name filter')
86
85
  .option('--reset', `Delete all clusters and prune all data and caches`)
87
86
  .option('--mariadb', 'Init with mariadb statefulset')
88
87
  .option('--mongodb', 'Init with mongodb statefulset')
89
88
  .option('--valkey', 'Init with valkey service')
90
89
  .option('--contour', 'Init with project contour base HTTPProxy and envoy')
90
+ .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
91
91
  .option('--info', 'Get all kinds objects deployed')
92
92
  .option('--full', 'Init with all statefulsets and services available')
93
93
  .option('--ns-use <ns-name>', 'Switches current context to namespace')
94
- .action((...args) => {
95
- if (args[0].reset) return Underpost.cluster.reset();
96
- return Underpost.cluster.init(args[0]);
97
- })
94
+ .option('--list-pods', 'Display list pods information')
95
+ .action(Underpost.cluster.init)
98
96
  .description('Manage cluster, for default initialization base kind cluster');
99
97
 
100
98
  program
@@ -104,6 +102,8 @@ program
104
102
  .option('--remove', 'Delete deployments and services')
105
103
  .option('--sync', 'Sync deployments env, ports, and replicas')
106
104
  .option('--info-router', 'Display router structure')
105
+ .option('--expose', 'Expose service match deploy-list')
106
+ .option('--info-util', 'Display kubectl util management commands')
107
107
  .option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
108
108
  .description('Manage deployment, for default deploy development pods')
109
109
  .action(Underpost.deploy.callback);
@@ -136,7 +136,8 @@ program
136
136
  .argument('<deploy-id>', 'Deploy configuration id')
137
137
  .argument('[env]', 'Optional environment, for default is development')
138
138
  .argument('[path]', 'Absolute or relative directory, for default is current')
139
- .option('--image-archive', 'Only load tar image from /images')
139
+ .option('--image-archive', 'Only load tar image from ./images')
140
+ .option('--podman-save', 'Save image from podman to ./images')
140
141
  .description('Build image from Dockerfile')
141
142
  .action(Underpost.image.dockerfile.build);
142
143
 
@@ -149,7 +150,7 @@ program
149
150
  .command('install')
150
151
  .description('Fast import underpost npm dependencies')
151
152
  .action(() => {
152
- fs.copySync(`${npmRoot}/underpost/node_modules`, './node_modules');
153
+ fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
153
154
  });
154
155
 
155
156
  program
@@ -164,17 +165,21 @@ program
164
165
  .command('script')
165
166
  .argument('operator', `Options: ${Object.keys(UnderpostScript.API)}`)
166
167
  .argument('<script-name>', 'Script name')
167
- .argument('[script-value]', 'Literal command')
168
+ .argument('[script-value]', 'Literal command, or path')
169
+ .option('--itc', 'Inside container execution context')
170
+ .option('--itc-path', 'Inside container path options')
171
+ .option('--ns <ns-name>', 'Options name space context')
172
+ .option('--pod-name <pod-name>')
168
173
  .description(
169
174
  'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
170
175
  )
171
- .action((...args) => Underpost.script[args[0]](args[1], args[2]));
176
+ .action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
172
177
 
173
178
  program
174
179
  .command('cron')
175
180
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
176
181
  .argument('[job-list]', `Deploy id list, e.g. ${Object.keys(UnderpostCron.JOB)}, for default all available jobs`)
177
- .option('--disable-kind-cluster', 'Disable kind cluster configuration')
182
+ .option('--itc', 'Inside container execution context')
178
183
  .option('--init', 'Init cron jobs for cron job default deploy id')
179
184
  .description('Cron jobs management')
180
185
  .action(Underpost.cron.callback);
@@ -183,9 +188,11 @@ program
183
188
  .command('test')
184
189
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
185
190
  .description('Manage Test, for default run current underpost default test')
186
- .option('--inside-container', 'Inside container execution context')
191
+ .option('--itc', 'Inside container execution context')
187
192
  .option('--sh', 'Copy to clipboard, container entrypoint shell command')
188
193
  .option('--logs', 'Display container logs')
194
+ .option('--pod-name <pod-name>')
195
+ .option('--pod-status <pod-status>')
189
196
  .action(Underpost.test.callback);
190
197
 
191
198
  program.parse();
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);
package/conf.js CHANGED
@@ -179,9 +179,7 @@ const DefaultConf = /**/ {
179
179
  },
180
180
  },
181
181
  cron: {
182
- ipDaemon: { ip: null },
183
182
  records: { A: [{ host: 'example.com', dns: 'dondominio', api_key: '???', user: '???' }] },
184
- backups: [{ deployGroupId: 'default-group' }],
185
183
  jobs: { dns: { expression: '* * * * *', enabled: true }, backups: { expression: '0 1 * * *', enabled: true } },
186
184
  },
187
185
  }; /**/
@@ -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.51'
61
+ engine.version: '2.8.55'
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,63 @@
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
+ # rs.initiate({ _id: "rs0", members: [ { _id: 0, host: "127.0.0.1:27017" } ] })
60
+ # db.createUser({user: "your_user",pwd: "your_password", roles: [{role: "userAdminAnyDatabase", db: "admin" },{ role: "readWriteAnyDatabase", db: "admin" }]});
61
+ # cfg = rs.conf();
62
+ # cfg.members[0].host = "127.0.0.1:27027";
63
+ # 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.51",
5
+ "version": "2.8.55",
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",
@@ -10,6 +10,7 @@
10
10
  "pm2": "env-cmd -f .env.production pm2 start src/server.js --node-args=\"--max-old-space-size=8192\" --name engine",
11
11
  "dev": "env-cmd -f .env.development node src/client.dev default",
12
12
  "dev-img": "env-cmd -f .env.development node src/server",
13
+ "prod-img": "env-cmd -f .env.production node src/server",
13
14
  "dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
14
15
  "dev-client": "env-cmd -f .env.development node src/client.dev",
15
16
  "proxy": "node src/proxy proxy",
@@ -1,13 +1,33 @@
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
+ import UnderpostDeploy from './deploy.js';
6
+ import UnderpostTest from './test.js';
5
7
 
6
8
  const logger = loggerFactory(import.meta);
7
9
 
8
10
  class UnderpostCluster {
9
11
  static API = {
10
- async init(options = { valkey: false, mariadb: false, valkey: false, full: false, info: false, nsUse: '' }) {
12
+ async init(
13
+ podName,
14
+ options = {
15
+ valkey: false,
16
+ mariadb: false,
17
+ valkey: false,
18
+ full: false,
19
+ info: false,
20
+ certManager: false,
21
+ listPods: false,
22
+ reset: false,
23
+ nsUse: '',
24
+ },
25
+ ) {
26
+ const npmRoot = getNpmRootPath();
27
+ const underpostRoot = `${npmRoot}/underpost`;
28
+ if (options.reset === true) return await UnderpostCluster.API.reset();
29
+ if (options.listPods === true) return console.table(UnderpostDeploy.API.get(podName ?? undefined));
30
+
11
31
  if (options.nsUse) {
12
32
  shellExec(`kubectl config set-context --current --namespace=${options.nsUse}`);
13
33
  return;
@@ -40,6 +60,7 @@ class UnderpostCluster {
40
60
  logger.info('----------------------------------------------------------------');
41
61
  shellExec(`kubectl get secrets --all-namespaces -o wide`);
42
62
  shellExec(`docker secret ls`);
63
+ shellExec(`kubectl get crd --all-namespaces -o wide`);
43
64
  return;
44
65
  }
45
66
  const testClusterInit = shellExec(`kubectl get pods --all-namespaces -o wide`, {
@@ -53,13 +74,15 @@ class UnderpostCluster {
53
74
  // shellExec(`cp /etc/kubernetes/admin.conf ~/.kube/config`);
54
75
  shellExec(`sudo systemctl restart kubelet`);
55
76
  shellExec(`sudo service docker restart`);
56
- 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`);
57
80
  shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
58
81
  } else logger.warn('Cluster already initialized');
59
82
 
60
83
  if (options.full || options.valkey) {
61
84
  shellExec(`kubectl delete statefulset service-valkey`);
62
- shellExec(`kubectl apply -k ./manifests/valkey`);
85
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/valkey`);
63
86
  }
64
87
  if (options.full || options.mariadb) {
65
88
  shellExec(
@@ -69,7 +92,7 @@ class UnderpostCluster {
69
92
  `sudo kubectl create secret generic github-secret --from-literal=GITHUB_TOKEN=${process.env.GITHUB_TOKEN}`,
70
93
  );
71
94
  shellExec(`kubectl delete statefulset mariadb-statefulset`);
72
- shellExec(`kubectl apply -k ./manifests/mariadb`);
95
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/mariadb`);
73
96
  }
74
97
  if (options.full || options.mongodb) {
75
98
  shellExec(
@@ -79,27 +102,9 @@ class UnderpostCluster {
79
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`,
80
103
  );
81
104
  shellExec(`kubectl delete statefulset mongodb`);
82
- shellExec(`kubectl apply -k ./manifests/mongodb`);
83
-
84
- await new Promise(async (resolve) => {
85
- cliSpinner(3000, `[cluster.js] `, ` Load mongodb instance`, 'yellow', 'material');
86
- await timer(3000);
105
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/mongodb`);
87
106
 
88
- const monitor = async () => {
89
- cliSpinner(1000, `[cluster.js] `, ` Load mongodb instance`, 'yellow', 'material');
90
- await timer(1000);
91
- if (
92
- shellExec(`kubectl get pods --all-namespaces -o wide`, {
93
- silent: true,
94
- stdout: true,
95
- disableLog: true,
96
- }).match(`mongodb-1 1/1 Running`)
97
- )
98
- return resolve();
99
- return monitor();
100
- };
101
- await monitor();
102
- });
107
+ await UnderpostTest.API.podStatusMonitor('mongodb-1');
103
108
 
104
109
  const mongoConfig = {
105
110
  _id: 'rs0',
@@ -119,6 +124,23 @@ class UnderpostCluster {
119
124
 
120
125
  if (options.full || options.contour)
121
126
  shellExec(`kubectl apply -f https://projectcontour.io/quickstart/contour.yaml`);
127
+
128
+ if (options.full || options.certManager) {
129
+ if (!UnderpostDeploy.API.get('cert-manager').find((p) => p.STATUS === 'Running')) {
130
+ shellExec(`helm repo add jetstack https://charts.jetstack.io --force-update`);
131
+ shellExec(
132
+ `helm install cert-manager jetstack/cert-manager \
133
+ --namespace cert-manager \
134
+ --create-namespace \
135
+ --version v1.17.0 \
136
+ --set crds.enabled=true`,
137
+ );
138
+ }
139
+
140
+ const letsEncName = 'letsencrypt-prod';
141
+ shellExec(`sudo kubectl delete ClusterIssuer ${letsEncName}`);
142
+ shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/${letsEncName}.yaml`);
143
+ }
122
144
  },
123
145
  reset() {
124
146
  shellExec(`kind get clusters | xargs -t -n1 kind delete cluster --name`);
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();