mirror of
https://github.com/zmkfirmware/zmk.git
synced 2026-03-20 13:05:20 -05:00
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:
committed by
Pete Johanson
parent
6f29453041
commit
e544d74948
@@ -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`,
|
||||
|
||||
Reference in New Issue
Block a user