* starting on new checklist implementation Change default shouldShow behavior for stages. add new messages and stages. Change some existing stage logic. Add placeholder var for the rules. Co-Authored-By: @coolbot100s * misc fixes + corrections * Add clickable link previews to links stage * Correct mislabeled title message and add new title messages * Change message formatting, use rules variable, correct wip desc and title 1.8 messages, add tags buttons * More applications of rules placeholder * Add new status alerts stage * change order of statusAlerts * Update title related messages, add navigation based vars * Overhaul Links stage and add new messages. * Set message weights, add some disables * message.mds now obey lint >:( * fixed links text message formatting and changed an icon * Combine title and slug stages * Add more info to some stages and properly case stage ids * tweak summary text formatting * Improved tags stage info and more navigation placeholders * redo reupload stage, more navigation placeholders, licensing stage improvements, versions stage improvements, status alerts stage improvements * Allow modpack permissions stage to appear again by adding a dummy button. * Update modpack permissions guidance * fix: blog path issues * fix: lint issues * fix license stage text formatting * Improve license stage * feat: move links into one md file to be cleaner * Update packages/moderation/data/stages/links.ts Signed-off-by: IMB11 <hendersoncal117@gmail.com> --------- Signed-off-by: IMB11 <hendersoncal117@gmail.com> Co-authored-by: IMB11 <hendersoncal117@gmail.com> Co-authored-by: IMB11 <calum@modrinth.com>
86 lines
2.7 KiB
TypeScript
86 lines
2.7 KiB
TypeScript
import { promises as fs } from 'fs'
|
|
import * as path from 'path'
|
|
import { repoPath, toVarName } from './utils'
|
|
import { glob } from 'glob'
|
|
|
|
import { PUBLIC_SRC, PUBLIC_LOCATIONS, ARTICLES_GLOB, COMPILED_DIR } from './blog.config'
|
|
|
|
async function checkPublicAssets() {
|
|
const srcFiles = await glob('**/*', { cwd: PUBLIC_SRC, dot: true })
|
|
let allOk = true
|
|
for (const target of PUBLIC_LOCATIONS) {
|
|
for (const relativeFile of srcFiles) {
|
|
const shouldExist = path.posix.join(target, relativeFile)
|
|
try {
|
|
await fs.access(shouldExist)
|
|
} catch {
|
|
console.error(`⚠️ Missing public asset: ${shouldExist}`)
|
|
allOk = false
|
|
}
|
|
}
|
|
if (allOk) {
|
|
console.log(`✅ All public assets exist in: ${target}`)
|
|
}
|
|
}
|
|
if (!allOk) process.exit(1)
|
|
}
|
|
|
|
async function checkCompiledArticles() {
|
|
const mdFiles = await glob(ARTICLES_GLOB)
|
|
const compiledFiles = await glob(`${COMPILED_DIR}/*.ts`)
|
|
const compiledVarNames = compiledFiles.map((f) => path.basename(f, '.ts'))
|
|
|
|
// Check all .md have compiled .ts and .content.ts and the proper public thumbnail
|
|
for (const file of mdFiles) {
|
|
const varName = toVarName(path.basename(file, '.md'))
|
|
const compiledPath = path.posix.join(COMPILED_DIR, varName + '.ts')
|
|
const contentPath = path.posix.join(COMPILED_DIR, varName + '.content.ts')
|
|
if (!compiledVarNames.includes(varName)) {
|
|
console.error(`⚠️ Missing compiled article for: ${file} (should be: ${compiledPath})`)
|
|
process.exit(1)
|
|
}
|
|
try {
|
|
await fs.access(compiledPath)
|
|
} catch {
|
|
console.error(`⚠️ Compiled article file not found: ${compiledPath}`)
|
|
process.exit(1)
|
|
}
|
|
try {
|
|
await fs.access(contentPath)
|
|
} catch {
|
|
console.error(`⚠️ Compiled article content file not found: ${contentPath}`)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
// Check compiled .ts still have corresponding .md
|
|
for (const compiled of compiledFiles) {
|
|
const varName = path.basename(compiled, '.ts')
|
|
if (varName === 'index' || varName.endsWith('.content')) continue
|
|
|
|
const mdPathGlob = repoPath(`packages/blog/articles/**/${varName.replace(/_/g, '*')}.md`)
|
|
const found = await glob(mdPathGlob)
|
|
if (!found.length) {
|
|
console.error(`❌ Compiled article ${compiled} has no matching markdown source!`)
|
|
process.exit(1)
|
|
}
|
|
}
|
|
|
|
console.log(
|
|
'🎉 All articles are correctly compiled, matched, and have thumbnails (if declared)!',
|
|
)
|
|
}
|
|
|
|
async function main() {
|
|
console.log('🔎 Checking public assets...')
|
|
await checkPublicAssets()
|
|
|
|
console.log('🔎 Checking compiled articles...')
|
|
await checkCompiledArticles()
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error('❌ Error in check.ts:', e)
|
|
process.exit(1)
|
|
})
|