@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 6.05 kB
JavaScript
"use strict";exports.id=2051,exports.ids=[2051],exports.modules={32058(e,i,s){s.r(i),s.d(i,{default:()=>O,promptNames:()=>h.rp});var n=s(76760),o=s(91170),a=s(94443);class FlpGenLogger{static _logger=a.DefaultLogger;static get logger(){return FlpGenLogger._logger}static set logger(e){FlpGenLogger._logger=e}static configureLogging(e,i,s,n,o,r){const p=s??new a.LogWrapper(e,i,n,o,r);FlpGenLogger.logger=p}}var r=s(73667),p=s(58808),h=s(99416),l=s(57550),c=s(7083),g=s(50702),d=s(40511),f=s(67566);const u="flpTitle",m="flpSubtitle";var b=s(68801);const w=JSON.parse('{"error":{"endPhase":"An error occurred in the end phase of the `deployment-generator:flp`: {{- error}}","telemetry":"Failed to send telemetry data after SAP Fiori launchpad configuration has been added: {{- error}}","noManifest":"The `manifest.json` file was not found at path: {{- path}}.","sapNotDefined":"The `manifest.json file` is missing the required section: sap.app. Add the required section."},"warning":{"updatei18n":"Cannot update the i18n properties file: {{- path}}. For more information, view the logs."},"info":{"filesGenerated":"The files have been generated."}}'),v="flp-config-generator",C=b.createInstance();function t(e,i){return i?.ns||(i=Object.assign(i??{},{ns:v})),C.t(e,i)}var F;(async function initI18n(){await C.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),C.addResourceBundle("en",v,w)})().catch(()=>{}),function(e){e.GENERATION_SUCCESS="GENERATION_SUCCESS"}(F||(F={}));const S="@sap-ux/flp-config-sub-generator",O=class extends o{appWizard;vscode;launchFlpConfigAsSubGenerator;existingApp;appRootPath;prompts;answers;abort=!1;manifest;manifestPath;promptOptions;options;setPromptsCallback;constructor(e,i){super(e,i),this.appWizard=i.appWizard??r.AppWizard.create(i),this.vscode=i.vscode,this.launchFlpConfigAsSubGenerator=i.launchFlpConfigAsSubGenerator??!1,this.appRootPath=i.data?.appRootPath??i?.appRootPath??this.destinationRoot(),this.promptOptions=this.options?.inquirerPromptOptions,this.options=i,FlpGenLogger.configureLogging(this.rootGeneratorName(),this.log,this.options.logWrapper,this.options.logLevel,this.options.logger,this.vscode),this.launchFlpConfigAsSubGenerator||(this.appWizard.setHeaderTitle("Fiori Launchpad Configuration Generator"),this.prompts=new r.Prompts(function getYUIDetails(e){return[{name:"Fiori Launchpad Configuration",description:`Configure Fiori Launchpad settings - ${(0,n.basename)(e)}`}]}(this.appRootPath)),this.setPromptsCallback=e=>{this.prompts&&this.prompts.setCallback(e)},this.existingApp=!0)}async initializing(){(0,a.setYeomanEnvConflicterForce)(this.env,this.options.force);const e=await(0,p.GJ)(this.env.create.bind(this.env),S,this.vscode);this.promptOptions={...e,...this.promptOptions},await a.TelemetryHelper.initTelemetrySettings({consumerModule:{name:S,version:this.rootGeneratorVersion()},internalFeature:(0,d.isInternalFeaturesSettingEnabled)(),watchTelemetrySettingStore:!1}),this.existingApp&&(this.manifestPath=(0,n.join)(await(0,c.vv)(this.appRootPath),c.o3.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),this.manifest||(0,p.sw)(this.appWizard,{errorMsg:t("error.noManifest",{path:this.manifestPath})}),this.manifest["sap.app"]||(0,p.sw)(this.appWizard,{errorMsg:t("error.sapNotDefined")}))}async prompting(){if(this.launchFlpConfigAsSubGenerator&&void 0!==this.options.inboundConfig?.semanticObject&&void 0!==this.options.inboundConfig?.action&&void 0!==this.options.inboundConfig?.title&&this.options.skipPrompt)return void(this.answers={overwrite:!0,semanticObject:this.options.inboundConfig.semanticObject,action:this.options.inboundConfig.action,title:this.options.inboundConfig.title,subTitle:this.options.inboundConfig.subTitle});let e={};this.manifest?.["sap.app"]?.crossNavigation?.inbounds&&(e=this.manifest?.["sap.app"]?.crossNavigation?.inbounds);const i=this.options.overwrite;let s=await(0,h.oO)(e,{silentOverwrite:i,...(n=this.promptOptions,{...n,[h.rp.inboundId]:{hide:!0,...n?.inboundId},[h.rp.existingFlpConfigInfo]:{hide:!0,...n?.existingFlpConfigInfo},[h.rp.icon]:{hide:!0,...n?.icon},[h.rp.additionalParameters]:{hide:!0,...n?.additionalParameters},[h.rp.confirmReplace]:{hide:!0,...n?.confirmReplace}})});var n;this.promptOptions&&(s=(0,f.extendWithOptions)(s,this.promptOptions)),this.answers={};const o=await this.prompt(s);(!1===o.s4Continue||!1===o.overwrite&&!i)&&(this.abort=!0,process.exit(0)),""===o.subTitle&&(o.subTitle=void 0),Object.assign(this.answers,o)}async writing(){!1===this.abort&&this.existingApp&&await this._updateFiles(this.answers)}async _updateFiles({semanticObject:e,action:i,title:s,subTitle:n}){let o=!1;s&&(o=await this._updateI18n(this.manifestPath,this.manifest,{semanticObject:e,action:i,title:s,subTitle:n})),await(0,l.rU)(this.appRootPath,{semanticObject:e,action:i,title:o?`{{${e}-${i}.${u}}}`:s,subTitle:o&&n?`{{${e}-${i}.${m}}}`:n},!0,this.fs)}async _updateI18n(e,i,{semanticObject:s,action:n,title:o,subTitle:a}){let p=!1;const{"sap.app":h}=await(0,c.Qw)(e,i);try{const e=[{key:`${s}-${n}.${u}`,value:o}];a&&e.push({key:`${s}-${n}.${m}`,value:a}),p=await(0,g.Kc)(h,e,this.appRootPath,this.fs)}catch(e){const i=t("warning.updatei18n",{path:h});this.appWizard.showWarning(i,r.MessageType.notification),FlpGenLogger.logger?.error(i)}return p}async end(){if(!this.abort&&!1!==this.answers.overwrite){!1!==this.abort||this.existingApp||(this.manifestPath=(0,n.join)(await(0,c.vv)(this.appRootPath),c.o3.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),await this._updateFiles(this.answers));try{!this.options.launchFlpConfigAsSubGenerator&&(0,a.isExtensionInstalled)(this.vscode,a.YUI_EXTENSION_ID,a.YUI_MIN_VER_FILES_GENERATED_MSG)&&this.appWizard?.showInformation(t("info.filesGenerated"),r.MessageType.notification),(0,a.sendTelemetry)(F.GENERATION_SUCCESS,a.TelemetryHelper.createTelemetryData({appType:"flp-config",...this.options.telemetryData})??{}).catch(e=>{FlpGenLogger.logger.error(t("error.telemetry",{error:e}))})}catch(e){FlpGenLogger.logger?.error(t("error.endPhase",{error:e}))}}}}}};