File "set-flysystem-version.php"
Full path: /home/orbitecv/orbite-school.orbit.et/vendor/league/flysystem/bin/set-flysystem-version.php
File size: 1.15 KiB (1181 bytes)
MIME-type: text/x-php
Charset: utf-8
Download Open Edit Advanced Edit Back
<?php
use League\Flysystem\FileAttributes;
use League\Flysystem\Filesystem;
use League\Flysystem\Local\LocalFilesystemAdapter;
use League\Flysystem\StorageAttributes;
include_once __DIR__ . '/tools.php';
if ( ! isset($argv[1])) {
panic('No base version provided');
}
$mainVersion = $argv[1];
write_line("☝️ Setting all flysystem constraints to {$mainVersion}.");
$filesystem = new Filesystem(new LocalFilesystemAdapter(__DIR__ . '/../'));
/** @var string[] $otherComposers */
$composerFiles = $filesystem->listContents('src', true)
->filter(function (StorageAttributes $item) {
return $item->isFile();
})
->filter(function (FileAttributes $item) {
return substr($item->path(), -5) === '.json';
})
->map(function (FileAttributes $item) {
return $item->path();
})
->toArray();
foreach ($composerFiles as $composerFile) {
$contents = $filesystem->read($composerFile);
$mainVersionRegex = preg_quote($mainVersion, '~');
$updated = preg_replace('~("league/flysystem": "\\^[a-zA-Z0-9\\.-]+")~ms', '"league/flysystem": "^' . $mainVersion . '"', $contents);
$filesystem->write($composerFile, $updated);
}