cds-plugin-ui5 0.9.5 → 0.9.7

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.7](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.6...cds-plugin-ui5@0.9.7) (2024-07-23)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cds-plugin-ui5:** fix error when resolving symlinks for CDS-DK root ([#1048](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1048)) ([3b05ada](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/3b05ada1fe2bfac2ecc962af700646030d8c39d8)), closes [#1033](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1033)
12
+
13
+
14
+
15
+
16
+
17
+ ## [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)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **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))
23
+
24
+
25
+
26
+
27
+
6
28
  ## [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)
7
29
 
8
30
 
package/cds-plugin.js CHANGED
@@ -48,8 +48,9 @@ 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");
53
54
 
54
55
  const { version: cdsPluginUI5Version } = require(`${__dirname}/package.json`);
55
56
 
@@ -62,18 +63,45 @@ if (!skip) {
62
63
  }
63
64
  };
64
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
+
65
79
  // find out the CDS-DK version to control the behavior of the plugin
66
80
  const getCDSDKVersion = function getCDSDKVersion() {
67
- const moduleName = "@sap/cds-dk";
68
- let resolvedPath = resolveModule(`${moduleName}/package.json`);
69
- if (!resolvedPath) {
70
- const globalModulesPath = execSync("npm root -g").toString().trim();
71
- resolvedPath = resolveModule(`${moduleName}/package.json`, [globalModulesPath]);
81
+ let cdsDkPath = process.argv[1];
82
+ try {
83
+ cdsDkPath = realpathSync(cdsDkPath);
84
+ } catch (err) {
85
+ // ignore
72
86
  }
73
- if (resolvedPath) {
74
- const packageJson = JSON.parse(readFileSync(resolvedPath, { encoding: "utf-8" }));
87
+ const cdsDkDir = dirname(cdsDkPath);
88
+ const packageJsonPath = findPackageJson(cdsDkDir);
89
+ if (packageJsonPath) {
90
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, { encoding: "utf-8" }));
75
91
  return packageJson.version;
92
+ } else {
93
+ const moduleName = "@sap/cds-dk";
94
+ let resolvedPath = resolveModule(`${moduleName}/package.json`);
95
+ if (!resolvedPath) {
96
+ const globalModulesPath = execSync("npm root -g").toString().trim();
97
+ resolvedPath = resolveModule(`${moduleName}/package.json`, [globalModulesPath]);
98
+ }
99
+ if (resolvedPath) {
100
+ const packageJson = JSON.parse(readFileSync(resolvedPath, { encoding: "utf-8" }));
101
+ return packageJson.version;
102
+ }
76
103
  }
104
+ return undefined;
77
105
  };
78
106
 
79
107
  // get the CDS-DK version to control the behavior of the plugin
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cds-plugin-ui5",
3
- "version": "0.9.5",
3
+ "version": "0.9.7",
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",
@@ -26,5 +26,5 @@
26
26
  "@sap/cds": ">=6.8.2",
27
27
  "express": ">=4.18.2"
28
28
  },
29
- "gitHead": "0a4076873a7fbd2fc675b5f9c2ec2efa3cd0518a"
29
+ "gitHead": "03e64dc67ace03c5f8857f92bbd3c8aebedd6d35"
30
30
  }