v7.0.0 release
This commit is contained in:
1 parent
0e7fa04b03
commit
c4ea9a6cd1
3582 files changed
+626189
-160151
No files matched your search
@@ -2,12 +2,15 @@
|
||||
|
||||
namespace App\Console\Commands\Core;
|
||||
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
|
||||
class BuildCoreCommand extends Command
|
||||
{
|
||||
use ClearsTemplateCaches;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
@@ -99,6 +102,7 @@ class BuildCoreCommand extends Command
|
||||
if ($result === Command::SUCCESS && ! $watchMode) {
|
||||
$this->info('✅ 코어 빌드 완료 (템플릿 엔진)');
|
||||
$this->showEngineBuildResults($projectPath);
|
||||
$this->incrementExtensionCacheVersion();
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -130,6 +134,7 @@ class BuildCoreCommand extends Command
|
||||
if ($result === Command::SUCCESS && ! $watchMode) {
|
||||
$this->info('✅ 코어 빌드 완료 (전체)');
|
||||
$this->showFullBuildResults($projectPath);
|
||||
$this->incrementExtensionCacheVersion();
|
||||
}
|
||||
|
||||
return $result;
|
||||
@@ -156,17 +161,6 @@ class BuildCoreCommand extends Command
|
||||
$fileSize = number_format(filesize($engineFile) / 1024, 2);
|
||||
$this->line(" - template-engine.min.js ({$fileSize} KB)");
|
||||
}
|
||||
|
||||
// lang 파일 확인
|
||||
$langPath = $corePath.'/lang';
|
||||
if (is_dir($langPath)) {
|
||||
$langFiles = glob($langPath.'/*.json');
|
||||
foreach ($langFiles as $langFile) {
|
||||
$fileName = 'lang/'.basename($langFile);
|
||||
$fileSize = number_format(filesize($langFile) / 1024, 2);
|
||||
$this->line(" - {$fileName} ({$fileSize} KB)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -3,13 +3,15 @@
|
||||
namespace App\Console\Commands\Core;
|
||||
|
||||
use App\Console\Commands\Core\Concerns\BundledExtensionUpdatePrompt;
|
||||
use App\Exceptions\UpgradeHandoffException;
|
||||
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
||||
use App\Exceptions\UpgradeHandoffException;
|
||||
use App\Extension\CoreVersionChecker;
|
||||
use App\Extension\Helpers\CoreBackupHelper;
|
||||
use App\Extension\Helpers\FilePermissionHelper;
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\TemplateManager;
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use App\Extension\Vendor\Exceptions\VendorInstallException;
|
||||
use App\Extension\Vendor\VendorMode;
|
||||
use App\Services\CoreUpdateService;
|
||||
@@ -19,6 +21,7 @@ use Illuminate\Support\Facades\Log;
|
||||
class CoreUpdateCommand extends Command
|
||||
{
|
||||
use BundledExtensionUpdatePrompt;
|
||||
use ClearsTemplateCaches;
|
||||
use HasUnifiedConfirm;
|
||||
|
||||
protected $signature = 'core:update
|
||||
@@ -457,6 +460,11 @@ class CoreUpdateCommand extends Command
|
||||
$service->updateVersionInEnv($toVersion);
|
||||
$service->clearAllCaches();
|
||||
|
||||
// 코어 업데이트 후 프론트엔드가 새 lang/routes/layout 자원으로 fetch 하도록
|
||||
// `ext.cache_version` bump. 코어 lang JSON 변경이 프론트엔드 캐시에
|
||||
// 반영되지 않는 회귀를 차단한다 (core-frontend-i18n-infrastructure 계획서).
|
||||
$this->incrementExtensionCacheVersion();
|
||||
|
||||
// sudo 실행 시 composer 등 외부 프로세스가 root 로 생성한 파일의 소유권을
|
||||
// 백업 직후 수집한 원본 스냅샷 기준으로 복원 (각 경로 고유 소유자 유지).
|
||||
// detailedSnapshot 동시 전달 — PHP-FPM 쓰기 영역의 owner/group/perms 를 항목별
|
||||
@@ -514,6 +522,10 @@ class CoreUpdateCommand extends Command
|
||||
$log('일괄 확장 업데이트 후 소유권 재복원 완료');
|
||||
}
|
||||
|
||||
// fallback(spawn 실패)로 부모가 upgrade step 을 직접 실행한 경우, 부모가 만든
|
||||
// upgrade 로그가 root 로 남는다 — 모든 로그 쓰기가 끝난 이 시점에 정합한다.
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
} catch (UpgradeHandoffException $e) {
|
||||
@@ -548,6 +560,10 @@ class CoreUpdateCommand extends Command
|
||||
try {
|
||||
$service->updateVersionInEnv($toVersion);
|
||||
$service->clearAllCaches();
|
||||
// 핸드오프 cleanup 에서도 프론트엔드 캐시 버전 bump — 사용자가 resume 명령
|
||||
// (execute-upgrade-steps) 을 실행하기 전이라도 이미 toVersion 으로 반영된
|
||||
// 코어 lang/routes/layout 자원이 프론트엔드 캐시 stale 로 가려지지 않도록.
|
||||
$this->incrementExtensionCacheVersion();
|
||||
// Stage 4 — handoff cleanup 도 detailed snapshot 으로 정확 복원
|
||||
$service->restoreOwnership($ownershipSnapshot, $onProgress, $detailedOwnershipSnapshot);
|
||||
$this->surfacePermissionWarnings($service, $log);
|
||||
@@ -587,6 +603,8 @@ class CoreUpdateCommand extends Command
|
||||
$this->newLine();
|
||||
}
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return Command::SUCCESS;
|
||||
|
||||
} catch (\Throwable $e) {
|
||||
@@ -680,6 +698,8 @@ class CoreUpdateCommand extends Command
|
||||
}
|
||||
}
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
@@ -703,9 +723,9 @@ class CoreUpdateCommand extends Command
|
||||
* @param string $toVersion 대상 버전
|
||||
* @param bool $force 동일 버전 강제 실행 여부
|
||||
* @param \Closure $log 로그 엔트리 수집 콜백
|
||||
* @return bool spawn 성공 여부 (false 면 fallback 실행 필요)
|
||||
* @return bool spawn 성공 여부 (false 면 fallback 실행 필요)
|
||||
*
|
||||
* @throws UpgradeHandoffException 자식이 핸드오프 신호를 보낸 경우
|
||||
* @throws UpgradeHandoffException 자식이 핸드오프 신호를 보낸 경우
|
||||
*/
|
||||
private function spawnUpgradeStepsProcess(string $fromVersion, string $toVersion, bool $force, \Closure $log): bool
|
||||
{
|
||||
@@ -893,9 +913,9 @@ class CoreUpdateCommand extends Command
|
||||
* @param \Closure $log 로그 엔트리 수집 콜백
|
||||
* @param string $fromVersion 업그레이드 시작 버전 (handoff afterVersion / resumeCommand 구성)
|
||||
* @param string $toVersion 업그레이드 대상 버전 (resumeCommand 구성)
|
||||
* @return false fallback 모드일 때만 반환. abort 모드는 throw 후 미반환.
|
||||
* @return false fallback 모드일 때만 반환. abort 모드는 throw 후 미반환.
|
||||
*
|
||||
* @throws UpgradeHandoffException mode=abort 일 때
|
||||
* @throws UpgradeHandoffException mode=abort 일 때
|
||||
*/
|
||||
private function failSpawnWithMode(string $reason, \Closure $log, string $fromVersion, string $toVersion): bool
|
||||
{
|
||||
@@ -1000,10 +1020,44 @@ class CoreUpdateCommand extends Command
|
||||
$content = $header."\n".implode("\n", $entries)."\n";
|
||||
|
||||
file_put_contents($logPath, $content);
|
||||
// sudo 업데이트가 로그 파일을 root 소유로 만들면 이후 www-data 의 tinker/로그 쓰기가
|
||||
// 거부된다. 부모(storage/logs) 소유권을 상속한다(멱등, sudo 없으면 silent no-op).
|
||||
FilePermissionHelper::inheritOwnershipFromParent($logPath);
|
||||
|
||||
Log::info("코어 업데이트 로그 저장: {$logPath}");
|
||||
}
|
||||
|
||||
/**
|
||||
* 코어 업데이트(부모 프로세스)가 생성한 upgrade 로그 파일의 소유권을 부모(storage/logs)
|
||||
* 로 정합합니다 — **spawn 실패로 부모가 upgrade step 을 in-process 로 직접 실행한 경우** 대비.
|
||||
*
|
||||
* upgrade 로그(`upgrade-YYYY-MM-DD.log`)를 만드는 주체는 두 갈래다:
|
||||
* - spawn 성공: 자식(ExecuteUpgradeStepsCommand)이 로그 생성 → 자식이 자기 종료 직전 정합
|
||||
* - spawn 실패(fallback): 부모가 runUpgradeSteps + reloadCoreConfigAndResync 를 직접 실행
|
||||
* 하여 부모 프로세스가 upgrade 로그를 root 로 생성 → **부모가** 정합해야 한다.
|
||||
*
|
||||
* sudo 업데이트는 root 로 실행되어 로그를 root 소유로 만들고, 이후 www-data(php-fpm) 의
|
||||
* module:update upgrade step 이 같은 날짜 로그에 append 하지 못해 Permission denied 로
|
||||
* 실패한다. 본 메서드를 코어 업데이트의 모든 로그 쓰기가 끝난 종료 시점(각 return 직전)에
|
||||
* 호출한다. **본 메서드 자체는 로그를 쓰지 않는다**(쓰면 다시 root 가 됨). silent no-op 멱등.
|
||||
*/
|
||||
private function restoreUpgradeLogOwnership(): void
|
||||
{
|
||||
$logsDir = storage_path('logs');
|
||||
if (! is_dir($logsDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 코어('upgrade-*.log') + 확장('extension-upgrade-*.log') 두 채널의 daily 로그를 모두
|
||||
// 정합한다. glob 'upgrade-*.log' 는 'extension-' 접두사 파일을 매칭하지 못하므로
|
||||
// 두 패턴을 각각 순회한다.
|
||||
foreach (['upgrade-*.log', 'extension-upgrade-*.log'] as $pattern) {
|
||||
foreach (glob($logsDir.DIRECTORY_SEPARATOR.$pattern) ?: [] as $logFile) {
|
||||
FilePermissionHelper::inheritOwnershipFromParent($logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 현재 실행 사용자와 코어 파일 소유자가 다른 경우 경고를 표시합니다.
|
||||
*
|
||||
@@ -1059,9 +1113,7 @@ class CoreUpdateCommand extends Command
|
||||
* 본 메서드 호출 후 service 의 `lastPermissionWarnings` 가 다음 호출 시 초기화되므로
|
||||
* 매 `restoreOwnership` 직후 1회 호출 패턴이 정합.
|
||||
*
|
||||
* @param CoreUpdateService $service
|
||||
* @param callable $log 내부 로그 누적 콜백 (`saveUpdateLog` 입력용)
|
||||
* @return void
|
||||
*/
|
||||
private function surfacePermissionWarnings(CoreUpdateService $service, callable $log): void
|
||||
{
|
||||
|
||||
@@ -5,9 +5,12 @@ namespace App\Console\Commands\Core;
|
||||
use App\Console\Commands\Core\Concerns\BundledExtensionUpdatePrompt;
|
||||
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
||||
use App\Exceptions\UpgradeHandoffException;
|
||||
use App\Extension\ExtensionManager;
|
||||
use App\Extension\Helpers\FilePermissionHelper;
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\TemplateManager;
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use App\Services\CoreUpdateService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
@@ -28,23 +31,30 @@ use Illuminate\Support\Facades\Log;
|
||||
* 기본값으로 부모 CoreUpdateCommand 가 처리하던 사전(Migration + Resync) 및
|
||||
* 사후(.env 버전 + 캐시 정리 + 번들 확장 일괄 업데이트) 단계를 자동 수행한다.
|
||||
* CoreUpdateCommand spawn 호출 시엔 `--skip-*` 옵션 5개로 중복 회피.
|
||||
*
|
||||
* `--steps-only`: 업그레이드 스텝만 실행하고 모든 보조 단계(권한 정상화 ·
|
||||
* 오토로드 재생성 · 마이그레이션 · resync · 버전 갱신 · 캐시 정리 · 번들 업데이트)를
|
||||
* 생략한다. 특정 스텝의 데이터 보정만 단발성으로 재실행할 때 사용한다. 보조 단계가
|
||||
* 이미 완료된 환경에서 무거운 권한 재귀 순회 등을 건너뛴다.
|
||||
*/
|
||||
class ExecuteUpgradeStepsCommand extends Command
|
||||
{
|
||||
use BundledExtensionUpdatePrompt;
|
||||
use ClearsTemplateCaches;
|
||||
use HasUnifiedConfirm;
|
||||
|
||||
protected $signature = 'core:execute-upgrade-steps
|
||||
{--from= : 시작 버전}
|
||||
{--to= : 대상 버전}
|
||||
{--force : 동일 버전 강제 실행 + 번들 확장 일괄 업데이트 prompt 스킵}
|
||||
{--steps-only : 업그레이드 스텝만 실행 — 권한 정상화·오토로드 재생성·마이그레이션·resync·버전 갱신·캐시 정리·번들 업데이트 등 모든 사전/사후 보조 단계 생략}
|
||||
{--skip-migrations : 마이그레이션 실행 생략 (CoreUpdateCommand spawn 시 부모 Step 9 가 이미 실행)}
|
||||
{--skip-resync : 코어 config 재로드 및 권한/메뉴/시더 동기화 생략 (동일 사유)}
|
||||
{--skip-version-env : .env APP_VERSION 갱신 생략 (부모 Step 11 가 처리)}
|
||||
{--skip-cache-clear : 캐시 정리 생략 (부모 Step 11 가 처리)}
|
||||
{--skip-bundled-updates : 번들 확장 일괄 업데이트 생략 (부모가 prompt 로 처리)}';
|
||||
|
||||
protected $description = '코어 업그레이드 스텝을 별도 프로세스에서 실행합니다. 단독 실행 시 사전/사후 단계를 자동 수행합니다.';
|
||||
protected $description = '코어 업그레이드 스텝을 별도 프로세스에서 실행합니다. 단독 실행 시 사전/사후 단계를 자동 수행하며, --steps-only 로 스텝만 실행할 수 있습니다.';
|
||||
|
||||
/**
|
||||
* 커맨드를 실행합니다.
|
||||
@@ -58,6 +68,11 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
$to = (string) $this->option('to');
|
||||
$force = (bool) $this->option('force');
|
||||
|
||||
// --steps-only: 업그레이드 스텝만 실행하고 모든 보조 단계(권한 정상화 · 오토로드
|
||||
// 재생성 · 마이그레이션 · resync · 버전 갱신 · 캐시 정리 · 번들 업데이트)를 생략한다.
|
||||
// 운영자가 특정 스텝의 데이터 보정만 단발성으로 재실행할 때 사용한다.
|
||||
$stepsOnly = (bool) $this->option('steps-only');
|
||||
|
||||
if ($from === '' || $to === '') {
|
||||
$this->error('--from 과 --to 는 필수 옵션입니다.');
|
||||
|
||||
@@ -75,12 +90,14 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// `app(ExtensionManager::class)->updateComposerAutoload()` 직접 호출은 stale 가능성
|
||||
// 없음. (Artisan::call 대신 직접 호출 — nested Artisan::call 이 outer 명령의
|
||||
// output buffer 를 덮어쓰는 Laravel 동작 회피)
|
||||
try {
|
||||
app(\App\Extension\ExtensionManager::class)->updateComposerAutoload();
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('upgrade step spawn 자식: updateComposerAutoload 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
if (! $stepsOnly) {
|
||||
try {
|
||||
app(ExtensionManager::class)->updateComposerAutoload();
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('upgrade step spawn 자식: updateComposerAutoload 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
// spawn 자식 진입 시 활성 디렉토리의 쓰기 권한 디렉토리를 멱등적으로 보장.
|
||||
@@ -90,23 +107,25 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
//
|
||||
// 한계: 부모(이전 버전) 만 알고 있던 신규 디렉토리는 처리 불가 — 그 일회성 케이스는
|
||||
// 해당 release 의 upgrade step 단발 처리. (예: beta.3→beta.4 의 lang-packs/* 보정)
|
||||
try {
|
||||
$writablePaths = (array) config('app.update.restore_ownership_group_writable', []);
|
||||
if (! empty($writablePaths)) {
|
||||
$service->ensureWritableDirectories(
|
||||
$writablePaths,
|
||||
function (string $level, string $msg): void {
|
||||
// 콘솔 + upgrade 로그 채널 동시 출력 — 운영자가 단일 파일(upgrade.log)에서
|
||||
// spawn 자식의 권한 정상화 진행을 추적할 수 있도록 양쪽 모두 누적.
|
||||
$this->{$level === 'warning' ? 'warn' : 'info'}($msg);
|
||||
\Illuminate\Support\Facades\Log::channel('upgrade')->$level('[spawn] '.$msg);
|
||||
},
|
||||
);
|
||||
if (! $stepsOnly) {
|
||||
try {
|
||||
$writablePaths = (array) config('app.update.restore_ownership_group_writable', []);
|
||||
if (! empty($writablePaths)) {
|
||||
$service->ensureWritableDirectories(
|
||||
$writablePaths,
|
||||
function (string $level, string $msg): void {
|
||||
// 콘솔 + upgrade 로그 채널 동시 출력 — 운영자가 단일 파일(upgrade.log)에서
|
||||
// spawn 자식의 권한 정상화 진행을 추적할 수 있도록 양쪽 모두 누적.
|
||||
$this->{$level === 'warning' ? 'warn' : 'info'}($msg);
|
||||
Log::channel('upgrade')->$level('[spawn] '.$msg);
|
||||
},
|
||||
);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
Log::warning('upgrade step spawn 자식: ensureWritableDirectories 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
\Illuminate\Support\Facades\Log::warning('upgrade step spawn 자식: ensureWritableDirectories 호출 실패', [
|
||||
'error' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
// 코어 업데이트 spawn 자식 감지.
|
||||
@@ -130,18 +149,18 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// 이미 동일 단계를 실행했으므로 --skip-migrations / --skip-resync 로 중복 회피.
|
||||
// 운영자 단독 호출 시 옵션 미전달 → 기본값으로 두 단계 자동 수행 →
|
||||
// migration / permission / menu / seeder 누락 차단.
|
||||
if (! $this->option('skip-migrations') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-migrations') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('마이그레이션 실행');
|
||||
$service->runMigrations();
|
||||
} else {
|
||||
$this->info('[spawn] 마이그레이션 스킵 — 부모가 이미 실행');
|
||||
$this->info($stepsOnly ? '[steps-only] 마이그레이션 스킵' : '[spawn] 마이그레이션 스킵 — 부모가 이미 실행');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-resync') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-resync') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('코어 config 재로드 및 권한/메뉴/시더 동기화');
|
||||
$service->reloadCoreConfigAndResync();
|
||||
} else {
|
||||
$this->info('[spawn] resync 스킵 — 부모가 이미 실행');
|
||||
$this->info($stepsOnly ? '[steps-only] resync 스킵' : '[spawn] resync 스킵 — 부모가 이미 실행');
|
||||
}
|
||||
|
||||
$stepsExecuted = 0;
|
||||
@@ -180,6 +199,8 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
'reason' => $e->reason,
|
||||
]);
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return UpgradeHandoffException::EXIT_CODE;
|
||||
} catch (\Throwable $e) {
|
||||
Log::error('core:execute-upgrade-steps 실패', [
|
||||
@@ -189,6 +210,8 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
]);
|
||||
$this->error($e->getMessage());
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
@@ -209,21 +232,25 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
// --skip-version-env / --skip-cache-clear / --skip-bundled-updates 로 중복 회피.
|
||||
// 단독 실행 시엔 옵션 미전달 → 기본값으로 3단계 자동 수행 → gnuboard/g7#34 의 운영자 수동 절차
|
||||
// (sed APP_VERSION + cache:clear + module/plugin/template:update --force --source=bundled) 통합.
|
||||
if (! $this->option('skip-version-env') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-version-env') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info(".env APP_VERSION={$to} 갱신");
|
||||
$service->updateVersionInEnv($to);
|
||||
} else {
|
||||
$this->info('[spawn] .env APP_VERSION 갱신 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] .env APP_VERSION 갱신 스킵' : '[spawn] .env APP_VERSION 갱신 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-cache-clear') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-cache-clear') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('캐시 정리 (config/route/view/services/packages)');
|
||||
$service->clearAllCaches();
|
||||
// 업그레이드 스텝 단독 실행 시에도 코어 lang/routes/layout 변경이
|
||||
// 프론트엔드 캐시 stale 로 가려지지 않도록 `ext.cache_version` bump.
|
||||
// spawn 자식·steps-only 모드에서는 부모가 처리하므로 스킵.
|
||||
$this->incrementExtensionCacheVersion();
|
||||
} else {
|
||||
$this->info('[spawn] 캐시 정리 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] 캐시 정리 스킵' : '[spawn] 캐시 정리 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
if (! $this->option('skip-bundled-updates') && ! $isSpawnChild) {
|
||||
if (! $this->option('skip-bundled-updates') && ! $isSpawnChild && ! $stepsOnly) {
|
||||
$this->info('번들 확장 일괄 업데이트 (모듈/플러그인/템플릿/언어팩)');
|
||||
$this->runBundledExtensionUpdatePrompt(
|
||||
app(ModuleManager::class),
|
||||
@@ -232,9 +259,42 @@ class ExecuteUpgradeStepsCommand extends Command
|
||||
$force,
|
||||
);
|
||||
} else {
|
||||
$this->info('[spawn] 번들 확장 일괄 업데이트 스킵 — 부모가 처리');
|
||||
$this->info($stepsOnly ? '[steps-only] 번들 확장 일괄 업데이트 스킵' : '[spawn] 번들 확장 일괄 업데이트 스킵 — 부모가 처리');
|
||||
}
|
||||
|
||||
$this->restoreUpgradeLogOwnership();
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* spawn 자식이 root 로 만든 upgrade 로그 파일의 소유권을 부모(storage/logs) 로 정합합니다.
|
||||
*
|
||||
* upgrade step 은 sudo 코어 업데이트에서 별도 PHP 프로세스로 spawn 되며(이 커맨드),
|
||||
* root 로 실행되어 `upgrade-YYYY-MM-DD.log`(Log::channel('upgrade')) 를 root 소유로
|
||||
* 만든다. 부모(CoreUpdateCommand) 프로세스는 업데이트 시작 시점의 *이전 버전* 클래스를
|
||||
* 메모리에 들고 있어, 부모 측 로그 정상화 로직이 추가돼 있어도 그 버전엔 없을 수 있다
|
||||
* (클래스 캐싱). 반면 본 spawn 자식은 항상 *신버전* 코드로 실행되므로, upgrade 로그를
|
||||
* 만든 주체인 자식이 자기 종료 직전에 직접 소유권을 정합하면 부모 버전과 무관하게 동작한다.
|
||||
*
|
||||
* 그 결과 이후 www-data(php-fpm) 의 module:update upgrade step 이 같은 날짜 upgrade
|
||||
* 로그에 append 할 수 있다. 본 메서드는 어떤 로그도 쓰지 않는다(쓰면 다시 root 가 됨).
|
||||
* sudo 아닌 환경에서는 silent no-op(멱등).
|
||||
*/
|
||||
private function restoreUpgradeLogOwnership(): void
|
||||
{
|
||||
$logsDir = storage_path('logs');
|
||||
if (! is_dir($logsDir)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 코어('upgrade-*.log') + 확장('extension-upgrade-*.log') 두 채널의 daily 로그를 모두
|
||||
// 정합한다. glob 'upgrade-*.log' 는 'extension-' 접두사 파일을 매칭하지 못하므로
|
||||
// 두 패턴을 각각 순회한다.
|
||||
foreach (['upgrade-*.log', 'extension-upgrade-*.log'] as $pattern) {
|
||||
foreach (glob($logsDir.DIRECTORY_SEPARATOR.$pattern) ?: [] as $logFile) {
|
||||
FilePermissionHelper::inheritOwnershipFromParent($logFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands\Module;
|
||||
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use App\Extension\Traits\GeneratesComponentManifest;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
@@ -11,6 +12,7 @@ use Symfony\Component\Process\Process;
|
||||
class BuildModuleCommand extends Command
|
||||
{
|
||||
use ClearsTemplateCaches;
|
||||
use GeneratesComponentManifest;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@@ -196,6 +198,14 @@ class BuildModuleCommand extends Command
|
||||
// 빌드 결과 파일 확인
|
||||
$this->displayBuildResults($buildPath, $identifier);
|
||||
|
||||
// 편집기 컴포넌트 매니페스트(components.json) 생성
|
||||
$manifestResult = $this->generateComponentManifest($buildPath, $identifier);
|
||||
if ($manifestResult['written']) {
|
||||
$this->line(" - components.json 생성됨 (컴포넌트 {$manifestResult['count']}개)");
|
||||
} else {
|
||||
$this->warn(' - components.json 생성 실패 (편집 모드 컨트롤 노출 제한)');
|
||||
}
|
||||
|
||||
// 캐시 버전 증가 (브라우저 캐시 무효화)
|
||||
$this->incrementExtensionCacheVersion();
|
||||
$this->line(' - 캐시 버전 갱신됨');
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Console\Commands\Module;
|
||||
use App\Console\Commands\Traits\HasProgressBar;
|
||||
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
||||
use App\Contracts\Repositories\ModuleRepositoryInterface;
|
||||
use App\Enums\LayoutSourceType;
|
||||
use App\Extension\ModuleManager;
|
||||
use App\Extension\Vendor\VendorMode;
|
||||
use App\Services\LayoutExtensionService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -36,7 +38,8 @@ class UpdateModuleCommand extends Command
|
||||
*/
|
||||
public function __construct(
|
||||
private ModuleManager $moduleManager,
|
||||
private ModuleRepositoryInterface $moduleRepository
|
||||
private ModuleRepositoryInterface $moduleRepository,
|
||||
private LayoutExtensionService $layoutExtensionService
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -120,6 +123,30 @@ class UpdateModuleCommand extends Command
|
||||
$this->info('업데이트 버전: (module.json 추출 후 판별)');
|
||||
}
|
||||
|
||||
$this->info(__('modules.commands.update.layout_strategy', ['strategy' => $layoutStrategy]));
|
||||
|
||||
// overwrite 전략일 때 관리자가 편집한 레이아웃 확장 경고
|
||||
if ($layoutStrategy === 'overwrite') {
|
||||
$modifiedExtensions = $this->layoutExtensionService->getModifiedExtensionsBySource(
|
||||
LayoutSourceType::Module,
|
||||
$identifier
|
||||
);
|
||||
|
||||
if (! empty($modifiedExtensions)) {
|
||||
$this->newLine();
|
||||
$this->warn('⚠️ '.__('modules.commands.update.modified_extensions_warning', [
|
||||
'count' => count($modifiedExtensions),
|
||||
]));
|
||||
|
||||
foreach ($modifiedExtensions as $extension) {
|
||||
$this->warn(__('modules.commands.update.modified_extension_item', [
|
||||
'target' => $extension['target_name'],
|
||||
'source' => $extension['source_identifier'],
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
|
||||
// 확인 프롬프트 (--force 시 건너뜀)
|
||||
|
||||
@@ -0,0 +1,130 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Enums\ExtensionOwnerType;
|
||||
use App\Models\Permission;
|
||||
use App\Models\Role;
|
||||
use App\Models\User;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
|
||||
/**
|
||||
* Playwright E2E 용 Sanctum 토큰 발급 커맨드.
|
||||
*
|
||||
* 임의 권한 식별자(코어/모듈/플러그인) 를 받아 권한 보유 관리자 유저를 즉시 생성하고
|
||||
* Sanctum 개인 액세스 토큰을 발급한다. 발급된 토큰은 stdout 마지막 줄에 출력되어
|
||||
* Playwright fixture 가 stdin 캡처로 사용한다.
|
||||
*
|
||||
* 보안 가드 (3중):
|
||||
* ① CLI 한정 — `php_sapi_name() === 'cli'` 확인. production 웹 요청에서 절대 도달 불가
|
||||
* ② 명시 옵트인 — `G7_PLAYWRIGHT_BYPASS=1` 환경변수 부여 필수.
|
||||
* `.env` 영구 수정 없이 인라인 환경변수로만 활성화 가능 → 무심코 production 으로 새지 않음
|
||||
* ③ APP_DEBUG 강제 — bypass flag 인지 후 `config('app.debug')` 를 true 로 inline override.
|
||||
* SettingsServiceProvider 의 testing/bypass 분기가 이미 settings JSON 덮어쓰기를 건너뛰므로
|
||||
* production + debug=false 환경에서도 토큰 발급이 가능하다
|
||||
*
|
||||
* 환경 매트릭스:
|
||||
* - local + bypass=1 : 로컬 개발자 PC 에서 직접 spec 작성/실행
|
||||
* - testing + bypass=1 : CI / PHPUnit 환경에서 .env.testing 로 동작하는 E2E 통합 (testing 환경은 이미 testing 가드로 통과)
|
||||
* - production + bypass=1 : production DB 가 활성 호스트를 가리키는 환경(예: g7.dev) 에서 E2E
|
||||
*
|
||||
* 호출 예시 (PowerShell):
|
||||
* $env:G7_PLAYWRIGHT_BYPASS='1'; php artisan playwright:issue-token --permissions=core.templates.layouts.edit
|
||||
*
|
||||
* 로직 출처: tests/Feature/Api/Admin/LayoutAccessCheckEndpointTest::makeAdminUser (44~87행)
|
||||
*/
|
||||
class PlaywrightIssueToken extends Command
|
||||
{
|
||||
protected $signature = 'playwright:issue-token
|
||||
{--permissions=* : 부여할 권한 식별자 (예: core.templates.layouts.edit). 다중 지정 가능}';
|
||||
|
||||
protected $description = 'Playwright E2E 용 Sanctum 토큰 발급 (CLI + G7_PLAYWRIGHT_BYPASS 3중 가드)';
|
||||
|
||||
public function handle(): int
|
||||
{
|
||||
// ① CLI 한정 — production 웹 요청에서 절대 도달 불가
|
||||
if (php_sapi_name() !== 'cli') {
|
||||
$this->error('CLI 전용 커맨드입니다. (현재 SAPI: '.php_sapi_name().')');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
// ② 명시 옵트인 — 환경변수 없이는 production 호출 실수 차단
|
||||
if (env('G7_PLAYWRIGHT_BYPASS') !== '1') {
|
||||
$this->error('G7_PLAYWRIGHT_BYPASS=1 환경변수가 필요합니다. (예: PowerShell — $env:G7_PLAYWRIGHT_BYPASS=\'1\')');
|
||||
|
||||
return self::FAILURE;
|
||||
}
|
||||
|
||||
// ③ APP_DEBUG 강제 — production + debug=false 환경에서도 sanctum 토큰 발급 + 디버그 정보 누락 방지.
|
||||
// SettingsServiceProvider::applyDebugConfig 는 bypass flag 가 있으면 settings JSON 덮어쓰기를 이미 건너뛴 상태.
|
||||
Config::set('app.debug', true);
|
||||
|
||||
$permissions = $this->option('permissions') ?: [];
|
||||
|
||||
$user = $this->makeAdminUser($permissions);
|
||||
$token = $user->createToken('playwright-'.uniqid())->plainTextToken;
|
||||
|
||||
$this->line($token);
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* 권한 식별자 배열로 관리자 유저를 생성하고 권한을 부여한다.
|
||||
*
|
||||
* 절차:
|
||||
* 1. User factory 로 신규 유저 생성
|
||||
* 2. 권한 식별자별로 Permission 행 보장 (firstOrCreate)
|
||||
* 3. uniqid 접미사로 격리된 test role 생성 + 권한 sync
|
||||
* 4. admin role 보장 (firstOrCreate) + 유저-역할 부여
|
||||
*/
|
||||
private function makeAdminUser(array $permissions): User
|
||||
{
|
||||
$user = User::factory()->create();
|
||||
|
||||
$permissionIds = [];
|
||||
foreach ($permissions as $identifier) {
|
||||
$permission = Permission::firstOrCreate(
|
||||
['identifier' => $identifier],
|
||||
[
|
||||
'name' => json_encode(['ko' => $identifier, 'en' => $identifier]),
|
||||
'description' => json_encode(['ko' => $identifier, 'en' => $identifier]),
|
||||
'extension_type' => ExtensionOwnerType::Core,
|
||||
'extension_identifier' => 'core',
|
||||
'type' => 'admin',
|
||||
]
|
||||
);
|
||||
$permissionIds[] = $permission->id;
|
||||
}
|
||||
|
||||
$testRole = Role::create([
|
||||
'identifier' => 'playwright_test_'.uniqid(),
|
||||
'name' => json_encode(['ko' => 'Playwright 테스트 관리자', 'en' => 'Playwright Test Admin']),
|
||||
'description' => json_encode(['ko' => 'E2E 자동화 전용', 'en' => 'E2E automation only']),
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$adminRole = Role::firstOrCreate(
|
||||
['identifier' => 'admin'],
|
||||
[
|
||||
'name' => json_encode(['ko' => '관리자', 'en' => 'Admin']),
|
||||
'description' => json_encode(['ko' => '시스템 관리자', 'en' => 'System Admin']),
|
||||
'extension_type' => ExtensionOwnerType::Core,
|
||||
'extension_identifier' => 'core',
|
||||
'type' => 'admin',
|
||||
'is_active' => true,
|
||||
]
|
||||
);
|
||||
|
||||
if (! empty($permissionIds)) {
|
||||
$testRole->permissions()->sync($permissionIds);
|
||||
}
|
||||
|
||||
$user->roles()->attach($adminRole->id, ['assigned_at' => now(), 'assigned_by' => null]);
|
||||
$user->roles()->attach($testRole->id, ['assigned_at' => now(), 'assigned_by' => null]);
|
||||
|
||||
return $user->fresh();
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ namespace App\Console\Commands\Plugin;
|
||||
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\Traits\ClearsTemplateCaches;
|
||||
use App\Extension\Traits\GeneratesComponentManifest;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Symfony\Component\Process\Process;
|
||||
@@ -11,6 +12,7 @@ use Symfony\Component\Process\Process;
|
||||
class BuildPluginCommand extends Command
|
||||
{
|
||||
use ClearsTemplateCaches;
|
||||
use GeneratesComponentManifest;
|
||||
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
@@ -196,6 +198,14 @@ class BuildPluginCommand extends Command
|
||||
// 빌드 결과 파일 확인
|
||||
$this->displayBuildResults($buildPath, $identifier);
|
||||
|
||||
// 편집기 컴포넌트 매니페스트(components.json) 생성
|
||||
$manifestResult = $this->generateComponentManifest($buildPath, $identifier);
|
||||
if ($manifestResult['written']) {
|
||||
$this->line(" - components.json 생성됨 (컴포넌트 {$manifestResult['count']}개)");
|
||||
} else {
|
||||
$this->warn(' - components.json 생성 실패 (편집 모드 컨트롤 노출 제한)');
|
||||
}
|
||||
|
||||
// 캐시 버전 증가 (브라우저 캐시 무효화)
|
||||
$this->incrementExtensionCacheVersion();
|
||||
$this->line(' - 캐시 버전 갱신됨');
|
||||
|
||||
@@ -5,8 +5,10 @@ namespace App\Console\Commands\Plugin;
|
||||
use App\Console\Commands\Traits\HasProgressBar;
|
||||
use App\Console\Commands\Traits\HasUnifiedConfirm;
|
||||
use App\Contracts\Repositories\PluginRepositoryInterface;
|
||||
use App\Enums\LayoutSourceType;
|
||||
use App\Extension\PluginManager;
|
||||
use App\Extension\Vendor\VendorMode;
|
||||
use App\Services\LayoutExtensionService;
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
|
||||
@@ -36,7 +38,8 @@ class UpdatePluginCommand extends Command
|
||||
*/
|
||||
public function __construct(
|
||||
private PluginManager $pluginManager,
|
||||
private PluginRepositoryInterface $pluginRepository
|
||||
private PluginRepositoryInterface $pluginRepository,
|
||||
private LayoutExtensionService $layoutExtensionService
|
||||
) {
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -119,6 +122,30 @@ class UpdatePluginCommand extends Command
|
||||
$this->info('업데이트 버전: (plugin.json 추출 후 판별)');
|
||||
}
|
||||
|
||||
$this->info(__('plugins.commands.update.layout_strategy', ['strategy' => $layoutStrategy]));
|
||||
|
||||
// overwrite 전략일 때 관리자가 편집한 레이아웃 확장 경고
|
||||
if ($layoutStrategy === 'overwrite') {
|
||||
$modifiedExtensions = $this->layoutExtensionService->getModifiedExtensionsBySource(
|
||||
LayoutSourceType::Plugin,
|
||||
$identifier
|
||||
);
|
||||
|
||||
if (! empty($modifiedExtensions)) {
|
||||
$this->newLine();
|
||||
$this->warn('⚠️ '.__('plugins.commands.update.modified_extensions_warning', [
|
||||
'count' => count($modifiedExtensions),
|
||||
]));
|
||||
|
||||
foreach ($modifiedExtensions as $extension) {
|
||||
$this->warn(__('plugins.commands.update.modified_extension_item', [
|
||||
'target' => $extension['target_name'],
|
||||
'source' => $extension['source_identifier'],
|
||||
]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->newLine();
|
||||
|
||||
// 확인 프롬프트 (--force 시 건너뜀)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Contracts\Repositories\LayoutVersionRepositoryInterface;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
/**
|
||||
* 레이아웃 버전의 변경 요약(changes_summary)을 현재 알고리즘으로 재계산하는 커맨드
|
||||
*
|
||||
* 버전 변경량 측정이 키 경로 단위에서 라인 단위(버전 비교 diff 뷰와 동일 SSoT)로
|
||||
* 바뀌기 전에 저장된 버전들은 옛 기준의 changes_summary 를 담고 있어, 버전 목록의
|
||||
* 변경량이 상세 diff 와 불일치한다. 본 커맨드로 기존 버전을 일괄 재계산해 정합시킨다.
|
||||
*/
|
||||
class RecalculateLayoutVersionDiffsCommand extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*/
|
||||
protected $signature = 'layout-versions:recalculate-diffs';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*/
|
||||
protected $description = '레이아웃 버전의 변경 요약을 현재 라인 단위 알고리즘으로 재계산합니다';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @param LayoutVersionRepositoryInterface $repository 버전 저장소
|
||||
* @return int 명령 실행 결과 코드
|
||||
*/
|
||||
public function handle(LayoutVersionRepositoryInterface $repository): int
|
||||
{
|
||||
$this->info('레이아웃 버전 변경 요약 재계산을 시작합니다...');
|
||||
|
||||
$updated = $repository->recalculateAllChangeSummaries();
|
||||
|
||||
$this->info("버전 {$updated}건의 변경 요약을 재계산했습니다.");
|
||||
|
||||
return self::SUCCESS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user