@ui5/server 3.1.5 → 3.2.0

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/.reuse/dep5 CHANGED
@@ -25,7 +25,7 @@ Disclaimer: The code in this project may include calls to APIs (“API Calls”)
25
25
  parties the right to use of access any SAP External Product, through API Calls.
26
26
 
27
27
  Files: *
28
- Copyright: 2018-2023 SAP SE or an SAP affiliate company and UI5 Tooling contributors
28
+ Copyright: 2018-2024 SAP SE or an SAP affiliate company and UI5 Tooling contributors
29
29
  License: Apache-2.0
30
30
 
31
31
  Files: lib/middleware/serveIndex/*
@@ -36,5 +36,5 @@ Copyright: 2010 Sencha Inc.
36
36
  License: MIT
37
37
 
38
38
  Files: lib/middleware/testRunner/*
39
- Copyright: 2009-2023 SAP SE or an SAP affiliate company and OpenUI5 contributors
39
+ Copyright: 2009-2024 SAP SE or an SAP affiliate company and OpenUI5 contributors
40
40
  License: Apache-2.0
package/CHANGELOG.md CHANGED
@@ -2,7 +2,13 @@
2
2
  All notable changes to this project will be documented in this file.
3
3
  This project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
4
4
 
5
- A list of unreleased changes can be found [here](https://github.com/SAP/ui5-server/compare/v3.1.5...HEAD).
5
+ A list of unreleased changes can be found [here](https://github.com/SAP/ui5-server/compare/v3.2.0...HEAD).
6
+
7
+ <a name="v3.2.0"></a>
8
+ ## [v3.2.0] - 2024-04-24
9
+ ### Features
10
+ - **serveResources:** Dynamically generate missing library manifest.json [`d31f2c5`](https://github.com/SAP/ui5-server/commit/d31f2c57aa0b0c72fb033c41587ff257312838d1)
11
+
6
12
 
7
13
  <a name="v3.1.5"></a>
8
14
  ## [v3.1.5] - 2023-12-12
@@ -329,6 +335,7 @@ Only Node.js v10 or higher is supported.
329
335
 
330
336
  <a name="v0.0.1"></a>
331
337
  ## v0.0.1 - 2018-06-06
338
+ [v3.2.0]: https://github.com/SAP/ui5-server/compare/v3.1.5...v3.2.0
332
339
  [v3.1.5]: https://github.com/SAP/ui5-server/compare/v3.1.4...v3.1.5
333
340
  [v3.1.4]: https://github.com/SAP/ui5-server/compare/v3.1.3...v3.1.4
334
341
  [v3.1.3]: https://github.com/SAP/ui5-server/compare/v3.1.2...v3.1.3
package/CONTRIBUTING.md CHANGED
@@ -1,3 +1,3 @@
1
1
  # Contributing to the UI5 Tooling
2
2
 
3
- See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md) repository.
3
+ See CONTRIBUTING.md in the [SAP/ui5-tooling](https://github.com/SAP/ui5-tooling/blob/v3/CONTRIBUTING.md) repository.
package/LICENSE.txt CHANGED
@@ -186,7 +186,7 @@
186
186
  same "printed page" as the copyright notice for easier
187
187
  identification within third-party archives.
188
188
 
189
- Copyright 2018-2023 SAP SE or an SAP affiliate company and UI5 Tooling contributors
189
+ Copyright 2018-2024 SAP SE or an SAP affiliate company and UI5 Tooling contributors
190
190
 
191
191
  Licensed under the Apache License, Version 2.0 (the "License");
192
192
  you may not use this file except in compliance with the License.
package/README.md CHANGED
@@ -1,11 +1,11 @@
1
- ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/main/docs/images/UI5_logo_wide.png)
1
+ ![UI5 icon](https://raw.githubusercontent.com/SAP/ui5-tooling/v3/docs/images/UI5_logo_wide.png)
2
2
 
3
3
  # ui5-server
4
4
  > Modules for running a UI5 development server
5
5
  > Part of the [UI5 Tooling](https://github.com/SAP/ui5-tooling)
6
6
 
7
7
  [![REUSE status](https://api.reuse.software/badge/github.com/SAP/ui5-server)](https://api.reuse.software/info/github.com/SAP/ui5-server)
8
- [![Build Status](https://dev.azure.com/sap/opensource/_apis/build/status/SAP.ui5-server?branchName=main)](https://dev.azure.com/sap/opensource/_build/latest?definitionId=34&branchName=main)
8
+ [![Build Status](https://dev.azure.com/sap/opensource/_apis/build/status/SAP.ui5-server?branchName=v3)](https://dev.azure.com/sap/opensource/_build/latest?definitionId=34&branchName=v3)
9
9
  [![npm Package Version](https://badge.fury.io/js/%40ui5%2Fserver.svg)](https://www.npmjs.com/package/@ui5/server)
10
10
  [![Coverage Status](https://coveralls.io/repos/github/SAP/ui5-server/badge.svg)](https://coveralls.io/github/SAP/ui5-server)
11
11
 
@@ -15,10 +15,10 @@ UI5 Server documentation can be found here: [sap.github.io/ui5-tooling](https://
15
15
  The UI5 Server API Reference can be found here: [`@ui5/server`](https://sap.github.io/ui5-tooling/v3/api/module-@ui5_server.html)
16
16
 
17
17
  ## Contributing
18
- Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md).
18
+ Please check our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/v3/CONTRIBUTING.md).
19
19
 
20
20
  ## Support
21
- Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/main/CONTRIBUTING.md#report-an-issue) on how to report an issue.
21
+ Please follow our [Contribution Guidelines](https://github.com/SAP/ui5-tooling/blob/v3/CONTRIBUTING.md#report-an-issue) on how to report an issue.
22
22
 
23
23
  Please report issues in the main [UI5 Tooling](https://github.com/SAP/ui5-tooling) repository.
24
24
 
@@ -220,16 +220,7 @@ class MiddlewareManager {
220
220
  await this.addMiddleware("testRunner");
221
221
  await this.addMiddleware("serveThemes");
222
222
  await this.addMiddleware("versionInfo", {
223
- mountPath: "/resources/sap-ui-version.json",
224
- wrapperCallback: ({middleware: versionInfoModule}) => {
225
- return ({resources, middlewareUtil}) => {
226
- return versionInfoModule({
227
- resources,
228
- middlewareUtil,
229
- graph: this.graph
230
- });
231
- };
232
- }
223
+ mountPath: "/resources/sap-ui-version.json"
233
224
  });
234
225
  // Handle anything but read operations *before* the serveIndex middleware
235
226
  // as it will reject them with a 405 (Method not allowed) instead of 404 like our old tooling
@@ -0,0 +1,18 @@
1
+ import createManifestProcessor from "@ui5/builder/processors/manifestCreator";
2
+
3
+ export default async function generateLibraryManifest(middlewareUtil, dotLibResource) {
4
+ const project = dotLibResource.getProject();
5
+ const libResources = await project.getReader().byGlob(
6
+ `/resources/**/*.{js,json,library,less,css,theming,theme,properties}`);
7
+
8
+ const res = await createManifestProcessor({
9
+ libraryResource: dotLibResource,
10
+ namespace: project.getNamespace(),
11
+ resources: libResources,
12
+ getProjectVersion: (projectName) => {
13
+ return middlewareUtil.getProject(projectName)?.getVersion();
14
+ }
15
+ });
16
+ res.setProject(project);
17
+ return res;
18
+ }
@@ -6,6 +6,8 @@ import fresh from "fresh";
6
6
 
7
7
  const rProperties = /\.properties$/i;
8
8
  const rReplaceVersion = /\.(library|js|json)$/i;
9
+ const rManifest = /\/manifest.json$/i;
10
+ const rResourcesPrefix = /^\/resources\//i;
9
11
 
10
12
  function isFresh(req, res) {
11
13
  return fresh(req.headers, {
@@ -20,18 +22,33 @@ function isFresh(req, res) {
20
22
  * @module @ui5/server/middleware/serveResources
21
23
  * @param {object} parameters Parameters
22
24
  * @param {@ui5/server/internal/MiddlewareManager.middlewareResources} parameters.resources Parameters
23
- * @param {object} parameters.middlewareUtil Specification version dependent interface to a
24
- * [MiddlewareUtil]{@link @ui5/server/middleware/MiddlewareUtil} instance
25
+ * @param {object} parameters.middlewareUtil [MiddlewareUtil]{@link @ui5/server/middleware/MiddlewareUtil} instance
25
26
  * @returns {Function} Returns a server middleware closure.
26
27
  */
27
28
  function createMiddleware({resources, middlewareUtil}) {
28
29
  return async function serveResources(req, res, next) {
29
30
  try {
30
31
  const pathname = middlewareUtil.getPathname(req);
31
- const resource = await resources.all.byPath(pathname);
32
+ let resource = await resources.all.byPath(pathname);
32
33
  if (!resource) { // Not found
33
- next();
34
- return;
34
+ if (!rManifest.test(pathname) || !rResourcesPrefix.test(pathname)) {
35
+ next();
36
+ return;
37
+ }
38
+ log.verbose(`Could not find manifest.json for ${pathname}. ` +
39
+ `Checking for .library file to generate manifest.json from.`);
40
+ const {default: generateLibraryManifest} = await import("./helper/generateLibraryManifest.js");
41
+ // Attempt to find a .library file, which is required for generating a manifest.json
42
+ const dotLibraryPath = pathname.replace(rManifest, "/.library");
43
+ const dotLibraryResource = await resources.all.byPath(dotLibraryPath);
44
+ if (!dotLibraryResource) {
45
+ log.verbose(
46
+ `Could not find a .library to generate manifest.json from at ${dotLibraryPath}. ` +
47
+ `This might indicate that the project is not a library project.`);
48
+ next();
49
+ return;
50
+ }
51
+ resource = await generateLibraryManifest(middlewareUtil, dotLibraryResource);
35
52
  }
36
53
 
37
54
  const resourcePath = resource.getPath();
@@ -64,7 +81,13 @@ function createMiddleware({resources, middlewareUtil}) {
64
81
  }
65
82
 
66
83
  // Enable ETag caching
67
- res.setHeader("ETag", etag(resource.getStatInfo()));
84
+ const statInfo = resource.getStatInfo();
85
+ if (statInfo?.size !== undefined) {
86
+ res.setHeader("ETag", etag(statInfo));
87
+ } else {
88
+ // Fallback to buffer if stats are not available or insufficient
89
+ res.setHeader("ETag", etag(await resource.getBuffer()));
90
+ }
68
91
 
69
92
  if (isFresh(req, res)) {
70
93
  // client has a fresh copy of the resource
@@ -1,5 +1,5 @@
1
1
  import createVersionInfoProcessor from "@ui5/builder/processors/versionInfoGenerator";
2
- import createManifestProcessor from "@ui5/builder/processors/manifestCreator";
2
+ import generateLibraryManifest from "./helper/generateLibraryManifest.js";
3
3
 
4
4
  const MANIFEST_JSON = "manifest.json";
5
5
 
@@ -9,10 +9,10 @@ const MANIFEST_JSON = "manifest.json";
9
9
  * @module @ui5/server/middleware/versionInfo
10
10
  * @param {object} parameters Parameters
11
11
  * @param {@ui5/server/internal/MiddlewareManager.middlewareResources} parameters.resources Parameters
12
- * @param {@ui5/project/graph/ProjectGraph} parameters.graph Project graph
12
+ * @param {object} parameters.middlewareUtil [MiddlewareUtil]{@link @ui5/server/middleware/MiddlewareUtil} instance
13
13
  * @returns {Function} Returns a server middleware closure.
14
14
  */
15
- function createMiddleware({resources, graph}) {
15
+ function createMiddleware({resources, middlewareUtil}) {
16
16
  return async function versionInfo(req, res, next) {
17
17
  try {
18
18
  const dependencies = resources.dependencies;
@@ -31,20 +31,7 @@ function createMiddleware({resources, graph}) {
31
31
  const embeddedManifests =
32
32
  manifestResources.filter((manifestResource) => manifestResource !== libraryManifest);
33
33
  if (!libraryManifest) {
34
- const extensions = "js,json,library,less,css,theming,theme,properties";
35
- const libResources = await dependencies.byGlob(`/resources/${namespace}/**/*.{${extensions}}`);
36
-
37
- libraryManifest = await createManifestProcessor({
38
- libraryResource: dotLibResource,
39
- namespace,
40
- resources: libResources,
41
- options: {
42
- omitMinVersions: true
43
- },
44
- getProjectVersion: (projectName) => {
45
- return graph.getProject(projectName)?.getVersion();
46
- }
47
- });
34
+ libraryManifest = await generateLibraryManifest(middlewareUtil, dotLibResource);
48
35
  }
49
36
  return {
50
37
  libraryManifest,
@@ -53,7 +40,7 @@ function createMiddleware({resources, graph}) {
53
40
  version: dotLibResource.getProject().getVersion()
54
41
  };
55
42
  });
56
- const rootProject = graph.getRoot();
43
+ const rootProject = middlewareUtil.getProject();
57
44
  const libraryInfos = await Promise.all(libraryInfosPromises);
58
45
  const [versionInfoResource] = await createVersionInfoProcessor({
59
46
  options: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ui5/server",
3
- "version": "3.1.5",
3
+ "version": "3.2.0",
4
4
  "description": "UI5 Tooling - Server",
5
5
  "author": {
6
6
  "name": "SAP SE",
@@ -115,7 +115,7 @@
115
115
  "url": "git@github.com:SAP/ui5-server.git"
116
116
  },
117
117
  "dependencies": {
118
- "@ui5/builder": "^3.2.0",
118
+ "@ui5/builder": "^3.4.0",
119
119
  "@ui5/fs": "^3.0.5",
120
120
  "@ui5/logger": "^3.0.0",
121
121
  "body-parser": "^1.20.2",
@@ -124,7 +124,7 @@
124
124
  "devcert-sanscache": "^0.4.8",
125
125
  "escape-html": "^1.0.3",
126
126
  "etag": "^1.8.1",
127
- "express": "^4.18.2",
127
+ "express": "^4.19.2",
128
128
  "fresh": "^0.5.2",
129
129
  "graceful-fs": "^4.2.11",
130
130
  "mime-types": "^2.1.35",
@@ -137,23 +137,23 @@
137
137
  },
138
138
  "devDependencies": {
139
139
  "@istanbuljs/esm-loader-hook": "^0.2.0",
140
- "@ui5/project": "^3.8.0",
140
+ "@ui5/project": "^3.9.1",
141
141
  "ava": "^5.3.1",
142
142
  "chokidar-cli": "^3.0.0",
143
143
  "cross-env": "^7.0.3",
144
144
  "depcheck": "^1.4.7",
145
145
  "docdash": "^2.0.2",
146
- "eslint": "^8.55.0",
146
+ "eslint": "^8.57.0",
147
147
  "eslint-config-google": "^0.14.0",
148
148
  "eslint-plugin-ava": "^14.0.0",
149
- "eslint-plugin-jsdoc": "^46.9.0",
150
- "esmock": "^2.6.0",
149
+ "eslint-plugin-jsdoc": "^46.10.1",
150
+ "esmock": "^2.6.4",
151
151
  "jsdoc": "^4.0.2",
152
152
  "nyc": "^15.1.0",
153
153
  "open-cli": "^7.2.0",
154
154
  "rimraf": "^5.0.5",
155
155
  "sinon": "^16.1.3",
156
- "supertest": "^6.3.3",
156
+ "supertest": "^6.3.4",
157
157
  "tap-xunit": "^2.4.1"
158
158
  }
159
159
  }