fix(build): migrate filesystem access to smartfs and tighten TypeScript compatibility

This commit is contained in:
2026-04-30 10:20:07 +00:00
parent a71a53092b
commit 8c6e8d9c96
14 changed files with 7298 additions and 3761 deletions
+18 -16
View File
@@ -8,22 +8,24 @@ export let compileDirectory = async (
destinationDirPathArg: string,
dataFileNameArg: string
) => {
let hbsFilePathArray = plugins.smartfile.fs.listFilesSync(originDirPathArg, /.hbs/);
let data = plugins.smartfile.fs.toObjectSync(
plugins.path.join(originDirPathArg, dataFileNameArg)
);
for (let hbsFilePath of hbsFilePathArray) {
let parsedPath = plugins.path.parse(hbsFilePath);
let hbsFileString = plugins.smartfile.fs.toStringSync(
plugins.path.join(originDirPathArg, hbsFilePath)
);
let template = plugins.handlebars.compile(hbsFileString);
let output = template(data);
const originDirPath = plugins.path.resolve(originDirPathArg);
const destinationDirPath = plugins.path.resolve(destinationDirPathArg);
const hbsFileArray = await plugins.smartFs.directory(originDirPath)
.filter((entry) => entry.isFile && entry.name.endsWith('.hbs'))
.list();
const dataFileString = await plugins.smartFs.file(
plugins.path.join(originDirPath, dataFileNameArg)
).encoding('utf8').read() as string;
const data = JSON.parse(dataFileString) as Record<string, unknown>;
for (const hbsFile of hbsFileArray) {
const parsedPath = plugins.path.parse(hbsFile.path);
const hbsFileString = await plugins.smartFs.file(hbsFile.path).encoding('utf8').read() as string;
const template = plugins.handlebars.compile(hbsFileString);
const output = template(data);
console.log('hi ' + output + ' hi');
await plugins.smartfile.fs.ensureDir(destinationDirPathArg);
plugins.smartfile.memory.toFsSync(
output,
plugins.path.join(destinationDirPathArg, parsedPath.name + '.html')
);
await plugins.smartFs.directory(destinationDirPath).create();
await plugins.smartFs.file(
plugins.path.join(destinationDirPath, parsedPath.name + '.html')
).encoding('utf8').write(output);
}
};