@sap/generator-fiori
Version:
Create an SAPUI5 application using SAP Fiori elements or a freestyle approach
1 lines • 7.12 kB
JavaScript
;exports.id=3380,exports.ids=[3380],exports.modules={76524(e,n,a){Object.defineProperty(n,"__esModule",{value:!0}),n.enableCdsUi5Plugin=async function enableCdsUi5Plugin(e,n){n||(n=(0,o.create)((0,s.create)()));const a=(0,i.join)(e,"package.json"),r=n.readJSON(a)??{},p=structuredClone(r);(0,c.ensureMinCdsVersion)(r),await(0,c.enableWorkspaces)(e,r),(0,c.addCdsPluginUi5)(r),JSON.stringify(p)!==JSON.stringify(r)&&n.writeJSON(a,r);return n};const i=a(76760),s=a(64812),o=a(90718),c=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.MinCdsVersion}`)},n.enableWorkspaces=async function enableWorkspaces(e,n){let{appWorkspace:a,workspaceEnabled:s,workspacePackages:o}=await(0,i.getWorkspaceInfo)(e,n);if(s)return;0===o.length&&(n.workspaces??=[],Array.isArray(n.workspaces)?o=n.workspaces:(n.workspaces.packages=[],o=n.workspaces.packages));o.push(a)},n.addCdsPluginUi5=function addCdsPluginUi5(e){(0,i.hasDependency)(e,"cds-plugin-ui5")||(e.devDependencies??={},e.devDependencies["cds-plugin-ui5"]=`^${i.MinCdsPluginUi5Version}`)};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 s=a(68288);Object.defineProperty(n,"getAppLaunchText",{enumerable:!0,get:function(){return s.getAppLaunchText}})},34332(e,n,a){Object.defineProperty(n,"__esModule",{value:!0}),n.getCDSWatchScript=getCDSWatchScript,n.updateRootPackageJson=async function updateRootPackageJson(e,n,a,r,p,d){const u=(0,o.join)(r.projectPath,"package.json"),l=e.readJSON(u)??{},g=(await(0,s.getCapCustomPaths)(r.projectPath)).app;"Node.js"===r?.capType&&(d&&await(0,c.enableCdsUi5Plugin)(r.projectPath,e),await async function updateScripts(e,n,{projectPath:a,projectName:c,appsPath:r,appId:p},d){let u={};d?(Object.assign(u,await async function updateExistingWatchScripts(e,n,a,c){const r={};if(!c?.scripts)return r;for(const p in c.scripts)if(p.startsWith("watch-")&&c?.scripts?.[p]?.includes("/webapp/")){const c=p.split("-")[1],d=(0,o.join)(n,a,c);if((0,i.existsSync)(d)){const n=(0,o.join)(await(0,s.getWebappPath)(d),s.FileName.Manifest),a=e.readJSON(n),i=a["sap.app"]?.id;i&&Object.assign(r,getCDSWatchScript(c,i))}}return r}(e,a,r,n)),Object.assign(u,getCDSWatchScript(c,p))):u=getCDSWatchScript(c);!function updatePackageJsonWithScripts(e,n,a){e.extendJSON(n,{scripts:a})}(e,(0,o.join)(a,"package.json"),u)}(e,l,{projectPath:r.projectPath,projectName:n,appsPath:g,appId:p},d));if(a){const a=(0,o.join)(r.appPath??g,n),i=(0,o.normalize)(a).split(/[\\/]/g).join(o.posix.sep),s=Array.isArray(l?.sapux)?[...l.sapux,i]:[i];e.extendJSON(u,{sapux:s})}},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(73024),s=a(20787),o=a(76760),c=a(76524);function getCDSWatchScript(e,n){const a=n??e+"/webapp";return{[`watch-${e}`]:`cds watch --open ${a}/index.html?sap-ui-xx-viewCache=false${n?" --livereload false":""}`}}},85432(e,n,a){Object.defineProperty(n,"__esModule",{value:!0}),n.updateTsConfig=function updateTsConfig(e,n){const a=(0,o.join)(n,i.FileName.Tsconfig);if(e.exists(a)){const n=e.readJSON(a);if(n.compilerOptions.typeRoots){const i=n.compilerOptions.typeRoots,s=i.map(e=>e.replace(/\.\//g,"../../"));e.extendJSON(a,{compilerOptions:{typeRoots:[...i,...s]}})}}},n.updateStaticLocationsInApplicationYaml=async function updateStaticLocationsInApplicationYaml(e,n,a,i){try{const i=e.read(n).toString(),o=await s.YamlDocument.newInstance(i),c=JSON.stringify(o),r=JSON.parse(c).documents;if(1===r.length&&void 0===r[0].spring["web.resources.static-locations"]){const i=r[0];i.spring["web.resources.static-locations"]=`file:./${a}`,e.write(n,(0,s.yamlDocumentToYamlString)(i))}}catch(e){i?.error((0,c.t)("error.updateApplicationYaml",{error:e}))}};const i=a(20787),s=a(55968),o=a(76760),c=a(34058)},5787(e,n,a){Object.defineProperty(n,"__esModule",{value:!0}),n.applyCAPUpdates=async function applyCAPUpdates(e,n,a){const{appRoot:c,packageName:r,appId:p,sapux:d=!1,enableCdsUi5Plugin:u=!0,enableTypescript:l=!1,disableRootPackageJsonUpdates:g=!1}=a;g?u&&await(0,o.enableCdsUi5Plugin)(n.projectPath,e):await(0,i.updateRootPackageJson)(e,r,d,n,p,u);l&&(0,s.updateTsConfig)(e,c);"Node.js"===n.capType&&u&&(0,i.updateAppPackageJson)(e,c)};const i=a(34332),s=a(85432),o=a(76524)},68288(e,n,a){Object.defineProperty(n,"__esModule",{value:!0}),n.getAppLaunchText=async function getAppLaunchText(e,n,a){await(0,i.initI18n)();const s="Java"===e?" (```mvn spring-boot:run```)":"",o=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:s,capUrl:o})}`};const i=a(34058)},34058(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 s=i(a(68801)),o=i(a(56209)),c="cap-config-writer";async function initI18n(){await n.i18n.init({resources:{en:{[c]:o.default}},lng:"en",fallbackLng:"en",defaultNS:c,ns:[c],showSupportNotice:!1})}n.i18n=s.default.createInstance(),initI18n().catch(()=>{})},64872(e,n,a){var i=this&&this.__createBinding||(Object.create?function(e,n,a,i){void 0===i&&(i=a);var s=Object.getOwnPropertyDescriptor(n,a);s&&!("get"in s?!n.__esModule:s.writable||s.configurable)||(s={enumerable:!0,get:function(){return n[a]}}),Object.defineProperty(e,i,s)}:function(e,n,a,i){void 0===i&&(i=a),e[i]=n[a]}),s=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 o=a(20787);Object.defineProperty(n,"checkCdsUi5PluginEnabled",{enumerable:!0,get:function(){return o.checkCdsUi5PluginEnabled}});var c=a(76524);Object.defineProperty(n,"enableCdsUi5Plugin",{enumerable:!0,get:function(){return c.enableCdsUi5Plugin}}),s(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}}"}')}};