underpost 2.8.872 → 2.8.873
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/.env.development +2 -1
- package/.env.production +2 -1
- package/.env.test +2 -1
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +1 -1
- package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -1
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +2 -4
- package/README.md +22 -2
- package/bin/build.js +4 -0
- package/bin/deploy.js +4 -0
- package/cli.md +3 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +138 -0
- package/manifests/deployment/dd-test-development/proxy.yaml +26 -0
- package/package.json +5 -1
- package/src/api/core/core.router.js +2 -1
- package/src/api/default/default.controller.js +6 -1
- package/src/api/default/default.router.js +6 -2
- package/src/api/default/default.service.js +10 -1
- package/src/api/file/file.router.js +2 -1
- package/src/api/test/test.router.js +1 -1
- package/src/api/user/postman_collection.json +216 -0
- package/src/api/user/user.controller.js +25 -60
- package/src/api/user/user.model.js +29 -7
- package/src/api/user/user.router.js +6 -3
- package/src/api/user/user.service.js +80 -32
- package/src/cli/baremetal.js +33 -3
- package/src/cli/cloud-init.js +11 -0
- package/src/cli/deploy.js +5 -2
- package/src/cli/index.js +1 -0
- package/src/cli/lxd.js +7 -0
- package/src/cli/run.js +17 -5
- package/src/cli/ssh.js +20 -6
- package/src/client/components/core/AgGrid.js +28 -6
- package/src/client/components/core/Auth.js +98 -55
- package/src/client/components/core/LogIn.js +16 -23
- package/src/client/components/core/LogOut.js +5 -1
- package/src/client/components/core/Pagination.js +202 -9
- package/src/client/components/core/Router.js +30 -3
- package/src/client/components/core/SignUp.js +1 -2
- package/src/client/components/default/LogInDefault.js +0 -6
- package/src/client/components/default/LogOutDefault.js +0 -16
- package/src/client/services/core/core.service.js +5 -1
- package/src/client/services/default/default.management.js +115 -18
- package/src/client/services/default/default.service.js +9 -4
- package/src/client/services/user/user.management.js +6 -0
- package/src/client/services/user/user.service.js +11 -4
- package/src/index.js +24 -2
- package/src/runtime/lampp/Lampp.js +89 -2
- package/src/runtime/xampp/Xampp.js +48 -1
- package/src/server/auth.js +518 -155
- package/src/server/conf.js +19 -1
- package/src/server/runtime.js +62 -228
- package/src/server/ssr.js +85 -0
- package/src/server/valkey.js +2 -1
package/src/cli/baremetal.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Baremetal module for managing the generation and deployment of cloud-init configuration files
|
|
3
|
+
* and associated scripts for baremetal provisioning.
|
|
4
|
+
* @module src/cli/baremetal.js
|
|
5
|
+
* @namespace UnderpostBaremetal
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
|
|
2
9
|
import { openTerminal, pbcopy, shellExec } from '../server/process.js';
|
|
3
10
|
import dotenv from 'dotenv';
|
|
@@ -40,6 +47,7 @@ class UnderpostBaremetal {
|
|
|
40
47
|
* @param {boolean} [options.nfsUnmount=false] - Flag to unmount the NFS root filesystem.
|
|
41
48
|
* @param {boolean} [options.nfsSh=false] - Flag to chroot into the NFS environment for shell access.
|
|
42
49
|
* @param {string} [options.logs=''] - Specifies which logs to display ('dhcp', 'cloud', 'machine', 'cloud-config').
|
|
50
|
+
* @memberof UnderpostBaremetal
|
|
43
51
|
* @returns {void}
|
|
44
52
|
*/
|
|
45
53
|
async callback(
|
|
@@ -576,6 +584,7 @@ menuentry '${menuentryStr}' {
|
|
|
576
584
|
* @param {object} params.maas - MAAS configuration details.
|
|
577
585
|
* @param {string} params.networkInterfaceName - The name of the network interface.
|
|
578
586
|
* @returns {Promise<void>} A promise that resolves when commissioning is initiated or after a delay.
|
|
587
|
+
* @memberof UnderpostBaremetal
|
|
579
588
|
*/
|
|
580
589
|
async commissionMonitor({ macAddress, nfsHostPath, underpostRoot, hostname, maas, networkInterfaceName }) {
|
|
581
590
|
{
|
|
@@ -725,6 +734,7 @@ menuentry '${menuentryStr}' {
|
|
|
725
734
|
* This is necessary for cross-architecture execution within a chroot environment.
|
|
726
735
|
* @param {object} params - The parameters for the function.
|
|
727
736
|
* @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
|
|
737
|
+
* @memberof UnderpostBaremetal
|
|
728
738
|
* @returns {void}
|
|
729
739
|
*/
|
|
730
740
|
mountBinfmtMisc({ nfsHostPath }) {
|
|
@@ -747,6 +757,7 @@ menuentry '${menuentryStr}' {
|
|
|
747
757
|
* @description Deletes all specified machines from MAAS.
|
|
748
758
|
* @param {object} params - The parameters for the function.
|
|
749
759
|
* @param {Array<object>} params.machines - An array of machine objects, each with a `system_id`.
|
|
760
|
+
* @memberof UnderpostBaremetal
|
|
750
761
|
* @returns {Array<object>} An empty array after machines are removed.
|
|
751
762
|
*/
|
|
752
763
|
removeMachines({ machines }) {
|
|
@@ -761,6 +772,7 @@ menuentry '${menuentryStr}' {
|
|
|
761
772
|
* @description Clears all observed discoveries in MAAS and optionally forces a new scan.
|
|
762
773
|
* @param {object} params - The parameters for the function.
|
|
763
774
|
* @param {boolean} params.force - If true, forces a new discovery scan after clearing.
|
|
775
|
+
* @memberof UnderpostBaremetal
|
|
764
776
|
* @returns {void}
|
|
765
777
|
*/
|
|
766
778
|
clearDiscoveries({ force }) {
|
|
@@ -776,6 +788,7 @@ menuentry '${menuentryStr}' {
|
|
|
776
788
|
* This is used to wait for the target machine to report its MAC address.
|
|
777
789
|
* @param {object} params - The parameters for the function.
|
|
778
790
|
* @param {string} params.nfsHostPath - The NFS host path where the MAC file is expected.
|
|
791
|
+
* @memberof UnderpostBaremetal
|
|
779
792
|
* @returns {Promise<void>} A promise that resolves when the MAC file is found or after a delay.
|
|
780
793
|
*/
|
|
781
794
|
async macMonitor({ nfsHostPath }) {
|
|
@@ -794,6 +807,7 @@ menuentry '${menuentryStr}' {
|
|
|
794
807
|
* for cross-architecture execution within a chroot environment.
|
|
795
808
|
* @param {object} params - The parameters for the function.
|
|
796
809
|
* @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
|
|
810
|
+
* @memberof UnderpostBaremetal
|
|
797
811
|
* @param {'arm64'|'amd64'} params.debootstrapArch - The target architecture of the debootstrap environment.
|
|
798
812
|
* @returns {void}
|
|
799
813
|
*/
|
|
@@ -825,6 +839,7 @@ menuentry '${menuentryStr}' {
|
|
|
825
839
|
* @param {string} params.nfsHostPath - The path to the NFS root filesystem on the host.
|
|
826
840
|
* @param {'arm64'|'amd64'} params.debootstrapArch - The target architecture of the debootstrap environment.
|
|
827
841
|
* @param {object} params.callbackMetaData - Metadata about the callback, including runner host architecture.
|
|
842
|
+
* @memberof UnderpostBaremetal
|
|
828
843
|
* @param {string[]} params.steps - An array of shell commands to execute.
|
|
829
844
|
* @returns {void}
|
|
830
845
|
*/
|
|
@@ -860,6 +875,7 @@ EOF`);
|
|
|
860
875
|
* This helps in visualizing and debugging the execution flow of provisioning steps.
|
|
861
876
|
* @param {string[]} [steps=[]] - An array of shell commands.
|
|
862
877
|
* @param {boolean} [yaml=true] - If true, formats the output as YAML list items.
|
|
878
|
+
* @memberof UnderpostBaremetal
|
|
863
879
|
* @returns {string} The formatted string of commands.
|
|
864
880
|
*/
|
|
865
881
|
stepsRender(steps = [], yaml = true) {
|
|
@@ -892,6 +908,7 @@ EOF`);
|
|
|
892
908
|
* @param {string} params.workflowId - The identifier for the workflow configuration.
|
|
893
909
|
* @param {boolean} [params.mount] - If true, attempts to mount the NFS paths.
|
|
894
910
|
* @param {boolean} [params.unmount] - If true, attempts to unmount the NFS paths.
|
|
911
|
+
* @memberof UnderpostBaremetal
|
|
895
912
|
* @returns {{isMounted: boolean}} An object indicating whether any NFS path is currently mounted.
|
|
896
913
|
*/
|
|
897
914
|
nfsMountCallback({ hostname, workflowId, mount, unmount }) {
|
|
@@ -929,7 +946,8 @@ EOF`);
|
|
|
929
946
|
* @method getHostArch
|
|
930
947
|
* @description Determines the architecture of the host machine.
|
|
931
948
|
* This is crucial for cross-compilation and selecting the correct QEMU binaries.
|
|
932
|
-
* @
|
|
949
|
+
* @memberof UnderpostBaremetal
|
|
950
|
+
* @returns {{alias: 'amd64'|'arm64', name: 'x86_64'|'aarch64'}} The host architecture.
|
|
933
951
|
* @throws {Error} If the host architecture is unsupported.
|
|
934
952
|
*/
|
|
935
953
|
getHostArch() {
|
|
@@ -944,12 +962,16 @@ EOF`);
|
|
|
944
962
|
* @property {object} systemProvisioningFactory
|
|
945
963
|
* @description A factory object containing functions for system provisioning based on OS type.
|
|
946
964
|
* Each OS type (e.g., 'ubuntu') provides methods for base system setup, user creation,
|
|
947
|
-
* timezone configuration, and keyboard layout settings.
|
|
965
|
+
* timezone configuration, and keyboard layout settings. *
|
|
966
|
+
* @memberof UnderpostBaremetal
|
|
967
|
+
* @namespace UnderpostBaremetal.systemProvisioningFactory
|
|
948
968
|
*/
|
|
949
969
|
systemProvisioningFactory: {
|
|
950
970
|
/**
|
|
951
971
|
* @property {object} ubuntu
|
|
952
972
|
* @description Provisioning steps for Ubuntu-based systems.
|
|
973
|
+
* @memberof UnderpostBaremetal.systemProvisioningFactory
|
|
974
|
+
* @namespace UnderpostBaremetal.systemProvisioningFactory.ubuntu
|
|
953
975
|
*/
|
|
954
976
|
ubuntu: {
|
|
955
977
|
/**
|
|
@@ -959,6 +981,7 @@ EOF`);
|
|
|
959
981
|
* kernel modules, cloud-init, SSH server, and other core utilities.
|
|
960
982
|
* @param {object} params - The parameters for the function.
|
|
961
983
|
* @param {string} params.kernelLibVersion - The specific kernel library version to install.
|
|
984
|
+
* @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
|
|
962
985
|
* @returns {string[]} An array of shell commands.
|
|
963
986
|
*/
|
|
964
987
|
base: ({ kernelLibVersion }) => [
|
|
@@ -991,6 +1014,7 @@ SOURCES`,
|
|
|
991
1014
|
* @method user
|
|
992
1015
|
* @description Generates shell commands for creating a root user and configuring SSH access.
|
|
993
1016
|
* This is a critical security step for initial access to the provisioned system.
|
|
1017
|
+
* @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
|
|
994
1018
|
* @returns {string[]} An array of shell commands.
|
|
995
1019
|
*/
|
|
996
1020
|
user: () => [
|
|
@@ -1014,6 +1038,7 @@ SOURCES`,
|
|
|
1014
1038
|
* @param {string} params.timezone - The timezone string (e.g., 'America/New_York').
|
|
1015
1039
|
* @param {string} params.chronyConfPath - The path to the Chrony configuration file.
|
|
1016
1040
|
* @param {string} [alias='chrony'] - The alias for the chrony service.
|
|
1041
|
+
* @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
|
|
1017
1042
|
* @returns {string[]} An array of shell commands.
|
|
1018
1043
|
*/
|
|
1019
1044
|
timezone: ({ timezone, chronyConfPath }, alias = 'chrony') => [
|
|
@@ -1081,6 +1106,7 @@ logdir /var/log/chrony
|
|
|
1081
1106
|
* @method keyboard
|
|
1082
1107
|
* @description Generates shell commands for configuring the keyboard layout.
|
|
1083
1108
|
* This ensures correct input behavior on the provisioned system.
|
|
1109
|
+
* @memberof UnderpostBaremetal.systemProvisioningFactory.ubuntu
|
|
1084
1110
|
* @returns {string[]} An array of shell commands.
|
|
1085
1111
|
*/
|
|
1086
1112
|
keyboard: () => [
|
|
@@ -1099,6 +1125,7 @@ logdir /var/log/chrony
|
|
|
1099
1125
|
* This is crucial for allowing baremetal machines to boot via NFS.
|
|
1100
1126
|
* @param {object} params - The parameters for the function.
|
|
1101
1127
|
* @param {string} params.nfsHostPath - The path to be exported by the NFS server.
|
|
1128
|
+
* @memberof UnderpostBaremetal
|
|
1102
1129
|
* @param {string} [params.subnet='192.168.1.0/24'] - The subnet allowed to access the NFS export.
|
|
1103
1130
|
* @returns {void}
|
|
1104
1131
|
*/
|
|
@@ -1169,6 +1196,7 @@ udp-port = 32766
|
|
|
1169
1196
|
* @param {string} params.clientIp - The static IP address for the client device.
|
|
1170
1197
|
* @param {string} params.subnet - The subnet mask for the client device.
|
|
1171
1198
|
* @param {string} params.gateway - The gateway IP address for the client device.
|
|
1199
|
+
* @memberof UnderpostBaremetal
|
|
1172
1200
|
* @returns {string} The generated boot configuration content.
|
|
1173
1201
|
* @throws {Error} If an invalid workflow ID is provided.
|
|
1174
1202
|
*/
|
|
@@ -1229,12 +1257,14 @@ GATEWAY=${gateway}`;
|
|
|
1229
1257
|
* @property {object} workflowsConfig
|
|
1230
1258
|
* @description Configuration for different baremetal provisioning workflows.
|
|
1231
1259
|
* Each workflow defines specific parameters like system provisioning type,
|
|
1232
|
-
* kernel version, Chrony settings, debootstrap image details, and NFS mounts.
|
|
1260
|
+
* kernel version, Chrony settings, debootstrap image details, and NFS mounts. *
|
|
1261
|
+
* @memberof UnderpostBaremetal
|
|
1233
1262
|
*/
|
|
1234
1263
|
workflowsConfig: {
|
|
1235
1264
|
/**
|
|
1236
1265
|
* @property {object} rpi4mb
|
|
1237
1266
|
* @description Configuration for the Raspberry Pi 4 Model B workflow.
|
|
1267
|
+
* @memberof UnderpostBaremetal.workflowsConfig
|
|
1238
1268
|
*/
|
|
1239
1269
|
rpi4mb: {
|
|
1240
1270
|
menuentryStr: 'UNDERPOST.NET UEFI/GRUB/MAAS RPi4 commissioning (ARM64)',
|
package/src/cli/cloud-init.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud-init module for managing the generation and deployment of cloud-init configuration files
|
|
3
|
+
* and associated scripts for baremetal provisioning.
|
|
4
|
+
* @module src/cli/cloud-init.js
|
|
5
|
+
* @namespace UnderpostCloudInit
|
|
6
|
+
*/
|
|
7
|
+
|
|
1
8
|
import dotenv from 'dotenv';
|
|
2
9
|
import { shellExec } from '../server/process.js';
|
|
3
10
|
import fs from 'fs-extra';
|
|
@@ -15,6 +22,7 @@ const logger = loggerFactory(import.meta);
|
|
|
15
22
|
* and associated scripts for baremetal provisioning. This class provides methods
|
|
16
23
|
* to build various shell scripts and a cloud-init configuration file tailored
|
|
17
24
|
* for MAAS (Metal as a Service) integration.
|
|
25
|
+
* @memberof UnderpostCloudInit
|
|
18
26
|
*/
|
|
19
27
|
class UnderpostCloudInit {
|
|
20
28
|
static API = {
|
|
@@ -30,6 +38,7 @@ class UnderpostCloudInit {
|
|
|
30
38
|
* @param {object} params.callbackMetaData - Metadata about the callback, used for dynamic configuration.
|
|
31
39
|
* @param {boolean} params.dev - Development mode flag.
|
|
32
40
|
* @returns {void}
|
|
41
|
+
* @memberof UnderpostCloudInit
|
|
33
42
|
*/
|
|
34
43
|
buildTools({ workflowId, nfsHostPath, hostname, callbackMetaData, dev }) {
|
|
35
44
|
// Destructure workflow configuration for easier access.
|
|
@@ -281,6 +290,7 @@ curl -X POST \\
|
|
|
281
290
|
* @param {object} [authCredentials={}] - Optional MAAS authentication credentials.
|
|
282
291
|
* @param {string} [path='/etc/cloud/cloud.cfg.d/90_maas.cfg'] - The target path for the cloud-init configuration file.
|
|
283
292
|
* @returns {string} The generated cloud-init configuration content.
|
|
293
|
+
* @memberof UnderpostCloudInit
|
|
284
294
|
*/
|
|
285
295
|
configFactory(
|
|
286
296
|
{
|
|
@@ -494,6 +504,7 @@ EOF_MAAS_CFG`;
|
|
|
494
504
|
* This method parses the output of `maas apikey` to extract the consumer key,
|
|
495
505
|
* consumer secret, token key, and token secret.
|
|
496
506
|
* @returns {object} An object containing the MAAS authentication credentials.
|
|
507
|
+
* @memberof UnderpostCloudInit
|
|
497
508
|
* @throws {Error} If the MAAS API key format is invalid.
|
|
498
509
|
*/
|
|
499
510
|
authCredentialsFactory() {
|
package/src/cli/deploy.js
CHANGED
|
@@ -62,7 +62,7 @@ class UnderpostDeploy {
|
|
|
62
62
|
)
|
|
63
63
|
.join('');
|
|
64
64
|
},
|
|
65
|
-
deploymentYamlPartsFactory({ deployId, env, suffix, resources, replicas }) {
|
|
65
|
+
deploymentYamlPartsFactory({ deployId, env, suffix, resources, replicas, image }) {
|
|
66
66
|
return `apiVersion: apps/v1
|
|
67
67
|
kind: Deployment
|
|
68
68
|
metadata:
|
|
@@ -81,7 +81,7 @@ spec:
|
|
|
81
81
|
spec:
|
|
82
82
|
containers:
|
|
83
83
|
- name: ${deployId}-${env}-${suffix}
|
|
84
|
-
image: localhost/rockylinux9-underpost:${Underpost.version}
|
|
84
|
+
image: ${image ?? `localhost/rockylinux9-underpost:${Underpost.version}`}
|
|
85
85
|
# resources:
|
|
86
86
|
# requests:
|
|
87
87
|
# memory: "${resources.requests.memory}"
|
|
@@ -118,6 +118,7 @@ spec:
|
|
|
118
118
|
async buildManifest(deployList, env, options) {
|
|
119
119
|
const resources = UnderpostDeploy.API.resourcesFactory();
|
|
120
120
|
const replicas = options.replicas;
|
|
121
|
+
const image = options.image;
|
|
121
122
|
|
|
122
123
|
for (const _deployId of deployList.split(',')) {
|
|
123
124
|
const deployId = _deployId.trim();
|
|
@@ -144,6 +145,7 @@ ${UnderpostDeploy.API.deploymentYamlPartsFactory({
|
|
|
144
145
|
suffix: deploymentVersion,
|
|
145
146
|
resources,
|
|
146
147
|
replicas,
|
|
148
|
+
image,
|
|
147
149
|
}).replace('{{ports}}', buildKindPorts(fromPort, toPort))}
|
|
148
150
|
`;
|
|
149
151
|
}
|
|
@@ -241,6 +243,7 @@ spec:
|
|
|
241
243
|
expose: false,
|
|
242
244
|
cert: false,
|
|
243
245
|
versions: '',
|
|
246
|
+
image: '',
|
|
244
247
|
traffic: '',
|
|
245
248
|
replicas: '',
|
|
246
249
|
node: '',
|
package/src/cli/index.js
CHANGED
|
@@ -164,6 +164,7 @@ program
|
|
|
164
164
|
'Builds Kubernetes YAML manifests, including deployments, services, proxies, and secrets.',
|
|
165
165
|
)
|
|
166
166
|
.option('--replicas <replicas>', 'Sets a custom number of replicas for deployments.')
|
|
167
|
+
.option('--image <image>', 'Sets a custom image for deployments.')
|
|
167
168
|
.option('--versions <deployment-versions>', 'A comma-separated list of custom deployment versions.')
|
|
168
169
|
.option('--traffic <traffic-versions>', 'A comma-separated list of custom deployment traffic weights.')
|
|
169
170
|
.option('--disable-update-deployment', 'Disables updates to deployments.')
|
package/src/cli/lxd.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* LXD module for managing LXD virtual machines and networks.
|
|
3
|
+
* @module src/cli/lxd.js
|
|
4
|
+
* @namespace UnderpostLxd
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { getNpmRootPath } from '../server/conf.js';
|
|
2
8
|
import { getLocalIPv4Address } from '../server/dns.js';
|
|
3
9
|
import { pbcopy, shellExec } from '../server/process.js';
|
|
@@ -32,6 +38,7 @@ class UnderpostLxd {
|
|
|
32
38
|
* @param {string} [options.deleteExpose=''] - Delete exposed ports from a VM (format: 'vmName:port1,port2').
|
|
33
39
|
* @param {string} [options.test=''] - Test health, status and network connectivity for a VM.
|
|
34
40
|
* @param {string} [options.autoExposeK8sPorts=''] - Automatically expose common Kubernetes ports for the VM.
|
|
41
|
+
* @memberof UnderpostLxd
|
|
35
42
|
*/
|
|
36
43
|
async callback(
|
|
37
44
|
options = {
|
package/src/cli/run.js
CHANGED
|
@@ -131,6 +131,7 @@ class UnderpostRun {
|
|
|
131
131
|
actionInitLog();
|
|
132
132
|
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
133
133
|
shellCd('/home/dd/engine');
|
|
134
|
+
shellExec(`node bin/build dd-${path.split('engine-')[1]} conf`);
|
|
134
135
|
shellExec(`git reset`);
|
|
135
136
|
shellExec(`${baseCommand} cmt . --empty cd ssh-${path}`);
|
|
136
137
|
shellExec(`${baseCommand} push . underpostnet/engine`);
|
|
@@ -149,13 +150,24 @@ class UnderpostRun {
|
|
|
149
150
|
let [deployId, subConf] = path.split(',');
|
|
150
151
|
shellExec(`npm run dev-api ${deployId} ${subConf}`);
|
|
151
152
|
},
|
|
152
|
-
|
|
153
|
+
sync: (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
154
|
+
const env = options.dev ? 'development' : 'production';
|
|
153
155
|
const baseCommand = options.dev || true ? 'node bin' : 'underpost';
|
|
154
|
-
|
|
155
|
-
|
|
156
|
+
shellExec(`${baseCommand} run clean`);
|
|
157
|
+
const defaultPaht = ['dd', 1, ``, 'kind-control-plane'];
|
|
158
|
+
let [deployId, replicas, image, node] = path ? path.split(',') : defaultPaht;
|
|
156
159
|
deployId = deployId ?? defaultPaht[0];
|
|
157
|
-
|
|
158
|
-
|
|
160
|
+
replicas = replicas ?? defaultPaht[1];
|
|
161
|
+
image = image ?? defaultPaht[2];
|
|
162
|
+
node = node ?? defaultPaht[3];
|
|
163
|
+
shellExec(
|
|
164
|
+
`${baseCommand} deploy --kubeadm --build-manifest --sync --info-router --replicas ${
|
|
165
|
+
replicas ?? 1
|
|
166
|
+
} --node ${node}${image ? ` --image ${image}` : ''} ${deployId} ${env}`,
|
|
167
|
+
);
|
|
168
|
+
},
|
|
169
|
+
'ls-deployments': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
170
|
+
console.table(await UnderpostDeploy.API.get(path, 'deployments'));
|
|
159
171
|
},
|
|
160
172
|
monitor: (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
161
173
|
const pid = getTerminalPid();
|
package/src/cli/ssh.js
CHANGED
|
@@ -1,23 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* SSH module for managing SSH key generation and connection setup.
|
|
3
|
+
* @module src/cli/ssh.js
|
|
4
|
+
* @namespace UnderpostSSH
|
|
5
|
+
*/
|
|
6
|
+
|
|
2
7
|
import { shellExec } from '../server/process.js';
|
|
3
8
|
|
|
9
|
+
/**
|
|
10
|
+
* @class UnderpostSSH
|
|
11
|
+
* @description Manages SSH key generation and connection setup.
|
|
12
|
+
* @memberof UnderpostSSH
|
|
13
|
+
*/
|
|
4
14
|
class UnderpostSSH {
|
|
5
15
|
static API = {
|
|
6
16
|
/**
|
|
7
17
|
* @method callback
|
|
8
|
-
* @
|
|
9
|
-
*
|
|
10
|
-
*
|
|
18
|
+
* @description Manages SSH key generation and connection setup based on the default deployment ID.
|
|
19
|
+
* This function will either generate a new SSH key pair or import an existing one,
|
|
20
|
+
* then initiate the SSH connection process.
|
|
21
|
+
* @param {object} [options={ generate: false }] - Options for the SSH callback.
|
|
22
|
+
* @param {boolean} [options.generate=false] - If true, generates a new SSH key pair. Otherwise, it imports the existing one.
|
|
23
|
+
* @memberof UnderpostSSH
|
|
24
|
+
* @returns {Promise<void>}
|
|
11
25
|
*/
|
|
12
26
|
callback: async (
|
|
13
27
|
options = {
|
|
14
28
|
generate: false,
|
|
15
29
|
},
|
|
16
30
|
) => {
|
|
17
|
-
//
|
|
31
|
+
// Example usage for importing an existing key:
|
|
18
32
|
// node bin/deploy ssh root@<host> <password> import
|
|
19
33
|
|
|
20
|
-
//
|
|
34
|
+
// Example usage for generating a new key:
|
|
21
35
|
// node bin/deploy ssh root@<host> <password>
|
|
22
36
|
|
|
23
37
|
shellExec(
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { ThemeEvents, darkTheme } from './Css.js';
|
|
5
5
|
import { append, htmls, s } from './VanillaJs.js';
|
|
6
6
|
import { getProxyPath } from './Router.js';
|
|
7
|
+
import './Pagination.js';
|
|
7
8
|
|
|
8
9
|
const AgGrid = {
|
|
9
10
|
grids: {},
|
|
@@ -14,6 +15,9 @@ const AgGrid = {
|
|
|
14
15
|
// Grid Options: Contains all of the grid configurations
|
|
15
16
|
const gridOptions = {
|
|
16
17
|
// Row Data: The data to be displayed.
|
|
18
|
+
pagination: false, // Disabled by default, will be handled by the management view
|
|
19
|
+
// paginationPageSize: 100,
|
|
20
|
+
// suppressPaginationPanel: true, // We are using our own custom pagination component
|
|
17
21
|
// rowHeight: 60,
|
|
18
22
|
enableCellChangeFlash: true,
|
|
19
23
|
defaultColDef: {
|
|
@@ -23,6 +27,12 @@ const AgGrid = {
|
|
|
23
27
|
filter: true,
|
|
24
28
|
autoHeight: true,
|
|
25
29
|
},
|
|
30
|
+
rowClassRules: {
|
|
31
|
+
'row-new-highlight': (params) => {
|
|
32
|
+
// a temporary flag we can set on new rows to highlight them
|
|
33
|
+
return params.data && params.data._new;
|
|
34
|
+
},
|
|
35
|
+
},
|
|
26
36
|
// domLayout: 'autoHeight', || 'normal'
|
|
27
37
|
// Column Definitions: Defines & controls grid columns.
|
|
28
38
|
columnDefs: options?.gridOptions?.rowData?.[0]
|
|
@@ -48,13 +58,17 @@ const AgGrid = {
|
|
|
48
58
|
}
|
|
49
59
|
};
|
|
50
60
|
});
|
|
61
|
+
const usePagination = options?.usePagination;
|
|
51
62
|
return html`
|
|
52
|
-
<div
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
63
|
+
<div>
|
|
64
|
+
<div
|
|
65
|
+
class="${id} ${this.theme}${options?.darkTheme ? `-dark` : ''}"
|
|
66
|
+
style="${options?.style
|
|
67
|
+
? Object.keys(options.style).map((styleKey) => `${styleKey}: ${options.style[styleKey]}; `)
|
|
68
|
+
: 'height: 500px'}"
|
|
69
|
+
></div>
|
|
70
|
+
${usePagination ? `<ag-pagination id="ag-pagination-${id}"></ag-pagination>` : ''}
|
|
71
|
+
</div>
|
|
58
72
|
`;
|
|
59
73
|
},
|
|
60
74
|
RenderStyle: async function (
|
|
@@ -136,6 +150,10 @@ const AgGrid = {
|
|
|
136
150
|
${darkTheme
|
|
137
151
|
? html`
|
|
138
152
|
<style>
|
|
153
|
+
.ag-row.row-new-highlight {
|
|
154
|
+
background-color: #6d68ff !important;
|
|
155
|
+
transition: background-color 1s ease-out;
|
|
156
|
+
}
|
|
139
157
|
.ag-cell-data-changed,
|
|
140
158
|
.ag-cell-data-changed-animation {
|
|
141
159
|
background-color: #6d68ff !important;
|
|
@@ -145,6 +163,10 @@ const AgGrid = {
|
|
|
145
163
|
</style>
|
|
146
164
|
`
|
|
147
165
|
: html`<style>
|
|
166
|
+
.ag-row.row-new-highlight {
|
|
167
|
+
background-color: #d0eaf8 !important;
|
|
168
|
+
transition: background-color 1s ease-out;
|
|
169
|
+
}
|
|
148
170
|
.ag-cell-data-changed,
|
|
149
171
|
.ag-cell-data-changed-animation {
|
|
150
172
|
background-color: #d1d1d1 !important;
|
|
@@ -8,12 +8,14 @@ import { SignUp } from './SignUp.js';
|
|
|
8
8
|
import { Translate } from './Translate.js';
|
|
9
9
|
import { s } from './VanillaJs.js';
|
|
10
10
|
|
|
11
|
-
const logger = loggerFactory(import.meta);
|
|
11
|
+
const logger = loggerFactory(import.meta, { trace: true });
|
|
12
12
|
|
|
13
13
|
const token = Symbol('token');
|
|
14
14
|
|
|
15
15
|
const guestToken = Symbol('guestToken');
|
|
16
16
|
|
|
17
|
+
const refreshTimeout = Symbol('refreshTimeout');
|
|
18
|
+
|
|
17
19
|
const Auth = {
|
|
18
20
|
[token]: '',
|
|
19
21
|
[guestToken]: '',
|
|
@@ -35,50 +37,65 @@ const Auth = {
|
|
|
35
37
|
getGuestToken: function () {
|
|
36
38
|
return this[guestToken];
|
|
37
39
|
},
|
|
38
|
-
// jwt
|
|
39
40
|
getJWT: function () {
|
|
40
|
-
return `Bearer ${
|
|
41
|
+
if (Auth.getToken()) return `Bearer ${Auth.getToken()}`;
|
|
42
|
+
if (Auth.getGuestToken()) return `Bearer ${Auth.getGuestToken()}`;
|
|
43
|
+
return '';
|
|
41
44
|
},
|
|
42
|
-
|
|
43
|
-
result = {
|
|
44
|
-
data: {
|
|
45
|
-
token: '',
|
|
46
|
-
user: null,
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
) {
|
|
45
|
+
decodeJwt: function (token) {
|
|
50
46
|
try {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
} catch (error) {
|
|
55
|
-
logger.error(error);
|
|
56
|
-
localStorage.removeItem('jwt');
|
|
47
|
+
return JSON.parse(atob(token.split('.')[1]));
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return null;
|
|
57
50
|
}
|
|
58
51
|
},
|
|
52
|
+
scheduleTokenRefresh: function () {
|
|
53
|
+
if (this[refreshTimeout]) {
|
|
54
|
+
clearTimeout(this[refreshTimeout]);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const currentToken = Auth.getToken();
|
|
58
|
+
if (!currentToken) return;
|
|
59
|
+
|
|
60
|
+
const payload = Auth.decodeJwt(currentToken);
|
|
61
|
+
if (!payload || !payload.refreshExpiresAt) return;
|
|
62
|
+
|
|
63
|
+
const expiresIn = payload.refreshExpiresAt - Date.now();
|
|
64
|
+
const refreshBuffer = 2 * 60 * 1000; // 2 minutes
|
|
65
|
+
const refreshIn = expiresIn - refreshBuffer;
|
|
66
|
+
|
|
67
|
+
logger.info(`Token refresh in ${refreshIn / (1000 * 60)} minutes`);
|
|
68
|
+
|
|
69
|
+
if (refreshIn <= 0) return; // Already expired or close to it
|
|
70
|
+
|
|
71
|
+
this[refreshTimeout] = setTimeout(async () => {
|
|
72
|
+
const { data, status } = await UserService.get({ id: 'auth' });
|
|
73
|
+
if (status === 'success') {
|
|
74
|
+
logger.info('Refreshed access token.');
|
|
75
|
+
Auth.setToken(data.token);
|
|
76
|
+
localStorage.setItem('jwt', data.token);
|
|
77
|
+
Auth.scheduleTokenRefresh();
|
|
78
|
+
} else Auth.sessionOut();
|
|
79
|
+
}, refreshIn);
|
|
80
|
+
},
|
|
59
81
|
sessionIn: async function (userServicePayload) {
|
|
60
82
|
try {
|
|
61
83
|
const token = userServicePayload?.data?.token ? userServicePayload.data.token : localStorage.getItem('jwt');
|
|
62
|
-
|
|
63
84
|
if (token) {
|
|
64
|
-
|
|
85
|
+
Auth.setToken(token);
|
|
86
|
+
|
|
65
87
|
const result = userServicePayload
|
|
66
|
-
? userServicePayload
|
|
67
|
-
: await (
|
|
68
|
-
|
|
69
|
-
return {
|
|
70
|
-
status: _result.status,
|
|
71
|
-
message: _result.message,
|
|
72
|
-
data: {
|
|
73
|
-
user: _result.data,
|
|
74
|
-
},
|
|
75
|
-
};
|
|
76
|
-
})();
|
|
88
|
+
? userServicePayload // From login/signup
|
|
89
|
+
: await UserService.get({ id: 'auth' });
|
|
90
|
+
|
|
77
91
|
const { status, data, message } = result;
|
|
78
92
|
if (status === 'success') {
|
|
93
|
+
Auth.setToken(data.token);
|
|
79
94
|
localStorage.setItem('jwt', token);
|
|
95
|
+
Auth.renderSessionUI();
|
|
80
96
|
await LogIn.Trigger({ user: data.user });
|
|
81
97
|
await Account.updateForm(data.user);
|
|
98
|
+
Auth.scheduleTokenRefresh();
|
|
82
99
|
return { user: data.user };
|
|
83
100
|
}
|
|
84
101
|
if (message && message.match('expired'))
|
|
@@ -89,41 +106,67 @@ const Auth = {
|
|
|
89
106
|
status: 'warning',
|
|
90
107
|
});
|
|
91
108
|
});
|
|
92
|
-
return await Auth.sessionOut();
|
|
93
109
|
}
|
|
94
|
-
|
|
95
|
-
// anon guest session
|
|
96
|
-
this.deleteToken();
|
|
110
|
+
Auth.deleteToken();
|
|
97
111
|
localStorage.removeItem('jwt');
|
|
98
|
-
let guestToken = localStorage.getItem('jwt.g');
|
|
99
112
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
guestToken
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
localStorage.removeItem('jwt.g');
|
|
111
|
-
return await Auth.sessionOut();
|
|
112
|
-
} else throw new Error(message);
|
|
113
|
+
// Anon guest session
|
|
114
|
+
let guestToken = localStorage.getItem('jwt.g');
|
|
115
|
+
if (guestToken) {
|
|
116
|
+
Auth.setGuestToken(guestToken);
|
|
117
|
+
let { data, status, message } = await UserService.get({ id: 'auth' });
|
|
118
|
+
if (status === 'success') {
|
|
119
|
+
await LogIn.Trigger(data);
|
|
120
|
+
await Account.updateForm(data.user);
|
|
121
|
+
return data;
|
|
122
|
+
} else logger.error(message);
|
|
113
123
|
}
|
|
114
|
-
await
|
|
115
|
-
return { user: data };
|
|
124
|
+
return await Auth.sessionOut();
|
|
116
125
|
} catch (error) {
|
|
117
126
|
logger.error(error);
|
|
118
127
|
return { user: UserMock.default };
|
|
119
128
|
}
|
|
120
129
|
},
|
|
121
130
|
sessionOut: async function () {
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
{
|
|
132
|
+
const result = await UserService.delete({ id: 'logout' });
|
|
133
|
+
localStorage.removeItem('jwt');
|
|
134
|
+
Auth.deleteToken();
|
|
135
|
+
if (this[refreshTimeout]) {
|
|
136
|
+
clearTimeout(this[refreshTimeout]);
|
|
137
|
+
}
|
|
138
|
+
Auth.renderGuestUi();
|
|
139
|
+
LogIn.Scope.user.main.model.user = {};
|
|
140
|
+
await LogOut.Trigger(result);
|
|
141
|
+
}
|
|
142
|
+
{
|
|
143
|
+
localStorage.removeItem('jwt.g');
|
|
144
|
+
Auth.deleteGuestToken();
|
|
145
|
+
const result = await UserService.post({ id: 'guest' });
|
|
146
|
+
localStorage.setItem('jwt.g', result.data.token);
|
|
147
|
+
Auth.setGuestToken(result.data.token);
|
|
148
|
+
return await Auth.sessionIn();
|
|
149
|
+
}
|
|
150
|
+
},
|
|
151
|
+
renderSessionUI: function () {
|
|
152
|
+
s(`.main-btn-log-in`).style.display = 'none';
|
|
153
|
+
s(`.main-btn-sign-up`).style.display = 'none';
|
|
154
|
+
s(`.main-btn-log-out`).style.display = null;
|
|
155
|
+
s(`.main-btn-account`).style.display = null;
|
|
156
|
+
setTimeout(() => {
|
|
157
|
+
if (s(`.modal-log-in`)) s(`.btn-close-modal-log-in`).click();
|
|
158
|
+
if (s(`.modal-sign-up`)) s(`.btn-close-modal-sign-up`).click();
|
|
159
|
+
});
|
|
160
|
+
},
|
|
161
|
+
renderGuestUi: function () {
|
|
162
|
+
s(`.main-btn-log-in`).style.display = null;
|
|
163
|
+
s(`.main-btn-sign-up`).style.display = null;
|
|
164
|
+
s(`.main-btn-log-out`).style.display = 'none';
|
|
165
|
+
s(`.main-btn-account`).style.display = 'none';
|
|
166
|
+
setTimeout(() => {
|
|
167
|
+
if (s(`.modal-log-out`)) s(`.btn-close-modal-log-out`).click();
|
|
168
|
+
if (s(`.modal-account`)) s(`.btn-close-modal-account`).click();
|
|
169
|
+
});
|
|
127
170
|
},
|
|
128
171
|
};
|
|
129
172
|
|