dev-approuter 0.1.2 → 0.1.4
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 +16 -0
- package/README.md +1 -1
- package/lib/devApprouter.js +11 -2
- package/lib/helpers.js +10 -10
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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.1.4](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.3...dev-approuter@0.1.4) (2023-09-02)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package dev-approuter
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
## [0.1.3](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.2...dev-approuter@0.1.3) (2023-08-29)
|
|
15
|
+
|
|
16
|
+
**Note:** Version bump only for package dev-approuter
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [0.1.2](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.1...dev-approuter@0.1.2) (2023-08-25)
|
|
7
23
|
|
|
8
24
|
|
package/README.md
CHANGED
|
@@ -134,7 +134,7 @@ Look at the following example `xs-dev.json` that defines different `authenticati
|
|
|
134
134
|
}
|
|
135
135
|
```
|
|
136
136
|
|
|
137
|
-
Behind the scenes, the `dev-approuter` will resolve these "dependency routes" by adding the `source`, `target`, and `destination` properties to them. Be aware that exactly these properties
|
|
137
|
+
Behind the scenes, the `dev-approuter` will resolve these "dependency routes" by adding the `source`, `target`, and `destination` properties to them. Be aware that exactly these properties get overwritten by the `dev-approuter` in case you use them together with `dependency`. The only exception are SAP CAP dependencies, for which only the `destination` property gets overwritten by the `dev-approuter`.
|
|
138
138
|
|
|
139
139
|
## Using the `dev-approuter` and SAP Application Router simultaneously
|
|
140
140
|
|
package/lib/devApprouter.js
CHANGED
|
@@ -109,8 +109,17 @@ class DevApprouter {
|
|
|
109
109
|
console.log(`CAP server started at: http://localhost:${process.env.CAP_PORT || 4004}`);
|
|
110
110
|
});
|
|
111
111
|
|
|
112
|
-
|
|
113
|
-
|
|
112
|
+
// create route if CAP module is not referenced in xs-dev.json/xs-app.json
|
|
113
|
+
if (!config.dependencyRoutes[moduleId]) {
|
|
114
|
+
const route = {
|
|
115
|
+
dependency: moduleId,
|
|
116
|
+
authenticationType: "none",
|
|
117
|
+
};
|
|
118
|
+
config.routes.unshift(Object.assign({}, route));
|
|
119
|
+
config.dependencyRoutes[moduleId] = configureCAPRoute(moduleId, servicesPaths, route);
|
|
120
|
+
} else {
|
|
121
|
+
config.dependencyRoutes[moduleId] = configureCAPRoute(moduleId, servicesPaths, config.dependencyRoutes[moduleId]);
|
|
122
|
+
}
|
|
114
123
|
|
|
115
124
|
// add destination for newly configured route
|
|
116
125
|
addDestination(moduleId, process.env.CAP_PORT || 4004);
|
package/lib/helpers.js
CHANGED
|
@@ -25,7 +25,8 @@ const parseConfig = () => {
|
|
|
25
25
|
if (config.dependencyRoutes[`${route.dependency}`]) {
|
|
26
26
|
throw new Error(`Duplicate dependency "${route.dependency}" found in file ${path.join(process.cwd(), configFile)}.`);
|
|
27
27
|
} else {
|
|
28
|
-
config.dependencyRoutes[`${route.dependency}`] =
|
|
28
|
+
config.dependencyRoutes[`${route.dependency}`] = {};
|
|
29
|
+
Object.assign(config.dependencyRoutes[`${route.dependency}`], route);
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
});
|
|
@@ -40,7 +41,8 @@ const parseConfig = () => {
|
|
|
40
41
|
const applyDependencyConfig = (config) => {
|
|
41
42
|
config.routes?.forEach((route) => {
|
|
42
43
|
if (route.dependency) {
|
|
43
|
-
route
|
|
44
|
+
Object.assign(route, config.dependencyRoutes[route.dependency]);
|
|
45
|
+
delete route.dependency;
|
|
44
46
|
}
|
|
45
47
|
});
|
|
46
48
|
delete config.dependencyRoutes;
|
|
@@ -95,15 +97,13 @@ const addDestination = (moduleId, port, mountPath) => {
|
|
|
95
97
|
* @returns {Object} the configured route.
|
|
96
98
|
*/
|
|
97
99
|
const configureCAPRoute = (moduleId, servicesPaths, route) => {
|
|
98
|
-
if (!route) {
|
|
99
|
-
route =
|
|
100
|
-
|
|
100
|
+
if (!route.source) {
|
|
101
|
+
route.source = servicesPaths
|
|
102
|
+
.map((path) => {
|
|
103
|
+
return `${path}(.*)`;
|
|
104
|
+
})
|
|
105
|
+
.join("|");
|
|
101
106
|
}
|
|
102
|
-
route.source = servicesPaths
|
|
103
|
-
.map((path) => {
|
|
104
|
-
return `${path}(.*)`;
|
|
105
|
-
})
|
|
106
|
-
.join("|");
|
|
107
107
|
route.destination = moduleId;
|
|
108
108
|
delete route.dependency;
|
|
109
109
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dev-approuter",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"description": "A dev time wrapper for the SAP Application Router that can serve UI5 and CAP modules added as dependencies.",
|
|
5
5
|
"author": "Nico Schoenteich <nicolai.schoenteich@sap.com> (https://github.com/nicoschoenteich)",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@sap/approuter": ">=14.3.0",
|
|
14
14
|
"@sap/xsenv": "4.0.0",
|
|
15
|
-
"cds-plugin-ui5": "^0.
|
|
15
|
+
"cds-plugin-ui5": "^0.5.0",
|
|
16
16
|
"express": "^4.18.2",
|
|
17
17
|
"path": "^0.12.7",
|
|
18
18
|
"ui5-middleware-cap": "^3.1.0"
|
|
19
19
|
},
|
|
20
|
-
"gitHead": "
|
|
20
|
+
"gitHead": "9db24d0cd23d691749cd1419f24ec7f6cf7c1f5b"
|
|
21
21
|
}
|