cds-plugin-ui5 0.9.3 → 0.9.4

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,17 @@
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.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
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **cds-plugin-ui5:** support @sap/cds-dk@8 build priorities ([#1037](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1037)) ([c921a35](https://github.com/ui5-community/ui5-ecosystem-showcase/commit/c921a35f97c0895b603f8b781a946ceaa1234275)), closes [#1033](https://github.com/ui5-community/ui5-ecosystem-showcase/issues/1033)
12
+
13
+
14
+
15
+
16
+
6
17
  ## [0.9.3](https://github.com/ui5-community/ui5-ecosystem-showcase/compare/cds-plugin-ui5@0.9.2...cds-plugin-ui5@0.9.3) (2024-06-04)
7
18
 
8
19
 
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > :wave: This is a **community project** and there is no official support for this package! Feel free to use it, open issues, contribute, and help answering questions.
4
4
 
5
- The `cds-plugin-ui5` is a CDS server `cds-plugin` which enables the integration of UI5 tooling based (UI5 freestyle or Fiori elements) projects into the CDS server via the UI5 tooling express middlewares. The UI5 or Fiori elements projects just need to be located in the `app` folder of the CDS server, or via the `cds.env.folders.app` variable, or be a dependency of the CDS server.
5
+ The `cds-plugin-ui5` is a CDS server `cds-plugin` for the node runtime of the [SAP Cloud Application Programming Model (CAP)](https://cap.cloud.sap/docs/about/) which enables the integration of UI5 tooling based (UI5 freestyle or Fiori elements) projects into the CDS server via the UI5 tooling express middlewares. The UI5 or Fiori elements projects just need to be located in the `app` folder of the CDS server, or via the `cds.env.folders.app` variable, or be a dependency of the CDS server.
6
6
 
7
7
  > :construction: **Note**
8
8
  > This cds-plugin is still work in progress and not final yet!
package/cds-plugin.js CHANGED
@@ -48,6 +48,35 @@ 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 { execSync } = require("child_process");
52
+ const { readFileSync } = require("fs");
53
+
54
+ // function to resolve a module with the given paths without throwing an error
55
+ const resolveModule = function resolveModule(moduleName, paths) {
56
+ try {
57
+ return require.resolve(moduleName, { paths });
58
+ } catch (error) {
59
+ return null;
60
+ }
61
+ };
62
+
63
+ // find out the CDS-DK version to control the behavior of the plugin
64
+ 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" }));
73
+ return packageJson.version;
74
+ }
75
+ };
76
+
77
+ // get the CDS-DK version to control the behavior of the plugin
78
+ const cdsdkVersion = getCDSDKVersion();
79
+
51
80
  // promise to await the bootstrap and lock the
52
81
  // served event to delay the startup a bit
53
82
  let bootstrapped;
@@ -194,11 +223,11 @@ if (!skip) {
194
223
  // check if the register function for build tasks is available at the cds object
195
224
  // and if the Plugin class is available to register the cds build task to cover
196
225
  // the tracks of the cds-plugin-ui5 workspace configuration and dependencies
226
+ const { minVersion, satisfies } = require("semver");
197
227
  if (typeof cds.build?.register === "function" && typeof cds.build?.Plugin?.constructor === "function") {
198
228
  const { readFile, writeFile } = require("fs").promises;
199
229
  const { existsSync } = require("fs");
200
230
  const { join } = require("path");
201
- const { minVersion } = require("semver");
202
231
  const util = require("util");
203
232
  const exec = util.promisify(require("child_process").exec);
204
233
 
@@ -226,10 +255,16 @@ if (!skip) {
226
255
  }
227
256
  init() {}
228
257
  clean() {
229
- this._priority = -1; // hack to ensure that the task is executed last!
258
+ if (!satisfies(cdsdkVersion, ">=8")) {
259
+ this._priority = -1; // hack to ensure that the task is executed last!
260
+ }
230
261
  }
231
262
  get priority() {
232
- return this._priority || 1;
263
+ if (!satisfies(cdsdkVersion, ">=8")) {
264
+ return this._priority || 1;
265
+ } else {
266
+ return -1;
267
+ }
233
268
  }
234
269
  async build() {
235
270
  // determine the namespace from the model
@@ -277,8 +312,10 @@ if (!skip) {
277
312
  }
278
313
  );
279
314
  } else {
280
- // TODO: add error message to inform the user that the cds build task is not available
281
- // and that the @sap/cds-dk version is too old to support the cds build task
282
- //log.info("The cds build task requires @sap/cds-dk version >= 7.6.0! Skipping execution as your @sap/cds-dk version is too old...");
315
+ if (!satisfies(cdsdkVersion, ">=7.5.0")) {
316
+ // TODO: add error message to inform the user that the cds build task is not available
317
+ // and that the @sap/cds-dk version is too old to support the cds build task
318
+ log.warn("The cds build task requires @sap/cds-dk version >= 7.5.0! Skipping execution as your @sap/cds-dk version is too old...");
319
+ }
283
320
  }
284
321
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cds-plugin-ui5",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
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": "0665b24121e9f7584e19246c94cab86987e5f32e"
29
+ "gitHead": "4a689e18ba048dfcb02b9adbd98b82769db22f53"
30
30
  }