Skip to content

Commit

Permalink
Provide some status output for the developer setup.
Browse files Browse the repository at this point in the history
  • Loading branch information
ralflang committed Jan 12, 2024
1 parent c4044fc commit af6882e
Show file tree
Hide file tree
Showing 8 changed files with 239 additions and 6 deletions.
3 changes: 3 additions & 0 deletions config/conf.php.dist
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions doc/UPGRADE_COMPONENT_H6.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ cd /srv/git/$component
## TODO: Edit .horde.yml require: versions to +1.0.0alpha1
/srv/www/horde/web/components/bin/horde-components composer
## This breaks for pear/pear!
sed -i 's/pear:/composer:/g' .horde.yml
sed -i 's|pear.horde.org/Horde_|horde/|g' .horde.yml
sed -i 's|php: .*|php: ^7|g' .horde.yml
sed -i 's/pear:/composer:/g' .horde.yml
sed -i 's|pear.horde.org/Horde_|horde/|g' .horde.yml
sed -i 's|php: .*|php: ^7|g' .horde.yml
## visually check for differences
#exit;
## If all is green, run release

/srv/www/horde/web/components/bin/horde-components /srv/git/$component release for h6-maintaina
/srv/www/horde/web/components/bin/horde-components /srv/git/horde/$component release for h6-maintaina

Empty file removed src/Application/Application.php
Empty file.
2 changes: 2 additions & 0 deletions src/Cli/ModuleProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Horde\Components\Module\Change;
use Horde\Components\Module\Package;
use Horde\Components\Module\Release;
use Horde\Components\Module\Status;

/**
* Components tool specific, context aware module provider
Expand Down Expand Up @@ -49,6 +50,7 @@ public function getModules(): Modules
$this->injector->get(Help::class),
$this->injector->get(Package::class),
$this->injector->get(Release::class),
$this->injector->get(Status::class),
]);
}
}
134 changes: 134 additions & 0 deletions src/Module/Status.php
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;
}
}
2 changes: 1 addition & 1 deletion src/Runner/Git.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(
$options = $this->config->getOptions();
$this->gitRepoBase = $options['git_repo_base'] ??
'https:/horde/';
$this->localCheckoutDir = $options['checkout_dir'] ?? '/srv/git/';
$this->localCheckoutDir = $options['checkout_dir'] ?? '/srv/git/horde';
}

public function run()
Expand Down
2 changes: 1 addition & 1 deletion src/Runner/Github.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function __construct(
$options = $this->config->getOptions();
$this->gitRepoBase = $options['git_repo_base'] ??
'https:/horde/';
$this->localCheckoutDir = $options['checkout_dir'] ?? '/srv/git/';
$this->localCheckoutDir = $options['checkout_dir'] ?? '/srv/git/horde';
}

public function run()
Expand Down
94 changes: 94 additions & 0 deletions src/Runner/Status.php
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");
};
}
}

0 comments on commit af6882e

Please sign in to comment.