UNPKG

@sap/generator-fiori

Version:

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

5 lines (4 loc) 22.3 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var Qe=Object.create;var G=Object.defineProperty;var We=Object.getOwnPropertyDescriptor;var ze=Object.getOwnPropertyNames;var Je=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var n=(e,t)=>G(e,"name",{value:t,configurable:!0});var ae=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(o){throw t=0,o}},W=(e,t)=>{for(var o in t)G(e,o,{get:t[o],enumerable:!0})},se=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let a of ze(t))!Xe.call(e,a)&&a!==o&&G(e,a,{get:()=>t[a],enumerable:!(i=We(t,a))||i.enumerable});return e};var z=(e,t,o)=>(o=e!=null?Qe(Je(e)):{},se(t||!e||!e.__esModule?G(o,"default",{value:e,enumerable:!0}):o,e)),Ze=e=>se(G({},"__esModule",{value:!0}),e);var he=ae((St,C)=>{var J=require("fs"),Y=require("path"),et=require("os"),tt=require("crypto"),pe=["\u25C8 encrypted .env [www.dotenvx.com]","\u25C8 secrets for agents [www.dotenvx.com]","\u2301 auth for agents [www.vestauth.com]","\u2318 custom filepath { path: '/custom/path/.env' }","\u2318 enable debugging { debug: true }","\u2318 override existing { override: true }","\u2318 suppress logs { quiet: true }","\u2318 multiple files { path: ['.env.local', '.env'] }"];function ot(){return pe[Math.floor(Math.random()*pe.length)]}n(ot,"_getRandomTip");function w(e){return typeof e=="string"?!["false","0","no","off",""].includes(e.toLowerCase()):!!e}n(w,"parseBoolean");function nt(){return process.stdout.isTTY}n(nt,"supportsAnsi");function rt(e){return nt()?`\x1B[2m${e}\x1B[0m`:e}n(rt,"dim");var it=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;function at(e){let t={},o=e.toString();o=o.replace(/\r\n?/mg,` `);let i;for(;(i=it.exec(o))!=null;){let a=i[1],s=i[2]||"";s=s.trim();let r=s[0];s=s.replace(/^(['"`])([\s\S]*)\1$/mg,"$2"),r==='"'&&(s=s.replace(/\\n/g,` `),s=s.replace(/\\r/g,"\r")),t[a]=s}return t}n(at,"parse");function st(e){e=e||{};let t=ue(e);e.path=t;let o=l.configDotenv(e);if(!o.parsed){let r=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);throw r.code="MISSING_DATA",r}let i=le(e).split(","),a=i.length,s;for(let r=0;r<a;r++)try{let p=i[r].trim(),f=ct(o,p);s=l.decrypt(f.ciphertext,f.key);break}catch(p){if(r+1>=a)throw p}return l.parse(s)}n(st,"_parseVault");function pt(e){console.error(`\u26A0 ${e}`)}n(pt,"_warn");function R(e){console.log(`\u2506 ${e}`)}n(R,"_debug");function fe(e){console.log(`\u25C7 ${e}`)}n(fe,"_log");function le(e){return e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0?e.DOTENV_KEY:process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0?process.env.DOTENV_KEY:""}n(le,"_dotenvKey");function ct(e,t){let o;try{o=new URL(t)}catch(p){if(p.code==="ERR_INVALID_URL"){let f=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");throw f.code="INVALID_DOTENV_KEY",f}throw p}let i=o.password;if(!i){let p=new Error("INVALID_DOTENV_KEY: Missing key part");throw p.code="INVALID_DOTENV_KEY",p}let a=o.searchParams.get("environment");if(!a){let p=new Error("INVALID_DOTENV_KEY: Missing environment part");throw p.code="INVALID_DOTENV_KEY",p}let s=`DOTENV_VAULT_${a.toUpperCase()}`,r=e.parsed[s];if(!r){let p=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);throw p.code="NOT_FOUND_DOTENV_ENVIRONMENT",p}return{ciphertext:r,key:i}}n(ct,"_instructions");function ue(e){let t=null;if(e&&e.path&&e.path.length>0)if(Array.isArray(e.path))for(let o of e.path)J.existsSync(o)&&(t=o.endsWith(".vault")?o:`${o}.vault`);else t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`;else t=Y.resolve(process.cwd(),".env.vault");return J.existsSync(t)?t:null}n(ue,"_vaultPath");function ce(e){return e[0]==="~"?Y.join(et.homedir(),e.slice(1)):e}n(ce,"_resolveHome");function ft(e){let t=w(process.env.DOTENV_CONFIG_DEBUG||e&&e.debug),o=w(process.env.DOTENV_CONFIG_QUIET||e&&e.quiet);(t||!o)&&fe("loading env from encrypted .env.vault");let i=l._parseVault(e),a=process.env;return e&&e.processEnv!=null&&(a=e.processEnv),l.populate(a,i,e),{parsed:i}}n(ft,"_configVault");function lt(e){let t=Y.resolve(process.cwd(),".env"),o="utf8",i=process.env;e&&e.processEnv!=null&&(i=e.processEnv);let a=w(i.DOTENV_CONFIG_DEBUG||e&&e.debug),s=w(i.DOTENV_CONFIG_QUIET||e&&e.quiet);e&&e.encoding?o=e.encoding:a&&R("no encoding is specified (UTF-8 is used by default)");let r=[t];if(e&&e.path)if(!Array.isArray(e.path))r=[ce(e.path)];else{r=[];for(let u of e.path)r.push(ce(u))}let p,f={};for(let u of r)try{let h=l.parse(J.readFileSync(u,{encoding:o}));l.populate(f,h,e)}catch(h){a&&R(`failed to load ${u} ${h.message}`),p=h}let _=l.populate(i,f,e);if(a=w(i.DOTENV_CONFIG_DEBUG||a),s=w(i.DOTENV_CONFIG_QUIET||s),a||!s){let u=Object.keys(_).length,h=[];for(let T of r)try{let g=Y.relative(process.cwd(),T);h.push(g)}catch(g){a&&R(`failed to load ${T} ${g.message}`),p=g}fe(`injected env (${u}) from ${h.join(",")} ${rt(`// tip: ${ot()}`)}`)}return p?{parsed:f,error:p}:{parsed:f}}n(lt,"configDotenv");function ut(e){if(le(e).length===0)return l.configDotenv(e);let t=ue(e);return t?l._configVault(e):(pt(`you set DOTENV_KEY but you are missing a .env.vault file at ${t}`),l.configDotenv(e))}n(ut,"config");function ht(e,t){let o=Buffer.from(t.slice(-64),"hex"),i=Buffer.from(e,"base64"),a=i.subarray(0,12),s=i.subarray(-16);i=i.subarray(12,-16);try{let r=tt.createDecipheriv("aes-256-gcm",o,a);return r.setAuthTag(s),`${r.update(i)}${r.final()}`}catch(r){let p=r instanceof RangeError,f=r.message==="Invalid key length",_=r.message==="Unsupported state or unable to authenticate data";if(p||f){let u=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");throw u.code="INVALID_DOTENV_KEY",u}else if(_){let u=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");throw u.code="DECRYPTION_FAILED",u}else throw r}}n(ht,"decrypt");function gt(e,t,o={}){let i=!!(o&&o.debug),a=!!(o&&o.override),s={};if(typeof t!="object"){let r=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");throw r.code="OBJECT_REQUIRED",r}for(let r of Object.keys(t))Object.prototype.hasOwnProperty.call(e,r)?(a===!0&&(e[r]=t[r],s[r]=t[r]),i&&R(a===!0?`"${r}" is already defined and WAS overwritten`:`"${r}" is already defined and was NOT overwritten`)):(e[r]=t[r],s[r]=t[r]);return s}n(gt,"populate");var l={configDotenv:lt,_configVault:ft,_parseVault:st,config:ut,decrypt:ht,parse:at,populate:gt};C.exports.configDotenv=l.configDotenv;C.exports._configVault=l._configVault;C.exports._parseVault=l._parseVault;C.exports.config=l.config;C.exports.decrypt=l.decrypt;C.exports.parse=l.parse;C.exports.populate=l.populate;C.exports=l});var Oe=ae(($t,xe)=>{"use strict";var L=require("../commonlibs/async/index.js"),we=require("fs"),ee=require("path");xe.exports=c;c.async=c;c.sync=yt;c.all=bt;c.all.sync=Ct;c.some=vt;c.some.sync=Et;c.first=_t;c.first.sync=Nt;c.every=c.all;c.any=c.some;function c(e,t){L.some(Pe(e),Tt,t)}n(c,"hasbin");function yt(e){return Pe(e).some(At)}n(yt,"hasbinSync");function bt(e,t){L.every(e,c.async,t)}n(bt,"hasbinAll");function Ct(e){return e.every(c.sync)}n(Ct,"hasbinAllSync");function vt(e,t){L.some(e,c.async,t)}n(vt,"hasbinSome");function Et(e){return e.some(c.sync)}n(Et,"hasbinSomeSync");function _t(e,t){L.detect(e,c.async,function(o){t(o||!1)})}n(_t,"hasbinFirst");function Nt(e){var t=e.filter(c.sync);return t.length?t[0]:!1}n(Nt,"hasbinFirstSync");function Pe(e){var t=process.env.PATH||"",o=process.env.PATHEXT||"";return t.replace(/["]+/g,"").split(ee.delimiter).map(function(i){return o.split(ee.delimiter).map(function(a){return ee.join(i,e+a)})}).reduce(function(i,a){return i.concat(a)})}n(Pe,"getPaths");function Tt(e,t){we.stat(e,function(o,i){if(o)return t(!1);t(i.isFile())})}n(Tt,"fileExists");function At(e){try{return we.statSync(e).isFile()}catch{return!1}}n(At,"fileExistsSync")});var xt={};W(xt,{__entries:()=>Pt,__entry_generators_app:()=>Ke,__entry_generators_headless:()=>qe,promptNames:()=>D});module.exports=Ze(xt);var M={};W(M,{default:()=>O,promptNames:()=>D});var re=z(he(),1),E=require("node:path"),S=require("../open-ux-shared/project-access/index.js"),d=require("../open-ux-shared/deploy-config-generator-shared/index.js");var ge=require("node:path");function me(e,t){let o;return typeof e=="string"?o=e:Array.isArray(e)&&(o=e?.[0]),o||(o=t.target),o}n(me,"parseTarget");function de(e){return[{name:"Deployment Configuration",description:`Configure Deployment settings - ${(0,ge.basename)(e)}`}]}n(de,"getYUIDetails");var ye=require("node:path"),be=require("../abap-deploy-config-sub-generator/index.js"),Ce=require("../open-ux-shared/ui5-config/index.js"),ve=require("../open-ux-shared/project-access/index.js");async function Ee(e,t,o,i){let a,s=!1;if(o){let r=await Ce.UI5Config.newInstance(e.read((0,ye.join)(i,t.base??ve.FileName.Ui5Yaml)));a=r.getBackendConfigsFromFioriToolsProxyMiddleware()[0],s=r.getType()===be.DeployProjectType.Library}else a={destination:t.appGenDestination||t.connectedSystem?.destination?.Name,url:t.appGenServiceHost,client:t.appGenClient,scp:!!t.connectedSystem?.backendSystem?.serviceKeys||!1};return{backendConfig:a,isLibrary:s}}n(Ee,"getBackendConfig");var X=require("../open-ux-shared/deploy-config-generator-shared/index.js");var B=n((e,t)=>`${e}_${t}`,"generatorNamespace"),_e="Deployment Configuration Generator",P={name:X.TargetName.ABAP,description:"ABAP"},x={name:X.TargetName.CF,description:"Cloud Foundry"},D;(function(e){e.targetName="targetName"})(D||(D={}));var Te=z(require("../commonlibs/i18next/index.js"),1);var Ne={prompts:{deployTarget:{breadcrumb:"Target Type",message:"Please choose the target."}},debug:{exit:"Exiting the deployment generator",loadingPrompts:"Loading deploy prompts..."},headless:{info:{generatorArgAppConfig:"Path to the application config file or application config as a string.",generatorNameVersion:"Generating application with: {{- generatorName}} {{generatorVersion}}",deletingApplicationConfigFile:"Deleting application config file: {{- filepath}}."},error:{headlessGenOptions:"Please provide one of the following: 1) The first argument of the file path to the application config file, 2) The first argument of the application config file as a JSON string, or 3) The option `appconfig` as a JSON object.",generationExiting:"Application generation exiting due to error: {{- error}}"}}};var Ae=require("../open-ux-shared/inquirer-common/index.js");var De="deploy-config-sub-generator",Z=Te.default.createInstance();async function dt(){await Z.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),Z.addResourceBundle("en",De,Ne),(0,Ae.addi18nResourceBundle)()}n(dt,"initI18n");function m(e,t){return t?.ns||(t=Object.assign(t??{},{ns:De})),Z.t(e,t)}n(m,"t");dt().catch(()=>{});var te=z(Oe(),1),v=require("../cf-deploy-config-sub-generator/index.js"),y=require("../open-ux-shared/deploy-config-generator-shared/index.js"),Se=require("node:fs"),Ie=require("node:path");function Ge(e,t){if(e==="cf"&&!te.default.sync(y.mtaExecutable)||e==="abap"&&!te.default.sync(y.mtaExecutable)&&(0,Se.existsSync)((0,Ie.join)(t,"mta.yaml"))){let o=y.ErrorHandler.getErrorMsgFromType(y.ERROR_TYPE.NO_MTA_BIN);return y.DeploymentGenerator.logger?.warn(o),o}return!0}n(Ge,"isMTAInstalled");function Re(){let e=process.env.API_HUB_API_KEY,t=process.env.API_HUB_TYPE;return e?{apiHubKey:e,apiHubType:t===v.ApiHubType.apiHubEnterprise?v.ApiHubType.apiHubEnterprise:v.ApiHubType.apiHub}:void 0}n(Re,"getEnvApiHubConfig");async function Ve(e,{appPath:t,servicePath:o},i){let a;return i?.apiHubType===v.ApiHubType.apiHubEnterprise&&(o||(o=(await(0,v.loadManifest)(e,t))?.["sap.app"].dataSources?.mainService?.uri),a=(0,y.generateDestinationName)(v.API_BUSINESS_HUB_ENTERPRISE_PREFIX,o)),{destinationName:a,servicePath:o}}n(Ve,"getApiHubOptions");var Fe=require("../abap-deploy-config-sub-generator/index.js"),je=require("../cf-deploy-config-sub-generator/index.js"),ke=require("../open-ux-shared/project-access/index.js"),He=require("../open-ux-shared/ui5-config/index.js"),oe=require("node:path");async function Ye(e,t,o=!1,i=!1,a,s=ke.FileName.Ui5Yaml){let r=a?.apiHubType===je.ApiHubType.apiHubEnterprise,p=e.exists((0,oe.join)(t,".extconfig.json")),f=!1;try{f=(await He.UI5Config.newInstance(e.read((0,oe.join)(t,s)))).getType()===Fe.DeployProjectType.Library}catch{}return r||o?[x]:f||p?[P]:i?[x,P]:[P,x]}n(Ye,"getSupportedTargets");var U=require("../commonlibs/yeoman-ui-types/index.js");function V(e,t){return[{type:"list",name:D.targetName,guiOptions:{breadcrumb:m("prompts.deployTarget.breadcrumb")},message:m("prompts.deployTarget.message"),default:n(()=>e[0].name,"default"),validate:n(o=>Ge(o,t),"validate"),choices:e.map(o=>({name:o.description,value:o.name}))}]}n(V,"getDeployTargetQuestion");var F=require("../open-ux-shared/inquirer-common/index.js"),Be=require("node:path");var b=require("../open-ux-shared/deploy-config-generator-shared/index.js"),$=require("../abap-deploy-config-sub-generator/index.js"),Le=require("../cf-deploy-config-sub-generator/index.js"),$e=require("../open-ux-shared/project-access/index.js");async function ne(e,t,{launchDeployConfigAsSubGenerator:o,launchStandaloneFromYui:i,promptOptions:a,supportedTargets:s,backendConfig:r,cfDestination:p,isCap:f,apiHubConfig:_,isLibrary:u},h){b.DeploymentGenerator.logger?.debug(m("debug.loadingPrompts"));let T=e.exists((0,Be.join)(t.appRootPath,t.config||$e.FileName.UI5DeployYaml)),g=(0,b.showOverwriteQuestion)(T,o,i,t.overwrite),ie=!u&&i&&!await(0,$.indexHtmlExists)(e,t.appRootPath),N=[],H={};(!h||h===b.TargetName.ABAP)&&({prompts:N,answers:H}=await(0,$.getAbapQuestions)({appRootPath:t.appRootPath,connectedSystem:t.connectedSystem,backendConfig:r,configFile:t.config,indexGenerationAllowed:ie,showOverwriteQuestion:g,promptOptions:t?.subGenPromptOptions,logger:b.DeploymentGenerator.logger}));let A=[];(!h||h===b.TargetName.CF)&&(A=await(0,Le.getCFQuestions)({projectRoot:t.projectRoot,isAbapDirectServiceBinding:t.isAbapDirectServiceBinding,cfDestination:p,isCap:f,addOverwrite:g,apiHubConfig:_,promptOptions:t?.subGenPromptOptions}));let Q=[];return h?Q=h===b.TargetName.ABAP?N:A:Q=Dt(t.projectRoot,{supportedTargets:s,abapPrompts:N,cfPrompts:A,promptOptions:a}),{questions:Q,abapAnswers:H}}n(ne,"getSubGenPrompts");function Dt(e,{supportedTargets:t,abapPrompts:o,cfPrompts:i,promptOptions:a}){let s=V(t,e);return s.push(...(0,F.withCondition)(o,r=>r.targetName===b.TargetName.ABAP)),s.push(...(0,F.withCondition)(i,r=>r.targetName===b.TargetName.CF)),a?(0,F.extendWithOptions)(s,a):s}n(Dt,"combineAllPrompts");async function Ue(e,t,o,{launchDeployConfigAsSubGenerator:i,launchStandaloneFromYui:a,promptOptions:s,supportedTargets:r,backendConfig:p,cfDestination:f,isCap:_,apiHubConfig:u,isLibrary:h},T){let g={};if(i){let{questions:N,abapAnswers:H}=await ne(e,t,{launchDeployConfigAsSubGenerator:i,launchStandaloneFromYui:a,promptOptions:s,supportedTargets:r,backendConfig:p,cfDestination:f,isCap:_,apiHubConfig:u,isLibrary:h},T),A=await o(N);Object.assign(g,A,H),g.overwrite=A.overwriteAbapConfig??A.overwriteCfConfig}else g=await o(V([...r],t.projectRoot));return{target:r.find(N=>N.name===g?.targetName||N.name===T)?.name,answers:g}}n(Ue,"promptDeployConfigQuestions");var wt="@sap-ux/deploy-config-sub-generator",O=class extends d.DeploymentGenerator{static{n(this,"default")}appWizard;prompts;genNamespace;launchStandaloneFromYui;apiHubConfig;launchDeployConfigAsSubGenerator;promptOptions;vscode;cfDestination;mtaPath;backendConfig;isLibrary=!1;isCap=!1;target;answers;setPromptsCallback;constructor(e,t){super(e,t),this.appWizard=t.appWizard??U.AppWizard.create(t),this.genNamespace=t.namespace,this.launchDeployConfigAsSubGenerator=t.launchDeployConfigAsSubGenerator??!1,this.promptOptions=t?.subGenPromptOptions,this.target=me(e,t),this.vscode=t.vscode,this.rootGeneratorName()&&this.env.lookup({packagePatterns:[this.rootGeneratorName()]}),this.options.data?.destinationRoot?(this.launchStandaloneFromYui=!0,this.launchDeployConfigAsSubGenerator||=this.options.data.launchDeployConfigAsSubGenerator,this.options.appRootPath=(0,E.join)((0,E.dirname)(this.options.data.destinationRoot),(0,E.basename)(this.options.data.destinationRoot)),this.options.projectRoot=this.options.data.destinationRoot,re.default.config({path:(0,E.join)(this.options.data.destinationRoot,".env"),quiet:!0})):(this.options.projectPath&&this.options.projectName?this.options.appRootPath=(0,E.join)(this.options.projectPath,this.options.projectName):this.options.appRootPath=this.destinationRoot(),re.default.config({quiet:!0}),this.apiHubConfig=this.options.apiHubConfig??Re(),this.launchStandaloneFromYui=!1),this.launchStandaloneFromYui&&(this.appWizard.setHeaderTitle(_e),this.prompts=new U.Prompts(de(this.options.projectRoot)),this.setPromptsCallback=o=>{this.prompts&&this.prompts.setCallback(o)})}async initializing(){await super.initializing();let e=await(0,d.getExtensionGenPromptOpts)(this.env.create.bind(this.env),wt,this.vscode);this.promptOptions={...e,...this.promptOptions};let t=await(0,S.findCapProjectRoot)(this.options.appRootPath);this.isCap=!!t,this.mtaPath=(await(0,S.getMtaPath)(this.options.appRootPath))?.mtaPath,this.isCap&&!this.mtaPath&&(this.target=d.TargetName.CF),await(0,S.getAppType)(this.options.appRootPath)==="Fiori Adaptation"&&(this.target=d.TargetName.ABAP,this.launchDeployConfigAsSubGenerator=!1),this.options.projectRoot=t??(this.mtaPath&&(0,E.dirname)(this.mtaPath))??this.options.appRootPath,{backendConfig:this.backendConfig,isLibrary:this.isLibrary}=await Ee(this.fs,this.options,this.launchStandaloneFromYui,this.options.appRootPath);let{destinationName:a,servicePath:s}=await Ve(this.fs,{appPath:this.options.appRootPath,servicePath:this.options.appGenServicePath});this.options.appGenServicePath||=s,this.cfDestination=a??this.options.appGenDestination??this.backendConfig?.destination}async prompting(){let e=await Ye(this.fs,this.options.appRootPath,this.isCap,!!this.mtaPath,this.apiHubConfig);if(this.target&&(e.find(o=>o.name===this.target)||(0,d.bail)(d.ErrorHandler.unrecognizedTarget(this.target))),!this.target||this.launchDeployConfigAsSubGenerator){let{target:t,answers:o}=await Ue(this.fs,this.options,this.prompt.bind(this),{launchDeployConfigAsSubGenerator:this.launchDeployConfigAsSubGenerator,launchStandaloneFromYui:this.launchStandaloneFromYui,promptOptions:this.promptOptions,supportedTargets:e,backendConfig:this.backendConfig,cfDestination:this.cfDestination,isCap:this.isCap,apiHubConfig:this.apiHubConfig,isLibrary:this.isLibrary},this.target);this.target=t,this.answers=o}this.target?await this._composeWithSubGenerator(this.target,this.answers):(d.DeploymentGenerator.logger?.debug(m("debug.exit")),process.exit(0))}async _composeWithSubGenerator(e,t){try{let o=e,i=this.launchDeployConfigAsSubGenerator?{...this.options,launchStandaloneFromYui:this.launchStandaloneFromYui,launchDeployConfigAsSubGenerator:!0,...t}:{...this.options,launchDeployConfigAsSubGenerator:!1};this.apiHubConfig&&(i.apiHubConfig=this.apiHubConfig),await this.composeWith(B(this.genNamespace,o),i)}catch(o){d.DeploymentGenerator.logger?.error(o.message)}}};var q={};W(q,{default:()=>I});var k=require("node:path"),Me=require("node:fs"),j=require("../open-ux-shared/deploy-config-generator-shared/index.js");var K=require("../fiori-generator-shared/dist/index.js");var I=class extends j.DeploymentGenerator{static{n(this,"default")}genNamespace;absAppConfigPath;appConfig;deployTarget;constructor(e,t){super(e,t),this.genNamespace=t.namespace;try{if(this.argument("appConfig",{type:String,description:m("headless.info.generatorArgAppConfig"),required:!1}),Object.keys(this.options.appConfig??{}).length===0)throw Error(m("headless.error.headlessGenOptions"));typeof this.options.appConfig=="object"?this.appConfig=this.options.appConfig:this.fs.exists(this.options.appConfig)?(this.appConfig=JSON.parse(this.fs.read(this.options.appConfig)),this.absAppConfigPath=(0,k.resolve)(this.options.appConfig)):this.appConfig=JSON.parse(this.options.appConfig),this.deployTarget=this.appConfig.deployConfig?.deployTarget}catch(o){j.DeploymentGenerator.logger?.error(m("headless.error.generationExiting")),this.env.error(o)}}async initializing(){j.DeploymentGenerator.logger?.info(m("headless.info.generatorNameVersion",{generatorName:this.rootGeneratorName(),generatorVersion:this.rootGeneratorVersion()}));let e={AppGenLaunchSource:this.options.appConfig.telemetryData?.generationSourceName??"Headless",AppGenLaunchSourceVersion:this.options.appConfig.telemetryData?.generationSourceVersion??"Not Provided"},t=this.transformExtConfig();if(t&&this.deployTarget){let o=this.deployTarget===K.DeployTarget.CF?x.name:P.name;await this.composeWith(B(this.genNamespace,o),{arguments:this.args,...Object.assign(this.options,t,{telemetryData:e})})}}transformExtConfig(){let e;if(this.deployTarget===K.DeployTarget.CF){let t=this.appConfig.deployConfig;this.appConfig.project.targetFolder&&(e={projectRoot:this.appConfig.project.targetFolder,destinationName:t.destinationName,destinationAuthType:t.destinationAuthType,addManagedAppRouter:t.addToManagedAppRouter,launchDeployConfigAsSubGenerator:!0,appRootPath:(0,k.join)(this.appConfig.project.targetFolder,this.appConfig.project.name),addMTADestination:t.addMTADestination,lcapModeOnly:t.lcapModeOnly,cloudServiceName:t.cloudServiceName})}else if(this.deployTarget===K.DeployTarget.ABAP){let t=this.appConfig.deployConfig;this.appConfig.project.targetFolder&&(e={appRootPath:(0,k.join)(this.appConfig.project.targetFolder,this.appConfig.project.name),destination:t?.destination,url:t?.url??"",client:t?.client,scp:t?.scp,ui5AbapRepo:t?.ui5AbapRepo,description:t?.description,package:t?.package,transport:t?.transport,launchDeployConfigAsSubGenerator:!0})}return e}end(){this.options.deleteFile&&this.fs.exists(this.absAppConfigPath)&&(j.DeploymentGenerator.logger?.info(m("headless.info.deletingApplicationConfigFile",{filepath:this.absAppConfigPath})),(0,Me.unlinkSync)(this.absAppConfigPath))}};var Ke=M&&O?O:M,qe=q&&I?I:q,Pt={"generators/app":Ke,"generators/headless":qe};0&&(module.exports={__entries,__entry_generators_app,__entry_generators_headless,promptNames});