underpost 2.8.6 → 2.8.8

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.
Files changed (103) hide show
  1. package/.vscode/extensions.json +36 -3
  2. package/.vscode/settings.json +2 -0
  3. package/CHANGELOG.md +24 -4
  4. package/Dockerfile +9 -10
  5. package/README.md +41 -2
  6. package/bin/build.js +2 -2
  7. package/bin/db.js +1 -0
  8. package/bin/deploy.js +1521 -130
  9. package/bin/file.js +8 -0
  10. package/bin/index.js +1 -218
  11. package/cli.md +530 -0
  12. package/conf.js +4 -0
  13. package/docker-compose.yml +1 -1
  14. package/jsdoc.json +1 -1
  15. package/manifests/deployment/adminer/deployment.yaml +32 -0
  16. package/manifests/deployment/adminer/kustomization.yaml +7 -0
  17. package/manifests/deployment/adminer/service.yaml +13 -0
  18. package/manifests/deployment/dd-template-development/deployment.yaml +167 -0
  19. package/manifests/deployment/dd-template-development/proxy.yaml +46 -0
  20. package/manifests/deployment/fastapi/backend-deployment.yml +120 -0
  21. package/manifests/deployment/fastapi/backend-service.yml +19 -0
  22. package/manifests/deployment/fastapi/frontend-deployment.yml +54 -0
  23. package/manifests/deployment/fastapi/frontend-service.yml +15 -0
  24. package/manifests/deployment/fastapi/initial_data.sh +56 -0
  25. package/manifests/deployment/kafka/deployment.yaml +69 -0
  26. package/manifests/deployment/spark/spark-pi-py.yaml +21 -0
  27. package/manifests/envoy-service-nodeport.yaml +23 -0
  28. package/manifests/kubeadm-calico-config.yaml +119 -0
  29. package/manifests/kubelet-config.yaml +65 -0
  30. package/manifests/lxd/lxd-admin-profile.yaml +17 -0
  31. package/manifests/lxd/lxd-preseed.yaml +30 -0
  32. package/manifests/lxd/underpost-setup.sh +163 -0
  33. package/manifests/maas/lxd-preseed.yaml +32 -0
  34. package/manifests/maas/maas-setup.sh +82 -0
  35. package/manifests/mariadb/statefulset.yaml +2 -1
  36. package/manifests/mariadb/storage-class.yaml +10 -0
  37. package/manifests/mongodb/kustomization.yaml +1 -1
  38. package/manifests/mongodb/statefulset.yaml +12 -11
  39. package/manifests/mongodb/storage-class.yaml +9 -0
  40. package/manifests/mongodb-4.4/service-deployment.yaml +3 -3
  41. package/manifests/mysql/kustomization.yaml +7 -0
  42. package/manifests/mysql/pv-pvc.yaml +27 -0
  43. package/manifests/mysql/statefulset.yaml +55 -0
  44. package/manifests/postgresql/configmap.yaml +9 -0
  45. package/manifests/postgresql/kustomization.yaml +10 -0
  46. package/manifests/postgresql/pv.yaml +15 -0
  47. package/manifests/postgresql/pvc.yaml +13 -0
  48. package/manifests/postgresql/service.yaml +10 -0
  49. package/manifests/postgresql/statefulset.yaml +37 -0
  50. package/manifests/valkey/service.yaml +3 -9
  51. package/manifests/valkey/statefulset.yaml +12 -13
  52. package/package.json +3 -9
  53. package/src/api/default/default.service.js +1 -1
  54. package/src/api/user/user.service.js +14 -11
  55. package/src/cli/baremetal.js +60 -0
  56. package/src/cli/cluster.js +551 -65
  57. package/src/cli/cron.js +39 -8
  58. package/src/cli/db.js +20 -10
  59. package/src/cli/deploy.js +288 -86
  60. package/src/cli/env.js +10 -4
  61. package/src/cli/fs.js +21 -9
  62. package/src/cli/image.js +116 -124
  63. package/src/cli/index.js +319 -0
  64. package/src/cli/lxd.js +395 -0
  65. package/src/cli/monitor.js +236 -0
  66. package/src/cli/repository.js +14 -8
  67. package/src/client/components/core/Account.js +28 -24
  68. package/src/client/components/core/Blockchain.js +1 -1
  69. package/src/client/components/core/CalendarCore.js +14 -84
  70. package/src/client/components/core/CommonJs.js +2 -1
  71. package/src/client/components/core/Css.js +0 -1
  72. package/src/client/components/core/CssCore.js +10 -2
  73. package/src/client/components/core/Docs.js +1 -1
  74. package/src/client/components/core/EventsUI.js +3 -3
  75. package/src/client/components/core/FileExplorer.js +86 -78
  76. package/src/client/components/core/JoyStick.js +2 -2
  77. package/src/client/components/core/LoadingAnimation.js +1 -17
  78. package/src/client/components/core/LogIn.js +3 -3
  79. package/src/client/components/core/LogOut.js +1 -1
  80. package/src/client/components/core/Modal.js +14 -8
  81. package/src/client/components/core/Panel.js +19 -61
  82. package/src/client/components/core/PanelForm.js +13 -22
  83. package/src/client/components/core/Recover.js +3 -3
  84. package/src/client/components/core/RichText.js +1 -11
  85. package/src/client/components/core/Router.js +3 -1
  86. package/src/client/components/core/SignUp.js +2 -2
  87. package/src/client/components/default/RoutesDefault.js +3 -2
  88. package/src/client/services/default/default.management.js +45 -38
  89. package/src/client/ssr/Render.js +2 -0
  90. package/src/index.js +34 -2
  91. package/src/mailer/MailerProvider.js +3 -0
  92. package/src/runtime/lampp/Dockerfile +65 -0
  93. package/src/server/client-build.js +13 -0
  94. package/src/server/conf.js +151 -1
  95. package/src/server/dns.js +56 -18
  96. package/src/server/json-schema.js +77 -0
  97. package/src/server/logger.js +3 -3
  98. package/src/server/network.js +7 -122
  99. package/src/server/peer.js +2 -2
  100. package/src/server/proxy.js +4 -4
  101. package/src/server/runtime.js +24 -11
  102. package/src/server/start.js +122 -0
  103. package/src/server/valkey.js +27 -13
@@ -0,0 +1,319 @@
1
+ import dotenv from 'dotenv';
2
+ import { Command } from 'commander';
3
+ import Underpost from '../index.js';
4
+ import { getNpmRootPath, getUnderpostRootPath, loadConf } from '../server/conf.js';
5
+ import fs from 'fs-extra';
6
+ import { commitData } from '../client/components/core/CommonJs.js';
7
+ import { shellExec } from '../server/process.js';
8
+ import UnderpostLxd from './lxd.js';
9
+ import UnderpostBaremetal from './baremetal.js';
10
+
11
+ const underpostRootPath = getUnderpostRootPath();
12
+ fs.existsSync(`${underpostRootPath}/.env`)
13
+ ? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
14
+ : dotenv.config();
15
+
16
+ const program = new Command();
17
+
18
+ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
19
+
20
+ program
21
+ .command('new')
22
+ .argument('<app-name>', 'Application name')
23
+ .description('Create a new project')
24
+ .action(Underpost.repo.new);
25
+
26
+ program
27
+ .command('start')
28
+ .argument('<deploy-id>', 'Deploy configuration id')
29
+ .argument('[env]', 'Optional environment, for default is development')
30
+ .option('--run', 'Run app servers and monitor health server')
31
+ .option('--build', 'Build app client')
32
+ .action(Underpost.start.callback)
33
+ .description('Start up server, build pipelines, or services');
34
+
35
+ program
36
+ .command('clone')
37
+ .argument(`<uri>`, 'e.g. username/repository')
38
+ .option('--bare', 'Clone only .git files')
39
+ .option('-g8', 'Use g8 repo extension')
40
+ .description('Clone github repository')
41
+ .action(Underpost.repo.clone);
42
+
43
+ program
44
+ .command('pull')
45
+ .argument('<path>', 'Absolute or relative directory')
46
+ .argument(`<uri>`, 'e.g. username/repository')
47
+ .description('Pull github repository')
48
+ .option('-g8', 'Use g8 repo extension')
49
+ .action(Underpost.repo.pull);
50
+
51
+ program
52
+ .command('cmt')
53
+ .argument('<path>', 'Absolute or relative directory')
54
+ .argument(`<commit-type>`, `Options: ${Object.keys(commitData)}`)
55
+ .argument(`[module-tag]`, 'Optional set module tag')
56
+ .argument(`[message]`, 'Optional set additional message')
57
+ .option('--empty', 'Allow empty files')
58
+ .option('--copy', 'Copy to clipboard message')
59
+ .option('--info', 'Info commit types')
60
+ .description('Commit github repository')
61
+ .action(Underpost.repo.commit);
62
+
63
+ program
64
+ .command('push')
65
+ .argument('<path>', 'Absolute or relative directory')
66
+ .argument(`<uri>`, 'e.g. username/repository')
67
+ .option('-f', 'Force push overwriting repository')
68
+ .option('-g8', 'Use g8 repo extension')
69
+ .description('Push github repository')
70
+ .action(Underpost.repo.push);
71
+
72
+ program
73
+ .command('env')
74
+ .argument('<deploy-id>', `deploy configuration id, if 'clean' restore default`)
75
+ .argument('[env]', 'Optional environment, for default is production')
76
+ .description('Set environment variables files and conf related to <deploy-id>')
77
+ .action(loadConf);
78
+
79
+ program
80
+ .command('config')
81
+ .argument('operator', `Options: ${Object.keys(Underpost.env)}`)
82
+ .argument('[key]', 'Config key')
83
+ .argument('[value]', 'Config value')
84
+ .option('--plain', 'Print plain value')
85
+ .description(`Manage configuration, operators`)
86
+ .action((...args) => Underpost.env[args[0]](args[1], args[2], args[3]));
87
+
88
+ program
89
+ .command('root')
90
+ .description('Get npm root path')
91
+ .action(() => console.log(getNpmRootPath()));
92
+
93
+ program
94
+ .command('cluster')
95
+ .argument('[pod-name]', 'Optional pod name filter')
96
+ .option('--reset', `Delete all clusters and prune all data and caches`)
97
+ .option('--mariadb', 'Init with mariadb statefulset')
98
+ .option('--mysql', 'Init with mysql statefulset')
99
+ .option('--mongodb', 'Init with mongodb statefulset')
100
+ .option('--postgresql', 'Init with postgresql statefulset')
101
+ .option('--mongodb4', 'Init with mongodb 4.4 service')
102
+ // .option('--istio', 'Init base istio service mesh')
103
+ .option('--valkey', 'Init with valkey service')
104
+ .option('--contour', 'Init with project contour base HTTPProxy and envoy')
105
+ .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
106
+ .option('--dedicated-gpu', 'Init with dedicated gpu base resources env')
107
+ .option('--info', 'Get all kinds objects deployed')
108
+ .option('--full', 'Init with all statefulsets and services available')
109
+ .option('--ns-use <ns-name>', 'Switches current context to namespace')
110
+ .option('--kubeadm', 'Init with kubeadm controlplane management')
111
+ .option('--dev', 'init with dev cluster')
112
+ .option('--list-pods', 'Display list pods information')
113
+ .option('--info-capacity', 'display current total machine capacity info')
114
+ .option('--info-capacity-pod', 'display current machine capacity pod info')
115
+ .option('--pull-image', 'Set optional pull associated image')
116
+ .option('--init-host', 'Install k8s node necessary cli env: kind, kubeadm, docker, podman, helm')
117
+ .option('--config', 'Set k8s base node config')
118
+ .option('--worker', 'Set worker node context')
119
+ .option('--chown', 'Set k8s kube chown')
120
+ .option('--k3s', 'Initialize the cluster using K3s')
121
+ .action(Underpost.cluster.init)
122
+ .description('Manage cluster, for default initialization base kind cluster');
123
+
124
+ program
125
+ .command('deploy')
126
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
127
+ .argument('[env]', 'Optional environment, for default is development')
128
+ .option('--remove', 'Delete deployments and services')
129
+ .option('--sync', 'Sync deployments env, ports, and replicas')
130
+ .option('--info-router', 'Display router structure')
131
+ .option('--expose', 'Expose service match deploy-list')
132
+ .option('--info-util', 'Display kubectl util management commands')
133
+ .option('--cert', 'Reset tls/ssl certificate secrets')
134
+ .option('--build-manifest', 'Build kind yaml manifests: deployments, services, proxy and secrets')
135
+ .option('--dashboard-update', 'Update dashboard instance data with current router config')
136
+ .option('--replicas <replicas>', 'Set custom number of replicas')
137
+ .option('--versions <deployment-versions>', 'Comma separated custom deployment versions')
138
+ .option('--traffic <traffic-versions>', 'Comma separated custom deployment traffic')
139
+ .option('--disable-update-deployment', 'Disable update deployments')
140
+ .option('--info-traffic', 'get traffic conf form current resources deployments')
141
+ .option('--kubeadm', 'Enable kubeadm context')
142
+ .option('--restore-hosts', 'Restore defautl etc hosts')
143
+ .option(
144
+ '--rebuild-clients-bundle',
145
+ 'Inside container, rebuild clients bundle, only static public or storage client files',
146
+ )
147
+ .description('Manage deployment, for default deploy development pods')
148
+ .action(Underpost.deploy.callback);
149
+
150
+ program
151
+ .command('secret')
152
+ .argument('<platform>', `Options: ${Object.keys(Underpost.secret)}`)
153
+ .option('--init', 'Init secrets platform environment')
154
+ .option('--create-from-file <path-env-file>', 'Create secret from env file')
155
+ .option('--list', 'Lists secrets')
156
+ // .option('--delete [secret-key]', 'Delete key secret, if not set, are default delete all')
157
+ // .option('--create [secret-key] [secret-value]', 'Create secret key, with secret value')
158
+ .description(`Manage secrets`)
159
+ .action((...args) => {
160
+ if (args[1].createFromFile) return Underpost.secret[args[0]].createFromEnvFile(args[1].createFromFile);
161
+ if (args[1].list) return Underpost.secret[args[0]].list();
162
+ if (args[1].init) return Underpost.secret[args[0]].init();
163
+ });
164
+
165
+ program
166
+ .command('dockerfile-image-build')
167
+ .option('--path [path]', 'Dockerfile path')
168
+ .option('--image-name [image-name]', 'Set image name')
169
+ .option('--image-path [image-path]', 'Set tar image path')
170
+ .option('--dockerfile-name [dockerfile-name]', 'set Dockerfile name')
171
+ .option('--podman-save', 'Export tar file from podman')
172
+ .option('--kind-load', 'Import tar image to Kind cluster')
173
+ .option('--kubeadm-load', 'Import tar image to Kubeadm cluster')
174
+ .option('--secrets', 'Dockerfile env secrets')
175
+ .option('--secrets-path [secrets-path]', 'Dockerfile custom path env secrets')
176
+ .option('--reset', 'Build without using cache')
177
+ .option('--k3s-load', 'Load image into K3s cluster.')
178
+ .description('Build image from Dockerfile')
179
+ .action(Underpost.image.dockerfile.build);
180
+
181
+ program
182
+ .command('dockerfile-pull-base-images')
183
+ .option('--path [path]', 'Dockerfile path')
184
+ .option('--kind-load', 'Import tar image to Kind cluster')
185
+ .option('--kubeadm-load', 'Import tar image to Kubeadm cluster')
186
+ .option('--version', 'Set custom version')
187
+ .option('--k3s-load', 'Load image into K3s cluster.')
188
+ .description('Pull underpost dockerfile images requirements')
189
+ .action(Underpost.image.dockerfile.pullBaseImages);
190
+
191
+ program
192
+ .command('install')
193
+ .description('Fast import underpost npm dependencies')
194
+ .action(() => {
195
+ fs.copySync(`${underpostRootPath}/node_modules`, './node_modules');
196
+ });
197
+
198
+ program
199
+ .command('db')
200
+ .argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
201
+ .option('--import', 'Import container backups from repositories')
202
+ .option('--export', 'Export container backups to repositories')
203
+ .option('--pod-name <pod-name>', 'Optional pod context')
204
+ .option('--collections <collections>', 'Comma separated collections')
205
+ .option('--out-path <out-path>', 'Custom out path backup')
206
+ .option('--drop', 'Drop databases')
207
+ .option('--preserveUUID', 'Preserve Ids')
208
+ .option('--git', 'Upload to github')
209
+ .option('--hosts <hosts>', 'Comma separated hosts')
210
+ .option('--paths <paths>', 'Comma separated paths')
211
+ .option('--ns <ns-name>', 'Optional name space context')
212
+ .description('Manage databases')
213
+ .action(Underpost.db.callback);
214
+
215
+ program
216
+ .command('script')
217
+ .argument('operator', `Options: ${Object.keys(Underpost.script)}`)
218
+ .argument('<script-name>', 'Script name')
219
+ .argument('[script-value]', 'Literal command, or path')
220
+ .option('--itc', 'Inside container execution context')
221
+ .option('--itc-path', 'Inside container path options')
222
+ .option('--ns <ns-name>', 'Options name space context')
223
+ .option('--pod-name <pod-name>')
224
+ .description(
225
+ 'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
226
+ )
227
+ .action((...args) => Underpost.script[args[0]](args[1], args[2], args[3]));
228
+
229
+ program
230
+ .command('cron')
231
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
232
+ .argument('[job-list]', `Deploy id list, e.g. ${Object.keys(Underpost.cron)}, for default all available jobs`)
233
+ .option('--itc', 'Inside container execution context')
234
+ .option('--init', 'Init cron jobs for cron job default deploy id')
235
+ .option('--git', 'Upload to github')
236
+ .option('--dashboard-update', 'Update dashboard cron data with current jobs config')
237
+ .description('Cron jobs management')
238
+ .action(Underpost.cron.callback);
239
+
240
+ program
241
+ .command('fs')
242
+ .argument('[path]', 'Absolute or relative directory')
243
+ .option('--rm', 'Remove file')
244
+ .option('--git', 'Current git changes')
245
+ .option('--recursive', 'Upload files recursively')
246
+ .option('--deploy-id <deploy-id>', 'Deploy configuration id')
247
+ .option('--pull', 'Download file')
248
+ .option('--force', 'Force action')
249
+ .option('--storage-file-path <storage-file-path>', 'custom file storage path')
250
+ .description('File storage management, for default upload file')
251
+ .action(Underpost.fs.callback);
252
+
253
+ program
254
+ .command('test')
255
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
256
+ .description('Manage Test, for default run current underpost default test')
257
+ .option('--itc', 'Inside container execution context')
258
+ .option('--sh', 'Copy to clipboard, container entrypoint shell command')
259
+ .option('--logs', 'Display container logs')
260
+ .option('--pod-name <pod-name>')
261
+ .option('--pod-status <pod-status>')
262
+ .option('--kind-type <kind-type>')
263
+ .action(Underpost.test.callback);
264
+
265
+ program
266
+ .command('monitor')
267
+ .argument('<deploy-id>', 'Deploy configuration id')
268
+ .argument('[env]', 'Optional environment, for default is development')
269
+ .option('--ms-interval <ms-interval>', 'Custom ms interval delta time')
270
+ .option('--now', 'Exec immediately monitor script')
271
+ .option('--single', 'Disable recurrence')
272
+ .option('--replicas <replicas>', 'Set custom number of replicas')
273
+ .option('--type <type>', 'Set custom monitor type')
274
+ .option('--sync', 'Sync with current proxy deployments proxy traffic')
275
+ .description('Monitor health server management')
276
+ .action(Underpost.monitor.callback);
277
+
278
+ program
279
+ .command('lxd')
280
+ .option('--init', 'Init lxd')
281
+ .option('--reset', 'Reset lxd on current machine')
282
+ .option('--install', 'Install lxd on current machine')
283
+ .option('--dev', 'Set dev context env')
284
+ .option('--create-virtual-network', 'Create lxd virtual network bridge')
285
+ .option('--create-admin-profile', 'Create admin profile for lxd management')
286
+ .option('--control', 'set control node vm context')
287
+ .option('--worker', 'set worker node context')
288
+ .option('--create-vm <vm-id>', 'Create default virtual machines')
289
+ .option('--init-vm <vm-id>', 'Get init vm underpost script')
290
+ .option('--info-vm <vm-id>', 'Get all info vm')
291
+ .option('--test <vm-id>', 'Test health, status and network connectivity for a VM')
292
+ .option('--root-size <gb-size>', 'Set root size vm')
293
+ .option('--k3s', 'Flag to indicate K3s cluster type for VM initialization')
294
+ .option('--join-node <nodes>', 'Comma separated worker and control node e. g. k8s-worker-1,k8s-control')
295
+ .option(
296
+ '--expose <vm-name-ports>',
297
+ 'Vm name and : separated with Comma separated vm port to expose e. g. k8s-control:80,443',
298
+ )
299
+ .option(
300
+ '--delete-expose <vm-name-ports>',
301
+ 'Vm name and : separated with Comma separated vm port to remove expose e. g. k8s-control:80,443',
302
+ )
303
+ .option('--auto-expose-k8s-ports <vm-id>', 'Automatically expose common Kubernetes ports for the VM.')
304
+ .description('Lxd management')
305
+ .action(UnderpostLxd.API.callback);
306
+
307
+ program
308
+ .command('baremetal')
309
+ .option('--control-server-install', 'Install baremetal control server')
310
+ .option('--control-server-init-db', 'Setup database baremetal control server')
311
+ .option('--control-server-init', 'Init baremetal control server')
312
+ .option('--control-server-uninstall', 'Uninstall baremetal control server')
313
+ .option('--control-server-stop', 'Stop baremetal control server')
314
+ .option('--control-server-start', 'Start baremetal control server')
315
+ .option('--dev', 'Set dev context env')
316
+ .description('Baremetal management')
317
+ .action(UnderpostBaremetal.API.callback);
318
+
319
+ export { program };