fix(ci): vercel (#1125)
This commit is contained in:
27
.github/scripts/preview.mjs
vendored
27
.github/scripts/preview.mjs
vendored
@@ -56,7 +56,6 @@ fs.copyFile(paths.join(__web, "style.vars.css"), paths.join(__preview_css, "styl
|
||||
fs.copyFile(paths.join(__node_modules, "prismjs/themes/prism-tomorrow.css"), paths.join(__preview_css, "style.prism.css"))
|
||||
//Scripts
|
||||
fs.writeFile(paths.join(__preview_js, "app.js"), `${await fs.readFile(paths.join(__web, "app.js"))}`)
|
||||
fs.writeFile(paths.join(__preview_js, "app.placeholder.js"), `${await fs.readFile(paths.join(__web, "app.placeholder.js"))}`)
|
||||
fs.copyFile(paths.join(__node_modules, "ejs/ejs.min.js"), paths.join(__preview_js, "ejs.min.js"))
|
||||
fs.writeFile(paths.join(__preview_js, "faker.min.js"), "import {faker} from '/.js/faker/index.mjs';globalThis.faker=faker;globalThis.placeholder.init(globalThis)")
|
||||
for (const path of [[], ["locale"]]) {
|
||||
@@ -76,15 +75,31 @@ fs.copyFile(paths.join(__node_modules, "prismjs/components/prism-yaml.min.js"),
|
||||
fs.copyFile(paths.join(__node_modules, "prismjs/components/prism-markdown.min.js"), paths.join(__preview_js, "prism.markdown.min.js"))
|
||||
fs.copyFile(paths.join(__node_modules, "clipboard/dist/clipboard.min.js"), paths.join(__preview_js, "clipboard.min.js"))
|
||||
//Meta
|
||||
fs.writeFile(paths.join(__preview, ".modes"), JSON.stringify(["embed", "insights"]))
|
||||
fs.writeFile(paths.join(__preview, ".version"), JSON.stringify(`${conf.package.version}-preview`))
|
||||
fs.writeFile(paths.join(__preview, ".hosted"), JSON.stringify({by: "metrics", link: "https://github.com/lowlighter/metrics"}))
|
||||
//Embed
|
||||
{
|
||||
const __web_embed = paths.join(paths.join(__web, "embed"))
|
||||
const __web_embed_placeholders = paths.join(__web_embed, "placeholders")
|
||||
const __preview_embed = paths.join(__preview, "embed")
|
||||
const __preview_embed_placeholders = paths.join(__preview, ".placeholders")
|
||||
const __preview_embed_js = paths.join(__preview_js, "embed")
|
||||
await fs.mkdir(__preview_embed, {recursive: true})
|
||||
await fs.mkdir(__preview_embed_placeholders, {recursive: true})
|
||||
await fs.mkdir(__preview_embed_js, {recursive: true})
|
||||
fs.writeFile(paths.join(__preview_embed, "index.html"), `${await fs.readFile(paths.join(__web_embed, "index.html"))}`)
|
||||
fs.writeFile(paths.join(__preview_embed_js, "app.js"), `${await fs.readFile(paths.join(__web_embed, "app.js"))}`)
|
||||
fs.writeFile(paths.join(__preview_embed_js, "app.placeholder.js"), `${await fs.readFile(paths.join(__web_embed, "app.placeholder.js"))}`)
|
||||
for (const file of await fs.readdir(__web_embed_placeholders))
|
||||
fs.copyFile(paths.join(__web_embed_placeholders, file), paths.join(__preview_embed_placeholders, file))
|
||||
}
|
||||
//Insights
|
||||
for (const insight of ["insights", "about"]) {
|
||||
const __web_insights = paths.join(paths.join(__web, insight))
|
||||
const __preview_insights = paths.join(__preview, `${insight}/.statics`)
|
||||
for (const insights of ["insights", "about"]) {
|
||||
const __web_insights = paths.join(paths.join(__web, "insights"))
|
||||
const __preview_insights = paths.join(__preview, `${insights}/.statics`)
|
||||
await fs.mkdir(__preview_insights, {recursive: true})
|
||||
|
||||
fs.copyFile(paths.join(__web, insight, "index.html"), paths.join(__preview, insight, "index.html"))
|
||||
fs.copyFile(paths.join(__web_insights, "index.html"), paths.join(__preview, insights, "index.html"))
|
||||
for (const file of await fs.readdir(__web_insights)) {
|
||||
if (file !== ".statics")
|
||||
fs.copyFile(paths.join(__web_insights, file), paths.join(__preview_insights, file))
|
||||
|
||||
@@ -224,7 +224,7 @@ metadata.plugin = async function({__plugins, __templates, name, logger}) {
|
||||
console.debug(`metrics/extras > ${name} > ${key} > require [${required}]`)
|
||||
|
||||
//Legacy handling
|
||||
const enabled = extras?.features ?? extras?.default ?? false
|
||||
const enabled = extras?.features ?? extras?.default ?? (typeof extras === "boolean" ? extras : false)
|
||||
if (typeof enabled === "boolean") {
|
||||
console.debug(`metrics/extras > ${name} > ${key} > extras features is set to ${enabled}`)
|
||||
if (!enabled)
|
||||
|
||||
@@ -65,7 +65,7 @@
|
||||
<div class="search">
|
||||
<div class="about">
|
||||
<small class="warning mb1" v-if="preview">
|
||||
Metrics insights are rendered by <a href="https://metrics.lecoq.io/">metrics.lecoq.io</a> in preview mode.<br>
|
||||
Metrics are rendered by <a href="https://metrics.lecoq.io/">metrics.lecoq.io</a> in preview mode.<br>
|
||||
Any backend editions won't be reflected but client-side rendering can still be tested.
|
||||
</small>
|
||||
<div class="warning mb1" v-if="(!requests.rest.remaining)||(!requests.graphql.remaining)">
|
||||
|
||||
@@ -53,6 +53,10 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
data.animated = animations
|
||||
console.debug(`metrics/compute/${login} > animations ${data.animated ? "enabled" : "disabled"}`)
|
||||
|
||||
//Extras features
|
||||
const extras = conf.settings?.extras?.features ?? conf.settings?.extras?.default ?? false
|
||||
console.debug(`metrics/compute/${login} > extras > ${JSON.stringify(extras)}`)
|
||||
|
||||
//Plugins
|
||||
for (const name of Object.keys(imports.plugins)) {
|
||||
if ((!plugins[name]?.enabled) || (!q[name]))
|
||||
@@ -60,7 +64,7 @@ export default async function({login, q}, {conf, data, rest, graphql, plugins, q
|
||||
pending.push((async () => {
|
||||
try {
|
||||
console.debug(`metrics/compute/${login}/plugins > ${name} > started`)
|
||||
data.plugins[name] = await imports.plugins[name]({login, q, imports, data, computed, rest, graphql, queries, account}, {extras: conf.settings?.extras?.features ?? conf.settings?.extras?.default ?? false, sandbox: conf.settings?.sandbox ?? false, ...plugins[name]})
|
||||
data.plugins[name] = await imports.plugins[name]({login, q, imports, data, computed, rest, graphql, queries, account}, {extras, sandbox: conf.settings?.sandbox ?? false, ...plugins[name]})
|
||||
console.debug(`metrics/compute/${login}/plugins > ${name} > completed`)
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
@@ -40,7 +40,7 @@ web.start = async () =>
|
||||
web.stop = async () => await web.instance.kill("SIGKILL")
|
||||
|
||||
//Web instance placeholder
|
||||
require("./../source/app/web/statics/app.placeholder.js")
|
||||
require("./../source/app/web/statics/embed/app.placeholder.js")
|
||||
const placeholder = globalThis.placeholder
|
||||
delete globalThis.placeholder
|
||||
placeholder.init({
|
||||
@@ -119,7 +119,7 @@ describe("GitHub Action", () =>
|
||||
if ((skip.includes(template)) || ((modes.length) && (!modes.includes("action"))))
|
||||
test.skip(name, () => null)
|
||||
else
|
||||
test(name, async () => expect(await action.run({template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, ...input})).toBe(true), timeout)
|
||||
test(name, async () => expect(await action.run({template, base: "", query: JSON.stringify(query), plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, retries:1, ...input})).toBe(true), timeout)
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
{"source": "/:login([-\\w]+)/:repository([-\\w]+)", "destination": "https://metrics.lecoq.io/:login/:repository"},
|
||||
{"source": "/about/query/:login", "destination": "https://metrics.lecoq.io/about/query/:login"},
|
||||
{"source": "/about/query/:login/:plugin", "destination": "https://metrics.lecoq.io/about/query/:login/:plugin"},
|
||||
{"source": "/insights/query/:login", "destination": "https://metrics.lecoq.io/insights/query/:login"},
|
||||
{"source": "/insights/query/:login/:plugin", "destination": "https://metrics.lecoq.io/insights/query/:login/:plugin"},
|
||||
{"source": "/insights/query/:login", "destination": "https://metrics.lecoq.io/about/query/:login"},
|
||||
{"source": "/insights/query/:login/:plugin", "destination": "https://metrics.lecoq.io/about/query/:login/:plugin"},
|
||||
{"source": "/.uncache", "destination": "https://metrics.lecoq.io/.uncache"},
|
||||
{"source": "/.requests", "destination": "https://metrics.lecoq.io/.requests"}
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user