Revert "fix(dependencies): Migrate to PHP scoper"

This commit is contained in:
Joas Schilling 2024-11-05 21:19:23 +01:00 committed by GitHub
parent fa7b7afeac
commit 7a7593ca48
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 452 additions and 926 deletions

View file

@ -66,8 +66,7 @@ updates:
directories:
- "/tests/integration"
- "/vendor-bin/csfixer"
- "/vendor-bin/openapi-extractor"
- "/vendor-bin/php-scoper"
- "/vendor-bin/mozart"
- "/vendor-bin/phpunit"
- "/vendor-bin/psalm"
- "/vendor-bin/rector"

View file

@ -88,7 +88,6 @@ appstore:
--exclude=jest.config.js \
--exclude=jest.global.setup.js \
--exclude=.l10nignore \
--exclude=lib-vendor-organizer.php \
--exclude=mkdocs.yml \
--exclude=Makefile \
--exclude=node_modules \
@ -101,7 +100,6 @@ appstore:
--exclude=.readthedocs.yaml \
--exclude=/recording \
--exclude=/redocly.yaml \
--exclude=/scoper.inc.php \
--exclude=/site \
--exclude=/src \
--exclude=.stylelintignore \

View file

@ -29,17 +29,13 @@
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
"post-install-cmd": [
"@composer bin all install --ansi",
"vendor/bin/php-scoper add-prefix --force # Scope our dependencies",
"@php lib-vendor-organizer.php lib/Vendor/ OCA\\\\Talk\\\\Vendor",
"composer dump-autoload -o"
"\"vendor/bin/mozart\" compose",
"composer dump-autoload"
],
"post-update-cmd": [
"@composer bin all update --ansi",
"vendor/bin/php-scoper add-prefix --force # Scope our dependencies",
"rm -Rf lib/Vendor && mv build lib/Vendor",
"find lib/Vendor/ -maxdepth 1 -mindepth 1 -type d | cut -d '/' -f3 | xargs -I {} rm -Rf vendor/{} # Remove origins",
"@php lib-vendor-organizer.php lib/Vendor/ OCA\\\\Talk\\\\Vendor",
"composer dump-autoload -o"
"\"vendor/bin/mozart\" compose",
"composer dump-autoload"
],
"test:unit": "vendor/bin/phpunit -c tests/php/phpunit.xml --colors=always --fail-on-warning --fail-on-risky"
},
@ -51,5 +47,17 @@
"bamarni/composer-bin-plugin": "^1.8",
"cuyz/valinor": "^1.14",
"firebase/php-jwt": "^6.10"
},
"extra": {
"mozart": {
"dep_namespace": "OCA\\Talk\\Vendor\\",
"dep_directory": "/lib/Vendor/",
"classmap_directory": "/lib/autoload/",
"classmap_prefix": "NEXTCLOUDTALK_",
"packages": [
"firebase/php-jwt",
"cuyz/valinor"
]
}
}
}

View file

@ -1,83 +0,0 @@
#!/usr/bin/env php
<?php
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
$sourceDirectory = $argv[1];
$sourceDirectory = rtrim($sourceDirectory, '/') . '/';
if (!str_starts_with('/', $sourceDirectory)) {
$sourceDirectory = getcwd() . '/' . $sourceDirectory;
}
$stripNamespacePrefix = $argv[2] ?? '';
if ($stripNamespacePrefix) {
printf("Namespace Prefix to strip from destination dir is %s%s", $stripNamespacePrefix, PHP_EOL);
}
if (!file_exists($sourceDirectory) || !is_dir($sourceDirectory)) {
print("Directory not found");
exit(1);
}
$organizationList = [];
foreach(scandir($sourceDirectory) as $file) {
if (!is_dir($sourceDirectory . $file) || $file === '.' || $file === '..') {
continue;
}
$organizationList[] = $sourceDirectory . $file . '/';
}
$projectList = [];
foreach($organizationList as $organizationDir) {
foreach(scandir($organizationDir) as $file) {
if (!is_dir($organizationDir . $file) || $file === '.' || $file === '..') {
continue;
}
$projectList[] = $organizationDir . $file . '/';
}
}
foreach ($projectList as $projectDir) {
if (!file_exists($projectDir . 'composer.json')) {
continue;
}
$projectInfo = json_decode(file_get_contents($projectDir . 'composer.json'), true);
if (!isset($projectInfo['autoload']['psr-4'])) {
printf("No supported autoload configuration in %s" . PHP_EOL, $projectDir);
exit(2);
}
foreach ($projectInfo['autoload']['psr-4'] as $namespace => $codeDir) {
if ($stripNamespacePrefix !== '' && strpos($namespace, $stripNamespacePrefix) === 0) {
$namespace = str_replace($stripNamespacePrefix, '', $namespace);
}
$destination = $sourceDirectory . str_replace('\\', '/', $namespace);
if (file_exists($destination)) {
rmdir_recursive($destination);
}
mkdir($destination, 0777, true);
if (!rename($projectDir . $codeDir, $destination)) {
printf("Failed to move %s to %s" . PHP_EOL, $projectDir . $codeDir, $destination);
exit(3);
}
}
}
foreach($organizationList as $organizationDir) {
rmdir_recursive($organizationDir);
}
function rmdir_recursive($dir) {
foreach(scandir($dir) as $file) {
if ('.' === $file || '..' === $file) {
continue;
}
if (is_dir("$dir/$file")) {
rmdir_recursive("$dir/$file");
} else {
unlink("$dir/$file");
}
}
rmdir($dir);
}

View file

@ -1,50 +0,0 @@
<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
use Isolated\Symfony\Component\Finder\Finder;
// You can do your own things here, e.g. collecting symbols to expose dynamically
// or files to exclude.
// However, beware that this file is executed by PHP-Scoper, hence if you are using
// the PHAR it will be loaded by the PHAR. So it is highly recommended to avoid
// to autoload any code here: it can result in a conflict or even corrupt
// the PHP-Scoper analysis.
return [
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#prefix
'prefix' => 'OCA\\Talk\\Vendor',
'output-dir' => 'lib/Vendor',
// For more see: https://github.com/humbug/php-scoper/blob/master/docs/configuration.md#finders-and-paths
'finders' => [
Finder::create()->files()
->exclude([
'test',
'composer',
'bin',
])
->notName('autoload.php')
->in('vendor/cuyz'),
Finder::create()->files()
->exclude([
'test',
'composer',
'bin',
])
->notName('autoload.php')
->in('vendor/psr/simple-cache'),
Finder::create()->files()
->exclude([
'test',
'composer',
'bin',
])
->notName('autoload.php')
->in('vendor/firebase'),
],
];

View file

@ -6,6 +6,6 @@
"sort-packages": true
},
"require": {
"humbug/php-scoper": "^0.18.7"
"coenjacobs/mozart": "^0.7.1"
}
}

File diff suppressed because it is too large Load diff