canina/docs/audit/generate_classification.js
2026-08-06 20:54:44 +03:30

56 lines
2.1 KiB
JavaScript

import fs from 'fs';
const lines = fs.readFileSync('docs/audit/27-all-tracked-repository-files.txt', 'utf8')
.split(/\r?\n/)
.map(l => l.trim())
.filter(l => l.length > 0);
const classified = lines.map(path => {
let classification = 'FIRST_PARTY_SOURCE';
let includedInAudit = true;
let exclusionReason = null;
let auditDomain = path.startsWith('backend/') ? 'Backend' : 'Storefront';
if (path === 'package-lock.json' || path === 'backend/package-lock.json') {
classification = 'LOCKFILE';
includedInAudit = false;
exclusionReason = 'Dependency lockfile';
} else if (path.includes('prisma/migrations/')) {
classification = 'MIGRATION';
includedInAudit = true;
auditDomain = 'Database';
} else if (path.endsWith('.png')) {
classification = 'BINARY_ASSET';
includedInAudit = false;
exclusionReason = 'Binary image asset';
} else if (path.endsWith('.spec.ts') || path.endsWith('.test.tsx') || path.endsWith('.test.ts') || path.startsWith('backend/test/')) {
classification = 'FIRST_PARTY_TEST';
includedInAudit = true;
} else if (path.endsWith('.json') || path.endsWith('.yml') || path.endsWith('.toml') || path.endsWith('.conf') || path.includes('.docker') || path.includes('Dockerfile') || path.endsWith('.mjs') || path.endsWith('.rc')) {
classification = 'FIRST_PARTY_CONFIGURATION';
includedInAudit = true;
if (path.includes('docker') || path === 'nginx.conf' || path === 'prometheus.yml' || path.includes('.docker')) {
auditDomain = 'DevOps';
}
} else if (path.endsWith('.md') || path === 'swagger.yml') {
classification = 'FIRST_PARTY_DOCUMENTATION';
includedInAudit = true;
auditDomain = 'Documentation';
} else if (path.endsWith('.prisma')) {
classification = 'FIRST_PARTY_SOURCE';
includedInAudit = true;
auditDomain = 'Database';
}
return {
path,
classification,
includedInAudit,
exclusionReason,
auditDomain
};
});
fs.writeFileSync('docs/audit/28-full-repository-classification.json', JSON.stringify(classified, null, 2), 'utf8');
console.log(`Classified ${classified.length} files into 28-full-repository-classification.json`);