oneie
Version:
Build apps, websites, and AI agents in English. Zero-interaction setup for AI agents (Claude Code, Cursor, Windsurf). Download to your computer, run in the cloud, deploy to the edge. Open source and free forever.
40 lines • 1.54 kB
JavaScript
import fs from "fs/promises";
import path from "path";
import { fileURLToPath } from "url";
import yaml from "yaml";
import { glob } from "glob";
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
export async function syncOntologyFiles() {
// 1. Determine package root (one level up from dist/)
const packageRoot = path.join(__dirname, "..");
// 2. Read config
const configPath = path.join(packageRoot, "folders.yaml");
const configContent = await fs.readFile(configPath, "utf-8");
const config = yaml.parse(configContent);
// 3. Build glob pattern for all allowed extensions
const patterns = config.allowed_extensions.map((ext) => `one/**/*${ext}`);
// 4. Find all matching files
const oneFiles = [];
for (const pattern of patterns) {
const files = await glob(pattern, {
cwd: packageRoot,
ignore: config.exclude_patterns,
});
oneFiles.push(...files);
}
// 5. Copy all files to user directory
for (const file of oneFiles) {
const sourcePath = path.join(packageRoot, file);
const targetPath = path.join(process.cwd(), file);
// Create directory if needed
await fs.mkdir(path.dirname(targetPath), { recursive: true });
// Copy file
await fs.copyFile(sourcePath, targetPath);
}
console.log(`✓ Copied ${oneFiles.length} ontology files`);
return {
filesCopied: oneFiles.length,
};
}
//# sourceMappingURL=sync-ontology.js.map