mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Create update.js
This commit is contained in:
parent
d519b521eb
commit
7e5b2edb42
1 changed files with 52 additions and 0 deletions
52
scripts/commands/status/update.js
Normal file
52
scripts/commands/status/update.js
Normal file
|
@ -0,0 +1,52 @@
|
|||
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)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue