@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 3.39 kB
JavaScript
"use strict";exports.id=6877,exports.ids=[6877],exports.modules={99561(e,r,s){s.r(r),s.d(r,{default:()=>y});var n=s(91170),o=s(73667),a=s(76760),i=s(94443);class ReuseLibGenLogger{static _logger=i.DefaultLogger;static get logger(){return ReuseLibGenLogger._logger}static set logger(e){ReuseLibGenLogger._logger=e}static configureLogging(e,r,s,n,o){const a=new i.LogWrapper(r,s,o,e,n);ReuseLibGenLogger.logger=a}}var g=s(68801);const c=JSON.parse('{"info":{"openingAppInfo":"Opening application info...","installingDependencies":"Installing dependencies...","dependenciesInstalled":"Library dependencies have been installed."},"error":{"unknown":"Unknown error.","generatingUi5Lib":"An error occurred when generating the reusable SAPUI5 library.","postLibGenHook":"Failed to run hook after library generation: {{- error}}"}}'),l="ui5-lib-generator",p=g.createInstance();function t(e,r){return r?.ns||(r=Object.assign(r??{},{ns:l})),p.t(e,r)}(async function initI18n(){await p.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),p.addResourceBundle("en",l,c)})().catch(()=>{});const d=[{name:"Generate UI5 Library",description:"Create a Reusable Library for use in SAP Fiori applications"}];var h=s(77947),u=s(48161),b=s(28470),L=s(86985);const w=L.NI;var m=s(29511),f=s(62108);const y=class extends n{answers={};prompts;appWizard;targetFolder;vscode;projectPath;setPromptsCallback;constructor(e,r){super(e,r),this.appWizard=o.AppWizard.create(r),this.vscode=r.vscode,ReuseLibGenLogger.configureLogging(this.options.logger,this.rootGeneratorName(),this.log,this.options.vscode,this.options.logLevel),this.targetFolder=(0,i.getDefaultTargetFolder)(this.options.vscode)??process.cwd(),this.appWizard.setHeaderTitle("SAP Fiori Reusable Library"),this.prompts=new o.Prompts(d),this.setPromptsCallback=e=>{this.prompts&&this.prompts.setCallback(e)}}async prompting(){const e=(0,i.isCli)();let r;r=this.env?.adapter?.actualAdapter?this.env.adapter.actualAdapter:this.env?.adapter;const s=await(0,f.J)({targetFolder:this.targetFolder,includeSeparators:!e,useAutocomplete:e},r);Object.assign(this.answers,s)}async writing(){const e={libraryName:this.answers.libraryName??"library1",namespace:this.answers.namespace??"com.myorg",framework:"SAPUI5",frameworkVersion:this.answers.ui5Version??w,author:"Fiori tools",typescript:this.answers.enableTypescript};this.answers.targetFolder&&(this.targetFolder=this.answers.targetFolder,this.projectPath=(0,a.join)(this.targetFolder,`${this.answers.namespace}.${this.answers.libraryName}`));try{await(0,m.c)(this.targetFolder,e,this.fs),(0,h.ll)(this.projectPath)}catch(e){throw ReuseLibGenLogger.logger.error(e),new Error(t("error.generatingUi5Lib"))}}async install(){if(!this.options.skipInstall)try{const e=new b.qo,r="win32"===(0,u.platform)()?"npm.cmd":"npm";ReuseLibGenLogger.logger.info(t("info.installingDependencies")),await e.run(r,["install"],{cwd:this.projectPath}),ReuseLibGenLogger.logger.info(t("info.dependenciesInstalled"))}catch(e){ReuseLibGenLogger.logger.error(e||t("error.unknown"))}}async end(){ReuseLibGenLogger.logger.info(t("info.openingAppInfo")),await async function runPostLibGenHook(e){try{await(e.vscodeInstance?.commands?.executeCommand?.("sap.ux.library.generated.handler",{fsPath:e.path}))}catch(e){ReuseLibGenLogger.logger.error(t("error.postLibGenHook",{error:e}))}}({path:this.projectPath,vscodeInstance:this.vscode})}}}};