files-checker.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 Morris Jobke <hey@morrisjobke.de>
  4. *
  5. * @license GNU AGPL version 3 or any later version
  6. *
  7. * This program is free software: you can redistribute it and/or modify
  8. * it under the terms of the GNU Affero General Public License as
  9. * published by the Free Software Foundation, either version 3 of the
  10. * License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU Affero General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Affero General Public License
  18. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  19. *
  20. */
  21. $expectedFiles = [
  22. '.',
  23. '..',
  24. '.codecov.yml',
  25. '.drone.yml',
  26. '.editorconfig',
  27. '.eslintrc.js',
  28. '.git',
  29. '.gitattributes',
  30. '.github',
  31. '.gitignore',
  32. '.gitmodules',
  33. '.htaccess',
  34. '.idea',
  35. '.jshintrc',
  36. '.mailmap',
  37. '.php_cs.dist',
  38. '.scrutinizer.yml',
  39. '.tag',
  40. '.tx',
  41. '.user.ini',
  42. '3rdparty',
  43. 'apps',
  44. 'AUTHORS',
  45. 'autotest-checkers.sh',
  46. 'autotest-external.sh',
  47. 'autotest-js.sh',
  48. 'autotest.sh',
  49. 'babel.config.js',
  50. 'build',
  51. 'CHANGELOG.md',
  52. 'CODE_OF_CONDUCT.md',
  53. 'composer.json',
  54. 'composer.lock',
  55. 'config',
  56. 'console.php',
  57. 'contribute',
  58. 'COPYING-README',
  59. 'COPYING',
  60. 'core',
  61. 'cron.php',
  62. 'index.html',
  63. 'index.php',
  64. 'lib',
  65. 'Makefile',
  66. 'occ',
  67. 'ocm-provider',
  68. 'ocs-provider',
  69. 'ocs',
  70. 'package-lock.json',
  71. 'package.json',
  72. 'psalm.xml',
  73. 'public.php',
  74. 'README.md',
  75. 'remote.php',
  76. 'resources',
  77. 'robots.txt',
  78. 'SECURITY.md',
  79. 'status.php',
  80. 'tests',
  81. 'themes',
  82. 'version.php',
  83. 'webpack.common.js',
  84. 'webpack.dev.js',
  85. 'webpack.prod.js',
  86. ];
  87. $actualFiles = [];
  88. $files = new \DirectoryIterator(__DIR__ . '/..');
  89. foreach ($files as $file) {
  90. $actualFiles[] = $file->getFilename();
  91. }
  92. $additionalFiles = array_diff($actualFiles, $expectedFiles);
  93. $missingFiles = array_diff($expectedFiles, $actualFiles);
  94. $failed = false;
  95. if (count($additionalFiles) > 0) {
  96. echo sprintf('ERROR: There were %d additional files:', count($additionalFiles)) . PHP_EOL;
  97. echo implode(PHP_EOL, $additionalFiles) . PHP_EOL;
  98. $failed = true;
  99. }
  100. if (count($missingFiles) > 0) {
  101. echo sprintf('ERROR: There were %d missing files:', count($missingFiles)) . PHP_EOL;
  102. echo implode(PHP_EOL, $missingFiles) . PHP_EOL;
  103. $failed = true;
  104. }
  105. if ($failed) {
  106. echo 'ERROR: Please remove or add those files again or inform the release team about those now files to be included or excluded from the release tar ball.' . PHP_EOL;
  107. exit(1);
  108. }
  109. echo 'OK: all expected files are present and no additional files are there.' . PHP_EOL;
  110. exit(0);