Переглянути джерело

Merge branch 'rangerz-cache-clean'

Mark Shust 3 роки тому
батько
коміт
46e19ec671

+ 0 - 1
README.md

@@ -255,7 +255,6 @@ It is recommended to keep your root docker config files in one repository, and y
 - `bin/copytocontainer`: Copy folders or files from host to container. Ex. `bin/copytocontainer --all`
 - `bin/dev-urn-catalog-generate`: Generate URN's for PHPStorm and remap paths to local host. Restart PHPStorm after running this command.
 - `bin/devconsole`: Alias for `bin/n98-magerun2 dev:console`
-- `bin/devtools-cli-check`: Check & install the CLI devtools if missing from system.
 - `bin/download`: Download specific Magento version from Composer to `/var/www/html` directory within the container. Ex. `bin/download 2.4.3 community`
 - `bin/fixowns`: This will fix filesystem ownerships within the container.
 - `bin/fixperms`: This will fix filesystem permissions within the container.

+ 23 - 1
compose/bin/cache-clean

@@ -1,2 +1,24 @@
 #!/bin/bash
-bin/cli /var/www/.composer-global/vendor/bin/cache-clean.js "$@"
+COMPOSER_GLOBAL=/var/www/.composer-global
+CACHE_CLEAN=${COMPOSER_GLOBAL}/vendor/bin/cache-clean.js
+
+if ! bin/cliq ls $CACHE_CLEAN; then
+  echo "Installing devtools metapackage, just a moment..."
+  bin/cliq mkdir -p ${COMPOSER_GLOBAL}
+  bin/composer init --working-dir=${COMPOSER_GLOBAL} --quiet --no-interaction
+  bin/composer require --working-dir=${COMPOSER_GLOBAL} --quiet markshust/magento2-metapackage-devtools-cli:^1.0
+  echo "Devtools installed."
+fi
+
+if [ "$1" == "--watch" ]; then
+  # Kill duplicate watch process
+  WATCH_PID=$(bin/clinotty ps -eaf | grep "$CACHE_CLEAN --quiet --watch" | grep -v grep | awk '{print $2}')
+  if [[ "" !=  "$WATCH_PID" ]]; then
+    bin/cliq kill -9 "$WATCH_PID"
+  fi
+
+  # Run watch mode in the background
+  bin/cliq $CACHE_CLEAN --quiet --watch &
+else
+  bin/cli $CACHE_CLEAN "$@"
+fi

+ 1 - 0
compose/bin/clinotty

@@ -1,3 +1,4 @@
 #!/bin/bash
 [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
+# -T: Disable pseudo-tty allocation
 docker-compose exec -T phpfpm "$@"

+ 2 - 1
compose/bin/cliq

@@ -1,3 +1,4 @@
 #!/bin/bash
 [ -z "$1" ] && echo "Please specify a CLI command (ex. ls)" && exit
-bin/clinotty "$@" >/dev/null
+# Without stdout and stderr
+bin/clinotty "$@" >/dev/null 2>&1

+ 0 - 7
compose/bin/devtools-cli-check

@@ -1,7 +0,0 @@
-#!/bin/bash
-if ! bin/clinotty ls /var/www/.composer-global/vendor/bin/cache-clean.js 1> /dev/null 2>&1; then
-  echo "Installing devtools metapackage, just a moment..."
-  bin/cliq mkdir -p /var/www/.composer-global
-  bin/composer require --working-dir=/var/www/.composer-global --quiet markshust/magento2-metapackage-devtools-cli:^1.0
-  echo "Devtools installed."
-fi

+ 11 - 4
compose/bin/n98-magerun2

@@ -1,7 +1,14 @@
 #!/bin/bash
-if ! bin/clinotty ls bin/n98-magerun2.phar 1> /dev/null 2>&1; then
-  bin/clinotty mkdir -p bin
-  bin/clinotty curl https://files.magerun.net/n98-magerun2.phar -o bin/n98-magerun2.phar
-  bin/clinotty chmod +x bin/n98-magerun2.phar
+if ! bin/cliq ls bin/n98-magerun2.phar; then
+  echo "Downloading n98-magerun2.phar, just a moment..."
+  bin/clinotty curl -sS -O https://files.magerun.net/n98-magerun2.phar
+  bin/clinotty curl -sS -o n98-magerun2.phar.sha256 https://files.magerun.net/sha256.php?file=n98-magerun2.phar
+  bin/clinotty shasum -a 256 -c n98-magerun2.phar.sha256
+  [ $? != 0 ] && echo "sha256 checksum do not match!" && exit
+
+  bin/cliq chmod +x n98-magerun2.phar
+  bin/cliq mkdir -p bin
+  bin/cliq mv n98-magerun2.phar bin
 fi
+
 bin/cli bin/n98-magerun2.phar "$@"

+ 1 - 2
compose/bin/start

@@ -57,5 +57,4 @@ docker-compose -f docker-compose.yml -f docker-compose.dev.yml up -d --remove-or
 ## Then uncomment the below line (and leave uncommented) to start the agent automatically with bin/start:
 #bin/root /etc/init.d/blackfire-agent start
 
-bin/devtools-cli-check
-bin/cliq /var/www/.composer-global/vendor/bin/cache-clean.js --quiet --watch &
+bin/cache-clean --watch