Skip to content

Commit

Permalink
PROD-7875 Prefix composer static files hash for php scoper compatibil…
Browse files Browse the repository at this point in the history
…ity with composer static files
  • Loading branch information
bb-yudhisthir committed Aug 16, 2024
1 parent 6cd17a2 commit 000638b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 2 deletions.
19 changes: 19 additions & 0 deletions bin/bb-scoper-prefixer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php
$files = array(
'vendor/composer/autoload_static.php',
'vendor/composer/autoload_files.php',
);

foreach( $files as $file ) {
if ( file_exists( $file ) ) {
$contents = file_get_contents( $file );
$contents = preg_replace_callback(
'/\'([a-f0-9]{32})\'\s*=>/',
function( $matches ) {
return "'bb_platform_" . $matches[1] . "' =>";
},
$contents
);
file_put_contents( $file, $contents );
}
}
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@
"mv scoped_vendor/vendor vendor/",
"cp -r scoped_vendor/includes/Library/Composer/Src/* includes/Library/Composer",
"rm -rf scoped_vendor",
"composer dumpautoload --optimize"
"composer dumpautoload --optimize",
"php bin/bb-scoper-prefixer.php"
]
},
"config": {
Expand Down
3 changes: 2 additions & 1 deletion src/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"cp -r scoped_vendor/includes/Library/Composer/Src/* includes/Library/Composer",
"rm -rf scoped_vendor",
"composer remove-ffmpeg-docs",
"composer dumpautoload --optimize"
"composer dumpautoload --optimize",
"php ../bin/bb-scoper-prefixer.php"
]
},
"config": {
Expand Down

0 comments on commit 000638b

Please sign in to comment.