@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 8.23 kB
JavaScript
"use strict";exports.id=2051,exports.ids=[2051],exports.modules={85047(e,i,n){var o=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(i,"__esModule",{value:!0}),i.promptNames=void 0;const s=n(76760),a=o(n(91170)),r=o(n(44749)),p=n(73667),l=n(4591),h=n(1484);Object.defineProperty(i,"promptNames",{enumerable:!0,get:function(){return h.promptNames}});const c=n(91637),u=n(20787),d=n(20197),g=n(98434),f=n(58012),m=n(12450),b=n(52620),v=n(78805),P=n(11846),O="@sap-ux/flp-config-sub-generator";class default_1 extends a.default{appWizard;vscode;launchFlpConfigAsSubGenerator;existingApp;appRootPath;prompts;answers;abort=!1;manifest;manifestPath;promptOptions;options;setPromptsCallback;constructor(e,i){super(e,i),this.appWizard=i.appWizard??p.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,r.default.configureLogging(this.rootGeneratorName(),this.log,this.options.logWrapper,this.options.logLevel,this.options.logger,this.vscode),this.launchFlpConfigAsSubGenerator||(this.appWizard.setHeaderTitle(b.generatorTitle),this.prompts=new p.Prompts((0,v.getYUIDetails)(this.appRootPath)),this.setPromptsCallback=e=>{this.prompts&&this.prompts.setCallback(e)},this.existingApp=!0)}async initializing(){(0,f.setYeomanEnvConflicterForce)(this.env,this.options.force);const e=await(0,l.getExtensionGenPromptOpts)(this.env.create.bind(this.env),O,this.vscode);this.promptOptions={...e,...this.promptOptions},await f.TelemetryHelper.initTelemetrySettings({consumerModule:{name:O,version:this.rootGeneratorVersion()},internalFeature:(0,g.isInternalFeaturesSettingEnabled)(),watchTelemetrySettingStore:!1}),this.existingApp&&(this.manifestPath=(0,s.join)(await(0,u.getWebappPath)(this.appRootPath),u.FileName.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),this.manifest||(0,l.handleErrorMessage)(this.appWizard,{errorMsg:(0,v.t)("error.noManifest",{path:this.manifestPath})}),this.manifest["sap.app"]||(0,l.handleErrorMessage)(this.appWizard,{errorMsg:(0,v.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 n=await(0,h.getPrompts)(e,{silentOverwrite:i,...(0,v.getPromptOptions)(this.promptOptions)});this.promptOptions&&(n=(0,m.extendWithOptions)(n,this.promptOptions)),this.answers={};const o=await this.prompt(n);(!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:n,subTitle:o}){let s=!1;n&&(s=await this._updateI18n(this.manifestPath,this.manifest,{semanticObject:e,action:i,title:n,subTitle:o})),await(0,c.generateInboundNavigationConfig)(this.appRootPath,{semanticObject:e,action:i,title:s?`{{${e}-${i}.${b.i18nKeyTitle}}}`:n,subTitle:s&&o?`{{${e}-${i}.${b.i18nKeySubTitle}}}`:o},!0,this.fs)}async _updateI18n(e,i,{semanticObject:n,action:o,title:s,subTitle:a}){let l=!1;const{"sap.app":h}=await(0,u.getI18nPropertiesPaths)(e,i);try{const e=[{key:`${n}-${o}.${b.i18nKeyTitle}`,value:s}];a&&e.push({key:`${n}-${o}.${b.i18nKeySubTitle}`,value:a}),l=await(0,d.createPropertiesI18nEntries)(h,e,this.appRootPath,this.fs)}catch(e){const i=(0,v.t)("warning.updatei18n",{path:h});this.appWizard.showWarning(i,p.MessageType.notification),r.default.logger?.error(i)}return l}async end(){if(!this.abort&&!1!==this.answers.overwrite){!1!==this.abort||this.existingApp||(this.manifestPath=(0,s.join)(await(0,u.getWebappPath)(this.appRootPath),u.FileName.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),await this._updateFiles(this.answers));try{!this.options.launchFlpConfigAsSubGenerator&&(0,f.isExtensionInstalled)(this.vscode,f.YUI_EXTENSION_ID,f.YUI_MIN_VER_FILES_GENERATED_MSG)&&this.appWizard?.showInformation((0,v.t)("info.filesGenerated"),p.MessageType.notification),(0,f.sendTelemetry)(P.EventName.GENERATION_SUCCESS,f.TelemetryHelper.createTelemetryData({appType:"flp-config",...this.options.telemetryData})??{}).catch(e=>{r.default.logger.error((0,v.t)("error.telemetry",{error:e}))})}catch(e){r.default.logger?.error((0,v.t)("error.endPhase",{error:e}))}}}}i.default=default_1},11846(e,i){var n;Object.defineProperty(i,"__esModule",{value:!0}),i.EventName=void 0,function(e){e.GENERATION_SUCCESS="GENERATION_SUCCESS"}(n||(i.EventName=n={}))},52620(e,i){Object.defineProperty(i,"__esModule",{value:!0}),i.generatorTitle=i.i18nKeySubTitle=i.i18nKeyTitle=void 0,i.i18nKeyTitle="flpTitle",i.i18nKeySubTitle="flpSubtitle",i.generatorTitle="Fiori Launchpad Configuration Generator"},70425(e,i,n){var o=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 s=o(n(68801)),a=o(n(99581)),r="flp-config-generator";async function initI18n(){await i.i18n.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),i.i18n.addResourceBundle("en",r,a.default)}i.i18n=s.default.createInstance(),initI18n().catch(()=>{})},78805(e,i,n){var o=this&&this.__createBinding||(Object.create?function(e,i,n,o){void 0===o&&(o=n);var s=Object.getOwnPropertyDescriptor(i,n);s&&!("get"in s?!i.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return i[n]}}),Object.defineProperty(e,o,s)}:function(e,i,n,o){void 0===o&&(o=n),e[o]=i[n]}),s=this&&this.__exportStar||function(e,i){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(i,n)||o(i,e,n)};Object.defineProperty(i,"__esModule",{value:!0}),i.getPromptOptions=i.getYUIDetails=void 0,s(n(70425),i);var a=n(35222);Object.defineProperty(i,"getYUIDetails",{enumerable:!0,get:function(){return a.getYUIDetails}}),Object.defineProperty(i,"getPromptOptions",{enumerable:!0,get:function(){return a.getPromptOptions}})},44749(e,i,n){Object.defineProperty(i,"__esModule",{value:!0});const o=n(58012);class FlpGenLogger{static _logger=o.DefaultLogger;static get logger(){return FlpGenLogger._logger}static set logger(e){FlpGenLogger._logger=e}static configureLogging(e,i,n,s,a,r){const p=n??new o.LogWrapper(e,i,s,a,r);FlpGenLogger.logger=p}}i.default=FlpGenLogger},35222(e,i,n){Object.defineProperty(i,"__esModule",{value:!0}),i.getYUIDetails=function getYUIDetails(e){return[{name:"Fiori Launchpad Configuration",description:`Configure Fiori Launchpad settings - ${(0,o.basename)(e)}`}]},i.getPromptOptions=function getPromptOptions(e){return{...e,[s.promptNames.inboundId]:{hide:!0,...e?.inboundId},[s.promptNames.existingFlpConfigInfo]:{hide:!0,...e?.existingFlpConfigInfo},[s.promptNames.icon]:{hide:!0,...e?.icon},[s.promptNames.additionalParameters]:{hide:!0,...e?.additionalParameters},[s.promptNames.confirmReplace]:{hide:!0,...e?.confirmReplace}}};const o=n(76760),s=n(1484)},99581(e){e.exports=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."}}')}};