• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

scriptype / writ-cms / 29418287132

15 Jul 2026 01:10PM UTC coverage: 50.776% (-0.3%) from 51.032%
29418287132

push

github

scriptype
Implement contentTypes.delete

Also:
- Update path validation to account for paths residing naturally outside
of content directory (e.g. schema)

666 of 1351 branches covered (49.3%)

Branch coverage included in aggregate %.

4 of 28 new or added lines in 4 files covered. (14.29%)

1 existing line in 1 file now uncovered.

2278 of 4447 relevant lines covered (51.23%)

1472.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/cms/api/models/contentTypes.js
1
const { join } = require('path')
×
NEW
2
const { mkdir, writeFile, rm } = require('fs/promises')
×
3
const { dump } = require('js-yaml')
×
NEW
4
const { validatePath } = require('../helpers')
×
5

6
const createContentTypesModel = ({ getSettings, getContentTypes }) => {
×
7
  const createContentType = async ({ name, description = '', attributes, ...config }) => {
×
8
    const { rootDirectory } = getSettings()
×
9
    const schemaDirectory = join(rootDirectory, 'schema')
×
10
    const filePath = join(schemaDirectory, `${name}.md`)
×
11
    const frontMatter = dump({
×
12
      name,
13
      attributes,
14
      ...config
15
    }, {
16
      flowLevel: 2
17
    })
18
    const fileContent = ['---', frontMatter.replace(/\s+$/, ''), '---', description].join('\n')
×
19
    await mkdir(schemaDirectory, { recursive: true })
×
20
    await writeFile(filePath, fileContent)
×
21
    return { ok: true }
×
22
  }
23

NEW
24
  const deleteContentType = async (path) => {
×
NEW
25
    if (!path) {
×
NEW
26
      throw new Error('path is required')
×
27
    }
28

NEW
29
    const contentType = getContentTypes().find(p => p.path === path)
×
30

NEW
31
    if (!contentType) {
×
NEW
32
      throw new Error('content type not found')
×
33
    }
34

NEW
35
    const isPathValid = await validatePath(
×
36
      getSettings(),
37
      contentType.absolutePath,
38
      { rootChild: true }
39
    )
NEW
40
    if (!isPathValid) {
×
NEW
41
      throw new Error('invalid page path')
×
42
    }
43

NEW
44
    await rm(contentType.absolutePath, { recursive: true, force: true })
×
45
  }
46

UNCOV
47
  return {
×
48
    get: getContentTypes,
49
    create: createContentType,
50
    delete: deleteContentType
51
  }
52
}
53

54
module.exports = createContentTypesModel
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc