@wavemaker-ai/angular-codegen 12.0.1-rc.647755 → 12.0.2-rc.647771

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- const path=require("path"),fs=require("fs"),{downloadNPMPackage:downloadNPMPackage}=require("../download-packages"),{isPrismProject:isPrismProject,DESIGN_TOKENS_DIR_NAME:DESIGN_TOKENS_DIR_NAME,OVERRIDE_TOKENS_PATH:OVERRIDE_TOKENS_PATH,APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH}=require("./wm-utils"),{getLegacyWmProjectProperties:getLegacyWmProjectProperties}=require("./project-meta"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),groupFilesByMode=e=>{const s={default:[]};return fs.readdirSync(e).forEach(o=>{const t=path.join(e,o),r=fs.statSync(t);if(r.isDirectory()){const e=groupFilesByMode(t);for(const o in e)s[o]||(s[o]=[]),s[o].push(...e[o])}else if(r.isFile()&&".json"===path.extname(t)){const e=o.match(/\.([^.]+)\.json$/);if(e){const o=e[1];s[o]||(s[o]=[]),s[o].push(t)}else s.default.push(t)}}),s},generateModeConfigs=(e,s,o,t)=>{const r=o&&o.name||"css/variables",n=t&&t.name||"css/variables",i=[];for(const o in e){const t=e[o].flatMap(e=>{const o=e.replace(s+"/","");return[{destination:o.replace(/\.json$/,".css"),options:{outputReferences:!0,selector:":root"},format:r,filter:function(s){var o;const t=e=>e?e.replace(/\\/g,"/"):e;o=t(o=s["@"]&&s["@"].filePath?s["@"].filePath:s.filePath),e=t(e);var r=o&&-1!==o.indexOf("overrides")||s.filePath&&-1!==s.filePath.indexOf("overrides"),n=o&&(e.includes(o)||e.includes(t(s.filePath)))&&!s.path.includes("appearances")&&!s.path.includes("states");return r&&n}},{destination:o.replace(/\.json$/,"variant.css"),options:{outputReferences:!0,selector:":root"},format:n,filter:s=>{let o;const t=(o=s["@"]&&s["@"].filePath?s["@"].filePath:s.filePath)&&-1!==o.indexOf("overrides"),r=o&&(e.includes(o)||e.includes(s.filePath))&&(s.path.includes("appearances")||s.path.includes("states"));return t&&r}}]});i.push({mode:o,files:t})}return i},accessFile=e=>{const s=path.dirname(e);fs.existsSync(s)||(fs.mkdirSync(s,{recursive:!0}),console.log(`Directory created: ${s}`)),fs.access(e,fs.constants.F_OK,s=>{if(s){console.log(`${e} does not exist. Creating file...`);const s=JSON.stringify({});fs.writeFile(e,s,s=>{if(s)throw s;console.log(`${e} was created successfully.`)})}})};async function setupSymlink(e,s){try{await fs.promises.mkdir(path.dirname(s),{recursive:!0});try{fs.existsSync(s)&&await fs.promises.unlink(s)}catch(e){console.error("Error removing existing symlink:",e)}const o="win32"===process.platform?"junction":"dir";await fs.promises.symlink(e,s,o),console.log("Symlink created successfully at:",s)}catch(e){console.error("Error creating symlink:",s,e)}}const getStyleDictionaryConfig=(e,s,o,t)=>{t.endsWith("/")||(t+="/");let r="";return{log:{verbosity:"verbose"},source:[r="default"===o?`${t}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/**/!(*.*).json`:`${t}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/**/*.${o}.json`],include:[`${s.replace(/\\/g,"/")}/**/!(*.dark|*.light).json`,`${t.replace(/\\/g,"/")}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/global/**/*.json`],platforms:{css:{transformGroup:"css",prefix:"--wm",files:e}}}};async function removeSymlink(e){const s=path.resolve(e);try{fs.lstatSync(s).isSymbolicLink()?(await fs.promises.unlink(s),console.log("Symlink removed successfully:",s)):console.warn("Not a symlink, skipping unlink:",s)}catch(e){console.error("Error during symlink removal:",e)}}async function getCustomFormatters(e,s){try{const o=await import(`${e}/node_modules/style-dictionary/lib/utils/index.js`),{usesReferences:t,getReferences:r}=o,n=await import(`${s}/node_modules/${WM_NPM_SCOPE}/foundation-css/src/utils/style-dictionary-utils.js`),{cssVarCalcMixFormatter:i,componentVariantsFormatter:a}=n,c="web";return{cssVarCalcMixFormatter:i(t,r),componentVariantsFormatter:a(t,r,c)}}catch(e){return console.error("Failed to load CssVarCalcMixFormatter:",e),null}}function processCSSFiles(e,s){for(const{destination:o}of e)try{if(o.endsWith(".css")&&fs.existsSync(o)){const e=fs.readFileSync(o,"utf-8"),t=/(:root\s*\{[^}]*\})/,r=path.basename(o).split(".");let n=e;if(3===r.length&&"light"!==r[1]){const o=r[0],t=r[1];s+=(n=e.replace(/:root/g,`:root[${o}='${t}']`))+"\n"}else{const o=s.match(t),r=e.match(t);if(o&&r){const e=o[1],t=r[1].replace(/:root\s*\{|\}/g,"").trim(),n=e.replace("}",`\n${t}\n}`);s=s.replace(e,n)}else s+=n+"\n"}fs.unlink(o,()=>{})}}catch(e){console.error(`\nStyle dictionary, Error processing file ${o}:`,e)}return s}const generateOverrideCSS=async(e,s,o)=>{e=e||{};const t=await getLegacyWmProjectProperties(s);if(isPrismProject(t)){const t=path.join(s+"/src/main/webapp/",OVERRIDE_TOKENS_PATH),r=s+`/src/main/webapp/${APP_OVERRIDE_CSS_PATH}`;if(accessFile(r),fs.existsSync(t)){console.log("CODEGEN ANGULAR APP: generating override css...");let n={scope:"",name:"style-dictionary",version:"4.1.0",packageJsonFile:"",successMsg:"STYLE DICTIONARY SUCCESS",infoMsg:"STYLE DICTIONARY PACKAGE : ",skipPackageVersion:!1};n.baseDir=o;const i=await downloadNPMPackage(n);let a={scope:WM_NPM_SCOPE,name:"foundation-css",version:e.runtimeUIVersion,packageJsonFile:"",successMsg:"Foundation-CSS SUCCESS",infoMsg:"Foundation-CSS PACKAGE : "};a.baseDir=o;const c=await downloadNPMPackage(a);console.log("FOUNDATION_CSS_PATH",c,"SourceDir",s),await(async()=>{const e=await import(`${i}/node_modules/style-dictionary/lib/StyleDictionary.js`).then(e=>e.default),o=path.join(c,`/node_modules/${WM_NPM_SCOPE}/foundation-css/src/tokens/web`),{cssVarCalcMixFormatter:n,componentVariantsFormatter:a}=await getCustomFormatters(i,c);n&&a||(n||console.error("cssVarCalcMixFormatter failed to load."),a||console.error("cssVariantFormatter failed to load.")),n&&e.registerFormat(n),a&&e.registerFormat(a);const l=path.resolve(s,"src","main","webapp",DESIGN_TOKENS_DIR_NAME,"temp-tokens"),d=groupFilesByMode(t),f=generateModeConfigs(d,s,n,a);let m="";try{console.log("\nSetting up foundation tokens symlink..."),await setupSymlink(o,l);for(const{mode:o,files:t}of f){console.log(`\nBuilding CSS for mode: ${o}...`);try{const n=getStyleDictionaryConfig(t,l,o,s);console.log(n,o);const i=new e(n);await i.buildPlatform("css"),console.log(`Style Dictionary build completed for mode: ${o}`),m=processCSSFiles(t,m),fs.writeFileSync(r,m),console.log(`CSS overrides generated successfully for mode: ${o}`)}catch(e){console.error(`Error during Style Dictionary build for mode: ${o}`,e)}}console.log("CODEGEN ANGULAR APP: generating overrides success !")}catch(e){console.error("Error setting up symlink or processing modes:",e)}finally{await removeSymlink(l)}})()}}};module.exports={generateOverrideCSS:generateOverrideCSS};
1
+ const path=require("path"),fs=require("fs"),{downloadNPMPackage:downloadNPMPackage}=require("../download-packages"),{usesFoundationStyling:usesFoundationStyling,DESIGN_TOKENS_DIR_NAME:DESIGN_TOKENS_DIR_NAME,OVERRIDE_TOKENS_PATH:OVERRIDE_TOKENS_PATH,APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH}=require("./wm-utils"),{getLegacyWmProjectProperties:getLegacyWmProjectProperties}=require("./project-meta"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),groupFilesByMode=e=>{const s={default:[]};return fs.readdirSync(e).forEach(o=>{const t=path.join(e,o),r=fs.statSync(t);if(r.isDirectory()){const e=groupFilesByMode(t);for(const o in e)s[o]||(s[o]=[]),s[o].push(...e[o])}else if(r.isFile()&&".json"===path.extname(t)){const e=o.match(/\.([^.]+)\.json$/);if(e){const o=e[1];s[o]||(s[o]=[]),s[o].push(t)}else s.default.push(t)}}),s},generateModeConfigs=(e,s,o,t)=>{const r=o&&o.name||"css/variables",n=t&&t.name||"css/variables",i=[];for(const o in e){const t=e[o].flatMap(e=>{const o=e.replace(s+"/","");return[{destination:o.replace(/\.json$/,".css"),options:{outputReferences:!0,selector:":root"},format:r,filter:function(s){var o;const t=e=>e?e.replace(/\\/g,"/"):e;o=t(o=s["@"]&&s["@"].filePath?s["@"].filePath:s.filePath),e=t(e);var r=o&&-1!==o.indexOf("overrides")||s.filePath&&-1!==s.filePath.indexOf("overrides"),n=o&&(e.includes(o)||e.includes(t(s.filePath)))&&!s.path.includes("appearances")&&!s.path.includes("states");return r&&n}},{destination:o.replace(/\.json$/,"variant.css"),options:{outputReferences:!0,selector:":root"},format:n,filter:s=>{let o;const t=(o=s["@"]&&s["@"].filePath?s["@"].filePath:s.filePath)&&-1!==o.indexOf("overrides"),r=o&&(e.includes(o)||e.includes(s.filePath))&&(s.path.includes("appearances")||s.path.includes("states"));return t&&r}}]});i.push({mode:o,files:t})}return i},accessFile=e=>{const s=path.dirname(e);fs.existsSync(s)||(fs.mkdirSync(s,{recursive:!0}),console.log(`Directory created: ${s}`)),fs.access(e,fs.constants.F_OK,s=>{if(s){console.log(`${e} does not exist. Creating file...`);const s=JSON.stringify({});fs.writeFile(e,s,s=>{if(s)throw s;console.log(`${e} was created successfully.`)})}})};async function setupSymlink(e,s){try{await fs.promises.mkdir(path.dirname(s),{recursive:!0});try{fs.existsSync(s)&&await fs.promises.unlink(s)}catch(e){console.error("Error removing existing symlink:",e)}const o="win32"===process.platform?"junction":"dir";await fs.promises.symlink(e,s,o),console.log("Symlink created successfully at:",s)}catch(e){console.error("Error creating symlink:",s,e)}}const getStyleDictionaryConfig=(e,s,o,t)=>{t.endsWith("/")||(t+="/");let r="";return{log:{verbosity:"verbose"},source:[r="default"===o?`${t}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/**/!(*.*).json`:`${t}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/**/*.${o}.json`],include:[`${s.replace(/\\/g,"/")}/**/!(*.dark|*.light).json`,`${t.replace(/\\/g,"/")}/src/main/webapp/${OVERRIDE_TOKENS_PATH}/global/**/*.json`],platforms:{css:{transformGroup:"css",prefix:"--wm",files:e}}}};async function removeSymlink(e){const s=path.resolve(e);try{fs.lstatSync(s).isSymbolicLink()?(await fs.promises.unlink(s),console.log("Symlink removed successfully:",s)):console.warn("Not a symlink, skipping unlink:",s)}catch(e){console.error("Error during symlink removal:",e)}}async function getCustomFormatters(e,s){try{const o=await import(`${e}/node_modules/style-dictionary/lib/utils/index.js`),{usesReferences:t,getReferences:r}=o,n=await import(`${s}/node_modules/${WM_NPM_SCOPE}/foundation-css/src/utils/style-dictionary-utils.js`),{cssVarCalcMixFormatter:i,componentVariantsFormatter:a}=n,c="web";return{cssVarCalcMixFormatter:i(t,r),componentVariantsFormatter:a(t,r,c)}}catch(e){return console.error("Failed to load CssVarCalcMixFormatter:",e),null}}function processCSSFiles(e,s){for(const{destination:o}of e)try{if(o.endsWith(".css")&&fs.existsSync(o)){const e=fs.readFileSync(o,"utf-8"),t=/(:root\s*\{[^}]*\})/,r=path.basename(o).split(".");let n=e;if(3===r.length&&"light"!==r[1]){const o=r[0],t=r[1];s+=(n=e.replace(/:root/g,`:root[${o}='${t}']`))+"\n"}else{const o=s.match(t),r=e.match(t);if(o&&r){const e=o[1],t=r[1].replace(/:root\s*\{|\}/g,"").trim(),n=e.replace("}",`\n${t}\n}`);s=s.replace(e,n)}else s+=n+"\n"}fs.unlink(o,()=>{})}}catch(e){console.error(`\nStyle dictionary, Error processing file ${o}:`,e)}return s}const generateOverrideCSS=async(e,s,o)=>{e=e||{};const t=await getLegacyWmProjectProperties(s);if(usesFoundationStyling(t)){const t=path.join(s+"/src/main/webapp/",OVERRIDE_TOKENS_PATH),r=s+`/src/main/webapp/${APP_OVERRIDE_CSS_PATH}`;if(accessFile(r),fs.existsSync(t)){console.log("CODEGEN ANGULAR APP: generating override css...");let n={scope:"",name:"style-dictionary",version:"4.1.0",packageJsonFile:"",successMsg:"STYLE DICTIONARY SUCCESS",infoMsg:"STYLE DICTIONARY PACKAGE : ",skipPackageVersion:!1};n.baseDir=o;const i=await downloadNPMPackage(n);let a={scope:WM_NPM_SCOPE,name:"foundation-css",version:e.runtimeUIVersion,packageJsonFile:"",successMsg:"Foundation-CSS SUCCESS",infoMsg:"Foundation-CSS PACKAGE : "};a.baseDir=o;const c=await downloadNPMPackage(a);console.log("FOUNDATION_CSS_PATH",c,"SourceDir",s),await(async()=>{const e=await import(`${i}/node_modules/style-dictionary/lib/StyleDictionary.js`).then(e=>e.default),o=path.join(c,`/node_modules/${WM_NPM_SCOPE}/foundation-css/src/tokens/web`),{cssVarCalcMixFormatter:n,componentVariantsFormatter:a}=await getCustomFormatters(i,c);n&&a||(n||console.error("cssVarCalcMixFormatter failed to load."),a||console.error("cssVariantFormatter failed to load.")),n&&e.registerFormat(n),a&&e.registerFormat(a);const l=path.resolve(s,"src","main","webapp",DESIGN_TOKENS_DIR_NAME,"temp-tokens"),d=groupFilesByMode(t),u=generateModeConfigs(d,s,n,a);let f="";try{console.log("\nSetting up foundation tokens symlink..."),await setupSymlink(o,l);for(const{mode:o,files:t}of u){console.log(`\nBuilding CSS for mode: ${o}...`);try{const n=getStyleDictionaryConfig(t,l,o,s);console.log(n,o);const i=new e(n);await i.buildPlatform("css"),console.log(`Style Dictionary build completed for mode: ${o}`),f=processCSSFiles(t,f),fs.writeFileSync(r,f),console.log(`CSS overrides generated successfully for mode: ${o}`)}catch(e){console.error(`Error during Style Dictionary build for mode: ${o}`,e)}}console.log("CODEGEN ANGULAR APP: generating overrides success !")}catch(e){console.error("Error setting up symlink or processing modes:",e)}finally{await removeSymlink(l)}})()}}};module.exports={generateOverrideCSS:generateOverrideCSS};
@@ -1 +1 @@
1
- const{deleteResource:deleteResource,createDir:createDir,readDir:readDir,getWebAppPath:getWebAppPath,readFileSync:readFileSync,isPrismProject:isPrismProject,mergePackageJsonWithOverrideJson:mergePackageJsonWithOverrideJson}=require("./wm-utils"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),util=require("util"),fs=require("fs"),{executeSyncCmd:executeSyncCmd}=require("../build-util"),writeFile=util.promisify(fs.writeFile),ncp=util.promisify(require("ncp").ncp),updatePackageJson=async(e,r,a)=>{const t=`${r}/package.json`;let s=readFileSync(t,!0);s.name=a.name,s.version=a.version,s=await mergePackageJsonWithOverrideJson(e,s,!0);const i=["variables","foundation-css","custom-widgets-m3"];for(const e of i){const a=`${WM_NPM_SCOPE}/${e}`,t=s.dependencies[a];t&&-1!==t.indexOf("yalc")&&executeSyncCmd(`cd ${r} && yalc add ${a}`,null,`Adding yalc ${e} dependency to ${r}`)}await writeFile(t,JSON.stringify(s,null,4))},createAppSkeleton=async(e,r,a,t)=>{await deleteResource(r),await createDir(r,{recursive:!0}),await ncp(a+"/angular-app",r),await updatePackageJson(e,r,t);const s=getWebAppPath(e),i=isPrismProject(t)?"design-tokens":"themes";try{if((await readDir(`${s}/${i}`)).length){const e=`${s}/${i}/`;await ncp(e,`${r}/src/assets/${i}`)}}catch(e){if("ENOENT"!==e.code||!isPrismProject(t))throw console.error("Failed to load themes",e.message),e;console.warn("No design-tokens folder found for Prism project.")}(await readDir(`${s}/extensions`)).length&&await ncp(`${s}/extensions`,`${r}/src/app/extensions`),await ncp(`${s}/app.css`,`${r}/src/assets/app.css`),await ncp(`${s}/resources`,`${r}/resources`),await ncp(`${a}/.npmrc`,`${r}/.npmrc`)};module.exports={createAppSkeleton:createAppSkeleton};
1
+ const{deleteResource:deleteResource,createDir:createDir,readDir:readDir,getWebAppPath:getWebAppPath,readFileSync:readFileSync,usesFoundationStyling:usesFoundationStyling,mergePackageJsonWithOverrideJson:mergePackageJsonWithOverrideJson}=require("./wm-utils"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),util=require("util"),fs=require("fs"),{executeSyncCmd:executeSyncCmd}=require("../build-util"),writeFile=util.promisify(fs.writeFile),ncp=util.promisify(require("ncp").ncp),updatePackageJson=async(e,t,a)=>{const n=`${t}/package.json`;let s=readFileSync(n,!0);s.name=a.name,s.version=a.version,s=await mergePackageJsonWithOverrideJson(e,s,!0);const i=["variables","foundation-css","custom-widgets-m3"];for(const e of i){const a=`${WM_NPM_SCOPE}/${e}`,n=s.dependencies[a];n&&-1!==n.indexOf("yalc")&&executeSyncCmd(`cd ${t} && yalc add ${a}`,null,`Adding yalc ${e} dependency to ${t}`)}await writeFile(n,JSON.stringify(s,null,4))},createAppSkeleton=async(e,t,a,n)=>{await deleteResource(t),await createDir(t,{recursive:!0}),await ncp(a+"/angular-app",t),await updatePackageJson(e,t,n);const s=getWebAppPath(e),i=usesFoundationStyling(n),r=i?"design-tokens":"themes";try{if((await readDir(`${s}/${r}`)).length){const e=`${s}/${r}/`;await ncp(e,`${t}/src/assets/${r}`)}}catch(e){if("ENOENT"!==e.code||!i)throw console.error("Failed to load themes",e.message),e;console.warn("No design-tokens folder found for design-token styled project.")}(await readDir(`${s}/extensions`)).length&&await ncp(`${s}/extensions`,`${t}/src/app/extensions`),await ncp(`${s}/app.css`,`${t}/src/assets/app.css`),await ncp(`${s}/resources`,`${t}/resources`),await ncp(`${a}/.npmrc`,`${t}/.npmrc`)};module.exports={createAppSkeleton:createAppSkeleton};
@@ -1 +1 @@
1
- const cheerio=require("cheerio"),{writeFile:writeFile,readFileSync:readFileSync,readDir:readDir,isMobileProject:isMobileProject,isPrismProject:isPrismProject,APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH}=require("./wm-utils"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),markScriptsAsLazy=e=>{const s=["./node_modules/d3/dist/d3.min.js","./node_modules/@wavemaker/nvd3/build/nv.d3.min.js","./node_modules/summernote/dist/summernote-lite.min.js",global._WM_PACKAGE_PATH+"/scripts/datatable/datatable.js","./node_modules/jquery-ui/ui/widgets/sortable.js","./node_modules/jquery-ui/ui/widgets/droppable.js","./node_modules/jquery-ui/ui/widgets/resizable.js","./node_modules/hammerjs/hammer.min.js","./node_modules/iscroll/build/iscroll.js"];if("string"==typeof e){let t=e.replace(/^(\.\/)/,"").replace(/\//g,"-").replace(/@/g,"");if(t=t.substring(0,t.lastIndexOf(".")),s.includes(e))return{input:e,inject:!1,bundleName:t}}return e},setBuildCustomizations=async e=>{const s=e.projects["angular-app"].architect.build,t=s.options.scripts;s.options.scripts=t.map(e=>markScriptsAsLazy(e))},addToScripts=async(e,s,t=[],i=[])=>{const n=`${s}/angular.json`;let o=readFileSync(n,!0);const a=o.projects["angular-app"].architect.build;let r=a.options.scripts;const l=`${s+"/src/app/extensions"}`,u=await readDir(l);u.length&&i.push("./src/app/extensions/"+u[0]),a.options.scripts=[...t,...r,...i],await writeFile(n,JSON.stringify(o,null,4))},updateAngularJSON=async(e,s,t,i,n,o,a,r,l,u)=>{const c=`${s}/angular.json`;let p=readFileSync(c,!0);const d=p.projects["angular-app"].architect.build;a&&a.trim().length>0&&(d.configurations.production.deployUrl=a,d.configurations.development.deployUrl=a),d.configurations.production.outputPath=d.configurations.production.outputPath+"/"+global.randomHash,d.configurations.development.outputPath=d.configurations.development.outputPath+"/"+global.randomHash;let m=d.options.styles;if(isPrismProject(t)){const e=(m=m.filter(e=>"string"==typeof e?!(e.includes("src/assets/styles/css/wm-style.css")||e.includes("src/assets/styles/css/wm-responsive.css")):"object"!=typeof e||!e.input||!e.input.includes("src/assets/themes/material/style.css"))).findIndex(e=>"object"==typeof e&&e.input&&e.input.includes("app.css")),s=`./node_modules/${WM_NPM_SCOPE}/foundation-css/foundation/foundation.css`,t={input:`src/assets/${APP_OVERRIDE_CSS_PATH}`,inject:!1,bundleName:"wm-styles"};-1!==e?m.splice(e,0,s,t):m.push(s,t),d.options.styles=m}if(isMobileProject(t)){const e=m.findIndex(e=>{let s="object"==typeof e;if(s){return(s?e.input:e).includes("themes")}return!1}),s=m[e].input;m[e].bundleName="wm-android-styles",m[e].input=m[e].input.replace(new RegExp("/[a-z]*/style.css$"),`/${i.activeTheme}/android/style.css`);const t=Object.assign({},m[e]);t.input=s.replace(new RegExp("/[a-z]*/style.css$"),`/${i.activeTheme}/ios/style.css`),t.bundleName="wm-ios-styles",m.push(t);const n=m.findIndex(e=>{let s="object"==typeof e;if(s){return"src/assets/app.css"===(s?e.input:e)}return!1});m[n].bundleName="wm-android-styles";const o=Object.assign({},m[n]);o.bundleName="wm-ios-styles",m.push(o)}m.forEach((e,s)=>{let t="object"==typeof e,n=t?e.input:e;!n.includes("themes")||n.includes("/android/")||n.includes("/ios/")||(t?m[s].input=n.replace(new RegExp("/[a-z]*/style.css$"),`/${i.activeTheme}/style.css`):m[s]=n.replace(new RegExp("/[a-z]*/style.css$"),`/${i.activeTheme}/style.css`))});const g=d.options.assets,f=[],y=[{patterns:f,path:"angular/global"}];if("STATIC"===t.languageBundleSources)for(const e of Object.values(t.supportedLanguages))e.angular&&f.push(`${e.angular}.js`);y.forEach(({patterns:e=[],path:s})=>{let t="**/*";1==e.length?t=e[0]:e.length>1&&(t=`{${e.join(",")}}`),["libraries/locales",`node_modules/${WM_NPM_SCOPE}/app-ng-runtime/locales`].forEach(e=>{(e=>{const s=g.find(s=>s.input===e.input&&s.output===e.output);s?s.glob=e.glob:g.push(e)})({glob:t,input:`${e}/${s}`,output:`/locales/${s}`})})}),d.options.assets=g,await setBuildCustomizations(p);const b=d.configurations.production,h=d.configurations.development;if(b.aot=!1!==r.aot,b.buildOptimizer=!1!==r.buildOptimizer,u){const e=d.options.assets;e.push("src/manifest.json"),e.push("src/wmsw-worker.js"),b.serviceWorker=h.serviceWorker=!0,b.ngswConfigPath=h.ngswConfigPath="ngsw-config.json",delete d.configurations.production.customWebpackConfig}await writeFile(c,JSON.stringify(p,null,4))};module.exports={updateAngularJSON:updateAngularJSON,addToScripts:addToScripts};
1
+ const cheerio=require("cheerio"),{writeFile:writeFile,readFileSync:readFileSync,readDir:readDir,isMobileProject:isMobileProject,usesFoundationStyling:usesFoundationStyling,APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH}=require("./wm-utils"),{WM_NPM_SCOPE:WM_NPM_SCOPE}=require("./wm-namespace"),markScriptsAsLazy=e=>{const s=["./node_modules/d3/dist/d3.min.js","./node_modules/@wavemaker/nvd3/build/nv.d3.min.js","./node_modules/summernote/dist/summernote-lite.min.js",global._WM_PACKAGE_PATH+"/scripts/datatable/datatable.js","./node_modules/jquery-ui/ui/widgets/sortable.js","./node_modules/jquery-ui/ui/widgets/droppable.js","./node_modules/jquery-ui/ui/widgets/resizable.js","./node_modules/hammerjs/hammer.min.js","./node_modules/iscroll/build/iscroll.js"];if("string"==typeof e){let t=e.replace(/^(\.\/)/,"").replace(/\//g,"-").replace(/@/g,"");if(t=t.substring(0,t.lastIndexOf(".")),s.includes(e))return{input:e,inject:!1,bundleName:t}}return e},setBuildCustomizations=async e=>{const s=e.projects["angular-app"].architect.build,t=s.options.scripts;s.options.scripts=t.map(e=>markScriptsAsLazy(e))},addToScripts=async(e,s,t=[],n=[])=>{const i=`${s}/angular.json`;let o=readFileSync(i,!0);const a=o.projects["angular-app"].architect.build;let l=a.options.scripts;const r=`${s+"/src/app/extensions"}`,u=await readDir(r);u.length&&n.push("./src/app/extensions/"+u[0]),a.options.scripts=[...t,...l,...n],await writeFile(i,JSON.stringify(o,null,4))},updateAngularJSON=async(e,s,t,n,i,o,a,l,r,u)=>{const c=`${s}/angular.json`;let p=readFileSync(c,!0);const d=p.projects["angular-app"].architect.build;a&&a.trim().length>0&&(d.configurations.production.deployUrl=a,d.configurations.development.deployUrl=a),d.configurations.production.outputPath=d.configurations.production.outputPath+"/"+global.randomHash,d.configurations.development.outputPath=d.configurations.development.outputPath+"/"+global.randomHash;let m=d.options.styles;if(usesFoundationStyling(t)){const e=(m=m.filter(e=>"string"==typeof e?!(e.includes("src/assets/styles/css/wm-style.css")||e.includes("src/assets/styles/css/wm-responsive.css")):"object"!=typeof e||!e.input||!e.input.includes("src/assets/themes/material/style.css"))).findIndex(e=>"object"==typeof e&&e.input&&e.input.includes("app.css")),s=`./node_modules/${WM_NPM_SCOPE}/foundation-css/foundation/foundation.css`,t={input:`src/assets/${APP_OVERRIDE_CSS_PATH}`,inject:!1,bundleName:"wm-styles"};-1!==e?m.splice(e,0,s,t):m.push(s,t),d.options.styles=m}if(isMobileProject(t)){const e=m.findIndex(e=>{let s="object"==typeof e;if(s){return(s?e.input:e).includes("themes")}return!1}),s=m[e].input;m[e].bundleName="wm-android-styles",m[e].input=m[e].input.replace(new RegExp("/[a-z]*/style.css$"),`/${n.activeTheme}/android/style.css`);const t=Object.assign({},m[e]);t.input=s.replace(new RegExp("/[a-z]*/style.css$"),`/${n.activeTheme}/ios/style.css`),t.bundleName="wm-ios-styles",m.push(t);const i=m.findIndex(e=>{let s="object"==typeof e;if(s){return"src/assets/app.css"===(s?e.input:e)}return!1});m[i].bundleName="wm-android-styles";const o=Object.assign({},m[i]);o.bundleName="wm-ios-styles",m.push(o)}m.forEach((e,s)=>{let t="object"==typeof e,i=t?e.input:e;!i.includes("themes")||i.includes("/android/")||i.includes("/ios/")||(t?m[s].input=i.replace(new RegExp("/[a-z]*/style.css$"),`/${n.activeTheme}/style.css`):m[s]=i.replace(new RegExp("/[a-z]*/style.css$"),`/${n.activeTheme}/style.css`))});const g=d.options.assets,f=[],y=[{patterns:f,path:"angular/global"}];if("STATIC"===t.languageBundleSources)for(const e of Object.values(t.supportedLanguages))e.angular&&f.push(`${e.angular}.js`);y.forEach(({patterns:e=[],path:s})=>{let t="**/*";1==e.length?t=e[0]:e.length>1&&(t=`{${e.join(",")}}`),["libraries/locales",`node_modules/${WM_NPM_SCOPE}/app-ng-runtime/locales`].forEach(e=>{(e=>{const s=g.find(s=>s.input===e.input&&s.output===e.output);s?s.glob=e.glob:g.push(e)})({glob:t,input:`${e}/${s}`,output:`/locales/${s}`})})}),d.options.assets=g,await setBuildCustomizations(p);const b=d.configurations.production,h=d.configurations.development;if(b.aot=!1!==l.aot,b.buildOptimizer=!1!==l.buildOptimizer,u){const e=d.options.assets;e.push("src/manifest.json"),e.push("src/wmsw-worker.js"),b.serviceWorker=h.serviceWorker=!0,b.ngswConfigPath=h.ngswConfigPath="ngsw-config.json",delete d.configurations.production.customWebpackConfig}await writeFile(c,JSON.stringify(p,null,4))};module.exports={updateAngularJSON:updateAngularJSON,addToScripts:addToScripts};
package/src/wm-utils.js CHANGED
@@ -1 +1 @@
1
- const util=require("util"),fs=require("fs"),rimraf=require("rimraf"),decodeUriComponent=require("decode-uri-component"),upperFirst=require("lodash/upperFirst"),tar=require("tar-fs"),prettier=require("prettier"),js_beautify=require("js-beautify"),html_beautify=require("js-beautify").html,path=require("path"),defaultEslintConfig=require("./eslintrc_config"),mergeWith=require("lodash/mergeWith"),stat=util.promisify(fs.stat),createDir=util.promisify(fs.mkdir),createReadStream=util.promisify(fs.createReadStream),readFile=util.promisify(fs.readFile),writeFile=util.promisify(fs.writeFile),readDir=util.promisify(fs.readdir),rename=util.promisify(fs.rename),searchFileByName=(e,t,r)=>{if(!fs.existsSync(e))return;fs.readdirSync(e).forEach(i=>{const s=path.join(e,i);fs.lstatSync(s).isDirectory()?searchFileByName(s,t,r):t.test(s)&&r(s)})},deleteResource=async e=>stat(e).then(()=>new Promise((t,r)=>{rimraf(e,()=>t())}),()=>Promise.resolve()),getComponentName=e=>`${e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}Component`,getComponentModuleName=e=>`${e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}Module`,getSafeObjectKey=e=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?e:`'${e}'`,decodeURIComponent=e=>decodeUriComponent(e.replace(/\+/g," ")),createTar=(e,t)=>new Promise((r,i)=>{tar.pack(e).pipe(fs.createWriteStream(t)).on("finish",r)}),extractTar=(e,t)=>new Promise((r,i)=>{fs.createReadStream(e).pipe(tar.extract(t)).on("finish",r)}),getWebAppPath=e=>`${e}/src/main/webapp`,getLayoutsConfigPath=e=>`${getWebAppPath(e)}/layouts/layouts-config.json`,getLayoutsDirPath=e=>`${getWebAppPath(e)}/layouts`,getPagesDirPath=e=>`${getWebAppPath(e)}/pages`,getPagesConfigPath=e=>`${getWebAppPath(e)}/pages/pages-config.json`,getPrefabsDirPath=e=>`${getWebAppPath(e)}/WEB-INF/prefabs`,getPrefabConfigPath=(e,t)=>`${getPrefabsDirPath(e)}/${t}/webapp/config.json`,getPrefabPagesDirPath=(e,t)=>`${getPrefabsDirPath(e)}/${t}/webapp/pages`,getSecurityConfigPath=e=>`${e}/services/securityService/designtime/intercept-urls.json`,getRolesConfigPath=e=>`${e}/services/securityService/designtime/roles.json`,getAuthInfoFilePath=e=>`${e}/services/securityService/designtime/auth-info.json`,getAppJsFilePath=e=>`${getWebAppPath(e)}/app.js`,getAppVariablesFilePath=e=>`${getWebAppPath(e)}/app.variables.json`,getThemesConfigPropertiesFilePath=e=>`${getWebAppPath(e)}/themes/themes-config.json`,getWmProjectPropertiesFilePath=e=>`${e}/target/ui-resources/wmProperties.js`,getLegacyWmProjectPropertiesFilePath=e=>`${e}/.wmproject.properties`,getIndexHtmlPath=e=>`${getWebAppPath(e)}/index.html`,{WM_NPM_SCOPE:_WM_NPM_SCOPE}=require("./wm-namespace");let codegenPath=`./node_modules/${_WM_NPM_SCOPE}/angular-codegen`;const setCodegenPath=e=>{e&&(codegenPath=e)},getCodegenPath=()=>codegenPath,generateRandomHash=()=>Array.from(Array(20),()=>Math.floor(36*Math.random()).toString(36)).join(""),formatContents=(e="",t)=>"javascript"===t?js_beautify(e,{}):prettier.format(e,{semi:!1,parser:"typescript",tabWidth:4}),formatMarkup=(e="")=>html_beautify(e),isMobileProject=e=>"MOBILE"===e.platformType,isPrefabProject=e=>"PREFAB"===e.type,isPrismProject=e=>"PRISM"===e.template,readFileSync=(e,t)=>{let r=fs.readFileSync(e);return t?JSON.parse(r):r};function copyFileSync(e,t){try{fs.copyFileSync(e,t)}catch(t){console.error(`Error copying ${e}: ${t.message}`)}}function existsFileSync(e){try{return fs.existsSync(e)}catch(t){return console.error(`Error in checking file exist ${e}: ${t.message}`),!1}}function copyPrefabFiles(e,t){const r=path.resolve(`${e}`);if(fs.existsSync(r)){const e=fs.readdirSync(r).filter(e=>fs.statSync(path.join(r,e)).isDirectory());t=path.resolve(`${t}`),e.forEach(e=>{const i=path.join(r,e),s=path.join(i,"prefab-servicedefs.json");fs.existsSync(s)&&copyFileSync(s,path.join(t+"/src","servicedefs",`${e}-prefab-servicedefs.json`));const a=path.join(i,"webapp"),o=path.join(t+"/resources",e);fs.existsSync(a)&&copyDirWithExclusionsSync(a,o,["resources"]);const n=path.join(a,"resources"),c=path.join(t+"/resources",e+"/resources");fs.existsSync(n)&&copyDirWithExclusionsSync(n,c)})}}const copyDirWithExclusionsSync=(e,t,r=[])=>{fs.existsSync(t)||fs.mkdirSync(t,{recursive:!0});let i=[];try{i=fs.readdirSync(e,{withFileTypes:!0})}catch(e){if("ENOENT"!==e.code)throw e}for(const s of i){const i=path.join(e,s.name),a=path.join(t,s.name);r.includes(s.name)||(s.isDirectory()?copyDirWithExclusionsSync(i,a,r):fs.copyFileSync(i,a))}},initExpressionParser=()=>{const e=require("../dependencies/expression-parser.cjs"),t=require("../dependencies/pipe-provider.cjs");e.setPipeProvider(new t.PipeProvider({},{get:()=>{}},{}))},DESIGN_TOKENS_DIR_NAME="design-tokens",APP_OVERRIDE_CSS_PATH="design-tokens/app.override.css",OVERRIDE_TOKENS_PATH="design-tokens/overrides",updateEslintConfig=async(e,t)=>{let r,i;try{existsFileSync(path.join(e,"build-src","eslintrc-override.js"))?(r=require(path.join(e,"build-src","eslintrc-override.js")),(i=cleanupDeletedKeys(mergeWith({},defaultEslintConfig,r,deleteNullOverridesCustomizer))).extends&&!i.extends.includes("eslint:recommended")&&i.extends.push("eslint:recommended"),Object.prototype.hasOwnProperty.call(i,"extraLintPaths")&&delete i.extraLintPaths,Object.prototype.hasOwnProperty.call(i,"ignoreCssPatterns")&&delete i.ignoreCssPatterns):i=mergeWith({},defaultEslintConfig),await fs.writeFileSync(path.join(t,".eslintrc.js"),`const config = ${JSON.stringify(i,null,4)};\n\nmodule.exports = config;`)}catch(e){console.log(`Error in updating eslint config: ${e.message}`)}},getOverridePackageJson=async e=>existsFileSync(`${e=-1!==e.indexOf("target")?e.split("/target")[0]:e}/build-src/package-override.json`)?readFileSync(`${e}/build-src/package-override.json`,!0):null,DELETE_KEY=Symbol("deleteKey"),deleteNullOverridesCustomizer=(e,t)=>{if(null===t)return DELETE_KEY},cleanupDeletedKeys=e=>(e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(t=>{e[t]===DELETE_KEY?delete e[t]:cleanupDeletedKeys(e[t])}),e),mergePackageJsonWithOverrideJson=async(e,t,r)=>{try{const i={"eslint-plugin-regex":"1.10.0","@html-eslint/parser":"0.41.0","@html-eslint/eslint-plugin":"0.41.0","yaml-eslint-parser":"1.3.0","any-eslint-parser":"1.0.1","eslint-html-parser":"1.0.1","eslint-plugin-html":"8.1.2","jsonc-eslint-parser":"2.1.0"},s=await getOverridePackageJson(e);if(r&&(t.devDependencies={...t.devDependencies,...i}),s)return cleanupDeletedKeys(mergeWith({},t,s,deleteNullOverridesCustomizer))}catch(e){console.log(`Error in merging the package.json with overrider-package.json: ${e.message}`)}return t};module.exports={stat:stat,createDir:createDir,createReadStream:createReadStream,readFile:readFile,writeFile:writeFile,deleteResource:deleteResource,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getSafeObjectKey:getSafeObjectKey,decodeURIComponent:decodeURIComponent,createTar:createTar,extractTar:extractTar,readDir:readDir,rename:rename,searchFileByName:searchFileByName,updateEslintConfig:updateEslintConfig,existsFileSync:existsFileSync,getWebAppPath:getWebAppPath,getLayoutsConfigPath:getLayoutsConfigPath,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,getPagesConfigPath:getPagesConfigPath,getPrefabsDirPath:getPrefabsDirPath,getPrefabConfigPath:getPrefabConfigPath,getPrefabPagesDirPath:getPrefabPagesDirPath,getSecurityConfigPath:getSecurityConfigPath,getRolesConfigPath:getRolesConfigPath,getAuthInfoFilePath:getAuthInfoFilePath,getAppJsFilePath:getAppJsFilePath,getAppVariablesFilePath:getAppVariablesFilePath,getWmProjectPropertiesFilePath:getWmProjectPropertiesFilePath,getThemesConfigPropertiesFilePath:getThemesConfigPropertiesFilePath,getIndexHtmlPath:getIndexHtmlPath,formatContents:formatContents,formatMarkup:formatMarkup,isMobileProject:isMobileProject,isPrefabProject:isPrefabProject,isPrismProject:isPrismProject,readFileSync:readFileSync,getCodegenPath:getCodegenPath,setCodegenPath:setCodegenPath,initExpressionParser:initExpressionParser,copyFileSync:copyFileSync,copyPrefabFiles:copyPrefabFiles,generateRandomHash:generateRandomHash,copyDirWithExclusionsSync:copyDirWithExclusionsSync,DESIGN_TOKENS_DIR_NAME:"design-tokens",APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH,OVERRIDE_TOKENS_PATH:OVERRIDE_TOKENS_PATH,getLegacyWmProjectPropertiesFilePath:getLegacyWmProjectPropertiesFilePath,mergePackageJsonWithOverrideJson:mergePackageJsonWithOverrideJson};
1
+ const util=require("util"),fs=require("fs"),rimraf=require("rimraf"),decodeUriComponent=require("decode-uri-component"),upperFirst=require("lodash/upperFirst"),tar=require("tar-fs"),prettier=require("prettier"),js_beautify=require("js-beautify"),html_beautify=require("js-beautify").html,path=require("path"),defaultEslintConfig=require("./eslintrc_config"),mergeWith=require("lodash/mergeWith"),stat=util.promisify(fs.stat),createDir=util.promisify(fs.mkdir),createReadStream=util.promisify(fs.createReadStream),readFile=util.promisify(fs.readFile),writeFile=util.promisify(fs.writeFile),readDir=util.promisify(fs.readdir),rename=util.promisify(fs.rename),searchFileByName=(e,t,r)=>{if(!fs.existsSync(e))return;fs.readdirSync(e).forEach(i=>{const s=path.join(e,i);fs.lstatSync(s).isDirectory()?searchFileByName(s,t,r):t.test(s)&&r(s)})},deleteResource=async e=>stat(e).then(()=>new Promise((t,r)=>{rimraf(e,()=>t())}),()=>Promise.resolve()),getComponentName=e=>`${e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}Component`,getComponentModuleName=e=>`${e.split("-").map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join("")}Module`,getSafeObjectKey=e=>/^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(e)?e:`'${e}'`,decodeURIComponent=e=>decodeUriComponent(e.replace(/\+/g," ")),createTar=(e,t)=>new Promise((r,i)=>{tar.pack(e).pipe(fs.createWriteStream(t)).on("finish",r)}),extractTar=(e,t)=>new Promise((r,i)=>{fs.createReadStream(e).pipe(tar.extract(t)).on("finish",r)}),DESIGN_TOKENS_DIR_NAME="design-tokens",APP_OVERRIDE_CSS_PATH=`${DESIGN_TOKENS_DIR_NAME}/app.override.css`,OVERRIDE_TOKENS_PATH=`${DESIGN_TOKENS_DIR_NAME}/overrides`,getWebAppPath=e=>`${e}/src/main/webapp`,getLayoutsConfigPath=e=>`${getWebAppPath(e)}/layouts/layouts-config.json`,getLayoutsDirPath=e=>`${getWebAppPath(e)}/layouts`,getPagesDirPath=e=>`${getWebAppPath(e)}/pages`,getPagesConfigPath=e=>`${getWebAppPath(e)}/pages/pages-config.json`,getPrefabsDirPath=e=>`${getWebAppPath(e)}/WEB-INF/prefabs`,getPrefabConfigPath=(e,t)=>`${getPrefabsDirPath(e)}/${t}/webapp/config.json`,getPrefabPagesDirPath=(e,t)=>`${getPrefabsDirPath(e)}/${t}/webapp/pages`,getSecurityConfigPath=e=>`${e}/services/securityService/designtime/intercept-urls.json`,getRolesConfigPath=e=>`${e}/services/securityService/designtime/roles.json`,getAuthInfoFilePath=e=>`${e}/services/securityService/designtime/auth-info.json`,getAppJsFilePath=e=>`${getWebAppPath(e)}/app.js`,getAppVariablesFilePath=e=>`${getWebAppPath(e)}/app.variables.json`,getThemesConfigPropertiesFilePath=e=>`${getWebAppPath(e)}/themes/themes-config.json`,getWmProjectPropertiesFilePath=e=>`${e}/target/ui-resources/wmProperties.js`,getLegacyWmProjectPropertiesFilePath=e=>`${e}/.wmproject.properties`,getIndexHtmlPath=e=>`${getWebAppPath(e)}/index.html`,{WM_NPM_SCOPE:_WM_NPM_SCOPE}=require("./wm-namespace");let codegenPath=`./node_modules/${_WM_NPM_SCOPE}/angular-codegen`;const setCodegenPath=e=>{e&&(codegenPath=e)},getCodegenPath=()=>codegenPath,generateRandomHash=()=>Array.from(Array(20),()=>Math.floor(36*Math.random()).toString(36)).join(""),formatContents=(e="",t)=>"javascript"===t?js_beautify(e,{}):prettier.format(e,{semi:!1,parser:"typescript",tabWidth:4}),formatMarkup=(e="")=>html_beautify(e),isMobileProject=e=>"MOBILE"===e.platformType,isPrefabProject=e=>"PREFAB"===e.type,isPrismProject=e=>"PRISM"===e.template,usesFoundationStyling=e=>isPrismProject(e)||isPrefabProject(e),readFileSync=(e,t)=>{let r=fs.readFileSync(e);return t?JSON.parse(r):r};function copyFileSync(e,t){try{fs.copyFileSync(e,t)}catch(t){console.error(`Error copying ${e}: ${t.message}`)}}function existsFileSync(e){try{return fs.existsSync(e)}catch(t){return console.error(`Error in checking file exist ${e}: ${t.message}`),!1}}function copyPrefabFiles(e,t){const r=path.resolve(`${e}`);if(fs.existsSync(r)){const e=fs.readdirSync(r).filter(e=>fs.statSync(path.join(r,e)).isDirectory());t=path.resolve(`${t}`),e.forEach(e=>{const i=path.join(r,e),s=path.join(i,"prefab-servicedefs.json");fs.existsSync(s)&&copyFileSync(s,path.join(t+"/src","servicedefs",`${e}-prefab-servicedefs.json`));const a=path.join(i,"webapp"),o=path.join(t+"/resources",e);fs.existsSync(a)&&copyDirWithExclusionsSync(a,o,["resources",DESIGN_TOKENS_DIR_NAME]);const n=path.join(a,"resources"),c=path.join(t+"/resources",e+"/resources");fs.existsSync(n)&&copyDirWithExclusionsSync(n,c)})}}const copyDirWithExclusionsSync=(e,t,r=[])=>{fs.existsSync(t)||fs.mkdirSync(t,{recursive:!0});let i=[];try{i=fs.readdirSync(e,{withFileTypes:!0})}catch(e){if("ENOENT"!==e.code)throw e}for(const s of i){const i=path.join(e,s.name),a=path.join(t,s.name);r.includes(s.name)||(s.isDirectory()?copyDirWithExclusionsSync(i,a,r):fs.copyFileSync(i,a))}},initExpressionParser=()=>{const e=require("../dependencies/expression-parser.cjs"),t=require("../dependencies/pipe-provider.cjs");e.setPipeProvider(new t.PipeProvider({},{get:()=>{}},{}))},updateEslintConfig=async(e,t)=>{let r,i;try{existsFileSync(path.join(e,"build-src","eslintrc-override.js"))?(r=require(path.join(e,"build-src","eslintrc-override.js")),(i=cleanupDeletedKeys(mergeWith({},defaultEslintConfig,r,deleteNullOverridesCustomizer))).extends&&!i.extends.includes("eslint:recommended")&&i.extends.push("eslint:recommended"),Object.prototype.hasOwnProperty.call(i,"extraLintPaths")&&delete i.extraLintPaths,Object.prototype.hasOwnProperty.call(i,"ignoreCssPatterns")&&delete i.ignoreCssPatterns):i=mergeWith({},defaultEslintConfig),await fs.writeFileSync(path.join(t,".eslintrc.js"),`const config = ${JSON.stringify(i,null,4)};\n\nmodule.exports = config;`)}catch(e){console.log(`Error in updating eslint config: ${e.message}`)}},getOverridePackageJson=async e=>existsFileSync(`${e=-1!==e.indexOf("target")?e.split("/target")[0]:e}/build-src/package-override.json`)?readFileSync(`${e}/build-src/package-override.json`,!0):null,DELETE_KEY=Symbol("deleteKey"),deleteNullOverridesCustomizer=(e,t)=>{if(null===t)return DELETE_KEY},cleanupDeletedKeys=e=>(e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).forEach(t=>{e[t]===DELETE_KEY?delete e[t]:cleanupDeletedKeys(e[t])}),e),mergePackageJsonWithOverrideJson=async(e,t,r)=>{try{const i={"eslint-plugin-regex":"1.10.0","@html-eslint/parser":"0.41.0","@html-eslint/eslint-plugin":"0.41.0","yaml-eslint-parser":"1.3.0","any-eslint-parser":"1.0.1","eslint-html-parser":"1.0.1","eslint-plugin-html":"8.1.2","jsonc-eslint-parser":"2.1.0"},s=await getOverridePackageJson(e);if(r&&(t.devDependencies={...t.devDependencies,...i}),s)return cleanupDeletedKeys(mergeWith({},t,s,deleteNullOverridesCustomizer))}catch(e){console.log(`Error in merging the package.json with overrider-package.json: ${e.message}`)}return t};module.exports={stat:stat,createDir:createDir,createReadStream:createReadStream,readFile:readFile,writeFile:writeFile,deleteResource:deleteResource,getComponentName:getComponentName,getComponentModuleName:getComponentModuleName,getSafeObjectKey:getSafeObjectKey,decodeURIComponent:decodeURIComponent,createTar:createTar,extractTar:extractTar,readDir:readDir,rename:rename,searchFileByName:searchFileByName,updateEslintConfig:updateEslintConfig,existsFileSync:existsFileSync,getWebAppPath:getWebAppPath,getLayoutsConfigPath:getLayoutsConfigPath,getLayoutsDirPath:getLayoutsDirPath,getPagesDirPath:getPagesDirPath,getPagesConfigPath:getPagesConfigPath,getPrefabsDirPath:getPrefabsDirPath,getPrefabConfigPath:getPrefabConfigPath,getPrefabPagesDirPath:getPrefabPagesDirPath,getSecurityConfigPath:getSecurityConfigPath,getRolesConfigPath:getRolesConfigPath,getAuthInfoFilePath:getAuthInfoFilePath,getAppJsFilePath:getAppJsFilePath,getAppVariablesFilePath:getAppVariablesFilePath,getWmProjectPropertiesFilePath:getWmProjectPropertiesFilePath,getThemesConfigPropertiesFilePath:getThemesConfigPropertiesFilePath,getIndexHtmlPath:getIndexHtmlPath,formatContents:formatContents,formatMarkup:formatMarkup,isMobileProject:isMobileProject,isPrefabProject:isPrefabProject,isPrismProject:isPrismProject,usesFoundationStyling:usesFoundationStyling,readFileSync:readFileSync,getCodegenPath:getCodegenPath,setCodegenPath:setCodegenPath,initExpressionParser:initExpressionParser,copyFileSync:copyFileSync,copyPrefabFiles:copyPrefabFiles,generateRandomHash:generateRandomHash,copyDirWithExclusionsSync:copyDirWithExclusionsSync,DESIGN_TOKENS_DIR_NAME:DESIGN_TOKENS_DIR_NAME,APP_OVERRIDE_CSS_PATH:APP_OVERRIDE_CSS_PATH,OVERRIDE_TOKENS_PATH:OVERRIDE_TOKENS_PATH,getLegacyWmProjectPropertiesFilePath:getLegacyWmProjectPropertiesFilePath,mergePackageJsonWithOverrideJson:mergePackageJsonWithOverrideJson};