@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
3 lines (2 loc) • 7.74 kB
JavaScript
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href;
var q=Object.create;var m=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var s=(t,e)=>m(t,"name",{value:e,configurable:!0});var F=(t,e)=>{for(var i in e)m(t,i,{get:e[i],enumerable:!0})},A=(t,e,i,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of H(e))!V.call(t,n)&&n!==i&&m(t,n,{get:()=>e[n],enumerable:!(o=K(e,n))||o.enumerable});return t};var G=(t,e,i)=>(i=t!=null?q(J(t)):{},A(e||!t||!t.__esModule?m(i,"default",{value:t,enumerable:!0}):i,t)),B=t=>A(m({},"__esModule",{value:!0}),t);var tt={};F(tt,{__entries:()=>Z,__entry_generators_app:()=>j,promptNames:()=>u.promptNames});module.exports=B(tt);var x={};F(x,{default:()=>g,promptNames:()=>u.promptNames});var E=require("node:path"),D=G(require("../commonlibs/yeoman-generator/index.js"),1);var P=require("../fiori-generator-shared/dist/index.js");var a=class t{static{s(this,"FlpGenLogger")}static _logger=P.DefaultLogger;static get logger(){return t._logger}static set logger(e){t._logger=e}static configureLogging(e,i,o,n,c,b){let w=o??new P.LogWrapper(e,i,n,c,b);t.logger=w}};var f=require("../commonlibs/yeoman-ui-types/index.js"),d=require("../open-ux-shared/deploy-config-generator-shared/index.js"),u=require("../open-ux-shared/flp-config-inquirer/index.js"),L=require("../app-config-writer/dist/index.js"),p=require("../open-ux-shared/project-access/index.js"),k=require("../open-ux-shared/i18n/index.js"),U=require("../open-ux-shared/feature-toggle/index.js"),r=require("../fiori-generator-shared/dist/index.js"),Y=require("../open-ux-shared/inquirer-common/index.js");var S="flpTitle",_="flpSubtitle",R="Fiori Launchpad Configuration Generator";var W=G(require("../commonlibs/i18next/index.js"),1);var O={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."}};var $="flp-config-generator",v=W.default.createInstance();async function Q(){await v.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),v.addResourceBundle("en",$,O)}s(Q,"initI18n");function h(t,e){return e?.ns||(e=Object.assign(e??{},{ns:$})),v.t(t,e)}s(h,"t");Q().catch(()=>{});var M=require("node:path"),l=require("../open-ux-shared/flp-config-inquirer/index.js");function I(t){return[{name:"Fiori Launchpad Configuration",description:`Configure Fiori Launchpad settings - ${(0,M.basename)(t)}`}]}s(I,"getYUIDetails");function N(t){return{...t,[l.promptNames.inboundId]:{hide:!0,...t?.inboundId},[l.promptNames.existingFlpConfigInfo]:{hide:!0,...t?.existingFlpConfigInfo},[l.promptNames.icon]:{hide:!0,...t?.icon},[l.promptNames.additionalParameters]:{hide:!0,...t?.additionalParameters},[l.promptNames.confirmReplace]:{hide:!0,...t?.confirmReplace}}}s(N,"getPromptOptions");var C;(function(t){t.GENERATION_SUCCESS="GENERATION_SUCCESS"})(C||(C={}));var z="@sap-ux/flp-config-sub-generator",g=class extends D.default{static{s(this,"default")}appWizard;vscode;launchFlpConfigAsSubGenerator;existingApp;appRootPath;prompts;answers;abort=!1;manifest;manifestPath;promptOptions;options;setPromptsCallback;constructor(t,e){super(t,e),this.appWizard=e.appWizard??f.AppWizard.create(e),this.vscode=e.vscode,this.launchFlpConfigAsSubGenerator=e.launchFlpConfigAsSubGenerator??!1,this.appRootPath=e.data?.appRootPath??e?.appRootPath??this.destinationRoot(),this.promptOptions=this.options?.inquirerPromptOptions,this.options=e,a.configureLogging(this.rootGeneratorName(),this.log,this.options.logWrapper,this.options.logLevel,this.options.logger,this.vscode),this.launchFlpConfigAsSubGenerator||(this.appWizard.setHeaderTitle(R),this.prompts=new f.Prompts(I(this.appRootPath)),this.setPromptsCallback=i=>{this.prompts&&this.prompts.setCallback(i)},this.existingApp=!0)}async initializing(){(0,r.setYeomanEnvConflicterForce)(this.env,this.options.force);let t=await(0,d.getExtensionGenPromptOpts)(this.env.create.bind(this.env),z,this.vscode);this.promptOptions={...t,...this.promptOptions},await r.TelemetryHelper.initTelemetrySettings({consumerModule:{name:z,version:this.rootGeneratorVersion()},internalFeature:(0,U.isInternalFeaturesSettingEnabled)(),watchTelemetrySettingStore:!1}),this.existingApp&&(this.manifestPath=(0,E.join)(await(0,p.getWebappPath)(this.appRootPath),p.FileName.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),this.manifest||(0,d.handleErrorMessage)(this.appWizard,{errorMsg:h("error.noManifest",{path:this.manifestPath})}),this.manifest["sap.app"]||(0,d.handleErrorMessage)(this.appWizard,{errorMsg:h("error.sapNotDefined")}))}async prompting(){if(this.launchFlpConfigAsSubGenerator&&this.options.inboundConfig?.semanticObject!==void 0&&this.options.inboundConfig?.action!==void 0&&this.options.inboundConfig?.title!==void 0&&this.options.skipPrompt){this.answers={overwrite:!0,semanticObject:this.options.inboundConfig.semanticObject,action:this.options.inboundConfig.action,title:this.options.inboundConfig.title,subTitle:this.options.inboundConfig.subTitle};return}let t={};this.manifest?.["sap.app"]?.crossNavigation?.inbounds&&(t=this.manifest?.["sap.app"]?.crossNavigation?.inbounds);let e=this.options.overwrite,i=await(0,u.getPrompts)(t,{silentOverwrite:e,...N(this.promptOptions)});this.promptOptions&&(i=(0,Y.extendWithOptions)(i,this.promptOptions)),this.answers={};let o=await this.prompt(i);(o.s4Continue===!1||o.overwrite===!1&&!e)&&(this.abort=!0,process.exit(0)),o.subTitle===""&&(o.subTitle=void 0),Object.assign(this.answers,o)}async writing(){this.abort===!1&&this.existingApp&&await this._updateFiles(this.answers)}async _updateFiles({semanticObject:t,action:e,title:i,subTitle:o}){let n=!1;i&&(n=await this._updateI18n(this.manifestPath,this.manifest,{semanticObject:t,action:e,title:i,subTitle:o})),await(0,L.generateInboundNavigationConfig)(this.appRootPath,{semanticObject:t,action:e,title:n?`{{${t}-${e}.${S}}}`:i,subTitle:n&&o?`{{${t}-${e}.${_}}}`:o},!0,this.fs)}async _updateI18n(t,e,{semanticObject:i,action:o,title:n,subTitle:c}){let b=!1,{"sap.app":w}=await(0,p.getI18nPropertiesPaths)(t,e);try{let y=[{key:`${i}-${o}.${S}`,value:n}];c&&y.push({key:`${i}-${o}.${_}`,value:c}),b=await(0,k.createPropertiesI18nEntries)(w,y,this.appRootPath,this.fs)}catch{let T=h("warning.updatei18n",{path:w});this.appWizard.showWarning(T,f.MessageType.notification),a.logger?.error(T)}return b}async end(){if(!(this.abort||this.answers.overwrite===!1)){this.abort===!1&&!this.existingApp&&(this.manifestPath=(0,E.join)(await(0,p.getWebappPath)(this.appRootPath),p.FileName.Manifest),this.manifest=this.fs.readJSON(this.manifestPath),await this._updateFiles(this.answers));try{!this.options.launchFlpConfigAsSubGenerator&&(0,r.isExtensionInstalled)(this.vscode,r.YUI_EXTENSION_ID,r.YUI_MIN_VER_FILES_GENERATED_MSG)&&this.appWizard?.showInformation(h("info.filesGenerated"),f.MessageType.notification),(0,r.sendTelemetry)(C.GENERATION_SUCCESS,r.TelemetryHelper.createTelemetryData({appType:"flp-config",...this.options.telemetryData})??{}).catch(t=>{a.logger.error(h("error.telemetry",{error:t}))})}catch(t){a.logger?.error(h("error.endPhase",{error:t}))}}}};var j=x&&g?g:x,Z={"generators/app":j};0&&(module.exports={__entries,__entry_generators_app,promptNames});