Skip to content

Commit 26244c7

Browse files
committed
Fixes #2: Include Drupal core
1 parent cd9c93a commit 26244c7

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

build/build-composer-json.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
$results = array();
88

9+
$versionFactory = new \Drupal\ParseComposer\VersionFactory();
910
$versionParser = new \Composer\Package\Version\VersionParser();
1011

1112
$client = new \GuzzleHttp\Client();
@@ -38,10 +39,10 @@ public static function prepareUrl($url) {
3839

3940
foreach ($results as $result) {
4041
$nid = $result->field_release_project->id;
41-
$version = new \Drupal\ParseComposer\Version($result->field_release_version);
42+
$core = (int) substr($result->field_release_version, 0, 1);
4243

4344
// Skip D6 and older.
44-
if ($version->getCore() < 7) {
45+
if ($core < 7) {
4546
continue;
4647
}
4748

@@ -55,13 +56,13 @@ public static function prepareUrl($url) {
5556
continue;
5657
}
5758

58-
$project = $projects[$nid];
59-
if ($project->field_project_machine_name == 'drupal') {
60-
// @todo: fix core version parser.
61-
continue;
62-
}
63-
6459
try {
60+
$project = $projects[$nid];
61+
$is_core = ($project->field_project_machine_name == 'drupal') ? TRUE : FALSE;
62+
$version = $versionFactory->create($result->field_release_version, $is_core);
63+
if (!$version) {
64+
throw new InvalidArgumentException('Invalid version number.');
65+
}
6566
$constraint = '<' . $version->getSemver();
6667
$versionParser->parseConstraints($constraint);
6768
$conflict[$version->getCore()]['drupal/' . $project->field_project_machine_name][] = '<' . $version->getSemver();
@@ -85,11 +86,10 @@ public static function prepareUrl($url) {
8586
];
8687

8788
foreach ($packages as $package => $constraints) {
88-
sort($constraints);
89+
natsort($constraints);
8990
$composer['conflict'][$package] = implode(',', $constraints);
9091
}
9192

9293
ksort($composer['conflict']);
9394
file_put_contents(__DIR__ . '/' . $target[$core] . '/composer.json', json_encode($composer, JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) . "\n");
9495
}
95-

0 commit comments

Comments
 (0)