-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_quotes.php
More file actions
59 lines (46 loc) · 1.92 KB
/
debug_quotes.php
File metadata and controls
59 lines (46 loc) · 1.92 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
<?php
require_once 'vendor/autoload.php';
use Illuminate\Support\Facades\File;
use Blemli\Envsync\Commands\EnvsyncCommand;
// Create test files
file_put_contents('.env', 'VITE_APP_NAME="${APP_NAME}"' . "\n");
file_put_contents('.env.example', 'VITE_APP_NAME="${OLD_NAME}"' . "\n");
echo "=== Debug Quote Detection ===\n\n";
echo "📄 .env content:\n";
echo file_get_contents('.env');
echo "\n📄 .env.example content:\n";
echo file_get_contents('.env.example');
// Test the parsing
$command = new EnvsyncCommand();
$reflection = new \ReflectionClass($command);
$parseMethod = $reflection->getMethod('parseEnvFileWithStructure');
$parseMethod->setAccessible(true);
$sourceData = $parseMethod->invoke($command, '.env');
$targetData = $parseMethod->invoke($command, '.env.example');
echo "\n🔍 Source structure:\n";
foreach ($sourceData['structure'] as $lineNum => $lineData) {
if ($lineData['type'] === 'env_var') {
echo "Line {$lineNum}: '{$lineData['original']}'\n";
echo " Key: {$lineData['key']}\n";
echo " Value: {$lineData['value']}\n";
// Test quote detection
$originalLine = $lineData['original'];
$hasQuotes = preg_match('/=\s*"/', $originalLine) || preg_match("/=\s*'/", $originalLine);
echo " Has quotes: " . ($hasQuotes ? 'YES' : 'NO') . "\n";
}
}
echo "\n🔍 Target structure:\n";
foreach ($targetData['structure'] as $lineNum => $lineData) {
if ($lineData['type'] === 'env_var') {
echo "Line {$lineNum}: '{$lineData['original']}'\n";
echo " Key: {$lineData['key']}\n";
echo " Value: {$lineData['value']}\n";
}
}
// Test sync method
$syncMethod = $reflection->getMethod('syncValueToTarget');
$syncMethod->setAccessible(true);
echo "\n🚀 Testing sync...\n";
$syncMethod->invoke($command, '.env.example', 'VITE_APP_NAME', '${APP_NAME}', false);
echo "\n📄 .env.example after sync:\n";
echo file_get_contents('.env.example');