underpost 2.8.522 → 2.8.532

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/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,80 +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
+ }
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/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
- setTimeout(() => {
736
- shellExec(`underpost deploy dd --build-manifest --sync --info-router`);
737
- shellExec(`underpost deploy dd production --build-manifest --sync --info-router`);
738
- shellExec(`node bin/build dd conf`);
739
- shellExec(`git add . && cd ./engine-private && git add .`);
740
- shellExec(`underpost cmt . ci package-pwa-microservices-template 'update version ${newVersion}'`);
741
- shellExec(
742
- `underpost cmt ./engine-private ci package-pwa-microservices-template 'update version ${newVersion}'`,
743
- );
744
- shellExec(`underpost push . underpostnet/engine`);
745
- shellExec(`cd ./engine-private && underpost push . underpostnet/engine-private`);
746
- }, 1000);
747
- }
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`);
748
747
  break;
748
+ }
749
749
 
750
750
  case 'update-authors': {
751
751
  // #### Ordered by first contribution.
@@ -838,7 +838,7 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
838
838
  DefaultConf.client = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.client.json`, 'utf8'));
839
839
  DefaultConf.server = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.server.json`, 'utf8'));
840
840
  DefaultConf.ssr = JSON.parse(fs.readFileSync(`./engine-private/conf/${confName}/conf.ssr.json`, 'utf8'));
841
- 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'));
842
842
 
843
843
  for (const host of Object.keys(DefaultConf.server)) {
844
844
  for (const path of Object.keys(DefaultConf.server[host])) {
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,21 @@ 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('--itc-path', 'Inside container path options')
169
+ .option('--ns <ns-name>', 'Options name space context')
170
+ .option('--pod-name <pod-name>')
169
171
  .description(
170
172
  'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
171
173
  )
172
- .action((...args) => Underpost.script[args[0]](args[1], args[2]));
174
+ .action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
173
175
 
174
176
  program
175
177
  .command('cron')
176
178
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
177
179
  .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')
180
+ .option('--itc', 'Inside container execution context')
179
181
  .option('--init', 'Init cron jobs for cron job default deploy id')
180
182
  .description('Cron jobs management')
181
183
  .action(Underpost.cron.callback);
@@ -184,7 +186,7 @@ program
184
186
  .command('test')
185
187
  .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
186
188
  .description('Manage Test, for default run current underpost default test')
187
- .option('--inside-container', 'Inside container execution context')
189
+ .option('--itc', 'Inside container execution context')
188
190
  .option('--sh', 'Copy to clipboard, container entrypoint shell command')
189
191
  .option('--logs', 'Display container logs')
190
192
  .option('--pod-name <pod-name>')
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.522'
61
+ engine.version: '2.8.532'
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,23 @@
1
+ apiVersion: v1
2
+ kind: PersistentVolume
3
+ metadata:
4
+ name: mongodb-pv
5
+ spec:
6
+ capacity:
7
+ storage: 5Gi
8
+ accessModes:
9
+ - ReadWriteOnce
10
+ hostPath:
11
+ path: /data/mongodb
12
+ ---
13
+ apiVersion: v1
14
+ kind: PersistentVolumeClaim
15
+ metadata:
16
+ name: mongodb-pvc
17
+ spec:
18
+ storageClassName: ''
19
+ accessModes:
20
+ - ReadWriteOnce
21
+ resources:
22
+ requests:
23
+ storage: 5Gi
@@ -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.522",
5
+ "version": "2.8.532",
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,31 @@ 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
+ const podScriptPath = `${options.itcPath && typeof options.itcPath === 'string' ? options.itcPath : '/'}${value
23
+ .split('/')
24
+ .pop()}`;
25
+ const nameSpace = options.ns && typeof options.ns === 'string' ? options.ns : 'default';
26
+ const podMatch = options.podName && typeof options.podName === 'string' ? options.podName : key;
27
+
28
+ if (fs.existsSync(`${value}`)) {
29
+ for (const pod of UnderpostDeploy.API.getPods(podMatch)) {
30
+ shellExec(`sudo kubectl cp ${value} ${nameSpace}/${pod.NAME}:${podScriptPath}`);
31
+ const cmd = `node ${podScriptPath}`;
32
+ shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${cmd}"`);
33
+ }
34
+ } else {
35
+ for (const pod of UnderpostDeploy.API.getPods(podMatch)) {
36
+ shellExec(`sudo kubectl exec -i ${pod.NAME} -- sh -c "${value}"`);
37
+ }
38
+ }
39
+
40
+ return;
41
+ }
18
42
  shellExec(`cd ${npmRoot} && npm run ${key}`);
19
43
  },
20
44
  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
  {
@@ -90,6 +90,8 @@ const MongooseDB = {
90
90
  // sudo yum erase $(rpm -qa | grep mongodb)
91
91
  // remove service
92
92
  // sudo systemctl reset-failed
93
+ // MongoDB 5.0+ requires a CPU with AVX support
94
+ // check: grep avx /proc/cpuinfo
93
95
  }
94
96
  logger.info('install legacy 4.4');
95
97
  shellExec(`wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -`);
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.522';
30
+ static version = 'v2.8.532';
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
  }
@@ -995,7 +995,7 @@ const Cmd = {
995
995
  syncPorts: (deployGroupId) => `node bin/deploy sync-env-port ${deployGroupId}`,
996
996
  cron: (deployList, jobList, name, expression, options) =>
997
997
  `pm2 start ./bin/index.js --no-autorestart --instances 1 --cron "${expression}" --name ${name} -- cron ${
998
- options?.disableKindCluster ? `--disable-kind-cluster ` : ''
998
+ options?.itc ? `--itc ` : ''
999
999
  }${deployList} ${jobList}`,
1000
1000
  };
1001
1001
 
@@ -1073,6 +1073,8 @@ const getNpmRootPath = () =>
1073
1073
  silent: true,
1074
1074
  }).trim();
1075
1075
 
1076
+ const getUnderpostRootPath = () => `${getNpmRootPath()}/underpost`;
1077
+
1076
1078
  const writeEnv = (envPath, envObj) =>
1077
1079
  fs.writeFileSync(
1078
1080
  envPath,
@@ -1118,5 +1120,6 @@ export {
1118
1120
  buildPortProxyRouter,
1119
1121
  splitFileFactory,
1120
1122
  getNpmRootPath,
1123
+ getUnderpostRootPath,
1121
1124
  writeEnv,
1122
1125
  };