/**
 * Copyright 2024 Phenix Real Time Solutions, Inc. Confidential and Proprietary. All Rights Reserved.
 */
import {writeFileSync} from 'fs';
import {join} from 'path';
import {program} from 'commander';
import packageJson from './../package.json' with {type: 'json'};

program.option('-e --environment <environment>', 'Specific environment (optional)');

program.parse(process.argv);

const {environment} = program.opts();
const prefix = environment ? `${environment}-` : 'local-';
const version = `${prefix}${new Date().toISOString()} (${packageJson.version})`;
const fileLocation = join(process.cwd(), 'src', 'config', 'version.json');
const controlVersion = {version};

writeFileSync(fileLocation, JSON.stringify(controlVersion, null, 2));

console.log(`Generated control center version [${version}]`);
