underpost 2.8.641 → 2.8.651

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/cli.md ADDED
@@ -0,0 +1,439 @@
1
+ ## underpost ci/cd cli v2.8.651
2
+
3
+ ### Usage: `underpost [options] [command]`
4
+ ```
5
+ Options:
6
+ -V, --version output the version number
7
+ -h, --help display help for command
8
+
9
+ Commands:
10
+ new <app-name> Create a new project
11
+ start [options] <deploy-id> [env] Start up server, build pipelines, or services
12
+ clone [options] <uri> Clone github repository
13
+ pull <path> <uri> Pull github repository
14
+ cmt [options] <path> <commit-type> [module-tag] [message] Commit github repository
15
+ push [options] <path> <uri> Push github repository
16
+ env <deploy-id> [env] Set environment variables files and conf related to <deploy-id>
17
+ config <operator> [key] [value] Manage configuration, operators
18
+ root Get npm root path
19
+ cluster [options] [pod-name] Manage cluster, for default initialization base kind cluster
20
+ deploy [options] <deploy-list> [env] Manage deployment, for default deploy development pods
21
+ secret [options] <platform> Manage secrets
22
+ dockerfile-image-build [options] Build image from Dockerfile
23
+ dockerfile-pull-base-images Pull underpost dockerfile images requirements
24
+ install Fast import underpost npm dependencies
25
+ db [options] <deploy-list> Manage databases
26
+ script [options] <operator> <script-name> [script-value] Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts
27
+ cron [options] [deploy-list] [job-list] Cron jobs management
28
+ fs [options] [path] File storage management, for default upload file
29
+ test [options] [deploy-list] Manage Test, for default run current underpost default test
30
+ monitor [options] <deploy-id> [env] Monitor health server management
31
+ help [command] display help for command
32
+
33
+ ```
34
+
35
+ ## Commands:
36
+
37
+
38
+ ### `new` :
39
+ ```
40
+ Usage: underpost new [options] <app-name>
41
+
42
+ Create a new project
43
+
44
+ Arguments:
45
+ app-name Application name
46
+
47
+ Options:
48
+ -h, --help display help for command
49
+
50
+ ```
51
+
52
+
53
+ ### `start` :
54
+ ```
55
+ Usage: underpost start [options] <deploy-id> [env]
56
+
57
+ Start up server, build pipelines, or services
58
+
59
+ Arguments:
60
+ deploy-id Deploy configuration id
61
+ env Optional environment, for default is development
62
+
63
+ Options:
64
+ --run Run app servers and monitor health server
65
+ --build Build app client
66
+ -h, --help display help for command
67
+
68
+ ```
69
+
70
+
71
+ ### `clone` :
72
+ ```
73
+ Usage: underpost clone [options] <uri>
74
+
75
+ Clone github repository
76
+
77
+ Arguments:
78
+ uri e.g. username/repository
79
+
80
+ Options:
81
+ --bare Clone only .git files
82
+ -h, --help display help for command
83
+
84
+ ```
85
+
86
+
87
+ ### `pull` :
88
+ ```
89
+ Usage: underpost pull [options] <path> <uri>
90
+
91
+ Pull github repository
92
+
93
+ Arguments:
94
+ path Absolute or relative directory
95
+ uri e.g. username/repository
96
+
97
+ Options:
98
+ -h, --help display help for command
99
+
100
+ ```
101
+
102
+
103
+ ### `cmt` :
104
+ ```
105
+ Usage: underpost cmt [options] <path> <commit-type> [module-tag] [message]
106
+
107
+ Commit github repository
108
+
109
+ Arguments:
110
+ path Absolute or relative directory
111
+ commit-type Options:
112
+ feat,fix,docs,style,refactor,perf,cd,test,build,ci,chore,revert,backup
113
+ module-tag Optional set module tag
114
+ message Optional set additional message
115
+
116
+ Options:
117
+ --empty Allow empty files
118
+ --copy Copy to clipboard message
119
+ --info Info commit types
120
+ -h, --help display help for command
121
+
122
+ ```
123
+
124
+
125
+ ### `push` :
126
+ ```
127
+ Usage: underpost push [options] <path> <uri>
128
+
129
+ Push github repository
130
+
131
+ Arguments:
132
+ path Absolute or relative directory
133
+ uri e.g. username/repository
134
+
135
+ Options:
136
+ -f Force push overwriting repository
137
+ -h, --help display help for command
138
+
139
+ ```
140
+
141
+
142
+ ### `env` :
143
+ ```
144
+ Usage: underpost env [options] <deploy-id> [env]
145
+
146
+ Set environment variables files and conf related to <deploy-id>
147
+
148
+ Arguments:
149
+ deploy-id deploy configuration id, if 'clean' restore default
150
+ env Optional environment, for default is production
151
+
152
+ Options:
153
+ -h, --help display help for command
154
+
155
+ ```
156
+
157
+
158
+ ### `config` :
159
+ ```
160
+ Usage: underpost config [options] <operator> [key] [value]
161
+
162
+ Manage configuration, operators
163
+
164
+ Arguments:
165
+ operator Options: set,delete,get,list,clean
166
+ key Config key
167
+ value Config value
168
+
169
+ Options:
170
+ -h, --help display help for command
171
+
172
+ ```
173
+
174
+
175
+ ### `root` :
176
+ ```
177
+ Usage: underpost root [options]
178
+
179
+ Get npm root path
180
+
181
+ Options:
182
+ -h, --help display help for command
183
+
184
+ ```
185
+
186
+
187
+ ### `cluster` :
188
+ ```
189
+ Usage: underpost cluster [options] [pod-name]
190
+
191
+ Manage cluster, for default initialization base kind cluster
192
+
193
+ Arguments:
194
+ pod-name Optional pod name filter
195
+
196
+ Options:
197
+ --reset Delete all clusters and prune all data and caches
198
+ --mariadb Init with mariadb statefulset
199
+ --mongodb Init with mongodb statefulset
200
+ --mongodb4 Init with mongodb 4.4 service
201
+ --valkey Init with valkey service
202
+ --contour Init with project contour base HTTPProxy and envoy
203
+ --cert-manager Init with letsencrypt-prod ClusterIssuer
204
+ --info Get all kinds objects deployed
205
+ --full Init with all statefulsets and services available
206
+ --ns-use <ns-name> Switches current context to namespace
207
+ --dev init with dev cluster
208
+ --list-pods Display list pods information
209
+ --info-capacity display current total machine capacity info
210
+ --info-capacity-pod display current machine capacity pod info
211
+ -h, --help display help for command
212
+
213
+ ```
214
+
215
+
216
+ ### `deploy` :
217
+ ```
218
+ Usage: underpost deploy [options] <deploy-list> [env]
219
+
220
+ Manage deployment, for default deploy development pods
221
+
222
+ Arguments:
223
+ deploy-list Deploy id list, e.g. default-a,default-b
224
+ env Optional environment, for default is
225
+ development
226
+
227
+ Options:
228
+ --remove Delete deployments and services
229
+ --sync Sync deployments env, ports, and replicas
230
+ --info-router Display router structure
231
+ --expose Expose service match deploy-list
232
+ --info-util Display kubectl util management commands
233
+ --cert Reset tls/ssl certificate secrets
234
+ --build-manifest Build kind yaml manifests: deployments,
235
+ services, proxy and secrets
236
+ --dashboard-update Update dashboard instance data with current
237
+ router config
238
+ --replicas <replicas> Set custom number of replicas
239
+ --versions <deployment-versions> Comma separated custom deployment versions
240
+ --traffic <traffic-versions> Comma separated custom deployment traffic
241
+ -h, --help display help for command
242
+
243
+ ```
244
+
245
+
246
+ ### `secret` :
247
+ ```
248
+ Usage: underpost secret [options] <platform>
249
+
250
+ Manage secrets
251
+
252
+ Arguments:
253
+ platform Options: docker,underpost
254
+
255
+ Options:
256
+ --init Init secrets platform environment
257
+ --create-from-file <path-env-file> Create secret from env file
258
+ --list Lists secrets
259
+ -h, --help display help for command
260
+
261
+ ```
262
+
263
+
264
+ ### `dockerfile-image-build` :
265
+ ```
266
+ Usage: underpost dockerfile-image-build [options]
267
+
268
+ Build image from Dockerfile
269
+
270
+ Options:
271
+ --path [path] Dockerfile path
272
+ --image-name [image-name] Set image name
273
+ --image-path [image-path] Set tar image path
274
+ --dockerfile-name [dockerfile-name] set Dockerfile name
275
+ --podman-save Export tar file from podman
276
+ --kind-load Import tar image to Kind cluster
277
+ --secrets Dockerfile env secrets
278
+ --secrets-path [secrets-path] Dockerfile custom path env secrets
279
+ --no-cache Build without using cache
280
+ -h, --help display help for command
281
+
282
+ ```
283
+
284
+
285
+ ### `dockerfile-pull-base-images` :
286
+ ```
287
+ Usage: underpost dockerfile-pull-base-images [options]
288
+
289
+ Pull underpost dockerfile images requirements
290
+
291
+ Options:
292
+ -h, --help display help for command
293
+
294
+ ```
295
+
296
+
297
+ ### `install` :
298
+ ```
299
+ Usage: underpost install [options]
300
+
301
+ Fast import underpost npm dependencies
302
+
303
+ Options:
304
+ -h, --help display help for command
305
+
306
+ ```
307
+
308
+
309
+ ### `db` :
310
+ ```
311
+ Usage: underpost db [options] <deploy-list>
312
+
313
+ Manage databases
314
+
315
+ Arguments:
316
+ deploy-list Deploy id list, e.g. default-a,default-b
317
+
318
+ Options:
319
+ --import Import container backups from repositories
320
+ --export Export container backups to repositories
321
+ --pod-name <pod-name> Optional pod context
322
+ --collections <collections> Comma separated collections
323
+ --out-path <out-path> Custom out path backup
324
+ --drop Drop databases
325
+ --preserveUUID Preserve Ids
326
+ --git Upload to github
327
+ --hosts <hosts> Comma separated hosts
328
+ --paths <paths> Comma separated paths
329
+ --ns <ns-name> Optional name space context
330
+ -h, --help display help for command
331
+
332
+ ```
333
+
334
+
335
+ ### `script` :
336
+ ```
337
+ Usage: underpost script [options] <operator> <script-name> [script-value]
338
+
339
+ Supports a number of built-in underpost global scripts and their preset life
340
+ cycle events as well as arbitrary scripts
341
+
342
+ Arguments:
343
+ operator Options: set,run,get
344
+ script-name Script name
345
+ script-value Literal command, or path
346
+
347
+ Options:
348
+ --itc Inside container execution context
349
+ --itc-path Inside container path options
350
+ --ns <ns-name> Options name space context
351
+ --pod-name <pod-name>
352
+ -h, --help display help for command
353
+
354
+ ```
355
+
356
+
357
+ ### `cron` :
358
+ ```
359
+ Usage: underpost cron [options] [deploy-list] [job-list]
360
+
361
+ Cron jobs management
362
+
363
+ Arguments:
364
+ deploy-list Deploy id list, e.g. default-a,default-b
365
+ job-list Deploy id list, e.g. callback,updateDashboardData, for
366
+ default all available jobs
367
+
368
+ Options:
369
+ --itc Inside container execution context
370
+ --init Init cron jobs for cron job default deploy id
371
+ --git Upload to github
372
+ --dashboard-update Update dashboard cron data with current jobs config
373
+ -h, --help display help for command
374
+
375
+ ```
376
+
377
+
378
+ ### `fs` :
379
+ ```
380
+ Usage: underpost fs [options] [path]
381
+
382
+ File storage management, for default upload file
383
+
384
+ Arguments:
385
+ path Absolute or relative directory
386
+
387
+ Options:
388
+ --rm Remove file
389
+ --git Current git changes
390
+ --recursive Upload files recursively
391
+ --deploy-id <deploy-id> Deploy configuration id
392
+ --pull Download file
393
+ --force Force action
394
+ -h, --help display help for command
395
+
396
+ ```
397
+
398
+
399
+ ### `test` :
400
+ ```
401
+ Usage: underpost test [options] [deploy-list]
402
+
403
+ Manage Test, for default run current underpost default test
404
+
405
+ Arguments:
406
+ deploy-list Deploy id list, e.g. default-a,default-b
407
+
408
+ Options:
409
+ --itc Inside container execution context
410
+ --sh Copy to clipboard, container entrypoint shell
411
+ command
412
+ --logs Display container logs
413
+ --pod-name <pod-name>
414
+ --pod-status <pod-status>
415
+ --kind-type <kind-type>
416
+ -h, --help display help for command
417
+
418
+ ```
419
+
420
+
421
+ ### `monitor` :
422
+ ```
423
+ Usage: underpost monitor [options] <deploy-id> [env]
424
+
425
+ Monitor health server management
426
+
427
+ Arguments:
428
+ deploy-id Deploy configuration id
429
+ env Optional environment, for default is development
430
+
431
+ Options:
432
+ --ms-interval <ms-interval> Custom ms interval delta time
433
+ --now Exec immediately monitor script
434
+ --single Disable recurrence
435
+ --type <type> Set custom monitor type
436
+ -h, --help display help for command
437
+
438
+ ```
439
+
@@ -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.641'
61
+ engine.version: '2.8.651'
62
62
  networks:
63
63
  - load-balancer
64
64
 
package/jsdoc.json CHANGED
@@ -23,7 +23,7 @@
23
23
  "homepageTitle": "Docs",
24
24
  "favicon": "./public/www.nexodev.org/"
25
25
  },
26
- "tutorials": "./public/www.nexodev.org/docs/learn"
26
+ "tutorials": "./public/www.nexodev.org/docs/references"
27
27
  },
28
28
  "markdown": {
29
29
  "hardwrap": false,
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.641",
5
+ "version": "2.8.651",
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",
@@ -118,12 +118,7 @@
118
118
  "vanilla-jsoneditor": "^2.3.2",
119
119
  "winston": "^3.11.0"
120
120
  },
121
- "devDependencies": {
122
- "clean-jsdoc-theme": "^4.3.0",
123
- "mocha": "^10.8.2",
124
- "plantuml": "^0.0.2",
125
- "swagger-autogen": "^2.23.7"
126
- },
121
+ "devDependencies": {},
127
122
  "publishConfig": {
128
123
  "provenance": true,
129
124
  "access": "public",
@@ -225,8 +225,8 @@ const UserService = {
225
225
  } else throw new Error('invalid email or password');
226
226
 
227
227
  case 'guest': {
228
- const user = await ValkeyAPI.valkeyObjectFactory('user', options);
229
- await ValkeyAPI.setValkeyObject(user.email, user);
228
+ const user = await ValkeyAPI.valkeyObjectFactory(options, 'user');
229
+ await ValkeyAPI.setValkeyObject(options, user.email, user);
230
230
  return {
231
231
  token: hashJWT({ user: UserDto.auth.payload(user) }),
232
232
  user: selectDtoFactory(user, UserDto.select.get()),
@@ -325,15 +325,18 @@ const UserService = {
325
325
  return await User.find().select(UserDto.select.getAll());
326
326
 
327
327
  case 'auth': {
328
- const user = (await ValkeyAPI.getValkeyObject(req.auth.user.email))
329
- ? await ValkeyAPI.getValkeyObject(req.auth.user.email)
330
- : await User.findOne({
331
- _id: req.auth.user._id,
332
- });
328
+ let user;
329
+ if (req.auth.user._id.match('guest')) {
330
+ user = await ValkeyAPI.getValkeyObject(options, req.auth.user.email);
331
+ if (!user) throw new Error('guest user expired');
332
+ } else
333
+ user = await User.findOne({
334
+ _id: req.auth.user._id,
335
+ });
333
336
 
334
337
  const file = await File.findOne({ _id: user.profileImageId });
335
338
 
336
- if (!file && !(await ValkeyAPI.getValkeyObject(req.auth.user.email))) {
339
+ if (!file && !(await ValkeyAPI.getValkeyObject(options, req.auth.user.email))) {
337
340
  await User.findByIdAndUpdate(
338
341
  user._id,
339
342
  { profileImageId: await getDefaultProfileImageId(File) },
@@ -342,8 +345,8 @@ const UserService = {
342
345
  },
343
346
  );
344
347
  }
345
- return (await ValkeyAPI.getValkeyObject(req.auth.user.email))
346
- ? selectDtoFactory(await ValkeyAPI.getValkeyObject(req.auth.user.email), UserDto.select.get())
348
+ return (await ValkeyAPI.getValkeyObject(options, req.auth.user.email))
349
+ ? selectDtoFactory(await ValkeyAPI.getValkeyObject(options, req.auth.user.email), UserDto.select.get())
347
350
  : await User.findOne({
348
351
  _id: req.auth.user._id,
349
352
  }).select(UserDto.select.get());
@@ -1,5 +1,4 @@
1
- import { timer } from '../client/components/core/CommonJs.js';
2
- import { cliSpinner, getNpmRootPath } from '../server/conf.js';
1
+ import { getNpmRootPath } from '../server/conf.js';
3
2
  import { loggerFactory } from '../server/logger.js';
4
3
  import { shellExec } from '../server/process.js';
5
4
  import UnderpostDeploy from './deploy.js';
@@ -23,10 +22,14 @@ class UnderpostCluster {
23
22
  reset: false,
24
23
  dev: false,
25
24
  nsUse: '',
25
+ infoCapacity: false,
26
+ infoCapacityPod: false,
26
27
  },
27
28
  ) {
28
29
  const npmRoot = getNpmRootPath();
29
30
  const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
31
+ if (options.infoCapacityPod === true) return logger.info('', UnderpostDeploy.API.resourcesFactory());
32
+ if (options.infoCapacity === true) return logger.info('', UnderpostCluster.API.getResourcesCapacity());
30
33
  if (options.reset === true) return await UnderpostCluster.API.reset();
31
34
  if (options.listPods === true) return console.table(UnderpostDeploy.API.get(podName ?? undefined));
32
35
 
@@ -197,6 +200,46 @@ class UnderpostCluster {
197
200
  );
198
201
  shellExec(`sudo podman system reset -f`);
199
202
  },
203
+ getResourcesCapacity() {
204
+ const resources = {};
205
+ const info = false
206
+ ? `Capacity:
207
+ cpu: 8
208
+ ephemeral-storage: 153131976Ki
209
+ hugepages-1Gi: 0
210
+ hugepages-2Mi: 0
211
+ memory: 11914720Ki
212
+ pods: 110
213
+ Allocatable:
214
+ cpu: 8
215
+ ephemeral-storage: 153131976Ki
216
+ hugepages-1Gi: 0
217
+ hugepages-2Mi: 0
218
+ memory: 11914720Ki
219
+ pods: `
220
+ : shellExec(`kubectl describe node kind-worker | grep -E '(Allocatable:|Capacity:)' -A 6`, {
221
+ stdout: true,
222
+ silent: true,
223
+ });
224
+ info
225
+ .split('Allocatable:')[1]
226
+ .split('\n')
227
+ .filter((row) => row.match('cpu') || row.match('memory'))
228
+ .map((row) => {
229
+ if (row.match('cpu'))
230
+ resources.cpu = {
231
+ value: parseInt(row.split(':')[1].trim()) * 1000,
232
+ unit: 'm',
233
+ };
234
+ if (row.match('memory'))
235
+ resources.memory = {
236
+ value: parseInt(row.split(':')[1].split('Ki')[0].trim()),
237
+ unit: 'Ki',
238
+ };
239
+ });
240
+
241
+ return resources;
242
+ },
200
243
  };
201
244
  }
202
245
  export default UnderpostCluster;
package/src/cli/db.js CHANGED
@@ -15,11 +15,13 @@ class UnderpostDB {
15
15
  export: false,
16
16
  podName: false,
17
17
  ns: false,
18
- collection: '',
18
+ collections: '',
19
19
  outPath: '',
20
20
  drop: false,
21
21
  preserveUUID: false,
22
22
  git: false,
23
+ hosts: '',
24
+ paths: '',
23
25
  },
24
26
  ) {
25
27
  const newBackupTimestamp = new Date().getTime();
@@ -39,20 +41,28 @@ class UnderpostDB {
39
41
  if (!dbs[provider]) dbs[provider] = {};
40
42
 
41
43
  if (!(name in dbs[provider]))
42
- dbs[provider][name] = { user, password, hostFolder: host + path.replaceAll('/', '-') };
44
+ dbs[provider][name] = { user, password, hostFolder: host + path.replaceAll('/', '-'), host, path };
43
45
  }
44
46
  }
45
47
  }
46
48
 
47
- if (!fs.existsSync(`../${repoName}`)) {
48
- shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}`);
49
- } else {
50
- shellExec(`cd ../${repoName} && underpost pull . ${process.env.GITHUB_USERNAME}/${repoName}`);
49
+ if (options.git === true) {
50
+ if (!fs.existsSync(`../${repoName}`)) {
51
+ shellExec(`cd .. && underpost clone ${process.env.GITHUB_USERNAME}/${repoName}`);
52
+ } else {
53
+ shellExec(`cd ../${repoName} && git checkout . && git clean -f -d`);
54
+ shellExec(`cd ../${repoName} && underpost pull . ${process.env.GITHUB_USERNAME}/${repoName}`);
55
+ }
51
56
  }
52
57
 
53
58
  for (const provider of Object.keys(dbs)) {
54
59
  for (const dbName of Object.keys(dbs[provider])) {
55
- const { hostFolder, user, password } = dbs[provider][dbName];
60
+ const { hostFolder, user, password, host, path } = dbs[provider][dbName];
61
+ if (
62
+ (options.hosts && !options.hosts.split(',').includes(host)) ||
63
+ (options.paths && !options.paths.split(',').includes(path))
64
+ )
65
+ continue;
56
66
  if (hostFolder) {
57
67
  logger.info('', { hostFolder, provider, dbName });
58
68
 
@@ -153,7 +163,7 @@ class UnderpostDB {
153
163
  const podName = podNameData.NAME;
154
164
  shellExec(`sudo kubectl exec -i ${podName} -- sh -c "rm -rf /${dbName}"`);
155
165
  if (options.collections)
156
- for (const collection of options.collections)
166
+ for (const collection of options.collections.split(','))
157
167
  shellExec(
158
168
  `sudo kubectl exec -i ${podName} -- sh -c "mongodump -d ${dbName} --collection ${collection} -o /"`,
159
169
  );