Skip to content

Commit

Permalink
#9753 Update composer script when copying jqueryui and jquery validation
Browse files Browse the repository at this point in the history
  • Loading branch information
blesildaramirez committed Aug 12, 2024
1 parent 07b8bcd commit 07913a6
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions classes/dev/ComposerScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@ class ComposerScript
{
/**
* A post-install-cmd custom composer script that
* copies node_module dependencies
* copies composer installs from repositories
* to the correct/existing directories of the following dependencies:
* jquery-ui and jquery validation
*/
public static function copyNodeModuleDeps(): void
public static function copyVendorAssets(): void
{
function copyDir($src, $dst) {
$dir = opendir($src);
Expand All @@ -39,22 +41,28 @@ function copyDir($src, $dst) {
}

try {
$baseDir = __DIR__ . '/../../../../node_modules';
$jqueryDist = $baseDir . '/jquery/dist';
$jqueryUiDist = $baseDir . '/jquery-ui/dist';
$vendorBaseDir = __DIR__ . '/../../lib/vendor';
$jsPluginsDir = __DIR__ . '/../../js/lib';
$jqueryPluginsDir = $jsPluginsDir . '/jquery/plugins';
$vendorComponents = __DIR__ . '/../../lib/vendor/components';

if (!file_exists($vendorComponents . '/jquery')) {
mkdir($vendorComponents . '/jquery', 0755, true);
}
$jqueryUiDist = $vendorBaseDir . '/jquery/ui/dist';
$jqueryValidationDist = $vendorBaseDir . '/jquery/validation/dist';
$chartjsDist = $vendorBaseDir . '/chart/js/dist';

// jQuery UI
if (!file_exists($vendorComponents . '/jqueryui')) {
mkdir($vendorComponents . '/jqueryui', 0755, true);
}

copyDir($jqueryDist, $vendorComponents . '/jquery');
copy($jqueryUiDist . '/jquery-ui.js', $vendorComponents . '/jqueryui/jquery-ui.js');
copy($jqueryUiDist . '/jquery-ui.min.js', $vendorComponents . '/jqueryui/jquery-ui.min.js');

// jQuery Validation
if (!file_exists($jqueryPluginsDir . '/validate')) {
mkdir($jqueryPluginsDir . '/validate', 0755, true);
}
copyDir($jqueryValidationDist, $jqueryPluginsDir . '/validate');

} catch (Exception $e) {
error_log($e->getMessage());
}
Expand Down

0 comments on commit 07913a6

Please sign in to comment.