Skip to content

Commit

Permalink
Merge pull request #66 from Islandora-Devops/feature/track-original-v…
Browse files Browse the repository at this point in the history
…ersion

Track original version, on `create-project`
  • Loading branch information
rosiel authored Mar 15, 2023
2 parents 1e8b5a3 + 850bf64 commit 8b7cef1
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
37 changes: 37 additions & 0 deletions assets/IslandoraStarterSite.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

namespace Islandora;

use Composer\Json\JsonFile;
use Composer\Script\Event;
use Composer\Util\Platform;

/**
* Starter Site Composer helper.
*/
class StarterSite {

/**
* Root package installation event callback.
*
* Expected to be triggered on the `post-root-package-install` event, to track
* the version of the project from which a project was derived.
*
* @see https://getcomposer.org/doc/articles/scripts.md#event-names
*/
public static function rootPackageInstall(Event $event) {
$composer = $event->getComposer();
$package = $composer->getPackage();
$version_file = new JsonFile('.starter_site_version');
$version_file->write([
'package' => "$package",
'full-pretty-version' => $package->getFullPrettyVersion(),
'pretty-string' => $package->getPrettyString(),
'pretty-version' => $package->getPrettyVersion(),
'unique-name' => $package->getUniqueName(),
'version' => $package->getVersion(),
'release-date' => $package->getReleaseDate(),
]);
}

}
10 changes: 10 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,5 +140,15 @@
"drupal/config_inspector": "^2.1",
"drupal/devel": "^5.0",
"drupal/restui": "^1.21"
},
"scripts": {
"post-root-package-install": [
"Islandora\\StarterSite::rootPackageInstall"
]
},
"autoload": {
"classmap": [
"assets/IslandoraStarterSite.php"
]
}
}

0 comments on commit 8b7cef1

Please sign in to comment.