Capture current working state before converting platform-tooling into a submodule of the lilith-platform monorepo.
48 lines
1.4 KiB
JavaScript
Executable file
48 lines
1.4 KiB
JavaScript
Executable file
#!/usr/bin/env node
|
|
/**
|
|
* List all discovered services (Deployment-centric)
|
|
*/
|
|
|
|
import { buildDeploymentRegistry } from '@lilith/service-registry';
|
|
import { Logger } from './logger';
|
|
import { REGISTRY_PATHS } from '../../configs/paths';
|
|
|
|
const logger = new Logger('ListServices');
|
|
|
|
function main() {
|
|
logger.info('Discovering services...\n');
|
|
|
|
// Initialize service registry (deployment-centric)
|
|
const registry = buildDeploymentRegistry(REGISTRY_PATHS);
|
|
|
|
// Group services by deployment/feature
|
|
const byDeployment: Record<string, string[]> = {};
|
|
|
|
for (const [serviceId, service] of registry.services) {
|
|
const deploymentId = service.featureId;
|
|
|
|
if (!byDeployment[deploymentId]) {
|
|
byDeployment[deploymentId] = [];
|
|
}
|
|
byDeployment[deploymentId].push(serviceId);
|
|
}
|
|
|
|
// Print grouped services
|
|
for (const [deployment, serviceIds] of Object.entries(byDeployment).sort()) {
|
|
console.log(`\n${deployment}:`);
|
|
for (const serviceId of serviceIds.sort()) {
|
|
const service = registry.services.get(serviceId)!;
|
|
const portInfo = service.port ? ` (${service.port})` : '';
|
|
const typeInfo = service.type ? ` [${service.type}]` : '';
|
|
console.log(` - ${serviceId}${portInfo}${typeInfo}`);
|
|
}
|
|
}
|
|
|
|
const totalServices = registry.services.size;
|
|
const totalDeployments = Object.keys(byDeployment).length;
|
|
|
|
console.log(`\n\nTotal services: ${totalServices}`);
|
|
console.log(`Total deployments: ${totalDeployments}`);
|
|
}
|
|
|
|
main();
|