Skip to content

Commit 9915d2e

Browse files
committed
Issue #5: Provide packages.drupal.org compatible format
1 parent 0453d95 commit 9915d2e

File tree

5 files changed

+56
-261
lines changed

5 files changed

+56
-261
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ This package ensures that your application doesn't have installed dependencies w
66

77
## Installation
88

9-
### Drupal 8 ([composer.json](https://github.com/drupal-composer/drupal-security-advisories/blob/8.0.x/composer.json))
9+
### Drupal 8 ([composer.json](https://github.com/drupal-composer/drupal-security-advisories/blob/8.x/composer.json))
1010

1111
```sh
12-
~$ composer require drupal-composer/drupal-security-advisories:8.0.x-dev
12+
~$ composer require drupal-composer/drupal-security-advisories:8.x-dev
1313
```
1414

1515
### Drupal 7 ([composer.json](https://github.com/drupal-composer/drupal-security-advisories/blob/7.x/composer.json))

build/build-composer-json.php

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@ public static function prepareUrl($url) {
2626

2727
}
2828

29+
class VersionParser {
30+
31+
public static function getSemVer($version, $isCore) {
32+
$version = $isCore ? static::handleCore($version) : static::handleContrib($version);
33+
return static::isValid($version) ? $version : FALSE;
34+
}
35+
36+
public static function handleCore($version) {
37+
return $version;
38+
}
39+
40+
public static function handleContrib($version) {
41+
list($core, $version) = explode('-', $version, 2);
42+
return $version;
43+
}
44+
45+
public static function isValid($version) {
46+
return (strpos($version, 'unstable') === FALSE);
47+
}
48+
49+
}
50+
2951
while (isset($data) && isset($data->list)) {
3052
$results = array_merge($results, $data->list);
3153

@@ -59,13 +81,11 @@ public static function prepareUrl($url) {
5981
try {
6082
$project = $projects[$nid];
6183
$is_core = ($project->field_project_machine_name == 'drupal') ? TRUE : FALSE;
62-
$version = $versionFactory->create($result->field_release_version, $is_core);
84+
$version = VersionParser::getSemVer($result->field_release_version, $is_core);
6385
if (!$version) {
6486
throw new InvalidArgumentException('Invalid version number.');
6587
}
66-
$constraint = '<' . $version->getSemver();
67-
$versionParser->parseConstraints($constraint);
68-
$conflict[$version->getCore()]['drupal/' . $project->field_project_machine_name][] = '<' . $version->getSemver();
88+
$conflict[$core]['drupal/' . $project->field_project_machine_name][] = '<' . $version;
6989
} catch (\Exception $e) {
7090
// @todo: log exception
7191
continue;
@@ -74,7 +94,7 @@ public static function prepareUrl($url) {
7494

7595
$target = [
7696
7 => 'build-7.x',
77-
8 => 'build-8.0.x',
97+
8 => 'build-8.x',
7898
];
7999

80100
foreach ($conflict as $core => $packages) {

build/build.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
REPO="https://github.com/drupal-composer/drupal-security-advisories.git"
44
cd build
55
composer install --no-interaction --no-progress
6-
rm -rf build-7.x build-8.0.x
6+
rm -rf build-7.x build-8.x
77

88
git clone --branch 7.x $REPO build-7.x
9-
git clone --branch 8.0.x $REPO build-8.0.x
9+
git clone --branch 8.x $REPO build-8.x
1010

1111
php build-composer-json.php
1212

@@ -19,7 +19,7 @@ then
1919
fi
2020
cd ..
2121

22-
cd build-8.0.x
22+
cd build-8.x
2323
if [ ! -z "$(git status --porcelain)" ]
2424
then
2525
git add composer.json

build/composer.json

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,8 @@
77
}
88
],
99
"require": {
10-
"drupal/parse-composer": "dev-master@dev",
1110
"guzzlehttp/guzzle": "5.3.0",
1211
"guzzlehttp/cache-subscriber": "0.1.*@dev",
1312
"composer/composer": "^1.0"
14-
},
15-
"repositories": [
16-
{
17-
"type": "git",
18-
"url": "https://github.com/drupal-composer/drupal-parse-composer.git"
19-
},
20-
{
21-
"type": "package",
22-
"package": {
23-
"name": "drupal/drupal",
24-
"version": "7.43.0",
25-
"dist": {
26-
"url": "https://ftp.drupal.org/files/projects/drupal-7.43.zip",
27-
"type": "zip"
28-
}
29-
}
30-
}
31-
]
13+
}
3214
}

0 commit comments

Comments
 (0)