@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 7.85 kB
JavaScript
;exports.id=380,exports.ids=[380],exports.modules={76524:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.enableCdsUi5Plugin=async function enableCdsUi5Plugin(e,n){n||(n=(0,r.create)((0,o.create)()));const a=(0,i.join)(e,"package.json"),c=n.readJSON(a)??{};return(0,s.ensureMinCdsVersion)(c),await(0,s.enableWorkspaces)(e,c),(0,s.addCdsPluginUi5)(c),n.writeJSON(a,c),n};const i=a(16928),o=a(64812),r=a(90718),s=a(7279)},7279:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.ensureMinCdsVersion=function ensureMinCdsVersion(e){(0,i.hasMinCdsVersion)(e)||(e.dependencies??={},e.dependencies["@sap/cds"]=`^${i.MinCdsVersionUi5Plugin}`)},n.enableWorkspaces=async function enableWorkspaces(e,n){let{appWorkspace:a,workspaceEnabled:o,workspacePackages:r}=await(0,i.getWorkspaceInfo)(e,n);if(o)return;0===r.length&&(n.workspaces??=[],Array.isArray(n.workspaces)?r=n.workspaces:(n.workspaces.packages=[],r=n.workspaces.packages));r.push(a)},n.addCdsPluginUi5=function addCdsPluginUi5(e){(0,i.hasDependency)(e,"cds-plugin-ui5")||(e.devDependencies??={},e.devDependencies["cds-plugin-ui5"]="^0.13.0")};const i=a(20787)},81541:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getAppLaunchText=n.applyCAPUpdates=void 0;var i=a(5787);Object.defineProperty(n,"applyCAPUpdates",{enumerable:!0,get:function(){return i.applyCAPUpdates}});var o=a(68288);Object.defineProperty(n,"getAppLaunchText",{enumerable:!0,get:function(){return o.getAppLaunchText}})},34332:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getCDSWatchScript=getCDSWatchScript,n.updateRootPackageJson=async function updateRootPackageJson(e,n,a,s,c,p,l){const u=(0,o.join)(s.projectPath,"package.json"),d=e.readJSON(u)??{};l&&d&&await(0,r.enableCdsUi5Plugin)(s.projectPath,e);"Node.js"===s?.capType&&await async function updateScripts(e,n,a,r,s){const c=await(0,i.checkCdsUi5PluginEnabled)((0,o.dirname)(n),e);let p;p=s||c?getCDSWatchScript(a,r):getCDSWatchScript(a);!function updatePackageJsonWithScripts(e,n,a){e.extendJSON(n,{scripts:a})}(e,n,p)}(e,u,n,c,l);if(a){const a=(0,o.join)(s.appPath??(await(0,i.getCapCustomPaths)(s.projectPath)).app,n),r=(0,o.normalize)(a).split(/[\\/]/g).join(o.posix.sep),c=Array.isArray(d?.sapux)?[...d.sapux,r]:[r];e.extendJSON(u,{sapux:c})}},n.updateAppPackageJson=function updateAppPackageJson(e,n){const a=(0,o.join)(n,"package.json"),i=e.readJSON(a)??{};delete i.sapux,i?.scripts&&delete i.scripts["int-test"];for(const e in i.scripts)e.startsWith("start")&&delete i.scripts[e];e.writeJSON(a,i)};const i=a(20787),o=a(16928),r=a(76524);function getCDSWatchScript(e,n){return{[`watch-${e}`]:`cds watch --open ${n??e+"/webapp"}/index.html?sap-ui-xx-viewCache=false${n?" --livereload false":""}`}}},15565:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updatePomXml=function updatePomXml(e,n,a){try{const a=function readPomXml(e,n){return e.read(n).toString()}(e,n),o=(0,i.xml2js)(a,{compact:!1,ignoreComment:!1}),r="spring-boot-maven-plugin";if(0===Object.keys(o).length)return;const s=o.elements.filter((e=>"project"===e.name))?.[0].elements.filter((e=>"build"===e.name))?.[0].elements.filter((e=>"plugins"===e.name))?.[0].elements.filter((e=>"plugin"===e.name))?.filter((e=>e?.elements?.some((e=>"artifactId"===e.name&&(e.elements??[]).some((e=>e.text===r))))))?.[0].elements?.filter((e=>"configuration"===e.name))?.[0];s&&(!function addWorkspaceElement(e){if(!e?.elements||function checkIfNameExists(e,n){return e?.some((e=>e.name===n))}(e.elements,"workingDirectory"))return!1;return e.elements.push({type:"element",name:"workingDirectory",elements:[{type:"text",text:".."}]}),!0}(s),function writePomXml(e,n,a){const o=(0,i.js2xml)(a,{compact:!1,ignoreComment:!1,spaces:4}),r=/&gt/g;e.write(n,o.replace(r,">"))}(e,n,o))}catch(e){a?.error(e)}};const i=a(1940)},85432:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.updateTsConfig=function updateTsConfig(e,n){const a=(0,r.join)(n,i.FileName.Tsconfig);if(e.exists(a)){const n=e.readJSON(a);if(n.compilerOptions.typeRoots){const i=n.compilerOptions.typeRoots,o=i.map((e=>e.replace(/\.\//g,"../../")));e.extendJSON(a,{compilerOptions:{typeRoots:[...i,...o]}})}}},n.updateStaticLocationsInApplicationYaml=async function updateStaticLocationsInApplicationYaml(e,n,a,i){try{const i=e.read(n).toString(),r=await o.YamlDocument.newInstance(i),s=JSON.stringify(r),c=JSON.parse(s).documents;if(1===c.length&&void 0===c[0].spring["web.resources.static-locations"]){const i=c[0];i.spring["web.resources.static-locations"]=`file:./${a}`,e.write(n,(0,o.yamlDocumentToYamlString)(i))}}catch(e){i?.error((0,s.t)("error.updateApplicationYaml",{error:e}))}};const i=a(20787),o=a(55968),r=a(16928),s=a(34058)},5787:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.applyCAPUpdates=async function applyCAPUpdates(e,n,a,p){const{appRoot:l,packageName:u,appId:d,sapux:g=!1,enableNPMWorkspaces:m=!1,enableCdsUi5Plugin:f=!1,enableTypescript:h=!1}=a;if(await(0,o.updateRootPackageJson)(e,u,g,n,d,p,m),"Java"===n.capType){const a=n.projectPath,o=(0,i.getCapFolderPathsSync)(a),l=(0,c.join)(a,"pom.xml");e.exists(l)&&(0,s.updatePomXml)(e,l,p);const u=(0,c.join)(a,o.srv,"src","main","resources","application.yaml");e.exists(u)&&await(0,r.updateStaticLocationsInApplicationYaml)(e,u,o.app,p)}h&&(0,r.updateTsConfig)(e,l);(f||m)&&(0,o.updateAppPackageJson)(e,l)};const i=a(58012),o=a(34332),r=a(85432),s=a(15565),c=a(16928)},68288:(e,n,a)=>{Object.defineProperty(n,"__esModule",{value:!0}),n.getAppLaunchText=async function getAppLaunchText(e,n,a){await(0,i.initI18n)();const o="Java"===e?" (```mvn spring-boot:run```)":"",r=function getCapUrl(e,n,a){const i=a??n+"/webapp";return"Java"===e?`http://localhost:8080/${n}/webapp/index.html`:`http://localhost:4004/${i}/index.html`}(e,n,a);return`${(0,i.t)("launchCapText",{mvnCommand:o,capUrl:r})}`};const i=a(34058)},34058:function(e,n,a){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(n,"__esModule",{value:!0}),n.i18n=void 0,n.initI18n=initI18n,n.t=function t(e,a){return n.i18n.t(e,a)};const o=i(a(68801)),r=i(a(56209)),s="cap-config-writer";async function initI18n(){await n.i18n.init({resources:{en:{[s]:r.default}},lng:"en",fallbackLng:"en",defaultNS:s,ns:[s]})}n.i18n=o.default.createInstance(),initI18n().catch((()=>{}))},64872:function(e,n,a){var i=this&&this.__createBinding||(Object.create?function(e,n,a,i){void 0===i&&(i=a);var o=Object.getOwnPropertyDescriptor(n,a);o&&!("get"in o?!n.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return n[a]}}),Object.defineProperty(e,i,o)}:function(e,n,a,i){void 0===i&&(i=a),e[i]=n[a]}),o=this&&this.__exportStar||function(e,n){for(var a in e)"default"===a||Object.prototype.hasOwnProperty.call(n,a)||i(n,e,a)};Object.defineProperty(n,"__esModule",{value:!0}),n.enableCdsUi5Plugin=n.checkCdsUi5PluginEnabled=void 0;const r=a(20787);Object.defineProperty(n,"checkCdsUi5PluginEnabled",{enumerable:!0,get:function(){return r.checkCdsUi5PluginEnabled}});var s=a(76524);Object.defineProperty(n,"enableCdsUi5Plugin",{enumerable:!0,get:function(){return s.enableCdsUi5Plugin}}),o(a(81541),n)},56209:e=>{e.exports=JSON.parse('{"info":{"capServiceName":"CAP Service Name: {{ capServiceName }}.","cdsUpdateInfo":"Update CDS file with `projectPath`: {{ projectPath }}, `annotationPath`: {{ annotationPath }} and `capService`: {{ capService }}."},"warn":{"cdsDKNotInstalled":"`cds-dk` {{ minCdsVersion }} or higher is required to add CDS watch scripts. Install `cds-dk` to continue."},"error":{"updateApplicationYaml":"An error occured when updating the application YAML. Error: {{ error }}."},"launchCapText":"To launch the generated app, start your CAP project: {{mvnCommand}} and navigate to the following location in your browser:\\n\\n{{- capUrl}}"}')}};