Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: decouple composer installation from pear #3

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions .horde.yml
Expand Up @@ -55,3 +55,10 @@ dependencies:
pear.phpunit.de/phpdcd: '*'
pear.phpunit.de/phploc: '*'
pear.phpmd.org/PHP_PMD: '*'
autoload:
psr-0:
Components: 'lib/'
psr-4:
'Horde\Components\': 'src/'
nocommands:
- 'bin/horde-bootstrap'
16 changes: 15 additions & 1 deletion bin/horde-components
Expand Up @@ -11,6 +11,20 @@ if (defined('E_DEPRECATED')) {
} else {
error_reporting(E_ALL & ~E_STRICT);
}
// horde-components standalone run in composer setups
$autoloaders = [
__DIR__ . '/../config/autoload.php', // custom autoload config
__DIR__ . '/../vendor/autoload.php', // components is root app
__DIR__ . '/../../../vendor/autoload.php', // components is installed in a horde-deployment
// handle "git developer install" and pear cases
'Horde/Autoloader/Default.php'
];

require_once 'Horde/Autoloader/Default.php';
foreach ($autoloaders as $autoloader) {
if (file_exists($autoloader)) {
require_once $autoloader;
break;
}
}
// in case of calling components via git-tools, this file plays no role
Components::main();
61 changes: 38 additions & 23 deletions composer.json
@@ -1,7 +1,7 @@
{
"name": "horde/components",
"description": "Developer tool for managing Horde components",
"type": "project",
"type": "horde-application",
"homepage": "https://www.horde.org",
"license": "LGPL-2.1",
"authors": [
Expand All @@ -17,30 +17,43 @@
}
],
"version": "1.0.0",
"time": "2020-03-15",
"time": "2020-10-15",
"repositories": [
{
"type": "pear",
"url": "https://pear.horde.org"
"type": "composer",
"url": "https://horde-satis.maintaina.com"
},
{
"url": "https://pear.php.net",
"type": "pear"
},
{
"url": "https://pear.phpunit.de",
"type": "pear"
},
{
"url": "https://pear.phpmd.org",
"type": "pear"
}
],
"require": {
"horde/horde-installer-plugin": "dev-master",
"php": "^5.4 || ^7",
"pear-pear.horde.org/Horde_Autoloader": "*",
"pear-pear.horde.org/Horde_Argv": "*",
"pear-pear.horde.org/Horde_Cli": "^2.3",
"pear-pear.horde.org/Horde_Cli_Modular": "^2.1",
"pear-pear.horde.org/Horde_Http": "*",
"pear-pear.horde.org/Horde_Pear": "*",
"pear-pear.horde.org/Horde_Role": "*",
"pear-pear.horde.org/Horde_Text_Diff": "*",
"pear-pear.horde.org/Horde_Util": "*",
"pear-pear.horde.org/Horde_Injector": "*",
"pear-pear.horde.org/Horde_Release": "*",
"pear-pear.horde.org/Horde_Yaml": "*"
"horde/autoloader": "dev-master",
"horde/argv": "dev-master",
"horde/cli": "dev-master",
"horde/cli_modular": "dev-master",
"horde/http": "dev-master",
"horde/pear": "dev-master",
"horde/role": "dev-master",
"horde/text_diff": "dev-master",
"horde/util": "dev-master",
"horde/injector": "dev-master",
"horde/release": "dev-master",
"horde/yaml": "dev-master"
},
"suggest": {
"pear-pear.horde.org/Horde_Test": "*",
"horde/test": "*",
"pear-pear.php.net/Archive_Tar": "*",

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could/should use pear/archive_tar instead of pear-pear.php.net/Archive_Tar.

This uses the much quicker installation as composer package AND will also work, if pear.php.net is down, as it is currently.

Ralf

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right. The current composer.json generator does not yet handle third party requirements. It's on the list ;)

"pear-pear.php.net/PHP_CodeSniffer": "*",
"pear-pear.phpunit.de/PHPUnit": "*",
Expand All @@ -49,13 +62,15 @@
"pear-pear.phpunit.de/phploc": "*",
"pear-pear.phpmd.org/PHP_PMD": "*"
},
"replace": {
"pear-pear.horde.org/components": "1.*",
"pear-horde/components": "1.*"
},
"autoload": {
"psr-0": {
"Components": "lib/"
},
"psr-4": {
"Horde\\Components\\": "src/"
}
}
}
},
"bin": [
"bin/horde-components"
]
}
179 changes: 179 additions & 0 deletions config/conf.php.dist
Expand Up @@ -8,6 +8,8 @@
* Strings should be enclosed in 'quotes'.
* Integers should be given literally (without quotes).
* Boolean values may be true or false (never quotes).
*
* PHP Version 5
*/

/* PEAR server name. Only change for testing purposes. */
Expand All @@ -28,3 +30,180 @@ $conf['from'] = 'Full name <user@horde.org>';

/* Path to a checkout of the horde-web repository. */
$conf['web_dir'] = '/var/www/horde-web';

/**
* Vendor: Used by the composer, packagist, satis and git-related tasks
* Defaults to 'horde' if unset
*/
// $conf['vendor'] = 'horde';

/**
* Git Repo Base: The base URL for your remote git repo
* Defaults to https://github.com/$vendor if unset
* If you configure this, $vendor will NOT be appended
*/
//$conf['git_repo_base'] = 'https://git.mycompany.com/level/nextlevel/';

/** composer_repo - Type of loader hints to generate
* Default is not to generate any hints. Dependencies will be from packagist
*/
// generate a vcs repo source per horde internal dependency
// $conf['composer_repo'] = 'vcs';
// generate a satis source for all horde namespace
// $conf['composer_repo'] = 'satis:https://satis.horde.org';

/**
* composer_version - tweak all dependency versions
* to a common branch name or version
* This is used by the horde-components composer command and
* the composer release task unless overwritten there
*
* Default: Depend on versions from .horde.yml
*/
// depend on master branch
// $conf['composer_version'] = 'dev-master';
// depend on a staging branch - components won't check if it even exists!
// $conf['composer_version'] = 'dev-staging';


/* Well known composer native substitutes for pear dependencies */
$conf['composer_opts']['pear-substitutes'] = [
['pear.php.net/Archive_Tar' =>
['source' => 'Packagist', 'name' => 'pear/archive_tar']],
['pear.php.net/Console_Color2' =>
['source' => 'Packagist', 'name' => 'pear/console_color2']],
['pear.php.net/Console_Table' =>
['source' => 'Packagist', 'name' => 'pear/table']],
['pear.php.net/PHP_CodeSniffer' =>
['source' => 'Packagist', 'name' => 'squizlabs/php_codesniffer']],
['pear.phpunit.de/phpcpd' => ['source' => 'Packagist', 'name' => 'sebastian/phpcpd']],
['pear.phpunit.de/phpdcd' => ['source' => 'Packagist', 'name' => 'sebastian/phpdcd']],
['pear.phpunit.de/phploc' => ['source' => 'Packagist', 'name' => 'phploc/phploc']]
];

/**
* Configure release pipelines
*/

/**
* Upstream pipeline
*
* Usage: horde-components path/to/component release for upstream
*
* The upstream pipeline is similar to the original pipeline
*
* Added Steps:
* - checkout of the correct branch, prevent accidental release from master
* - writing an updated composer file
* - Pushing to github
* - Notifying to Packagist
*
* Removed Steps:
* - None
*
*/
$conf['pipeline']['release']['upstream'] = [
// Checkout the FRAMEWORK_5_2 branch, don't accidentally release master
['name' => 'GitBranch', 'options' => [
'git_branch' => 'FRAMEWORK_5_2',
'git_branch_prereq' => false
]
],
['name' => 'Unit'],
['name' => 'Changelog'],
['name' => 'Timestamp'],
['name' => 'CurrentSentinel'],
// By default, upload to Pirum server after generating
['name' => 'Package', 'options' => ['upload' => 'true']],

// The composer task will use global options like composer_opts,
// composer_version, composer_repo unless explicitly overwritten here
['name' => 'Composer'],
['name' => 'CommitPreRelease'],
['name' => 'TagRelease'],
['name' => 'Announce'],
['name' => 'Website'],
['name' => 'Bugs'],
['name' => 'NextVersion'],
['name' => 'CommitPostRelease'],
['name' => 'GitPush'],
// Nudge Packagist that we have an update
// Requires API key. Does not work for new packages not yet registered.
['name' => 'Packagist', 'options' => [
'packagist_api_key' => '',
'packagist_user' => 'horde',
'vendor' => 'horde'
]
]
// Optional: A local Satis installation satis.horde.org
// satis_bin: path to satis cli
// satis_json: path to satis json file
// satis_outdir: path where satis should write the repository
// satis_push: If the output dir is a git checkout, try to commit and push?
/* ['name' => 'Satis', 'options' => [
'satis_bin' => '',
'satis_json' => '',
'satis_outdir' => '',
'satis_push' => true
]
]*/
];

/**
* Downstream pipeline
*
* Usage: horde-components path/to/component release for downstream
*
* The downstream pipeline is for developing horde based code in your own lab
*
* Added Steps:
* - checkout of the correct branch, prevent accidental release from master
* - writing an updated composer file
* - Pushing to github
* - Writing to a satis repository
*
* Removed Steps:
* - Package/Upload (Pear)
* - Announce
* - Website
* - Bugs
*
*/
$conf['pipeline']['release']['downstream'] = [
// Ensure we create release from the staging branch. Break if not.
['name' => 'GitBranch', 'options' => [
'git_branch' => 'staging',
'git_branch_prereq' => true
]
],
['name' => 'Unit'],
['name' => 'Changelog'],
['name' => 'Timestamp'],
['name' => 'CurrentSentinel'],
// Pear related steps have been removed
// The composer task will use global options like composer_opts,
// composer_version, composer_repo unless explicitly overwritten here
['name' => 'Composer', 'options' => ['composer_version' => '' ] ],
['name' => 'CommitPreRelease'],
['name' => 'TagRelease'],
// Increase version numbers for development mode
['name' => 'NextVersion'],
// Force our component to require staging branch dependencies
// This is useful for development mode
['name' => 'Composer', 'options' => ['composer_version' => 'dev-staging' ]],
['name' => 'CommitPostRelease'],
['name' => 'GitPush'],
// Our downstream pipeline uses satis rather than packagist
// satis_bin: path to satis cli
// satis_json: path to satis json file
// satis_outdir: path where satis should write the repository
// satis_push: If the output dir is a git checkout, try to commit and push?
['name' => 'Satis', 'options' => [
'satis_bin' => '',
'satis_json' => '',
'satis_outdir' => '',
'satis_push' => true
]
]
// TODO: Missing a step to update the release branch from the latest tag
];
23 changes: 13 additions & 10 deletions lib/Components/Component/Identify.php
Expand Up @@ -136,23 +136,26 @@ private function _determineComponent($arguments)
return array($result, '');
}
}

throw new Components_Exception(
sprintf(Components::ERROR_NO_ACTION_OR_COMPONENT, $arguments[0])
);
}
}

$cwd = getcwd();
if ($this->_isDirectory($cwd) && $this->_containsPackageXml($cwd)) {
return array(
$this->_dependencies
->getComponentFactory()
->createSource($cwd),
$cwd
);
}

// Usability: check if we are in a subdir of a component
do {
if ($this->_isDirectory($cwd) && $this->_containsPackageXml($cwd)) {
return array(
$this->_dependencies
->getComponentFactory()
->createSource($cwd),
$cwd
);
}
$cwd = dirname($cwd, 1);
} while ($cwd != '/');
throw new Components_Exception(Components::ERROR_NO_COMPONENT);
}

Expand Down