From 6f333e7b6844a443ec09501fdb42088e87adcc3d Mon Sep 17 00:00:00 2001 From: Kartik Suthar Date: Fri, 24 May 2024 11:18:14 +0530 Subject: [PATCH] PROD-7243 - implement scoper for the build --- .gitignore | 3 + Gruntfile.js | 5 +- composer.json | 1 + includes/Library/Composer/Src/FFMpeg.php | 10 +- scoper.inc.php | 6 -- src/composer.json | 21 ++++- src/composer.lock | 90 ++++++++---------- src/includes/Library/Composer/Src/FFMpeg.php | 93 +++++++++++++++++++ .../Library/Composer/Src/ZipStream.php | 39 ++++++++ src/includes/Library/composer.php | 56 +++++++++++ src/scoper.inc.php | 18 ++++ 11 files changed, 277 insertions(+), 65 deletions(-) create mode 100644 src/includes/Library/Composer/Src/FFMpeg.php create mode 100644 src/includes/Library/Composer/Src/ZipStream.php create mode 100644 src/includes/Library/composer.php create mode 100644 src/scoper.inc.php diff --git a/.gitignore b/.gitignore index 70cc89a7c4..b8a4d03a13 100644 --- a/.gitignore +++ b/.gitignore @@ -20,7 +20,10 @@ src/vendor vendor includes/Library/Composer/*.php includes/Library/Composer/[!Src] +src/includes/Library/Composer/*.php +src/includes/Library/Composer/[!Src] scoped_vendor +src/scoped_vendor node_modules npm-debug.log diff --git a/Gruntfile.js b/Gruntfile.js index 8249c1f987..1a10b6490a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -225,6 +225,7 @@ module.exports = function (grunt) { all: [BUILD_DIR], bp_rest: [SOURCE_DIR + 'buddyboss-platform-api/'], bb_icons: [SOURCE_DIR + 'bp-templates/bp-nouveau/icons/bb-icons/'], + composer: [ BUILD_DIR + 'composer.json', BUILD_DIR + 'composer.lock', BUILD_DIR + 'scoper.inc.php', BUILD_DIR + 'apidoc.json' ], }, copy: { files: { @@ -446,7 +447,7 @@ module.exports = function (grunt) { stdout: false, }, composer: { - command: 'composer update', + command: 'composer update; composer scoper;', cwd: SOURCE_DIR, stdout: false } @@ -554,7 +555,7 @@ module.exports = function (grunt) { grunt.registerTask('src', ['checkDependencies', 'jsvalidate', 'jshint', 'stylelint', 'sass', 'rtlcss', 'checktextdomain', /*'imagemin',*/ 'uglify', 'cssmin', 'makepot:src']); grunt.registerTask('bp_rest', ['clean:bp_rest', 'exec:rest_api', 'copy:bp_rest_components', 'copy:bp_rest_core', 'clean:bp_rest', 'apidoc' ]); grunt.registerTask('bp_performance', ['clean:bp_rest', 'exec:rest_performance', 'copy:bp_rest_performance', 'copy:bp_rest_mu', 'clean:bp_rest']); - grunt.registerTask('build', ['string-replace:dist', 'exec:composer', 'exec:cli', 'clean:all', 'copy:files', 'compress', 'clean:all']); + grunt.registerTask('build', ['string-replace:dist', 'exec:composer', 'exec:cli', 'clean:all', 'copy:files', 'clean:composer', 'compress', 'clean:all']); grunt.registerTask('release', ['src', 'build']); // Testing tasks. diff --git a/composer.json b/composer.json index a5b96080f2..82fbbfa0d8 100644 --- a/composer.json +++ b/composer.json @@ -50,6 +50,7 @@ "lint": ["@lint-php", "@lint-js", "@lint-css"], "scoper": [ "rm -rf vendor", + "rm -rf scoped_vendor", "composer install --no-dev", "php-scoper add-prefix vendor includes/Library/Composer/Src --output-dir=scoped_vendor --prefix BuddyBossPlatform", "rm -rf vendor", diff --git a/includes/Library/Composer/Src/FFMpeg.php b/includes/Library/Composer/Src/FFMpeg.php index 65e451ed30..05fb5646ac 100644 --- a/includes/Library/Composer/Src/FFMpeg.php +++ b/includes/Library/Composer/Src/FFMpeg.php @@ -23,7 +23,7 @@ public static function instance() { /** * This Function Is Used To Get Instance From Scoped Vendor * - * @since [BBVERSION] + * @since 2.6.11 * * @param \FFMpeg\Driver\FFMpegDriver $ffmpeg. * @param \FFMpeg\FFProbe $ffprobe. @@ -37,7 +37,7 @@ function ffmpeg( $ffmpeg, $ffprobe ) { /** * This Function Is Used To Get Instance From Scoped Vendor * - * @since [BBVERSION] + * @since 2.6.11 * * @param \FFMpeg\Driver\FFProbeDriver $ffprobe. * @param \Doctrine\Common\Cache\Cache $cache. @@ -51,7 +51,7 @@ function ffprobe( $ffprobe, $cache ) { /** * Creates an FFMpeg. * - * @since [BBVERSION] + * @since 2.6.11 * * @param array|\Alchemy\BinaryDriver\ConfigurationInterface $configuration * @param \Psr\Log\LoggerInterface $logger @@ -66,7 +66,7 @@ function ffmpeg_create( $configuration = array(), $logger = null, $probe = null /** * Creates an FFProbe. * - * @since [BBVERSION] + * @since 2.6.11 * * @param array|\Alchemy\BinaryDriver\ConfigurationInterface $configuration * @param \Psr\Log\LoggerInterface $logger @@ -81,7 +81,7 @@ function ffprobe_create( $configuration = array(), $logger = null, $cache = null /** * Create timecode from number of seconds From Scoped Vendor * - * @since [BBVERSION] + * @since 2.6.11 * * @param float $seconds Seconds value. * diff --git a/scoper.inc.php b/scoper.inc.php index d4453891c9..622afcf66e 100644 --- a/scoper.inc.php +++ b/scoper.inc.php @@ -12,12 +12,6 @@ 'whitelist' => [ // Excludes specific namespaces from being prefixed. 'Composer\\*', - 'Humbug\\PhpScoper\\*', // Namespace for PHP-Scoper. - 'Humbug\\PhpScoper', - 'PHPUnit\\*', - 'PHPUnit\\Framework\TestCase', // A specific class. - // 'MyCLabs', - // 'MyCLabs\\*', ], 'finders' => [], 'patchers' => [], diff --git a/src/composer.json b/src/composer.json index 96770ae6cc..ea58ed2f1a 100644 --- a/src/composer.json +++ b/src/composer.json @@ -21,12 +21,27 @@ "php-ffmpeg/php-ffmpeg": "^0.16.0", "maennchen/zipstream-php": "^2.1" }, - "autoload": { - }, + "autoload": { + "classmap": [ + "../includes/" + ] + }, "scripts": { "remove-ffmpeg-docs": ["rm -rf vendor/php-ffmpeg/php-ffmpeg/docs && rm -rf vendor/php-ffmpeg/php-ffmpeg/tests"], "post-install-cmd": ["@remove-ffmpeg-docs"], - "post-update-cmd": ["@remove-ffmpeg-docs"] + "post-update-cmd": ["@remove-ffmpeg-docs"], + "scoper": [ + "rm -rf vendor", + "rm -rf scoped_vendor", + "composer install --no-dev", + "php-scoper add-prefix vendor includes/Library/Composer/Src --output-dir=scoped_vendor --prefix BuddyBossPlatform", + "rm -rf vendor", + "mv scoped_vendor/vendor vendor/", + "cp -r scoped_vendor/includes/Library/Composer/Src/* includes/Library/Composer", + "rm -rf scoped_vendor", + "composer remove-ffmpeg-docs", + "composer dumpautoload --optimize" + ] }, "config": { "allow-plugins": { diff --git a/src/composer.lock b/src/composer.lock index 5b76cb01b4..dd91a4f480 100644 --- a/src/composer.lock +++ b/src/composer.lock @@ -324,28 +324,28 @@ }, { "name": "evenement/evenement", - "version": "v3.0.1", + "version": "v3.0.2", "source": { "type": "git", "url": "https://github.com/igorw/evenement.git", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7" + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/igorw/evenement/zipball/531bfb9d15f8aa57454f5f0285b18bec903b8fb7", - "reference": "531bfb9d15f8aa57454f5f0285b18bec903b8fb7", + "url": "https://api.github.com/repos/igorw/evenement/zipball/0a16b0d71ab13284339abb99d9d2bd813640efbc", + "reference": "0a16b0d71ab13284339abb99d9d2bd813640efbc", "shasum": "" }, "require": { "php": ">=7.0" }, "require-dev": { - "phpunit/phpunit": "^6.0" + "phpunit/phpunit": "^9 || ^6" }, "type": "library", "autoload": { - "psr-0": { - "Evenement": "src" + "psr-4": { + "Evenement\\": "src/" } }, "notification-url": "https://packagist.org/downloads/", @@ -365,9 +365,9 @@ ], "support": { "issues": "https://github.com/igorw/evenement/issues", - "source": "https://github.com/igorw/evenement/tree/master" + "source": "https://github.com/igorw/evenement/tree/v3.0.2" }, - "time": "2017-07-23T21:35:13+00:00" + "time": "2023-08-08T05:53:35+00:00" }, { "name": "maennchen/zipstream-php", @@ -747,23 +747,24 @@ }, { "name": "symfony/filesystem", - "version": "v5.4.25", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/filesystem.git", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364" + "reference": "e6edd875d5d39b03de51f3c3951148cfa79a4d12" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", - "reference": "0ce3a62c9579a53358d3a7eb6b3dfb79789a6364", + "url": "https://api.github.com/repos/symfony/filesystem/zipball/e6edd875d5d39b03de51f3c3951148cfa79a4d12", + "reference": "e6edd875d5d39b03de51f3c3951148cfa79a4d12", "shasum": "" }, "require": { "php": ">=7.2.5", "symfony/polyfill-ctype": "~1.8", "symfony/polyfill-mbstring": "~1.8", - "symfony/polyfill-php80": "^1.16" + "symfony/polyfill-php80": "^1.16", + "symfony/process": "^5.4|^6.4" }, "type": "library", "autoload": { @@ -791,7 +792,7 @@ "description": "Provides basic utilities for the filesystem", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/filesystem/tree/v5.4.25" + "source": "https://github.com/symfony/filesystem/tree/v5.4.39" }, "funding": [ { @@ -807,20 +808,20 @@ "type": "tidelift" } ], - "time": "2023-05-31T13:04:02+00:00" + "time": "2024-04-18T08:26:06+00:00" }, { "name": "symfony/polyfill-ctype", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a" + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/5bbc823adecdae860bb64756d639ecfec17b050a", - "reference": "5bbc823adecdae860bb64756d639ecfec17b050a", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/ef4d7e442ca910c4764bce785146269b30cb5fc4", + "reference": "ef4d7e442ca910c4764bce785146269b30cb5fc4", "shasum": "" }, "require": { @@ -834,9 +835,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -873,7 +871,7 @@ "portable" ], "support": { - "source": "https://github.com/symfony/polyfill-ctype/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.29.0" }, "funding": [ { @@ -889,20 +887,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534" + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/8ad114f6b39e2c98a8b0e3bd907732c207c2b534", - "reference": "8ad114f6b39e2c98a8b0e3bd907732c207c2b534", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/9773676c8a1bb1f8d4340a62efe641cf76eda7ec", + "reference": "9773676c8a1bb1f8d4340a62efe641cf76eda7ec", "shasum": "" }, "require": { @@ -916,9 +914,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -956,7 +951,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.29.0" }, "funding": [ { @@ -972,20 +967,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/polyfill-php80", - "version": "v1.27.0", + "version": "v1.29.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-php80.git", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936" + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", - "reference": "7a6ff3f1959bb01aefccb463a0f2cd3d3d2fd936", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", + "reference": "87b68208d5c1188808dd7839ee1e6c8ec3b02f1b", "shasum": "" }, "require": { @@ -993,9 +988,6 @@ }, "type": "library", "extra": { - "branch-alias": { - "dev-main": "1.27-dev" - }, "thanks": { "name": "symfony/polyfill", "url": "https://github.com/symfony/polyfill" @@ -1039,7 +1031,7 @@ "shim" ], "support": { - "source": "https://github.com/symfony/polyfill-php80/tree/v1.27.0" + "source": "https://github.com/symfony/polyfill-php80/tree/v1.29.0" }, "funding": [ { @@ -1055,20 +1047,20 @@ "type": "tidelift" } ], - "time": "2022-11-03T14:55:06+00:00" + "time": "2024-01-29T20:11:03+00:00" }, { "name": "symfony/process", - "version": "v5.4.24", + "version": "v5.4.39", "source": { "type": "git", "url": "https://github.com/symfony/process.git", - "reference": "e3c46cc5689c8782944274bb30702106ecbe3b64" + "reference": "85a554acd7c28522241faf2e97b9541247a0d3d5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/e3c46cc5689c8782944274bb30702106ecbe3b64", - "reference": "e3c46cc5689c8782944274bb30702106ecbe3b64", + "url": "https://api.github.com/repos/symfony/process/zipball/85a554acd7c28522241faf2e97b9541247a0d3d5", + "reference": "85a554acd7c28522241faf2e97b9541247a0d3d5", "shasum": "" }, "require": { @@ -1101,7 +1093,7 @@ "description": "Executes commands in sub-processes", "homepage": "https://symfony.com", "support": { - "source": "https://github.com/symfony/process/tree/v5.4.24" + "source": "https://github.com/symfony/process/tree/v5.4.39" }, "funding": [ { @@ -1117,7 +1109,7 @@ "type": "tidelift" } ], - "time": "2023-05-17T11:26:05+00:00" + "time": "2024-04-18T08:26:06+00:00" } ], "packages-dev": [], diff --git a/src/includes/Library/Composer/Src/FFMpeg.php b/src/includes/Library/Composer/Src/FFMpeg.php new file mode 100644 index 0000000000..05fb5646ac --- /dev/null +++ b/src/includes/Library/Composer/Src/FFMpeg.php @@ -0,0 +1,93 @@ + \ No newline at end of file diff --git a/src/scoper.inc.php b/src/scoper.inc.php new file mode 100644 index 0000000000..ccfea8bb06 --- /dev/null +++ b/src/scoper.inc.php @@ -0,0 +1,18 @@ + $namespace, + 'whitelist' => [ + // Excludes specific namespaces from being prefixed. + 'Composer\\*' + ], + 'finders' => [], + 'patchers' => [], +];