mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 09:00:07 -04:00
52 lines
1.6 KiB
JavaScript
52 lines
1.6 KiB
JavaScript
const { file, markdown, logger, table } = require('../../core')
|
|
const { program } = require('commander')
|
|
const _ = require('lodash')
|
|
|
|
const CONFIGS_PATH = process.env.CONFIGS_PATH || 'sites/**/*.config.js'
|
|
|
|
const options = program
|
|
.option('-c, --config <config>', 'Set path to config file', '.readme/status.json')
|
|
.parse(process.argv)
|
|
.opts()
|
|
|
|
async function main() {
|
|
let data = []
|
|
|
|
const files = await file.list(CONFIGS_PATH).catch(console.error)
|
|
for (const filepath of files) {
|
|
try {
|
|
const { site, ignore } = require(file.resolve(filepath))
|
|
|
|
if (ignore) continue
|
|
|
|
data.push([
|
|
site,
|
|
`<a href="https://github.com/iptv-org/epg/actions/workflows/${site}.yml"><img src="https://github.com/iptv-org/epg/actions/workflows/${site}.yml/badge.svg" alt="${site}" style="max-width: 100%;"></a>`
|
|
])
|
|
} catch (err) {
|
|
console.error(err)
|
|
continue
|
|
}
|
|
}
|
|
|
|
data = Object.values(_.groupBy(data, item => item[0]))
|
|
|
|
const output = table.create(data, [
|
|
'Site',
|
|
'Status '
|
|
])
|
|
|
|
await file.create('./.readme/_sites.md', output)
|
|
|
|
await updateMarkdown()
|
|
}
|
|
|
|
main()
|
|
|
|
async function updateMarkdown() {
|
|
logger.info('updating status.md...')
|
|
|
|
const config = require(file.resolve(options.config))
|
|
await file.createDir(file.dirname(config.build))
|
|
await markdown.compile(options.config)
|
|
}
|