diff --git a/composer.json b/composer.json index df8e07c8..1e536103 100644 --- a/composer.json +++ b/composer.json @@ -1,5 +1,5 @@ { - "name": "xwp/wpcom-vip-plugins", + "name": "xwp/vip-wpcom-plugins-builder", "description": "Composer repository for VIP WPCOM shared plugins", "type": "project", "license": "MIT", @@ -33,6 +33,7 @@ "composer validate --no-check-all" ], "build": [ + "rm -rf public/*", "XWP\\WPCOMVIPPlugins\\ConfigBuilder::build", "satis build satis.json public" ] diff --git a/composer.lock b/composer.lock index e00f85a8..b85d69bd 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d61856f567e64697ff7db71a248ebfeb", + "content-hash": "a03edc7b069da1c7d1cd2d973436e35a", "packages": [ { "name": "automattic/vip-wpcom-plugins", @@ -281,16 +281,16 @@ }, { "name": "composer/spdx-licenses", - "version": "1.5.2", + "version": "1.5.3", "source": { "type": "git", "url": "https://github.com/composer/spdx-licenses.git", - "reference": "7ac1e6aec371357df067f8a688c3d6974df68fa5" + "reference": "0c3e51e1880ca149682332770e25977c70cf9dae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/7ac1e6aec371357df067f8a688c3d6974df68fa5", - "reference": "7ac1e6aec371357df067f8a688c3d6974df68fa5", + "url": "https://api.github.com/repos/composer/spdx-licenses/zipball/0c3e51e1880ca149682332770e25977c70cf9dae", + "reference": "0c3e51e1880ca149682332770e25977c70cf9dae", "shasum": "" }, "require": { @@ -337,7 +337,7 @@ "spdx", "validator" ], - "time": "2019-07-29T10:31:59+00:00" + "time": "2020-02-14T07:44:31+00:00" }, { "name": "composer/xdebug-handler", @@ -547,16 +547,16 @@ }, { "name": "seld/phar-utils", - "version": "1.0.2", + "version": "1.1.0", "source": { "type": "git", "url": "https://github.com/Seldaek/phar-utils.git", - "reference": "84715761c35808076b00908a20317a3a8a67d17e" + "reference": "8800503d56b9867d43d9c303b9cbcc26016e82f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/84715761c35808076b00908a20317a3a8a67d17e", - "reference": "84715761c35808076b00908a20317a3a8a67d17e", + "url": "https://api.github.com/repos/Seldaek/phar-utils/zipball/8800503d56b9867d43d9c303b9cbcc26016e82f0", + "reference": "8800503d56b9867d43d9c303b9cbcc26016e82f0", "shasum": "" }, "require": { @@ -585,9 +585,9 @@ ], "description": "PHAR file format utilities, for when PHP phars you up", "keywords": [ - "phra" + "phar" ], - "time": "2020-01-13T10:41:09+00:00" + "time": "2020-02-14T15:25:33+00:00" }, { "name": "symfony/console", @@ -818,16 +818,16 @@ }, { "name": "symfony/polyfill-ctype", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3" + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", - "reference": "f8f0b461be3385e56d6de3dbb5a0df24c0c275e3", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", + "reference": "fbdeaec0df06cf3d51c93de80c7eb76e271f5a38", "shasum": "" }, "require": { @@ -839,7 +839,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -872,20 +872,20 @@ "polyfill", "portable" ], - "time": "2019-11-27T13:56:44+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.13.1", + "version": "v1.14.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f" + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/7b4aab9743c30be783b73de055d24a39cf4b954f", - "reference": "7b4aab9743c30be783b73de055d24a39cf4b954f", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/34094cfa9abe1f0f14f48f490772db7a775559f2", + "reference": "34094cfa9abe1f0f14f48f490772db7a775559f2", "shasum": "" }, "require": { @@ -897,7 +897,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.13-dev" + "dev-master": "1.14-dev" } }, "autoload": { @@ -931,7 +931,7 @@ "portable", "shim" ], - "time": "2019-11-27T14:18:11+00:00" + "time": "2020-01-13T11:15:53+00:00" }, { "name": "symfony/process", @@ -984,16 +984,16 @@ }, { "name": "twig/twig", - "version": "v2.12.4", + "version": "v2.12.5", "source": { "type": "git", "url": "https://github.com/twigphp/Twig.git", - "reference": "822d57eac92f966cd1e3232539b3dbbfed21f754" + "reference": "18772e0190734944277ee97a02a9a6c6555fcd94" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/822d57eac92f966cd1e3232539b3dbbfed21f754", - "reference": "822d57eac92f966cd1e3232539b3dbbfed21f754", + "url": "https://api.github.com/repos/twigphp/Twig/zipball/18772e0190734944277ee97a02a9a6c6555fcd94", + "reference": "18772e0190734944277ee97a02a9a6c6555fcd94", "shasum": "" }, "require": { @@ -1045,7 +1045,7 @@ "keywords": [ "templating" ], - "time": "2020-02-11T06:01:32+00:00" + "time": "2020-02-11T15:31:23+00:00" } ], "packages-dev": [], diff --git a/src/ConfigBuilder.php b/src/ConfigBuilder.php index bbdb5502..d453d4a5 100644 --- a/src/ConfigBuilder.php +++ b/src/ConfigBuilder.php @@ -14,6 +14,10 @@ public static function build(Event $event) $repositories = array_map( function ($plugin) use ($plugins_dir) { + $plugin_dir_path = sprintf('%s/%s', $plugins_dir, $plugin); + $revisions = self::getDirectorySvnRevisions($plugin_dir_path); + $latestRevision = reset($revisions); + return [ 'type' => 'package', 'package' => [ @@ -23,10 +27,10 @@ function ($plugin) use ($plugins_dir) { 'source' => [ 'url' => 'https://vip-svn.wordpress.com/plugins', 'type' => 'svn', - 'reference' => $plugin, + 'reference' => sprintf('%s@%s', $plugin, $latestRevision), ], 'dist' => [ - 'url' => sprintf('%s/%s', $plugins_dir, $plugin), + 'url' => $plugin_dir_path, 'type' => 'path', ], ], @@ -54,4 +58,16 @@ protected static function getDirectories($path) { return glob($pattern , GLOB_ONLYDIR); } + + protected static function getDirectorySvnRevisions($path) { + $logCommand = sprintf('svn log --xml %s', $path); + $xml = simplexml_load_string(shell_exec($logCommand)); + $revisions = []; + + foreach ($xml->logentry as $logentry) { + $revisions[] = (int) $logentry->attributes()->revision; + } + + return $revisions; + } }