cds-plugin-ui5 0.6.8 → 0.6.9
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 +11 -0
- package/README.md +7 -7
- package/cds-plugin.js +17 -6
- package/lib/findUI5Modules.js +4 -4
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
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.9](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.8...cds-plugin-ui5@0.6.9) (2023-09-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* prevent side-effects for combined scenarios ([#842](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/842)) ([36aaa5f](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/36aaa5f8d8b8404725250664704a560229055943))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [0.6.8](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.7...cds-plugin-ui5@0.6.8) (2023-09-13)
|
|
7
18
|
|
|
8
19
|
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> :wave: This is a **community project** and there is no official support for this package! Feel free to use it, open issues, contribute, and help answering questions.
|
|
4
4
|
|
|
5
|
-
The `cds-plugin-ui5` is a
|
|
5
|
+
The `cds-plugin-ui5` is a CDS server `cds-plugin` which enables the integration of UI5 tooling based (UI5 freestyle or Fiori elements) projects into the CDS server via the UI5 tooling express middlewares. The UI5 or Fiori elements projects just need to be located in the `app` folder of the CDS server or be dependency of the CDS server.
|
|
6
6
|
|
|
7
7
|
> :construction: **Note**
|
|
8
8
|
> This cds-plugin is still work in progress and not final yet!
|
|
@@ -13,7 +13,7 @@ The plugin requires [`@sap/cds`](https://www.npmjs.com/package/@sap/cds) `>=6.8.
|
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
15
15
|
|
|
16
|
-
Add a `devDependency` to the `cds-plugin-ui5` to your
|
|
16
|
+
Add a `devDependency` to the `cds-plugin-ui5` to your CDS server project:
|
|
17
17
|
|
|
18
18
|
```sh
|
|
19
19
|
npm add cds-plugin-ui5 -D
|
|
@@ -23,7 +23,7 @@ That's it!
|
|
|
23
23
|
|
|
24
24
|
### Configuration
|
|
25
25
|
|
|
26
|
-
The plugin accepts configuration to control the mount path for the embedding into the
|
|
26
|
+
The plugin accepts configuration to control the mount path for the embedding into the CDS server and selected configuration options for the UI5 server middlewares which are embedded into the mount path of the CDS server.
|
|
27
27
|
|
|
28
28
|
#### Mount Path
|
|
29
29
|
|
|
@@ -48,7 +48,7 @@ customConfiguration:
|
|
|
48
48
|
mountPath: /bookshop
|
|
49
49
|
```
|
|
50
50
|
|
|
51
|
-
In some cases it is necessary to overrule the UI5 application local configuration in the
|
|
51
|
+
In some cases it is necessary to overrule the UI5 application local configuration in the CDS server. Therefore, you can add custom configuration into the `package.json` of the CDS server into the section: `cds/cds-plugin-ui5/modules/%moduleId%/mountPath`
|
|
52
52
|
|
|
53
53
|
```json
|
|
54
54
|
{
|
|
@@ -67,7 +67,7 @@ In some cases it is necessary to overrule the UI5 application local configuratio
|
|
|
67
67
|
}
|
|
68
68
|
```
|
|
69
69
|
|
|
70
|
-
The `moduleId` is either the directory name for local apps in the `app` directory of the
|
|
70
|
+
The `moduleId` is either the directory name for local apps in the `app` directory of the CDS server or for dependencies the `name` from the `package.json`.
|
|
71
71
|
|
|
72
72
|
The configuration can also be injected with the environment variable `CDS_PLUGIN_UI5_MODULES`. It contains the JSON string from the configuration above, e.g.:
|
|
73
73
|
|
|
@@ -77,7 +77,7 @@ CDS_PLUGIN_UI5_MODULES="{ \"ui5-bookshop\": { \"mountPath\": \"/the-bookshop\" }
|
|
|
77
77
|
|
|
78
78
|
#### UI5 Server Middlewares
|
|
79
79
|
|
|
80
|
-
If you require to configure the UI5 server middlewares, you can do so by adding some selected configuration options in the `package.json` of the
|
|
80
|
+
If you require to configure the UI5 server middlewares, you can do so by adding some selected configuration options in the `package.json` of the CDS server in the section: `cds/cds-plugin-ui5/modules/%moduleId%`
|
|
81
81
|
|
|
82
82
|
```json
|
|
83
83
|
{
|
|
@@ -99,7 +99,7 @@ If you require to configure the UI5 server middlewares, you can do so by adding
|
|
|
99
99
|
}
|
|
100
100
|
```
|
|
101
101
|
|
|
102
|
-
The `moduleId` is either the directory name for local apps in the `app` directory of the
|
|
102
|
+
The `moduleId` is either the directory name for local apps in the `app` directory of the CDS server or for dependencies the `name` from the `package.json`.
|
|
103
103
|
|
|
104
104
|
The available configuration options are:
|
|
105
105
|
|
package/cds-plugin.js
CHANGED
|
@@ -41,7 +41,7 @@ cds.on("bootstrap", async function bootstrap(app) {
|
|
|
41
41
|
for await (const ui5Module of ui5Modules) {
|
|
42
42
|
const { moduleId, mountPath, modulePath } = ui5Module;
|
|
43
43
|
|
|
44
|
-
// mounting the Router for the UI5 application to the
|
|
44
|
+
// mounting the Router for the UI5 application to the CDS server
|
|
45
45
|
log.info(`Mounting ${mountPath} to UI5 app ${modulePath} (id=${moduleId})${config[moduleId] ? ` using config=${JSON.stringify(config[moduleId])}` : ""}`);
|
|
46
46
|
|
|
47
47
|
// create a patched router
|
|
@@ -65,7 +65,18 @@ cds.on("bootstrap", async function bootstrap(app) {
|
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
// identify whether the welcome page should be rewritten
|
|
69
|
+
let rewrite = links.length > 0;
|
|
70
|
+
if (process.env["ui5-middleware-cap"]) {
|
|
71
|
+
log.info("Skip rewriting of welcome page as CDS server is started via ui5-middleware-cap!");
|
|
72
|
+
rewrite = false;
|
|
73
|
+
} else if (process.env["dev-approuter"]) {
|
|
74
|
+
log.info("Skip rewriting of welcome page as CDS server is started via dev-approuter!");
|
|
75
|
+
rewrite = false;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// rewrite the welcome page
|
|
79
|
+
if (rewrite) {
|
|
69
80
|
// register the custom middleware (similar like in @sap/cds/server.js)
|
|
70
81
|
app.get("/", function appendLinksToIndex(req, res, next) {
|
|
71
82
|
req._cds_plugin_ui5 = true; // marker for patched router to ignore
|
|
@@ -110,14 +121,14 @@ cds.on("bootstrap", async function bootstrap(app) {
|
|
|
110
121
|
newLis.push(...links.map((link) => `<li><a class="ui5" href="${link}">${link}</a></li>`));
|
|
111
122
|
ul.innerHTML = newLis.join("\n");
|
|
112
123
|
} else {
|
|
113
|
-
log.warn(`Failed to inject application links into
|
|
124
|
+
log.warn(`Failed to inject application links into CDS index page!`);
|
|
114
125
|
}
|
|
115
126
|
}
|
|
116
127
|
);
|
|
117
128
|
next();
|
|
118
129
|
});
|
|
119
130
|
|
|
120
|
-
// move our middleware before the
|
|
131
|
+
// move our middleware before the CDS index serve middleware to
|
|
121
132
|
// allow that we can intercept the response and modify it to
|
|
122
133
|
// inject our application pages an remove the exitsing ones
|
|
123
134
|
const middlewareStack = app?._router?.stack;
|
|
@@ -127,10 +138,10 @@ cds.on("bootstrap", async function bootstrap(app) {
|
|
|
127
138
|
if (idxOfServeStatic !== -1) {
|
|
128
139
|
middlewareStack.splice(idxOfServeStatic, 0, cmw);
|
|
129
140
|
} else {
|
|
130
|
-
log.error(`Failed to determine
|
|
141
|
+
log.error(`Failed to determine welcome page middleware! The links of the application pages may not work properly!`);
|
|
131
142
|
}
|
|
132
143
|
} else {
|
|
133
|
-
log.error(`Failed to inject application pages to
|
|
144
|
+
log.error(`Failed to inject application pages to welcome page! The links of the application pages may not work properly!`);
|
|
134
145
|
}
|
|
135
146
|
}
|
|
136
147
|
// bootstrap completed, unlock the "served" event
|
package/lib/findUI5Modules.js
CHANGED
|
@@ -97,7 +97,7 @@ module.exports = async function findUI5Modules({ cwd, skipLocalApps, skipDeps })
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
// if apps are available, attach the middlewares of the UI5 apps
|
|
100
|
-
// to the express of the
|
|
100
|
+
// to the express of the CDS server via a express router
|
|
101
101
|
const apps = [];
|
|
102
102
|
apps.config = {};
|
|
103
103
|
if (appDirs) {
|
|
@@ -125,7 +125,7 @@ module.exports = async function findUI5Modules({ cwd, skipLocalApps, skipDeps })
|
|
|
125
125
|
const modulePath = path.dirname(ui5YamlPath);
|
|
126
126
|
|
|
127
127
|
// manually get the module name as defined in package.json
|
|
128
|
-
// skipDeps is only true if we are looking for UI5 apps inside a
|
|
128
|
+
// skipDeps is only true if we are looking for UI5 apps inside a CDS
|
|
129
129
|
// server project in all other cases the module name equals the appDir
|
|
130
130
|
let moduleName;
|
|
131
131
|
if (skipDeps) {
|
|
@@ -140,7 +140,7 @@ module.exports = async function findUI5Modules({ cwd, skipLocalApps, skipDeps })
|
|
|
140
140
|
// by default the mount path is derived from the "metadata/name"
|
|
141
141
|
// and can be overridden by "customConfiguration/mountPath" or
|
|
142
142
|
// by "customConfiguration/cds-plugin-ui5/mountPath" or by
|
|
143
|
-
// the following configuration entry in the package.json of
|
|
143
|
+
// the following configuration entry in the package.json of CDS
|
|
144
144
|
// server: "cds/cds-plugin-ui5/modules/%moduleId%/mountPath"
|
|
145
145
|
let mountPath =
|
|
146
146
|
modulesConfig?.[moduleId]?.mountPath || ui5Config?.customConfiguration?.["cds-plugin-ui5"]?.mountPath || ui5Config?.customConfiguration?.mountPath || ui5Config?.metadata?.name;
|
|
@@ -157,7 +157,7 @@ module.exports = async function findUI5Modules({ cwd, skipLocalApps, skipDeps })
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
|
-
apps.localApps = localApps; // necessary for
|
|
160
|
+
apps.localApps = localApps; // necessary for CDS index.html rewrite
|
|
161
161
|
|
|
162
162
|
// return the apps
|
|
163
163
|
return apps;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cds-plugin-ui5",
|
|
3
|
-
"version": "0.6.
|
|
4
|
-
"description": "A
|
|
3
|
+
"version": "0.6.9",
|
|
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",
|
|
7
7
|
"repository": {
|
|
@@ -24,5 +24,5 @@
|
|
|
24
24
|
"@sap/cds": ">=6.8.2",
|
|
25
25
|
"express": ">=4.18.2"
|
|
26
26
|
},
|
|
27
|
-
"gitHead": "
|
|
27
|
+
"gitHead": "7ff4fbf9fa7501c5e2691bb2b92c1ea59a403edf"
|
|
28
28
|
}
|