@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 7.76 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,s.create)((0,o.create)()));const a=(0,i.join)(e,"package.json"),c=n.readJSON(a)??{};return(0,r.ensureMinCdsVersion)(c),await(0,r.enableWorkspaces)(e,c),(0,r.addCdsPluginUi5)(c),n.writeJSON(a,c),n};const i=a(16928),o=a(64812),s=a(90718),r=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:s}=await(0,i.getWorkspaceInfo)(e,n);if(o)return;0===s.length&&(n.workspaces??=[],Array.isArray(n.workspaces)?s=n.workspaces:(n.workspaces.packages=[],s=n.workspaces.packages));s.push(a)},n.addCdsPluginUi5=function addCdsPluginUi5(e){(0,i.hasDependency)(e,"cds-plugin-ui5")||(e.devDependencies??={},e.devDependencies["cds-plugin-ui5"]="^0.9.3")};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,r,c,p,l){const u=(0,o.join)(r.projectPath,"package.json"),d=e.readJSON(u)??{};l&&d&&await(0,s.enableCdsUi5Plugin)(r.projectPath,e);"Node.js"===r?.capType&&await async function updateScripts(e,n,a,s,r){const c=await(0,i.checkCdsUi5PluginEnabled)((0,o.dirname)(n),e);let p;p=r||c?getCDSWatchScript(a,s):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)(r.appPath??(await(0,i.getCapCustomPaths)(r.projectPath)).app,n),s=(0,o.normalize)(a).split(/[\\/]/g).join(o.posix.sep),c=Array.isArray(d?.sapux)?[...d.sapux,s]:[s];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),s=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}),s="spring-boot-maven-plugin";if(0===Object.keys(o).length)return;const r=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===s))))))?.[0].elements?.filter((e=>"configuration"===e.name))?.[0];r&&(!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}(r),function writePomXml(e,n,a){const o=(0,i.js2xml)(a,{compact:!1,ignoreComment:!1,spaces:4}),s=/&gt/g;e.write(n,o.replace(s,">"))}(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,s.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(),s=await o.YamlDocument.newInstance(i),r=JSON.stringify(s),c=JSON.parse(r).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,r.t)("error.updateApplicationYaml",{error:e}))}};const i=a(20787),o=a(55968),s=a(16928),r=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:m=!1,enableNPMWorkspaces:f=!1,enableCdsUi5Plugin:g=!1,enableTypescript:h=!1}=a;if(await(0,o.updateRootPackageJson)(e,u,m,n,d,p,f),"Java"===n.capType){const a=n.projectPath,o=(0,i.getCapFolderPathsSync)(a),l=(0,c.join)(a,"pom.xml");e.exists(l)&&(0,r.updatePomXml)(e,l,p);const u=(0,c.join)(a,o.srv,"src","main","resources","application.yaml");e.exists(u)&&await(0,s.updateStaticLocationsInApplicationYaml)(e,u,o.app,p)}h&&(0,s.updateTsConfig)(e,l);(g||f)&&(0,o.updateAppPackageJson)(e,l)};const i=a(58012),o=a(34332),s=a(85432),r=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```)":"",s=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:s})}`};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.initI18n=initI18n,n.t=function t(e,n){return o.default.t(e,n)};const o=i(a(7077)),s=i(a(56209)),r="cap-config-writer";async function initI18n(){await o.default.init({resources:{en:{[r]:s.default}},lng:"en",fallbackLng:"en",defaultNS:r,ns:[r]})}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 s=a(20787);Object.defineProperty(n,"checkCdsUi5PluginEnabled",{enumerable:!0,get:function(){return s.checkCdsUi5PluginEnabled}});var r=a(76524);Object.defineProperty(n,"enableCdsUi5Plugin",{enumerable:!0,get:function(){return r.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 }}, capService: {{ capService }}."},"warn":{"cdsDKNotInstalled":"minimum cds-dk {{ minCdsVersion }} version is required to add cds watch scripts"},"error":{"updateApplicationYaml":"Error occured while updating application yaml {{ error }}"},"launchCapText":"In order to launch the generated app, simply start your CAP project{{mvnCommand}} and navigate to the following location in your browser:\\n\\n{{- capUrl}}"}')}};