From 1446640bd01637b49de09e8072cc0d0f9110c60d Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Wed, 7 Jan 2015 11:45:48 -0800 Subject: [PATCH] CRM-15797 - distmaker - Fixes for JS dependencies: * Exclude node_modules * Include bower_components * Include .json, composer.lock, bower.json, package.json * DM_NPM should be optional --- distmaker/distmaker.conf.dist | 6 ++++- distmaker/distmaker.sh | 4 +-- distmaker/dists/common.sh | 45 ++++++++++++++++++++----------- distmaker/dists/drupal6_php5.sh | 1 + distmaker/dists/drupal_php5.sh | 1 + distmaker/dists/drupal_sk_php5.sh | 1 + distmaker/dists/joomla_php5.sh | 1 + distmaker/dists/wordpress_php5.sh | 1 + 8 files changed, 40 insertions(+), 20 deletions(-) diff --git a/distmaker/distmaker.conf.dist b/distmaker/distmaker.conf.dist index 738812ae14..a1b4f9b382 100644 --- a/distmaker/distmaker.conf.dist +++ b/distmaker/distmaker.conf.dist @@ -4,11 +4,15 @@ DM_GENFILESDIR= DM_TMPDIR= DM_TARGETDIR= -DM_NPM= DM_PHP= DM_RSYNC= DM_ZIP= +## Optional +# DM_NPM= [default: npm] +# DM_NODE= [default: node] +# DM_COMPOSER= [default: composer] + DM_VERSION= ## Git banch/tag name diff --git a/distmaker/distmaker.sh b/distmaker/distmaker.sh index b3967adc45..404ad852bb 100755 --- a/distmaker/distmaker.sh +++ b/distmaker/distmaker.sh @@ -156,9 +156,6 @@ case $1 in esac -## Install npm packages -dm_npm_install "$DM_SOURCEDIR" - ## Make sure we have the right branch or tag dm_git_checkout "$DM_SOURCEDIR" "$DM_REF_CORE" dm_git_checkout "$DM_SOURCEDIR/packages" "$DM_REF_PACKAGES" @@ -168,6 +165,7 @@ dm_git_checkout "$DM_SOURCEDIR/drupal" "$DM_REF_DRUPAL" ## Get latest dependencies dm_generate_vendor "$DM_SOURCEDIR" +dm_generate_bower "$DM_SOURCEDIR" # Before anything - regenerate DAOs diff --git a/distmaker/dists/common.sh b/distmaker/dists/common.sh index b6bfc6c186..b6a4c752f7 100644 --- a/distmaker/dists/common.sh +++ b/distmaker/dists/common.sh @@ -45,17 +45,32 @@ function dm_remove_files() { done } +## Copy all bower dependencies +function dm_install_bower() { + local repo="$1" + local to="$2" + + local excludes_rsync="" + for exclude in .git .svn {T,t}est{,s} {D,d}oc{,s} {E,e}xample{,s} ; do + excludes_rsync="--exclude=${exclude} ${excludes_rsync}" + done + + [ ! -d "$to" ] && mkdir "$to" + $DM_RSYNC -avC $excludes_rsync "$repo/./" "$to/./" +} + ## Copy all core files ## usage: dm_install_core function dm_install_core() { local repo="$1" local to="$2" - for dir in css i js PEAR templates bin CRM api extern Reports install settings Civi partials node_modules bower_components ; do + for dir in css i js PEAR templates bin CRM api extern Reports install settings Civi partials ; do [ -d "$repo/$dir" ] && dm_install_dir "$repo/$dir" "$to/$dir" done dm_install_files "$repo" "$to" {agpl-3.0,agpl-3.0.exception,gpl,README,CONTRIBUTORS}.txt + dm_install_files "$repo" "$to" composer.json composer.lock bower.json package.json mkdir -p "$to/sql" pushd "$repo" >> /dev/null @@ -146,13 +161,8 @@ function dm_install_vendor() { excludes_rsync="--exclude=${exclude} ${excludes_rsync}" done - ## Note: These small folders have items that previously were not published, - ## but there's no real cost to including them, and excluding them seems - ## likely to cause confusion as the codebase evolves: - ## packages/Files packages/PHP packages/Text - [ ! -d "$to" ] && mkdir "$to" - $DM_RSYNC -avC $excludes_rsync --include=core "$repo/./" "$to/./" + $DM_RSYNC -avC $excludes_rsync "$repo/./" "$to/./" } ## usage: dm_install_wordpress @@ -173,12 +183,23 @@ function dm_install_wordpress() { ## Need --exclude=civicrm for self-building on WP site } + +## Generate the "bower_components" folder. +## usage: dm_generate_bower +function dm_generate_bower() { + local repo="$1" + pushd "$repo" + ${DM_NPM:-npm} install + ${DM_NODE:-node} node_modules/bower/bin/bower install + popd +} + ## Generate the composer "vendor" folder ## usage: dm_generate_vendor function dm_generate_vendor() { local repo="$1" pushd "$repo" - composer install + ${DM_COMPOSER:-composer} install popd } @@ -206,11 +227,3 @@ function dm_git_checkout() { git checkout "$2" popd } - -## Install npm packages -## usage: dm_npm_install -function dm_npm_install() { - pushd "$1" - $DM_NPM install - popd -} diff --git a/distmaker/dists/drupal6_php5.sh b/distmaker/dists/drupal6_php5.sh index c6083d846d..1a7c7c5790 100755 --- a/distmaker/dists/drupal6_php5.sh +++ b/distmaker/dists/drupal6_php5.sh @@ -21,6 +21,7 @@ dm_generate_version "$TRG/civicrm-version.php" Drupal6 dm_install_core "$SRC" "$TRG" dm_install_packages "$SRC/packages" "$TRG/packages" dm_install_vendor "$SRC/vendor" "$TRG/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/bower_components" dm_install_drupal "$SRC/drupal" "$TRG/drupal" # gen tarball diff --git a/distmaker/dists/drupal_php5.sh b/distmaker/dists/drupal_php5.sh index dd421936ea..a090e31fd7 100755 --- a/distmaker/dists/drupal_php5.sh +++ b/distmaker/dists/drupal_php5.sh @@ -21,6 +21,7 @@ dm_generate_version "$TRG/civicrm-version.php" Drupal dm_install_core "$SRC" "$TRG" dm_install_packages "$SRC/packages" "$TRG/packages" dm_install_vendor "$SRC/vendor" "$TRG/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/bower_components" dm_install_drupal "$SRC/drupal" "$TRG/drupal" # gen tarball diff --git a/distmaker/dists/drupal_sk_php5.sh b/distmaker/dists/drupal_sk_php5.sh index c35d07b7e8..6c55a71335 100755 --- a/distmaker/dists/drupal_sk_php5.sh +++ b/distmaker/dists/drupal_sk_php5.sh @@ -21,6 +21,7 @@ dm_generate_version "$TRG/civicrm-version.php" Drupal dm_install_core "$SRC" "$TRG" dm_install_packages "$SRC/packages" "$TRG/packages" dm_install_vendor "$SRC/vendor" "$TRG/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/bower_components" dm_install_drupal "$SRC/drupal" "$TRG/drupal" # delete packages that distributions on Drupal.org repalce if present diff --git a/distmaker/dists/joomla_php5.sh b/distmaker/dists/joomla_php5.sh index 08ab281fdc..7c1a25b476 100755 --- a/distmaker/dists/joomla_php5.sh +++ b/distmaker/dists/joomla_php5.sh @@ -21,6 +21,7 @@ dm_generate_version "$TRG/civicrm-version.php" Joomla dm_install_core "$SRC" "$TRG" dm_install_packages "$SRC/packages" "$TRG/packages" dm_install_vendor "$SRC/vendor" "$TRG/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/bower_components" ## WTF: It's so good we'll install it twice! ## (The first is probably extraneous, but there could be bugs dependent on it.) diff --git a/distmaker/dists/wordpress_php5.sh b/distmaker/dists/wordpress_php5.sh index 1982e6a4f3..25bff97ff4 100644 --- a/distmaker/dists/wordpress_php5.sh +++ b/distmaker/dists/wordpress_php5.sh @@ -21,6 +21,7 @@ dm_generate_version "$TRG/civicrm/civicrm/civicrm-version.php" Wordpress dm_install_core "$SRC" "$TRG/civicrm/civicrm" dm_install_packages "$SRC/packages" "$TRG/civicrm/civicrm/packages" dm_install_vendor "$SRC/vendor" "$TRG/civicrm/civicrm/vendor" +dm_install_bower "$SRC/bower_components" "$TRG/civicrm/civicrm/bower_components" dm_install_wordpress "$SRC/WordPress" "$TRG/civicrm" # gen tarball -- 2.25.1