Skip to content

Commit 963c4f8

Browse files
author
Christian Opitz
committed
Initial import
1 parent 84a59d5 commit 963c4f8

23 files changed

+1761
-0
lines changed

composer.json

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"name": "netresearch/composer-patches-plugin",
3+
"type": "composer-plugin",
4+
"license": "GPL-2.0",
5+
"description": "Composer patches plugin",
6+
"keywords": [
7+
"composer", "patches", "plugin"
8+
],
9+
"homepage": "",
10+
"authors": [
11+
{
12+
"name": "Christian Opitz",
13+
"email": "[email protected]"
14+
}
15+
16+
],
17+
"minimum-stability": "dev",
18+
"autoload": {
19+
"psr-0": { "": "src/"}
20+
},
21+
"require-dev": {
22+
"composer/composer": "1.*"
23+
},
24+
"extra": {
25+
"class": "Netresearch\\Composer\\Patches\\Plugin",
26+
"branch-alias": {
27+
"dev-master": "1.0.x-dev"
28+
}
29+
}
30+
}

phpunit.xml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="./tests/bootstrap.php"
13+
>
14+
<testsuites>
15+
<testsuite name="Full Composer Test Suite">
16+
<directory>./tests/Netresearch/Test/Composer</directory>
17+
</testsuite>
18+
</testsuites>
19+
</phpunit>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
namespace Netresearch\Composer\Patches\Downloader;
3+
4+
/* *
5+
* This script belongs to the Composer-TYPO3-Installer package *
6+
* (c) 2014 Netresearch GmbH & Co. KG *
7+
* This copyright notice MUST APPEAR in all copies of the script! *
8+
* *
9+
* It is free software; you can redistribute it and/or modify it under *
10+
* the terms of the GNU Lesser General Public License, either version 3 *
11+
* of the License, or (at your option) any later version. *
12+
* *
13+
* The TYPO3 project - inspiring people to share! *
14+
* */
15+
16+
use Composer\Util\RemoteFilesystem;
17+
18+
/**
19+
* Downloader, which uses the composer RemoteFilesystem
20+
*/
21+
class Composer implements DownloaderInterface {
22+
/**
23+
* @var RemoteFilesystem
24+
*/
25+
protected $remoteFileSystem;
26+
27+
/**
28+
* Very simple cache system
29+
* @var array
30+
*/
31+
protected $cache = array();
32+
33+
/**
34+
* Construct the RFS
35+
*
36+
* @param \Composer\IO\IOInterface $io
37+
*/
38+
public function __construct(\Composer\IO\IOInterface $io) {
39+
$this->remoteFileSystem = new RemoteFilesystem($io);
40+
}
41+
42+
/**
43+
* Get the origin URL required by composer rfs
44+
*
45+
* @param string $url
46+
* @return string
47+
*/
48+
protected function getOriginUrl($url) {
49+
return parse_url($url, PHP_URL_HOST);
50+
}
51+
52+
/**
53+
* Download the file and return its contents
54+
*
55+
* @param string $url The URL from where to download
56+
* @return string Contents of the URL
57+
*/
58+
public function getContents($url) {
59+
if (array_key_exists($url, $this->cache)) {
60+
return $this->cache[$url];
61+
}
62+
return $this->cache[$url] = $this->remoteFileSystem->getContents($this->getOriginUrl($url), $url);
63+
}
64+
65+
/**
66+
* Download file and decode the JSON string to PHP object
67+
*
68+
* @param string $json
69+
* @return stdClass
70+
*/
71+
public function getJson($url) {
72+
$key = 'json://' . $url;
73+
if (array_key_exists($key, $this->cache)) {
74+
return $this->cache[$key];
75+
}
76+
$json = new \Composer\Json\JsonFile($url, $this->remoteFileSystem);
77+
return $this->cache[$key] = $json->read();
78+
}
79+
}
80+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
namespace Netresearch\Composer\Patches\Downloader;
3+
4+
/* *
5+
* This script belongs to the Composer-TYPO3-Installer package *
6+
* (c) 2014 Netresearch GmbH & Co. KG *
7+
* This copyright notice MUST APPEAR in all copies of the script! *
8+
* *
9+
* It is free software; you can redistribute it and/or modify it under *
10+
* the terms of the GNU Lesser General Public License, either version 3 *
11+
* of the License, or (at your option) any later version. *
12+
* *
13+
* The TYPO3 project - inspiring people to share! *
14+
* */
15+
16+
/**
17+
* Downloader interface
18+
*
19+
* @author Christian Opitz <christian.opitz at netresearch.de>
20+
*/
21+
interface DownloaderInterface {
22+
/**
23+
* Download the file and return its contents
24+
*
25+
* @param string $url The URL from where to download
26+
* @return string Contents of the URL
27+
*/
28+
public function getContents($url);
29+
30+
/**
31+
* Download file and decode the JSON string to PHP object
32+
*
33+
* @param string $json
34+
* @return stdClass
35+
*/
36+
public function getJson($url);
37+
}
38+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
namespace Netresearch\Composer\Patches;
3+
4+
/* *
5+
* This script belongs to the Composer-TYPO3-Installer package *
6+
* (c) 2014 Netresearch GmbH & Co. KG *
7+
* This copyright notice MUST APPEAR in all copies of the script! *
8+
* *
9+
* It is free software; you can redistribute it and/or modify it under *
10+
* the terms of the GNU Lesser General Public License, either version 3 *
11+
* of the License, or (at your option) any later version. *
12+
* *
13+
* The TYPO3 project - inspiring people to share! *
14+
* */
15+
16+
/**
17+
* Base Exception for PatchSet package
18+
*
19+
* @author Christian Opitz <christian.opitz at netresearch.de>
20+
*/
21+
class Exception extends \ErrorException {
22+
/**
23+
* Constructor - message is required only
24+
*
25+
* @param string $message
26+
*/
27+
public function __construct($message) {
28+
parent::__construct($message);
29+
}
30+
}
31+
?>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
namespace Netresearch\Composer\Patches;
3+
4+
/* *
5+
* This script belongs to the Composer-TYPO3-Installer package *
6+
* (c) 2014 Netresearch GmbH & Co. KG *
7+
* This copyright notice MUST APPEAR in all copies of the script! *
8+
* *
9+
* It is free software; you can redistribute it and/or modify it under *
10+
* the terms of the GNU Lesser General Public License, either version 3 *
11+
* of the License, or (at your option) any later version. *
12+
* *
13+
* The TYPO3 project - inspiring people to share! *
14+
* */
15+
16+
/**
17+
* This is just a noop installer to enable packages of type "patches"
18+
* The patch application is done in the plugin and is not limited to
19+
* "patches"-packages: Every package that has patches in it's extras
20+
* is respected there.
21+
*
22+
* @author Christian Opitz <christian.opitz at netresearch.de>
23+
*/
24+
class Installer extends \Composer\Installer\NoopInstaller {
25+
/**
26+
* Supports packages of type "patches"
27+
*
28+
* @param string $packageType
29+
* @return boolean
30+
*/
31+
public function supports($packageType) {
32+
return $packageType == 'patches';
33+
}
34+
}

0 commit comments

Comments
 (0)