dev-approuter 0.1.2 → 0.1.3

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 CHANGED
@@ -3,6 +3,14 @@
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.3](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.2...dev-approuter@0.1.3) (2023-08-29)
7
+
8
+ **Note:** Version bump only for package dev-approuter
9
+
10
+
11
+
12
+
13
+
6
14
  ## [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
15
 
8
16
 
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 might get overwritten by the `dev-approuter` in case you use them together with `dependency`.
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
 
@@ -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
- config.routes.unshift(configureCAPRoute(moduleId, servicesPaths, config.dependencyRoutes[moduleId]));
113
- config.dependencyRoutes[moduleId] = configureCAPRoute(moduleId, servicesPaths, config.dependencyRoutes[moduleId]);
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}`] = route;
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 = config.dependencyRoutes[route.dependency];
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
- route.authenticationType = "none";
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.2",
3
+ "version": "0.1.3",
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",
@@ -17,5 +17,5 @@
17
17
  "path": "^0.12.7",
18
18
  "ui5-middleware-cap": "^3.1.0"
19
19
  },
20
- "gitHead": "3e8e6d7625a544cb6d1a329cc66a8d796e1c969f"
20
+ "gitHead": "acbf2b7d5faf5d9b52a747201681c43a99377d02"
21
21
  }