-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Provide some status output for the developer setup.
- Loading branch information
Showing
8 changed files
with
239 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,6 +31,9 @@ $conf['from'] = 'Full name <[email protected]>'; | |
/* Path to a checkout of the horde-web repository. */ | ||
$conf['web_dir'] = '/var/www/horde-web'; | ||
|
||
// Target directory for a developer installation. The webroot will be the ./web dir under that install dir | ||
$conf['install_base'] = '/var/www/horde-dev'; | ||
|
||
/** | ||
* Vendor: Used by the composer, packagist, satis and git-related tasks | ||
* Defaults to 'horde' if unset | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
<?php | ||
/** | ||
* Components_Module_Change:: records a change log entry. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Horde | ||
* @package Components | ||
* @author Gunnar Wrobel <[email protected]> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
|
||
namespace Horde\Components\Module; | ||
|
||
use Horde\Components\Config; | ||
use Horde\Components\Dependencies; | ||
use Horde\Components\Component\ComponentDirectory; | ||
use Horde\Components\RuntimeContext\CurrentWorkingDirectory; | ||
use Horde\Components\Runner\Status as RunnerStatus; | ||
|
||
/** | ||
* Components_Module_Change:: records a change log entry. | ||
* | ||
* Copyright 2011-2020 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file LICENSE for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @package Components | ||
* @author Gunnar Wrobel <[email protected]> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
class Status extends Base | ||
{ | ||
public function __construct(Dependencies $dependencies) | ||
{ | ||
parent::__construct($dependencies); | ||
} | ||
|
||
|
||
public function getOptionGroupTitle(): string | ||
{ | ||
return 'status'; | ||
} | ||
|
||
public function getOptionGroupDescription(): string | ||
{ | ||
return 'This module prints out status'; | ||
} | ||
|
||
public function getOptionGroupOptions(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Get the usage title for this module. | ||
* | ||
* @return string The title. | ||
*/ | ||
public function getTitle(): string | ||
{ | ||
return 'status'; | ||
} | ||
|
||
/** | ||
* Get the usage description for this module. | ||
* | ||
* @return string The description. | ||
*/ | ||
public function getUsage(): string | ||
{ | ||
return 'Show status'; | ||
} | ||
|
||
/** | ||
* Return the action arguments supported by this module. | ||
* | ||
* @return array A list of supported action arguments. | ||
*/ | ||
public function getActions(): array | ||
{ | ||
return ['changed']; | ||
} | ||
|
||
/** | ||
* Return the help text for the specified action. | ||
* | ||
* @param string $action The action. | ||
* | ||
* @return string The help text. | ||
*/ | ||
public function getHelp($action): string | ||
{ | ||
return 'horde-components status'; | ||
} | ||
|
||
/** | ||
* Return the options that should be explained in the context help. | ||
* | ||
* @return array A list of option help texts. | ||
*/ | ||
public function getContextOptionHelp(): array | ||
{ | ||
return []; | ||
} | ||
|
||
/** | ||
* Determine if this module should act. Run all required actions if it has | ||
* been instructed to do so. | ||
* | ||
* @param Config $config The configuration. | ||
* | ||
* @return bool True if the module performed some action. | ||
*/ | ||
public function handle(Config $config): bool | ||
{ | ||
$options = $config->getOptions(); | ||
$arguments = $config->getArguments(); | ||
|
||
if (!empty($options['status']) || | ||
(isset($arguments[0]) && $arguments[0] == 'status')) { | ||
$componentDirectory = new ComponentDirectory($options['working_dir'] ?? new CurrentWorkingDirectory); | ||
$component = $this->dependencies | ||
->getComponentFactory() | ||
->createSource($componentDirectory); | ||
$config->setComponent($component); | ||
$this->dependencies->get(RunnerStatus::class)->run($config); | ||
return true; | ||
} | ||
return false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
<?php | ||
/** | ||
* Horde\Components\Runner\Status:: runner for status output. | ||
* | ||
* PHP Version 7 | ||
* | ||
* @category Horde | ||
* @package Components | ||
* @author Ralf Lang <[email protected]> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
|
||
namespace Horde\Components\Runner; | ||
|
||
use Horde\Components\Config; | ||
use Horde\Components\Exception; | ||
use Horde\Components\Helper\Git as GitHelper; | ||
use Horde\Components\Output; | ||
|
||
/** | ||
* Horde\Components\Runner\Status:: runner for status output. | ||
* | ||
* Copyright 2020-2021 Horde LLC (http://www.horde.org/) | ||
* | ||
* See the enclosed file LICENSE for license information (LGPL). If you | ||
* did not receive this file, see http://www.horde.org/licenses/lgpl21. | ||
* | ||
* @category Horde | ||
* @package Components | ||
* @author Ralf Lang <[email protected]> | ||
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1 | ||
*/ | ||
class Status | ||
{ | ||
/** | ||
* The repo base url. | ||
*/ | ||
private readonly string $gitRepoBase; | ||
|
||
/** | ||
* Where do we store local checkouts. | ||
*/ | ||
private readonly string $localCheckoutDir; | ||
|
||
/** | ||
* Constructor. | ||
* | ||
* @param Config $config The configuration for the current job. | ||
* @param Output $output The output handler. | ||
* @param GitHelper $git The output handler. | ||
*/ | ||
public function __construct( | ||
private readonly Config $config, | ||
private readonly Output $output, | ||
private GitHelper $gitHelper | ||
) { | ||
// $this->gitHelper = $git; | ||
$options = $this->config->getOptions(); | ||
$this->gitRepoBase = $options['git_repo_base'] ?? | ||
'https:/horde/'; | ||
$this->localCheckoutDir = $options['checkout_dir'] ?? '/srv/git/horde'; | ||
} | ||
|
||
public function run() | ||
{ | ||
$arguments = $this->config->getArguments(); | ||
$this->output->plain("horde-components status -- minding any CLI switches, current working directory and config file content"); | ||
$configFilePath = $this->config->getOptions()['config']; | ||
$this->output->info("Config file path: $configFilePath"); | ||
if (is_readable($configFilePath)) { | ||
$this->output->ok("Config file exists and is readable."); | ||
} else { | ||
$this->output->warn("Config file does not exist or is not readable."); | ||
}; | ||
$this->output->info("Git Tree root path: $this->localCheckoutDir"); | ||
if (is_readable($this->localCheckoutDir)) { | ||
$componentsCount = count(glob($this->localCheckoutDir . '/*', GLOB_ONLYDIR)); | ||
$this->output->ok("Git Tree dir exists and has $componentsCount repos checked out"); | ||
} else { | ||
$this->output->warn("Git Tree dir does not exist or is not readable."); | ||
}; | ||
$installDir = $this->config->getOptions()['install_base']; | ||
$this->output->info("Install Base path: $installDir"); | ||
if (is_readable($installDir)) { | ||
$this->output->ok("Install dir exists."); | ||
if (is_readable($installDir . '/composer.json')) { | ||
$this->output->ok("Root composer.json file exists."); | ||
} | ||
} else { | ||
$this->output->warn("Install dir does not exist or is not readable."); | ||
$this->output->help("Run: \ncomposer create-project horde/bundle $installDir"); | ||
}; | ||
} | ||
} |