OneBot: Leantime 改造版源码(BOM/Univer 表格/AI 接管/品牌替换等)
This commit is contained in:
39
app/Domain/Environment/Commands/SyncEnvironment.php
Normal file
39
app/Domain/Environment/Commands/SyncEnvironment.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace Leantime\Domain\Environment\Commands;
|
||||
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class SyncEnvironment extends Command
|
||||
{
|
||||
protected static $defaultName = 'env:sync';
|
||||
|
||||
protected static $defaultDescription = 'Synchronizes environment variables to .env file';
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||
{
|
||||
$output->writeln('Starting environment variable sync...');
|
||||
|
||||
$envFile = base_path('.env');
|
||||
|
||||
// Create or clear the .env file
|
||||
file_put_contents($envFile, '# Generated by env:sync command - '.date('Y-m-d H:i:s')."\n");
|
||||
|
||||
// Get all environment variables
|
||||
foreach ($_ENV as $name => $value) {
|
||||
if (str_starts_with($name, 'LEAN_')) {
|
||||
$escapedValue = str_replace(['\\', '"', '$'], ['\\\\', '\\"', '\\$'], $value);
|
||||
file_put_contents($envFile, "{$name}=\"{$escapedValue}\"\n", FILE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
// Set proper permissions
|
||||
chmod($envFile, 0640);
|
||||
|
||||
$output->writeln('Environment sync completed.');
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user