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.

242 lines 12.5 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 }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.getDeploySummaryPrompts = exports.getDeployConfigurationPrompts = void 0; const adp_common_1 = require("@sap/adp-common"); const types_1 = require("../../types"); const validator_1 = require("../validator"); const adp_abap_1 = require("@sap/adp-abap"); const choices_1 = require("../choices"); const conditions_1 = require("../conditions"); const transport_list_1 = __importDefault(require("../../utils/transport-list")); const path_1 = require("path"); function getDeployConfigurationPrompts(config) { var _a, _b, _c, _d, _e, _f, _g, _h; return __awaiter(this, void 0, void 0, function* () { let morePackageResultsMsg = ""; const abapService = config.abapService; yield abapService.connectToSystem(config.abapServiceConfig.system, config.abapServiceConfig.client, config.abapServiceConfig.username, config.abapServiceConfig.password); let packageInputChoiceValid = false; return [ { type: types_1.PromptType.INPUT, name: "sapui5ABAPRepository", message: adp_common_1.Messages.SAPUI5_ABAP_REPOSITORY_LABEL, default: (_b = (_a = config.deployApp) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : "", guiOptions: { hint: adp_common_1.Messages.SAPUI5_ABAP_REPOSITORY_TOOLTIP, mandatory: true, breadcrumb: adp_common_1.Messages.SAPUI5_ABAP_REPOSITORY_LABEL }, validate: (value) => (0, validator_1.validateSAPUI5Repository)(value) }, { type: types_1.PromptType.INPUT, name: "deployConfigDescription", default: (_d = (_c = config.deployApp) === null || _c === void 0 ? void 0 : _c.description) !== null && _d !== void 0 ? _d : "", message: adp_common_1.Messages.DEPLOY_CONFIG_DESCRIPTION_LABEL, guiOptions: { hint: adp_common_1.Messages.DEPLOYMENT_DESCRIPTION_TOOLTIP, breadcrumb: adp_common_1.Messages.DEPLOY_CONFIG_DESCRIPTION_LABEL } }, { type: types_1.PromptType.LIST, name: "packageInputChoice", message: adp_common_1.Messages.PACKAGE_INPUT_CHOICE, choices: (0, choices_1.getInputChoiceChoices)(), default: (answers) => { var _a; return (_a = answers.packageInputChoice) !== null && _a !== void 0 ? _a : adp_common_1.InputChoice.ENTER_MANUALLY; }, guiOptions: { applyDefaultWhenDirty: true }, validate: (value) => __awaiter(this, void 0, void 0, function* () { packageInputChoiceValid = yield (0, validator_1.validatePackageChoiceInput)(value, abapService); return packageInputChoiceValid; }) }, { type: types_1.PromptType.INPUT, name: "packageManual", message: adp_common_1.Messages.DEPLOY_CONFIG_PACKAGE_LABEL, default: (_f = (_e = config.deployApp) === null || _e === void 0 ? void 0 : _e.package) !== null && _f !== void 0 ? _f : "", guiOptions: { hint: adp_common_1.Messages.DEPLOYMENT_PACKAGE_TOOLTIP, mandatory: true, breadcrumb: adp_common_1.Messages.DEPLOY_CONFIG_PACKAGE_LABEL }, when: (answers) => { return ((answers === null || answers === void 0 ? void 0 : answers.packageInputChoice) === adp_common_1.InputChoice.ENTER_MANUALLY || (answers.packageInputChoice === adp_common_1.InputChoice.CHOOSE_FROM_EXISTING && typeof packageInputChoiceValid === "string")); }, validate: (value, answers) => __awaiter(this, void 0, void 0, function* () { return yield (0, validator_1.validatePackageExtended)(value, abapService, answers); }) }, { type: types_1.PromptType.AUTOCOMPLETE, name: "packageAutoComplete", message: adp_common_1.Messages.DEPLOY_CONFIG_PACKAGE_LABEL, guiOptions: { mandatory: true, hint: adp_common_1.Messages.DEPLOYMENT_PACKAGE_TOOLTIP, breadcrumb: adp_common_1.Messages.DEPLOY_CONFIG_PACKAGE_LABEL }, source: (answers, input) => __awaiter(this, void 0, void 0, function* () { var _j; let packages = []; try { packages = yield abapService.listPackages(input); morePackageResultsMsg = packages && packages.length === adp_abap_1.ABAP_PACKAGE_SEARCH_MAX_RESULTS ? adp_common_1.Messages.INFO_MESSAGE_MORE_SEARCH_RESULTS(packages.length) : ""; return packages; } catch (error) { (_j = adp_common_1.Logger.getLogger) === null || _j === void 0 ? void 0 : _j.error(`Could not get packages. Error: ${error.message}`); } return packages; }), additionalInfo: () => morePackageResultsMsg, when: (answers) => { return packageInputChoiceValid === true && (answers === null || answers === void 0 ? void 0 : answers.packageInputChoice) === adp_common_1.InputChoice.CHOOSE_FROM_EXISTING; }, validate: (value, answers) => __awaiter(this, void 0, void 0, function* () { return yield (0, validator_1.validatePackageExtended)(value, abapService, answers); }) }, { type: types_1.PromptType.LIST, name: "transportInputChoice", message: adp_common_1.Messages.TRANSPORT_INPUT_CHOICE, choices: (0, choices_1.getInputChoiceChoices)(), default: (answers) => { var _a; return (_a = answers.transportInputChoice) !== null && _a !== void 0 ? _a : adp_common_1.InputChoice.ENTER_MANUALLY; }, guiOptions: { applyDefaultWhenDirty: true }, validate: (value, answers) => __awaiter(this, void 0, void 0, function* () { return yield (0, validator_1.validateTransportChoiceInput)(value, answers.packageInputChoice === adp_common_1.InputChoice.ENTER_MANUALLY ? answers.packageManual : answers.packageAutoComplete, answers.sapui5ABAPRepository, abapService); }), when: (answers) => (0, conditions_1.shouldShowTransport)(answers) }, { type: types_1.PromptType.LIST, name: "transportFromList", message: adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL, choices: () => transport_list_1.default.transports, validate: (value) => (0, validator_1.validateEmptyInput)(value, adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL), when: (answers) => (0, conditions_1.shouldShowTransportList)(answers), guiOptions: { hint: adp_common_1.Messages.DEPLOYMENT_TRANSPORT_TOOLTIP, mandatory: true, breadcrumb: adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL } }, { type: types_1.PromptType.INPUT, name: "transportManual", message: adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL, default: (_h = (_g = config.deployApp) === null || _g === void 0 ? void 0 : _g.transport) !== null && _h !== void 0 ? _h : "", validate: (value) => (0, validator_1.validateEmptyInput)(value, adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL), when: (answers) => (0, conditions_1.shouldShowTransportManual)(answers), guiOptions: { hint: adp_common_1.Messages.DEPLOYMENT_TRANSPORT_TOOLTIP, mandatory: true, breadcrumb: adp_common_1.Messages.DEPLOY_CONFIG_TRANSPORT_REQUEST_LABEL } } ]; }); } exports.getDeployConfigurationPrompts = getDeployConfigurationPrompts; function getDeploySummaryPrompts(projectPath) { var _a, _b, _c; try { const configuration = adp_common_1.Workspace.getCloudConfigs((0, path_1.join)(projectPath, "ui5-deploy.yaml")).configuration; return [ { type: "input", name: "cloudDescription", message: `Deployment Description: ${((_a = configuration === null || configuration === void 0 ? void 0 : configuration.app) === null || _a === void 0 ? void 0 : _a.description) || "N/A"}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudDestination", message: `System: ${(_b = configuration === null || configuration === void 0 ? void 0 : configuration.target) === null || _b === void 0 ? void 0 : _b.destination}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudUrl", message: `System URL: ${configuration.target.url}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudClient", message: `System Client: ${configuration.target.client || "N/A"}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudAbapRepository", message: `Repository: ${configuration.app.name}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudPackage", message: `Package: ${configuration.app.package}`, guiOptions: { type: "label" } }, { type: "input", name: "cloudTransport", message: `Transport: ${configuration.app.transport || "N/A"}`, guiOptions: { type: "label" } }, { type: "list", choices: (0, choices_1.getDeployActionsChoices)(), name: "action", message: "Select action" } ]; } catch (e) { (_c = adp_common_1.Logger.getLogger) === null || _c === void 0 ? void 0 : _c.error(`Error occured while trying to get deploy summary prompts: ${e.message}`); return [ { type: "input", name: "error", message: "There is an issue with your ui5-deploy.yaml file", guiOptions: { type: "label" }, validate: false } ]; } } exports.getDeploySummaryPrompts = getDeploySummaryPrompts; //# sourceMappingURL=deploy-config.js.map