2026-04-13 06:12:04 +00:00
|
|
|
#!/usr/bin/env php
|
|
|
|
|
<?php
|
2026-05-24 17:07:51 -05:00
|
|
|
|
2026-04-13 06:12:04 +00:00
|
|
|
/* 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.Validate
|
|
|
|
|
* 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: /validate/check_dolibarr_module.php
|
2026-04-13 06:12:04 +00:00
|
|
|
* BRIEF: Validates Dolibarr module directory structure
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
2026-05-31 12:14:34 -05:00
|
|
|
require_once __DIR__ . '/../vendor/autoload.php';
|
2026-04-13 06:12:04 +00:00
|
|
|
|
2026-06-06 08:58:52 -05:00
|
|
|
use MokoEnterprise\{CliFramework, SourceResolver};
|
2026-04-13 06:12:04 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Validates the required directory structure of a Dolibarr module repository.
|
|
|
|
|
*/
|
|
|
|
|
class CheckDolibarrModule extends CliFramework
|
|
|
|
|
{
|
2026-05-24 17:07:51 -05:00
|
|
|
/**
|
|
|
|
|
* Configure available arguments.
|
|
|
|
|
*/
|
|
|
|
|
protected function configure(): void
|
|
|
|
|
{
|
|
|
|
|
$this->setDescription('Validates Dolibarr module directory structure');
|
|
|
|
|
$this->addArgument('--path', 'Repository path to check', '.');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Run the Dolibarr module validation.
|
|
|
|
|
*
|
|
|
|
|
* @return int Exit code: 0 on pass, 1 on failure.
|
|
|
|
|
*/
|
|
|
|
|
protected function run(): int
|
|
|
|
|
{
|
|
|
|
|
$path = $this->getArgument('--path');
|
|
|
|
|
$passed = 0;
|
|
|
|
|
$failed = 0;
|
|
|
|
|
|
|
|
|
|
$this->section('Checking directory structure');
|
2026-06-06 08:58:52 -05:00
|
|
|
$srcName = SourceResolver::resolve($path);
|
|
|
|
|
SourceResolver::warnIfLegacy($path);
|
2026-05-24 17:07:51 -05:00
|
|
|
|
2026-06-06 08:58:52 -05:00
|
|
|
$srcDir = SourceResolver::resolveAbsolute($path);
|
|
|
|
|
if ($srcDir === null) {
|
|
|
|
|
$this->status(false, 'source/ or src/ directory exists');
|
2026-05-24 17:07:51 -05:00
|
|
|
$failed++;
|
|
|
|
|
} else {
|
2026-06-06 08:58:52 -05:00
|
|
|
$this->status(true, "{$srcName}/ directory exists");
|
2026-05-24 17:07:51 -05:00
|
|
|
$passed++;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-06 08:58:52 -05:00
|
|
|
if (!is_dir($path . "/{$srcName}/core/modules")) {
|
|
|
|
|
$this->status(false, "{$srcName}/core/modules/ directory exists");
|
2026-05-24 17:07:51 -05:00
|
|
|
$failed++;
|
|
|
|
|
} else {
|
2026-06-06 08:58:52 -05:00
|
|
|
$this->status(true, "{$srcName}/core/modules/ directory exists");
|
2026-05-24 17:07:51 -05:00
|
|
|
$passed++;
|
|
|
|
|
}
|
|
|
|
|
|
2026-06-06 08:58:52 -05:00
|
|
|
if (!is_dir($path . "/{$srcName}/langs")) {
|
|
|
|
|
$this->warning("Missing suggested directory: {$srcName}/langs/");
|
2026-05-24 17:07:51 -05:00
|
|
|
} else {
|
2026-06-06 08:58:52 -05:00
|
|
|
$this->status(true, "{$srcName}/langs/ directory exists");
|
2026-05-24 17:07:51 -05:00
|
|
|
$passed++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->section('Checking module descriptor');
|
|
|
|
|
|
2026-06-06 08:58:52 -05:00
|
|
|
$descriptors = glob($path . "/{$srcName}/core/modules/mod*.class.php") ?: [];
|
2026-05-24 17:07:51 -05:00
|
|
|
if (empty($descriptors)) {
|
|
|
|
|
$this->status(false, 'Module descriptor found (mod*.class.php)');
|
|
|
|
|
$failed++;
|
|
|
|
|
} else {
|
|
|
|
|
$this->status(true, 'Module descriptor found', basename($descriptors[0]));
|
|
|
|
|
$passed++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$this->printSummary($passed, $failed, $this->elapsed());
|
|
|
|
|
|
|
|
|
|
if ($failed > 0) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2026-04-13 06:12:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$script = new CheckDolibarrModule('check_dolibarr_module', 'Validates Dolibarr module directory structure');
|
|
|
|
|
exit($script->execute());
|