MCPcopy Create free account
hub / github.com/vercel/examples / updateFields

Function updateFields

internal/scripts/update-fields.ts:11–28  ·  view source on GitHub ↗

* Writes a json file that describes the schema used for the Contentful template.

()

Source from the content-addressed store, hash-verified

9 * Writes a json file that describes the schema used for the Contentful template.
10 */
11async 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
30updateFields().catch((error) => {
31 console.error(error)

Callers 1

update-fields.tsFile · 0.85

Calls 1

getTemplateFieldsFunction · 0.85

Tested by

no test coverage detected