UNPKG

@sap/generator-fiori

Version:

Create an SAPUI5 application using SAP Fiori elements or a freestyle approach

1 lines 15.3 kB
"use strict";exports.id=703,exports.ids=[703],exports.modules={29735(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.DeployProjectType=i.indexHtmlExists=i.getAbapQuestions=void 0;const s=n(73667),o=n(4591),a=n(58012),r=n(83740),p=n(99214),c=n(8231),l=n(20787),d=n(2218),h=n(84229),u=n(48546),g=n(17910),m=n(22366),y=n(90409),f=n(98434),w=n(75199),A=n(17313),b=n(36620),P=n(85393),T=n(60987);class default_1 extends o.DeploymentGenerator{appWizard;vscode;launchDeployConfigAsSubGenerator;launchStandaloneFromYui;abort=!1;backendConfig;indexGenerationAllowed;configExists;answers;projectType;adpProjectType;isAdp;constructor(e,i){super(e,i),this.launchDeployConfigAsSubGenerator=i.launchDeployConfigAsSubGenerator??!1,this.launchStandaloneFromYui=i.launchStandaloneFromYui,this.adpProjectType=i.adpProjectType,this.appWizard=i.appWizard||s.AppWizard.create(i),this.vscode=i.vscode,this.options=i}async initializing(){await super.initializing(),await(0,y.initI18n)(),o.DeploymentGenerator.logger?.debug((0,h.t)("debug.initTelemetry")),await a.TelemetryHelper.initTelemetrySettings({consumerModule:{name:"@sap-ux/abap-deploy-config-sub-generator",version:this.rootGeneratorVersion()},internalFeature:(0,f.isInternalFeaturesSettingEnabled)(),watchTelemetrySettingStore:!1}),(0,a.setYeomanEnvConflicterForce)(this.env,this.options.force),this.launchDeployConfigAsSubGenerator||(await this._initializing(),this.adpProjectType=await(0,P.getExistingAdpProjectType)(this.destinationRoot()))}_initDestinationRoot(){this.options.appRootPath&&(this.destinationRoot(this.options.appRootPath),o.DeploymentGenerator.logger?.debug((0,h.t)("debug.appRootPath",{appRootPath:this.options.appRootPath})))}_processProjectConfig(){this.options.base=this.options.base||l.FileName.Ui5Yaml,this.options.config=this.options.config||l.FileName.UI5DeployYaml;this.fs.exists(this.destinationPath(this.options.base))||(this.abort=!0,(0,h.handleProjectDoesNotExist)(this.appWizard,this.destinationPath(this.options.base))),this.configExists=this.fs.exists(this.destinationPath(this.options.config)),this.configExists&&o.DeploymentGenerator.logger?.debug((0,h.t)("debug.configExists",{configPath:this.destinationPath(this.options.config)}))}async _processIndexHtmlConfig(){if(this.projectType===m.DeployProjectType.Library)this.indexGenerationAllowed=!1;else{await(0,h.indexHtmlExists)(this.fs,this.destinationPath())?(this.indexGenerationAllowed=!1,this.options.index&&o.DeploymentGenerator.logger?.debug((0,h.t)("debug.indexExists")),delete this.options.index):this.indexGenerationAllowed=!0}}async _initBackendConfig(){const e=await c.UI5Config.newInstance(this.fs.read(this.destinationPath(this.options.base??l.FileName.Ui5Yaml)));this.projectType="library"===e.getType()?m.DeployProjectType.Library:m.DeployProjectType.Application,this.backendConfig=e.getBackendConfigsFromFioriToolsProxyMiddleware()[0]}async _initializing(){this._initDestinationRoot();try{this._processProjectConfig(),await this._initBackendConfig(),await this._processIndexHtmlConfig()}catch(e){if(e!==o.ERROR_TYPE.ABORT_SIGNAL)throw e;o.DeploymentGenerator.logger?.debug((0,h.t)("debug.initFailed",{error:o.ErrorHandler.getErrorMsgFromType(o.ERROR_TYPE.ABORT_SIGNAL)}))}}async prompting(){if(this.answers={},!this.abort){if(!this.launchDeployConfigAsSubGenerator){const e=await(0,l.getAppType)(this.destinationPath());this.isAdp="Fiori Adaptation"===e;const i={shouldValidatePackageForStartingPrefix:this.isAdp,shouldValidatePackageType:this.isAdp,shouldValidateFormatAndSpecialCharacters:this.isAdp},n=this.adpProjectType===T.AdaptationProjectType.ON_PREMISE,s={ui5AbapRepo:{hideIfOnPremise:n},transportInputChoice:{hideIfOnPremise:n},packageAutocomplete:{additionalValidation:i},packageManual:{additionalValidation:i},adpProjectType:this.adpProjectType},a=this.indexGenerationAllowed&&!this.isAdp,{prompts:p,answers:c={}}=await(0,u.getAbapQuestions)({appRootPath:this.destinationRoot(),connectedSystem:this.options.connectedSystem,backendConfig:this.backendConfig,configFile:this.options.config,indexGenerationAllowed:a,showOverwriteQuestion:(0,o.showOverwriteQuestion)(this.launchDeployConfigAsSubGenerator,this.launchStandaloneFromYui,this.options.overwrite,this.configExists),projectType:this.projectType,logger:o.DeploymentGenerator.logger,promptOptions:s}),d=await this.prompt(p);this.answers=(0,r.reconcileAnswers)(d,c)}await this._reconcileAnswersWithOptions()}}async _processAbapTargetAnswers(){this.answers.destination=this.options.destination||this.answers.destination,this.answers.url=this.options.url||this.answers.url||await(0,h.determineUrlFromDestination)(this.answers.destination),this.answers.connectPath=this.options.connectPath||this.answers.connectPath,this.answers.client=this.options.client||this.answers.client,this.answers.scp=this.options.scp||this.answers.scp||await(0,h.determineScpFromTarget)({url:this.answers.url,client:this.answers.client,destination:this.answers.destination}),this.answers.isAbapCloud=this.options.isAbapCloud||this.answers.isAbapCloud||await(0,h.determineS4HCFromTarget)({url:this.answers.url,client:this.answers.client,destination:this.answers.destination}),!(0,w.isAppStudio)()&&this.answers.scp&&delete this.answers.client}_processBspAppAnswers(){this.answers.ui5AbapRepo=(this.options.ui5AbapRepo||this.answers.ui5AbapRepo)?.toUpperCase(),this.answers.description=this.options.description||this.answers.description,this.answers.package||(this.answers.package=(0,r.getPackageAnswer)(this.options,this.options.package)||(0,r.getPackageAnswer)(this.answers)||(this.answers.scp?"":A.DEFAULT_PACKAGE_ABAP)),this.answers.transport||(this.answers.transport=this.options.transport??((0,r.getTransportAnswer)(this.options)||(0,r.getTransportAnswer)(this.answers)))}async _reconcileAnswersWithOptions(){await this._processAbapTargetAnswers(),this._processBspAppAnswers(),this.answers.index=this.options.index??this.answers.index,this.answers.overwrite=this.options.overwrite??this.answers.overwrite}async writing(){this.launchDeployConfigAsSubGenerator?(await this._initializing(),await this._writing()):await this._writing()}async _writing(){if(this.abort||!1===this.answers.overwrite)return;const e=this.adpProjectType===T.AdaptationProjectType.CLOUD_READY,i=await(0,b.getVariantNamespace)(this.destinationPath(),e,this.fs);await(0,p.generate)(this.destinationPath(),{target:{url:this.answers.url,connectPath:this.answers.connectPath,client:this.answers.client,scp:this.answers.scp,destination:this.answers.destination,authenticationType:this.answers.isAbapCloud?d.AuthenticationType.ReentranceTicket:void 0},app:{name:this.answers.ui5AbapRepo,description:this.answers.description,package:this.answers.package,transport:this.answers.transport},index:this.answers.index,lrep:i},{baseFile:this.options.base,deployFile:this.options.config,addBuildToUndeployScript:!this.isAdp},this.fs)}install(){!1!==this.answers.overwrite&&this._install()}_install(){this.options.skipInstall?o.DeploymentGenerator.logger?.info((0,h.t)("info.skippedInstallation")):this.spawnCommand("npm",["install","--no-audit","--no-fund","--silent","--prefer-offline","--no-progress"])}async end(){this.abort||!1===this.answers.overwrite||(this.launchStandaloneFromYui&&(0,a.isExtensionInstalled)(this.vscode,a.YUI_EXTENSION_ID,a.YUI_MIN_VER_FILES_GENERATED_MSG)&&this.appWizard?.showInformation((0,h.t)("info.filesGenerated"),s.MessageType.notification),(0,a.sendTelemetry)(g.EventName.DEPLOY_CONFIG,a.TelemetryHelper.createTelemetryData({DeployTarget:"ABAP",...this.options.telemetryData})??{},this.destinationRoot())?.catch(e=>{o.DeploymentGenerator.logger.error((0,h.t)("error.telemetry",{error:e}))}))}}i.default=default_1;var _=n(48546);Object.defineProperty(i,"getAbapQuestions",{enumerable:!0,get:function(){return _.getAbapQuestions}});var x=n(84229);Object.defineProperty(i,"indexHtmlExists",{enumerable:!0,get:function(){return x.indexHtmlExists}});var S=n(22366);Object.defineProperty(i,"DeployProjectType",{enumerable:!0,get:function(){return S.DeployProjectType}})},48546(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.getAbapQuestions=async function getAbapQuestions({appRootPath:e,connectedSystem:i,backendConfig:n,configFile:l=o.FileName.UI5DeployYaml,indexGenerationAllowed:d=!1,showOverwriteQuestion:h=!1,projectType:u=c.DeployProjectType.Application,promptOptions:g={},logger:m}){const{backendSystem:y,serviceProvider:f,destination:w}=i||{};let A;try{const i=await(0,o.readUi5Yaml)(e,l);A=i.findCustomTask(p.ABAP_DEPLOY_TASK)?.configuration}catch{}const b=function getAbapTarget(e,i,n,s){let o,a,p,c,l,d;if((0,r.isAppStudio)()&&e)c=e.Name;else if(i){try{const e=new URL(i.url);o=e.origin,d="/"===e.pathname?void 0:e.pathname}catch{o=i.url}p=i.client,a=!!i.serviceKeys,l=i.authenticationType}else n?.target?(o=n.target.url,p=n.target.client,a=n.target.scp,l=n.target.authenticationType,c=n.target.destination):s&&(o=s.url,d=s.connectPath,a=s.scp,p=s.client,l=s.authenticationType,c=s?.destination);return{url:o,scp:a,client:p||"",destination:c,authenticationType:l,connectPath:d}}(w,y,A,n),P=A?.app;return m?.debug(`Retrieve ABAP prompts using: \n App path: ${e}, \n ABAPTarget: ${JSON.stringify(b)}, SystemName: ${y?.name}, \n ServiceProvider: ${!!f}, showOverwriteQuestion ${h}, indexGenerationAllowed ${d}`),(0,s.getPrompts)({backendTarget:{abapTarget:b,systemName:y?.name,serviceProvider:f,type:u},adpProjectType:g.adpProjectType,ui5AbapRepo:{default:P?.name,...g?.ui5AbapRepo},description:{default:P?.description},packageManual:{default:P?.package??g?.packageManual?.default,...g?.packageManual},transportManual:{default:P?.transport},index:{indexGenerationAllowed:d},packageAutocomplete:{useAutocomplete:!0,...g?.packageAutocomplete},overwriteAbapConfig:{hide:!h},transportInputChoice:{hideIfOnPremise:g?.transportInputChoice?.hideIfOnPremise??!1}},m,(0,a.getHostEnvironment)()!==a.hostEnvironment.cli)};const s=n(83740),o=n(20787),a=n(58012),r=n(75199),p=n(62268),c=n(22366)},22366(e,i){var n;Object.defineProperty(i,"__esModule",{value:!0}),i.DeployProjectType=void 0,function(e){e.Application="application",e.Library="library"}(n||(i.DeployProjectType=n={}))},17910(e,i){var n;Object.defineProperty(i,"__esModule",{value:!0}),i.EventName=void 0,function(e){e.DEPLOY_CONFIG="DEPLOY_CONFIG"}(n||(i.EventName=n={}))},62268(e,i){Object.defineProperty(i,"__esModule",{value:!0}),i.ABAP_DEPLOY_TASK=void 0,i.ABAP_DEPLOY_TASK="deploy-to-abap"},48706(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.handleProjectDoesNotExist=function handleProjectDoesNotExist(e,i){const n=s.ErrorHandler.fileDoesNotExist(i);throw(0,s.handleErrorMessage)(e,{errorMsg:n}),s.ERROR_TYPE.ABORT_SIGNAL};const s=n(4591)},99920(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.determineUrlFromDestination=async function determineUrlFromDestination(e){let i;if((0,s.isAppStudio)()&&e){const n=await getDestinations();i=n?.[e]?.Host}return i},i.determineScpFromTarget=async function determineScpFromTarget(e){let i=!1;if((0,s.isAppStudio)()&&e.destination){const n=await getDestinations();n?.[e.destination]&&(i=(0,s.isAbapEnvironmentOnBtp)(n?.[e.destination]))}else if(e.url){const n=await getBackendSystems(),s=n?.find(i=>isSameSystem(i,e));i=!!s?.serviceKeys}return i},i.determineS4HCFromTarget=async function determineS4HCFromTarget(e){let i=!1;if((0,s.isAppStudio)()&&e.destination){const n=await getDestinations();n?.[e.destination]&&(i=(0,s.isS4HC)(n?.[e.destination]))}else if(e.url){const n=await getBackendSystems(),s=n?.find(i=>isSameSystem(i,e));i=s?.authenticationType===a.AuthenticationType.ReentranceTicket}return i};const s=n(75199),o=n(4591),a=n(2218);let r={},p=[];function isSameSystem(e,i){return e.url.trim().replace(/\/$/,"")===i.url?.trim().replace(/\/$/,"")&&(e.client??"")===(i?.client??"")}async function getDestinations(){if(0===Object.keys(r)?.length)try{r=await(0,s.listDestinations)({stripS4HCApiHosts:!0})}catch(e){o.DeploymentGenerator.logger.error(`Failed to fetch destinations. Error: ${e.message}`)}return r}async function getBackendSystems(){if(0===p?.length)try{const e=await(0,a.getService)({logger:o.DeploymentGenerator.logger,entityName:"system"});p=await(e?.getAll())}catch(e){o.DeploymentGenerator.logger.error(`Failed to fetch systems list. Error: ${e.message}`)}return p}},90409(e,i,n){var s=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0}),i.i18n=void 0,i.initI18n=initI18n,i.t=function t(e,n){n?.ns||(n=Object.assign(n??{},{ns:r}));return i.i18n.t(e,n)};const o=s(n(68801)),a=s(n(46649)),r="abap-deploy-config-sub-generator";async function initI18n(){await i.i18n.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),i.i18n.addResourceBundle("en",r,a.default)}i.i18n=o.default.createInstance(),initI18n().catch(()=>{})},84229(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.determineS4HCFromTarget=i.determineUrlFromDestination=i.determineScpFromTarget=i.t=i.handleProjectDoesNotExist=i.indexHtmlExists=void 0;var s=n(36620);Object.defineProperty(i,"indexHtmlExists",{enumerable:!0,get:function(){return s.indexHtmlExists}});var o=n(48706);Object.defineProperty(i,"handleProjectDoesNotExist",{enumerable:!0,get:function(){return o.handleProjectDoesNotExist}});var a=n(90409);Object.defineProperty(i,"t",{enumerable:!0,get:function(){return a.t}});var r=n(99920);Object.defineProperty(i,"determineScpFromTarget",{enumerable:!0,get:function(){return r.determineScpFromTarget}}),Object.defineProperty(i,"determineUrlFromDestination",{enumerable:!0,get:function(){return r.determineUrlFromDestination}}),Object.defineProperty(i,"determineS4HCFromTarget",{enumerable:!0,get:function(){return r.determineS4HCFromTarget}})},36620(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.indexHtmlExists=async function indexHtmlExists(e,i){const n=await(0,s.getWebappPath)(i),a=(0,o.join)(n,"index.html");return e.exists(a)},i.getVariantNamespace=async function getVariantNamespace(e,i,n){if(i)return;try{const i=(0,o.join)(await(0,s.getWebappPath)(e,n),s.FileName.ManifestAppDescrVar);if(n.exists(i)){return n.readJSON(i).namespace}}catch(e){r.DeploymentGenerator.logger?.debug((0,a.t)("debug.lrepNamespaceNotFound",{error:e.message}))}return};const s=n(20787),o=n(76760),a=n(90409),r=n(4591)},46649(e){e.exports=JSON.parse('{"error":{"telemetry":"Failed to send telemetry data after deployment configuration has been added: {{- error}}"},"info":{"filesGenerated":"The files have been generated.","skippedInstallation":"Option: `--skipInstall` was specified. Installation of dependencies will be skipped."},"debug":{"configExists":"Existing deployment configuration file found at {{- configPath}}.","configNotFound":"No existing deployment configuration file found. Create a deployment configuration file.","indexExists":"The `webapp/index.html` file already exists and will not be overwritten.","initFailed":"Initializing failed. Unable to process the project configuration: {{- error}}","initTelemetry":"Initializing telemetry in ABAP deployment configuration generator...","appRootPath":"Application loaded from: {{- appRootPath}}.","lrepNamespaceNotFound":"Failed to get the `lrep` namespace: {{- error}}"}}')}};