From e544d74948097864a9e0d846694ea16e5a443f22 Mon Sep 17 00:00:00 2001 From: Peter Johanson Date: Tue, 12 Oct 2021 05:31:56 +0000 Subject: refactor: Config setup scripts to support onboard keyboards. * Use unified config template repo that uses an external build matrix YAML file. * Proper handling for onboard keyboards, including splits, and supports for appending the right build matrix once selected. --- docs/src/setup-script-generation-plugin/index.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'docs/src/setup-script-generation-plugin/index.js') diff --git a/docs/src/setup-script-generation-plugin/index.js b/docs/src/setup-script-generation-plugin/index.js index e97a4d0..0d768d7 100644 --- a/docs/src/setup-script-generation-plugin/index.js +++ b/docs/src/setup-script-generation-plugin/index.js @@ -5,6 +5,7 @@ */ var PrebuildPlugin = require("prebuild-webpack-plugin"); +const path = require("path"); const fs = require("fs"); const glob = require("glob"); const yaml = require("js-yaml"); @@ -12,9 +13,10 @@ const Mustache = require("mustache"); function generateSetupScripts() { return glob("../app/boards/**/*.zmk.yml", (error, files) => { - const aggregated = files.flatMap((f) => - yaml.safeLoadAll(fs.readFileSync(f, "utf8")) - ); + const aggregated = files.map((f) => ({ + ...yaml.safeLoadAll(fs.readFileSync(f, "utf8"))[0], + base_dir: path.basename(path.dirname(f)), + })); const data = aggregated.reduce( (agg, item) => { @@ -25,7 +27,9 @@ function generateSetupScripts() { agg.keyboards.push(item); break; case "board": - if (!item.features?.includes("keys")) { + if (item.features?.includes("keys")) { + agg.keyboards.push(item); + } else { agg.boards.push(item); } break; @@ -35,6 +39,9 @@ function generateSetupScripts() { { keyboards: [], boards: [] } ); + data.keyboards.sort((a, b) => a.name.localeCompare(b.name)); + data.boards.sort((a, b) => a.name.localeCompare(b.name)); + for (let script_ext of ["sh", "ps1"]) { const templateBuffer = fs.readFileSync( `src/templates/setup.${script_ext}.mustache`, -- cgit v1.2.3