@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 2.88 kB
JavaScript
;exports.id=3380,exports.ids=[3380],exports.modules={88167(a,e,n){n.d(e,{dK:()=>applyCAPUpdates,mF:()=>p.mF,Od:()=>getAppLaunchText});var p=n(7083),s=n(54700),i=n(73024),c=n(76760);function getCDSWatchScript(a,e){const n=e??a+"/webapp";return{[`watch-${a}`]:`cds watch --open ${n}/index.html?sap-ui-xx-viewCache=false${e?" --livereload false":""}`}}async function updateScripts(a,e,{projectPath:n,projectName:s,appsPath:o,appId:r},d){let u={};d?(Object.assign(u,await async function updateExistingWatchScripts(a,e,n,s){const o={};if(!s?.scripts)return o;for(const r in s.scripts)if(r.startsWith("watch-")&&s?.scripts?.[r]?.includes("/webapp/")){const s=r.split("-")[1],d=(0,c.join)(e,n,s);if((0,i.existsSync)(d)){const e=(0,c.join)(await(0,p.vv)(d),p.o3.Manifest),n=a.readJSON(e),i=n["sap.app"]?.id;i&&Object.assign(o,getCDSWatchScript(s,i))}}return o}(a,n,o,e)),Object.assign(u,getCDSWatchScript(s,r))):u=getCDSWatchScript(s),function updatePackageJsonWithScripts(a,e,n){a.extendJSON(e,{scripts:n})}(a,(0,c.join)(n,"package.json"),u)}n(1083);var o=n(68801),r=n(56209);const d="cap-config-writer",u=o.createInstance();async function initI18n(){await u.init({resources:{en:{[d]:r}},lng:"en",fallbackLng:"en",defaultNS:d,ns:[d],showSupportNotice:!1})}async function applyCAPUpdates(a,e,n){const{appRoot:i,packageName:o,appId:r,sapux:d=!1,enableCdsUi5Plugin:u=!0,enableTypescript:l=!1,disableRootPackageJsonUpdates:h=!1}=n;h?u&&await(0,s.W)(e.projectPath,a):await async function updateRootPackageJson(a,e,n,i,o,r){const d=(0,c.join)(i.projectPath,"package.json"),u=a.readJSON(d)??{},l=(await(0,p.so)(i.projectPath)).app;if("Node.js"===i?.capType&&(r&&await(0,s.W)(i.projectPath,a),await updateScripts(a,u,{projectPath:i.projectPath,projectName:e,appsPath:l,appId:o},r)),n){const n=(0,c.join)(i.appPath??l,e),p=(0,c.normalize)(n).split(/[\\/]/g).join(c.posix.sep),s=Array.isArray(u?.sapux)?[...u.sapux,p]:[p];a.extendJSON(d,{sapux:s})}}(a,o,d,e,r,u),l&&function updateTsConfig(a,e){const n=(0,c.join)(e,p.o3.Tsconfig);if(a.exists(n)){const e=a.readJSON(n);if(e.compilerOptions.typeRoots){const p=e.compilerOptions.typeRoots,s=p.map(a=>a.replace(/\.\//g,"../../"));a.extendJSON(n,{compilerOptions:{typeRoots:[...p,...s]}})}}}(a,i),"Node.js"===e.capType&&u&&function updateAppPackageJson(a,e){const n=(0,c.join)(e,"package.json"),p=a.readJSON(n)??{};delete p.sapux,p?.scripts&&delete p.scripts["int-test"];for(const a in p.scripts)a.startsWith("start")&&delete p.scripts[a];a.writeJSON(n,p)}(a,i)}async function getAppLaunchText(a,e,n){await initI18n();const p="Java"===a?" (```mvn spring-boot:run```)":"",s=function getCapUrl(a,e,n){return"Java"===a?`http://localhost:8080/${e}/webapp/index.html`:`http://localhost:4004/${n??e+"/webapp"}/index.html`}(a,e,n);return`${function t(a,e){return u.t(a,e)}("launchCapText",{mvnCommand:p,capUrl:s})}`}initI18n().catch(()=>{})}};