underpost 2.8.873 → 2.8.875

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/README.md CHANGED
@@ -49,13 +49,15 @@
49
49
 
50
50
 
51
51
 
52
+
53
+
52
54
 
53
55
 
54
56
 
55
57
  <!-- badges -->
56
58
 
57
59
 
58
- [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.873)](https://socket.dev/npm/package/underpost/overview/2.8.873) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
60
+ [![Node.js CI](https://github.com/underpostnet/engine/actions/workflows/docker-image.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [![Test](https://github.com/underpostnet/engine/actions/workflows/coverall.ci.yml/badge.svg?branch=master)](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [![Downloads](https://img.shields.io/npm/dm/underpost.svg)](https://www.npmjs.com/package/underpost) [![Socket Badge](https://socket.dev/api/badge/npm/package/underpost/2.8.875)](https://socket.dev/npm/package/underpost/overview/2.8.875) [![Coverage Status](https://coveralls.io/repos/github/underpostnet/engine/badge.svg?branch=master)](https://coveralls.io/github/underpostnet/engine?branch=master) [![Version](https://img.shields.io/npm/v/underpost.svg)](https://www.npmjs.org/package/underpost) [![License](https://img.shields.io/npm/l/underpost.svg)](https://www.npmjs.com/package/underpost)
59
61
 
60
62
 
61
63
  <!-- end-badges -->
@@ -93,6 +95,8 @@
93
95
 
94
96
 
95
97
 
98
+
99
+
96
100
 
97
101
 
98
102
 
@@ -140,7 +144,7 @@ Run dev client server
140
144
  npm run dev
141
145
  ```
142
146
  <!-- -->
143
- ## underpost ci/cd cli v2.8.873
147
+ ## underpost ci/cd cli v2.8.875
144
148
 
145
149
  ### Usage: `underpost [options] [command]`
146
150
  ```
package/bin/deploy.js CHANGED
@@ -368,6 +368,8 @@ try {
368
368
  }
369
369
 
370
370
  case 'version-build': {
371
+ shellCd(`/home/dd/engine`);
372
+ shellExec(`node bin/deploy clean-core-repo`);
371
373
  shellExec(`node bin run kill 4001`);
372
374
  shellExec(`node bin run kill 4002`);
373
375
  shellExec(`node bin run kill 4003`);
@@ -384,8 +386,8 @@ try {
384
386
  logger.error('Test template runner result failed');
385
387
  break;
386
388
  }
387
- shellExec(`node bin/deploy clean-core-repo`);
388
389
  shellCd(`/home/dd/engine`);
390
+ shellExec(`node bin/deploy clean-core-repo`);
389
391
  const originPackageJson = JSON.parse(fs.readFileSync(`package.json`, 'utf8'));
390
392
  const newVersion = process.argv[3] ?? originPackageJson.version;
391
393
  const node = process.argv[4] ?? 'kind-control-plane';
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.873
1
+ ## underpost ci/cd cli v2.8.875
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -291,6 +291,8 @@ Options:
291
291
  management commands.
292
292
  --cert Resets TLS/SSL certificate secrets for
293
293
  deployments.
294
+ --cert-hosts <hosts> Resets TLS/SSL certificate secrets for
295
+ specified hosts.
294
296
  --node <node> Sets optional node for deployment
295
297
  operations.
296
298
  --build-manifest Builds Kubernetes YAML manifests, including
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-default-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.873
20
+ image: localhost/rockylinux9-underpost:v2.8.875
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-default-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.873
103
+ image: localhost/rockylinux9-underpost:v2.8.875
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-test-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.873
20
+ image: localhost/rockylinux9-underpost:v2.8.875
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "96294Ki"
@@ -66,6 +66,24 @@ spec:
66
66
  protocol: UDP
67
67
  port: 4022
68
68
  targetPort: 4022
69
+
70
+ - name: 'tcp-4023'
71
+ protocol: TCP
72
+ port: 4023
73
+ targetPort: 4023
74
+ - name: 'udp-4023'
75
+ protocol: UDP
76
+ port: 4023
77
+ targetPort: 4023
78
+
79
+ - name: 'tcp-4024'
80
+ protocol: TCP
81
+ port: 4024
82
+ targetPort: 4024
83
+ - name: 'udp-4024'
84
+ protocol: UDP
85
+ port: 4024
86
+ targetPort: 4024
69
87
  type: LoadBalancer
70
88
  ---
71
89
  apiVersion: apps/v1
@@ -86,7 +104,7 @@ spec:
86
104
  spec:
87
105
  containers:
88
106
  - name: dd-test-development-green
89
- image: localhost/rockylinux9-underpost:v2.8.873
107
+ image: localhost/rockylinux9-underpost:v2.8.875
90
108
  # resources:
91
109
  # requests:
92
110
  # memory: "96294Ki"
@@ -135,4 +153,22 @@ spec:
135
153
  protocol: UDP
136
154
  port: 4022
137
155
  targetPort: 4022
156
+
157
+ - name: 'tcp-4023'
158
+ protocol: TCP
159
+ port: 4023
160
+ targetPort: 4023
161
+ - name: 'udp-4023'
162
+ protocol: UDP
163
+ port: 4023
164
+ targetPort: 4023
165
+
166
+ - name: 'tcp-4024'
167
+ protocol: TCP
168
+ port: 4024
169
+ targetPort: 4024
170
+ - name: 'udp-4024'
171
+ protocol: UDP
172
+ port: 4024
173
+ targetPort: 4024
138
174
  type: LoadBalancer
@@ -23,4 +23,29 @@ spec:
23
23
  - name: dd-test-development-blue-service
24
24
  port: 4022
25
25
  weight: 100
26
+
27
+ ---
28
+ apiVersion: projectcontour.io/v1
29
+ kind: HTTPProxy
30
+ metadata:
31
+ name: stagging.nexodev.org
32
+ spec:
33
+ virtualhost:
34
+ fqdn: stagging.nexodev.org
35
+ routes:
36
+ - conditions:
37
+ - prefix: /
38
+ enableWebsockets: true
39
+ services:
40
+ - name: dd-test-development-blue-service
41
+ port: 4023
42
+ weight: 100
43
+
44
+ - conditions:
45
+ - prefix: /peer
46
+ enableWebsockets: true
47
+ services:
48
+ - name: dd-test-development-blue-service
49
+ port: 4024
50
+ weight: 100
26
51
 
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.873",
5
+ "version": "2.8.875",
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",
@@ -48,7 +48,9 @@ const UserRouter = (options) => {
48
48
  check: fs.readFileSync(`./src/client/public/default/assets/mailer/api-user-check.png`),
49
49
  },
50
50
  header: (res) => {
51
- res.set('Content-Type', 'image/png');
51
+ res.header('Access-Control-Allow-Origin', '*');
52
+ res.header('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept, Authorization');
53
+ res.header('Content-Type', 'image/png');
52
54
  },
53
55
  };
54
56
 
@@ -453,6 +453,10 @@ const UserService = {
453
453
  const user = await User.findOne({
454
454
  email: payload.email,
455
455
  });
456
+ if (process.env.NODE_ENV === 'development') {
457
+ logger.warn('Only production check image token request on mailer GET /user/recover, set fallback timeout');
458
+ user.recoverTimeOut = new Date(+new Date() + 1000 * 60 * 15);
459
+ }
456
460
  if (user && new Date().getTime() < new Date(user.recoverTimeOut).getTime()) {
457
461
  const validatePassword = validatePasswordMiddleware(req.body.password);
458
462
  if (validatePassword.status === 'error') throw new Error(validatePassword.message);
package/src/cli/deploy.js CHANGED
@@ -12,7 +12,6 @@ import { loggerFactory } from '../server/logger.js';
12
12
  import { shellExec } from '../server/process.js';
13
13
  import fs from 'fs-extra';
14
14
  import dotenv from 'dotenv';
15
- import { DataBaseProvider } from '../db/DataBaseProvider.js';
16
15
  import UnderpostRootEnv from './env.js';
17
16
  import UnderpostCluster from './cluster.js';
18
17
  import Underpost from '../index.js';
@@ -155,21 +154,7 @@ ${UnderpostDeploy.API.deploymentYamlPartsFactory({
155
154
  let secretYaml = '';
156
155
 
157
156
  for (const host of Object.keys(confServer)) {
158
- if (env === 'production')
159
- secretYaml += `
160
- ---
161
- apiVersion: cert-manager.io/v1
162
- kind: Certificate
163
- metadata:
164
- name: ${host}
165
- spec:
166
- commonName: ${host}
167
- dnsNames:
168
- - ${host}
169
- issuerRef:
170
- name: letsencrypt-prod
171
- kind: ClusterIssuer
172
- secretName: ${host}`;
157
+ if (env === 'production') secretYaml += UnderpostDeploy.API.buildCertManagerCertificate({ host });
173
158
 
174
159
  const pathPortAssignment = pathPortAssignmentData[host];
175
160
  // logger.info('', { host, pathPortAssignment });
@@ -223,6 +208,22 @@ spec:
223
208
  }
224
209
  }
225
210
  },
211
+ buildCertManagerCertificate({ host }) {
212
+ return `
213
+ ---
214
+ apiVersion: cert-manager.io/v1
215
+ kind: Certificate
216
+ metadata:
217
+ name: ${host}
218
+ spec:
219
+ commonName: ${host}
220
+ dnsNames:
221
+ - ${host}
222
+ issuerRef:
223
+ name: letsencrypt-prod
224
+ kind: ClusterIssuer
225
+ secretName: ${host}`;
226
+ },
226
227
  getCurrentTraffic(deployId) {
227
228
  // kubectl get deploy,sts,svc,configmap,secret -n default -o yaml --export > default.yaml
228
229
  const hostTest = Object.keys(
@@ -232,7 +233,7 @@ spec:
232
233
  return info.match('blue') ? 'blue' : info.match('green') ? 'green' : null;
233
234
  },
234
235
  async callback(
235
- deployList = 'default',
236
+ deployList = '',
236
237
  env = 'development',
237
238
  options = {
238
239
  remove: false,
@@ -242,6 +243,7 @@ spec:
242
243
  infoUtil: false,
243
244
  expose: false,
244
245
  cert: false,
246
+ certHosts: '',
245
247
  versions: '',
246
248
  image: '',
247
249
  traffic: '',
@@ -305,6 +307,14 @@ docker login nvcr.io
305
307
  Username: $oauthtoken
306
308
  Password: <Your Key>
307
309
  `);
310
+ if (!deployList && options.certHosts) {
311
+ for (const host of options.certHosts.split(',')) {
312
+ shellExec(`sudo kubectl apply -f - <<EOF
313
+ ${UnderpostDeploy.API.buildCertManagerCertificate({ host })}
314
+ EOF`);
315
+ }
316
+ return;
317
+ } else if (!deployList) deployList = 'dd-default';
308
318
  if (deployList === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`))
309
319
  deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
310
320
  if (options.infoTraffic === true) {
@@ -361,7 +371,8 @@ Password: <Your Key>
361
371
  const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'));
362
372
  for (const host of Object.keys(confServer)) {
363
373
  shellExec(`sudo kubectl delete HTTPProxy ${host}`);
364
- if (env === 'production' && options.cert === true) shellExec(`sudo kubectl delete Certificate ${host}`);
374
+ if (UnderpostDeploy.API.isValidTLSContext({ host, env, options }))
375
+ shellExec(`sudo kubectl delete Certificate ${host}`);
365
376
  if (!options.remove === true && env === 'development') etcHosts.push(host);
366
377
  }
367
378
 
@@ -373,7 +384,7 @@ Password: <Your Key>
373
384
  if (!options.remove === true) {
374
385
  if (!options.disableUpdateDeployment) shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
375
386
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
376
- if (env === 'production' && options.cert === true)
387
+ if (UnderpostDeploy.API.isValidTLSContext({ host, env, options }))
377
388
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
378
389
  }
379
390
  }
@@ -458,7 +469,11 @@ Password: <Your Key>
458
469
  notReadyPods.push(pod);
459
470
  }
460
471
  }
461
- return { ready: notReadyPods.length === 0, notReadyPods, readyPods };
472
+ return {
473
+ ready: pods.length > 0 && notReadyPods.length === 0,
474
+ notReadyPods,
475
+ readyPods,
476
+ };
462
477
  },
463
478
  configMap(env) {
464
479
  shellExec(`kubectl delete configmap underpost-config`);
@@ -482,6 +497,10 @@ Password: <Your Key>
482
497
  fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
483
498
  return { renderHosts };
484
499
  },
500
+ isValidTLSContext: ({ host, env, options }) =>
501
+ env === 'production' &&
502
+ options.cert === true &&
503
+ (!options.certHosts || options.certHosts.split(',').includes(host)),
485
504
  };
486
505
  }
487
506
 
package/src/cli/index.js CHANGED
@@ -158,6 +158,7 @@ program
158
158
  .option('--expose', 'Exposes services matching the provided deployment ID list.')
159
159
  .option('--info-util', 'Displays useful `kubectl` utility management commands.')
160
160
  .option('--cert', 'Resets TLS/SSL certificate secrets for deployments.')
161
+ .option('--cert-hosts <hosts>', 'Resets TLS/SSL certificate secrets for specified hosts.')
161
162
  .option('--node <node>', 'Sets optional node for deployment operations.')
162
163
  .option(
163
164
  '--build-manifest',
@@ -1,6 +1,6 @@
1
1
  import { commitData } from '../client/components/core/CommonJs.js';
2
2
  import dotenv from 'dotenv';
3
- import { pbcopy, shellExec } from '../server/process.js';
3
+ import { pbcopy, shellCd, shellExec } from '../server/process.js';
4
4
  import { actionInitLog, loggerFactory } from '../server/logger.js';
5
5
  import fs from 'fs-extra';
6
6
  import { getNpmRootPath } from '../server/conf.js';
@@ -49,7 +49,7 @@ class UnderpostRepository {
49
49
  },
50
50
  ) {
51
51
  if (commitType === 'reset') {
52
- pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
52
+ if (options.copy) pbcopy(shellExec(`git --no-pager log -1 --pretty=%B`, { stdout: true }));
53
53
  shellExec(`cd ${repoPath} && git reset --soft HEAD~${isNaN(parseInt(subModule)) ? 1 : parseInt(subModule)}`);
54
54
  return;
55
55
  }
@@ -138,6 +138,15 @@ class UnderpostRepository {
138
138
  .concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
139
139
  .filter((f) => !deleteFiles.includes(f));
140
140
  },
141
+ privateConfUpdate(deployId) {
142
+ shellCd(`/home/dd/engine`);
143
+ const privateRepoName = `engine-${deployId.split('dd-')[1]}-private`;
144
+ const privateRepoPath = `../${privateRepoName}`;
145
+ if (fs.existsSync(privateRepoPath)) fs.removeSync(privateRepoPath);
146
+ shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
147
+ shellExec(`cd ${privateRepoPath} && underpost pull . ${process.env.GITHUB_USERNAME}/${privateRepoName}`);
148
+ shellExec(`node bin/build ${deployId} conf`);
149
+ },
141
150
  };
142
151
  }
143
152
 
package/src/cli/run.js CHANGED
@@ -7,6 +7,7 @@ import fs from 'fs-extra';
7
7
  import { range, setPad, timer } from '../client/components/core/CommonJs.js';
8
8
  import UnderpostDeploy from './deploy.js';
9
9
  import UnderpostRootEnv from './env.js';
10
+ import UnderpostRepository from './repository.js';
10
11
 
11
12
  const logger = loggerFactory(import.meta);
12
13
 
@@ -131,7 +132,6 @@ class UnderpostRun {
131
132
  actionInitLog();
132
133
  const baseCommand = options.dev || true ? 'node bin' : 'underpost';
133
134
  shellCd('/home/dd/engine');
134
- shellExec(`node bin/build dd-${path.split('engine-')[1]} conf`);
135
135
  shellExec(`git reset`);
136
136
  shellExec(`${baseCommand} cmt . --empty cd ssh-${path}`);
137
137
  shellExec(`${baseCommand} push . underpostnet/engine`);
@@ -303,6 +303,7 @@ class UnderpostRun {
303
303
  },
304
304
  deploy: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
305
305
  const deployId = path;
306
+ UnderpostRepository.API.privateConfUpdate(deployId);
306
307
  const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
307
308
  const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
308
309
  const env = 'production';
@@ -107,6 +107,7 @@ const Auth = {
107
107
  });
108
108
  });
109
109
  }
110
+ // Important delete session token if guest token already exists
110
111
  Auth.deleteToken();
111
112
  localStorage.removeItem('jwt');
112
113
 
package/src/index.js CHANGED
@@ -35,7 +35,7 @@ class Underpost {
35
35
  * @type {String}
36
36
  * @memberof Underpost
37
37
  */
38
- static version = 'v2.8.873';
38
+ static version = 'v2.8.875';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -106,10 +106,10 @@ const Lampp = {
106
106
  break;
107
107
  }
108
108
  },
109
- createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget }) => {
109
+ createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget, resetRouter }) => {
110
110
  if (!Lampp.enabled()) return { disabled: true };
111
111
  if (!Lampp.ports.includes(port)) Lampp.ports.push(port);
112
- if (currentPort === initPort) Lampp.removeRouter();
112
+ if (resetRouter) Lampp.removeRouter();
113
113
  Lampp.appendRouter(`
114
114
  Listen ${port}
115
115
 
@@ -31,12 +31,12 @@ const Xampp = {
31
31
  this.router = undefined;
32
32
  if (fs.existsSync(`./tmp/xampp-router.conf`)) fs.rmSync(`./tmp/xampp-router.conf`);
33
33
  },
34
- createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget }) => {
34
+ createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget, resetRouter }) => {
35
35
  if (!Xampp.enabled()) {
36
36
  return { disabled: true };
37
37
  }
38
38
  if (!Xampp.ports.includes(port)) Xampp.ports.push(port);
39
- if (currentPort === initPort) Xampp.removeRouter();
39
+ if (resetRouter) Xampp.removeRouter();
40
40
  Xampp.appendRouter(`
41
41
  Listen ${port}
42
42
 
@@ -552,7 +552,7 @@ function applySecurity(app, opts = {}) {
552
552
  origin: origin || false,
553
553
  methods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'],
554
554
  credentials: true,
555
- allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept'],
555
+ allowedHeaders: ['Content-Type', 'Authorization', 'X-Requested-With', 'Accept', 'withcredentials'],
556
556
  maxAge: 600,
557
557
  }),
558
558
  );
@@ -295,6 +295,7 @@ const buildRuntime = async () => {
295
295
  rootHostPath,
296
296
  redirect,
297
297
  redirectTarget,
298
+ resetRouter: currentPort === initPort,
298
299
  });
299
300
  if (disabled) continue;
300
301
  await UnderpostStartUp.API.listenPortController(
@@ -314,6 +315,7 @@ const buildRuntime = async () => {
314
315
  rootHostPath,
315
316
  redirect,
316
317
  redirectTarget,
318
+ resetRouter: currentPort === initPort,
317
319
  });
318
320
  if (disabled) continue;
319
321
  await UnderpostStartUp.API.listenPortController(