Files
Owen/scripts/validate-animations.js
Kaj Kowalski ad8dbb95dd
Some checks failed
CI/CD Pipeline / Test & Lint (16.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (18.x) (push) Has been cancelled
CI/CD Pipeline / Test & Lint (20.x) (push) Has been cancelled
CI/CD Pipeline / Security Audit (push) Has been cancelled
CI/CD Pipeline / Release (push) Has been cancelled
Release / Validate Version (push) Has been cancelled
Release / Build and Test (push) Has been cancelled
Release / Create Release (push) Has been cancelled
Release / Publish to NPM (push) Has been cancelled
Release / Deploy Demo (push) Has been cancelled
Animation Processing Pipeline / Validate Animation Names (push) Has been cancelled
Animation Processing Pipeline / Process Blender Animation Assets (push) Has been cancelled
Animation Processing Pipeline / Update Animation Documentation (push) Has been cancelled
Animation Processing Pipeline / Deploy Animation Demo (push) Has been cancelled
Implement multi-scheme animation name mapper for Owen Animation System
- Added AnimationNameMapper class to handle conversion between different animation naming schemes (legacy, artist, hierarchical, semantic).
- Included methods for initialization, pattern matching, conversion, and validation of animation names.
- Developed comprehensive unit tests for the animation name converter and demo pages using Playwright.
- Created a Vite configuration for the demo application, including asset handling and optimization settings.
- Enhanced the demo with features for batch conversion, performance metrics, and responsive design.
2025-05-24 05:40:03 +02:00

169 lines
5.2 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env node
/**
* Animation Name Validation Script
* Validates all animation names across different schemes
*/
import { AnimationNameMapper } from '../src/animation/AnimationNameMapper.js'
import { writeFile, mkdir } from 'fs/promises'
import { existsSync } from 'fs'
const PRIMARY_SCHEME = process.env.PRIMARY_SCHEME || 'semantic'
async function validateAnimations () {
console.log('🔍 Validating animation naming schemes...')
console.log(`Primary scheme: ${PRIMARY_SCHEME}`)
const mapper = new AnimationNameMapper()
const results = {
timestamp: new Date().toISOString(),
primaryScheme: PRIMARY_SCHEME,
validations: [],
errors: [],
warnings: [],
summary: {}
}
try {
// Get all animations from the mapper
const allAnimations = mapper.getAllAnimations()
console.log(`Found ${allAnimations.length} animations to validate`)
// Validate each animation
for (const animation of allAnimations) {
const schemes = ['legacy', 'artist', 'hierarchical', 'semantic']
for (const scheme of schemes) {
const animName = animation[scheme]
if (!animName) continue
try {
const validation = mapper.validateAnimationName(animName)
results.validations.push({
name: animName,
scheme,
isValid: validation.isValid,
detectedScheme: validation.scheme,
error: validation.error
})
if (!validation.isValid) {
results.errors.push({
name: animName,
scheme,
error: validation.error,
suggestions: validation.suggestions
})
}
// Check for scheme mismatches
if (validation.isValid && validation.scheme !== scheme) {
results.warnings.push({
name: animName,
expectedScheme: scheme,
detectedScheme: validation.scheme,
message: `Animation name "${animName}" expected to be in ${scheme} scheme but detected as ${validation.scheme}`
})
}
} catch (error) {
results.errors.push({
name: animName,
scheme,
error: error.message
})
}
}
}
// Test conversions between schemes
console.log('🔄 Testing scheme conversions...')
for (const animation of allAnimations) {
const schemes = ['legacy', 'artist', 'hierarchical', 'semantic']
for (const fromScheme of schemes) {
for (const toScheme of schemes) {
if (fromScheme === toScheme) continue
const sourceName = animation[fromScheme]
if (!sourceName) continue
try {
const converted = mapper.convert(sourceName, toScheme)
const expected = animation[toScheme]
if (converted !== expected) {
results.errors.push({
name: sourceName,
scheme: `${fromScheme}->${toScheme}`,
error: `Conversion mismatch: expected "${expected}", got "${converted}"`
})
}
} catch (error) {
results.errors.push({
name: sourceName,
scheme: `${fromScheme}->${toScheme}`,
error: `Conversion failed: ${error.message}`
})
}
}
}
}
// Generate summary
results.summary = {
totalAnimations: allAnimations.length,
totalValidations: results.validations.length,
validAnimations: results.validations.filter(v => v.isValid).length,
invalidAnimations: results.errors.length,
warnings: results.warnings.length,
successRate: ((results.validations.filter(v => v.isValid).length / results.validations.length) * 100).toFixed(2)
}
// Create reports directory if it doesn't exist
if (!existsSync('reports')) {
await mkdir('reports', { recursive: true })
}
// Write results to file
await writeFile('reports/animation-validation.json', JSON.stringify(results, null, 2))
// Print summary
console.log('\n📊 Validation Summary:')
console.log(`✅ Valid animations: ${results.summary.validAnimations}/${results.summary.totalValidations}`)
console.log(`❌ Invalid animations: ${results.summary.invalidAnimations}`)
console.log(`⚠️ Warnings: ${results.summary.warnings}`)
console.log(`📈 Success rate: ${results.summary.successRate}%`)
if (results.errors.length > 0) {
console.log('\n❌ Errors found:')
results.errors.forEach(error => {
console.log(` - ${error.name} (${error.scheme}): ${error.error}`)
})
}
if (results.warnings.length > 0) {
console.log('\n⚠ Warnings:')
results.warnings.forEach(warning => {
console.log(` - ${warning.message}`)
})
}
// Exit with error if validation failed
if (results.errors.length > 0) {
console.log('\n💥 Validation failed with errors')
process.exit(1)
} else {
console.log('\n✅ All animations validated successfully')
process.exit(0)
}
} catch (error) {
console.error('💥 Validation script failed:', error)
process.exit(1)
}
}
if (import.meta.url === `file://${process.argv[1]}`) {
validateAnimations()
}