refactor(batchSetting): 重构批量设置脚本
- 将单个配置文件改为模块化设计,便于维护和扩展 - 新增 UpstarConfig.js 文件,作为独立的配置模块 - 重构 batchSetting.js 文件,使其支持多配置文件的批量处理 - 优化代码结构,提高可读性和可维护性
This commit is contained in:
		
							
								
								
									
										26
									
								
								tools/batchSetting.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								tools/batchSetting.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,26 @@ | ||||
| const fs = require("fs"); | ||||
| const path = require("path"); | ||||
| const scope = ["UpstarConfig"].filter(Boolean); | ||||
| const start = () => { | ||||
|   const configs = scope.map((key) => { | ||||
|     const file = require(`./batchTemples/${key}.js`); | ||||
|     return file; | ||||
|   }); | ||||
|   configs.forEach((file) => { | ||||
|     const { key, values, interval, num, template } = file; | ||||
|     const getStr = (index) => { | ||||
|       let str = template; | ||||
|       values.forEach((v, i) => { | ||||
|         const reg = new RegExp(`S${i + 1}`, "g"); | ||||
|         str = str.replace(reg, v + index * interval[i]); | ||||
|       }); | ||||
|       return str; | ||||
|     }; | ||||
|     const content = Array(num) | ||||
|       .fill(1) | ||||
|       .map((e, i) => `${getStr(i)}`) | ||||
|       .join(","); | ||||
|     fs.writeFileSync(`./dist/${key}.txt`, content); | ||||
|   }); | ||||
| }; | ||||
| start(); | ||||
		Reference in New Issue
	
	Block a user