underpost 2.8.872 → 2.8.874
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 +24 -2
- package/bin/build.js +4 -0
- package/bin/deploy.js +4 -0
- package/cli.md +5 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +174 -0
- package/manifests/deployment/dd-test-development/proxy.yaml +51 -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 +9 -4
- package/src/api/user/user.service.js +84 -32
- package/src/cli/baremetal.js +33 -3
- package/src/cli/cloud-init.js +11 -0
- package/src/cli/deploy.js +44 -22
- package/src/cli/index.js +2 -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 +99 -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 +64 -228
- package/src/server/ssr.js +85 -0
- package/src/server/valkey.js +2 -1
|
@@ -7,6 +7,7 @@ import { loggerFactory } from '../../components/core/Logger.js';
|
|
|
7
7
|
import { Modal } from '../../components/core/Modal.js';
|
|
8
8
|
import { NotificationManager } from '../../components/core/NotificationManager.js';
|
|
9
9
|
import { Translate } from '../../components/core/Translate.js';
|
|
10
|
+
import { getQueryParams, RouterEvents, setQueryParams } from '../../components/core/Router.js';
|
|
10
11
|
import { s } from '../../components/core/VanillaJs.js';
|
|
11
12
|
import { DefaultService } from './default.service.js';
|
|
12
13
|
|
|
@@ -47,19 +48,48 @@ const columnDefFormatter = (obj, columnDefs, customFormat) => {
|
|
|
47
48
|
|
|
48
49
|
const DefaultManagement = {
|
|
49
50
|
Tokens: {},
|
|
51
|
+
loadTable: async function (id, options = { reload: true }) {
|
|
52
|
+
const { serviceId, columnDefs, customFormat } = this.Tokens[id];
|
|
53
|
+
const result = await this.Tokens[id].ServiceProvider.get({
|
|
54
|
+
page: this.Tokens[id].page,
|
|
55
|
+
limit: this.Tokens[id].limit,
|
|
56
|
+
id: this.Tokens[id].serviceOptions?.get?.id ?? undefined,
|
|
57
|
+
});
|
|
58
|
+
if (result.status === 'success') {
|
|
59
|
+
const { data, total, page, totalPages } = result.data;
|
|
60
|
+
this.Tokens[id].total = total;
|
|
61
|
+
this.Tokens[id].page = page;
|
|
62
|
+
this.Tokens[id].totalPages = totalPages;
|
|
63
|
+
const rowDataScope = data.map((row) => columnDefFormatter(row, columnDefs, customFormat));
|
|
64
|
+
if (options.reload) AgGrid.grids[this.Tokens[id].gridId].setGridOption('rowData', rowDataScope);
|
|
65
|
+
const paginationComp = s(`#ag-pagination-${this.Tokens[id].gridId}`);
|
|
66
|
+
paginationComp.setAttribute('current-page', this.Tokens[id].page);
|
|
67
|
+
paginationComp.setAttribute('total-pages', this.Tokens[id].totalPages);
|
|
68
|
+
paginationComp.setAttribute('total-items', this.Tokens[id].total);
|
|
69
|
+
}
|
|
70
|
+
},
|
|
50
71
|
RenderTable: async function (options = DefaultOptions) {
|
|
51
72
|
if (!options) options = DefaultOptions;
|
|
52
73
|
const { serviceId, columnDefs, entity, defaultColKeyFocus, ServiceProvider, permissions } = options;
|
|
53
74
|
logger.info('DefaultManagement RenderTable', options);
|
|
54
75
|
const id = options?.idModal ? options.idModal : getId(this.Tokens, `${serviceId}-`);
|
|
55
76
|
const gridId = `${serviceId}-grid-${id}`;
|
|
56
|
-
|
|
77
|
+
const queryParams = getQueryParams();
|
|
78
|
+
const page = parseInt(queryParams.page) || 1;
|
|
79
|
+
const limit = parseInt(queryParams.limit) || 10;
|
|
80
|
+
this.Tokens[id] = {
|
|
81
|
+
...options,
|
|
82
|
+
gridId,
|
|
83
|
+
page,
|
|
84
|
+
limit,
|
|
85
|
+
total: 0,
|
|
86
|
+
totalPages: 1,
|
|
87
|
+
};
|
|
57
88
|
|
|
89
|
+
setQueryParams({ page, limit });
|
|
58
90
|
setTimeout(async () => {
|
|
59
91
|
// https://www.ag-grid.com/javascript-data-grid/data-update-transactions/
|
|
60
92
|
|
|
61
|
-
let rowDataScope = [];
|
|
62
|
-
|
|
63
93
|
class RemoveActionGridRenderer {
|
|
64
94
|
eGui;
|
|
65
95
|
tokens;
|
|
@@ -110,6 +140,16 @@ const DefaultManagement = {
|
|
|
110
140
|
});
|
|
111
141
|
if (result.status === 'success') {
|
|
112
142
|
AgGrid.grids[gridId].applyTransaction({ remove: [params.data] });
|
|
143
|
+
const token = DefaultManagement.Tokens[id];
|
|
144
|
+
// if we are on the last page and we delete the last item, go to the previous page
|
|
145
|
+
const newTotal = token.total - 1;
|
|
146
|
+
const newTotalPages = Math.ceil(newTotal / token.limit);
|
|
147
|
+
if (token.page > newTotalPages && newTotalPages > 0) {
|
|
148
|
+
token.page = newTotalPages;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
// reload the current page
|
|
152
|
+
await DefaultManagement.loadTable(id, { reload: false });
|
|
113
153
|
}
|
|
114
154
|
},
|
|
115
155
|
{ context: 'modal' },
|
|
@@ -142,13 +182,14 @@ const DefaultManagement = {
|
|
|
142
182
|
: [],
|
|
143
183
|
),
|
|
144
184
|
);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
185
|
+
DefaultManagement.loadTable(id);
|
|
186
|
+
// {
|
|
187
|
+
// const result = await ServiceProvider.get();
|
|
188
|
+
// if (result.status === 'success') {
|
|
189
|
+
// rowDataScope = result.data.map((row) => columnDefFormatter(row, columnDefs, options.customFormat));
|
|
190
|
+
// AgGrid.grids[gridId].setGridOption('rowData', rowDataScope);
|
|
191
|
+
// }
|
|
192
|
+
// }
|
|
152
193
|
s(`.management-table-btn-save-${id}`).onclick = () => {
|
|
153
194
|
AgGrid.grids[gridId].stopEditing();
|
|
154
195
|
};
|
|
@@ -168,9 +209,13 @@ const DefaultManagement = {
|
|
|
168
209
|
// });
|
|
169
210
|
if (result.status === 'success') {
|
|
170
211
|
AgGrid.grids[gridId].applyTransaction({
|
|
171
|
-
add: [columnDefFormatter(
|
|
212
|
+
add: [columnDefFormatter(rowObj, columnDefs, options.customFormat)],
|
|
172
213
|
addIndex: 0,
|
|
173
214
|
});
|
|
215
|
+
// AgGrid.grids[gridId].applyTransaction({
|
|
216
|
+
// add: [columnDefFormatter(result.data, columnDefs, options.customFormat)],
|
|
217
|
+
// addIndex: 0,
|
|
218
|
+
// });
|
|
174
219
|
// AgGrid.grids[gridId].applyColumnState({
|
|
175
220
|
// state: [
|
|
176
221
|
// // { colId: 'country', sort: 'asc', sortIndex: 1 },
|
|
@@ -244,9 +289,34 @@ const DefaultManagement = {
|
|
|
244
289
|
status: result.status,
|
|
245
290
|
});
|
|
246
291
|
if (result.status === 'success') {
|
|
247
|
-
|
|
292
|
+
DefaultManagement.loadTable(id);
|
|
248
293
|
}
|
|
249
294
|
});
|
|
295
|
+
s(`#ag-pagination-${gridId}`).addEventListener('page-change', async (event) => {
|
|
296
|
+
const token = DefaultManagement.Tokens[id];
|
|
297
|
+
token.page = event.detail.page;
|
|
298
|
+
await DefaultManagement.loadTable(id);
|
|
299
|
+
});
|
|
300
|
+
s(`#ag-pagination-${gridId}`).addEventListener('limit-change', async (event) => {
|
|
301
|
+
const token = DefaultManagement.Tokens[id];
|
|
302
|
+
token.limit = event.detail.limit;
|
|
303
|
+
token.page = 1; // Reset to first page
|
|
304
|
+
await DefaultManagement.loadTable(id);
|
|
305
|
+
});
|
|
306
|
+
RouterEvents[id] = async (...args) => {
|
|
307
|
+
const queryParams = getQueryParams();
|
|
308
|
+
const page = parseInt(queryParams.page) || 1;
|
|
309
|
+
const limit = parseInt(queryParams.limit) || 10;
|
|
310
|
+
const token = DefaultManagement.Tokens[id];
|
|
311
|
+
|
|
312
|
+
// Check if the pagination state in the URL is different from the current state
|
|
313
|
+
if (token.page !== page || token.limit !== limit) {
|
|
314
|
+
token.page = page;
|
|
315
|
+
token.limit = limit;
|
|
316
|
+
// Reload the table with the new pagination state from the URL
|
|
317
|
+
await DefaultManagement.loadTable(id);
|
|
318
|
+
}
|
|
319
|
+
};
|
|
250
320
|
}, 1);
|
|
251
321
|
return html`<div class="fl">
|
|
252
322
|
${await BtnIcon.Render({
|
|
@@ -274,6 +344,7 @@ const DefaultManagement = {
|
|
|
274
344
|
<div class="in section-mp">
|
|
275
345
|
${await AgGrid.Render({
|
|
276
346
|
id: gridId,
|
|
347
|
+
usePagination: true,
|
|
277
348
|
darkTheme,
|
|
278
349
|
gridOptions: {
|
|
279
350
|
defaultColDef: {
|
|
@@ -327,7 +398,32 @@ const DefaultManagement = {
|
|
|
327
398
|
status: result.status,
|
|
328
399
|
});
|
|
329
400
|
if (result.status === 'success') {
|
|
330
|
-
|
|
401
|
+
this.Tokens[id].page = 1;
|
|
402
|
+
await DefaultManagement.loadTable(id);
|
|
403
|
+
// const newItemId = result.data?.[entity]?._id || result.data?._id;
|
|
404
|
+
// The `event.node.id` is the temporary ID assigned by AG Grid.
|
|
405
|
+
// const rowNode = AgGrid.grids[gridId].getRowNode(event.node.id);
|
|
406
|
+
setQueryParams({ page: 1, limit: this.Tokens[id].limit });
|
|
407
|
+
|
|
408
|
+
let rowNode;
|
|
409
|
+
AgGrid.grids[gridId].forEachLeafNode((_rowNode) => {
|
|
410
|
+
if (_rowNode.data._id === result.data._id) {
|
|
411
|
+
rowNode = _rowNode;
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
if (rowNode) {
|
|
415
|
+
const newRow = columnDefFormatter(result.data, columnDefs, options.customFormat);
|
|
416
|
+
// Add a temporary flag to the new row data.
|
|
417
|
+
newRow._new = true;
|
|
418
|
+
// Update the row data with the data from the server, which includes the new permanent `_id`.
|
|
419
|
+
rowNode.setData(newRow);
|
|
420
|
+
// The `rowClassRules` will automatically apply the 'row-new-highlight' class.
|
|
421
|
+
// Now, remove the flag after a delay to remove the highlight.
|
|
422
|
+
// setTimeout(() => {
|
|
423
|
+
// delete newRow._new;
|
|
424
|
+
// rowNode.setData(newRow);
|
|
425
|
+
// }, 2000);
|
|
426
|
+
}
|
|
331
427
|
}
|
|
332
428
|
} else {
|
|
333
429
|
const body = event.data ? event.data : {};
|
|
@@ -336,11 +432,12 @@ const DefaultManagement = {
|
|
|
336
432
|
html: result.status === 'error' ? result.message : `${Translate.Render('success-update-item')}`,
|
|
337
433
|
status: result.status,
|
|
338
434
|
});
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
435
|
+
if (result.status === 'success') {
|
|
436
|
+
AgGrid.grids[gridId].applyTransaction({
|
|
437
|
+
update: [event.data],
|
|
438
|
+
});
|
|
439
|
+
DefaultManagement.loadTable(id, { reload: false });
|
|
440
|
+
}
|
|
344
441
|
}
|
|
345
442
|
},
|
|
346
443
|
},
|
|
@@ -47,9 +47,13 @@ const DefaultService = {
|
|
|
47
47
|
return reject(error);
|
|
48
48
|
}),
|
|
49
49
|
),
|
|
50
|
-
get: (options = { id: '', body: {} }) =>
|
|
51
|
-
|
|
52
|
-
|
|
50
|
+
get: (options = { id: '', body: {}, page: 1, limit: 10 }) => {
|
|
51
|
+
const { id, page, limit } = options;
|
|
52
|
+
const url = new URL(getApiBaseUrl({ id, endpoint }));
|
|
53
|
+
url.searchParams.append('page', page);
|
|
54
|
+
url.searchParams.append('limit', limit);
|
|
55
|
+
return new Promise((resolve, reject) =>
|
|
56
|
+
fetch(url.toString(), {
|
|
53
57
|
method: 'GET',
|
|
54
58
|
headers: headersFactory(),
|
|
55
59
|
})
|
|
@@ -64,7 +68,8 @@ const DefaultService = {
|
|
|
64
68
|
logger.error(error);
|
|
65
69
|
return reject(error);
|
|
66
70
|
}),
|
|
67
|
-
)
|
|
71
|
+
);
|
|
72
|
+
},
|
|
68
73
|
delete: (options = { id: '', body: {} }) =>
|
|
69
74
|
new Promise((resolve, reject) =>
|
|
70
75
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
|
@@ -13,6 +13,7 @@ const UserManagement = {
|
|
|
13
13
|
add: role === 'admin',
|
|
14
14
|
remove: role === 'admin',
|
|
15
15
|
},
|
|
16
|
+
usePagination: true,
|
|
16
17
|
columnDefs: [
|
|
17
18
|
{ field: 'username', headerName: 'username', editable: role === 'admin' },
|
|
18
19
|
{ field: 'email', headerName: 'email', editable: role === 'admin' },
|
|
@@ -44,6 +45,11 @@ const UserManagement = {
|
|
|
44
45
|
],
|
|
45
46
|
defaultColKeyFocus: 'username',
|
|
46
47
|
ServiceProvider: UserService,
|
|
48
|
+
serviceOptions: {
|
|
49
|
+
get: {
|
|
50
|
+
id: 'all',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
47
53
|
});
|
|
48
54
|
},
|
|
49
55
|
};
|
|
@@ -36,9 +36,15 @@ const UserService = {
|
|
|
36
36
|
return reject(error);
|
|
37
37
|
}),
|
|
38
38
|
),
|
|
39
|
-
get: (options = { id: '' }) =>
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
get: (options = { id: '', page: 1, limit: 10 }) => {
|
|
40
|
+
const { id = '', page, limit } = options;
|
|
41
|
+
const query = new URLSearchParams();
|
|
42
|
+
if (page) query.set('page', page);
|
|
43
|
+
if (limit) query.set('limit', limit);
|
|
44
|
+
const queryString = query.toString();
|
|
45
|
+
const url = `${getApiBaseUrl({ id, endpoint })}${queryString ? (id.includes('?') ? '&' : '?') + queryString : ''}`;
|
|
46
|
+
return new Promise((resolve, reject) =>
|
|
47
|
+
fetch(url, {
|
|
42
48
|
method: 'GET',
|
|
43
49
|
headers: headersFactory(),
|
|
44
50
|
})
|
|
@@ -53,7 +59,8 @@ const UserService = {
|
|
|
53
59
|
logger.error(error);
|
|
54
60
|
return reject(error);
|
|
55
61
|
}),
|
|
56
|
-
)
|
|
62
|
+
);
|
|
63
|
+
},
|
|
57
64
|
delete: (options = { id: '', body: {} }) =>
|
|
58
65
|
new Promise((resolve, reject) =>
|
|
59
66
|
fetch(getApiBaseUrl({ id: options.id, endpoint }), {
|
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.
|
|
38
|
+
static version = 'v2.8.874';
|
|
39
39
|
/**
|
|
40
40
|
* Repository cli API
|
|
41
41
|
* @static
|
|
@@ -171,6 +171,28 @@ const up = Underpost;
|
|
|
171
171
|
|
|
172
172
|
const underpost = Underpost;
|
|
173
173
|
|
|
174
|
-
export {
|
|
174
|
+
export {
|
|
175
|
+
underpost,
|
|
176
|
+
up,
|
|
177
|
+
Underpost,
|
|
178
|
+
UnderpostBaremetal,
|
|
179
|
+
UnderpostCloudInit,
|
|
180
|
+
UnderpostCluster,
|
|
181
|
+
UnderpostCron,
|
|
182
|
+
UnderpostDB,
|
|
183
|
+
UnderpostDeploy,
|
|
184
|
+
UnderpostRootEnv,
|
|
185
|
+
UnderpostFileStorage,
|
|
186
|
+
UnderpostImage,
|
|
187
|
+
UnderpostLxd,
|
|
188
|
+
UnderpostMonitor,
|
|
189
|
+
UnderpostRepository,
|
|
190
|
+
UnderpostRun,
|
|
191
|
+
UnderpostScript,
|
|
192
|
+
UnderpostSecret,
|
|
193
|
+
UnderpostSSH,
|
|
194
|
+
UnderpostTest,
|
|
195
|
+
UnderpostStartUp,
|
|
196
|
+
};
|
|
175
197
|
|
|
176
198
|
export default Underpost;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import { shellCd, shellExec } from '../../server/process.js';
|
|
3
|
-
import { timer } from '../../client/components/core/CommonJs.js';
|
|
2
|
+
import { getRootDirectory, shellCd, shellExec } from '../../server/process.js';
|
|
4
3
|
import { loggerFactory } from '../../server/logger.js';
|
|
5
4
|
|
|
6
5
|
const logger = loggerFactory(import.meta);
|
|
@@ -107,6 +106,94 @@ const Lampp = {
|
|
|
107
106
|
break;
|
|
108
107
|
}
|
|
109
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(`
|
|
114
|
+
Listen ${port}
|
|
115
|
+
|
|
116
|
+
<VirtualHost *:${port}>
|
|
117
|
+
DocumentRoot "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}"
|
|
118
|
+
ServerName ${host}:${port}
|
|
119
|
+
|
|
120
|
+
<Directory "${directory ? directory : `${getRootDirectory()}${rootHostPath}`}">
|
|
121
|
+
Options Indexes FollowSymLinks MultiViews
|
|
122
|
+
AllowOverride All
|
|
123
|
+
Require all granted
|
|
124
|
+
</Directory>
|
|
125
|
+
|
|
126
|
+
${
|
|
127
|
+
redirect
|
|
128
|
+
? `
|
|
129
|
+
RewriteEngine on
|
|
130
|
+
|
|
131
|
+
RewriteCond %{REQUEST_URI} !^/.well-known/acme-challenge
|
|
132
|
+
RewriteRule ^(.*)$ ${redirectTarget}%{REQUEST_URI} [R=302,L]
|
|
133
|
+
`
|
|
134
|
+
: ''
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
ErrorDocument 400 ${path === '/' ? '' : path}/400.html
|
|
138
|
+
ErrorDocument 404 ${path === '/' ? '' : path}/400.html
|
|
139
|
+
ErrorDocument 500 ${path === '/' ? '' : path}/500.html
|
|
140
|
+
ErrorDocument 502 ${path === '/' ? '' : path}/500.html
|
|
141
|
+
ErrorDocument 503 ${path === '/' ? '' : path}/500.html
|
|
142
|
+
ErrorDocument 504 ${path === '/' ? '' : path}/500.html
|
|
143
|
+
|
|
144
|
+
</VirtualHost>
|
|
145
|
+
|
|
146
|
+
`);
|
|
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
|
+
},
|
|
110
197
|
};
|
|
111
198
|
|
|
112
199
|
export { Lampp };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import fs from 'fs-extra';
|
|
2
|
-
import { shellExec } from '../../server/process.js';
|
|
2
|
+
import { shellExec, getRootDirectory } from '../../server/process.js';
|
|
3
3
|
|
|
4
4
|
const Xampp = {
|
|
5
5
|
ports: [],
|
|
@@ -31,6 +31,53 @@ const Xampp = {
|
|
|
31
31
|
this.router = undefined;
|
|
32
32
|
if (fs.existsSync(`./tmp/xampp-router.conf`)) fs.rmSync(`./tmp/xampp-router.conf`);
|
|
33
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
|
+
},
|
|
34
81
|
};
|
|
35
82
|
|
|
36
83
|
export { Xampp };
|