diff options
Diffstat (limited to 'docs/src/hardware-metadata-collection-plugin')
-rw-r--r-- | docs/src/hardware-metadata-collection-plugin/index.js | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/docs/src/hardware-metadata-collection-plugin/index.js b/docs/src/hardware-metadata-collection-plugin/index.js new file mode 100644 index 0000000..cbea805 --- /dev/null +++ b/docs/src/hardware-metadata-collection-plugin/index.js @@ -0,0 +1,33 @@ +/* + * 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"); +const { compile, compileFromFile } = require('json-schema-to-typescript'); + +function generateHardwareMetadataAggregate() { + glob("../app/boards/**/*.zmk.yml", (error, files) => { + const aggregated = files.flatMap(f => yaml.safeLoadAll(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, + }), + ], + }; + }, + }; +};
\ No newline at end of file |