platform-codebase/features/client-intel/backend-api/scripts/verify-circular-deps.mjs
Lilith f54d64b9ee chore(pages): 🔧 Update maintenance scripts in 6 mjs files for consistent page updates
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
2026-02-20 13:40:11 -08:00

45 lines
1.5 KiB
JavaScript

#!/usr/bin/env node
/**
* Verify Circular Dependencies
*
* Safely checks for circular dependency issues by importing the AppModule
* without bootstrapping the application (no server start, no DB connections).
*
* Usage: node scripts/verify-circular-deps.mjs
*/
import { fileURLToPath } from 'node:url';
import { dirname, join } from 'node:path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const distPath = join(__dirname, '..', 'dist');
// buildDeploymentRegistry needs deployments/@domains relative to CWD
// Ensure we run from project root
const projectRoot = join(__dirname, '..', '..', '..', '..', '..');
process.chdir(projectRoot);
// Prevent application from actually starting
process.env.NODE_ENV = 'test';
process.env.SKIP_BOOTSTRAP = 'true';
console.log('Checking for circular dependencies...\n');
try {
// Import AppModule - this triggers all decorators without starting the app
const appModulePath = join(distPath, 'app.module.js');
await import(appModulePath);
console.log('No circular dependency issues detected');
console.log(' All modules and entities loaded successfully\n');
process.exit(0);
} catch (error) {
console.error('Circular dependency detected!\n');
console.error('Error:', error.message);
console.error('\nStack trace:');
console.error(error.stack);
console.error('\nHint: Look for entities with bidirectional relations.');
console.error(' Use string references in decorators: @ManyToOne(\'EntityName\', ...)\n');
process.exit(1);
}