mirror of
https://github.com/twentyhq/twenty.git
synced 2024-12-18 00:52:21 +03:00
00a3c8ca2b
* Change to using arrow functions Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> * Add lint rule --------- Co-authored-by: v1b3m <vibenjamin6@gmail.com> Co-authored-by: Matheus <matheus_benini@hotmail.com> Co-authored-by: Charles Bochet <charles@twenty.com>
33 lines
882 B
JavaScript
33 lines
882 B
JavaScript
/* eslint-disable @typescript-eslint/no-var-requires */
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
const { getDMMF, getSchemaPath } = require('@prisma/internals');
|
|
|
|
const generateTypes = async () => {
|
|
const schemaPath = await getSchemaPath();
|
|
const dmmf = await getDMMF({
|
|
datamodel: fs.readFileSync(schemaPath, 'utf-8'),
|
|
});
|
|
|
|
let content =
|
|
'// THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.\n';
|
|
content += "import { Prisma } from '@prisma/client';\n\n";
|
|
content += 'export type ModelSelectMap = {\n';
|
|
|
|
for (const model of dmmf.datamodel.models) {
|
|
content += ` ${model.name}: Prisma.${model.name}Select;\n`;
|
|
}
|
|
|
|
content += '};\n';
|
|
|
|
fs.writeFileSync(
|
|
path.join(__dirname, '../src/utils/prisma-select/model-select-map.ts'),
|
|
content,
|
|
);
|
|
};
|
|
|
|
generateTypes().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|