cds-plugin-ui5 0.6.11 → 0.6.13
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/CHANGELOG.md +20 -0
- package/cds-plugin.js +7 -5
- package/lib/createPatchedRouter.js +22 -23
- package/lib/findUI5Modules.js +1 -0
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,26 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.6.13](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.12...cds-plugin-ui5@0.6.13) (2023-10-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package cds-plugin-ui5
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.6.12](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.11...cds-plugin-ui5@0.6.12) (2023-10-01)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **cds-plugin-ui5:** handle dirs without trailing slash ([#856](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/856)) ([ee0df6b](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/ee0df6b1cd2242c3a0d49bda4737838f17daef33))
|
|
20
|
+
* **cds-plugin-ui5:** rework collision detection ([#853](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/853)) ([b25fd5c](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/b25fd5c10600c15e0bd4977e3792c78fea7f366e))
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
6
26
|
## [0.6.11](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.10...cds-plugin-ui5@0.6.11) (2023-09-25)
|
|
7
27
|
|
|
8
28
|
|
package/cds-plugin.js
CHANGED
|
@@ -7,10 +7,6 @@ const createPatchedRouter = require("./lib/createPatchedRouter");
|
|
|
7
7
|
const applyUI5Middleware = require("./lib/applyUI5Middleware");
|
|
8
8
|
const rewriteHTML = require("./lib/rewriteHTML");
|
|
9
9
|
|
|
10
|
-
// marker that the cds-plugin-ui5 plugin is running
|
|
11
|
-
// to disable the ui5-middleware-cap if used in apps
|
|
12
|
-
process.env["cds-plugin-ui5"] = true;
|
|
13
|
-
|
|
14
10
|
// identify whether the execution should be skipped
|
|
15
11
|
let skip = false;
|
|
16
12
|
if (process.env["ui5-middleware-cap"]) {
|
|
@@ -23,6 +19,10 @@ if (process.env["ui5-middleware-cap"]) {
|
|
|
23
19
|
|
|
24
20
|
// only hook into lifecycle if the plugin should not be skipped
|
|
25
21
|
if (!skip) {
|
|
22
|
+
// marker that the cds-plugin-ui5 plugin is running
|
|
23
|
+
// to disable the ui5-middleware-cap if used in apps
|
|
24
|
+
process.env["cds-plugin-ui5"] = true;
|
|
25
|
+
|
|
26
26
|
// promise to await the bootstrap and lock the
|
|
27
27
|
// served event to delay the startup a bit
|
|
28
28
|
let bootstrapped;
|
|
@@ -164,6 +164,8 @@ if (!skip) {
|
|
|
164
164
|
// return callback for plugin activation
|
|
165
165
|
module.exports = {
|
|
166
166
|
activate: function activate(conf) {
|
|
167
|
-
|
|
167
|
+
if (!skip) {
|
|
168
|
+
log.debug("activate", conf);
|
|
169
|
+
}
|
|
168
170
|
},
|
|
169
171
|
};
|
|
@@ -12,7 +12,7 @@ module.exports = async function createPatchedRouter() {
|
|
|
12
12
|
router.use(function (req, res, next) {
|
|
13
13
|
// store the original request information
|
|
14
14
|
const { url, originalUrl, baseUrl } = req;
|
|
15
|
-
req["
|
|
15
|
+
req["ui5-patched-router"] = req["ui5-patched-router"] || {
|
|
16
16
|
url,
|
|
17
17
|
originalUrl,
|
|
18
18
|
baseUrl,
|
|
@@ -20,26 +20,25 @@ module.exports = async function createPatchedRouter() {
|
|
|
20
20
|
// rewite the path to simulate requests on the root level
|
|
21
21
|
req.originalUrl = req.url;
|
|
22
22
|
req.baseUrl = "/";
|
|
23
|
+
// only accept requests for html-related content (via accept header)
|
|
24
|
+
const accept = req.headers["accept"]?.indexOf("html") !== -1;
|
|
23
25
|
// disable the compression when livereload is used
|
|
24
26
|
// for loading html-related content (via accept header)
|
|
25
27
|
// otherwise we run into compression issue with CDS livereload
|
|
26
|
-
const accept = req.headers["accept"]?.indexOf("html") !== -1;
|
|
27
28
|
if (accept && res._livereload) {
|
|
28
29
|
req.headers["accept-encoding"] = "identity";
|
|
29
30
|
}
|
|
30
|
-
// override UI5 server directory listing if
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
// 3.) not forwarded to a welcome page
|
|
34
|
-
if (!req._cds_plugin_ui5 && req.url?.endsWith("/") && req.url === (req?.["ui5-middleware-index"]?.url || req.url)) {
|
|
31
|
+
// override UI5 server directory listing if not forwarded to a welcome page
|
|
32
|
+
// and not already handled by the HTML rewriter of the CDS welcome page
|
|
33
|
+
if (accept && !req._cds_plugin_ui5 && req.url === (req["ui5-middleware-index"]?.url || req.url)) {
|
|
35
34
|
// determine context path (approuter contains x-forwarded-path header)
|
|
36
35
|
let contextPath = baseUrl;
|
|
37
|
-
if (req.headers["x-forwarded-path"]) {
|
|
36
|
+
if (req.headers["x-forwarded-path"]?.endsWith(url)) {
|
|
38
37
|
// determine the context path by removing the subpath from the forwarded path
|
|
39
38
|
contextPath = req.headers["x-forwarded-path"].slice(0, -1 * url.length);
|
|
40
|
-
} else if (req["
|
|
39
|
+
} else if (req["ui5-patched-router"].originalUrl?.endsWith(url)) {
|
|
41
40
|
// determine the context path by removing the subpath from the originalUrl
|
|
42
|
-
contextPath = req["
|
|
41
|
+
contextPath = req["ui5-patched-router"].originalUrl.slice(0, -1 * url.length);
|
|
43
42
|
}
|
|
44
43
|
rewriteHTML(
|
|
45
44
|
req,
|
|
@@ -50,21 +49,21 @@ module.exports = async function createPatchedRouter() {
|
|
|
50
49
|
},
|
|
51
50
|
(doc) => {
|
|
52
51
|
const title = doc.getElementsByTagName("title")?.[0];
|
|
53
|
-
if (title) {
|
|
52
|
+
if (title && title.innerHTML.startsWith(`Index of ${req.url}`)) {
|
|
54
53
|
title.innerHTML = `Index of ${contextPath}/`;
|
|
54
|
+
const files = doc.getElementById("files");
|
|
55
|
+
const filesas = files?.getElementsByTagName("a");
|
|
56
|
+
filesas?.forEach((a) => {
|
|
57
|
+
a.setAttribute("href", `${contextPath}${a.getAttribute("href")}`);
|
|
58
|
+
});
|
|
59
|
+
const h1 = doc.getElementsByTagName("h1")?.[0];
|
|
60
|
+
const h1as = h1?.getElementsByTagName("a");
|
|
61
|
+
h1as?.forEach((a) => {
|
|
62
|
+
const path = a.getAttribute("href") === "/" ? "/" : a.getAttribute("href") + "/";
|
|
63
|
+
a.setAttribute("href", `${contextPath}${path}`);
|
|
64
|
+
});
|
|
65
|
+
h1?.insertAdjacentHTML("afterbegin", `<a href="/">🏡</a> / `);
|
|
55
66
|
}
|
|
56
|
-
const files = doc.getElementById("files");
|
|
57
|
-
const filesas = files?.getElementsByTagName("a");
|
|
58
|
-
filesas?.forEach((a) => {
|
|
59
|
-
a.setAttribute("href", `${contextPath}${a.getAttribute("href")}`);
|
|
60
|
-
});
|
|
61
|
-
const h1 = doc.getElementsByTagName("h1")?.[0];
|
|
62
|
-
const h1as = h1?.getElementsByTagName("a");
|
|
63
|
-
h1as?.forEach((a) => {
|
|
64
|
-
const path = a.getAttribute("href") === "/" ? "/" : a.getAttribute("href") + "/";
|
|
65
|
-
a.setAttribute("href", `${contextPath}${path}`);
|
|
66
|
-
});
|
|
67
|
-
h1?.insertAdjacentHTML("afterbegin", `<a href="/">🏡</a> / `);
|
|
68
67
|
}
|
|
69
68
|
);
|
|
70
69
|
}
|
package/lib/findUI5Modules.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cds-plugin-ui5",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.13",
|
|
4
4
|
"description": "A CDS server plugin to inject the middlewares of all related UI5 tooling based projects.",
|
|
5
5
|
"author": "Peter Muessig",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"@ui5/project": "^3.7.0",
|
|
15
15
|
"@ui5/server": "^3.1.3",
|
|
16
16
|
"js-yaml": "^4.1.0",
|
|
17
|
-
"node-html-parser": "^6.1.
|
|
17
|
+
"node-html-parser": "^6.1.10"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"@sap/cds": "^6.8.4",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@sap/cds": ">=6.8.2",
|
|
25
25
|
"express": ">=4.18.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "0469566e63fdad3800a1a3a92c781f807328dac8"
|
|
28
28
|
}
|