From 004334f6422d305a67ae7815528a0a5ce948dcf6 Mon Sep 17 00:00:00 2001 From: Younes ENNAJI Date: Sun, 6 Oct 2024 15:54:53 +0100 Subject: [PATCH] chore: clean up build files --- .prettierignore | 3 - .shared/.github/workflows/auto_closer.yaml | 23 ------- bin/copy | 76 ++++++++++++++-------- 3 files changed, 48 insertions(+), 54 deletions(-) delete mode 100644 .shared/.github/workflows/auto_closer.yaml diff --git a/.prettierignore b/.prettierignore index 81bef90d..bcd0e31e 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,6 +1,3 @@ -pnpm-lock.yaml -pnpm-workspace.yaml - **/node_modules src/**/Resources/public/** src/**/Resources/dist/** diff --git a/.shared/.github/workflows/auto_closer.yaml b/.shared/.github/workflows/auto_closer.yaml deleted file mode 100644 index ba4fb618..00000000 --- a/.shared/.github/workflows/auto_closer.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: Auto Closer PR - -on: - pull_request_target: - types: [ opened ] - -jobs: - run: - name: 🤖 PR Auto-Closure - runs-on: ubuntu-latest - steps: - - uses: superbrothers/close-pull-request@v3 - with: - comment: | - Hi there 👋, - - First off, thanks for your effort! 🎉 Unfortunately, this repository is read-only because it's split from our primary monorepo repository. - - 🙏 We kindly ask if you could direct your valuable contribution to our main repository at https://github.com/php-flasher/php-flasher. - - Once you've moved your contribution there, we'll review it and provide feedback. 🕵️‍♂️ - - Thanks again for your understanding and cooperation. We really appreciate it! 🙌 diff --git a/bin/copy b/bin/copy index bbfeb90b..cf2b4921 100755 --- a/bin/copy +++ b/bin/copy @@ -1,50 +1,70 @@ #!/usr/bin/env php files() + ->in($dirs) + ->name('composer.json') + ->depth('< 3'); // Adjust depth as needed -foreach ($packages as $package) { - $package = realpath(dirname($package)); +$packages = []; + +// Collect package directories +foreach ($finder as $file) { + $packages[] = dirname($file->getRealPath()); +} + +foreach ($packages as $packageDir) { foreach ($resources as $resource) { - $resource = realpath($resource); - $dest = $package.str_replace(realpath(__DIR__.'/../'), '', $resource); - - if (!is_dir($resource) && file_exists($resource)) { - copy($resource, $dest); + if (!is_string($resource)) { continue; } - $files = new RecursiveIteratorIterator( - new RecursiveDirectoryIterator($resource, FilesystemIterator::SKIP_DOTS), - RecursiveIteratorIterator::SELF_FIRST - ); + $resourcePath = realpath($resource); - foreach ($files as $file) { - $target = $resource === $shared - ? $package.str_replace($resource, '', $file->getPathname()) - : $dest .'/'. $file->getFilename(); + if (!$resourcePath) { + continue; // Skip if the resource doesn't exist + } - if ($file->isDir()) { - system('rm -rf -- ' . escapeshellarg($dest)); - @mkdir(dirname($target), 0777, true); - continue; + $relativePath = str_replace(realpath(__DIR__.'/../') ?: '', '', $resourcePath); + $destination = $packageDir.$relativePath; + + if (is_file($resourcePath)) { + // Ensure the destination directory exists + $filesystem->mkdir(dirname($destination)); + // Copy the file + $filesystem->copy($resourcePath, $destination, true); + } elseif (is_dir($resourcePath)) { + if ($resourcePath === $shared) { + // Copy contents of the shared directory into the package directory + $filesystem->mirror($shared, $packageDir, null, ['override' => true]); + } else { + // Copy the entire directory to the destination + $filesystem->mirror($resourcePath, $destination, null, ['override' => true]); } - - @mkdir(dirname($target), 0777, true); - @copy($file->getPathname(), $target); } } }