setup-grunt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #!/bin/bash
  2. DEFAULT_THEME_ID="select value from core_config_data where path = 'design/theme/theme_id'"
  3. THEME_PATH="select theme_path from theme where theme_id in ($DEFAULT_THEME_ID);"
  4. VENDOR_THEME=$(bin/n98-magerun2 db:query "$THEME_PATH" | sed -n 2p | cut -d$'\r' -f1)
  5. THEME=$(echo "$VENDOR_THEME" | cut -d'/' -f2)
  6. LOCALE_CODE=$(bin/magento config:show general/locale/code | cut -d$'\r' -f1 | sed 's/ *$//g')
  7. # Generate local-theme.js for custom theme
  8. read -r -d '' GEN_THEME_JS << EOM
  9. var fs = require('fs');
  10. var util = require('util');
  11. var theme = require('./dev/tools/grunt/configs/themes');
  12. theme['$THEME'] = {
  13. area: 'frontend',
  14. name: '$VENDOR_THEME',
  15. locale: '$LOCALE_CODE',
  16. files: [
  17. 'css/styles-m',
  18. 'css/styles-l'
  19. ],
  20. dsl: 'less'
  21. };
  22. fs.writeFileSync('./dev/tools/grunt/configs/local-themes.js', '"use strict"; module.exports = ' + util.inspect(theme), 'utf-8');
  23. EOM
  24. if [ -z "$VENDOR_THEME" ] || [ -z "$THEME" ]; then
  25. echo "Using Magento/luma theme for grunt config"
  26. THEME=luma
  27. bin/clinotty cp ./dev/tools/grunt/configs/themes.js ./dev/tools/grunt/configs/local-themes.js
  28. else
  29. echo "Using $VENDOR_THEME theme for grunt config"
  30. bin/node -e "$GEN_THEME_JS"
  31. fi
  32. bin/clinotty cp package.json.sample package.json
  33. bin/clinotty cp Gruntfile.js.sample Gruntfile.js
  34. bin/clinotty cp grunt-config.json.sample grunt-config.json
  35. bin/npm install ajv@^5.0.0 --save
  36. bin/npm install
  37. bin/magento cache:clean
  38. bin/grunt clean
  39. bin/grunt exec:$THEME
  40. bin/grunt less:$THEME