UNPKG

i18ntk

Version:

i18n Tool Kit - Zero-dependency internationalization toolkit for setup, scanning, analysis, validation, auto translation, fixing, reporting, and runtime translation loading.

64 lines (58 loc) 1.8 kB
#!/usr/bin/env node /** * I18NTK SIZING COMMAND * * Handles translation sizing analysis functionality. */ class SizingCommand { constructor(config = {}, ui = null) { this.config = config; this.ui = ui; this.prompt = null; this.isNonInteractiveMode = false; this.safeClose = null; } /** * Set runtime dependencies for interactive operations */ setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose) { this.prompt = prompt; this.isNonInteractiveMode = isNonInteractiveMode; this.safeClose = safeClose; } /** * Execute the sizing command */ async execute(options = {}) { try { const I18nSizingAnalyzer = require('../../i18ntk-sizing'); const sizingAnalyzer = new I18nSizingAnalyzer(); const result = await sizingAnalyzer.run(options); if (result && result.success === false) { throw new Error(result.error || 'Sizing analysis failed'); } return { success: true, command: 'sizing', result }; } catch (error) { console.error(`Sizing command failed: ${error.message}`); throw error; } } /** * Get command metadata */ getMetadata() { return { name: 'sizing', description: 'Analyze translation file sizes and content metrics', category: 'analysis', aliases: [], usage: 'sizing [options]', examples: [ 'sizing', 'sizing --source-dir=./src/locales', 'sizing --output-dir=./reports' ] }; } } module.exports = SizingCommand;