dev-approuter 0.1.22 → 0.2.1

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,28 @@
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.2.1](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.2.0...dev-approuter@0.2.1) (2023-10-04)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **dev-approuter:** consider the UI5 middleware config ([#872](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/872)) ([e724aee](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/e724aeeee9bbb66d3ee2070474f63f7f4ea57299))
12
+
13
+
14
+
15
+
16
+
17
+ # [0.2.0](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.22...dev-approuter@0.2.0) (2023-10-03)
18
+
19
+
20
+ ### Features
21
+
22
+ * **ui5-middleware-cap:** wrap @sap/cds/bin/serve command ([#869](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/869)) ([541e6e6](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/541e6e6d8f877e4bf4e472bc576e7e33224f0e03))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.1.22](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/dev-approuter@0.1.21...dev-approuter@0.1.22) (2023-10-02)
7
29
 
8
30
  **Note:** Version bump only for package dev-approuter
@@ -58,9 +58,19 @@ class DevApprouter {
58
58
  }
59
59
 
60
60
  // find all UI5 modules from the CDS server root and dependencies from the approuter
61
- const ui5Modules = [...(await findUI5Modules({ cwd, skipLocalApps: true }))];
61
+ const ui5Modules = [];
62
+ let ui5ModulesConfig = {};
63
+ const approuterUI5Modules = await findUI5Modules({ cwd, skipLocalApps: true });
64
+ ui5Modules.push(...(approuterUI5Modules || []));
65
+ const { config: approuterUI5ModulesConfig } = approuterUI5Modules;
66
+ ui5ModulesConfig = Object.assign(ui5ModulesConfig, approuterUI5ModulesConfig);
67
+ //const ui5Modules = [...(await findUI5Modules({ cwd, skipLocalApps: true }))];
62
68
  if (cdsServerConfig) {
63
- ui5Modules.push(...(await findUI5Modules({ cwd: cdsServerConfig.modulePath, skipDeps: true })));
69
+ const cdsUI5Modules = await findUI5Modules({ cwd: cdsServerConfig.modulePath, skipLocalApps: true });
70
+ ui5Modules.push(...(cdsUI5Modules || []));
71
+ const { config: cdsUI5ModulesConfig } = cdsUI5Modules;
72
+ ui5ModulesConfig = Object.assign(ui5ModulesConfig, cdsUI5ModulesConfig);
73
+ //ui5Modules.push(...(await findUI5Modules({ cwd: cdsServerConfig.modulePath, skipDeps: true })));
64
74
  }
65
75
 
66
76
  // collect UI5 middlewares
@@ -75,6 +85,7 @@ class DevApprouter {
75
85
  await applyUI5Middleware(router, {
76
86
  cwd,
77
87
  basePath: modulePath,
88
+ ...(ui5ModulesConfig[moduleId] || {}),
78
89
  });
79
90
 
80
91
  // mounting the router for the UI5 application to the CDS server
@@ -104,12 +115,26 @@ class DevApprouter {
104
115
  // start CDS server on different port
105
116
  if (cdsServerConfig) {
106
117
  const { modulePath, moduleId } = cdsServerConfig;
118
+ const port = process.env.CDS_PORT || 4004;
107
119
 
108
- // start CDS server on different port
120
+ // start CDS server on different port (requires to override the
121
+ // origin listen function to intercept call from CDS server and
122
+ // ensure to use the port as defined by environment variable or
123
+ // the default port for the CDS server!)
109
124
  const app = express();
110
- const { servicesPaths } = await applyCDSMiddleware(app, { root: modulePath, cwd });
111
- app.listen(process.env.CDS_PORT || 4004, () => {
112
- console.log(`CDS server started at: http://localhost:${process.env.CDS_PORT || 4004}`);
125
+ app._listen = app.listen;
126
+ app.listen = function (port, callback) {
127
+ return this._listen(process.env.CDS_PORT || 4004, function () {
128
+ console.log(`CDS server started at: http://localhost:${process.env.CDS_PORT || 4004}`);
129
+ callback?.apply(callback, arguments);
130
+ });
131
+ };
132
+
133
+ // apply the CDS server middlewares and keep the welcome page
134
+ const { servicesPaths } = await applyCDSMiddleware(app, {
135
+ root: modulePath,
136
+ options: config.dependencyRoutes[moduleId]?.options,
137
+ headless: false,
113
138
  });
114
139
 
115
140
  // create route if CDS module is not referenced in xs-dev.json/xs-app.json
@@ -125,7 +150,7 @@ class DevApprouter {
125
150
  }
126
151
 
127
152
  // add destination for newly configured route
128
- addDestination(moduleId, process.env.CDS_PORT || 4004);
153
+ addDestination(moduleId, port);
129
154
  }
130
155
 
131
156
  // create and start the SAP Approuter
package/lib/helpers.js CHANGED
@@ -43,6 +43,7 @@ const applyDependencyConfig = (config) => {
43
43
  if (route.dependency) {
44
44
  Object.assign(route, config.dependencyRoutes[route.dependency]);
45
45
  delete route.dependency;
46
+ delete route.options;
46
47
  }
47
48
  });
48
49
  delete config.dependencyRoutes;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dev-approuter",
3
- "version": "0.1.22",
3
+ "version": "0.2.1",
4
4
  "description": "A dev time wrapper for the SAP Application Router that can serve UI5 and CDS modules added as dependencies.",
5
5
  "author": "Nico Schoenteich <nicolai.schoenteich@sap.com> (https://github.com/nicoschoenteich)",
6
6
  "license": "Apache-2.0",
@@ -14,7 +14,7 @@
14
14
  "@sap/xsenv": "4.0.0",
15
15
  "cds-plugin-ui5": "^0.6.13",
16
16
  "express": "^4.18.2",
17
- "ui5-middleware-cap": "^3.1.5"
17
+ "ui5-middleware-cap": "^3.2.1"
18
18
  },
19
- "gitHead": "0469566e63fdad3800a1a3a92c781f807328dac8"
19
+ "gitHead": "4c60ccc427b97468dbc6aee0d4c909d42c49e926"
20
20
  }