forked from opentiny/tiny-vue
fix(automate): fix reviews comments (#1187)
This commit is contained in:
parent
c4a7391bdd
commit
642e31eee6
|
@ -12,6 +12,9 @@
|
|||
"fs-extra": "^11.2.0",
|
||||
"esno": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^20.10.5"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC"
|
||||
|
|
|
@ -1,31 +1,24 @@
|
|||
import path from 'node:path'
|
||||
import fs from 'fs-extra'
|
||||
import { findAllFiles } from './utils/find-all-files'
|
||||
|
||||
const demo = path.resolve('../../examples/sites/demos/pc/app')
|
||||
|
||||
let apiSize = 0
|
||||
let apiLength = 0
|
||||
let compNumber = 0
|
||||
|
||||
// 递归遍历所有的组件,然后依次修改文件内容和修改文件格式
|
||||
const findAllpage = (packagesPath) => {
|
||||
if (fs.statSync(packagesPath).isDirectory()) {
|
||||
fs.readdirSync(packagesPath).forEach((childPatch) => {
|
||||
findAllpage(path.join(packagesPath, childPatch))
|
||||
})
|
||||
} else {
|
||||
if (packagesPath.includes('webdoc') && packagesPath.endsWith('.js')) {
|
||||
const stats = fs.statSync(packagesPath)
|
||||
const string = fs.readFileSync(packagesPath, 'utf8').replace(/\s/g, '')
|
||||
compNumber++
|
||||
apiLength += string.length
|
||||
apiSize += stats.size
|
||||
}
|
||||
}
|
||||
}
|
||||
const demoUrl = path.join(process.cwd(), '../../examples/sites/demos/pc/app')
|
||||
|
||||
export const statistics = () => {
|
||||
findAllpage(demo)
|
||||
let apiSize = 0
|
||||
let apiLength = 0
|
||||
let compNumber = 0
|
||||
|
||||
const readAndProcessFile = (filePath) => {
|
||||
const stats = fs.statSync(filePath)
|
||||
const string = fs.readFileSync(filePath, 'utf8').replace(/\s/g, '')
|
||||
compNumber++
|
||||
apiLength += string.length
|
||||
apiSize += stats.size
|
||||
}
|
||||
|
||||
findAllFiles(demoUrl, readAndProcessFile)
|
||||
|
||||
return {
|
||||
apiSize,
|
||||
apiLength,
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
import fs from 'fs-extra'
|
||||
import path from 'node:path'
|
||||
|
||||
/**
|
||||
* @param packagesPath {String} 文件夹或者文件路径
|
||||
* @param callback {Function} 处理目标文件的回调函数
|
||||
*/
|
||||
export const findAllFiles = (packagesPath: string, callback: (path: string) => void) => {
|
||||
const findAllpage = (packagesPath) => {
|
||||
try {
|
||||
if (fs.statSync(packagesPath).isDirectory()) {
|
||||
fs.readdirSync(packagesPath).forEach((childPatch) => {
|
||||
findAllpage(path.join(packagesPath, childPatch))
|
||||
})
|
||||
} else {
|
||||
if (packagesPath.includes('webdoc') && packagesPath.endsWith('.js')) {
|
||||
callback(packagesPath)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error processing ${packagesPath}: ${error.message}`)
|
||||
}
|
||||
}
|
||||
findAllpage(packagesPath)
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"target": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"strict": true,
|
||||
"declaration": true,
|
||||
"noUnusedLocals": true,
|
||||
"esModuleInterop": true,
|
||||
"outDir": "dist",
|
||||
"lib": ["ESNext"],
|
||||
"sourceMap": false,
|
||||
"noEmitOnError": true,
|
||||
"noImplicitAny": false
|
||||
},
|
||||
"include": ["src/**/*", "*.d.ts"],
|
||||
"exclude": ["dist", "node_modules"]
|
||||
}
|
Loading…
Reference in New Issue