@ui5/task-adaptation
Version:
Custom task for ui5-builder which allows building UI5 Flexibility Adaptation Projects for SAP BTP, Cloud Foundry environment
37 lines • 1.8 kB
JavaScript
import { createAbapServiceProvider } from "@sap-ux/system-access";
import BtpUtils from "@sap-ux/btp-utils";
import { getLogger } from "@ui5/logger";
import { validateObject } from "../util/commonUtil.js";
const log = getLogger("@ui5/task-adaptation::AbapProvider");
log.debug = (message) => log.verbose(message);
export default class AbapProvider {
provider = null;
async get({ target, destination }) {
if (!this.provider) {
const abapTarget = AbapProvider.validateAndGetAbapTarget(target, destination);
if (abapTarget) {
this.provider = await createAbapServiceProvider(abapTarget, { ignoreCertErrors: abapTarget.ignoreCertErrors }, true, log);
}
}
if (!this.provider) {
throw new Error("Target should be specified in ui5.yaml configuration to connect the ABAP system");
}
return this.provider;
}
static validateAndGetAbapTarget(target, destination) {
if (target) {
// if target configuration appears, we validate that it should be
// either target/destination for BAS or target/url for IDE we're
// trying to detect is it destination for BAS or url for IDE
const abapTargetProperties = BtpUtils.isAppStudio() ? ["destination"] : ["url"];
validateObject(target, abapTargetProperties, "should be specified in ui5.yaml configuration/target");
return target;
}
else if (destination) {
log.warn("Destination is deprecated, use target/destination configuration instead");
return { destination };
}
throw new Error("Target should be specified in ui5.yaml configuration to connect the ABAP system");
}
}
//# sourceMappingURL=abapProvider.js.map