blob: cbea805fa7b01cc2a43640461bae8d077f0b20e9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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,
}),
],
};
},
};
};
|