files-checker.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. '.devcontainer',
  26. '.drone.yml',
  27. '.editorconfig',
  28. '.eslintignore',
  29. '.eslintrc.js',
  30. '.git',
  31. '.gitattributes',
  32. '.github',
  33. '.gitignore',
  34. '.gitmodules',
  35. '.htaccess',
  36. '.idea',
  37. '.jshintrc',
  38. '.mailmap',
  39. '.npmignore',
  40. '.php-cs-fixer.dist.php',
  41. '.scrutinizer.yml',
  42. '.tag',
  43. '.tx',
  44. '.user.ini',
  45. '3rdparty',
  46. 'apps',
  47. 'AUTHORS',
  48. 'autotest-checkers.sh',
  49. 'autotest-external.sh',
  50. 'autotest-js.sh',
  51. 'autotest.sh',
  52. 'babel.config.js',
  53. 'build',
  54. 'CHANGELOG.md',
  55. 'CODE_OF_CONDUCT.md',
  56. 'composer.json',
  57. 'composer.lock',
  58. 'config',
  59. 'console.php',
  60. 'contribute',
  61. 'COPYING-README',
  62. 'COPYING',
  63. 'core',
  64. 'cron.php',
  65. 'index.html',
  66. 'index.php',
  67. 'lib',
  68. 'Makefile',
  69. 'occ',
  70. 'ocm-provider',
  71. 'ocs-provider',
  72. 'ocs',
  73. 'package-lock.json',
  74. 'package.json',
  75. 'psalm.xml',
  76. 'psalm-ocp.xml',
  77. 'public.php',
  78. 'README.md',
  79. 'remote.php',
  80. 'resources',
  81. 'robots.txt',
  82. 'SECURITY.md',
  83. 'status.php',
  84. 'tests',
  85. 'themes',
  86. 'version.php',
  87. 'vendor-bin',
  88. 'webpack.common.js',
  89. 'webpack.dev.js',
  90. 'webpack.prod.js',
  91. ];
  92. $actualFiles = [];
  93. $files = new \DirectoryIterator(__DIR__ . '/..');
  94. foreach ($files as $file) {
  95. $actualFiles[] = $file->getFilename();
  96. }
  97. $additionalFiles = array_diff($actualFiles, $expectedFiles);
  98. $missingFiles = array_diff($expectedFiles, $actualFiles);
  99. $failed = false;
  100. if (count($additionalFiles) > 0) {
  101. echo sprintf('ERROR: There were %d additional files:', count($additionalFiles)) . PHP_EOL;
  102. echo implode(PHP_EOL, $additionalFiles) . PHP_EOL;
  103. $failed = true;
  104. }
  105. if (count($missingFiles) > 0) {
  106. echo sprintf('ERROR: There were %d missing files:', count($missingFiles)) . PHP_EOL;
  107. echo implode(PHP_EOL, $missingFiles) . PHP_EOL;
  108. $failed = true;
  109. }
  110. if ($failed) {
  111. 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;
  112. exit(1);
  113. }
  114. echo 'OK: all expected files are present and no additional files are there.' . PHP_EOL;
  115. exit(0);