mirror of
https://github.com/primer/css.git
synced 2024-12-18 03:31:43 +03:00
scoreboard reorg; better docs test output parsing
This commit is contained in:
parent
4ba2368977
commit
c2226b6841
@ -7,27 +7,54 @@ const lernaConfig = require(join(rootDir, 'lerna.json'))
|
|||||||
const modulesDir = join(rootDir, 'modules')
|
const modulesDir = join(rootDir, 'modules')
|
||||||
require('console.table')
|
require('console.table')
|
||||||
|
|
||||||
const checks = [
|
const unique = list => Array.from(new Set(list)).sort()
|
||||||
function hasStories(module) {
|
|
||||||
const key = 'has stories'
|
const matchAll = (pattern, text) => {
|
||||||
|
const matches = []
|
||||||
|
let match
|
||||||
|
while (match = pattern.exec(text)) {
|
||||||
|
matches.push(match)
|
||||||
|
}
|
||||||
|
return matches
|
||||||
|
}
|
||||||
|
|
||||||
|
const checks = {
|
||||||
|
'has stories': (module, key) => {
|
||||||
return globby(join(module.path, '**/stories.js'))
|
return globby(join(module.path, '**/stories.js'))
|
||||||
.then(files => ({[key]: files.length > 0 ? 'yes' : 'no'}))
|
.then(files => ({
|
||||||
|
[key]: files.length > 0 ? 'yes' : 'no'
|
||||||
|
}))
|
||||||
},
|
},
|
||||||
function passesDocTest(module) {
|
'docs test': (module, key) => {
|
||||||
const key = 'docs test'
|
|
||||||
return execa(join(rootDir, 'script/test-docs'), {
|
return execa(join(rootDir, 'script/test-docs'), {
|
||||||
cwd: module.path
|
cwd: module.path
|
||||||
})
|
})
|
||||||
.then(result => {
|
.then(result => ({[key]: 'pass'}))
|
||||||
return {[key]: '✔'}
|
.catch(({stderr}) => {
|
||||||
})
|
const pattern = /("\.[-\w]+") is not documented/g
|
||||||
.catch(result => {
|
const matches = matchAll(pattern, stderr)
|
||||||
return {[key]: 'FAIL'}
|
.map(match => match[1])
|
||||||
|
let missing = matches ? Array.from(matches) : []
|
||||||
|
const max = 5
|
||||||
|
if (missing.length > max) {
|
||||||
|
const more = missing.length - max
|
||||||
|
missing = missing.slice(0, max).concat(`and ${more} more...`)
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
[key]: 'FAIL',
|
||||||
|
'missing docs': unique(missing).join(', ')
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
]
|
}
|
||||||
|
|
||||||
const modules = globby(join(modulesDir, 'primer-*'))
|
const args = process.argv.slice(2)
|
||||||
|
|
||||||
|
const modules = args.length
|
||||||
|
? Promise.resolve(args)
|
||||||
|
: globby(join(modulesDir, 'primer-*'))
|
||||||
|
|
||||||
|
modules
|
||||||
.then(moduleDirs => {
|
.then(moduleDirs => {
|
||||||
console.log('Found %d module directories', moduleDirs.length)
|
console.log('Found %d module directories', moduleDirs.length)
|
||||||
return moduleDirs
|
return moduleDirs
|
||||||
@ -40,19 +67,23 @@ const modules = globby(join(modulesDir, 'primer-*'))
|
|||||||
})
|
})
|
||||||
.then(modules => {
|
.then(modules => {
|
||||||
console.log('Filtered to %d modules (excluding meta-packages)', modules.length)
|
console.log('Filtered to %d modules (excluding meta-packages)', modules.length)
|
||||||
const queue = new PromiseQueue({concurrency: 5})
|
|
||||||
|
const queue = new PromiseQueue({concurrency: 3})
|
||||||
|
|
||||||
for (const module of modules) {
|
for (const module of modules) {
|
||||||
module.checks = {}
|
module.checks = {}
|
||||||
for (const check of checks) {
|
for (const [name, check] of Object.entries(checks)) {
|
||||||
queue.add(() => {
|
queue.add(() => {
|
||||||
console.warn(`? check: ${module.name} ${check.name}`)
|
// console.warn(`? check: ${module.name} ${name}`)
|
||||||
return check(module)
|
return check(module, name)
|
||||||
.then(result => {
|
.then(result => {
|
||||||
Object.assign(module.checks, result)
|
Object.assign(module.checks, result)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.warn(`Running ${queue.size} checks...`)
|
||||||
return queue.onIdle().then(() => modules)
|
return queue.onIdle().then(() => modules)
|
||||||
})
|
})
|
||||||
.then(modules => {
|
.then(modules => {
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"console.table": "^0.10.0",
|
"console.table": "^0.10.0",
|
||||||
"execa": "^0.10.0",
|
"execa": "^0.10.0",
|
||||||
"globby": "^8.0.1",
|
"globby": "^6.1.0",
|
||||||
"p-queue": "^2.4.2"
|
"p-queue": "^2.4.2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user