2024-01-15 12:33:15 +00:00
|
|
|
import { addAuthors } from '@/utils/addAuthors'
|
2024-02-06 09:49:31 +00:00
|
|
|
import { addContentToDb, addFTS } from '@/utils/addContent'
|
2024-01-15 12:33:15 +00:00
|
|
|
import { autoLinkDocs } from '@/utils/autoLinkDocs'
|
|
|
|
import { nicelog } from '@/utils/nicelog'
|
|
|
|
import { connect } from './connect'
|
|
|
|
import { generateApiContent } from './generateApiContent'
|
|
|
|
import { generateContent } from './generateContent'
|
2024-01-30 14:19:25 +00:00
|
|
|
import { generateExamplesContent } from './generateExamplesContent'
|
2024-01-15 12:33:15 +00:00
|
|
|
|
|
|
|
export async function refreshContent(opts = {} as { silent: boolean }) {
|
|
|
|
if (!opts.silent) nicelog('◦ Resetting database...')
|
2024-04-24 15:58:26 +00:00
|
|
|
const db = await connect({ reset: true, mode: 'readwrite' })
|
2024-01-15 12:33:15 +00:00
|
|
|
|
|
|
|
if (!opts.silent) nicelog('◦ Adding authors to db...')
|
|
|
|
await addAuthors(db, await require('../../content/authors.json'))
|
|
|
|
|
|
|
|
if (!opts.silent) nicelog('◦ Generating / adding regular content to db...')
|
|
|
|
await addContentToDb(db, await generateContent())
|
|
|
|
|
2024-01-30 14:19:25 +00:00
|
|
|
if (!opts.silent) nicelog('◦ Generating / adding Examples content to db...')
|
|
|
|
await addContentToDb(db, await generateExamplesContent())
|
|
|
|
|
2024-01-15 12:33:15 +00:00
|
|
|
if (!opts.silent) nicelog('◦ Generating / adding API content to db...')
|
|
|
|
await addContentToDb(db, await generateApiContent())
|
|
|
|
|
2024-02-06 09:49:31 +00:00
|
|
|
if (!opts.silent) nicelog('◦ Adding full-text search...')
|
|
|
|
await addFTS(db)
|
|
|
|
|
2024-01-15 12:33:15 +00:00
|
|
|
if (!opts.silent) nicelog('◦ Fixing links to API docs...')
|
|
|
|
await autoLinkDocs(db)
|
|
|
|
|
|
|
|
if (!opts.silent) nicelog('✔ Complete')
|
|
|
|
}
|