@ui5/task-adaptation
Version:
Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment
61 lines • 2.71 kB
JavaScript
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
import HTML5RepoManager from "../repositories/html5RepoManager.js";
import { cached } from "../cache/cacheHolder.js";
import { validateObject } from "../util/commonUtil.js";
export default class CFProcessor {
configuration;
constructor(configuration) {
this.configuration = configuration;
}
async getAppVariantIdHierarchy(appId) {
const metadata = await HTML5RepoManager.getMetadata(this.configuration);
return [{
repoName: this.configuration.appName,
appVariantId: appId,
cachebusterToken: metadata.changedOn
}];
}
fetch(_repoName, _cachebusterToken) {
return HTML5RepoManager.getBaseAppFiles(this.configuration);
}
validateConfiguration() {
validateObject(this.configuration, ["appHostId", "appName", "appVersion"], "should be specified in ui5.yaml configuration");
}
async updateLandscapeSpecificContent(renamedBaseAppManifest) {
this.updateCloudPlatform(renamedBaseAppManifest);
}
updateCloudPlatform(renamedBaseAppManifest) {
const sapCloudService = renamedBaseAppManifest["sap.cloud"]?.service;
const sapPlatformCf = renamedBaseAppManifest["sap.platform.cf"];
if (sapPlatformCf?.oAuthScopes && sapCloudService) {
sapPlatformCf.oAuthScopes = sapPlatformCf.oAuthScopes.map((scope) => scope.replace(`$XSAPPNAME.`, `$XSAPPNAME('${sapCloudService}').`));
}
if (this.configuration.sapCloudService) {
if (renamedBaseAppManifest["sap.cloud"] == null) {
renamedBaseAppManifest["sap.cloud"] = {};
}
renamedBaseAppManifest["sap.cloud"].service = this.configuration.sapCloudService;
}
else {
delete renamedBaseAppManifest["sap.cloud"];
}
}
getConfigurationType() {
return "cf";
}
createAppVariantHierarchyItem(appVariantId, version) {
return {
appVariantId,
version
};
}
}
__decorate([
cached()
], CFProcessor.prototype, "fetch", null);
//# sourceMappingURL=cfProcessor.js.map