2
0

setup-grunt 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. # Generate local-theme.js for custom theme
  7. read -r -d '' GEN_THEME_JS << EOM
  8. var fs = require('fs');
  9. var util = require('util');
  10. var theme = require('./dev/tools/grunt/configs/themes');
  11. theme['$THEME'] = {
  12. area: 'frontend',
  13. name: '$VENDOR_THEME',
  14. locale: 'en_US',
  15. files: [
  16. 'css/styles-m',
  17. 'css/styles-l'
  18. ],
  19. dsl: 'less'
  20. };
  21. fs.writeFileSync('./dev/tools/grunt/configs/local-themes.js', '"use strict"; module.exports = ' + util.inspect(theme), 'utf-8');
  22. EOM
  23. if [ -z "$VENDOR_THEME" ] || [ -z "$THEME" ]; then
  24. echo "Using Magento/luma theme for grunt config"
  25. THEME=luma
  26. bin/clinotty cp ./dev/tools/grunt/configs/themes.js ./dev/tools/grunt/configs/local-themes.js
  27. else
  28. echo "Using $VENDOR_THEME theme for grunt config"
  29. bin/node -e "$GEN_THEME_JS"
  30. fi
  31. bin/clinotty cp package.json.sample package.json
  32. bin/clinotty cp Gruntfile.js.sample Gruntfile.js
  33. bin/clinotty cp grunt-config.json.sample grunt-config.json
  34. bin/npm install ajv@^5.0.0 --save
  35. bin/npm install
  36. bin/magento cache:clean
  37. bin/grunt clean
  38. bin/grunt exec:$THEME
  39. bin/grunt less:$THEME