-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-local.js
More file actions
executable file
·62 lines (50 loc) · 1.86 KB
/
Copy pathtest-local.js
File metadata and controls
executable file
·62 lines (50 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env node
// Local testing script for i18n String Reviewer with LLM
// This script sets environment variables with dashes (which shell can't do)
const { spawn } = require('child_process');
const path = require('path');
console.log('🧪 Testing i18n String Reviewer with LLM');
console.log('========================================\n');
// Get command line arguments
const baseFile = process.argv[2] || 'examples/base.pot';
const targetFile = process.argv[3] || 'examples/target.pot';
const openrouterKey = process.env.OPENROUTER_API_KEY || '';
const openrouterModel = process.env.OPENROUTER_MODEL || 'anthropic/claude-3.5-sonnet';
if (!openrouterKey) {
console.log('⚠️ Warning: OPENROUTER_API_KEY not set');
console.log('Set it with: export OPENROUTER_API_KEY=\'your-key\'');
console.log('Testing without LLM feature...\n');
}
console.log(`📁 Base POT: ${baseFile}`);
console.log(`📁 Target POT: ${targetFile}`);
console.log(`🤖 LLM Model: ${openrouterModel}\n`);
// Check for debug mode
const debugMode = process.env.DEBUG_LLM === 'true' || process.argv.includes('--debug');
if (debugMode) {
console.log('🐛 Debug mode enabled\n');
}
// Set environment variables (Node.js can handle dashes in process.env)
const env = {
...process.env,
'INPUT_BASE-POT-FILE': baseFile,
'INPUT_TARGET-POT-FILE': targetFile,
'INPUT_FAIL-ON-CHANGES': 'false',
'INPUT_COMMENT-ON-PR': 'false',
'INPUT_OPENROUTER-KEY': openrouterKey,
'INPUT_OPENROUTER-MODEL': openrouterModel,
'DEBUG_LLM': debugMode ? 'true' : 'false'
};
// Run the action
const child = spawn('node', ['dist/index.js'], {
env: env,
stdio: 'inherit',
cwd: __dirname
});
child.on('close', (code) => {
console.log(`\n✅ Test complete (exit code: ${code})`);
process.exit(code);
});
child.on('error', (error) => {
console.error(`\n❌ Error: ${error.message}`);
process.exit(1);
});