* Writes a json file that describes the schema used for the Contentful template.
()
| 9 | * Writes a json file that describes the schema used for the Contentful template. |
| 10 | */ |
| 11 | async function updateFields() { |
| 12 | const fields = await getTemplateFields() |
| 13 | const data = fields.map((field) => ({ |
| 14 | name: field.id, |
| 15 | type: field.type === 'Symbol' ? 'Text' : field.type, |
| 16 | required: true, |
| 17 | validations: field.validations, |
| 18 | ...(field.items?.type === 'Symbol' || field.items?.type === 'Link' |
| 19 | ? { items: field.items.validations } |
| 20 | : {}), |
| 21 | })) |
| 22 | |
| 23 | await fs.writeFile( |
| 24 | // Goes back two paths because this script gets bundled to /scripts/dist |
| 25 | path.join(__dirname, '../../fields.json'), |
| 26 | JSON.stringify(data, null, 2) |
| 27 | ) |
| 28 | } |
| 29 | |
| 30 | updateFields().catch((error) => { |
| 31 | console.error(error) |
no test coverage detected