UNPKG

@sap/generator-fiori

Version:

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

3 lines (2 loc) 7.43 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var N=Object.create;var c=Object.defineProperty;var u=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var a=(e,o)=>c(e,"name",{value:o,configurable:!0});var P=(e,o)=>{for(var t in o)c(e,t,{get:o[t],enumerable:!0})},_=(e,o,t,p)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of I(o))!T.call(e,s)&&s!==t&&c(e,s,{get:()=>o[s],enumerable:!(p=u(o,s))||p.enumerable});return e};var g=(e,o,t)=>(t=e!=null?N(R(e)):{},_(o||!e||!e.__esModule?c(t,"default",{value:e,enumerable:!0}):t,e)),C=e=>_(c({},"__esModule",{value:!0}),e);var j={};P(j,{default:()=>h});module.exports=C(j);var f=require("../fiori-generator-shared/dist/index.js"),r=g(require("node:fs")),i=require("node:path"),m=g(require("../commonlibs/yeoman-generator/index.js"));var E=g(require("../commonlibs/i18next/index.js"));var d={DEBUG_MSG_ADAPTOR_MATCH_FOUND:"An adaptor has been found matching the specified input data: {{adaptorName}}.",DEBUG_MSG_NO_ADAPTOR_MATCH_FOUND:"No adaptors have been found matching the input data.",DEBUG_MSG_APP_GEN_LAUNCHED_WITH_DATA:"SAP Fiori Generator was launched with the data: {{- inputData}}.",INFO_GENERATOR_ARG_APP_CONFIG:"Path to the application config file or application config as a string.",ERROR_ARG_OR_OPTION_HEADLESS_GENERATOR:"Please provide one of the following: the first argument of the file path to the app config, the first argument of the app config file as a JSON string or an `appconfig` option as a JSON object.",INFO_REMOVING_EXISTING_APP_FOLDER_FORCE_OPTION:"The `--force` option was specified. The existing application at the path: {{-projectPath}} will be overwritten.",ERROR_APP_FOLDER_EXISTS:"A folder with the application name already exists at path: {{- projectPath}}. Choose a different folder.",INFO_APP_TARGET_FOLDER:"An application will be generated at path: {{- targetFolder}}",INFO_DELETING_APPLICATION_CONFIG_FILE:"Deleting application config file: {{- filepath}}.",LABEL_SELECTED_TEMPLATE_BREADCRUMB:"Template",CREATE_APP_MESSAGE:"Which template do you want to use?",INFO_MSG_CLI_ARGUMENT_LOG_LEVEL_DESCRIPTION:"Log level settings. Possible options: trace < debug < info < warn < error < fatal < off.",INFO_OPTIONS_DISABLE_GENERATOR_EXTENSIONS:"Disables search and loading of generator extensions.",LOGGING_INITIALISED:"`LogWrapper` initialized at log level: {{logLevel}}.",INFO_MSG_SUB_GENERATOR_FOUND:"The installed generator: {{-generatorInfo.name}}@{{-generatorInfo.version}} has been found at path: {{-generatorInfo.path}}.",INFO_MSG_SUB_GENERATOR_APPLIED:"The generator extension: {{-generatorInfo.name}}@{{-generatorInfo.version}} will be integrated to the SAP Fiori Generator. Steps added: {{-generatorInfo.additionalSteps}}. Extension points added: {{-generatorInfo.extensionsAdded}}.",ERROR_GENERATION_EXITING:"Application generation exited due to the error: {{error}}.",PROJECT_ACCELERATOR_TEXT:"Looking to generate your SAP Fiori elements application directly from your business requirements? Try the ",PROJECT_ACCELERATOR_ACTION_TEXT:"Project Accelerator.",PROJECT_ACCELERATOR_ARIA_LABEL:"Project Accelerator Banner",DEBUG_MSG_HELP_EXTENSION_NOT_INSTALLED:"The required extension '{{extensionId}}' is not installed.",DEBUG_MSG_COMMAND_NOT_REGISTERED:"The required command '{{commandName}}' is not registered.",DEBUG_MSG_FIORI_AI_CHECK_FAILED:"An error occurred when checking the availability of SAP Fiori AI: {{error}}."};var l="common",F=1,O=E.default.createInstance();async function G(){await O.init({resources:{en:{[l]:d}},lng:"en",fallbackLng:"en",defaultNS:l,ns:[l],interpolation:{format:a(function(o){return o?` V${o}`:""},"odataVersionFormatter"),defaultVariables:{defaultProjectNumber:F}},missingInterpolationHandler:a(()=>"","missingInterpolationHandler"),showSupportNotice:!1})}a(G,"initI18n");function n(e,o){return O.t(e,o)}a(n,"t");G().catch(()=>{});var L="fiori-app-sub-gen";function A(e){return`@sap/fiori:${L}${e?"_headless":""}`}a(A,"getFioriAppSubGeneratorName");var D="@sap/fiori:fiori-deployment_headless",b="@sap/fiori:flp-config",h=class extends m.default{static{a(this,"default")}arguments;absAppConfigPath;appConfig;constructor(e,o){super(e,o,{unique:"namespace"}),o.testMode||this.env.lookup({packagePatterns:["@sap/generator-fiori"]});try{if(this.arguments=e,this.argument("appconfig",{type:String,description:n("INFO_GENERATOR_ARG_APP_CONFIG"),required:!1}),!this.options.appconfig)throw Error(n("ERROR_ARG_OR_OPTION_HEADLESS_GENERATOR"));let t;if(typeof this.options.appconfig=="object"?t=this.options.appconfig:(0,r.existsSync)(this.options.appconfig)?(t=JSON.parse((0,r.readFileSync)(this.options.appconfig,"utf-8")),this.absAppConfigPath=(0,i.resolve)(this.options.appconfig)):t=JSON.parse(this.options.appconfig),this.argument("targetfolder",{type:String,required:!1}),this.options.targetfolder?t.project.targetFolder=(0,i.isAbsolute)(this.options.targetfolder)?this.options.targetfolder:(0,i.join)(process.cwd(),t.project.targetFolder||""):t.project.targetFolder&&!(0,i.isAbsolute)(t.project.targetFolder)&&(t.project.targetFolder=(0,i.join)(process.cwd(),t.project.targetFolder||"")),t.service?.capService?.projectPath)this.log(`Target folder determined by cap path: ${t.service.capService.projectPath}`);else{let p=(0,i.join)(t.project.targetFolder||process.cwd(),t.project.name);if((0,r.existsSync)(p))if(this.options.force)this.log(n("INFO_REMOVING_EXISTING_APP_FOLDER_FORCE_OPTION",{projectPath:p})),r.default.rmSync(p,{recursive:!0,force:!0});else throw Error(n("ERROR_APP_FOLDER_EXISTS",{projectPath:p}));this.log(n("INFO_APP_TARGET_FOLDER",{targetFolder:t.project.targetFolder}))}this.appConfig=t}catch(t){throw this.log(n("ERROR_GENERATION_EXITING")),t}}_getTargetFolder(){return this.appConfig.service?.capService?.projectPath?(0,i.join)(this.appConfig.service.capService.projectPath,this.appConfig.service.capService.appPath??(0,f.getCapFolderPathsSync)(this.appConfig.service.capService.projectPath).app):this.options.appConfig.project.targetFolder}async initializing(){let e=A(!0);await this.composeWith(e,{arguments:this.arguments,...Object.assign(this.options,{appConfig:this.appConfig})}),this.options.additionalTelemetryData={AppGenLaunchSource:this.options.appConfig.telemetryData?.generationSourceName??"Headless",AppGenLaunchSourceVersion:this.options.appConfig.telemetryData?.generationSourceVersion??"Not Provided"},this.appConfig.deployConfig&&(this.options.appConfig.project.targetFolder=this._getTargetFolder(),await this.composeWith(D,{arguments:this.arguments,...this.options})),this.appConfig.flpConfig&&await this._addFlpConfig()}async _addFlpConfig(){let e=this.appConfig.flpConfig;this.appConfig.project.targetFolder=this._getTargetFolder();let o={inboundConfig:{semanticObject:e.semanticObject||(0,f.getSemanticObject)(this.appConfig.project.name).replace("#",""),action:e.action,title:e.title},skipPrompt:!0,launchFlpConfigAsSubGenerator:!0,appRootPath:(0,i.join)(this.appConfig.project.targetFolder,this.appConfig.project.name),telemetryData:this.options.additionalTelemetryData};await this.composeWith(b,{arguments:this.arguments,...this.options,...o})}end(){this.options.deleteFile&&(0,r.existsSync)(this.absAppConfigPath)&&(this.log(n("INFO_DELETING_APPLICATION_CONFIG_FILE",{filepath:this.absAppConfigPath})),(0,r.unlinkSync)(this.absAppConfigPath))}};