feat: reorganize builder

This commit is contained in:
obvTiger 2025-03-27 13:28:12 +01:00
parent ff7bb041ef
commit 362b7aa15e
18 changed files with 1094 additions and 310 deletions

View file

@ -0,0 +1,42 @@
const fs = require("fs");
/**
* Handles reading Blueprint files from the file system.
*/
class BlueprintFileReader {
/**
* Creates a new BlueprintFileReader instance.
* @param {Object} [options] - Options object
* @param {boolean} [options.debug=false] - Enable debug logging
*/
constructor(options = {}) {
this.options = {
debug: false,
...options,
};
}
/**
* Reads a Blueprint file from the file system.
* @param {string} inputPath - Path to the Blueprint file
* @returns {string} - The content of the file
* @throws {Error} - If the file does not exist or has an invalid extension
*/
readFile(inputPath) {
if (this.options.debug) {
console.log(`[DEBUG] Reading Blueprint file: ${inputPath}`);
}
if (!inputPath.endsWith(".bp")) {
throw new Error("Input file must have .bp extension");
}
if (!fs.existsSync(inputPath)) {
throw new Error(`File not found: ${inputPath}`);
}
return fs.readFileSync(inputPath, "utf8");
}
}
module.exports = BlueprintFileReader;