/** * @purpose Writer tool * @description Create a properly formatted Call-to-Action URL with tracking parameters */ import { Command } from 'commander' import readline from 'readline' import chalk from 'chalk' import Ajv from 'ajv' import ctaSchema from '@/data-directory/lib/data-schemas/ctas' const ajv = new Ajv({ strict: false, allErrors: true }) const validateCTASchema = ajv.compile(ctaSchema) interface CTAParams { ref_product?: string ref_plan?: string ref_type?: string ref_style?: string } // Conversion mappings from old CTA format to new schema const ctaToTypeMapping: Record = { 'GHEC trial': 'trial', 'Copilot trial': 'trial', 'Copilot Enterprise trial': 'trial', 'Copilot Business trial': 'trial', 'Copilot Pro+': 'purchase', 'Copilot plans signup': 'engagement', 'download desktop': 'engagement', 'Copilot free': 'engagement', } const ctaToPlanMapping: Record = { 'Copilot Enterprise trial': 'enterprise', 'Copilot Business trial': 'business', 'Copilot Pro+': 'pro', 'Copilot free': 'free', 'GHEC trial': 'enterprise', } // Keywords that suggest a button context vs inline text link const buttonKeywords = ['landing', 'signup', 'download', 'trial'] const program = new Command() // CLI setup program .name('cta-builder') .description('Create a properly formatted Call-to-Action URL with tracking parameters.') .version('1.0.0') // Add conversion command program .command('convert') .description('Convert old CTA URLs to new schema format') .option('-u, --url ', 'Convert a single URL') .option('-q, --quiet', 'Only output the new URL (no other messages)') .action((options) => { convertUrls(options) }) // Add validation command program .command('validate') .description('Validate a CTA URL against the schema') .option('-u, --url ', 'URL to validate') .action((options) => { validateUrl(options) }) // Add programmatic build command program .command('build') .description('Build a CTA URL programmatically with flags (outputs URL only)') .requiredOption('--url ', 'Base URL for the CTA') .requiredOption('--product ', 'Product reference (copilot, ghec, desktop)') .requiredOption('--type ', 'CTA type (trial, purchase, engagement)') .requiredOption('--style