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.
This commit is contained in:
Peter Johanson
2021-10-12 05:31:56 +00:00
committed by Pete Johanson
parent 6f29453041
commit e544d74948
3 changed files with 129 additions and 57 deletions

View File

@@ -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`,