diff --git a/.github/scripts/presets_examples.mjs b/.github/scripts/presets_examples.mjs index ec91119f..b1a4254b 100644 --- a/.github/scripts/presets_examples.mjs +++ b/.github/scripts/presets_examples.mjs @@ -1,10 +1,10 @@ //Imports +import fs from "fs/promises" import processes from "child_process" import yaml from "js-yaml" -import sgit from "simple-git" import paths from "path" +import sgit from "simple-git" import url from "url" -import fs from "fs/promises" //Mode const [mode = "dryrun"] = process.argv.slice(2) @@ -14,8 +14,8 @@ console.log(`Mode: ${mode}`) const __metrics = paths.join(paths.dirname(url.fileURLToPath(import.meta.url)), "../..") const __presets = paths.join(__metrics, ".presets") -if ((!await fs.access(__presets).then(_ => true).catch(_ => false))||(!(await fs.lstat(__presets)).isDirectory())) - await sgit().clone(`https://github-actions[bot]:${process.env.GITHUB_TOKEN}@github.com/lowlighter/metrics`, __presets, {"--branch":"presets", "--single-branch":true}) +if ((!await fs.access(__presets).then(_ => true).catch(_ => false)) || (!(await fs.lstat(__presets)).isDirectory())) + await sgit().clone(`https://github-actions[bot]:${process.env.GITHUB_TOKEN}@github.com/lowlighter/metrics`, __presets, { "--branch": "presets", "--single-branch": true }) const git = sgit(__presets) await git.pull() const staged = new Set() @@ -49,14 +49,16 @@ for (const path of await fs.readdir(__presets)) { //Example console.log(`generating: ${preset}/example.svg`) - const svg = await action.run({config_presets:`@${preset}`, debug_print: true, plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, token:"MOCKED_TOKEN"}) + const svg = await action.run({ config_presets: `@${preset}`, debug_print: true, plugins_errors_fatal: true, dryrun: true, use_mocked_data: true, verify: true, token: "MOCKED_TOKEN" }) await fs.writeFile(paths.join(__presets, path, "example.svg"), svg) staged.add(paths.join(__presets, path, "example.svg")) //Readme console.log(`generating: ${preset}/README.svg`) - const {name, description} = await yaml.load(await fs.readFile(paths.join(__presets, preset, "preset.yml"))) - await fs.writeFile(paths.join(__presets, path, "README.md"), ` + const { name, description } = await yaml.load(await fs.readFile(paths.join(__presets, preset, "preset.yml"))) + await fs.writeFile( + paths.join(__presets, path, "README.md"), + ` @@ -65,7 +67,8 @@ for (const path of await fs.readdir(__presets)) {

${name}

${description}

-`.trim()) +`.trim(), + ) staged.add(paths.join(__presets, path, "README.md")) } @@ -78,6 +81,6 @@ if (mode === "publish") { .add([...staged]) .commit("ci: auto-regenerate files") .push("origin", "presets") - console.log(gitted) + console.log(gitted) } -console.log("Success!") \ No newline at end of file +console.log("Success!") diff --git a/README.md b/README.md index a59c1c6a..2cf91f85 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ Generate metrics that can be embedded everywhere, including your GitHub profile -

🧩 Customizable with 39 plugins and 239 options!

+

🧩 Customizable with 39 plugins and 240 options!

diff --git a/source/plugins/core/README.md b/source/plugins/core/README.md index 35535826..a8e72148 100644 --- a/source/plugins/core/README.md +++ b/source/plugins/core/README.md @@ -902,6 +902,19 @@ This option has no effects on forks (images will always be rebuilt from Dockerfi (space-separated)
allowed values: + + + debug_print +

Print output in console

+ + + + ⏯️ Cannot be preset
+🔧 For development
+✨ On master/main
+type: boolean +
+default: no
dryrun diff --git a/tests/presets.test.js b/tests/presets.test.js index 893c9baf..6b953f49 100644 --- a/tests/presets.test.js +++ b/tests/presets.test.js @@ -30,21 +30,21 @@ for (const path of fss.readdirSync(__presets)) { test("syntax is valid", () => expect(true).toBe(true)) try { //Load schema - const {properties} = yaml.load(fss.readFileSync(paths.join(__presets, "@schema", `${preset.schema}.yml`))) + const { properties } = yaml.load(fss.readFileSync(paths.join(__presets, "@schema", `${preset.schema}.yml`))) test("schema is valid", () => expect(preset.schema).toBeDefined()) //Test schema - for (const [key, {type, required}] of Object.entries(properties)) { + for (const [key, { type, required }] of Object.entries(properties)) { if (required) test(`preset.${key} is defined`, () => expect(preset[key]).toBeDefined()) test(`preset.${key} type is ${type}`, () => { switch (true) { - case /^'.*'$/.test(type):{ - const value = type.substring(1, type.length-1) + case /^'.*'$/.test(type): { + const value = type.substring(1, type.length - 1) expect(preset[key]).toBe(value) return } - case /\{\}$/.test(type):{ - const typed = type.substring(0, type.length-2) + case /\{\}$/.test(type): { + const typed = type.substring(0, type.length - 2) expect(typeof preset[key]).toBe("object") if (typed !== "unknown") { for (const value of Object.values(preset[key])) @@ -52,8 +52,8 @@ for (const path of fss.readdirSync(__presets)) { } return } - case /\[\]$/.test(type):{ - const typed = type.substring(0, type.length-2) + case /\[\]$/.test(type): { + const typed = type.substring(0, type.length - 2) expect(Array.isArray(preset[key])).toBe(true) if (typed !== "unknown") { for (const value of Object.values(preset[key])) @@ -75,4 +75,4 @@ for (const path of fss.readdirSync(__presets)) { test("syntax is valid", () => expect(false).toBe(true)) } }) -} \ No newline at end of file +}