// src/lib/repoTemplates.ts
import { readdirSync, readFileSync } from "fs";
import { createRequire } from "module";
import PATH from "path";
var require2 = createRequire(import.meta.url);
var packageRoot = PATH.dirname(require2.resolve("@xylabs/toolchain/package.json"));
var repoTemplatesDir = PATH.resolve(packageRoot, "templates", "repo");
function collectFiles(dir, prefix) {
  const results = [];
  for (const entry of readdirSync(dir, { withFileTypes: true })) {
    const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
    if (entry.isDirectory()) {
      results.push(...collectFiles(PATH.resolve(dir, entry.name), rel));
    } else {
      results.push({
        content: readFileSync(PATH.resolve(dir, entry.name), "utf8"),
        relativePath: rel
      });
    }
  }
  return results;
}
function loadRepoTemplateFiles(template, section) {
  const dir = PATH.resolve(repoTemplatesDir, template, section);
  return collectFiles(dir, "");
}
function listRepoTemplates() {
  return readdirSync(repoTemplatesDir, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
}
export {
  listRepoTemplates,
  loadRepoTemplateFiles
};
//# sourceMappingURL=repoTemplates.mjs.map