浏览代码

Merge branch 'master' of github.com:markshust/docker-magento

Mark Shust 5 年之前
父节点
当前提交
fd572df041
共有 3 个文件被更改,包括 46 次插入0 次删除
  1. 2 0
      README.md
  2. 1 0
      compose/bin/dev-urn-catalog-generate
  3. 43 0
      compose/bin/setup-grunt

+ 2 - 0
README.md

@@ -277,6 +277,7 @@ You'll now have an updated `bin/update` helper script, and can run it to update
 - `bin/root`: Run any CLI command as root without going into the bash prompt. Ex `bin/root apt-get install nano`
 - `bin/rootnotty`: Run any CLI command as root with no TTY. Ex `bin/rootnotty chown -R app:app /var/www/html`
 - `bin/setup`: Run the Magento setup process to install Magento from the source code, with optional domain name. Defaults to `magento2.test`. Ex. `bin/setup magento2.test`
+- `bin/setup-grunt`: Install and configure Grunt JavaScript task runner to compile .less files
 - `bin/setup-pwa-studio`: (BETA) Install PWA Studio (requires NodeJS and Yarn to be installed on the host machine). Pass in your base site domain, otherwise the default `master-7rqtwti-mfwmkrjfqvbjk.us-4.magentosite.cloud` will be used. Ex: `bin/setup-pwa-studio magento2.test`
 - `bin/setup-ssl`: Generate an SSL certificate for one or more domains. Ex. `bin/setup-ssl magento2.test magento3.test`
 - `bin/setup-ssl-ca`: Generate a certificate authority and copy it to the host.
@@ -325,6 +326,7 @@ Use the following lines to enable Redis on existing installs:
 `bin/magento setup:config:set --cache-backend=redis --cache-backend-redis-server=redis --cache-backend-redis-db=0`
 
 **Enable for Full Page Cache:**
+
 `bin/magento setup:config:set --page-cache=redis --page-cache-redis-server=redis --page-cache-redis-db=1`
 
 **Enable for Session:**

+ 1 - 0
compose/bin/dev-urn-catalog-generate

@@ -1,6 +1,7 @@
 #!/bin/bash
 bin/magento dev:urn-catalog:generate misc.xml
 bin/copyfromcontainer misc.xml
+bin/clinotty rm misc.xml
 
 REAL_SRC=$(cd -P "src" && pwd)
 

+ 43 - 0
compose/bin/setup-grunt

@@ -0,0 +1,43 @@
+#!/bin/bash
+DEFAULT_THEME_ID="select value from core_config_data where path = 'design/theme/theme_id'"
+THEME_PATH="select theme_path from theme where theme_id in ($DEFAULT_THEME_ID);"
+VENDOR_THEME=`bin/n98-magerun2 db:query "$THEME_PATH" | sed -n 2p | cut -d$'\r' -f1`
+THEME=`echo $VENDOR_THEME | cut -d'/' -f2`
+
+# Generate local-theme.js for custom theme
+read -d '' GEN_THEME_JS << EOM
+var fs = require('fs');
+var util = require('util');
+var theme = require('./dev/tools/grunt/configs/themes');
+
+theme['$THEME'] = {
+    area: 'frontend',
+    name: '$VENDOR_THEME',
+    locale: 'en_US',
+    files: [
+        'css/styles-m',
+        'css/styles-l'
+    ],
+    dsl: 'less'
+};
+fs.writeFileSync('./dev/tools/grunt/configs/local-themes.js', '"use strict"; module.exports = ' + util.inspect(theme), 'utf-8');
+EOM
+
+if [ -z "$VENDOR_THEME" ] || [ -z "$THEME" ]; then
+    echo "Using Magento/luma theme for grunt config"
+    THEME=luma
+    bin/clinotty cp ./dev/tools/grunt/configs/themes.js ./dev/tools/grunt/configs/local-themes.js
+else
+    echo "Using $VENDOR_THEME theme for grunt config"
+    bin/node -e "$GEN_THEME_JS"
+fi
+
+bin/clinotty cp package.json.sample package.json
+bin/clinotty cp Gruntfile.js.sample Gruntfile.js
+bin/clinotty cp grunt-config.json.sample grunt-config.json
+bin/npm install ajv@^5.0.0 --save
+bin/npm install
+bin/magento cache:clean
+bin/grunt clean
+bin/grunt exec:$THEME
+bin/grunt less:$THEME