underpost 2.8.882 → 2.8.883

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
@@ -66,13 +66,15 @@
66
66
 
67
67
 
68
68
 
69
+
70
+
69
71
 
70
72
 
71
73
 
72
74
  <!-- badges -->
73
75
 
74
76
 
75
- [![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.882)](https://socket.dev/npm/package/underpost/overview/2.8.882) [![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)
77
+ [![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.883)](https://socket.dev/npm/package/underpost/overview/2.8.883) [![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)
76
78
 
77
79
 
78
80
  <!-- end-badges -->
@@ -127,6 +129,8 @@
127
129
 
128
130
 
129
131
 
132
+
133
+
130
134
 
131
135
 
132
136
 
@@ -174,7 +178,7 @@ Run dev client server
174
178
  npm run dev
175
179
  ```
176
180
  <!-- -->
177
- ## underpost ci/cd cli v2.8.882
181
+ ## underpost ci/cd cli v2.8.883
178
182
 
179
183
  ### Usage: `underpost [options] [command]`
180
184
  ```
package/bin/db.js CHANGED
@@ -2,7 +2,6 @@ import fs from 'fs-extra';
2
2
  import { shellExec } from '../src/server/process.js';
3
3
  import { loggerFactory } from '../src/server/logger.js';
4
4
  import { MariaDB } from '../src/db/mariadb/MariaDB.js';
5
- import { Xampp } from '../src/runtime/xampp/Xampp.js';
6
5
  import { Lampp } from '../src/runtime/lampp/Lampp.js';
7
6
  import { getCapVariableName, loadConf, splitFileFactory } from '../src/server/conf.js';
8
7
  import { DataBaseProvider } from '../src/db/DataBaseProvider.js';
@@ -105,9 +104,7 @@ try {
105
104
  break;
106
105
  case 'import':
107
106
  break;
108
- case 'init-xampp-service':
109
- await Xampp.initService();
110
- break;
107
+
111
108
  case 'init-lampp-service':
112
109
  await Lampp.initService();
113
110
  break;
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.882
1
+ ## underpost ci/cd cli v2.8.883
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -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.882
20
+ image: localhost/rockylinux9-underpost:v2.8.883
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.882
103
+ image: localhost/rockylinux9-underpost:v2.8.883
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.882
20
+ image: localhost/rockylinux9-underpost:v2.8.883
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "96294Ki"
@@ -104,7 +104,7 @@ spec:
104
104
  spec:
105
105
  containers:
106
106
  - name: dd-test-development-green
107
- image: localhost/rockylinux9-underpost:v2.8.882
107
+ image: localhost/rockylinux9-underpost:v2.8.883
108
108
  # resources:
109
109
  # requests:
110
110
  # memory: "96294Ki"
@@ -20,7 +20,7 @@ for iface_path in /sys/class/net/*; do
20
20
  if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
21
21
  vendor_id=$(< "$pci_dev/vendor")
22
22
  device_id=$(< "$pci_dev/device")
23
- # pasamos de 0x8086 a 8086, etc.
23
+ # parse 0x8086 to 8086, etc.
24
24
  vendor_id=${vendor_id#0x}
25
25
  device_id=${device_id#0x}
26
26
  pci="${vendor_id}:${device_id}"
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.882",
5
+ "version": "2.8.883",
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",
@@ -156,7 +156,6 @@ const Docs = {
156
156
  id: options.idModal,
157
157
  routeId: 'docs',
158
158
  event: (path) => {
159
- Modal.subMenuBtnClass['docs'].open = !Modal.subMenuBtnClass['docs'].open;
160
159
  if (s(`.btn-docs-${path}`)) s(`.btn-docs-${path}`).click();
161
160
  if (Modal.mobileModal()) {
162
161
  setTimeout(() => {
@@ -2413,6 +2413,10 @@ const buildBadgeToolTipMenuOption = (id, sideKey = 'left') => {
2413
2413
  return option;
2414
2414
  };
2415
2415
 
2416
+ const isSubMenuOpen = (subMenuId) => {
2417
+ return s(`.down-arrow-submenu-${subMenuId}`).style.rotate === '180deg';
2418
+ };
2419
+
2416
2420
  const subMenuRender = async (subMenuId) => {
2417
2421
  const _hBtn = 51;
2418
2422
  const menuBtn = s(`.main-btn-${subMenuId}`);
@@ -2421,6 +2425,9 @@ const subMenuRender = async (subMenuId) => {
2421
2425
 
2422
2426
  if (!menuBtn || !menuContainer || !arrow) return;
2423
2427
 
2428
+ // if (Modal.subMenuBtnClass[subMenuId] && !(isSubMenuOpen(subMenuId) && Modal.subMenuBtnClass[subMenuId].open === true))
2429
+ // Modal.subMenuBtnClass[subMenuId].open = false;
2430
+
2424
2431
  const top = () => {
2425
2432
  menuContainer.style.top = menuBtn.offsetTop + Modal.Data['modal-menu'].options.heightTopBar + 'px';
2426
2433
  };
@@ -2466,4 +2473,4 @@ const subMenuRender = async (subMenuId) => {
2466
2473
  }, 500);
2467
2474
  };
2468
2475
 
2469
- export { Modal, renderMenuLabel, renderViewTitle, buildBadgeToolTipMenuOption, subMenuRender };
2476
+ export { Modal, renderMenuLabel, renderViewTitle, buildBadgeToolTipMenuOption, subMenuRender, isSubMenuOpen };
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.882';
38
+ static version = 'v2.8.883';
39
39
  /**
40
40
  * Repository cli API
41
41
  * @static
@@ -4,120 +4,230 @@ import { loggerFactory } from '../../server/logger.js';
4
4
 
5
5
  const logger = loggerFactory(import.meta);
6
6
 
7
- const Lampp = {
8
- ports: [],
9
- initService: async function (options = { daemon: false }) {
7
+ /**
8
+ * @class LamppService
9
+ * @description Provides utilities for managing the XAMPP (Lampp) service on Linux,
10
+ * including initialization, router configuration, and virtual host creation.
11
+ * It manages the server's configuration files and controls the service process.
12
+ */
13
+ class LamppService {
14
+ /**
15
+ * @private
16
+ * @type {string | undefined}
17
+ * @description Stores the accumulated Apache virtual host configuration (router definition).
18
+ */
19
+ router;
20
+
21
+ /**
22
+ * @public
23
+ * @type {number[]}
24
+ * @description A list of ports currently configured and listened to by the Lampp service.
25
+ */
26
+ ports;
27
+
28
+ /**
29
+ * Creates an instance of LamppService.
30
+ * Initializes the router configuration and ports list.
31
+ */
32
+ constructor() {
33
+ this.router = undefined;
34
+ this.ports = [];
35
+ }
36
+
37
+ /**
38
+ * Checks if the XAMPP (Lampp) service appears to be installed based on the presence of its main configuration file.
39
+ *
40
+ * @memberof LamppService
41
+ * @returns {boolean} True if the configuration file exists, indicating Lampp is likely installed.
42
+ */
43
+ enabled() {
44
+ return fs.existsSync('/opt/lampp/etc/httpd.conf');
45
+ }
46
+
47
+ /**
48
+ * Initializes or restarts the Lampp Apache service.
49
+ * This method configures virtual hosts, disables default ports (80/443) in the main config
50
+ * to avoid conflicts, and starts or stops the service using shell commands.
51
+ *
52
+ * @memberof LamppService.prototype
53
+ * @param {object} [options={daemon: false}] - Options for service initialization.
54
+ * @param {boolean} [options.daemon=false] - Flag to indicate if the service should be run as a daemon (currently unused in logic).
55
+ * @returns {Promise<void>}
56
+ */
57
+ async initService(options = { daemon: false }) {
10
58
  let cmd;
11
- // linux
12
- // /opt/lampp/apache2/conf/httpd.conf
59
+
60
+ // 1. Write the current virtual host router configuration
13
61
  fs.writeFileSync(`/opt/lampp/etc/extra/httpd-vhosts.conf`, this.router || '', 'utf8');
62
+
63
+ // 2. Ensure the vhosts file is included in the main httpd.conf
64
+ const httpdConfPath = `/opt/lampp/etc/httpd.conf`;
14
65
  fs.writeFileSync(
15
- `/opt/lampp/etc/httpd.conf`,
66
+ httpdConfPath,
16
67
  fs
17
- .readFileSync(`/opt/lampp/etc/httpd.conf`, 'utf8')
68
+ .readFileSync(httpdConfPath, 'utf8')
18
69
  .replace(`#Include etc/extra/httpd-vhosts.conf`, `Include etc/extra/httpd-vhosts.conf`),
19
70
  'utf8',
20
71
  );
21
72
 
73
+ // 3. Stop the service before making port changes
22
74
  cmd = `sudo /opt/lampp/lampp stop`;
23
- if (!fs.readFileSync(`/opt/lampp/etc/httpd.conf`, 'utf8').match(`# Listen 80`))
75
+ shellExec(cmd);
76
+
77
+ // 4. Comment out default port Listen directives (80 and 443) to prevent conflicts
78
+ // Modify httpd.conf (port 80)
79
+ if (!fs.readFileSync(httpdConfPath, 'utf8').match(/# Listen 80/))
24
80
  fs.writeFileSync(
25
- `/opt/lampp/etc/httpd.conf`,
26
- fs.readFileSync(`/opt/lampp/etc/httpd.conf`, 'utf8').replace(`Listen 80`, `# Listen 80`),
81
+ httpdConfPath,
82
+ fs.readFileSync(httpdConfPath, 'utf8').replace(`Listen 80`, `# Listen 80`),
27
83
  'utf8',
28
84
  );
29
- if (!fs.readFileSync(`/opt/lampp/etc/extra/httpd-ssl.conf`, 'utf8').match(`# Listen 443`))
85
+
86
+ // Modify httpd-ssl.conf (port 443)
87
+ const httpdSslConfPath = `/opt/lampp/etc/extra/httpd-ssl.conf`;
88
+ if (fs.existsSync(httpdSslConfPath) && !fs.readFileSync(httpdSslConfPath, 'utf8').match(/# Listen 443/))
30
89
  fs.writeFileSync(
31
- `/opt/lampp/etc/extra/httpd-ssl.conf`,
32
- fs.readFileSync(`/opt/lampp/etc/extra/httpd-ssl.conf`, 'utf8').replace(`Listen 443`, `# Listen 443`),
90
+ httpdSslConfPath,
91
+ fs.readFileSync(httpdSslConfPath, 'utf8').replace(`Listen 443`, `# Listen 443`),
33
92
  'utf8',
34
93
  );
35
- if (!fs.readFileSync(`/opt/lampp/lampp`, 'utf8').match(`testport 443 && false`))
94
+
95
+ // 5. Modify the lampp startup script to bypass port checking for 80 and 443
96
+ const lamppScriptPath = `/opt/lampp/lampp`;
97
+ if (!fs.readFileSync(lamppScriptPath, 'utf8').match(/testport 443 && false/))
36
98
  fs.writeFileSync(
37
- `/opt/lampp/lampp`,
38
- fs.readFileSync(`/opt/lampp/lampp`, 'utf8').replace(`testport 443`, `testport 443 && false`),
99
+ lamppScriptPath,
100
+ fs.readFileSync(lamppScriptPath, 'utf8').replace(`testport 443`, `testport 443 && false`),
39
101
  'utf8',
40
102
  );
41
- if (!fs.readFileSync(`/opt/lampp/lampp`, 'utf8').match(`testport 80 && false`))
103
+ if (!fs.readFileSync(lamppScriptPath, 'utf8').match(/testport 80 && false/))
42
104
  fs.writeFileSync(
43
- `/opt/lampp/lampp`,
44
- fs.readFileSync(`/opt/lampp/lampp`, 'utf8').replace(`testport 80`, `testport 80 && false`),
105
+ lamppScriptPath,
106
+ fs.readFileSync(lamppScriptPath, 'utf8').replace(`testport 80`, `testport 80 && false`),
45
107
  'utf8',
46
108
  );
47
109
 
48
- shellExec(cmd);
110
+ // 6. Start the service
49
111
  cmd = `sudo /opt/lampp/lampp start`;
50
112
  if (this.router) fs.writeFileSync(`./tmp/lampp-router.conf`, this.router, 'utf-8');
51
113
  shellExec(cmd);
52
- },
53
- enabled: () => fs.existsSync(`/opt/lampp/etc/httpd.conf`),
54
- appendRouter: function (render) {
114
+ }
115
+
116
+ /**
117
+ * Appends new Apache VirtualHost configuration content to the internal router string.
118
+ * If a router config file exists from a previous run, it loads it first.
119
+ *
120
+ * @memberof LamppService.prototype
121
+ * @param {string} render - The new VirtualHost configuration string to append.
122
+ * @returns {string} The complete, updated router configuration string.
123
+ */
124
+ appendRouter(render) {
55
125
  if (!this.router) {
56
- if (fs.existsSync(`./tmp/lampp-router.conf`))
57
- return (this.router = fs.readFileSync(`./tmp/lampp-router.conf`, 'utf-8')) + render;
126
+ if (fs.existsSync(`./tmp/lampp-router.conf`)) {
127
+ this.router = fs.readFileSync(`./tmp/lampp-router.conf`, 'utf-8');
128
+ return this.router + render;
129
+ }
58
130
  return (this.router = render);
59
131
  }
60
132
  return (this.router += render);
61
- },
62
- removeRouter: function () {
133
+ }
134
+
135
+ /**
136
+ * Resets the internal router configuration and removes the temporary configuration file.
137
+ *
138
+ * @memberof LamppService.prototype
139
+ * @returns {void}
140
+ */
141
+ removeRouter() {
63
142
  this.router = undefined;
64
143
  if (fs.existsSync(`./tmp/lampp-router.conf`)) fs.rmSync(`./tmp/lampp-router.conf`);
65
- },
66
- install: async function () {
67
- switch (process.platform) {
68
- case 'linux':
69
- {
70
- if (!fs.existsSync(`./engine-private/setup`)) fs.mkdirSync(`./engine-private/setup`, { recursive: true });
71
-
72
- shellCd(`./engine-private/setup`);
73
-
74
- if (!process.argv.includes(`server`)) {
75
- shellExec(
76
- `curl -Lo xampp-linux-installer.run https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/7.4.30/xampp-linux-x64-7.4.30-1-installer.run?from_af=true`,
77
- );
78
- shellExec(`sudo chmod +x xampp-linux-installer.run`);
79
- shellExec(
80
- `sudo ./xampp-linux-installer.run --mode unattended && \\` +
81
- `ln -sf /opt/lampp/lampp /usr/bin/lampp && \\` +
82
- `sed -i.bak s'/Require local/Require all granted/g' /opt/lampp/etc/extra/httpd-xampp.conf && \\` +
83
- `sed -i.bak s'/display_errors=Off/display_errors=On/g' /opt/lampp/etc/php.ini && \\` +
84
- `mkdir /opt/lampp/apache2/conf.d && \\` +
85
- `echo "IncludeOptional /opt/lampp/apache2/conf.d/*.conf" >> /opt/lampp/etc/httpd.conf && \\` +
86
- `mkdir /www && \\` +
87
- `ln -s /www /opt/lampp/htdocs`,
88
- );
89
- }
90
-
91
- if (fs.existsSync(`/opt/lampp/logs/access_log`))
92
- fs.copySync(`/opt/lampp/logs/access_log`, `/opt/lampp/logs/access.log`);
93
- if (fs.existsSync(`/opt/lampp/logs/error_log`))
94
- fs.copySync(`/opt/lampp/logs/error_log`, `/opt/lampp/logs/error.log`);
95
- if (fs.existsSync(`/opt/lampp/logs/php_error_log`))
96
- fs.copySync(`/opt/lampp/logs/php_error_log`, `/opt/lampp/logs/php_error.log`);
97
- if (fs.existsSync(`/opt/lampp/logs/ssl_request_log`))
98
- fs.copySync(`/opt/lampp/logs/ssl_request_log`, `/opt/lampp/logs/ssl_request.log`);
99
-
100
- await Lampp.initService({ daemon: true });
101
- }
102
-
103
- break;
104
-
105
- default:
106
- break;
144
+ }
145
+
146
+ /**
147
+ * Installs and configures the Lampp service on Linux.
148
+ * This includes downloading the installer, running it, and setting up initial configurations.
149
+ * Only runs on the 'linux' platform.
150
+ *
151
+ * @memberof LamppService.prototype
152
+ * @returns {Promise<void>}
153
+ */
154
+ async install() {
155
+ if (process.platform === 'linux') {
156
+ if (!fs.existsSync(`./engine-private/setup`)) fs.mkdirSync(`./engine-private/setup`, { recursive: true });
157
+
158
+ shellCd(`./engine-private/setup`);
159
+
160
+ if (!process.argv.includes(`server`)) {
161
+ // Download and run the XAMPP installer
162
+ shellExec(
163
+ `curl -Lo xampp-linux-installer.run https://sourceforge.net/projects/xampp/files/XAMPP%20Linux/7.4.30/xampp-linux-x64-7.4.30-1-installer.run?from_af=true`,
164
+ );
165
+ shellExec(`sudo chmod +x xampp-linux-installer.run`);
166
+ shellExec(
167
+ `sudo ./xampp-linux-installer.run --mode unattended && \\` +
168
+ // Create symlink for easier access
169
+ `ln -sf /opt/lampp/lampp /usr/bin/lampp && \\` +
170
+ // Allow all access to xampp config (security measure override)
171
+ `sed -i.bak s'/Require local/Require all granted/g' /opt/lampp/etc/extra/httpd-xampp.conf && \\` +
172
+ // Enable display errors in PHP
173
+ `sed -i.bak s'/display_errors=Off/display_errors=On/g' /opt/lampp/etc/php.ini && \\` +
174
+ // Allow including custom Apache configuration files
175
+ `mkdir /opt/lampp/apache2/conf.d && \\` +
176
+ `echo "IncludeOptional /opt/lampp/apache2/conf.d/*.conf" >> /opt/lampp/etc/httpd.conf && \\` +
177
+ // Create /www directory and symlink it to htdocs
178
+ `mkdir /www && \\` +
179
+ `ln -s /www /opt/lampp/htdocs`,
180
+ );
181
+ }
182
+
183
+ // Copy log files to standard names for easier consumption
184
+ if (fs.existsSync(`/opt/lampp/logs/access_log`))
185
+ fs.copySync(`/opt/lampp/logs/access_log`, `/opt/lampp/logs/access.log`);
186
+ if (fs.existsSync(`/opt/lampp/logs/error_log`))
187
+ fs.copySync(`/opt/lampp/logs/error_log`, `/opt/lampp/logs/error.log`);
188
+ if (fs.existsSync(`/opt/lampp/logs/php_error_log`))
189
+ fs.copySync(`/opt/lampp/logs/php_error_log`, `/opt/lampp/logs/php_error.log`);
190
+ if (fs.existsSync(`/opt/lampp/logs/ssl_request_log`))
191
+ fs.copySync(`/opt/lampp/logs/ssl_request_log`, `/opt/lampp/logs/ssl_request.log`);
192
+
193
+ // Initialize the service after installation
194
+ await this.initService({ daemon: true });
107
195
  }
108
- },
109
- createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget, resetRouter }) => {
110
- if (!Lampp.enabled()) return { disabled: true };
111
- if (!Lampp.ports.includes(port)) Lampp.ports.push(port);
112
- if (resetRouter) Lampp.removeRouter();
113
- Lampp.appendRouter(`
196
+ }
197
+
198
+ /**
199
+ * Creates and appends a new Apache VirtualHost entry to the router configuration for a web application.
200
+ * The router is then applied by calling {@link LamppService#initService}.
201
+ *
202
+ * @memberof LamppService.prototype
203
+ * @param {object} options - Configuration options for the new web application.
204
+ * @param {number} options.port - The port the VirtualHost should listen on.
205
+ * @param {string} options.host - The ServerName/host for the VirtualHost.
206
+ * @param {string} options.path - The base path for error documents (e.g., '/app').
207
+ * @param {string} [options.directory] - Optional absolute path to the document root.
208
+ * @param {string} [options.rootHostPath] - Relative path from the root directory to the document root, used if `directory` is not provided.
209
+ * @param {boolean} [options.redirect] - If true, enables RewriteEngine for redirection.
210
+ * @param {string} [options.redirectTarget] - The target URL for redirection.
211
+ * @param {boolean} [options.resetRouter] - If true, clears the existing router configuration before appending the new one.
212
+ * @returns {{disabled: boolean}} An object indicating if the service is disabled.
213
+ */
214
+ createApp({ port, host, path, directory, rootHostPath, redirect, redirectTarget, resetRouter }) {
215
+ if (!this.enabled()) return { disabled: true };
216
+
217
+ if (!this.ports.includes(port)) this.ports.push(port);
218
+ if (resetRouter) this.removeRouter();
219
+
220
+ const documentRoot = directory ? directory : `${getRootDirectory()}${rootHostPath}`;
221
+
222
+ // Append the new VirtualHost configuration
223
+ this.appendRouter(`
114
224
  Listen ${port}
115
225
 
116
226
  <VirtualHost *:${port}>
117
- DocumentRoot "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}"
227
+ DocumentRoot "${documentRoot}"
118
228
  ServerName ${host}:${port}
119
229
 
120
- <Directory "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}">
230
+ <Directory "${documentRoot}">
121
231
  Options Indexes FollowSymLinks MultiViews
122
232
  AllowOverride All
123
233
  Require all granted
@@ -128,12 +238,14 @@ Listen ${port}
128
238
  ? `
129
239
  RewriteEngine on
130
240
 
241
+ # Exclude the ACME challenge path for certificate renewals
131
242
  RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge
132
243
  RewriteRule ^(.*)$ ${redirectTarget}%{REQUEST_URI} [R=302,L]
133
244
  `
134
245
  : ''
135
246
  }
136
247
 
248
+ # Custom Error Documents
137
249
  ErrorDocument 400 ${path === '/' ? '' : path}/400.html
138
250
  ErrorDocument 404 ${path === '/' ? '' : path}/400.html
139
251
  ErrorDocument 500 ${path === '/' ? '' : path}/500.html
@@ -144,56 +256,69 @@ Listen ${port}
144
256
  </VirtualHost>
145
257
 
146
258
  `);
147
- // ERR too many redirects:
148
- // Check: SELECT * FROM database.wp_options where option_name = 'siteurl' or option_name = 'home';
149
- // Check: wp-config.php
150
- // if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
151
- // $_SERVER['HTTPS'] = 'on';
152
- // }
153
- // For plugins:
154
- // define( 'FS_METHOD', 'direct' );
155
-
156
- // ErrorDocument 404 /custom_404.html
157
- // ErrorDocument 500 /custom_50x.html
158
- // ErrorDocument 502 /custom_50x.html
159
- // ErrorDocument 503 /custom_50x.html
160
- // ErrorDocument 504 /custom_50x.html
161
-
162
- // Respond When Error Pages are Directly Requested
163
-
164
- // <Files "custom_404.html">
165
- // <If "-z %{ENV:REDIRECT_STATUS}">
166
- // RedirectMatch 404 ^/custom_404.html$
167
- // </If>
168
- // </Files>
169
-
170
- // <Files "custom_50x.html">
171
- // <If "-z %{ENV:REDIRECT_STATUS}">
172
- // RedirectMatch 404 ^/custom_50x.html$
173
- // </If>
174
- // </Files>
175
-
176
- // Add www or https with htaccess rewrite
177
-
178
- // Options +FollowSymLinks
179
- // RewriteEngine On
180
- // RewriteCond %{HTTP_HOST} ^ejemplo.com [NC]
181
- // RewriteRule ^(.*)$ http://ejemplo.com/$1 [R=301,L]
182
-
183
- // Redirect http to https with htaccess rewrite
184
-
185
- // RewriteEngine On
186
- // RewriteCond %{SERVER_PORT} 80
187
- // RewriteRule ^(.*)$ https://www.ejemplo.com/$1 [R,L]
188
-
189
- // Redirect to HTTPS with www subdomain
190
-
191
- // RewriteEngine On
192
- // RewriteCond %{HTTPS} off [OR]
193
- // RewriteCond %{HTTP_HOST} ^www\. [NC]
194
- // RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
195
- // RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
196
- },
197
- };
259
+
260
+ return { disabled: false };
261
+ }
262
+ }
263
+
264
+ /**
265
+ * @namespace LamppService
266
+ * @description Exported singleton instance of the LamppService class.
267
+ * This object is used to interact with the Lampp configuration and service.
268
+ * @type {LamppService}
269
+ */
270
+ const Lampp = new LamppService();
271
+
272
+ // -- helper info --
273
+
274
+ // ERR too many redirects:
275
+ // Check: SELECT * FROM database.wp_options where option_name = 'siteurl' or option_name = 'home';
276
+ // Check: wp-config.php
277
+ // if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
278
+ // $_SERVER['HTTPS'] = 'on';
279
+ // }
280
+ // For plugins:
281
+ // define( 'FS_METHOD', 'direct' );
282
+
283
+ // ErrorDocument 404 /custom_404.html
284
+ // ErrorDocument 500 /custom_50x.html
285
+ // ErrorDocument 502 /custom_50x.html
286
+ // ErrorDocument 503 /custom_50x.html
287
+ // ErrorDocument 504 /custom_50x.html
288
+
289
+ // Respond When Error Pages are Directly Requested
290
+
291
+ // <Files "custom_404.html">
292
+ // <If "-z %{ENV:REDIRECT_STATUS}">
293
+ // RedirectMatch 404 ^/custom_404.html$
294
+ // </If>
295
+ // </Files>
296
+
297
+ // <Files "custom_50x.html">
298
+ // <If "-z %{ENV:REDIRECT_STATUS}">
299
+ // RedirectMatch 404 ^/custom_50x.html$
300
+ // </If>
301
+ // </Files>
302
+
303
+ // Add www or https with htaccess rewrite
304
+
305
+ // Options +FollowSymLinks
306
+ // RewriteEngine On
307
+ // RewriteCond %{HTTP_HOST} ^example.com [NC]
308
+ // RewriteRule ^(.*)$ http://example.com/$1 [R=301,L]
309
+
310
+ // Redirect http to https with htaccess rewrite
311
+
312
+ // RewriteEngine On
313
+ // RewriteCond %{SERVER_PORT} 80
314
+ // RewriteRule ^(.*)$ https://www.example.com/$1 [R,L]
315
+
316
+ // Redirect to HTTPS with www subdomain
317
+
318
+ // RewriteEngine On
319
+ // RewriteCond %{HTTPS} off [OR]
320
+ // RewriteCond %{HTTP_HOST} ^www\. [NC]
321
+ // RewriteCond %{HTTP_HOST} ^(?:www\.)?(.+)$ [NC]
322
+ // RewriteRule ^ https://%1%{REQUEST_URI} [L,NE,R=301]
198
323
 
199
324
  export { Lampp };
@@ -14,7 +14,6 @@ import { MailerProvider } from '../mailer/MailerProvider.js';
14
14
  import { DataBaseProvider } from '../db/DataBaseProvider.js';
15
15
  import { createPeerServer } from './peer.js';
16
16
  import { Lampp } from '../runtime/lampp/Lampp.js';
17
- import { Xampp } from '../runtime/xampp/Xampp.js';
18
17
  import { createValkeyConnection } from './valkey.js';
19
18
  import { applySecurity, authMiddlewareFactory } from './auth.js';
20
19
  import { getInstanceContext } from './conf.js';
@@ -311,26 +310,6 @@ const buildRuntime = async () => {
311
310
  );
312
311
  }
313
312
  break;
314
- case 'xampp':
315
- {
316
- const { disabled } = await Xampp.createApp({
317
- port,
318
- host,
319
- path,
320
- directory,
321
- rootHostPath,
322
- redirect,
323
- redirectTarget,
324
- resetRouter: currentPort === initPort,
325
- });
326
- if (disabled) continue;
327
- await UnderpostStartUp.API.listenPortController(
328
- UnderpostStartUp.API.listenServerFactory(),
329
- port,
330
- runningData,
331
- );
332
- }
333
- break;
334
313
  default:
335
314
  break;
336
315
  }
@@ -338,7 +317,6 @@ const buildRuntime = async () => {
338
317
  }
339
318
  }
340
319
 
341
- if (Xampp.enabled() && Xampp.router) Xampp.initService();
342
320
  if (Lampp.enabled() && Lampp.router) Lampp.initService();
343
321
 
344
322
  UnderpostStartUp.API.logRuntimeRouter();
@@ -1,83 +0,0 @@
1
- import fs from 'fs-extra';
2
- import { shellExec, getRootDirectory } from '../../server/process.js';
3
-
4
- const Xampp = {
5
- ports: [],
6
- initService: async function (options = { daemon: false }) {
7
- let cmd;
8
- // windows
9
- fs.writeFileSync(
10
- `C:/xampp/apache/conf/httpd.conf`,
11
- fs.readFileSync(`C:/xampp/apache/conf/httpd.template.conf`, 'utf8').replace(`Listen 80`, ``),
12
- 'utf8',
13
- );
14
- fs.writeFileSync(`C:/xampp/apache/conf/extra/httpd-ssl.conf`, this.router || '', 'utf8');
15
- cmd = `C:/xampp/xampp_stop.exe`;
16
- shellExec(cmd);
17
- cmd = `C:/xampp/xampp_start.exe`;
18
- if (this.router) fs.writeFileSync(`./tmp/xampp-router.conf`, this.router, 'utf-8');
19
- shellExec(cmd);
20
- },
21
- enabled: () => fs.existsSync(`C:/xampp/apache/conf/httpd.conf`),
22
- appendRouter: function (render) {
23
- if (!this.router) {
24
- if (fs.existsSync(`./tmp/xampp-router.conf`))
25
- return (this.router = fs.readFileSync(`./tmp/xampp-router.conf`, 'utf-8')) + render;
26
- return (this.router = render);
27
- }
28
- return (this.router += render);
29
- },
30
- removeRouter: function () {
31
- this.router = undefined;
32
- if (fs.existsSync(`./tmp/xampp-router.conf`)) fs.rmSync(`./tmp/xampp-router.conf`);
33
- },
34
- createApp: async ({ port, host, path, directory, rootHostPath, redirect, redirectTarget, resetRouter }) => {
35
- if (!Xampp.enabled()) {
36
- return { disabled: true };
37
- }
38
- if (!Xampp.ports.includes(port)) Xampp.ports.push(port);
39
- if (resetRouter) Xampp.removeRouter();
40
- Xampp.appendRouter(`
41
- Listen ${port}
42
-
43
- <VirtualHost *:${port}>
44
- DocumentRoot "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}"
45
- ServerName ${host}:${port}
46
-
47
- <Directory "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}">
48
- Options Indexes FollowSymLinks MultiViews
49
- AllowOverride All
50
- Require all granted
51
- </Directory>
52
-
53
- ${
54
- redirect
55
- ? `
56
- RewriteEngine on
57
-
58
- RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge
59
- RewriteRule ^(.*)$ ${redirectTarget}%{REQUEST_URI} [R=302,L]
60
- `
61
- : ''
62
- }
63
-
64
- ErrorDocument 400 ${path === '/' ? '' : path}/400.html
65
- ErrorDocument 404 ${path === '/' ? '' : path}/400.html
66
- ErrorDocument 500 ${path === '/' ? '' : path}/500.html
67
- ErrorDocument 502 ${path === '/' ? '' : path}/500.html
68
- ErrorDocument 503 ${path === '/' ? '' : path}/500.html
69
- ErrorDocument 504 ${path === '/' ? '' : path}/500.html
70
-
71
- </VirtualHost>
72
-
73
- `);
74
- // ERR too many redirects:
75
- // Check: SELECT * FROM database.wp_options where option_name = 'siteurl' or option_name = 'home';
76
- // Check: wp-config.php
77
- // if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https') {
78
- // $_SERVER['HTTPS'] = 'on';
79
- // }
80
- },
81
- };
82
-
83
- export { Xampp };