mirror of
https://github.com/nextcloud/spreed.git
synced 2025-12-17 21:12:20 +01:00
fix(dependencies): Migrate to PHP scoper
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
2ecce8545a
commit
3ddfa913d2
7 changed files with 927 additions and 453 deletions
3
.github/dependabot.yml
vendored
3
.github/dependabot.yml
vendored
|
|
@ -66,7 +66,8 @@ updates:
|
|||
directories:
|
||||
- "/tests/integration"
|
||||
- "/vendor-bin/csfixer"
|
||||
- "/vendor-bin/mozart"
|
||||
- "/vendor-bin/openapi-extractor"
|
||||
- "/vendor-bin/php-scoper"
|
||||
- "/vendor-bin/phpunit"
|
||||
- "/vendor-bin/psalm"
|
||||
- "/vendor-bin/rector"
|
||||
|
|
|
|||
2
Makefile
2
Makefile
|
|
@ -88,6 +88,7 @@ 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 \
|
||||
|
|
@ -100,6 +101,7 @@ appstore:
|
|||
--exclude=.readthedocs.yaml \
|
||||
--exclude=/recording \
|
||||
--exclude=/redocly.yaml \
|
||||
--exclude=/scoper.inc.php \
|
||||
--exclude=/site \
|
||||
--exclude=/src \
|
||||
--exclude=.stylelintignore \
|
||||
|
|
|
|||
|
|
@ -29,13 +29,17 @@
|
|||
"psalm:fix": "psalm --alter --issues=InvalidReturnType,InvalidNullableReturnType,MissingParamType,InvalidFalsableReturnType",
|
||||
"post-install-cmd": [
|
||||
"@composer bin all install --ansi",
|
||||
"\"vendor/bin/mozart\" compose",
|
||||
"composer dump-autoload"
|
||||
"vendor/bin/php-scoper add-prefix --force # Scope our dependencies",
|
||||
"@php lib-vendor-organizer.php lib/Vendor/ OCA\\\\Talk\\\\Vendor",
|
||||
"composer dump-autoload -o"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"@composer bin all update --ansi",
|
||||
"\"vendor/bin/mozart\" compose",
|
||||
"composer dump-autoload"
|
||||
"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"
|
||||
],
|
||||
"test:unit": "vendor/bin/phpunit -c tests/php/phpunit.xml --colors=always --fail-on-warning --fail-on-risky"
|
||||
},
|
||||
|
|
@ -47,17 +51,5 @@
|
|||
"bamarni/composer-bin-plugin": "^1.8",
|
||||
"cuyz/valinor": "^1.8",
|
||||
"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"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
83
lib-vendor-organizer.php
Normal file
83
lib-vendor-organizer.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
#!/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);
|
||||
}
|
||||
50
scoper.inc.php
Normal file
50
scoper.inc.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?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'),
|
||||
],
|
||||
];
|
||||
|
|
@ -6,6 +6,6 @@
|
|||
"sort-packages": true
|
||||
},
|
||||
"require": {
|
||||
"coenjacobs/mozart": "^0.7.1"
|
||||
"humbug/php-scoper": "^0.18.7"
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Reference in a new issue