1
1
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:
Shawn Allen 2018-05-03 15:17:28 -07:00
parent 4ba2368977
commit c2226b6841
2 changed files with 49 additions and 18 deletions

View File

@ -7,27 +7,54 @@ const lernaConfig = require(join(rootDir, 'lerna.json'))
const modulesDir = join(rootDir, 'modules')
require('console.table')
const checks = [
function hasStories(module) {
const key = 'has stories'
const unique = list => Array.from(new Set(list)).sort()
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'))
.then(files => ({[key]: files.length > 0 ? 'yes' : 'no'}))
.then(files => ({
[key]: files.length > 0 ? 'yes' : 'no'
}))
},
function passesDocTest(module) {
const key = 'docs test'
'docs test': (module, key) => {
return execa(join(rootDir, 'script/test-docs'), {
cwd: module.path
})
.then(result => {
return {[key]: '✔'}
})
.catch(result => {
return {[key]: 'FAIL'}
.then(result => ({[key]: 'pass'}))
.catch(({stderr}) => {
const pattern = /("\.[-\w]+") is not documented/g
const matches = matchAll(pattern, stderr)
.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 => {
console.log('Found %d module directories', moduleDirs.length)
return moduleDirs
@ -40,19 +67,23 @@ const modules = globby(join(modulesDir, 'primer-*'))
})
.then(modules => {
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) {
module.checks = {}
for (const check of checks) {
for (const [name, check] of Object.entries(checks)) {
queue.add(() => {
console.warn(`? check: ${module.name} ${check.name}`)
return check(module)
// console.warn(`? check: ${module.name} ${name}`)
return check(module, name)
.then(result => {
Object.assign(module.checks, result)
})
})
}
}
console.warn(`Running ${queue.size} checks...`)
return queue.onIdle().then(() => modules)
})
.then(modules => {

View File

@ -3,7 +3,7 @@
"devDependencies": {
"console.table": "^0.10.0",
"execa": "^0.10.0",
"globby": "^8.0.1",
"globby": "^6.1.0",
"p-queue": "^2.4.2"
}
}