UNPKG

@sap/generator-adaptation-project

Version:

Adaptation project allows you to create an app variant for an existing SAP Fiori elements-based or SAPUI5 freestyle application, without changing the original application.

60 lines 3.08 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; const adp_tooling_1 = require("@sap-ux/adp-tooling"); const adp_common_1 = require("@sap/adp-common"); const SubGeneratorWithAuthBase_1 = __importDefault(require("../common/generator/SubGeneratorWithAuthBase")); class OdataServiceGenerator extends SubGeneratorWithAuthBase_1.default { constructor(args, opts) { super(args, opts, adp_common_1.GeneratorTypes.CHANGE_DATA_SOURCE); } initializing() { return __awaiter(this, void 0, void 0, function* () { yield this.onInit(); }); } prompting() { var _a; return __awaiter(this, void 0, void 0, function* () { try { // TODO: getManifest() should return a manifest object and not use this.manifest yield this.getManifest(); this.answers = yield this.prompt((0, adp_tooling_1.getPromptsForChangeDataSource)((_a = this.manifest["sap.app"].dataSources) !== null && _a !== void 0 ? _a : {})); this.logger.log(adp_common_1.Messages.ODATA_TARGET_SOURCES(JSON.stringify(this.manifest["sap.app"].dataSources, null, 2))); this.logger.log(adp_common_1.Messages.CURRENT_ODATA_SERVICES(JSON.stringify(this.answers, null, 2))); } catch (error) { yield this.handleRuntimeCrash(error.message, this.isCFEnv); } }); } writing() { return __awaiter(this, void 0, void 0, function* () { // TODO: the appdescr file has already been read in the constructor, it should be refactored to be read only once const variant = adp_common_1.Workspace.getManifestAppdescrFile(this.projectPath); yield (0, adp_tooling_1.generateChange)(this.projectPath, "appdescr_app_changeDataSource" /* ChangeType.CHANGE_DATA_SOURCE */, { variant, dataSources: this.manifest["sap.app"].dataSources, service: this.answers }, // @ts-ignore this.fs); this.logger.log("Change written to changes folder"); }); } end() { this.logger.log("Successfully created OData Change!"); } } module.exports = OdataServiceGenerator; //# sourceMappingURL=index.js.map