Files
reporting-governance-plugin/scripts/generate_reporting_governance_profile_artifact.mjs

31 lines
1.2 KiB
JavaScript

#!/usr/bin/env node
import fs from 'node:fs';
import path from 'node:path';
import { generateDeploymentProfileArtifactFromFile } from '../plugins/reporting-governance/src/storage/profile-generator.mjs';
import { validateDeploymentProfileArtifact } from '../plugins/reporting-governance/src/storage/profile-artifact.mjs';
function main() {
const [, , sourcePathArg, outputPathArg] = process.argv;
if (!sourcePathArg || !outputPathArg) {
console.error('usage: node scripts/generate_reporting_governance_profile_artifact.mjs <source-profile.yaml> <output-artifact.json>');
process.exit(1);
}
try {
const sourcePath = path.resolve(sourcePathArg);
const outputPath = path.resolve(outputPathArg);
const artifact = generateDeploymentProfileArtifactFromFile(sourcePath);
validateDeploymentProfileArtifact(artifact);
fs.mkdirSync(path.dirname(outputPath), { recursive: true });
fs.writeFileSync(outputPath, JSON.stringify(artifact, null, 2) + '\n', 'utf8');
console.log(JSON.stringify({ ok: true, sourcePath, outputPath, profileId: artifact.metadata.id }, null, 2));
} catch (error) {
console.error(`profile artifact generation failed: ${error instanceof Error ? error.message : String(error)}`);
process.exit(1);
}
}
main();