cds-plugin-ui5 0.6.10 → 0.6.12
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 +23 -0
- package/cds-plugin.js +15 -6
- package/lib/applyUI5Middleware.js +4 -1
- package/lib/createPatchedRouter.js +22 -23
- package/lib/findUI5Modules.js +1 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,29 @@
|
|
|
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.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)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **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))
|
|
12
|
+
* **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))
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
## [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)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
* **cds-plugin-ui5:** disable view cache for Fiori elements based apps ([#847](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/847)) ([81f6a80](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/81f6a803cff4f0c7323e7dcf5b2a28dc081d3123))
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
6
29
|
## [0.6.10](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.9...cds-plugin-ui5@0.6.10) (2023-09-15)
|
|
7
30
|
|
|
8
31
|
|
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;
|
|
@@ -123,7 +123,14 @@ if (!skip) {
|
|
|
123
123
|
newLis.push(li.toString());
|
|
124
124
|
}
|
|
125
125
|
});
|
|
126
|
-
newLis.push(
|
|
126
|
+
newLis.push(
|
|
127
|
+
...links.sort().map((link) => {
|
|
128
|
+
// we remove the query parameters from the link text
|
|
129
|
+
const linkText = link.indexOf("?") === -1 ? link : link.substr(0, link.indexOf("?"));
|
|
130
|
+
// renders a UI5 link ;-)
|
|
131
|
+
return `<li><a class="ui5" href="${link}">${linkText}</a></li>`;
|
|
132
|
+
})
|
|
133
|
+
);
|
|
127
134
|
ul.innerHTML = newLis.join("\n");
|
|
128
135
|
} else {
|
|
129
136
|
log.warn(`Failed to inject application links into CDS index page!`);
|
|
@@ -157,6 +164,8 @@ if (!skip) {
|
|
|
157
164
|
// return callback for plugin activation
|
|
158
165
|
module.exports = {
|
|
159
166
|
activate: function activate(conf) {
|
|
160
|
-
|
|
167
|
+
if (!skip) {
|
|
168
|
+
log.debug("activate", conf);
|
|
169
|
+
}
|
|
161
170
|
},
|
|
162
171
|
};
|
|
@@ -117,9 +117,12 @@ module.exports = async function applyUI5Middleware(router, options) {
|
|
|
117
117
|
});
|
|
118
118
|
await middlewareManager.applyMiddleware(router);
|
|
119
119
|
|
|
120
|
+
// for Fiori elements based applications we need to invalidate the view cache
|
|
121
|
+
const isFioriElementsBased = rootProject.getFrameworkDependencies().find((lib) => lib.name.startsWith("sap.fe"));
|
|
122
|
+
|
|
120
123
|
// collect app pages from workspace (glob testing: https://globster.xyz/ and https://codepen.io/mrmlnc/pen/OXQjMe)
|
|
121
124
|
// -> but exclude the HTML fragments from the list of app pages!
|
|
122
|
-
const pages = (await rootReader.byGlob("**/!(*.fragment).{html,htm}")).map((resource) => resource.getPath());
|
|
125
|
+
const pages = (await rootReader.byGlob("**/!(*.fragment).{html,htm}")).map((resource) => `${resource.getPath()}${isFioriElementsBased ? "?sap-ui-xx-viewCache=false" : ""}`);
|
|
123
126
|
|
|
124
127
|
// collect app pages from middlewares implementing the getAppPages
|
|
125
128
|
middlewareManager.middlewareExecutionOrder?.map((name) => {
|
|
@@ -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.12",
|
|
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",
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@sap/cds": ">=6.8.2",
|
|
25
25
|
"express": ">=4.18.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "fb2d781edbff18febc11b79d686281cddc2532d6"
|
|
28
28
|
}
|