i18ntk 1.10.2 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +141 -1191
- package/main/i18ntk-analyze.js +65 -84
- package/main/i18ntk-backup-class.js +420 -0
- package/main/i18ntk-backup.js +3 -3
- package/main/i18ntk-complete.js +90 -65
- package/main/i18ntk-doctor.js +123 -103
- package/main/i18ntk-fixer.js +61 -725
- package/main/i18ntk-go.js +14 -15
- package/main/i18ntk-init.js +77 -26
- package/main/i18ntk-java.js +27 -32
- package/main/i18ntk-js.js +70 -68
- package/main/i18ntk-manage.js +129 -30
- package/main/i18ntk-php.js +75 -75
- package/main/i18ntk-py.js +55 -56
- package/main/i18ntk-scanner.js +59 -57
- package/main/i18ntk-setup.js +9 -404
- package/main/i18ntk-sizing.js +6 -6
- package/main/i18ntk-summary.js +21 -18
- package/main/i18ntk-ui.js +11 -10
- package/main/i18ntk-usage.js +54 -18
- package/main/i18ntk-validate.js +13 -13
- package/main/manage/commands/AnalyzeCommand.js +1124 -0
- package/main/manage/commands/BackupCommand.js +62 -0
- package/main/manage/commands/CommandRouter.js +295 -0
- package/main/manage/commands/CompleteCommand.js +61 -0
- package/main/manage/commands/DoctorCommand.js +60 -0
- package/main/manage/commands/FixerCommand.js +624 -0
- package/main/manage/commands/InitCommand.js +62 -0
- package/main/manage/commands/ScannerCommand.js +654 -0
- package/main/manage/commands/SizingCommand.js +60 -0
- package/main/manage/commands/SummaryCommand.js +61 -0
- package/main/manage/commands/UsageCommand.js +60 -0
- package/main/manage/commands/ValidateCommand.js +978 -0
- package/main/manage/index-fixed.js +1447 -0
- package/main/manage/index.js +1462 -0
- package/main/manage/managers/DebugMenu.js +140 -0
- package/main/manage/managers/InteractiveMenu.js +177 -0
- package/main/manage/managers/LanguageMenu.js +62 -0
- package/main/manage/managers/SettingsMenu.js +53 -0
- package/main/manage/services/AuthenticationService.js +263 -0
- package/main/manage/services/ConfigurationService-fixed.js +449 -0
- package/main/manage/services/ConfigurationService.js +449 -0
- package/main/manage/services/FileManagementService.js +368 -0
- package/main/manage/services/FrameworkDetectionService.js +458 -0
- package/main/manage/services/InitService.js +1051 -0
- package/main/manage/services/SetupService.js +462 -0
- package/main/manage/services/SummaryService.js +450 -0
- package/main/manage/services/UsageService.js +1502 -0
- package/package.json +32 -29
- package/runtime/enhanced.d.ts +221 -221
- package/runtime/index.d.ts +29 -29
- package/runtime/index.full.d.ts +331 -331
- package/runtime/index.js +7 -6
- package/scripts/build-lite.js +17 -17
- package/scripts/deprecate-versions.js +23 -6
- package/scripts/export-translations.js +5 -5
- package/scripts/fix-all-i18n.js +3 -3
- package/scripts/fix-and-purify-i18n.js +3 -2
- package/scripts/fix-locale-control-chars.js +110 -0
- package/scripts/lint-locales.js +80 -0
- package/scripts/locale-optimizer.js +8 -8
- package/scripts/prepublish.js +21 -21
- package/scripts/security-check.js +117 -117
- package/scripts/sync-translations.js +4 -4
- package/scripts/sync-ui-locales.js +9 -8
- package/scripts/validate-all-translations.js +8 -7
- package/scripts/verify-deprecations.js +157 -161
- package/scripts/verify-translations.js +6 -5
- package/settings/i18ntk-config.json +282 -282
- package/settings/language-config.json +5 -5
- package/settings/settings-cli.js +9 -9
- package/settings/settings-manager.js +18 -18
- package/ui-locales/de.json +2417 -2348
- package/ui-locales/en.json +2415 -2352
- package/ui-locales/es.json +2425 -2353
- package/ui-locales/fr.json +2418 -2348
- package/ui-locales/ja.json +2463 -2361
- package/ui-locales/ru.json +2463 -2359
- package/ui-locales/zh.json +2418 -2351
- package/utils/admin-auth.js +2 -2
- package/utils/admin-cli.js +297 -297
- package/utils/admin-pin.js +9 -9
- package/utils/cli-helper.js +9 -9
- package/utils/config-helper.js +73 -104
- package/utils/config-manager.js +204 -171
- package/utils/config.js +5 -4
- package/utils/env-manager.js +249 -263
- package/utils/framework-detector.js +27 -24
- package/utils/i18n-helper.js +85 -41
- package/utils/init-helper.js +152 -94
- package/utils/json-output.js +98 -98
- package/utils/mini-commander.js +179 -0
- package/utils/missing-key-validator.js +5 -5
- package/utils/plugin-loader.js +40 -29
- package/utils/prompt.js +14 -44
- package/utils/safe-json.js +40 -0
- package/utils/secure-errors.js +3 -3
- package/utils/security-check-improved.js +390 -0
- package/utils/security-config.js +5 -5
- package/utils/security-fixed.js +607 -0
- package/utils/security.js +652 -602
- package/utils/setup-enforcer.js +136 -44
- package/utils/setup-validator.js +33 -32
- package/utils/ultra-performance-optimizer.js +11 -9
- package/utils/watch-locales.js +2 -1
- package/utils/prompt-fixed.js +0 -55
- package/utils/security-check.js +0 -454
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* I18NTK BACKUP COMMAND
|
|
5
|
+
*
|
|
6
|
+
* Handles backup operations for translation files and settings.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const I18nBackup = require('../../i18ntk-backup-class');
|
|
10
|
+
|
|
11
|
+
class BackupCommand {
|
|
12
|
+
constructor(config = {}, ui = null) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.ui = ui;
|
|
15
|
+
this.prompt = null;
|
|
16
|
+
this.isNonInteractiveMode = false;
|
|
17
|
+
this.safeClose = null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Set runtime dependencies for interactive operations
|
|
22
|
+
*/
|
|
23
|
+
setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose) {
|
|
24
|
+
this.prompt = prompt;
|
|
25
|
+
this.isNonInteractiveMode = isNonInteractiveMode;
|
|
26
|
+
this.safeClose = safeClose;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Execute the backup command
|
|
31
|
+
*/
|
|
32
|
+
async execute(options = {}) {
|
|
33
|
+
try {
|
|
34
|
+
const backup = new I18nBackup();
|
|
35
|
+
await backup.run(options);
|
|
36
|
+
return { success: true, command: 'backup' };
|
|
37
|
+
} catch (error) {
|
|
38
|
+
console.error(`Backup command failed: ${error.message}`);
|
|
39
|
+
throw error;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Get command metadata
|
|
45
|
+
*/
|
|
46
|
+
getMetadata() {
|
|
47
|
+
return {
|
|
48
|
+
name: 'backup',
|
|
49
|
+
description: 'Create backups of translation files and settings',
|
|
50
|
+
category: 'maintenance',
|
|
51
|
+
aliases: [],
|
|
52
|
+
usage: 'backup [options]',
|
|
53
|
+
examples: [
|
|
54
|
+
'backup',
|
|
55
|
+
'backup --output-dir=./backups',
|
|
56
|
+
'backup --include-settings'
|
|
57
|
+
]
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
module.exports = BackupCommand;
|
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* I18NTK COMMAND ROUTER
|
|
5
|
+
*
|
|
6
|
+
* Central command routing system for i18n operations.
|
|
7
|
+
* Handles command execution, authentication, and completion management.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
const path = require('path');
|
|
11
|
+
const { t } = require('../../../utils/i18n-helper');
|
|
12
|
+
|
|
13
|
+
// Import command handlers
|
|
14
|
+
const InitCommand = require('./InitCommand');
|
|
15
|
+
const AnalyzeCommand = require('./AnalyzeCommand');
|
|
16
|
+
const ValidateCommand = require('./ValidateCommand');
|
|
17
|
+
const CompleteCommand = require('./CompleteCommand');
|
|
18
|
+
const SummaryCommand = require('./SummaryCommand');
|
|
19
|
+
const SizingCommand = require('./SizingCommand');
|
|
20
|
+
const UsageCommand = require('./UsageCommand');
|
|
21
|
+
const BackupCommand = require('./BackupCommand');
|
|
22
|
+
const DoctorCommand = require('./DoctorCommand');
|
|
23
|
+
const FixerCommand = require('./FixerCommand');
|
|
24
|
+
const ScannerCommand = require('./ScannerCommand');
|
|
25
|
+
|
|
26
|
+
class CommandRouter {
|
|
27
|
+
constructor(config = {}, ui = null, adminAuth = null) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.ui = ui;
|
|
30
|
+
this.adminAuth = adminAuth;
|
|
31
|
+
this.prompt = null;
|
|
32
|
+
this.isNonInteractiveMode = false;
|
|
33
|
+
this.safeClose = null;
|
|
34
|
+
|
|
35
|
+
// Initialize command handlers
|
|
36
|
+
this.commandHandlers = {
|
|
37
|
+
'init': new InitCommand(config, ui),
|
|
38
|
+
'analyze': new AnalyzeCommand(config, ui),
|
|
39
|
+
'validate': new ValidateCommand(config, ui),
|
|
40
|
+
'complete': new CompleteCommand(config, ui),
|
|
41
|
+
'summary': new SummaryCommand(config, ui),
|
|
42
|
+
'sizing': new SizingCommand(config, ui),
|
|
43
|
+
'usage': new UsageCommand(config, ui),
|
|
44
|
+
'backup': new BackupCommand(config, ui),
|
|
45
|
+
'doctor': new DoctorCommand(config, ui),
|
|
46
|
+
'fix': new FixerCommand(config, ui),
|
|
47
|
+
'scanner': new ScannerCommand(config, ui)
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Set runtime dependencies for interactive operations
|
|
53
|
+
*/
|
|
54
|
+
setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose) {
|
|
55
|
+
this.prompt = prompt;
|
|
56
|
+
this.isNonInteractiveMode = isNonInteractiveMode;
|
|
57
|
+
this.safeClose = safeClose;
|
|
58
|
+
|
|
59
|
+
// Update command handlers with runtime dependencies
|
|
60
|
+
Object.values(this.commandHandlers).forEach(handler => {
|
|
61
|
+
if (typeof handler.setRuntimeDependencies === 'function') {
|
|
62
|
+
handler.setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Determine execution context based on options and environment
|
|
69
|
+
*/
|
|
70
|
+
getExecutionContext(options = {}) {
|
|
71
|
+
// Check if called from interactive menu
|
|
72
|
+
if (options.fromMenu === true) {
|
|
73
|
+
return { type: 'manager', source: 'interactive_menu' };
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Check if called from workflow/autorun
|
|
77
|
+
if (options.fromWorkflow === true) {
|
|
78
|
+
return { type: 'workflow', source: 'autorun_script' };
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Check if this is a direct command line execution
|
|
82
|
+
if (process.argv.some(arg => arg.startsWith('--command='))) {
|
|
83
|
+
return { type: 'direct', source: 'command_line' };
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Default to direct execution
|
|
87
|
+
return { type: 'direct', source: 'unknown' };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Check admin authentication for protected commands
|
|
92
|
+
*/
|
|
93
|
+
async checkAdminAuth() {
|
|
94
|
+
if (!this.adminAuth) {
|
|
95
|
+
return true; // No auth service available, allow execution
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const isRequired = await this.adminAuth.isAuthRequired();
|
|
99
|
+
if (!isRequired) {
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
console.log(t('adminCli.authRequired'));
|
|
104
|
+
const cliHelper = require('../../../utils/cli-helper');
|
|
105
|
+
const pin = await cliHelper.promptPin(t('adminCli.enterPin'));
|
|
106
|
+
const isValid = await this.adminAuth.verifyPin(pin);
|
|
107
|
+
|
|
108
|
+
if (!isValid) {
|
|
109
|
+
console.log(t('adminCli.invalidPin'));
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
console.log(t('adminCli.authSuccess'));
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Execute a command with proper routing and error handling
|
|
119
|
+
*/
|
|
120
|
+
async executeCommand(command, options = {}) {
|
|
121
|
+
console.log(t('menu.executingCommand', { command }));
|
|
122
|
+
|
|
123
|
+
// Enhanced context detection
|
|
124
|
+
const executionContext = this.getExecutionContext(options);
|
|
125
|
+
const isDirectCommand = executionContext.type === 'direct';
|
|
126
|
+
const isWorkflowExecution = executionContext.type === 'workflow';
|
|
127
|
+
const isManagerExecution = executionContext.type === 'manager';
|
|
128
|
+
|
|
129
|
+
// Ensure UI language is refreshed from settings for workflow and direct execution
|
|
130
|
+
if (isWorkflowExecution || isDirectCommand) {
|
|
131
|
+
if (this.ui && typeof this.ui.refreshLanguageFromSettings === 'function') {
|
|
132
|
+
this.ui.refreshLanguageFromSettings();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
// Check admin authentication for protected commands
|
|
137
|
+
const authRequiredCommands = [
|
|
138
|
+
'init', 'analyze', 'validate', 'usage', 'scanner',
|
|
139
|
+
'complete', 'fix', 'sizing', 'workflow', 'status',
|
|
140
|
+
'delete', 'settings', 'debug', 'backup', 'doctor'
|
|
141
|
+
];
|
|
142
|
+
|
|
143
|
+
if (authRequiredCommands.includes(command)) {
|
|
144
|
+
const authPassed = await this.checkAdminAuth();
|
|
145
|
+
if (!authPassed) {
|
|
146
|
+
if (!this.isNonInteractiveMode && !isDirectCommand && this.prompt) {
|
|
147
|
+
await this.prompt(t('menu.pressEnterToContinue'));
|
|
148
|
+
// Return to menu would be handled by caller
|
|
149
|
+
}
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
try {
|
|
155
|
+
// Route command to appropriate handler
|
|
156
|
+
const result = await this.routeCommand(command, options, executionContext);
|
|
157
|
+
|
|
158
|
+
// Handle command completion based on execution context
|
|
159
|
+
console.log(t('operations.completed'));
|
|
160
|
+
|
|
161
|
+
if (isManagerExecution && !this.isNonInteractiveMode && this.prompt) {
|
|
162
|
+
// Interactive menu execution - return to menu
|
|
163
|
+
await this.prompt(t('menu.returnToMainMenu'));
|
|
164
|
+
// Menu return would be handled by caller
|
|
165
|
+
} else {
|
|
166
|
+
// Direct commands, non-interactive mode, or workflow execution - exit immediately
|
|
167
|
+
console.log(t('workflow.exitingCompleted'));
|
|
168
|
+
if (this.safeClose) this.safeClose();
|
|
169
|
+
process.exit(0);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
} catch (error) {
|
|
173
|
+
console.error(t('common.errorExecutingCommand', { error: error.message }));
|
|
174
|
+
|
|
175
|
+
if (isManagerExecution && !this.isNonInteractiveMode && this.prompt) {
|
|
176
|
+
// Interactive menu execution - show error and return to menu
|
|
177
|
+
await this.prompt(t('menu.pressEnterToContinue'));
|
|
178
|
+
// Menu return would be handled by caller
|
|
179
|
+
} else if (isDirectCommand && !this.isNonInteractiveMode && this.prompt) {
|
|
180
|
+
// Direct command execution - show "enter to continue" and exit with error
|
|
181
|
+
await this.prompt(t('menu.pressEnterToContinue'));
|
|
182
|
+
if (this.safeClose) this.safeClose();
|
|
183
|
+
process.exit(1);
|
|
184
|
+
} else {
|
|
185
|
+
// Non-interactive mode or workflow execution - exit immediately with error
|
|
186
|
+
if (this.safeClose) this.safeClose();
|
|
187
|
+
process.exit(1);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Route command to the appropriate handler
|
|
194
|
+
*/
|
|
195
|
+
async routeCommand(command, options, executionContext) {
|
|
196
|
+
const isManagerExecution = executionContext.type === 'manager';
|
|
197
|
+
|
|
198
|
+
switch (command) {
|
|
199
|
+
case 'init':
|
|
200
|
+
return await this.commandHandlers.init.execute(options);
|
|
201
|
+
|
|
202
|
+
case 'analyze':
|
|
203
|
+
return await this.commandHandlers.analyze.execute(options);
|
|
204
|
+
|
|
205
|
+
case 'validate':
|
|
206
|
+
return await this.commandHandlers.validate.execute(options);
|
|
207
|
+
|
|
208
|
+
case 'complete':
|
|
209
|
+
return await this.commandHandlers.complete.execute(options);
|
|
210
|
+
|
|
211
|
+
case 'summary':
|
|
212
|
+
return await this.commandHandlers.summary.execute(options);
|
|
213
|
+
|
|
214
|
+
case 'sizing':
|
|
215
|
+
return await this.commandHandlers.sizing.execute(options);
|
|
216
|
+
|
|
217
|
+
case 'usage':
|
|
218
|
+
return await this.commandHandlers.usage.execute(options);
|
|
219
|
+
|
|
220
|
+
case 'backup':
|
|
221
|
+
return await this.commandHandlers.backup.execute(options);
|
|
222
|
+
|
|
223
|
+
case 'doctor':
|
|
224
|
+
return await this.commandHandlers.doctor.execute(options);
|
|
225
|
+
|
|
226
|
+
case 'fix':
|
|
227
|
+
return await this.commandHandlers.fix.execute(options);
|
|
228
|
+
|
|
229
|
+
case 'scanner':
|
|
230
|
+
return await this.commandHandlers.scanner.execute(options);
|
|
231
|
+
|
|
232
|
+
case 'debug':
|
|
233
|
+
console.log('Debug functionality is not available in this version.');
|
|
234
|
+
return { success: false, message: 'Debug not available' };
|
|
235
|
+
|
|
236
|
+
case 'help':
|
|
237
|
+
this.showHelp();
|
|
238
|
+
if (isManagerExecution && !this.isNonInteractiveMode && this.prompt) {
|
|
239
|
+
await this.prompt(t('menu.pressEnterToContinue'));
|
|
240
|
+
// Menu return would be handled by caller
|
|
241
|
+
} else {
|
|
242
|
+
console.log(t('workflow.exitingCompleted'));
|
|
243
|
+
if (this.safeClose) this.safeClose();
|
|
244
|
+
process.exit(0);
|
|
245
|
+
}
|
|
246
|
+
return { success: true, command: 'help' };
|
|
247
|
+
|
|
248
|
+
default:
|
|
249
|
+
console.log(t('menu.unknownCommand', { command }));
|
|
250
|
+
this.showHelp();
|
|
251
|
+
return { success: false, error: 'Unknown command' };
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Show help information
|
|
257
|
+
*/
|
|
258
|
+
showHelp() {
|
|
259
|
+
const localT = this.ui && this.ui.t ? this.ui.t.bind(this.ui) : (key) => key;
|
|
260
|
+
|
|
261
|
+
console.log(t('help.usage'));
|
|
262
|
+
console.log(t('help.interactiveMode'));
|
|
263
|
+
console.log(t('help.initProject'));
|
|
264
|
+
console.log(t('help.analyzeTranslations'));
|
|
265
|
+
console.log(t('help.validateTranslations'));
|
|
266
|
+
console.log(t('help.checkUsage'));
|
|
267
|
+
console.log(t('help.showHelp'));
|
|
268
|
+
console.log(t('help.availableCommands'));
|
|
269
|
+
console.log(t('help.initCommand'));
|
|
270
|
+
console.log(t('help.analyzeCommand'));
|
|
271
|
+
console.log(t('help.validateCommand'));
|
|
272
|
+
console.log(t('help.usageCommand'));
|
|
273
|
+
console.log(t('help.sizingCommand'));
|
|
274
|
+
console.log(t('help.completeCommand'));
|
|
275
|
+
console.log(t('help.summaryCommand'));
|
|
276
|
+
console.log(t('help.debugCommand'));
|
|
277
|
+
console.log(t('help.scannerCommand'));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Get list of available commands
|
|
282
|
+
*/
|
|
283
|
+
getAvailableCommands() {
|
|
284
|
+
return Object.keys(this.commandHandlers);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
/**
|
|
288
|
+
* Check if a command is available
|
|
289
|
+
*/
|
|
290
|
+
isCommandAvailable(command) {
|
|
291
|
+
return command in this.commandHandlers;
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
module.exports = CommandRouter;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* I18NTK COMPLETE COMMAND
|
|
5
|
+
*
|
|
6
|
+
* Handles completion analysis functionality.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
class CompleteCommand {
|
|
10
|
+
constructor(config = {}, ui = null) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
this.ui = ui;
|
|
13
|
+
this.prompt = null;
|
|
14
|
+
this.isNonInteractiveMode = false;
|
|
15
|
+
this.safeClose = null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Set runtime dependencies for interactive operations
|
|
20
|
+
*/
|
|
21
|
+
setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose) {
|
|
22
|
+
this.prompt = prompt;
|
|
23
|
+
this.isNonInteractiveMode = isNonInteractiveMode;
|
|
24
|
+
this.safeClose = safeClose;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Execute the complete command
|
|
29
|
+
*/
|
|
30
|
+
async execute(options = {}) {
|
|
31
|
+
try {
|
|
32
|
+
const completeTool = require('../../i18ntk-complete');
|
|
33
|
+
const tool = new completeTool();
|
|
34
|
+
await tool.run(options);
|
|
35
|
+
return { success: true, command: 'complete' };
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(`Complete command failed: ${error.message}`);
|
|
38
|
+
throw error;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Get command metadata
|
|
44
|
+
*/
|
|
45
|
+
getMetadata() {
|
|
46
|
+
return {
|
|
47
|
+
name: 'complete',
|
|
48
|
+
description: 'Run complete analysis on translation files',
|
|
49
|
+
category: 'analysis',
|
|
50
|
+
aliases: [],
|
|
51
|
+
usage: 'complete [options]',
|
|
52
|
+
examples: [
|
|
53
|
+
'complete',
|
|
54
|
+
'complete --source-dir=./src/locales',
|
|
55
|
+
'complete --output-dir=./reports'
|
|
56
|
+
]
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = CompleteCommand;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* I18NTK DOCTOR COMMAND
|
|
5
|
+
*
|
|
6
|
+
* Handles diagnostic functionality for i18n toolkit.
|
|
7
|
+
*/
|
|
8
|
+
class DoctorCommand {
|
|
9
|
+
constructor(config = {}, ui = null) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.ui = ui;
|
|
12
|
+
this.prompt = null;
|
|
13
|
+
this.isNonInteractiveMode = false;
|
|
14
|
+
this.safeClose = null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Set runtime dependencies for interactive operations
|
|
19
|
+
*/
|
|
20
|
+
setRuntimeDependencies(prompt, isNonInteractiveMode, safeClose) {
|
|
21
|
+
this.prompt = prompt;
|
|
22
|
+
this.isNonInteractiveMode = isNonInteractiveMode;
|
|
23
|
+
this.safeClose = safeClose;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Execute the doctor command
|
|
28
|
+
*/
|
|
29
|
+
async execute(options = {}) {
|
|
30
|
+
try {
|
|
31
|
+
const I18nDoctor = require('../../i18ntk-doctor');
|
|
32
|
+
const doctor = new I18nDoctor();
|
|
33
|
+
await doctor.run(options);
|
|
34
|
+
return { success: true, command: 'doctor' };
|
|
35
|
+
} catch (error) {
|
|
36
|
+
console.error(`Doctor command failed: ${error.message}`);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Get command metadata
|
|
43
|
+
*/
|
|
44
|
+
getMetadata() {
|
|
45
|
+
return {
|
|
46
|
+
name: 'doctor',
|
|
47
|
+
description: 'Run diagnostic checks on i18n setup and configuration',
|
|
48
|
+
category: 'diagnostic',
|
|
49
|
+
aliases: ['diagnose'],
|
|
50
|
+
usage: 'doctor [options]',
|
|
51
|
+
examples: [
|
|
52
|
+
'doctor',
|
|
53
|
+
'doctor --verbose',
|
|
54
|
+
'doctor --fix'
|
|
55
|
+
]
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
module.exports = DoctorCommand;
|