-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fea(run): bin/console polyfill for PS 1.6 to auto-install modules (#116)
- Loading branch information
1 parent
4319176
commit 1745eee
Showing
14 changed files
with
137 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/local/bin/php -d memory_limit=-1 | ||
<?php | ||
if (!defined('_PS_ADMIN_DIR_')) { define('_PS_ADMIN_DIR_', '/admin-dev'); } | ||
if (!defined('_PS_MODE_DEV_')) { define('_PS_MODE_DEV_', true); } | ||
$rootDirectory = getenv('_PS_ROOT_DIR_') ?: '/var/www/html'; | ||
require_once $rootDirectory . '/config/config.inc.php'; | ||
|
||
function getModuleName($args) { | ||
for ($i = 0; $i < count($args); $i++) { | ||
if ($args[$i] === 'install') { | ||
if (isset($args[$i + 1])) { | ||
return $args[$i + 1]; | ||
} | ||
} | ||
} | ||
throw new Exception('Module name not found'); | ||
} | ||
|
||
function installModule($args) { | ||
$moduleName = getModuleName($args); | ||
if (version_compare(_PS_VERSION_, '1.7', '>=')) { | ||
global $kernel; | ||
if(!$kernel){ | ||
require_once _PS_ROOT_DIR_.'/app/AppKernel.php'; | ||
$kernel = new \AppKernel('dev', true); | ||
$kernel->boot(); | ||
} | ||
} | ||
$module = Module::getInstanceByName($moduleName); | ||
$module->install(); | ||
} | ||
|
||
function clearCache() { | ||
$cacheDirs = [ | ||
_PS_CACHEFS_DIRECTORY_ . '/smarty/compile', | ||
_PS_CACHEFS_DIRECTORY_ . '/smarty/cache', | ||
_PS_IMG_DIR_ . '/tmp', | ||
]; | ||
foreach ($cacheDirs as $dir) { | ||
$files = glob($dir . '/*'); | ||
foreach ($files as $file) { | ||
if (is_file($file)) { | ||
unlink($file); | ||
} | ||
} | ||
} | ||
} | ||
|
||
switch ($argv[1]) { | ||
case 'prestashop:module': | ||
installModule($argv); | ||
break; | ||
case 'cache:clear': | ||
clearCache(); | ||
break; | ||
default: | ||
throw new Exception('This command is not supported by prestashop-flashlight\'s polyfill'); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,42 @@ | ||
#!/bin/sh | ||
set -eu | ||
PRESTASHOP_TAGS=.prestashop-tags | ||
PRESTASHOP_MINOR_TAGS=.prestashop-minor-tags | ||
|
||
get_prestashop_tags() { | ||
git ls-remote --tags [email protected]:PrestaShop/PrestaShop.git \ | ||
| cut -f2 \ | ||
| grep -Ev '\/1.5|\/1.6.0|beta|rc|RC|\^' \ | ||
| cut -d '/' -f3 \ | ||
| sort -r -V > "$PRESTASHOP_TAGS" | ||
} | ||
|
||
get_prestashop_minor_tags() { | ||
printf "" > "$PRESTASHOP_MINOR_TAGS" | ||
while IFS= read -r version; do | ||
major_minor=$(echo "$version" | cut -d. -f1-2) | ||
major_minor_patch=$(echo "$version" | cut -d. -f1-3) | ||
criteria=$major_minor | ||
# shellcheck disable=SC3010 | ||
[[ "$major_minor" == 1* ]] && criteria=$major_minor_patch | ||
if ! grep -q "^$criteria" "$PRESTASHOP_MINOR_TAGS"; then | ||
echo "$version" >> "$PRESTASHOP_MINOR_TAGS" | ||
fi | ||
done < "$PRESTASHOP_TAGS" | ||
} | ||
EXCLUDED_TAGS='\/1.5|\/1.6.0|alpha|beta|rc|RC|\^' | ||
PRESTASHOP_TAGS=$(git ls-remote --tags [email protected]:PrestaShop/PrestaShop.git | cut -f2 | grep -Ev $EXCLUDED_TAGS | cut -d '/' -f3 | sort -r -V) | ||
# PRESTASHOP_MAJOR_TAGS=$( | ||
# MAJOR_TAGS="" | ||
# for VERSION in $PRESTASHOP_TAGS; do | ||
# CRITERIA=$(echo "$VERSION" | cut -d. -f1) | ||
# # shellcheck disable=SC3010 | ||
# if [[ "$CRITERIA" == 1* ]]; then | ||
# CRITERIA=$(echo "$VERSION" | cut -d. -f1-2) | ||
# fi | ||
# if ! echo "$MAJOR_TAGS" | grep -q "^$CRITERIA"; then | ||
# MAJOR_TAGS="$MAJOR_TAGS\n$VERSION"; | ||
# fi | ||
# done | ||
# echo "$MAJOR_TAGS" | ||
# ) | ||
# PRESTASHOP_MINOR_TAGS=$( | ||
# MINOR_TAGS="" | ||
# for VERSION in $PRESTASHOP_TAGS; do | ||
# CRITERIA=$(echo "$VERSION" | cut -d. -f1-2) | ||
# # shellcheck disable=SC3010 | ||
# if [[ "$CRITERIA" == 1* ]]; then | ||
# CRITERIA=$(echo "$VERSION" | cut -d. -f1-3) | ||
# fi | ||
# if ! echo "$MINOR_TAGS" | grep -q "^$CRITERIA"; then | ||
# MINOR_TAGS="$MINOR_TAGS\n$VERSION"; | ||
# fi | ||
# done | ||
# echo "$MINOR_TAGS" | ||
# ) | ||
|
||
get_compatible_php_version() { | ||
REGEXP_LIST=$(jq -r 'keys_unsorted | .[]' <prestashop-versions.json) | ||
REGEXP_LIST=$(echo "$PRESTASHOP_TAGS" | jq -r 'keys_unsorted | .[]') | ||
while IFS= read -r regExp; do | ||
# shellcheck disable=SC3010 | ||
if [[ $1 =~ $regExp ]]; then | ||
jq -r '."'"${regExp}"'".php.compatible[]' <prestashop-versions.json | ||
echo "$PRESTASHOP_TAGS" | jq -r '."'"${regExp}"'".php.compatible[]' | ||
break; | ||
fi | ||
done <<EOF | ||
|
@@ -44,30 +50,21 @@ publish() { | |
--field target_platforms=linux/amd64,linux/arm64 "$@" | ||
} | ||
|
||
get_prestashop_tags | ||
get_prestashop_minor_tags | ||
|
||
# Latest | ||
publish --field ps_version=latest | ||
publish --field ps_version=latest --field os_flavour=debian | ||
|
||
# Recommended PHP for some minor tag | ||
# while IFS= read -r PS_VERSION; do | ||
# publish --field ps_version="$PS_VERSION" | ||
# publish --field ps_version="$PS_VERSION" --field os_flavour=debian | ||
# done < "$PRESTASHOP_MINOR_TAGS" | ||
|
||
# Recommended PHP for every tag | ||
while IFS= read -r PS_VERSION; do | ||
# Build & publish every prestashop version with recommended PHP version | ||
for PS_VERSION in $PRESTASHOP_TAGS; do | ||
publish --field ps_version="$PS_VERSION" | ||
publish --field ps_version="$PS_VERSION" --field os_flavour=debian | ||
done < "$PRESTASHOP_TAGS" | ||
done | ||
|
||
# Compatible PHP for every minor tag (alpine only) | ||
# while IFS= read -r PS_VERSION; do | ||
# Build & publish every prestashop minor version with all compatible PHP versions (alpine only) | ||
# for PS_VERSION in $PRESTASHOP_MINOR_TAGS; do | ||
# while IFS= read -r PHP_VERSION; do | ||
# publish --field ps_version="$PS_VERSION" --field php_version="$PHP_VERSION" | ||
# done <<EOF | ||
# $(get_compatible_php_version "$PS_VERSION") | ||
# EOF | ||
# done < "$PRESTASHOP_MINOR_TAGS" | ||
# done |