UNPKG

@sap/generator-fiori

Version:

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

3 lines (2 loc) 5.81 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var L=Object.create;var f=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var s=(t,e)=>f(t,"name",{value:e,configurable:!0});var z=(t,e)=>{for(var o in e)f(t,o,{get:e[o],enumerable:!0})},b=(t,e,o,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of R(e))!E.call(t,r)&&r!==o&&f(t,r,{get:()=>e[r],enumerable:!(n=M(e,r))||n.enumerable});return t};var y=(t,e,o)=>(o=t!=null?L(T(t)):{},b(e||!t||!t.__esModule?f(o,"default",{value:t,enumerable:!0}):o,t)),H=t=>b(f({},"__esModule",{value:!0}),t);var Q={};z(Q,{CommandRunner:()=>p,ProxyValidationStatus:()=>d,default:()=>K,ensureValidYoVersion:()=>J,findInstalledPackages:()=>X,i18n:()=>v,initI18nNodejsUtils:()=>N,setGlobalRejectUnauthorized:()=>D,t:()=>h,validateProxySettings:()=>B});module.exports=H(Q);var A=require("node:child_process");var p=class{static{s(this,"CommandRunner")}run(e,o=[],n={},r){return r&&r.debug(`Running command: ${e} ${o.join(" ")}`),new Promise((i,a)=>{let k=[],j=process.platform==="win32"?{...n,shell:!0}:n,u=(0,A.spawn)(e,o,j);u.stdout.setEncoding("utf8");let Y;u.stdout.on("data",l=>{r?.info(l.toString().replace(/[\r\n]$/,"")),Y=l.toString()}),u.stderr.on("data",l=>{r?.info(l.toString().replace(/[\r\n]$/,"")),k.push(l.toString())}),u.on("error",l=>{let g=`Command failed with error: ${l.message}`;r?.error(g),a(l)}),u.on("close",l=>{if(l!==0){let g=`Command failed, \`${e} ${o.join(" ")}\`, ${k.join(", ")}`;r?.debug(g),a(g)}i(Y)})})}};var w=require("../../open-ux-shared/btp-utils/index.js");var O=y(require("../../commonlibs/fast-glob/index.js"),1),P=require("node:path"),C=y(require("../../commonlibs/read-pkg-up/index.js"),1),c=require("../../commonlibs/semver/index.js");var I=y(require("../../commonlibs/i18next/index.js"),1);var _={error:{unsupportedYoVersion:"The installed version of the `Yo` CLI tool: {{installedYoVersion}} is not supported. Please use `npm` or `yarn` to globally install the latest supported version by running: 'npm i -g yo@{{latestSupportedYoVer}}'.",executingYoVersionCmd:"Running: {{yoCmd}} returned an error: {{- error}}. Check that `yo` is installed and available on the path. If `yo@{{latestSupportedYoVer}}` is not installed, use `npm` or `yarn` to globally install the latest required version by running: 'npm i -g yo@{{latestSupportedYoVer}}'."}};var x="nodejs-utils",v=I.default.createInstance();async function N(){await v.init({lng:"en",fallbackLng:"en",defaultNS:x,ns:[x],resources:{en:{[x]:_}},interpolation:{escapeValue:!1},showSupportNotice:!1})}s(N,"initI18nNodejsUtils");function h(t,e){return e?.ns||(e=Object.assign(e??{},{ns:x})),v.t(t,e)}s(h,"t");N().catch(()=>{});var S="7.0.1",W=s(async(t,e)=>{let o=await(0,C.default)({cwd:t});if(o)return e&&(0,c.lt)((0,c.coerce)(o.packageJson.version),e)?void 0:{packageJsonPath:o.path,packageInfo:o.packageJson,path:(0,P.join)(t,o.packageJson.main??"/generators/app")}},"getPackageInfo");async function X(t,e){let o=await G(e?.vscWorkspaceConfig),n=[],r=[];for(let i of o){let a=await(0,O.default)(`**/*${t}*`,{cwd:i,deep:2,onlyDirectories:!0,absolute:!0});a.length>0&&r.push(...a)}for(let i of r){let a=await W(i,e?.minVersion);a&&(!e?.keyword||e.keyword&&a.packageInfo.keywords?.includes(e.keyword))&&n.push(a)}return n}s(X,"findInstalledPackages");async function G(t){let e=[];if(t){let a=t?.get("ApplicationWizard.installationLocation");a&&e.push((0,P.join)(a,"node_modules"))}let o=new p,n=process.platform==="win32"?"npm.cmd":"npm",r=await o.run(n,["-g","root"]).then(i=>i).catch(()=>{});return r&&e.push((0,P.join)(r.trim())),(0,w.isAppStudio)()&&process.env.NODE_PATH&&e.push(...process.env.NODE_PATH.split(":").filter(i=>i.endsWith("node_modules"))),e}s(G,"getNpmInstallPaths");async function J(){let t;if(!(0,w.isAppStudio)()){let e=process.platform==="win32"?"yo.cmd":"yo",o=["--version"],n;try{let r=await new p().run(e,o);n=typeof r=="string"?r.trim():void 0}catch(r){t=h("error.executingYoVersionCmd",{error:r,yoCmd:`${e} ${o.join(" ")}`,latestSupportedYoVer:S})}!t&&n&&!(0,c.satisfies)(n,"4.x || 5.x || 7.x")&&(t=h("error.unsupportedYoVersion",{installedYoVersion:n,latestSupportedYoVer:S}))}return{error:t}}s(J,"ensureValidYoVersion");var m=y(require("node:https"),1);function D(t){m.default.globalAgent.options&&(m.default.globalAgent.options.rejectUnauthorized=t),m.default.globalAgent.fallbackAgent?.options&&(m.default.globalAgent.fallbackAgent.options.rejectUnauthorized=t)}s(D,"setGlobalRejectUnauthorized");var d={NO_PROXY:"no-proxy",MATCH:"match",MISMATCH:"mismatch",ENV_ONLY:"env-only",PARAM_ONLY:"param-only"},F=["HTTP_PROXY","http_proxy","HTTPS_PROXY","https_proxy"],q=s(()=>{for(let t of F){let e=process.env[t];if(e&&e.trim()!=="")return e}},"getEnvProxy"),$=s(t=>{let e=t?.trim().toLowerCase();for(;e?.endsWith("/");)e=e.slice(0,-1);return e||void 0},"normalizeProxy");function B(t){let e=q(),o=$(e),n=$(t);return o||n?o&&!n?{isValid:!1,status:d.ENV_ONLY,message:"Using environment proxy settings.",envProxy:o,providedProxy:void 0}:!o&&n?{isValid:!1,status:d.PARAM_ONLY,message:`Using provided (${n}) proxy settings.`,envProxy:void 0,providedProxy:n}:o===n?{isValid:!0,status:d.MATCH,message:"Proxy settings match.",envProxy:o,providedProxy:n}:{isValid:!1,status:d.MISMATCH,message:`Proxy settings conflict between environment (${o}) and parameter (${n}).`,envProxy:o,providedProxy:n}:{isValid:!0,status:d.NO_PROXY,message:"No proxy settings configured.",providedProxy:void 0,envProxy:e}}s(B,"validateProxySettings");var K=void 0;0&&(module.exports={CommandRunner,ProxyValidationStatus,ensureValidYoVersion,findInstalledPackages,i18n,initI18nNodejsUtils,setGlobalRejectUnauthorized,t,validateProxySettings});