Files
Kasra Bigdeli 0bac03c278 Generate v2, v3 and v4 catalogs from v5 source (#1389)
* Generate legacy catalogs from the v5 source

* Document testing generated v4 and v5 templates on compatible dashboards

* Simplify one-click app testing instructions
2026-11-30 23:02:02 -08:00

66 lines
2.0 KiB
JavaScript

const path = require('path')
const yaml = require('yaml')
const fs = require('fs-extra')
function validateApp(version, filename) {
const appsDir = path.join(__dirname, '..', 'public', version, 'apps')
const logosDir = path.join(__dirname, '..', 'public', version, 'logos')
const expectedCaptainVersion = version.slice(1)
if (!filename.endsWith('.yml')) {
throw new Error(
`All files in ${version} must end with .yml: ${filename}`
)
}
const name = path.basename(filename, '.yml')
const app = `${version}/${name}`
const template = yaml.parse(
fs.readFileSync(path.join(appsDir, filename), 'utf-8')
)
if (String(template.captainVersion) !== expectedCaptainVersion) {
throw new Error(
`Expected captainVersion ${expectedCaptainVersion} for ${app}`
)
}
const metadata = template.caproverOneClickApp
if (!metadata) {
throw new Error(`Cannot find caproverOneClickApp for ${app}`)
}
if (!metadata.description) {
throw new Error(`Cannot find description for ${app}`)
}
if (metadata.description.length > 200) {
throw new Error(`Description too long for ${app} - max 200 chars`)
}
if (!metadata.instructions?.start || !metadata.instructions?.end) {
throw new Error(
`Cannot find instructions.start or instructions.end for ${app}`
)
}
if (!template.services) {
throw new Error(`Cannot find services for ${app}`)
}
const logoPath = path.join(logosDir, name + '.png')
if (!fs.existsSync(logoPath) || !fs.statSync(logoPath).isFile()) {
throw new Error(`Cannot find logo for ${app}: ${logoPath}`)
}
console.log(`Validated ${app}`)
}
try {
for (const version of ['v5']) {
const appsDir = path.join(__dirname, '..', 'public', version, 'apps')
for (const filename of fs.readdirSync(appsDir)) {
validateApp(version, filename)
}
}
} catch (err) {
console.error(err)
process.exit(127)
}