@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 15.5 kB
JavaScript
"use strict";exports.id=8236,exports.ids=[8236],exports.modules={13277(e,o,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.promptNames=void 0;const a=n(i(59636)),s=i(76760),r=i(20787),p=i(4591),c=i(12251),g=i(72756);Object.defineProperty(o,"promptNames",{enumerable:!0,get:function(){return g.promptNames}});const l=i(73667),h=i(43988);class default_1 extends p.DeploymentGenerator{appWizard;prompts;genNamespace;launchStandaloneFromYui;apiHubConfig;launchDeployConfigAsSubGenerator;promptOptions;vscode;cfDestination;mtaPath;backendConfig;isLibrary=!1;isCap=!1;target;answers;setPromptsCallback;constructor(e,o){super(e,o),this.appWizard=o.appWizard??l.AppWizard.create(o),this.genNamespace=o.namespace,this.launchDeployConfigAsSubGenerator=o.launchDeployConfigAsSubGenerator??!1,this.promptOptions=o?.subGenPromptOptions,this.target=(0,c.parseTarget)(e,o),this.vscode=o.vscode,this.rootGeneratorName()&&this.env.lookup({packagePatterns:[this.rootGeneratorName()]}),this.options.data?.destinationRoot?(this.launchStandaloneFromYui=!0,this.launchDeployConfigAsSubGenerator||=this.options.data.launchDeployConfigAsSubGenerator,this.options.appRootPath=(0,s.join)((0,s.dirname)(this.options.data.destinationRoot),(0,s.basename)(this.options.data.destinationRoot)),this.options.projectRoot=this.options.data.destinationRoot,a.default.config({path:(0,s.join)(this.options.data.destinationRoot,".env"),quiet:!0})):(this.options.projectPath&&this.options.projectName?this.options.appRootPath=(0,s.join)(this.options.projectPath,this.options.projectName):this.options.appRootPath=this.destinationRoot(),a.default.config({quiet:!0}),this.apiHubConfig=this.options.apiHubConfig??(0,g.getEnvApiHubConfig)(),this.launchStandaloneFromYui=!1),this.launchStandaloneFromYui&&(this.appWizard.setHeaderTitle(g.generatorTitle),this.prompts=new l.Prompts((0,c.getYUIDetails)(this.options.projectRoot)),this.setPromptsCallback=e=>{this.prompts&&this.prompts.setCallback(e)})}async initializing(){await super.initializing();const e=await(0,p.getExtensionGenPromptOpts)(this.env.create.bind(this.env),"@sap-ux/deploy-config-sub-generator",this.vscode);this.promptOptions={...e,...this.promptOptions};const o=await(0,r.findCapProjectRoot)(this.options.appRootPath);this.isCap=!!o,this.mtaPath=(await(0,r.getMtaPath)(this.options.appRootPath))?.mtaPath,this.isCap&&!this.mtaPath&&(this.target=p.TargetName.CF);"Fiori Adaptation"===await(0,r.getAppType)(this.options.appRootPath)&&(this.target=p.TargetName.ABAP,this.launchDeployConfigAsSubGenerator=!1),this.options.projectRoot=o??(this.mtaPath&&(0,s.dirname)(this.mtaPath))??this.options.appRootPath,({backendConfig:this.backendConfig,isLibrary:this.isLibrary}=await(0,g.getBackendConfig)(this.fs,this.options,this.launchStandaloneFromYui,this.options.appRootPath));const{destinationName:i,servicePath:n}=await(0,g.getApiHubOptions)(this.fs,{appPath:this.options.appRootPath,servicePath:this.options.appGenServicePath});this.options.appGenServicePath||=n,this.cfDestination=i??this.options.appGenDestination??this.backendConfig?.destination}async prompting(){const e=await(0,g.getSupportedTargets)(this.fs,this.options.appRootPath,this.isCap,!!this.mtaPath,this.apiHubConfig);if(this.target){e.find(e=>e.name===this.target)||(0,p.bail)(p.ErrorHandler.unrecognizedTarget(this.target))}if(!this.target||this.launchDeployConfigAsSubGenerator){const{target:o,answers:i}=await(0,h.promptDeployConfigQuestions)(this.fs,this.options,this.prompt.bind(this),{launchDeployConfigAsSubGenerator:this.launchDeployConfigAsSubGenerator,launchStandaloneFromYui:this.launchStandaloneFromYui,promptOptions:this.promptOptions,supportedTargets:e,backendConfig:this.backendConfig,cfDestination:this.cfDestination,isCap:this.isCap,apiHubConfig:this.apiHubConfig,isLibrary:this.isLibrary},this.target);this.target=o,this.answers=i}this.target?await this._composeWithSubGenerator(this.target,this.answers):(p.DeploymentGenerator.logger?.debug((0,g.t)("debug.exit")),process.exit(0))}async _composeWithSubGenerator(e,o){try{const i=e,n=this.launchDeployConfigAsSubGenerator?{...this.options,launchStandaloneFromYui:this.launchStandaloneFromYui,launchDeployConfigAsSubGenerator:!0,...o}:{...this.options,launchDeployConfigAsSubGenerator:!1};this.apiHubConfig&&(n.apiHubConfig=this.apiHubConfig),await this.composeWith((0,g.generatorNamespace)(this.genNamespace,i),n)}catch(e){p.DeploymentGenerator.logger?.error(e.message)}}}o.default=default_1},43988(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.promptDeployConfigQuestions=async function promptDeployConfigQuestions(e,o,i,{launchDeployConfigAsSubGenerator:a,launchStandaloneFromYui:s,promptOptions:r,supportedTargets:p,backendConfig:c,cfDestination:g,isCap:l,apiHubConfig:h,isLibrary:u},d){let f={};if(a){const{questions:m,abapAnswers:b}=await(0,n.getSubGenPrompts)(e,o,{launchDeployConfigAsSubGenerator:a,launchStandaloneFromYui:s,promptOptions:r,supportedTargets:p,backendConfig:c,cfDestination:g,isCap:l,apiHubConfig:h,isLibrary:u},d),y=await i(m);Object.assign(f,y,b),f.overwrite=y.overwriteAbapConfig??y.overwriteCfConfig}else f=await i((0,n.getDeployTargetQuestion)([...p],o.projectRoot));const m=p.find(e=>e.name===f?.targetName||e.name===d)?.name;return{target:m,answers:f}};const n=i(4466)},12251(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.parseTarget=function parseTarget(e,o){let i;"string"==typeof e?i=e:Array.isArray(e)&&(i=e?.[0]);i||(i=o.target);return i},o.getYUIDetails=function getYUIDetails(e){return[{name:"Deployment Configuration",description:`Configure Deployment settings - ${(0,n.basename)(e)}`}]};const n=i(76760)},76804(e,o,i){Object.defineProperty(o,"__esModule",{value:!0});const n=i(76760),a=i(73024),s=i(4591),r=i(72756),p=i(58012);class default_1 extends s.DeploymentGenerator{genNamespace;absAppConfigPath;appConfig;deployTarget;constructor(e,o){super(e,o),this.genNamespace=o.namespace;try{if(this.argument("appConfig",{type:String,description:(0,r.t)("headless.info.generatorArgAppConfig"),required:!1}),0===Object.keys(this.options.appConfig??{}).length)throw Error((0,r.t)("headless.error.headlessGenOptions"));"object"==typeof this.options.appConfig?this.appConfig=this.options.appConfig:this.fs.exists(this.options.appConfig)?(this.appConfig=JSON.parse(this.fs.read(this.options.appConfig)),this.absAppConfigPath=(0,n.resolve)(this.options.appConfig)):this.appConfig=JSON.parse(this.options.appConfig),this.deployTarget=this.appConfig.deployConfig?.deployTarget}catch(e){s.DeploymentGenerator.logger?.error((0,r.t)("headless.error.generationExiting")),this.env.error(e)}}async initializing(){s.DeploymentGenerator.logger?.info((0,r.t)("headless.info.generatorNameVersion",{generatorName:this.rootGeneratorName(),generatorVersion:this.rootGeneratorVersion()}));const e={AppGenLaunchSource:this.options.appConfig.telemetryData?.generationSourceName??"Headless",AppGenLaunchSourceVersion:this.options.appConfig.telemetryData?.generationSourceVersion??"Not Provided"},o=this.transformExtConfig();if(o&&this.deployTarget){const i=this.deployTarget===p.DeployTarget.CF?r.cfChoice.name:r.abapChoice.name;await this.composeWith((0,r.generatorNamespace)(this.genNamespace,i),{arguments:this.args,...Object.assign(this.options,o,{telemetryData:e})})}}transformExtConfig(){let e;if(this.deployTarget===p.DeployTarget.CF){const o=this.appConfig.deployConfig;this.appConfig.project.targetFolder&&(e={projectRoot:this.appConfig.project.targetFolder,destinationName:o.destinationName,destinationAuthType:o.destinationAuthType,addManagedAppRouter:o.addToManagedAppRouter,launchDeployConfigAsSubGenerator:!0,appRootPath:(0,n.join)(this.appConfig.project.targetFolder,this.appConfig.project.name),addMTADestination:o.addMTADestination,lcapModeOnly:o.lcapModeOnly,cloudServiceName:o.cloudServiceName})}else if(this.deployTarget===p.DeployTarget.ABAP){const o=this.appConfig.deployConfig;this.appConfig.project.targetFolder&&(e={appRootPath:(0,n.join)(this.appConfig.project.targetFolder,this.appConfig.project.name),destination:o?.destination,url:o?.url??"",client:o?.client,scp:o?.scp,ui5AbapRepo:o?.ui5AbapRepo,description:o?.description,package:o?.package,transport:o?.transport,launchDeployConfigAsSubGenerator:!0})}return e}end(){this.options.deleteFile&&this.fs.exists(this.absAppConfigPath)&&(s.DeploymentGenerator.logger?.info((0,r.t)("headless.info.deletingApplicationConfigFile",{filepath:this.absAppConfigPath})),(0,a.unlinkSync)(this.absAppConfigPath))}}o.default=default_1},36629(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.getDeployTargetQuestion=function getDeployTargetQuestion(e,o){return[{type:"list",name:n.promptNames.targetName,guiOptions:{breadcrumb:(0,n.t)("prompts.deployTarget.breadcrumb")},message:(0,n.t)("prompts.deployTarget.message"),default:()=>e[0].name,validate:e=>(0,n.isMTAInstalled)(e,o),choices:e.map(e=>({name:e.description,value:e.name}))}]};const n=i(72756)},4466(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.getSubGenPrompts=o.getDeployTargetQuestion=void 0;var n=i(36629);Object.defineProperty(o,"getDeployTargetQuestion",{enumerable:!0,get:function(){return n.getDeployTargetQuestion}});var a=i(92019);Object.defineProperty(o,"getSubGenPrompts",{enumerable:!0,get:function(){return a.getSubGenPrompts}})},92019(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.getSubGenPrompts=async function getSubGenPrompts(e,o,{launchDeployConfigAsSubGenerator:i,launchStandaloneFromYui:h,promptOptions:u,supportedTargets:d,backendConfig:f,cfDestination:m,isCap:b,apiHubConfig:y,isLibrary:C},P){r.DeploymentGenerator.logger?.debug((0,s.t)("debug.loadingPrompts"));const A=e.exists((0,a.join)(o.appRootPath,o.config||g.FileName.UI5DeployYaml)),T=(0,r.showOverwriteQuestion)(A,i,h,o.overwrite),S=!C&&h&&!await(0,p.indexHtmlExists)(e,o.appRootPath);let D=[],_={};P&&P!==r.TargetName.ABAP||({prompts:D,answers:_}=await(0,p.getAbapQuestions)({appRootPath:o.appRootPath,connectedSystem:o.connectedSystem,backendConfig:f,configFile:o.config,indexGenerationAllowed:S,showOverwriteQuestion:T,promptOptions:o?.subGenPromptOptions,logger:r.DeploymentGenerator.logger}));let v=[];P&&P!==r.TargetName.CF||(v=await(0,c.getCFQuestions)({projectRoot:o.projectRoot,isAbapDirectServiceBinding:o.isAbapDirectServiceBinding,cfDestination:m,isCap:b,addOverwrite:T,apiHubConfig:y,promptOptions:o?.subGenPromptOptions}));let N=[];N=P?P===r.TargetName.ABAP?D:v:function combineAllPrompts(e,{supportedTargets:o,abapPrompts:i,cfPrompts:a,promptOptions:s}){const p=(0,l.getDeployTargetQuestion)(o,e);return p.push(...(0,n.withCondition)(i,e=>e.targetName===r.TargetName.ABAP)),p.push(...(0,n.withCondition)(a,e=>e.targetName===r.TargetName.CF)),s?(0,n.extendWithOptions)(p,s):p}(o.projectRoot,{supportedTargets:d,abapPrompts:D,cfPrompts:v,promptOptions:u});return{questions:N,abapAnswers:_}};const n=i(12450),a=i(76760),s=i(72756),r=i(4591),p=i(29735),c=i(12754),g=i(20787),l=i(36629)},78600(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.getBackendConfig=async function getBackendConfig(e,o,i,p){let c,g=!1;if(i){const i=await s.UI5Config.newInstance(e.read((0,n.join)(p,o.base??r.FileName.Ui5Yaml)));c=i.getBackendConfigsFromFioriToolsProxyMiddleware()[0],g=i.getType()===a.DeployProjectType.Library}else c={destination:o.appGenDestination||o.connectedSystem?.destination?.Name,url:o.appGenServiceHost,client:o.appGenClient,scp:!!o.connectedSystem?.backendSystem?.serviceKeys||!1};return{backendConfig:c,isLibrary:g}};const n=i(76760),a=i(29735),s=i(8231),r=i(20787)},46233(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.promptNames=o.cfChoice=o.abapChoice=o.generatorTitle=o.generatorNamespace=void 0;const n=i(4591);var a;o.generatorNamespace=(e,o)=>`${e}_${o}`,o.generatorTitle="Deployment Configuration Generator",o.abapChoice={name:n.TargetName.ABAP,description:"ABAP"},o.cfChoice={name:n.TargetName.CF,description:"Cloud Foundry"},function(e){e.targetName="targetName"}(a||(o.promptNames=a={}))},70625(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.isMTAInstalled=function isMTAInstalled(e,o){if("cf"===e&&!n.sync(s.mtaExecutable)||"abap"===e&&!n.sync(s.mtaExecutable)&&(0,r.existsSync)((0,p.join)(o,"mta.yaml"))){const e=s.ErrorHandler.getErrorMsgFromType(s.ERROR_TYPE.NO_MTA_BIN);return s.DeploymentGenerator.logger?.warn(e),e}return!0},o.getEnvApiHubConfig=function getEnvApiHubConfig(){const e=process.env.API_HUB_API_KEY,o=process.env.API_HUB_TYPE;return e?{apiHubKey:e,apiHubType:"API_HUB_ENTERPRISE"===o?"API_HUB_ENTERPRISE":"API_HUB"}:void 0},o.getApiHubOptions=async function getApiHubOptions(e,{appPath:o,servicePath:i},n){let r;if("API_HUB_ENTERPRISE"===n?.apiHubType){if(!i){const n=await(0,a.loadManifest)(e,o);i=n?.["sap.app"].dataSources?.mainService?.uri}r=(0,s.generateDestinationName)(a.API_BUSINESS_HUB_ENTERPRISE_PREFIX,i)}return{destinationName:r,servicePath:i}};const n=i(44425),a=i(12754),s=i(4591),r=i(73024),p=i(76760)},20766(e,o,i){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o,"__esModule",{value:!0}),o.i18n=void 0,o.initI18n=initI18n,o.t=function t(e,i){i?.ns||(i=Object.assign(i??{},{ns:p}));return o.i18n.t(e,i)};const a=n(i(68801)),s=n(i(97643)),r=i(12450),p="deploy-config-sub-generator";async function initI18n(){await o.i18n.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),o.i18n.addResourceBundle("en",p,s.default),(0,r.addi18nResourceBundle)()}o.i18n=a.default.createInstance(),initI18n().catch(()=>{})},72756(e,o,i){var n=this&&this.__createBinding||(Object.create?function(e,o,i,n){void 0===n&&(n=i);var a=Object.getOwnPropertyDescriptor(o,i);a&&!("get"in a?!o.__esModule:a.writable||a.configurable)||(a={enumerable:!0,get:function(){return o[i]}}),Object.defineProperty(e,n,a)}:function(e,o,i,n){void 0===n&&(n=i),e[n]=o[i]}),a=this&&this.__exportStar||function(e,o){for(var i in e)"default"===i||Object.prototype.hasOwnProperty.call(o,i)||n(o,e,i)};Object.defineProperty(o,"__esModule",{value:!0}),a(i(78600),o),a(i(46233),o),a(i(20766),o),a(i(70625),o),a(i(27774),o)},27774(e,o,i){Object.defineProperty(o,"__esModule",{value:!0}),o.getSupportedTargets=async function getSupportedTargets(e,o,i=!1,c=!1,g,l=a.FileName.Ui5Yaml){const h="API_HUB_ENTERPRISE"===g?.apiHubType,u=e.exists((0,r.join)(o,".extconfig.json"));let d=!1;try{d=(await s.UI5Config.newInstance(e.read((0,r.join)(o,l)))).getType()===n.DeployProjectType.Library}catch{}return h||i?[p.cfChoice]:d||u?[p.abapChoice]:c?[p.cfChoice,p.abapChoice]:[p.abapChoice,p.cfChoice]};const n=i(29735),a=i(20787),s=i(8231),r=i(76760),p=i(46233)},97643(e){e.exports=JSON.parse('{"prompts":{"deployTarget":{"breadcrumb":"Target Type","message":"Please choose the target."}},"debug":{"exit":"Exiting the deployment generator","loadingPrompts":"Loading deploy prompts..."},"headless":{"info":{"generatorArgAppConfig":"Path to the application config file or application config as a string.","generatorNameVersion":"Generating application with: {{- generatorName}} {{generatorVersion}}","deletingApplicationConfigFile":"Deleting application config file: {{- filepath}}."},"error":{"headlessGenOptions":"Please provide one of the following: 1) The first argument of the file path to the application config file, 2) The first argument of the application config file as a JSON string, or 3) The option `appconfig` as a JSON object.","generationExiting":"Application generation exiting due to error: {{- error}}"}}}')}};