feat: use a custom build js step instead of all the dependencies (#53)
All checks were successful
Lint / pre-commit Linting (push) Successful in 1m38s

Reviewed-on: #53
This commit was merged in pull request #53.
This commit is contained in:
2025-12-27 19:25:56 +01:00
parent 60d3342a1c
commit de6b54abe9
1331 changed files with 56905 additions and 157292 deletions

View File

@@ -38,34 +38,18 @@ function replacePlaceholders(content, hostname) {
* @returns {Promise<string[]>} A promise that resolves with an array of file paths that were processed, or rejects with an error if the process fails.
*/
async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
return new Promise((resolve, reject) => {
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern);
glob(globPattern, async (err, files) => {
if (err) {
return reject(err);
}
let processPromises = [];
files.forEach((file) => {
let processPromise = fs.promises
.readFile(file, "utf8")
.then((content) => {
content = replacePlaceholders(content, hostname);
return fs.promises.writeFile(file, content);
});
processPromises.push(processPromise);
});
try {
await Promise.all(processPromises);
resolve(files);
} catch (processError) {
reject(processError);
}
let processPromises = files.map((file) => {
return fs.promises.readFile(file, "utf8").then((content) => {
content = replacePlaceholders(content, hostname);
return fs.promises.writeFile(file, content);
});
});
await Promise.all(processPromises);
return files;
}
/**
@@ -74,40 +58,27 @@ async function readReplaceAndWriteFiles(pattern, prefix, hostname) {
* @param {string} prefix - Directory prefix for file paths.
* @returns {Promise<Object>} - Promise resolving to a dictionary of file contents keyed by filenames.
*/
function readFilesIntoDict(pattern, prefix) {
async function readFilesIntoDict(pattern, prefix) {
// Prepend the prefix to the glob pattern
const globPattern = prefix ? path.join(prefix, pattern) : pattern;
const files = await glob(globPattern);
return new Promise((resolve, reject) => {
glob(globPattern, (err, files) => {
if (err) {
return reject(err);
let fileDict = {};
let readPromises = files.map((file) => {
return fs.promises.readFile(file, "utf8").then((content) => {
// Remove the prefix from the filename and drop the file suffix
let key = file;
if (prefix && file.startsWith(prefix)) {
key = key.slice(prefix.length);
}
key = path.basename(key, path.extname(key)); // Drop the file suffix
let fileDict = {};
let readPromises = [];
files.forEach((file) => {
let readPromise = fs.promises.readFile(file, "utf8").then((content) => {
// Remove the prefix from the filename and drop the file suffix
let key = file;
if (prefix && file.startsWith(prefix)) {
key = key.slice(prefix.length);
}
key = path.basename(key, path.extname(key)); // Drop the file suffix
fileDict[key] = content;
});
readPromises.push(readPromise);
});
// Use Promise.all to ensure all files are read before resolving
Promise.all(readPromises)
.then(() => resolve(fileDict))
.catch(reject);
fileDict[key] = content;
});
});
await Promise.all(readPromises);
return fileDict;
}
/**