UNPKG

@sap/generator-fiori

Version:

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

3 lines (2 loc) 19.5 kB
const __esmImportMetaUrl = require('node:url').pathToFileURL(__filename).href; var Z=Object.create;var u=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var G=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty;var n=(e,t)=>u(e,"name",{value:t,configurable:!0});var P=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},Q=(e,t)=>{for(var r in t)u(e,r,{get:t[r],enumerable:!0})},L=(e,t,r,o)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of H(t))!K.call(e,i)&&i!==r&&u(e,i,{get:()=>t[i],enumerable:!(o=J(t,i))||o.enumerable});return e};var j=(e,t,r)=>(r=e!=null?Z(G(e)):{},L(t||!e||!e.__esModule?u(r,"default",{value:e,enumerable:!0}):r,e)),X=e=>L(u({},"__esModule",{value:!0}),e);var $=P((_e,W)=>{"use strict";var I=require("../../commonlibs/semver/index.js"),oe=["assert","buffer","child_process","cluster","console","constants","crypto","dgram","dns","domain","events","fs","http","https","module","net","os","path","punycode","querystring","readline","repl","stream","string_decoder","sys","timers","tls","tty","url","util","vm","zlib"],ie={freelist:"<6.0.0",v8:">=1.0.0",process:">=1.1.0",inspector:">=8.0.0",async_hooks:">=8.1.0",http2:">=8.4.0",perf_hooks:">=8.5.0",trace_events:">=10.0.0",worker_threads:">=12.0.0","node:test":">=18.0.0"},se={worker_threads:">=10.5.0",wasi:">=12.16.0",diagnostics_channel:"^14.17.0 || >=15.1.0"};W.exports=({version:e=process.version,experimental:t=!1}={})=>{let r=[...oe];for(let[o,i]of Object.entries(ie))(e==="*"||I.satisfies(e,i))&&r.push(o);if(t)for(let[o,i]of Object.entries(se))!r.includes(o)&&(e==="*"||I.satisfies(e,i))&&r.push(o);return r}});var M=P((ke,O)=>{"use strict";var le=new RegExp("^(?:@([^/]+?)[/])?([^/]+?)$"),ce=$(),pe=["node_modules","favicon.ico"];function ue(e){var t=[],r=[];if(e===null)return r.push("name cannot be null"),d(t,r);if(e===void 0)return r.push("name cannot be undefined"),d(t,r);if(typeof e!="string")return r.push("name must be a string"),d(t,r);if(e.length||r.push("name length must be greater than zero"),e.match(/^\./)&&r.push("name cannot start with a period"),e.match(/^_/)&&r.push("name cannot start with an underscore"),e.trim()!==e&&r.push("name cannot contain leading or trailing spaces"),pe.forEach(function(l){e.toLowerCase()===l&&r.push(l+" is a blacklisted name")}),ce({version:"*"}).forEach(function(l){e.toLowerCase()===l&&t.push(l+" is a core module name")}),e.length>214&&t.push("name can no longer contain more than 214 characters"),e.toLowerCase()!==e&&t.push("name can no longer contain capital letters"),/[~'!()*]/.test(e.split("/").slice(-1)[0])&&t.push(`name can no longer contain special characters ("~'!()*")`),encodeURIComponent(e)!==e){var o=e.match(le);if(o){var i=o[1],s=o[2];if(encodeURIComponent(i)===i&&encodeURIComponent(s)===s)return d(t,r)}r.push("name can only contain URL-friendly characters")}return d(t,r)}n(ue,"validate");var d=n(function(e,t){var r={validForNewPackages:t.length===0&&e.length===0,validForOldPackages:t.length===0,warnings:e,errors:t};return r.warnings.length||delete r.warnings,r.errors.length||delete r.errors,r},"done");O.exports=ue});var Se={};Q(Se,{addi18nResourceBundle:()=>y,default:()=>Ee,hasContentDuplication:()=>Ce,hasCustomerPrefix:()=>Te,initI18nProjectValidators:()=>x,isDataSourceURI:()=>be,validateAch:()=>Le,validateAllowedCharacters:()=>C,validateAppDescription:()=>re,validateAppName:()=>ee,validateClient:()=>ge,validateDuplicateProjectName:()=>B,validateEmptySpaces:()=>xe,validateEmptyString:()=>h,validateFioriAppProjectFolder:()=>k,validateFioriAppTargetFolder:()=>Ne,validateJSON:()=>ve,validateLibModuleName:()=>he,validateMaxLength:()=>N,validateModuleName:()=>F,validateNamespace:()=>me,validateNamespaceAdp:()=>Pe,validatePackage:()=>ne,validateProjectFolder:()=>w,validateProjectName:()=>Ae,validateProjectNameExternal:()=>D,validateProjectNameInternal:()=>q,validateSpecialChars:()=>we,validateText:()=>je,validateTransportRequestNumber:()=>ae,validateUrl:()=>ye,validateWindowsPathLength:()=>T});module.exports=X(Se);var S=j(require("../../commonlibs/i18next/index.js"),1);var E={deploy:{abapAppDescLength:"The deployment description cannot exceed 60 characters.",abapTransportNumRequired:"Provide a transport request for your application.",abapPackageWarn:"Provide a package.",abapAppNameRequired:"The application name is required.",abapInvalidNamespace:"The namespace is invalid because there are too many forward slashes.",abapInvalidNamespaceLength:"The namespace is limited to 10 characters. Entered {{length}}.",abapInvalidAppNameLength:"The application name is limited to 15 characters. Entered {{length}}.",abapInvalidAppName:"The application name must be prefixed with [{{prefix}}].",charactersForbiddenInAppName:"Only alphanumeric, underscore, and slash characters are allowed.",invalidAppNameMultipleReason:"The application name is invalid for multiple reasons:"},ui5:{namespaceMustStartWithLetter:"The namespace must start with a letter.",namespaceEndInPeriod:"The namespace cannot end with a period.",namespaceCannotBeSap:"The namespace cannot be {{str}}.",namespaceStartsWithNew:"The namespace cannot start with {{str}}.",namespaceNumberAfterPeriod:"A number cannot follow a period in the namespace.",lowerAlphaNumericOnly:"Only use lowercase alphanumeric characters.",lowerAlphaNumericDotsOnly:"Only use lowercase alphanumeric characters and dots for the namespace.",namespaceSpecialCharacter:"The namespace can only contain letters, digits, dots, and underscores.",moduleNameMustStartWithLetter:"The module name must start with a letter.",nameCombinedTooLong:"The combined length of the namespace and module name must not exceed {{length}} characters.",folderDoesNotExist:"This folder does not exist. Please enter the root folder for your project.",folderDoesNotHaveCorrectPermissions:"The selected folder does not have the required permissions. Please ensure you have permission to write to the selected folder and try again.",enterProjectFolder:"Please enter a project folder.",nameNull:"The module name cannot be null.",nameUndefined:"The module name cannot be undefined.",nameNotString:"The module name must be a string.",nameLengthZero:"The module name's length must be greater than zero.",nameStartsWithPeriod:"The module name cannot start with a period.",nameStartsWithUnderscore:"The module name cannot start with an underscore.",nameStartsOrEndsWithSpace:"The module name cannot contain leading or trailing spaces.",nameBlocklisted:"{{modName}} is a blocklisted module name. Choose a different name.",nameIsCoreModule:"{{modName}} is a core module name. Choose a different name.",nameTooLong:"The module name cannot exceed {{length}} characters.",nameTooShort:"The module name must be at least {{length}} characters.",inputValueContainsCapital:"{{promptName}} cannot contain capital letters",nameContainsSpecialCharacters:`The module name cannot contain special characters: ("~'!()*)`,nameNotUrlFriendly:"The module name can only contain URL-friendly characters.",invalidModuleName:"Invalid module name.",moduleAlreadyExists:"The module folder named: {{folderName}} already exists at the specified path.",appFolderExistsAtPath:"A module with this name already exists in the folder: {{-path}}.",folderContainsFioriApp:"The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again.",folderContainsCapApp:"The selected project folder is part of an existing CAP project. This application must use the local CAP project as the data source."},general:{invalidUrl:"Invalid URL: [{{-input}}]",invalidClient:"[{{client}}] is invalid. Leave this field empty or enter a value between 000-999.",inputCannotBeEmpty:"The input cannot be empty.",inputCannotHaveSpaces:"The input cannot contain spaces.",invalidJSON:"Invalid JSON.",invalidValueForSpecialChars:"The input must only contain Latin alphanumeric characters or the following symbols: '-','_','$' and '.'.",maxLength:"The maximum length is: {{maxLength}} characters.",supportedFormats:"Only alphanumeric and '{{allowedCharacters}}' characters are allowed.",nameContainsSpecialCharacters:`Module name cannot contain special characters ("~'!()*)`,nameNotUrlFriendly:"Module name can only contain URL-friendly characters",invalidModuleName:"Invalid module name",moduleAlreadyExists:"The module folder named: {{folderName}} already exists at the specified path",appFolderExistsAtPath:"A module with this name already exists in the folder: {{-path}}",folderContainsCapApp:"The selected project folder is part of an existing CAP project. This application must therefore use the local CAP project as the data source.",folderContainsFioriApp:"The project folder path already contains an SAP Fiori application in the folder: {{-path}}. Please choose a different folder and try again.",windowsFolderPathTooLong:"The combined length {{length}} of the target folder and module name exceeds the default Windows path length. This can cause issues with project generation."},adp:{projectNameUppercaseError:"The project name cannot contain uppercase letters.",projectNameLengthErrorExt:"The project name cannot exceed 61 characters or end with the word 'component'.",projectNameValidationErrorExt:"The project name must only contain alphanumeric characters. Every part must start with a letter and different parts can be separated by a period.",projectNameLengthErrorInt:"The project name cannot start with the word 'customer', exceed 61 characters, or end with the word 'component'.",projectNameValidationErrorInt:"The project name must only contain Latin alphanumeric characters and it must have at least two parts. The different parts must be separated by a period and every part must start with a letter.",duplicatedProjectName:"A project with this name already exists in your workspace. Please choose another name.",differentNamespaceThanProjectName:"The namespace must be the same as the project name.",namespaceSameAsProjectNameError:"The namespace must be the same as the project name.",namespaceLengthError:"The namespace cannot exceed 61 characters or end with the word 'component'.",namespaceValidationError:"The namespace must only contain alphanumeric characters. Every part must start with a letter and different parts can be separated by a period.",achMandatoryError:"The Application Component Hierarchy must only contain capital letters, digits, and dashes."}};var R="project-input-validator",g=S.default.createInstance();function y(){g.addResourceBundle("en",R,E)}n(y,"addi18nResourceBundle");async function x(){await g.init({lng:"en",fallbackLng:"en",showSupportNotice:!1}),y()}n(x,"initI18nProjectValidators");function a(e,t){return t?.ns||(t=Object.assign(t??{},{ns:R})),g.t(e,t)}n(a,"t");x().catch(()=>{});var f=require("node:os");function ee(e,t){let r=[],o=e?e.trim().length:0;if(!o)return a("deploy.abapAppNameRequired");if(e.split("/").length>3)r.push(a("deploy.abapInvalidNamespace"));else if(/^\/.*\/\w*$/g.test(e)){let i=e.split("/"),s="";if(i[1].length>10){let l=a("deploy.abapInvalidNamespaceLength",{length:i[1].length});s+=`${l}, `}if(i[2].length>15){let l=a("deploy.abapInvalidAppNameLength",{length:i[2].length});s+=`${l}, `}s&&(s=s.substring(0,s.length-2),r.push(s))}else o>15&&r.push(a("deploy.abapInvalidAppNameLength",{length:o}));return t&&!e.toUpperCase().startsWith(t.toUpperCase())&&r.push(a("deploy.abapInvalidAppName",{prefix:t})),/^[A-Za-z0-9_/]*$/.test(e)||r.push(a("deploy.charactersForbiddenInAppName")),te(r)}n(ee,"validateAppName");function te(e){if(e.length===0)return!0;if(e.length===1)return e[0];{let t=e.map(r=>`${" ".repeat(8)}${r}`).join(f.EOL);return`${a("deploy.invalidAppNameMultipleReason")}${f.EOL}${t}${f.EOL}`}}n(te,"processErrorMessages");function re(e){return e.length>60?a("deploy.abapAppDescLength"):!0}n(re,"validateAppDescription");function ae(e,t){return!/^[$LlTt]/.test(t)&&!e?.trim()?a("deploy.abapTransportNumRequired"):!0}n(ae,"validateTransportRequestNumber");function ne(e){return e?.trim()?!0:a("deploy.abapPackageWarn")}n(ne,"validatePackage");var m=require("node:path");var c=require("node:fs"),U=j(M(),1);function de(e,t="",r=!0){return/^[a-zA-Z]/.test(e)?e.endsWith(".")?a("ui5.namespaceEndInPeriod"):e.toUpperCase()==="SAP"?a("ui5.namespaceCannotBeSap",{str:e}):e.toLowerCase().startsWith("new")?a("ui5.namespaceStartsWithNew",{str:e.substring(0,3)}):/\.\d/.test(e)?a("ui5.namespaceNumberAfterPeriod"):r&&!/^[\w.]+$/.test(e)?a("ui5.namespaceSpecialCharacter"):!r&&!/^[a-z0-9.]*$/g.test(e)?a("ui5.lowerAlphaNumericDotsOnly"):(t+e).length>70?a("ui5.nameCombinedTooLong",{length:70}):e.toLowerCase()!==e?a("ui5.inputValueContainsCapital",{promptName:"Namespace"}):!0:a("ui5.namespaceMustStartWithLetter")}n(de,"validateNamespacePattern");function me(e,t,r=!0){return e?de(e,t,r):!1}n(me,"validateNamespace");function he(e){let t=F(e);return typeof t=="string"?t:/^[a-z0-9]*$/g.test(e)?!0:a("ui5.lowerAlphaNumericOnly")}n(he,"validateLibModuleName");function w(e,t){return v(e)?fe(e)?e&&e.length>0&&!v((0,m.join)(e,t))?!0:e&&e.length>0&&v((0,m.join)(e,t))?a("ui5.moduleAlreadyExists",{folderName:t}):a("ui5.enterProjectFolder"):a("ui5.folderDoesNotHaveCorrectPermissions"):a("ui5.folderDoesNotExist")}n(w,"validateProjectFolder");function F(e){if(/^[^a-zA-Z]/.test(e))return a("ui5.moduleNameMustStartWithLetter");if(e?.length>70)return a("ui5.nameTooLong",{length:70});if(e?.length<3)return a("ui5.nameTooShort",{length:3});let t={"name cannot be null":a("ui5.nameNull"),"name cannot be undefined":a("ui5.nameUndefined"),"name must be a string":a("ui5.nameNotString"),"name length must be greater than zero":a("ui5.nameLengthZero"),"name cannot start with a period":a("ui5.nameStartsWithPeriod"),"name cannot start with an underscore":a("ui5.nameStartsWithUnderscore"),"name cannot contain leading or trailing spaces":a("ui5.nameStartsOrEndsWithSpace"),[e+" is a blocklisted name"]:a("ui5.nameBlocklisted",{moduleName:e}),[e+" is a core module name"]:a("ui5.nameIsCoreModule",{moduleName:e}),"name can no longer contain more than 214 characters":a("ui5.nameTooLong",{length:214}),"name can no longer contain capital letters":a("ui5.inputValueContainsCapital",{promptName:"Module"}),'name can no longer contain special characters ("~\'!()*")':a("ui5.nameContainsSpecialCharacters"),"name can only contain URL-friendly characters":a("ui5.nameNotUrlFriendly")},r=(0,U.default)(e);return r.validForNewPackages&&r.validForOldPackages?!0:[...r.errors??[],...r.warnings??[]].filter(o=>!!o).map(o=>t[o]??a("ui5.invalidModuleName")).join(", ")}n(F,"validateModuleName");function v(e){return e&&typeof e!="string"?a("ERROR_NAME_NOT_STRING"):(0,c.existsSync)(e)&&(0,c.lstatSync)(e).isDirectory()}n(v,"folderExists");function fe(e){let t=!0,r=process.platform==="win32";try{(0,c.accessSync)(r?m.posix.basename(e):e,c.constants.W_OK)}catch{t=!1}return t}n(fe,"folderWritePermExists");var p=require("../../open-ux-shared/project-access/index.js"),_=require("node:path");function ge(e){let t=e?.trim()||"";return t===""||/^\d{3}$/.test(t)?!0:a("general.invalidClient",{client:e})}n(ge,"validateClient");function ye(e){try{let t=new URL(e);return!!t.protocol&&!!t.host}catch{return a("general.invalidUrl",{input:e})}}n(ye,"validateUrl");function h(e){return(e?.trim()||"").trim().length>0?!0:a("general.inputCannotBeEmpty")}n(h,"validateEmptyString");function xe(e){return/\s/.test(e)?a("general.inputCannotHaveSpaces"):!0}n(xe,"validateEmptySpaces");function N(e,t=0){return t>0&&e.length>t?a("general.maxLength",{maxLength:t}):!0}n(N,"validateMaxLength");function C(e,t){if(t&&t.length>0){let r=t.map(i=>`\\${i}`).join("");if(!new RegExp(`^[a-zA-Z0-9${r}]+$`).test(e))return a("general.supportedFormats",{allowedCharacters:t.join("")})}return!0}n(C,"validateAllowedCharacters");function ve(e){try{return JSON.parse(`{${e}}`),!0}catch{return a("general.invalidJSON")}}n(ve,"validateJSON");function we(e,t="^[a-zA-Z0-9_$.\\-]+$"){return new RegExp(t,"g").test(e)?!0:a("general.invalidValueForSpecialChars")}n(we,"validateSpecialChars");function T(e,t){if(process.platform==="win32"){let r=`${e}`.length;if(r>=256)return t.replace("{{length}}",r.toString())}return!0}n(T,"validateWindowsPathLength");async function k(e){if(await(0,p.findCapProjectRoot)(e,!1)||await(0,p.getCapProjectType)(e))return a("ui5.folderContainsCapApp");let t=await(0,p.findRootsForPath)(e);return t?a("ui5.folderContainsFioriApp",{path:t.appRoot}):!0}n(k,"validateFioriAppProjectFolder");async function Ne(e,t,r){if(r===!0){let s=await k(e);if(s!==!0)return s}let o=w(e,t);if(o!==!0)return o;let i=T((0,_.join)(e,t),a("general.windowsFolderPathTooLong"));return i!==!0?i:!0}n(Ne,"validateFioriAppTargetFolder");var V=require("node:path"),z=require("node:fs");function Ce(e,t,r){return r.some(({content:o})=>{let i=o[t];return i&&Object.keys(i).includes(e)})}n(Ce,"hasContentDuplication");function Te(e){return e.toLowerCase().startsWith("customer.")}n(Te,"hasCustomerPrefix");function be(e){return/^(?!.*\/\/)\/([^\s]*)\/$/.test(e)}n(be,"isDataSourceURI");function Ae(e,t,r,o){let i=h(e);if(typeof i=="string")return i;if(/[A-Z]/.test(e))return a("adp.projectNameUppercaseError");let s=r?D(e):q(e);return typeof s=="string"?s:o?B(e,t):!0}n(Ae,"validateProjectName");function D(e){return e.length>61||e.toLocaleLowerCase().endsWith("component")?a("adp.projectNameLengthErrorExt"):/^[a-z][a-z0-9]*(\.[a-z][a-z0-9]*)*$/.test(e)?!0:a("adp.projectNameValidationErrorExt")}n(D,"validateProjectNameExternal");function q(e){return e.toLowerCase().startsWith("customer")||e.length>61||e.toLocaleLowerCase().endsWith("component")?a("adp.projectNameLengthErrorInt"):/^[a-z]+[a-z0-9]*(\.[a-z]+[a-z0-9]*)+$/i.test(e)?!0:a("adp.projectNameValidationErrorInt")}n(q,"validateProjectNameInternal");function B(e,t){return(0,z.existsSync)((0,V.join)(t,e))?a("adp.duplicatedProjectName"):!0}n(B,"validateDuplicateProjectName");function Pe(e,t,r){let o=h(e);if(typeof o=="string")return o;if(r){if(e.toLowerCase().startsWith("customer.")!==!0)return a("adp.namespaceSameAsProjectNameError");e=e.slice(9,e.length)}else if(e!==t)return a("adp.differentNamespaceThanProjectName");return e.length>61||e.toLowerCase().endsWith("component")===!0?a("adp.namespaceLengthError"):e!==""&&/^[a-z]+((\.)?[a-z0-9])*$/.test(e)===!1?a("adp.namespaceValidationError"):!0}n(Pe,"validateNamespaceAdp");function Le(e,t){let r=h(e);if(typeof r=="string")return r;let o=/^([A-Z0-9]{2,3})(-[A-Z0-9]{1,6})*$/.exec(e.toUpperCase());return!t&&!o?a("adp.achMandatoryError"):!0}n(Le,"validateAch");function je(e,t,r=0,o){if(!(e?e.trim():"").length)return t?a("general.inputCannotBeEmpty"):!1;let l=N(e,r);if(typeof l=="string")return l;let A=C(e,o);return typeof A=="string"?A:!0}n(je,"validateText");var Ee=void 0;0&&(module.exports={addi18nResourceBundle,hasContentDuplication,hasCustomerPrefix,initI18nProjectValidators,isDataSourceURI,validateAch,validateAllowedCharacters,validateAppDescription,validateAppName,validateClient,validateDuplicateProjectName,validateEmptySpaces,validateEmptyString,validateFioriAppProjectFolder,validateFioriAppTargetFolder,validateJSON,validateLibModuleName,validateMaxLength,validateModuleName,validateNamespace,validateNamespaceAdp,validatePackage,validateProjectFolder,validateProjectName,validateProjectNameExternal,validateProjectNameInternal,validateSpecialChars,validateText,validateTransportRequestNumber,validateUrl,validateWindowsPathLength});