feat(core): add insights output (#575)
This commit is contained in:
@@ -5,6 +5,7 @@ import octokit from "@octokit/graphql"
|
||||
import fs from "fs/promises"
|
||||
import paths from "path"
|
||||
import sgit from "simple-git"
|
||||
import processes from "child_process"
|
||||
import metrics from "../metrics/index.mjs"
|
||||
import setup from "../metrics/setup.mjs"
|
||||
import mocks from "../mocks/index.mjs"
|
||||
@@ -96,8 +97,8 @@ async function wait(seconds) {
|
||||
...config
|
||||
} = metadata.plugins.core.inputs.action({core})
|
||||
const q = {...query, ...(_repo ? {repo:_repo} : null), template}
|
||||
const _output = ["svg", "jpeg", "png", "json", "markdown", "markdown-pdf"].includes(config["config.output"]) ? config["config.output"] : metadata.templates[template].formats[0] ?? null
|
||||
const filename = _filename.replace(/[*]/g, {jpeg:"jpg", markdown:"md", "markdown-pdf":"pdf"}[_output] ?? _output)
|
||||
const _output = ["svg", "jpeg", "png", "json", "markdown", "markdown-pdf", "insights"].includes(config["config.output"]) ? config["config.output"] : metadata.templates[template].formats[0] ?? null
|
||||
const filename = _filename.replace(/[*]/g, {jpeg:"jpg", markdown:"md", "markdown-pdf":"pdf", insights:"html"}[_output] ?? _output)
|
||||
|
||||
//Docker image
|
||||
if (_image)
|
||||
@@ -248,6 +249,22 @@ async function wait(seconds) {
|
||||
Object.assign(q, config)
|
||||
if (/markdown/.test(convert))
|
||||
info("Markdown cache", _markdown_cache)
|
||||
if (/insights/.test(convert)) {
|
||||
try {
|
||||
await new Promise(async (solve, reject) => {
|
||||
let stdout = ""
|
||||
setTimeout(() => reject("Timeout while waiting for Insights webserver"), 5*60*1000)
|
||||
const web = await processes.spawn("node", ["/metrics/source/app/web/index.mjs"], {env:{...process.env, NO_SETTINGS: true }})
|
||||
web.stdout.on("data", data => (console.debug(`web > ${data}`), stdout += data, /Server ready !/.test(stdout) ? solve() : null))
|
||||
web.stderr.on("data", data => console.debug(`web > ${data}`))
|
||||
})
|
||||
info("Insights webserver", "ok")
|
||||
}
|
||||
catch (error) {
|
||||
info("Insights webserver", "(failed to initialize)")
|
||||
throw error
|
||||
}
|
||||
}
|
||||
|
||||
//Base content
|
||||
info.break()
|
||||
|
||||
Reference in New Issue
Block a user