2026-04-13 06:12:04 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
|
|
|
|
/* Copyright (C) 2026 Moko Consulting <hello@mokoconsulting.tech>
|
|
|
|
|
*
|
|
|
|
|
* This file is part of a Moko Consulting project.
|
|
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
|
*
|
|
|
|
|
* FILE INFORMATION
|
2026-05-31 12:14:34 -05:00
|
|
|
* DEFGROUP: MokoPlatform.Scripts.Fix
|
|
|
|
|
* INGROUP: MokoPlatform
|
2026-05-11 17:01:17 -05:00
|
|
|
* REPO: https://git.mokoconsulting.tech/MokoConsulting/moko-platform
|
2026-04-15 02:35:30 +00:00
|
|
|
* PATH: /fix/fix_permissions.php
|
2026-05-31 12:14:34 -05:00
|
|
|
* BRIEF: CLI script to normalise file permissions (dirs 755, files 644, scripts 755)
|
2026-04-13 06:12:04 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
|
|
|
|
require_once __DIR__ . '/../lib/Enterprise/CliFramework.php';
|
2026-04-13 06:12:04 +00:00
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
use MokoEnterprise\CliFramework;
|
2026-04-13 06:12:04 +00:00
|
|
|
use MokoEnterprise\FileFixUtility;
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
class FixPermissions extends CliFramework
|
2026-04-13 06:12:04 +00:00
|
|
|
{
|
2026-05-31 12:14:34 -05:00
|
|
|
protected function configure(): void
|
|
|
|
|
{
|
|
|
|
|
$this->setDescription('Normalise file permissions (dirs 755, files 644, scripts 755)');
|
|
|
|
|
$this->addArgument('--path', 'Repository root (default: current directory)', '.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function run(): int
|
|
|
|
|
{
|
|
|
|
|
$path = (string) $this->getArgument('--path');
|
|
|
|
|
|
|
|
|
|
if ($this->dryRun) {
|
|
|
|
|
$this->log('WARNING', 'Would fix permissions (dirs 755, files 644, scripts 755)');
|
|
|
|
|
return self::EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileFixUtility::fixPermissions($path, $this->dryRun);
|
|
|
|
|
$this->log('SUCCESS', 'Permissions fixed');
|
|
|
|
|
return self::EXIT_SUCCESS;
|
|
|
|
|
}
|
2026-04-13 06:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
$app = new FixPermissions();
|
|
|
|
|
exit($app->execute());
|