cds-plugin-ui5 0.6.1 → 0.6.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,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.6.3](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.2...cds-plugin-ui5@0.6.3) (2023-09-08)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cds-plugin-ui5:** fix type for config ([ebd95f0](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/ebd95f0e5a269c769587e7c9c3bdf6885fc7ca3d))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.6.2](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.1...cds-plugin-ui5@0.6.2) (2023-09-08)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **cds-plugin-ui5:** allow relative config files in package.json ([#838](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/838)) ([735b24d](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/735b24d34cebee5463c97c3bb5a3d58e07dace24))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.6.1](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.6.0...cds-plugin-ui5@0.6.1) (2023-09-08)
7
29
 
8
30
 
package/README.md CHANGED
@@ -108,6 +108,8 @@ The available configuration options are:
108
108
  * `workspaceName`: *`string`* - name of the workspace (defaults to "default" when the file at workspaceConfigPath exists)
109
109
  * `versionOverride`: *`string`* - Framework version to use instead of the one defined in the root project
110
110
 
111
+ If the `configFile` or `workspaceConfigFile` startes with `./` or `../` then the config file is considered to be relative to the `package.json`.
112
+
111
113
  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.:
112
114
 
113
115
  ```sh
package/cds-plugin.js CHANGED
@@ -49,6 +49,7 @@ cds.on("bootstrap", async function bootstrap(app) {
49
49
  // apply the UI5 middlewares to the router and
50
50
  // retrieve the available HTML pages
51
51
  const appInfo = await applyUI5Middleware(router, {
52
+ cwd,
52
53
  basePath: modulePath,
53
54
  ...(config[moduleId] || {}),
54
55
  });
@@ -12,6 +12,7 @@ const log = require("./log");
12
12
  /**
13
13
  * @typedef applyUI5MiddlewareOptions
14
14
  * @type {object}
15
+ * @property {string} [cwd] cwd to resolve relative config files to, e.g. "./ui5.yaml" or "./ui5-workspace.yaml" (defaults to `process.cwd()`)
15
16
  * @property {string} [basePath] base path of the UI5 application (defaults to `process.cwd()`)
16
17
  * @property {string} [configFile] name of the config file (defaults to "ui5.yaml")
17
18
  * @property {string} [configPath] /!\ RESTRICTED /!\ - path to the ui5.yaml (defaults to "${basePath}/${configFile}")
@@ -30,23 +31,37 @@ const log = require("./log");
30
31
  * @param {applyUI5MiddlewareOptions} options configuration options
31
32
  * @returns {UI5AppInfo} UI5 application information object
32
33
  */
33
- module.exports = async function applyUI5Middleware(router, options = { basePath: process.cwd() }) {
34
+ module.exports = async function applyUI5Middleware(router, options) {
34
35
  const { graphFromPackageDependencies } = await import("@ui5/project/graph");
35
36
  const { createReaderCollection } = await import("@ui5/fs/resourceFactory");
36
37
 
38
+ options.cwd = options.cwd || process.cwd();
39
+ options.basePath = options.basePath || process.cwd();
40
+
37
41
  const configPath = options.configPath || options.basePath;
38
42
  const configFile = options.configFile || "ui5.yaml";
39
43
  const workspaceConfigPath = options.workspaceConfigPath || options.basePath;
40
- const workpaceConfigFile = options.workpaceConfigFile || "ui5-workspace.yaml";
44
+ const workspaceConfigFile = options.workspaceConfigFile || "ui5-workspace.yaml";
41
45
 
42
46
  const determineConfigPath = function (configPath, configFile) {
47
+ // ensure that the config path is absolute
48
+ if (!path.isAbsolute(configPath)) {
49
+ configPath = path.resolve(options.basePath, configPath);
50
+ }
51
+ // if the config path is a file, then we assume that this is the
52
+ // configuration which should be used for the UI5 server middlewares
43
53
  if (fs.existsSync(configPath) && fs.statSync(configPath).isFile()) {
44
54
  return configPath;
45
55
  }
46
- configPath = path.resolve(configPath, configFile);
56
+ // if the configuration file is starting with ./ or ../ then we
57
+ // resolve the configuration relative to the current working dir
58
+ // otherwise we are resolving it relative to the config path
59
+ // which is typically the directory of the UI5 application
60
+ configPath = path.resolve(/^\.\.?\//.test(configFile) ? options.cwd : configPath, configFile);
47
61
  if (fs.existsSync(configPath) && fs.statSync(configPath).isFile()) {
48
62
  return configPath;
49
63
  }
64
+ // nothing matched => no config
50
65
  return undefined;
51
66
  };
52
67
 
@@ -54,7 +69,7 @@ module.exports = async function applyUI5Middleware(router, options = { basePath:
54
69
  cwd: options.basePath,
55
70
  rootConfigPath: determineConfigPath(configPath, configFile),
56
71
  workspaceName: process.env["ui5-workspace"] || options.workspaceName || "default",
57
- workspaceConfigPath: determineConfigPath(workspaceConfigPath, workpaceConfigFile),
72
+ workspaceConfigPath: determineConfigPath(workspaceConfigPath, workspaceConfigFile),
58
73
  versionOverride: options.versionOverride,
59
74
  cacheMode: options.cacheMode,
60
75
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cds-plugin-ui5",
3
- "version": "0.6.1",
3
+ "version": "0.6.3",
4
4
  "description": "A CAP server cds-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": "8a914d8872de9fd4b0583fe44493acf0cee71c86"
27
+ "gitHead": "3472cac3f95ef971a3b912fc71c97cd8e3518e20"
28
28
  }