* Make the synthetic "base name" property double underscore prefixed, since internal, and to avoid future conflicts w/ YAML format add'ns. * Switch to PS hash dictionaries for our metadata collections for saner data inspection/use.
37 lines
831 B
JavaScript
37 lines
831 B
JavaScript
/*
|
|
* Copyright (c) 2021 The ZMK Contributors
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
var PrebuildPlugin = require("prebuild-webpack-plugin");
|
|
const fs = require("fs");
|
|
const yaml = require("js-yaml");
|
|
const glob = require("glob");
|
|
|
|
function generateHardwareMetadataAggregate() {
|
|
glob("../app/boards/**/*.zmk.yml", (error, files) => {
|
|
const aggregated = files.flatMap((f) =>
|
|
yaml.loadAll(fs.readFileSync(f, "utf8"))
|
|
);
|
|
fs.writeFileSync(
|
|
"src/data/hardware-metadata.json",
|
|
JSON.stringify(aggregated)
|
|
);
|
|
});
|
|
}
|
|
|
|
module.exports = function () {
|
|
return {
|
|
name: "hardware-metadata-collection-plugin",
|
|
configureWebpack() {
|
|
return {
|
|
plugins: [
|
|
new PrebuildPlugin({
|
|
build: generateHardwareMetadataAggregate,
|
|
}),
|
|
],
|
|
};
|
|
},
|
|
};
|
|
};
|