@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 16.3 kB
JavaScript
"use strict";exports.id=134,exports.ids=[134],exports.modules={57829:(e,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.defaultMtaVersion=i.prompts=i.generatorTitle=void 0,i.generatorTitle="Application Router Generator",i.prompts=[{name:"Application Router Configuration",description:"Configure the Cloud Foundry application router"}],i.defaultMtaVersion="0.0.1"},37648:(e,i,a)=>{Object.defineProperty(i,"__esModule",{value:!0});const n=a(16928),s=a(44425),o=a(70857),r=a(13651),p=a(4591),c=a(45048),d=a(13149),l=a(95644),h=a(57829);class default_1 extends p.DeploymentGenerator{appWizard;prompts;answers;abort=!1;setPromptsCallback;constructor(e,i){super(e,i),this.appWizard=i.appWizard??r.AppWizard.create(i),this.options=i,this.appWizard.setHeaderTitle(h.generatorTitle),this.prompts=new r.Prompts(h.prompts),this.setPromptsCallback=e=>{this.prompts&&this.prompts.setCallback(e)}}async initializing(){await super.initializing(),await(0,l.initI18n)(),this._initFromProjectConfig()}_initFromProjectConfig(){s.sync(p.mtaExecutable)||((0,p.handleErrorMessage)(this.appWizard,{errorType:p.ERROR_TYPE.NO_MTA_BIN}),this.abort=!0)}async prompting(){if(this.abort)return;const e={[c.appRouterPromptNames.mtaPath]:this.destinationRoot()??process.cwd(),[c.appRouterPromptNames.mtaId]:!0,[c.appRouterPromptNames.mtaDescription]:!0,[c.appRouterPromptNames.mtaVersion]:!1,[c.appRouterPromptNames.routerType]:!0,[c.appRouterPromptNames.addConnectivityService]:!0,[c.appRouterPromptNames.addABAPServiceBinding]:!0},i=await(0,c.getAppRouterPrompts)(e);this.answers=await this.prompt(i)}async writing(){if(this.abort)return;let e;this.destinationRoot((0,n.join)(this.answers.mtaPath,this.answers.mtaId)),p.DeploymentGenerator.logger?.debug((0,l.t)("appRouterGen.debug.projectPath",{destinationPath:this.destinationRoot()})),this.answers.addABAPServiceBinding&&(e={abapServiceName:this.answers.abapServiceProvider?.label,abapService:this.answers.abapServiceProvider?.service});const i={routerType:this.answers.routerType,addConnectivityService:this.answers.addConnectivityService??!1,abapServiceProvider:e,mtaId:this.answers.mtaId,mtaPath:this.destinationRoot(),mtaDescription:this.answers.mtaDescription,mtaVersion:h.defaultMtaVersion};await(0,d.generateBaseConfig)(i,this.fs,p.DeploymentGenerator.logger)}install(){this._install()}_install(){if(!this.abort&&!this.options.skipInstall){const e="win32"===(0,o.platform)()?"npm.cmd":"npm";this.spawnCommand(e,["install","--no-audit","--no-fund","--silent","--prefer-offline","--no-progress"],{cwd:this.destinationRoot()})}}}i.default=default_1},12754:(e,i,a)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DESTINATION_AUTHTYPE_NOTFOUND=i.API_BUSINESS_HUB_ENTERPRISE_PREFIX=i.loadManifest=i.getCFQuestions=void 0;const n=a(16928),s=a(70857),o=a(44425),r=a(13651),p=a(58012),c=a(98434),d=a(75199),l=a(13149),h=a(4591),u=a(95644);Object.defineProperty(i,"DESTINATION_AUTHTYPE_NOTFOUND",{enumerable:!0,get:function(){return u.DESTINATION_AUTHTYPE_NOTFOUND}}),Object.defineProperty(i,"API_BUSINESS_HUB_ENTERPRISE_PREFIX",{enumerable:!0,get:function(){return u.API_BUSINESS_HUB_ENTERPRISE_PREFIX}});const m=a(55379);Object.defineProperty(i,"loadManifest",{enumerable:!0,get:function(){return m.loadManifest}});const g=a(20787),f=a(60711),_=a(10483);Object.defineProperty(i,"getCFQuestions",{enumerable:!0,get:function(){return _.getCFQuestions}});class default_1 extends h.DeploymentGenerator{appWizard;vscode;launchDeployConfigAsSubGenerator;launchStandaloneFromYui;appPath;addMtaDestination;apiHubConfig;cloudServiceName;serviceBase;answers={};appRouterAnswers;projectRoot;mtaPath;isCap=!1;isAbapDirectServiceBinding=!1;lcapModeOnly=!1;servicePath;destinationName;abort=!1;deployConfigExists=!1;packageName;constructor(e,i){super(e,i),this.launchDeployConfigAsSubGenerator=i.launchDeployConfigAsSubGenerator??!1,this.launchStandaloneFromYui=i.launchStandaloneFromYui,this.appWizard=i.appWizard??r.AppWizard.create(i),this.vscode=i.vscode,this.options=i,this.destinationName=i.destinationName??"",this.addMtaDestination=i.addMTADestination??!1,this.lcapModeOnly=i.lcapModeOnly??!1,this.cloudServiceName=i.cloudServiceName||void 0,this.apiHubConfig=i.apiHubConfig,this.servicePath=i.appGenServicePath,this.serviceBase=i.appGenServiceHost,this.appPath=i.appRootPath??this.destinationRoot(),this.projectRoot=i.projectRoot??this.destinationRoot()}async initializing(){await super.initializing(),await(0,u.initI18n)(),this.env.conflicter&&(this.env.conflicter.force=this.options.force??!0),h.DeploymentGenerator.logger?.debug((0,u.t)("cfGen.debug.initTelemetry")),await p.TelemetryHelper.initTelemetrySettings({consumerModule:{name:"@sap-ux/cf-deploy-config-sub-generator",version:this.rootGeneratorVersion()},internalFeature:(0,c.isInternalFeaturesSettingEnabled)(),watchTelemetrySettingStore:!1}),this.launchDeployConfigAsSubGenerator||await this._init()}async _init(){o.sync(h.mtaExecutable)||(this.abort=!0,(0,h.handleErrorMessage)(this.appWizard,{errorType:h.ERROR_TYPE.NO_MTA_BIN})),await this._processProjectPaths(),await this._processProjectConfigs(),this.isAbapDirectServiceBinding=await(0,l.useAbapDirectServiceBinding)(this.appPath,!1,this.mtaPath),this.isCap||(this.lcapModeOnly=!1)}async _processProjectPaths(){const e=await(0,g.getMtaPath)(this.appPath);this.mtaPath=e?.mtaPath;const i=await(0,g.findCapProjectRoot)(this.appPath,!0,this.fs);if(i){o.sync(h.cdsExecutable)||(0,h.bail)(h.ErrorHandler.getErrorMsgFromType(h.ERROR_TYPE.NO_CDS_BIN)),this.isCap=!0,this.projectRoot=i;try{this.packageName=this.fs.readJSON((0,n.join)(this.projectRoot,g.FileName.Package))?.name??""}catch{}}else this.mtaPath&&(this.projectRoot=(0,n.dirname)(this.mtaPath))}async _processProjectConfigs(){const e=this.options.base??g.FileName.Ui5Yaml;this.fs.exists((0,n.join)(this.appPath,e))||(0,h.bail)(h.ErrorHandler.noBaseConfig(e)),this.deployConfigExists=this.fs.exists((0,n.join)(this.appPath,this.options.config??g.FileName.Ui5Yaml))}async prompting(){this.abort||(this.launchDeployConfigAsSubGenerator||await this._prompting(),await this._reconcileAnswersWithOptions())}async _prompting(){if(this.isCap&&this.projectRoot&&!this.mtaPath){if(h.DeploymentGenerator.logger?.debug((0,u.t)("cfGen.debug.capMissingMTA")),this.appRouterAnswers=await this.prompt(await(0,_.getCAPMTAQuestions)({projectRoot:this.projectRoot??process.cwd()})),!0!==this.appRouterAnswers.addCapMtaContinue)return void(this.abort=!0);this.appRouterAnswers.mtaId=this.packageName,this.destinationName=l.DefaultMTADestination,this.options.overwrite=!0,this.answers={},this.answers.destinationName=this.destinationName,this.answers.addManagedAppRouter=!1}else{await this._handleApiHubConfig();const e=await this._getCFQuestions();this.answers=await this.prompt(e)}}async _handleApiHubConfig(){if(this.apiHubConfig&&"API_HUB_ENTERPRISE"===this.apiHubConfig.apiHubType){if(!this.servicePath){const e=await(0,m.loadManifest)(this.fs,this.appPath);this.servicePath=e?.["sap.app"]?.dataSources?.mainService?.uri}this.destinationName=(0,h.generateDestinationName)(u.API_BUSINESS_HUB_ENTERPRISE_PREFIX,this.servicePath)}}async _getCFQuestions(){return(0,_.getCFQuestions)({projectRoot:this.projectRoot,isAbapDirectServiceBinding:this.isAbapDirectServiceBinding,cfDestination:this.destinationName,isCap:this.isCap,addOverwrite:(0,h.showOverwriteQuestion)(this.deployConfigExists,this.launchDeployConfigAsSubGenerator,this.launchStandaloneFromYui,this.options.overwrite),apiHubConfig:this.apiHubConfig})}async _reconcileAnswersWithOptions(){const e=this.destinationName||this.answers.destinationName,i=await(0,h.getDestination)(e),a=this.options.addManagedAppRouter??this.answers.addManagedAppRouter??!1,n=this.options.isFullUrlDest??(i&&(0,d.isFullUrlDestination)(i))??!1,s=this.options.destinationAuthType??i?.Authentication??u.DESTINATION_AUTHTYPE_NOTFOUND,o=this.options.overwrite??this.answers.overwrite;this.answers={destinationName:e,addManagedAppRouter:a,isDestinationFullUrl:n,destinationAuthentication:s,overwrite:o}}async writing(){this.abort||!1===this.options.overwrite||(this.launchDeployConfigAsSubGenerator?(await this._init(),await this._writing()):await this._writing())}async _writing(){try{this.appRouterAnswers&&await(0,l.generateCAPConfig)(this.appRouterAnswers,this.fs,h.DeploymentGenerator.logger),await(0,l.generateAppConfig)(this._getAppConfig(),this.fs,h.DeploymentGenerator.logger)}catch(e){this.abort=!0,(0,h.handleErrorMessage)(this.appWizard,{errorMsg:(0,u.t)("cfGen.error.writing",{error:e})})}}_getAppConfig(){return{appPath:this.appPath,addManagedAppRouter:this.answers.addManagedAppRouter,destinationName:this.answers.destinationName,destinationAuthentication:this.answers.destinationAuthentication,isDestinationFullUrl:this.answers.isDestinationFullUrl,apiHubConfig:this.apiHubConfig,serviceHost:this.serviceBase,lcapMode:this.lcapModeOnly,addMtaDestination:this.addMtaDestination,cloudServiceName:this.cloudServiceName}}async install(){!1===this.options.overwrite||this.abort||await this._install()}async _install(){if(this.options.skipInstall)h.DeploymentGenerator.logger?.info((0,u.t)("cfGen.info.skippedInstallation"));else try{await this._runNpmInstall(this.projectRoot),this.projectRoot!==this.appPath&&await this._runNpmInstall(this.appPath)}catch(e){(0,h.handleErrorMessage)(this.appWizard,{errorMsg:(0,u.t)("cfGen.error.install",{error:e})})}}async _runNpmInstall(e){const i="win32"===(0,s.platform)()?"npm.cmd":"npm";await this.spawnCommand(i,["install","--no-audit","--no-fund","--silent","--prefer-offline","--no-progress"],{cwd:e})}async end(){try{this.options.launchStandaloneFromYui&&(0,p.isExtensionInstalled)(this.vscode,p.YUI_EXTENSION_ID,p.YUI_MIN_VER_FILES_GENERATED_MSG)&&this.appWizard?.showInformation((0,u.t)("cfGen.info.filesGenerated"),r.MessageType.notification),await this._sendTelemetry()}catch(e){h.DeploymentGenerator.logger?.error((0,u.t)("cfGen.error.end",{error:e}))}}async _sendTelemetry(){const e=p.TelemetryHelper.createTelemetryData({DeployTarget:"CF",ManagedApprouter:this.answers.addManagedAppRouter,MTA:this.mtaPath?"true":"false",...this.options.telemetryData})??{};await(0,p.sendTelemetry)(f.EventName.DEPLOY_CONFIG,e,this.appPath)}}i.default=default_1},10483:(e,i,a)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getCAPMTAQuestions=i.getCFQuestions=void 0;const n=a(75199),s=a(4591),o=a(20787),r=a(45048),p=a(58012),c=a(55379),d=a(95644),l=a(12450);i.getCFQuestions=async function getCFQuestions({projectRoot:e,isAbapDirectServiceBinding:i,cfDestination:a,isCap:l,addOverwrite:h,apiHubConfig:u}){const m=(0,n.isAppStudio)(),g=!!await(0,o.getMtaPath)(e),f=await(0,c.getCFChoices)({projectRoot:e,isCap:l,cfDestination:a,isAbapDirectServiceBinding:i,apiHubConfigType:u?.apiHubType}),_={[r.promptNames.destinationName]:{defaultValue:(0,c.destinationQuestionDefaultOption)(i,m,a),hint:!!i,useAutocomplete:(0,p.getHostEnvironment)()===p.hostEnvironment.cli,addBTPDestinationList:!!m&&!i,additionalChoiceList:f},[r.promptNames.addManagedAppRouter]:!g&&!l,[r.promptNames.overwrite]:h};return s.DeploymentGenerator.logger?.debug((0,d.t)("cfGen.debug.promptOptions",{options:JSON.stringify(_)})),(0,r.getPrompts)(_)},i.getCAPMTAQuestions=async function getCAPMTAQuestions({projectRoot:e}){let i=await async function getCFApprouterQuestionsForCap({projectRoot:e}){const i={[r.appRouterPromptNames.mtaPath]:e,[r.appRouterPromptNames.mtaId]:!1,[r.appRouterPromptNames.mtaDescription]:!1,[r.appRouterPromptNames.mtaVersion]:!1,[r.appRouterPromptNames.routerType]:!0,[r.appRouterPromptNames.addConnectivityService]:!0,[r.appRouterPromptNames.addABAPServiceBinding]:!1};return(0,r.getAppRouterPrompts)(i)}({projectRoot:e});return i=(0,l.withCondition)(i,(e=>!0===e.addCapMtaContinue)),i.unshift(...(0,s.getConfirmMtaContinuePrompt)()),i}},55379:(e,i,a)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.loadManifest=i.destinationQuestionDefaultOption=i.getCFChoices=void 0;const n=a(75199),s=a(20787),o=a(4591),r=a(13149),p=a(16928),c=a(95644);i.getCFChoices=async function getCFChoices({projectRoot:e,isAbapDirectServiceBinding:i,cfDestination:a,isCap:p,apiHubConfigType:d}){let l=[];const h=[{name:(0,c.t)("cfGen.prompts.abapBinding.name"),value:c.DESTINATION_CHOICE_DIRECT_SERVICE_BINDING}];if("API_HUB_ENTERPRISE"===d)l=[{name:a,value:a}];else{const d=!i&&(0,n.isAppStudio)()?await async function getCFSystemChoices(e,i,a){const n=[];try{let a=[];if(i){a=(await r.MtaConfig.newInstance(e)).getExposedDestinations(),a?.length&&n.push({name:(0,c.t)("cfGen.prompts.capInstanceBasedDest.name"),value:c.DEFAULT_MTA_DESTINATION})}else{const i=(await(0,s.getMtaPath)(e))?.mtaPath?.split(s.FileName.MtaYaml)[0];if(i){a=(await r.MtaConfig.newInstance(i)).getExposedDestinations(!0)}}a?.length&&a.forEach((e=>{n.push({name:(0,c.t)("cfGen.prompts.instanceBasedDest.name",{destination:e}),value:e})}))}catch(e){o.DeploymentGenerator.logger?.debug((0,c.t)("cfGen.error.mtaDestinations",{error:e}))}a||n.splice(0,0,{name:(0,c.t)("cfGen.prompts.none.name"),value:c.DESTINATION_CHOICE_NONE});return n}(e,p,a):[];l=i?h:d}return l},i.destinationQuestionDefaultOption=function destinationQuestionDefaultOption(e,i,a){let n="";return i?a?n=a:e?n=c.DESTINATION_CHOICE_DIRECT_SERVICE_BINDING:i&&(n=c.DESTINATION_CHOICE_NONE):n=a??"",n},i.loadManifest=async function loadManifest(e,i){const a=(0,p.join)(await(0,s.getWebappPath)(i),s.FileName.Manifest),n=e.readJSON(a);return n||(0,o.bail)(o.ErrorHandler.getErrorMsgFromType(o.ERROR_TYPE.NO_MANIFEST)),n["sap.app"]?.id||(0,o.bail)(o.ErrorHandler.getErrorMsgFromType(o.ERROR_TYPE.NO_APP_NAME)),n}},60711:(e,i)=>{var a;Object.defineProperty(i,"__esModule",{value:!0}),i.EventName=void 0,function(e){e.DEPLOY_CONFIG="DEPLOY_CONFIG"}(a||(i.EventName=a={}))},40737:(e,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DESTINATION_CHOICE_DIRECT_SERVICE_BINDING=i.DESTINATION_CHOICE_NONE=i.DESTINATION_AUTHTYPE_NOTFOUND=i.DEFAULT_MTA_DESTINATION=i.API_BUSINESS_HUB_ENTERPRISE_PREFIX=void 0,i.API_BUSINESS_HUB_ENTERPRISE_PREFIX="ABHE",i.DEFAULT_MTA_DESTINATION="fiori-default-srv-api",i.DESTINATION_AUTHTYPE_NOTFOUND="NotAvailable",i.DESTINATION_CHOICE_NONE="NONE",i.DESTINATION_CHOICE_DIRECT_SERVICE_BINDING="DIRECT_SERVICE_BINDING"},96758:function(e,i,a){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0}),i.t=i.initI18n=void 0;const s=n(a(79601)),o=n(a(66211)),r=a(12450),p="cf-deploy-config-generator";async function initI18n(){await s.default.init({lng:"en",fallbackLng:"en"},(()=>s.default.addResourceBundle("en",p,o.default))),(0,r.addi18nResourceBundle)()}i.initI18n=initI18n,i.t=function t(e,i){return i?.ns||(i=Object.assign(i??{},{ns:p})),s.default.t(e,i)},initI18n().catch((()=>{}))},95644:function(e,i,a){var n=this&&this.__createBinding||(Object.create?function(e,i,a,n){void 0===n&&(n=a);var s=Object.getOwnPropertyDescriptor(i,a);s&&!("get"in s?!i.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return i[a]}}),Object.defineProperty(e,n,s)}:function(e,i,a,n){void 0===n&&(n=a),e[n]=i[a]}),s=this&&this.__exportStar||function(e,i){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(i,a)||n(i,e,a)};Object.defineProperty(i,"__esModule",{value:!0}),s(a(40737),i),s(a(96758),i)},66211:e=>{e.exports=JSON.parse('{"cfGen":{"prompts":{"abapBinding":{"name":"Direct Service Binding"},"capInstanceBasedDest":{"name":"Local CAP Project API (Instance Based Destination)"},"instanceBasedDest":{"name":"{{- destination}} (Instance Based Destination)"},"none":{"name":"None"}},"info":{"filesGenerated":"The files have been generated.","skippedInstallation":"Option `--skipInstall` was specified. Installation of dependencies will be skipped."},"error":{"mtaDestinations":"No destinations loaded from mta.yaml. {{- error}}","writing":"Error in writing phase: {{- error}}","install":"Error in install phase: {{- error}}","end":"Error in end phase: {{- error}}"},"debug":{"promptOptions":"Retrieving CF prompts using: \\n {{- options}}","initTelemetry":"Initializing telemetry in CF deployment configuration generator","capMissingMTA":"CAP project detected with no MTA configuration"}},"appRouterGen":{"debug":{"projectPath":"Project loaded from {{- destinationPath}}"}}}')}};