Yaffs site version 1.1
[yaffs-website] / vendor / ezyang / htmlpurifier / release1-update.php
1 <?php
2
3 // release script
4 // PHP 5.0 only
5
6 if (php_sapi_name() != 'cli') {
7     echo 'Release script cannot be called from web-browser.';
8     exit;
9 }
10
11 if (!isset($argv[1])) {
12     echo
13 'php release.php [version]
14     HTML Purifier release script
15 ';
16     exit;
17 }
18
19 $version = trim($argv[1]);
20
21 // Bump version numbers:
22
23 // ...in VERSION
24 file_put_contents('VERSION', $version);
25
26 // ...in NEWS
27 if ($is_dev = (strpos($version, 'dev') === false)) {
28   $date = date('Y-m-d');
29   $news_c = str_replace(
30       $l = "$version, unknown release date",
31       "$version, released $date",
32       file_get_contents('NEWS'),
33       $c
34   );
35   if (!$c) {
36       echo 'Could not update NEWS, missing ' . $l . PHP_EOL;
37       exit;
38   } elseif ($c > 1) {
39       echo 'More than one release declaration in NEWS replaced' . PHP_EOL;
40       exit;
41   }
42   file_put_contents('NEWS', $news_c);
43 }
44
45 // ...in Doxyfile
46 $doxyfile_c = preg_replace(
47     '/(?<=PROJECT_NUMBER {9}= )[^\s]+/m', // brittle
48     $version,
49     file_get_contents('Doxyfile'),
50     1, $c
51 );
52 if (!$c) {
53     echo 'Could not update Doxyfile, missing PROJECT_NUMBER.' . PHP_EOL;
54     exit;
55 }
56 file_put_contents('Doxyfile', $doxyfile_c);
57
58 // ...in HTMLPurifier.php
59 $htmlpurifier_c = file_get_contents('library/HTMLPurifier.php');
60 $htmlpurifier_c = preg_replace(
61     '/HTML Purifier .+? - /',
62     "HTML Purifier $version - ",
63     $htmlpurifier_c,
64     1, $c
65 );
66 if (!$c) {
67     echo 'Could not update HTMLPurifier.php, missing HTML Purifier [version] header.' . PHP_EOL;
68     exit;
69 }
70 $htmlpurifier_c = preg_replace(
71     '/public \$version = \'.+?\';/',
72     "public \$version = '$version';",
73     $htmlpurifier_c,
74     1, $c
75 );
76 if (!$c) {
77     echo 'Could not update HTMLPurifier.php, missing public $version.' . PHP_EOL;
78     exit;
79 }
80 $htmlpurifier_c = preg_replace(
81     '/const VERSION = \'.+?\';/',
82     "const VERSION = '$version';",
83     $htmlpurifier_c,
84     1, $c
85 );
86 if (!$c) {
87     echo 'Could not update HTMLPurifier.php, missing const $version.' . PHP_EOL;
88     exit;
89 }
90 file_put_contents('library/HTMLPurifier.php', $htmlpurifier_c);
91
92 $config_c = file_get_contents('library/HTMLPurifier/Config.php');
93 $config_c = preg_replace(
94     '/public \$version = \'.+?\';/',
95     "public \$version = '$version';",
96     $config_c,
97     1, $c
98 );
99 if (!$c) {
100     echo 'Could not update Config.php, missing public $version.' . PHP_EOL;
101     exit;
102 }
103 file_put_contents('library/HTMLPurifier/Config.php', $config_c);
104
105 passthru('php maintenance/flush.php');
106
107 if ($is_dev) echo "Review changes, write something in WHATSNEW and FOCUS, and then commit with log 'Release $version.'" . PHP_EOL;
108 else echo "Numbers updated to dev, no other modifications necessary!";
109
110 // vim: et sw=4 sts=4