cds-plugin-ui5 0.9.4 → 0.9.6

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.9.6](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.5...cds-plugin-ui5@0.9.6) (2024-07-22)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cds-plugin-ui5:** correctly determine the @sap/cds-dk version ([#1047](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1047)) ([5c7f982](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/5c7f982715c6ed2e11859420a4867d192117e9aa))
12
+
13
+
14
+
15
+
16
+
17
+ ## [0.9.5](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.4...cds-plugin-ui5@0.9.5) (2024-07-22)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **cds-plugin-ui5:** report versions of the plugin and @sap/cds-dk, @sap/cds ([#1045](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1045)) ([8db7560](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/8db7560da65d2d042a5e71887b885c8d102714db))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [0.9.4](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.3...cds-plugin-ui5@0.9.4) (2024-07-19)
7
29
 
8
30
 
package/cds-plugin.js CHANGED
@@ -48,8 +48,11 @@ if (!skip) {
48
48
  // to disable the ui5-middleware-cap if used in apps
49
49
  process.env["cds-plugin-ui5"] = true;
50
50
 
51
+ const { dirname, join, resolve } = require("path");
52
+ const { readFileSync, existsSync, realpathSync } = require("fs");
51
53
  const { execSync } = require("child_process");
52
- const { readFileSync } = require("fs");
54
+
55
+ const { version: cdsPluginUI5Version } = require(`${__dirname}/package.json`);
53
56
 
54
57
  // function to resolve a module with the given paths without throwing an error
55
58
  const resolveModule = function resolveModule(moduleName, paths) {
@@ -60,23 +63,54 @@ if (!skip) {
60
63
  }
61
64
  };
62
65
 
66
+ // helper to find the package.json in the current dir or upwards
67
+ const findPackageJson = function findPackageJson(dir) {
68
+ let currentDir = dir;
69
+ while (currentDir !== resolve(currentDir, "..")) {
70
+ const packageJsonPath = join(currentDir, "package.json");
71
+ if (existsSync(packageJsonPath)) {
72
+ return packageJsonPath;
73
+ }
74
+ currentDir = resolve(currentDir, "..");
75
+ }
76
+ return undefined;
77
+ };
78
+
63
79
  // find out the CDS-DK version to control the behavior of the plugin
64
80
  const getCDSDKVersion = function getCDSDKVersion() {
65
- const moduleName = "@sap/cds-dk";
66
- const globalModulesPath = execSync("npm root -g").toString().trim();
67
- let resolvedPath = resolveModule(`${moduleName}/package.json`);
68
- if (!resolvedPath) {
69
- resolvedPath = resolveModule(`${moduleName}/package.json`, [globalModulesPath]);
70
- }
71
- if (resolvedPath) {
72
- const packageJson = JSON.parse(readFileSync(resolvedPath, { encoding: "utf-8" }));
81
+ const cdsDkPath = realpathSync(process.argv[1]);
82
+ const cdsDkDir = dirname(cdsDkPath);
83
+ const packageJsonPath = findPackageJson(cdsDkDir);
84
+ if (packageJsonPath) {
85
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, { encoding: "utf-8" }));
73
86
  return packageJson.version;
87
+ } else {
88
+ const moduleName = "@sap/cds-dk";
89
+ let resolvedPath = resolveModule(`${moduleName}/package.json`);
90
+ if (!resolvedPath) {
91
+ const globalModulesPath = execSync("npm root -g").toString().trim();
92
+ resolvedPath = resolveModule(`${moduleName}/package.json`, [globalModulesPath]);
93
+ }
94
+ if (resolvedPath) {
95
+ const packageJson = JSON.parse(readFileSync(resolvedPath, { encoding: "utf-8" }));
96
+ return packageJson.version;
97
+ }
74
98
  }
99
+ return undefined;
75
100
  };
76
101
 
77
102
  // get the CDS-DK version to control the behavior of the plugin
78
103
  const cdsdkVersion = getCDSDKVersion();
79
104
 
105
+ // logging the version of the cds-plugin-ui5
106
+ log.info(`Running cds-plugin-ui5@${cdsPluginUI5Version} (@sap/cds-dk@${cdsdkVersion}, @sap/cds@${cds.version})`);
107
+ if (global.__cds_loaded_from?.size > 1) {
108
+ log.warn(" !! Multiple versions of @sap/cds loaded !!");
109
+ global.__cds_loaded_from.forEach((cdsPath) => {
110
+ log.warn(` => ${cdsPath}`);
111
+ });
112
+ }
113
+
80
114
  // promise to await the bootstrap and lock the
81
115
  // served event to delay the startup a bit
82
116
  let bootstrapped;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cds-plugin-ui5",
3
- "version": "0.9.4",
3
+ "version": "0.9.6",
4
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",
@@ -12,19 +12,19 @@
12
12
  },
13
13
  "dependencies": {
14
14
  "@ui5/fs": "^3.0.5",
15
- "@ui5/project": "^3.9.1",
16
- "@ui5/server": "^3.2.0",
15
+ "@ui5/project": "^3.9.2",
16
+ "@ui5/server": "^3.2.1",
17
17
  "js-yaml": "^4.1.0",
18
18
  "node-html-parser": "^6.1.13",
19
- "semver": "^7.6.2"
19
+ "semver": "^7.6.3"
20
20
  },
21
21
  "devDependencies": {
22
- "@sap/cds": "^6.8.4",
23
- "express": "^4.19.2"
22
+ "@sap/cds": "*",
23
+ "express": "*"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@sap/cds": ">=6.8.2",
27
27
  "express": ">=4.18.2"
28
28
  },
29
- "gitHead": "4a689e18ba048dfcb02b9adbd98b82769db22f53"
29
+ "gitHead": "d17d6b66530a90711be777b9864fe2bf4f27f239"
30
30
  }