@zebrains/velund-python
Version:
Python-генератор для системы UI-компонентов Velund
32 lines (29 loc) • 984 B
JavaScript
import fs from 'fs';
import path from 'path';
export function generateInitPy(outDir, components) {
const initPath = path.join(outDir, '__init__.py');
const imports = components
.map((c) => `from .components.${c.name}Component import ${c.name}Component`)
.join('\n');
const registryImports = `from .PrepareRegistry import register, get\nfrom .Renderer import Renderer`;
const componentList = components
.map((c) => `${c.name} = ${c.name}Component()`)
.join('\n');
const content = `
# Auto-generated Velund package __init__.py
${imports}
${registryImports}
# Instantiate components
${componentList}
__all__ = [
${components.map((c) => `"${c.name}"`).join(', ')},
"Renderer",
"register",
"get",
]
`;
// Создаём директорию, если нет
fs.mkdirSync(path.dirname(initPath), { recursive: true });
fs.writeFileSync(initPath, content.trim(), 'utf-8');
}
//# sourceMappingURL=generateInitPy.js.map