@sap-ux/ui5-config
Advanced tools
Comparing version 0.22.0 to 0.22.1
export { UI5Config } from './ui5config'; | ||
export { Configuration, CustomTask, CustomMiddleware, FioriAppReloadConfig, FioriToolsProxyConfig, FioriToolsProxyConfigBackend, FioriToolsProxyConfigUI5, FioriToolsServeStaticPath, FioriToolsServeStaticConfig, Adp, BspApp, AbapTarget, AbapDeployConfig, UI5ProxyConfig, UI5ProxyConfigTarget } from './types'; | ||
export { Configuration, CustomTask, CustomMiddleware, FioriAppReloadConfig, FioriToolsProxyConfig, FioriToolsProxyConfigBackend, FioriToolsProxyConfigUI5, FioriToolsServeStaticPath, FioriToolsServeStaticConfig, ServeStaticPath, Adp, BspApp, AbapTarget, AbapDeployConfig, UI5ProxyConfig, UI5ProxyConfigTarget } from './types'; | ||
export { UI5_DEFAULT } from './defaults'; | ||
@@ -4,0 +4,0 @@ export { mergeObjects, getEsmTypesVersion, getTypesVersion, getTypesPackage } from './utils'; |
@@ -33,2 +33,7 @@ export * from './ui5yaml'; | ||
} | ||
export interface ServeStaticPath { | ||
path: string; | ||
src: string; | ||
fallthrough: boolean; | ||
} | ||
//# sourceMappingURL=index.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import type { BspApp, AbapTarget, Configuration, CustomMiddleware, CustomTask, FioriToolsProxyConfig, FioriToolsProxyConfigBackend, FioriToolsProxyConfigUI5, Ui5Document, Adp, MockserverConfig } from './types'; | ||
import type { BspApp, AbapTarget, Configuration, CustomMiddleware, CustomTask, FioriToolsProxyConfig, FioriToolsProxyConfigBackend, FioriToolsProxyConfigUI5, Ui5Document, Adp, MockserverConfig, ServeStaticPath } from './types'; | ||
import type { NodeComment } from '@sap-ux/yaml'; | ||
@@ -196,2 +196,17 @@ /** | ||
/** | ||
* Returns the serve static config. | ||
* | ||
* @param addFioriToolProxy - if true, `fiori-tools-proxy` config is added, otherwise a `compression` config will be added | ||
* @param paths - serve static paths for the reuse libraries | ||
* @returns the serve static middleware config | ||
*/ | ||
private getServeStaticConfig; | ||
/** | ||
* Adds or updates the serve static middleware in the config. | ||
* | ||
* @param serveStaticPaths serve static paths for the reuse libraries | ||
* @returns {UI5Config} the UI5Config instance | ||
*/ | ||
addServeStaticConfig(serveStaticPaths: ServeStaticPath[]): this; | ||
/** | ||
* Returns a string representation of the config. | ||
@@ -198,0 +213,0 @@ * |
@@ -15,2 +15,3 @@ "use strict"; | ||
const middlewares_1 = require("./middlewares"); | ||
const constants_1 = require("./constants"); | ||
/** | ||
@@ -217,3 +218,3 @@ * Represents a UI5 config file in yaml format (ui5(-*).yaml) with utility functions to manipulate the yaml document. | ||
const middlewareList = this.document.getSequence({ path: 'server.customMiddleware' }); | ||
const proxyMiddleware = this.document.findItem(middlewareList, (item) => item.name === 'fiori-tools-proxy'); | ||
const proxyMiddleware = this.document.findItem(middlewareList, (item) => item.name === constants_1.fioriToolsProxy); | ||
if (!proxyMiddleware) { | ||
@@ -234,3 +235,3 @@ throw new Error('Could not find fiori-tools-proxy'); | ||
const middlewareList = this.document.getSequence({ path: 'server.customMiddleware' }); | ||
const proxyMiddleware = this.document.findItem(middlewareList, (item) => item.name === 'fiori-tools-proxy'); | ||
const proxyMiddleware = this.document.findItem(middlewareList, (item) => item.name === constants_1.fioriToolsProxy); | ||
if (!proxyMiddleware) { | ||
@@ -379,2 +380,52 @@ throw new Error('Could not find fiori-tools-proxy'); | ||
/** | ||
* Returns the serve static config. | ||
* | ||
* @param addFioriToolProxy - if true, `fiori-tools-proxy` config is added, otherwise a `compression` config will be added | ||
* @param paths - serve static paths for the reuse libraries | ||
* @returns the serve static middleware config | ||
*/ | ||
getServeStaticConfig(addFioriToolProxy, paths) { | ||
return addFioriToolProxy | ||
? { | ||
name: constants_1.serveStatic, | ||
beforeMiddleware: constants_1.fioriToolsProxy, | ||
configuration: { | ||
paths: paths | ||
} | ||
} | ||
: { | ||
name: constants_1.serveStatic, | ||
afterMiddleware: 'compression', | ||
configuration: { | ||
paths: paths | ||
} | ||
}; | ||
} | ||
/** | ||
* Adds or updates the serve static middleware in the config. | ||
* | ||
* @param serveStaticPaths serve static paths for the reuse libraries | ||
* @returns {UI5Config} the UI5Config instance | ||
*/ | ||
addServeStaticConfig(serveStaticPaths) { | ||
const serveStaticConfig = this.findCustomMiddleware(constants_1.serveStatic); | ||
const fioriToolsProxyConfig = this.findCustomMiddleware(constants_1.fioriToolsProxy); | ||
if (serveStaticConfig) { | ||
if (serveStaticConfig.afterMiddleware === 'compression' && fioriToolsProxyConfig) { | ||
this.updateCustomMiddleware({ | ||
name: constants_1.serveStatic, | ||
beforeMiddleware: constants_1.fioriToolsProxy, | ||
configuration: { | ||
paths: [...serveStaticConfig.configuration.paths, ...serveStaticPaths] | ||
} | ||
}); | ||
} | ||
} | ||
else { | ||
const serveStaticConfig = this.getServeStaticConfig(!!fioriToolsProxyConfig, serveStaticPaths); | ||
this.addCustomMiddleware([serveStaticConfig]); | ||
} | ||
return this; | ||
} | ||
/** | ||
* Returns a string representation of the config. | ||
@@ -381,0 +432,0 @@ * |
@@ -12,3 +12,3 @@ { | ||
}, | ||
"version": "0.22.0", | ||
"version": "0.22.1", | ||
"license": "Apache-2.0", | ||
@@ -15,0 +15,0 @@ "main": "dist/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
56965
21
1095