UNPKG

dry-react

Version:

Initialiseur de structure React Native typée et modulaire

43 lines (36 loc) 1.31 kB
const fs = require('fs'); const path = require('path'); module.exports = function generateModels() { const root = path.resolve(__dirname, '..'); const modelsPath = path.join(root, 'src', 'models', 'interfaces'); fs.mkdirSync(modelsPath, { recursive: true }); // === person.interface.tsx === const personInterface = `export interface PersonInterface { _id: string; label: string; picture: string; cover: string; } `; fs.writeFileSync(path.join(modelsPath, 'person.interface.tsx'), personInterface); // === dry-user.interface.tsx === const dryUserInterface = `import { PersonInterface } from './person.interface.tsx'; export interface DryUserInterface { slug: string; _id: string; label: string; username: string; person: PersonInterface; } `; fs.writeFileSync(path.join(modelsPath, 'dry-user.interface.tsx'), dryUserInterface); // === dry-auth.interface.tsx === const dryAuthInterface = `import { DryUserInterface } from './dry-user.interface.tsx'; export interface DryAuthInterface { data: DryUserInterface; token: string; } `; fs.writeFileSync(path.join(modelsPath, 'dry-auth.interface.tsx'), dryAuthInterface); console.log(`📄 Interfaces DryUser, Person et Auth générées dans src/models/interfaces.`); };