underpost 2.8.884 → 2.8.886
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.production +3 -0
- package/.github/workflows/ghpkg.ci.yml +1 -1
- package/.github/workflows/npmpkg.ci.yml +1 -1
- package/.github/workflows/publish.ci.yml +5 -5
- package/.github/workflows/pwa-microservices-template-page.cd.yml +1 -1
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/CHANGELOG.md +145 -1
- package/Dockerfile +1 -1
- package/README.md +5 -121
- package/bin/build.js +18 -9
- package/bin/deploy.js +102 -197
- package/bin/file.js +4 -6
- package/cli.md +16 -12
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +54 -54
- package/manifests/deployment/dd-test-development/proxy.yaml +4 -4
- package/manifests/lxd/underpost-setup.sh +5 -5
- package/package.json +3 -3
- package/scripts/ssl.sh +164 -0
- package/src/cli/baremetal.js +7 -7
- package/src/cli/cloud-init.js +1 -1
- package/src/cli/cluster.js +31 -3
- package/src/cli/cron.js +9 -1
- package/src/cli/db.js +64 -2
- package/src/cli/deploy.js +189 -4
- package/src/cli/env.js +43 -0
- package/src/cli/fs.js +96 -2
- package/src/cli/image.js +15 -0
- package/src/cli/index.js +17 -4
- package/src/cli/monitor.js +33 -2
- package/src/cli/repository.js +95 -2
- package/src/cli/run.js +315 -51
- package/src/cli/script.js +32 -0
- package/src/cli/secrets.js +34 -0
- package/src/cli/test.js +42 -1
- package/src/client/components/core/Css.js +16 -8
- package/src/client/components/core/Docs.js +5 -13
- package/src/client/components/core/Modal.js +48 -29
- package/src/client/components/core/Router.js +6 -3
- package/src/client/components/core/Worker.js +205 -118
- package/src/client/components/core/windowGetDimensions.js +229 -162
- package/src/client/components/default/MenuDefault.js +1 -0
- package/src/client.dev.js +6 -3
- package/src/db/DataBaseProvider.js +65 -12
- package/src/db/mariadb/MariaDB.js +39 -6
- package/src/db/mongo/MongooseDB.js +51 -133
- package/src/index.js +2 -2
- package/src/mailer/EmailRender.js +58 -9
- package/src/mailer/MailerProvider.js +99 -25
- package/src/runtime/express/Express.js +32 -38
- package/src/runtime/lampp/Dockerfile +1 -1
- package/src/server/auth.js +9 -28
- package/src/server/backup.js +20 -0
- package/src/server/client-build-live.js +23 -12
- package/src/server/client-build.js +136 -91
- package/src/server/client-dev-server.js +35 -8
- package/src/server/client-icons.js +19 -0
- package/src/server/conf.js +543 -80
- package/src/server/dns.js +184 -42
- package/src/server/downloader.js +65 -24
- package/src/server/object-layer.js +260 -162
- package/src/server/peer.js +3 -9
- package/src/server/proxy.js +93 -76
- package/src/server/runtime.js +15 -21
- package/src/server/ssr.js +4 -4
- package/src/server/start.js +39 -0
- package/src/server/tls.js +251 -0
- package/src/server/valkey.js +11 -10
- package/src/ws/IoInterface.js +133 -39
- package/src/ws/IoServer.js +80 -31
- package/src/ws/core/core.ws.connection.js +50 -16
- package/src/ws/core/core.ws.emit.js +47 -8
- package/src/ws/core/core.ws.server.js +62 -10
- package/manifests/maas/lxd-preseed.yaml +0 -32
- package/src/server/ssl.js +0 -108
- /package/{manifests/maas → scripts}/device-scan.sh +0 -0
- /package/{manifests/maas → scripts}/gpu-diag.sh +0 -0
- /package/{manifests/maas → scripts}/maas-setup.sh +0 -0
- /package/{manifests/maas → scripts}/nat-iptables.sh +0 -0
- /package/{manifests/maas → scripts}/nvim.sh +0 -0
- /package/{manifests/maas → scripts}/snap-clean.sh +0 -0
- /package/{manifests/maas → scripts}/ssh-cluster-info.sh +0 -0
package/src/cli/monitor.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Monitor module for managing the monitoring of deployments and services.
|
|
3
|
+
* @module src/cli/monitor.js
|
|
4
|
+
* @namespace UnderpostMonitor
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { loadReplicas, pathPortAssignmentFactory } from '../server/conf.js';
|
|
2
8
|
import { loggerFactory } from '../server/logger.js';
|
|
3
9
|
import UnderpostDeploy from './deploy.js';
|
|
@@ -9,8 +15,34 @@ import { isInternetConnection } from '../server/dns.js';
|
|
|
9
15
|
|
|
10
16
|
const logger = loggerFactory(import.meta);
|
|
11
17
|
|
|
18
|
+
/**
|
|
19
|
+
* @class UnderpostMonitor
|
|
20
|
+
* @description Manages deployment monitoring and health checks.
|
|
21
|
+
* This class provides a set of static methods to monitor and manage
|
|
22
|
+
* deployment health, including checking server status, handling traffic
|
|
23
|
+
* switching, and orchestrating monitoring workflows.
|
|
24
|
+
* @memberof UnderpostMonitor
|
|
25
|
+
*/
|
|
12
26
|
class UnderpostMonitor {
|
|
13
27
|
static API = {
|
|
28
|
+
/**
|
|
29
|
+
* @method callback
|
|
30
|
+
* @description Initiates a deployment monitoring workflow based on the provided options.
|
|
31
|
+
* This method orchestrates the monitoring process for a specific deployment, handling
|
|
32
|
+
* traffic switching, error accumulation, and optional Git integration for version control.
|
|
33
|
+
* @param {string} deployId - The identifier for the deployment to monitor.
|
|
34
|
+
* @param {string} [env='development'] - The environment for the deployment (e.g., 'development', 'production').
|
|
35
|
+
* @param {object} [options] - An object containing boolean flags for various operations.
|
|
36
|
+
* @param {boolean} [options.now=false] - Perform a single health check immediately.
|
|
37
|
+
* @param {boolean} [options.single=false] - Perform a single health check and exit.
|
|
38
|
+
* @param {string} [options.msInterval=''] - Interval in milliseconds for periodic health checks.
|
|
39
|
+
* @param {string} [options.type=''] - Type of deployment (e.g., 'blue-green', 'remote').
|
|
40
|
+
* @param {string} [options.replicas=''] - Number of replicas for the deployment.
|
|
41
|
+
* @param {boolean} [options.sync=false] - Synchronize traffic switching with the deployment.
|
|
42
|
+
* @param {object} [commanderOptions] - Options passed from the command line interface.
|
|
43
|
+
* @param {object} [auxRouter] - Optional router configuration for the deployment.
|
|
44
|
+
* @memberof UnderpostMonitor
|
|
45
|
+
*/
|
|
14
46
|
async callback(
|
|
15
47
|
deployId,
|
|
16
48
|
env = 'development',
|
|
@@ -34,10 +66,9 @@ class UnderpostMonitor {
|
|
|
34
66
|
|
|
35
67
|
const confServer = loadReplicas(
|
|
36
68
|
JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8')),
|
|
37
|
-
'proxy',
|
|
38
69
|
);
|
|
39
70
|
|
|
40
|
-
const pathPortAssignmentData = pathPortAssignmentFactory(router, confServer);
|
|
71
|
+
const pathPortAssignmentData = await pathPortAssignmentFactory(deployId, router, confServer);
|
|
41
72
|
|
|
42
73
|
let errorPayloads = [];
|
|
43
74
|
if (options.sync === true) {
|
package/src/cli/repository.js
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Repository module for managing Git operations and configurations.
|
|
3
|
+
* @module src/cli/repository.js
|
|
4
|
+
* @namespace UnderpostRepository
|
|
5
|
+
*/
|
|
6
|
+
|
|
1
7
|
import { commitData } from '../client/components/core/CommonJs.js';
|
|
2
8
|
import dotenv from 'dotenv';
|
|
3
9
|
import { pbcopy, shellCd, shellExec } from '../server/process.js';
|
|
@@ -11,8 +17,23 @@ dotenv.config();
|
|
|
11
17
|
|
|
12
18
|
const logger = loggerFactory(import.meta);
|
|
13
19
|
|
|
20
|
+
/**
|
|
21
|
+
* @class UnderpostRepository
|
|
22
|
+
* @description Manages Git operations and configurations.
|
|
23
|
+
* This class provides a set of static methods to automate various
|
|
24
|
+
* Git operations, including cloning, pulling, and committing changes.
|
|
25
|
+
* @memberof UnderpostRepository
|
|
26
|
+
*/
|
|
14
27
|
class UnderpostRepository {
|
|
15
28
|
static API = {
|
|
29
|
+
/**
|
|
30
|
+
* Clones a Git repository from GitHub.
|
|
31
|
+
* @param {string} [gitUri=`${process.env.GITHUB_USERNAME}/pwa-microservices-template`] - The URI of the GitHub repository (e.g., "username/repository").
|
|
32
|
+
* @param {object} [options={ bare: false, g8: false }] - Cloning options.
|
|
33
|
+
* @param {boolean} [options.bare=false] - If true, performs a bare clone.
|
|
34
|
+
* @param {boolean} [options.g8=false] - If true, uses the .g8 extension.
|
|
35
|
+
* @memberof UnderpostRepository
|
|
36
|
+
*/
|
|
16
37
|
clone(gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`, options = { bare: false, g8: false }) {
|
|
17
38
|
const gExtension = options.g8 === true ? '.g8' : '.git';
|
|
18
39
|
const repoName = gitUri.split('/').pop();
|
|
@@ -26,6 +47,14 @@ class UnderpostRepository {
|
|
|
26
47
|
},
|
|
27
48
|
);
|
|
28
49
|
},
|
|
50
|
+
/**
|
|
51
|
+
* Pulls updates from a GitHub repository.
|
|
52
|
+
* @param {string} [repoPath='./'] - The local path to the repository.
|
|
53
|
+
* @param {string} [gitUri=`${process.env.GITHUB_USERNAME}/pwa-microservices-template`] - The URI of the GitHub repository.
|
|
54
|
+
* @param {object} [options={ g8: false }] - Pulling options.
|
|
55
|
+
* @param {boolean} [options.g8=false] - If true, uses the .g8 extension.
|
|
56
|
+
* @memberof UnderpostRepository
|
|
57
|
+
*/
|
|
29
58
|
pull(
|
|
30
59
|
repoPath = './',
|
|
31
60
|
gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`,
|
|
@@ -41,6 +70,18 @@ class UnderpostRepository {
|
|
|
41
70
|
},
|
|
42
71
|
);
|
|
43
72
|
},
|
|
73
|
+
/**
|
|
74
|
+
* Creates a Git commit with a conventional commit message.
|
|
75
|
+
* @param {string} [repoPath='./'] - The local path to the repository.
|
|
76
|
+
* @param {string} [commitType='feat'] - The type of commit (e.g., 'feat', 'fix', 'docs', 'reset').
|
|
77
|
+
* @param {string} [subModule=''] - The submodule or scope of the commit.
|
|
78
|
+
* @param {string} [message=''] - The commit message.
|
|
79
|
+
* @param {object} [options={ copy: false, info: false, empty: false }] - Commit options.
|
|
80
|
+
* @param {boolean} [options.copy=false] - If true, copies the commit message to the clipboard.
|
|
81
|
+
* @param {boolean} [options.info=false] - If true, displays information about commit types.
|
|
82
|
+
* @param {boolean} [options.empty=false] - If true, allows an empty commit.
|
|
83
|
+
* @memberof UnderpostRepository
|
|
84
|
+
*/
|
|
44
85
|
commit(
|
|
45
86
|
repoPath = './',
|
|
46
87
|
commitType = 'feat',
|
|
@@ -65,9 +106,18 @@ class UnderpostRepository {
|
|
|
65
106
|
shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
|
|
66
107
|
},
|
|
67
108
|
|
|
109
|
+
/**
|
|
110
|
+
* Pushes commits to a remote GitHub repository.
|
|
111
|
+
* @param {string} [repoPath='./'] - The local path to the repository.
|
|
112
|
+
* @param {string} [gitUri=`${process.env.GITHUB_USERNAME}/pwa-microservices-template`] - The URI of the GitHub repository.
|
|
113
|
+
* @param {object} [options={ f: false, g8: false }] - Push options.
|
|
114
|
+
* @param {boolean} [options.f=false] - If true, forces the push.
|
|
115
|
+
* @param {boolean} [options.g8=false] - If true, uses the .g8 extension.
|
|
116
|
+
* @memberof UnderpostRepository
|
|
117
|
+
*/
|
|
68
118
|
push(
|
|
69
119
|
repoPath = './',
|
|
70
|
-
gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template
|
|
120
|
+
gitUri = `${process.env.GITHUB_USERNAME}/pwa-microservices-template`,
|
|
71
121
|
options = { f: false, g8: false },
|
|
72
122
|
) {
|
|
73
123
|
const gExtension = options.g8 === true || options.G8 === true ? '.g8' : '.git';
|
|
@@ -90,11 +140,34 @@ class UnderpostRepository {
|
|
|
90
140
|
);
|
|
91
141
|
},
|
|
92
142
|
|
|
93
|
-
|
|
143
|
+
/**
|
|
144
|
+
* Creates a new Underpost project, service, or configuration.
|
|
145
|
+
* @param {string} repositoryName - The name of the new project or service, or a deployId.
|
|
146
|
+
* @param {object} [options={ dev: false, deployId: false, cluster: false, subConf: '' }] - Creation options.
|
|
147
|
+
* @param {boolean} [options.dev=false] - If true, sets up a development project.
|
|
148
|
+
* @param {boolean} [options.deployId=false] - If true, creates deploy ID configuration files.
|
|
149
|
+
* @param {boolean} [options.cluster=false] - If true, creates cluster configuration files.
|
|
150
|
+
* @param {string} [options.subConf=''] - If provided, creates a sub-configuration for a deployId.
|
|
151
|
+
* @returns {Promise<void>} A promise that resolves when the operation is complete.
|
|
152
|
+
* @memberof UnderpostRepository
|
|
153
|
+
*/
|
|
154
|
+
new(repositoryName, options = { dev: false, deployId: false, cluster: false, subConf: '' }) {
|
|
94
155
|
return new Promise(async (resolve, reject) => {
|
|
95
156
|
try {
|
|
96
157
|
await logger.setUpInfo();
|
|
97
158
|
actionInitLog();
|
|
159
|
+
if (options.subConf && typeof options.subConf === 'string') {
|
|
160
|
+
const deployId = repositoryName;
|
|
161
|
+
logger.info('Creating sub conf', {
|
|
162
|
+
deployId,
|
|
163
|
+
subConf: options.subConf,
|
|
164
|
+
});
|
|
165
|
+
fs.copySync(
|
|
166
|
+
`./engine-private/conf/${deployId}/conf.server.json`,
|
|
167
|
+
`./engine-private/conf/${deployId}/conf.server.dev.${options.subConf}.json`,
|
|
168
|
+
);
|
|
169
|
+
return resolve();
|
|
170
|
+
}
|
|
98
171
|
if (repositoryName === 'service')
|
|
99
172
|
return resolve(
|
|
100
173
|
await UnderpostStartUp.API.listenPortController(UnderpostStartUp.API.listenServerFactory(), ':'),
|
|
@@ -126,12 +199,26 @@ class UnderpostRepository {
|
|
|
126
199
|
});
|
|
127
200
|
},
|
|
128
201
|
|
|
202
|
+
/**
|
|
203
|
+
* Gets a list of deleted files from a Git repository.
|
|
204
|
+
* @param {string} [path='.'] - The path to the repository.
|
|
205
|
+
* @returns {string[]} An array of deleted file paths.
|
|
206
|
+
* @memberof UnderpostRepository
|
|
207
|
+
*/
|
|
129
208
|
getDeleteFiles(path = '.') {
|
|
130
209
|
const commandUntrack = `cd ${path} && git ls-files --deleted`;
|
|
131
210
|
const diffUntrackOutput = shellExec(commandUntrack, { stdout: true, silent: true });
|
|
132
211
|
return diffUntrackOutput.toString().split('\n').filter(Boolean);
|
|
133
212
|
},
|
|
134
213
|
|
|
214
|
+
/**
|
|
215
|
+
* Gets a list of changed (modified and untracked) files in a Git repository.
|
|
216
|
+
* @param {string} [path='.'] - The path to the repository.
|
|
217
|
+
* @param {string} [extension=''] - An optional file extension to filter by.
|
|
218
|
+
* @param {boolean} [head=false] - If true, diffs against HEAD^.
|
|
219
|
+
* @returns {string[]} An array of changed file paths.
|
|
220
|
+
* @memberof UnderpostRepository
|
|
221
|
+
*/
|
|
135
222
|
getChangedFiles(path = '.', extension = '', head = false) {
|
|
136
223
|
const extensionFilter = extension ? `-- '***.${extension}'` : '';
|
|
137
224
|
const command = `cd ${path} && git diff ${head ? 'HEAD^ HEAD ' : ''}--name-only ${extensionFilter}`;
|
|
@@ -146,6 +233,12 @@ class UnderpostRepository {
|
|
|
146
233
|
.concat(diffUntrackOutput.toString().split('\n').filter(Boolean))
|
|
147
234
|
.filter((f) => !deleteFiles.includes(f));
|
|
148
235
|
},
|
|
236
|
+
/**
|
|
237
|
+
* Updates the private configuration repository for a given deployId.
|
|
238
|
+
* @param {string} deployId - The deployment ID.
|
|
239
|
+
* @returns {{validVersion: boolean, engineVersion: string, deployVersion: string}} An object indicating if the versions are valid.
|
|
240
|
+
* @memberof UnderpostRepository
|
|
241
|
+
*/
|
|
149
242
|
privateConfUpdate(deployId) {
|
|
150
243
|
shellCd(`/home/dd/engine`);
|
|
151
244
|
const privateRepoName = `engine-${deployId.split('dd-')[1]}-private`;
|